target: Use ArchCPU & CPUArchState as abstract interface to target CPU
Subsystems (2)
cover target: Use ArchCPU & CPUArchState as abstract interface to target CPU
Hi Richard,
Kind of respin of the "exec: Move translation declarations to 'translate-all.h'" series, but without modifying translate-all.h :) (same same but different).
Last patches are RFC, not sure worthwhile (at least for now).
Based-on: <[email protected]> "exec: Remove 'qemu/log.h' from 'exec-all.h'"
Philippe Mathieu-Daudé (15):
meson: Display libfdt as disabled when system emulation is disabled hw/m68k/mcf: Add missing 'exec/hwaddr.h' header hw/tricore: Remove unused and incorrect header exec/cpu_ldst: Include 'cpu.h' to get target_ulong definition
cpu: Add missing 'exec/exec-all.h' and 'qemu/accel.h' headers target/i386/cpu: Ensure accelerators set CPU addressble physical bits target/i386/tcg/sysemu: Include missing 'exec/exec-all.h' header
target: Include missing 'cpu.h'
target: Use forward declared type instead of structure type
target: Use CPUArchState as interface to target-specific CPU state
target: Use ArchCPU as interface to target CPU
hw/m68k: Restrict M68kCPU type to target/ code
hw/mips: Restrict MIPSCPU type to target/ code
hw/sparc: Restrict SPARCCPU type to target/ code
hw/sh4: Restrict SuperHCPU type to target/ code
cpu.c | 2 ++ include/exec/cpu_ldst.h | 1 + include/exec/poison.h | 2 -- include/hw/core/cpu.h | 2 +- include/hw/m68k/mcf.h | 4 ++-- include/hw/mips/cpudevs.h | 6 ++---- include/hw/sh4/sh.h | 3 +-- include/hw/sparc/sparc64.h | 4 +--- include/hw/tricore/triboard.h | 1 - include/qemu/typedefs.h | 2 ++ meson.build | 4 +++- target/alpha/cpu-qom.h | 4 +++- target/alpha/cpu.h | 11 +++-------- target/arm/cpu-qom.h | 4 +++- target/arm/cpu.h | 5 +---- target/arm/hvf_arm.h | 2 +- target/avr/cpu-qom.h | 4 +++- target/avr/cpu.h | 13 ++++--------- target/cris/cpu-qom.h | 4 +++- target/cris/cpu.h | 7 ++----- target/hexagon/cpu.h | 10 +++------- target/hppa/cpu-qom.h | 4 +++- target/hppa/cpu.h | 12 +++--------- target/i386/cpu-qom.h | 4 +++- target/i386/cpu.c | 1 + target/i386/cpu.h | 7 ++----- target/i386/tcg/sysemu/excp_helper.c | 1 + target/i386/tcg/sysemu/misc_helper.c | 1 + target/m68k/cpu-qom.h | 2 +- target/m68k/cpu.h | 9 +++------ target/microblaze/cpu-qom.h | 4 +++- target/microblaze/cpu.h | 11 +++++------ target/microblaze/mmu.h | 2 ++ target/mips/cpu-qom.h | 2 +- target/mips/cpu.h | 12 ++++-------- target/mips/internal.h | 15 ++++++++------- target/nios2/cpu.h | 8 ++++---- target/nios2/mmu.h | 2 ++ target/openrisc/cpu.h | 18 +++++++----------- target/ppc/cpu-qom.h | 6 ++++-- target/ppc/cpu.h | 7 ++----- target/riscv/cpu.h | 10 ++++------ target/riscv/pmp.h | 2 ++ target/rx/cpu-qom.h | 6 +++--- target/rx/cpu.h | 6 ++---- target/s390x/cpu-qom.h | 8 +++++--- target/s390x/cpu.h | 7 ++----- target/sh4/cpu-qom.h | 2 +- target/sh4/cpu.h | 9 +++------ target/sparc/cpu-qom.h | 2 +- target/sparc/cpu.h | 11 ++++------- target/tricore/cpu-qom.h | 4 +++- target/tricore/cpu.h | 10 +++------- target/xtensa/cpu-qom.h | 4 +++- target/xtensa/cpu.h | 13 +++++-------- 55 files changed, 142 insertions(+), 175 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/15 meson: Display libfdt as disabled when system emulation is disabled
When configuring QEMU with --disable-system, meson keeps showing libfdt as "auto". Mark it as disabled instead.
--- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meson.build +3 -1
@@ -2271,8 +2271,8 @@ if get_option('cfi') and slirp_opt == 'system' endif fdt = not_found -fdt_opt = get_option('fdt') if have_system + fdt_opt = get_option('fdt') if fdt_opt in ['enabled', 'auto', 'system'] have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt') fdt = cc.find_library('fdt', kwargs: static_kwargs,
@@ -2315,6 +2315,8 @@ if have_system fdt = declare_dependency(link_with: libfdt, include_directories: fdt_inc) endif +else + fdt_opt = 'disabled' endif if not fdt.found() and fdt_required.length() > 0 error('fdt not available but required by targets ' + ', '.join(fdt_required))
Signature · 1 line
2.34.1
PATCH 2/15 hw/m68k/mcf: Add missing 'exec/hwaddr.h' header
In reply to Philippe Mathieu-Daudé viahwaddr type is defined in "exec/hwaddr.h".
--- include/hw/m68k/mcf.h | 1 + 1 file changed, 1 insertion(+)
include/hw/m68k/mcf.h +1 -0
@@ -2,6 +2,7 @@#define HW_MCF_H /* Motorola ColdFire device prototypes. */ +#include "exec/hwaddr.h" #include "target/m68k/cpu-qom.h" /* mcf_uart.c */
Signature · 1 line
2.34.1
Re: [PATCH 02/15] hw/m68k/mcf: Add missing 'exec/hwaddr.h' header
Quoted 6 lines · Philippe Mathieu-Daudé
hwaddr type is defined in "
exec/hwaddr.h".Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/m68k/mcf.h | 1 + 1 file changed, 1 insertion(+)
r~
Re: [PATCH 02/15] hw/m68k/mcf: Add missing 'exec/hwaddr.h' header
In reply to Philippe Mathieu-Daudé viaQuoted 12 lines · Philippe Mathieu-Daudé
hwaddr type is defined in "
exec/hwaddr.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/m68k/mcf.h | 1 + 1 file changed, 1 insertion(+)include/hw/m68k/mcf.h +0
-0
include/hw/m68k/mcf.h line 8
Quoted 7 lines
include/hw/m68k/mcf.h +1
-0@@ -2,6 +2,7 @@#define HW_MCF_H /* Motorola ColdFire device prototypes. */ +#include "exec/hwaddr.h" #include "target/m68k/cpu-qom.h" /* mcf_uart.c */
PATCH 3/15 hw/tricore: Remove unused and incorrect header
In reply to Philippe Mathieu-Daudé viaTriCore boards certainly don't need the ARM loader API :)
--- include/hw/tricore/triboard.h | 1 - 1 file changed, 1 deletion(-)
include/hw/tricore/triboard.h +0 -1
@@ -21,7 +21,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/boards.h" -#include "hw/arm/boot.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" #include "qom/object.h"
Signature · 1 line
2.34.1
Re: [PATCH 03/15] hw/tricore: Remove unused and incorrect header
Quoted 6 lines · Philippe Mathieu-Daudé
TriCore boards certainly don't need the ARM loader API :)
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/tricore/triboard.h | 1 - 1 file changed, 1 deletion(-)
r~
Re: [PATCH 03/15] hw/tricore: Remove unused and incorrect header
In reply to Philippe Mathieu-Daudé viaQuoted 12 lines · Philippe Mathieu-Daudé
TriCore boards certainly don't need the ARM loader API :)
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/tricore/triboard.h | 1 - 1 file changed, 1 deletion(-)include/hw/tricore/triboard.h +0
-0
include/hw/tricore/triboard.h line 26
Quoted 7 lines
include/hw/tricore/triboard.h +0
-1@@ -21,7 +21,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/boards.h" -#include "hw/arm/boot.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" #include "qom/object.h"
PATCH 4/15 exec/cpu_ldst: Include 'cpu.h' to get target_ulong definition
In reply to Philippe Mathieu-Daudé via--- include/exec/cpu_ldst.h | 1 + 1 file changed, 1 insertion(+)
include/exec/cpu_ldst.h +1 -0
@@ -64,6 +64,7 @@#include "exec/memopidx.h" #include "qemu/int128.h" +#include "cpu.h" #if defined(CONFIG_USER_ONLY )/* sparc32plus has 64bit long but 32bit space address
Signature · 1 line
2.34.1
PATCH 5/15 cpu: Add missing 'exec/exec-all.h' and 'qemu/accel.h' headers
In reply to Philippe Mathieu-Daudé viacpu.c requires "exec/exec-all.h" to call tlb_flush() and "qemu/accel.h" to call accel_cpu_realizefn().
--- cpu.c | 2 ++ 1 file changed, 2 insertions(+)
cpu.c +2 -0
@@ -35,10 +35,12 @@#include "sysemu/tcg.h" #include "sysemu/kvm.h" #include "sysemu/replay.h" +#include "exec/exec-all.h" #include "exec/translate-all.h" #include "exec/log.h" #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" +#include "qemu/accel.h" uintptr_t qemu_host_page_size;intptr_t qemu_host_page_mask;
Signature · 1 line
2.34.1
PATCH 6/15 target/i386/cpu: Ensure accelerators set CPU addressble physical bits
In reply to Philippe Mathieu-Daudé viaThe only accelerator allowed to use zero as default value is TCG.
--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/i386/cpu.c +1 -0
@@ -6384,6 +6384,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)* In this case, the default is the value used by TCG (40). */ if (cpu->phys_bits ==0 ) { +assert (tcg_enabled ()); cpu->phys_bits =TCG_PHYS_ADDR_BITS ; } }else {
Signature · 1 line
2.34.1
PATCH 7/15 target/i386/tcg/sysemu: Include missing 'exec/exec-all.h' header
In reply to Philippe Mathieu-Daudé viaexcp_helper.c requires "exec/exec-all.h" for tlb_set_page_with_attrs() and misc_helper.c for tlb_flush().
--- target/i386/tcg/sysemu/excp_helper.c | 1 + target/i386/tcg/sysemu/misc_helper.c | 1 + 2 files changed, 2 insertions(+)
target/i386/tcg/sysemu/excp_helper.c +1 -0
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" #include "tcg/helper-tcg.h" int get_pg_mode (CPUX86State *env)
target/i386/tcg/sysemu/misc_helper.c +1 -0
@@ -23,6 +23,7 @@#include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" +#include "exec/exec-all.h" #include "tcg/helper-tcg.h" void helper_outb (CPUX86State *env,uint32_t port,uint32_t data)
Signature · 1 line
2.34.1
PATCH 8/15 target: Include missing 'cpu.h'
In reply to Philippe Mathieu-Daudé viaThese target-specific files use the target-specific CPU state but lack to include "cpu.h"; i.e.:
../target/riscv/pmp.h:61:23: error: unknown type name 'CPURISCVState'
void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index,
^
../target/nios2/mmu.h:43:18: error: unknown type name 'CPUNios2State'
void mmu_flip_um(CPUNios2State *env, unsigned int um);
^
../target/microblaze/mmu.h:88:19: error: unknown type name 'CPUMBState'; did you mean 'CPUState'?
uint32_t mmu_read(CPUMBState *env, bool ea, uint32_t rn);
^~~~~~~~~~
CPUState--- target/microblaze/mmu.h | 2 ++ target/mips/internal.h | 1 + target/nios2/mmu.h | 2 ++ target/riscv/pmp.h | 2 ++ 4 files changed, 7 insertions(+)
target/microblaze/mmu.h +2 -0
@@ -20,6 +20,8 @@#ifndef TARGET_MICROBLAZE_MMU_H #define TARGET_MICROBLAZE_MMU_H +#include "cpu.h" +#define MMU_R_PID 0#define MMU_R_ZPR 1#define MMU_R_TLBX 2
target/mips/internal.h +1 -0
@@ -12,6 +12,7 @@#ifdef CONFIG_TCG #include "tcg/tcg-internal.h" #endif +#include "cpu.h" /* * MMU types, the first four entries have the same layout as the
target/nios2/mmu.h +2 -0
@@ -21,6 +21,8 @@ #ifndef NIOS2_MMU_H #define NIOS2_MMU_H +#include "cpu.h" + typedef struct Nios2TLBEntry { target_ulong tag; target_ulong data;
target/riscv/pmp.h +2 -0
@@ -22,6 +22,8 @@ #ifndef RISCV_PMP_H #define RISCV_PMP_H +#include "cpu.h" + typedef enum { PMP_READ = 1 << 0, PMP_WRITE = 1 << 1,
Signature · 1 line
2.34.1
PATCH 9/15 target: Use forward declared type instead of structure type
In reply to Philippe Mathieu-Daudé viaThe CPU / CPU state are forward declared.
$ git grep -E 'struct [A-Za-z]+CPU\ \*' target/arm/hvf_arm.h:16:void hvf_arm_set_cpu_features_from_host(struct ARMCPU *cpu); target/openrisc/cpu.h:234: int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, target/openrisc/cpu.h:238: int (*cpu_openrisc_map_address_data)(struct OpenRISCCPU *cpu,
$ git grep -E 'struct CPU[A-Za-z]+State\ \*' target/mips/internal.h:137: int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *prot, target/mips/internal.h:139: void (*helper_tlbwi)(struct CPUMIPSState *env); target/mips/internal.h:140: void (*helper_tlbwr)(struct CPUMIPSState *env); target/mips/internal.h:141: void (*helper_tlbp)(struct CPUMIPSState *env); target/mips/internal.h:142: void (*helper_tlbr)(struct CPUMIPSState *env); target/mips/internal.h:143: void (*helper_tlbinv)(struct CPUMIPSState *env); target/mips/internal.h:144: void (*helper_tlbinvf)(struct CPUMIPSState *env); target/xtensa/cpu.h:347: struct CPUXtensaState *env;
--- target/arm/hvf_arm.h | 2 +- target/mips/internal.h | 14 +++++++------- target/openrisc/cpu.h | 4 ++-- target/xtensa/cpu.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-)
target/arm/hvf_arm.h +1 -1
@@ -13,6 +13,6 @@#include "cpu.h" -void hvf_arm_set_cpu_features_from_host (struct ARMCPU *cpu); +void hvf_arm_set_cpu_features_from_host (ARMCPU *cpu);#endif
target/mips/internal.h +7 -7
@@ -134,14 +134,14 @@ struct r4k_tlb_t { struct CPUMIPSTLBContext { uint32_t nb_tlb; uint32_t tlb_in_use; - int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *prot, + int (*map_address)(CPUMIPSState *env, hwaddr *physical, int *prot, target_ulong address, MMUAccessType access_type); - void (*helper_tlbwi)(struct CPUMIPSState *env); - void (*helper_tlbwr)(struct CPUMIPSState *env); - void (*helper_tlbp)(struct CPUMIPSState *env); - void (*helper_tlbr)(struct CPUMIPSState *env); - void (*helper_tlbinv)(struct CPUMIPSState *env); - void (*helper_tlbinvf)(struct CPUMIPSState *env); + void (*helper_tlbwi)(CPUMIPSState *env); + void (*helper_tlbwr)(CPUMIPSState *env); + void (*helper_tlbp)(CPUMIPSState *env); + void (*helper_tlbr)(CPUMIPSState *env); + void (*helper_tlbinv)(CPUMIPSState *env); + void (*helper_tlbinvf)(CPUMIPSState *env); union { struct { r4k_tlb_t tlb[MIPS_TLB_MAX];
target/openrisc/cpu.h +2 -2
@@ -231,11 +231,11 @@ typedef struct CPUOpenRISCTLBContext {OpenRISCTLBEntry itlb[TLB_SIZE ];OpenRISCTLBEntry dtlb[TLB_SIZE ]; -int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, +int (*cpu_openrisc_map_address_code)(OpenRISCCPU *cpu,hwaddr *physical,int *prot,target_ulong address,int rw); -int (*cpu_openrisc_map_address_data)(struct OpenRISCCPU *cpu, +int (*cpu_openrisc_map_address_data)(OpenRISCCPU *cpu,hwaddr *physical,int *prot,target_ulong address,int rw);
target/xtensa/cpu.h +1 -1
@@ -344,7 +344,7 @@ typedef struct XtensaGdbRegmap { } XtensaGdbRegmap;typedef struct XtensaCcompareTimer { -struct CPUXtensaState *env; +CPUXtensaState *env;QEMUTimer *timer; }XtensaCcompareTimer ;
Signature · 1 line
2.34.1
PATCH 10/15 target: Use CPUArchState as interface to target-specific CPU state
In reply to Philippe Mathieu-Daudé viaWhile CPUState is our interface with generic code, CPUArchState is our interface with target-specific code. Use CPUArchState as an abstract type, defined by each target.
--- include/exec/poison.h | 2 -- include/hw/core/cpu.h | 2 +- include/qemu/typedefs.h | 1 + target/alpha/cpu.h | 7 ++----- target/arm/cpu.h | 3 +-- target/avr/cpu.h | 7 ++----- target/cris/cpu.h | 3 +-- target/hexagon/cpu.h | 8 ++------ target/hppa/cpu.h | 8 ++------ target/i386/cpu.h | 3 +-- target/m68k/cpu.h | 3 +-- target/microblaze/cpu.h | 5 ++--- target/mips/cpu.h | 6 ++---- target/nios2/cpu.h | 4 ++-- target/openrisc/cpu.h | 3 +-- target/ppc/cpu-qom.h | 2 +- target/ppc/cpu.h | 3 +-- target/riscv/cpu.h | 5 ++--- target/rx/cpu-qom.h | 2 -- target/rx/cpu.h | 2 +- target/s390x/cpu-qom.h | 4 ++-- target/s390x/cpu.h | 3 +-- target/sh4/cpu.h | 3 +-- target/sparc/cpu.h | 5 ++--- target/tricore/cpu.h | 6 ++---- target/xtensa/cpu.h | 7 +++---- 26 files changed, 37 insertions(+), 70 deletions(-)
include/exec/poison.h +0 -2
@@ -51,8 +51,6 @@#pragma GCC poison TARGET_PAGE_BITS#pragma GCC poison TARGET_PAGE_ALIGN -#pragma GCC poison CPUArchState -#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB#pragma GCC poison CPU_INTERRUPT_HALT
include/hw/core/cpu.h +1 -1
@@ -340,7 +340,7 @@ struct CPUState {AddressSpace *as;MemoryRegion *memory; -void *env_ptr;/* CPUArchState */ +CPUArchState *env_ptr;IcountDecr *icount_decr_ptr;/* Accessed in parallel; all accesses must be atomic */
include/qemu/typedefs.h +1 -0
@@ -39,6 +39,7 @@ typedef struct CompatProperty CompatProperty;typedef struct CoMutex CoMutex ;typedef struct ConfidentialGuestSupport ConfidentialGuestSupport ;typedef struct CPUAddressSpace CPUAddressSpace ; +typedef struct CPUArchState CPUArchState ;typedef struct CPUState CPUState ;typedef struct DeviceListener DeviceListener ;typedef struct DeviceState DeviceState ;
target/alpha/cpu.h +2 -5
@@ -197,9 +197,7 @@ enum {#define MMU_USER_IDX 1#define MMU_PHYS_IDX 2 -typedef struct CPUAlphaState CPUAlphaState ; - -struct CPUAlphaState { +typedef struct CPUArchState { uint64_t ir[31]; float64 fir[31]; uint64_t pc;
@@ -251,7 +249,7 @@ struct CPUAlphaState {uint32_t features;uint32_t amask;int implver; -}; +} CPUAlphaState;/** * AlphaCPU:
@@ -285,7 +283,6 @@ int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);#define cpu_list alpha_cpu_list -typedef CPUAlphaState CPUArchState ;typedef AlphaCPU ArchCPU ;#include "exec/cpu-all.h"
target/arm/cpu.h +1 -2
@@ -232,7 +232,7 @@ typedef struct CPUARMTBFlags {target_ulong flags2; } CPUARMTBFlags; -typedef struct CPUARMState { +typedef struct CPUArchState { /* Regs for current mode. */ uint32_t regs[16];
@@ -3410,7 +3410,6 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) } } -typedef CPUARMState CPUArchState ;typedef ARMCPU ArchCPU ;#include "exec/cpu-all.h"
target/avr/cpu.h +2 -5
@@ -108,9 +108,7 @@ typedef enum AVRFeature {AVR_FEATURE_RAMPZ , } AVRFeature; -typedef struct CPUAVRState CPUAVRState ; - -struct CPUAVRState { +typedef struct CPUArchState { uint32_t pc_w; /* 0x003fffff up to 22 bits */ uint32_t sregC; /* 0x00000001 1 bit */
@@ -137,7 +135,7 @@ struct CPUAVRState {bool fullacc;/* CPU/MEM if true MEM only otherwise */ uint64_t features; -}; +} CPUAVRState;/** * AVRCPU:
@@ -247,7 +245,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); -typedef CPUAVRState CPUArchState ;typedef AVRCPU ArchCPU ;#include "exec/cpu-all.h"
target/cris/cpu.h +1 -2
@@ -105,7 +105,7 @@ typedef struct {uint32_t lo; } TLBSet; -typedef struct CPUCRISState { +typedef struct CPUArchState { uint32_t regs[16]; /* P0 - P15 are referred to as special registers in the docs. */ uint32_t pregs[16];
@@ -265,7 +265,6 @@ static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)#define SFR_RW_MM_TLB_LO env->pregs[PR_SRS]][5#define SFR_RW_MM_TLB_HI env->pregs[PR_SRS]][6 -typedef CPUCRISState CPUArchState ;typedef CRISCPU ArchCPU ;#include "exec/cpu-all.h"
target/hexagon/cpu.h +2 -6
@@ -18,9 +18,6 @@#ifndef HEXAGON_CPU_H #define HEXAGON_CPU_H -/* Forward declaration needed by some of the header files */ -typedef struct CPUHexagonState CPUHexagonState ; -#include "fpu/softfloat-types.h" #include "exec/cpu-defs.h"
@@ -75,7 +72,7 @@ typedef struct {/* Maximum number of vector temps in a packet */ #define VECTOR_TEMPS_MAX 4 -struct CPUHexagonState { +typedef struct CPUArchState { target_ulong gpr[TOTAL_PER_THREAD_REGS]; target_ulong pred[NUM_PREGS]; target_ulong branch_taken;
@@ -129,7 +126,7 @@ struct CPUHexagonState {target_ulong vstore_pending[VSTORES_MAX ];bool vtcm_pending;VTCMStoreLog vtcm_log; -}; +} CPUHexagonState;#define HEXAGON_CPU_CLASS (klass) \ OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
@@ -180,7 +177,6 @@ static inline int cpu_mmu_index(CPUHexagonState *env, bool ifetch)#endif } -typedef struct CPUHexagonState CPUArchState ;typedef HexagonCPU ArchCPU ;void hexagon_translate_init (void );
target/hppa/cpu.h +2 -6
@@ -138,8 +138,6 @@#define CR_IPSW 22#define CR_EIRR 23 -typedef struct CPUHPPAState CPUHPPAState ; -#if TARGET_REGISTER_BITS ==32 typedef uint32_t target_ureg ;typedef int32_t target_sreg ;
@@ -168,7 +166,7 @@ typedef struct { unsigned access_id : 16; } hppa_tlb_entry; -struct CPUHPPAState { +typedef struct CPUArchState { target_ureg gr[32]; uint64_t fr[32]; uint64_t sr[8]; /* stored shifted into place for gva */
@@ -207,7 +205,7 @@ struct CPUHPPAState {/* ??? We should use a more intelligent data structure. */ hppa_tlb_entry tlb[HPPA_TLB_ENTRIES ];uint32_t tlb_last; -}; +} CPUHPPAState;/** * HPPACPU:
@@ -225,8 +223,6 @@ struct HPPACPU {QEMUTimer *alarm_timer; }; - -typedef CPUHPPAState CPUArchState ;typedef HPPACPU ArchCPU ;#include "exec/cpu-all.h"
target/i386/cpu.h +1 -2
@@ -1429,7 +1429,7 @@ typedef struct HVFX86LazyFlags {target_ulong auxbits; } HVFX86LazyFlags; -typedef struct CPUX86State { +typedef struct CPUArchState { /* standard registers */ target_ulong regs[CPU_NB_REGS]; target_ulong eip;
@@ -2072,7 +2072,6 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env)#define CC_SRC2 (env->cc_src2)#define CC_OP (env->cc_op) -typedef CPUX86State CPUArchState ;typedef X86CPU ArchCPU ;#include "exec/cpu-all.h"
target/m68k/cpu.h +1 -2
@@ -79,7 +79,7 @@typedef CPU_LDoubleU FPReg ; -typedef struct CPUM68KState { +typedef struct CPUArchState { uint32_t dregs[8]; uint32_t aregs[8]; uint32_t pc;
@@ -574,7 +574,6 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); -typedef CPUM68KState CPUArchState ;typedef M68kCPU ArchCPU ;#include "exec/cpu-all.h"
target/microblaze/cpu.h +2 -3
@@ -24,7 +24,7 @@#include "exec/cpu-defs.h" #include "fpu/softfloat-types.h" -typedef struct CPUMBState CPUMBState ; +typedef struct CPUArchState CPUMBState ;#if !defined(CONFIG_USER_ONLY )#include "mmu.h" #endif
@@ -239,7 +239,7 @@ typedef struct CPUMBState CPUMBState;#define USE_NON_SECURE_M_AXI_DC_MASK 0x4#define USE_NON_SECURE_M_AXI_IC_MASK 0x8 -struct CPUMBState { +struct CPUArchState {uint32_t bvalue;/* TCG temporary, only valid during a TB */ uint32_t btarget;/* Full resolved branch destination */
@@ -394,7 +394,6 @@ void mb_tcg_init(void);#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -typedef CPUMBState CPUArchState ;typedef MicroBlazeCPU ArchCPU ;#include "exec/cpu-all.h"
target/mips/cpu.h +2 -4
@@ -524,8 +524,7 @@ struct TCState { };struct MIPSITUState ; -typedef struct CPUMIPSState CPUMIPSState ; -struct CPUMIPSState { +typedef struct CPUArchState { TCState active_tc; CPUMIPSFPUContext active_fpu;
@@ -1161,7 +1160,7 @@ struct CPUMIPSState {QEMUTimer *timer;/* Internal timer */ target_ulong exception_base;/* ExceptionBase input to the core */ uint64_t cp0_count_ns;/* CP0_Count clock period (in nanoseconds) */ -}; +} CPUMIPSState;/** * MIPSCPU:
@@ -1218,7 +1217,6 @@ static inline int cpu_mmu_index(CPUMIPSState *env, bool ifetch)return hflags_mmu_index (env->hflags); } -typedef CPUMIPSState CPUArchState ;typedef MIPSCPU ArchCPU ;#include "exec/cpu-all.h"
target/nios2/cpu.h +2 -2
@@ -25,7 +25,7 @@#include "hw/core/cpu.h" #include "qom/object.h" -typedef struct CPUNios2State CPUNios2State ; +typedef struct CPUArchState CPUNios2State ;#if !defined(CONFIG_USER_ONLY )#include "mmu.h" #endif
@@ -155,7 +155,7 @@ struct Nios2CPUClass {#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 -struct CPUNios2State { +struct CPUArchState {uint32_t regs[NUM_CORE_REGS ];#if !defined(CONFIG_USER_ONLY )
target/openrisc/cpu.h +1 -2
@@ -242,7 +242,7 @@ typedef struct CPUOpenRISCTLBContext { } CPUOpenRISCTLBContext;#endif -typedef struct CPUOpenRISCState { +typedef struct CPUArchState { target_ulong shadow_gpr[16][32]; /* Shadow registers */ target_ulong pc; /* Program counter */
@@ -348,7 +348,6 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu);#define OPENRISC_CPU_TYPE_NAME (model) model OPENRISC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU -typedef CPUOpenRISCState CPUArchState ;typedef OpenRISCCPU ArchCPU ;#include "exec/cpu-all.h"
target/ppc/cpu-qom.h +1 -1
@@ -32,7 +32,7 @@OBJECT_DECLARE_TYPE (PowerPCCPU, PowerPCCPUClass, POWERPC_CPU) -typedef struct CPUPPCState CPUPPCState ; +typedef struct CPUArchState CPUPPCState ;typedef struct ppc_tb_t ppc_tb_t ;typedef struct ppc_dcr_t ppc_dcr_t ;
target/ppc/cpu.h +1 -2
@@ -1080,7 +1080,7 @@ struct ppc_radix_page_info {#define PPC_CPU_OPCODES_LEN 0x40#define PPC_CPU_INDIRECT_OPCODES_LEN 0x20 -struct CPUPPCState { +struct CPUArchState {/* Most commonly used resources during translated code execution first */ target_ulong gpr[32 ];/* general purpose registers */ target_ulong gprh[32 ];/* storage for GPR MSB, used by the SPE extension */
@@ -1476,7 +1476,6 @@ void ppc_compat_add_property(Object *obj, const char *name, uint32_t *compat_pvr, const char *basedesc);#endif /* defined(TARGET_PPC64) */ -typedef CPUPPCState CPUArchState ;typedef PowerPCCPU ArchCPU ;#include "exec/cpu-all.h"
target/riscv/cpu.h +2 -3
@@ -97,7 +97,7 @@ enum {#define MAX_RISCV_PMPS (16) -typedef struct CPURISCVState CPURISCVState ; +typedef struct CPUArchState CPURISCVState ;#if !defined(CONFIG_USER_ONLY )#include "pmp.h"
@@ -112,7 +112,7 @@ FIELD(VTYPE, VMA, 7, 1) FIELD(VTYPE, VEDIV, 8, 2) FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) -struct CPURISCVState { +struct CPUArchState {target_ulong gpr[32 ];target_ulong gprh[32 ];/* 64 top bits of the 128-bit registers */ uint64_t fpr[32 ];/* assume both F and D extensions */
@@ -430,7 +430,6 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MSTATUS_FS MSTATUS_FS#define TB_FLAGS_MSTATUS_VS MSTATUS_VS -typedef CPURISCVState CPUArchState ;typedef RISCVCPU ArchCPU ;#include "exec/cpu-all.h"
target/rx/cpu-qom.h +0 -2
@@ -45,6 +45,4 @@ struct RXCPUClass { DeviceReset parent_reset; }; -#define CPUArchState struct CPURXState -#endif
target/rx/cpu.h +1 -1
@@ -65,7 +65,7 @@ enum { NUM_REGS = 16, }; -typedef struct CPURXState { +typedef struct CPUArchState { /* CPU registers */ uint32_t regs[NUM_REGS]; /* general registers */ uint32_t psw_o; /* O bit of status register */
target/s390x/cpu-qom.h +2 -2
@@ -31,6 +31,8 @@ OBJECT_DECLARE_TYPE(S390CPU, S390CPUClass,typedef struct S390CPUModel S390CPUModel ;typedef struct S390CPUDef S390CPUDef ; +typedef struct CPUArchState CPUS390XState ; + typedef enum cpu_reset_type { S390_CPU_RESET_NORMAL, S390_CPU_RESET_INITIAL,
@@ -63,6 +65,4 @@ struct S390CPUClass { void (*reset)(CPUState *cpu, cpu_reset_type type); }; -typedef struct CPUS390XState CPUS390XState ; -#endif
target/s390x/cpu.h +1 -2
@@ -51,7 +51,7 @@ typedef struct PSW {uint64_t addr; }PSW ; -struct CPUS390XState { +struct CPUArchState {uint64_t regs[16 ];/* GP registers */ /* * The floating point registers are part of the vector registers.
@@ -840,7 +840,6 @@ uint64_t s390_cpu_get_psw_mask(CPUS390XState *env);/* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state (uint16_t cpu_addr); -typedef CPUS390XState CPUArchState ;typedef S390CPU ArchCPU ;#include "exec/cpu-all.h"
target/sh4/cpu.h +1 -2
@@ -130,7 +130,7 @@ typedef struct memory_content {struct memory_content *next; } memory_content; -typedef struct CPUSH4State { +typedef struct CPUArchState { uint32_t flags; /* general execution flags */ uint32_t gregs[24]; /* general registers */ float32 fregs[32]; /* floating point registers */
@@ -264,7 +264,6 @@ static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch) } } -typedef CPUSH4State CPUArchState ;typedef SuperHCPU ArchCPU ;#include "exec/cpu-all.h"
target/sparc/cpu.h +2 -3
@@ -420,7 +420,7 @@ struct CPUTimertypedef struct CPUTimer CPUTimer ; -typedef struct CPUSPARCState CPUSPARCState ; +typedef struct CPUArchState CPUSPARCState ; #if defined(TARGET_SPARC64) typedef union { uint64_t mmuregs[16];
@@ -439,7 +439,7 @@ typedef union { }; } SparcV9MMU;#endif -struct CPUSPARCState { +struct CPUArchState {target_ulong gregs[8 ];/* general registers */ target_ulong *regwptr;/* pointer to current register window */ target_ulong pc;/* program counter */
@@ -743,7 +743,6 @@ static inline int cpu_pil_allowed(CPUSPARCState *env1, int pil)#endif } -typedef CPUSPARCState CPUArchState ;typedef SPARCCPU ArchCPU ;#include "exec/cpu-all.h"
target/tricore/cpu.h +2 -4
@@ -28,8 +28,7 @@ struct tricore_boot_info;typedef struct tricore_def_t tricore_def_t ; -typedef struct CPUTriCoreState CPUTriCoreState ; -struct CPUTriCoreState { +typedef struct CPUArchState { /* GPR Register */ uint32_t gpr_a[16]; uint32_t gpr_d[16];
@@ -189,7 +188,7 @@ struct CPUTriCoreState {const tricore_def_t *cpu_model;void *irq[8 ];struct QEMUTimer *timer;/* Internal timer */ -}; +} CPUTriCoreState;/** * TriCoreCPU:
@@ -369,7 +368,6 @@ static inline int cpu_mmu_index(CPUTriCoreState *env, bool ifetch)return 0 ; } -typedef CPUTriCoreState CPUArchState ;typedef TriCoreCPU ArchCPU ;#include "exec/cpu-all.h"
target/xtensa/cpu.h +3 -4
@@ -306,7 +306,7 @@ typedef enum {INTTYPE_MAX } interrupt_type; -struct CPUXtensaState ; +typedef struct CPUArchState CPUXtensaState ; typedef struct xtensa_tlb_entry { uint32_t vaddr;
@@ -506,7 +506,7 @@ enum { };#endif -typedef struct CPUXtensaState { +struct CPUArchState {const XtensaConfig *config;uint32_t regs[16 ];uint32_t pc;
@@ -545,7 +545,7 @@ typedef struct CPUXtensaState {/* Watchpoints for DBREAK registers */ struct CPUWatchpoint *cpu_watchpoint[MAX_NDBREAK ]; -} CPUXtensaState; +};/** * XtensaCPU:
@@ -722,7 +722,6 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)#define XTENSA_CSBASE_LBEG_OFF_MASK 0x00ff0000#define XTENSA_CSBASE_LBEG_OFF_SHIFT 16 -typedef CPUXtensaState CPUArchState ;typedef XtensaCPU ArchCPU ;#include "exec/cpu-all.h"
Signature · 1 line
2.34.1
PATCH 11/15 target: Use ArchCPU as interface to target CPU
In reply to Philippe Mathieu-Daudé viaArchCPU is our interface with target-specific code. Use it as a forward-declared opaque pointer (abstract type), having its structure defined by each target.
--- include/qemu/typedefs.h | 1 + target/alpha/cpu-qom.h | 4 +++- target/alpha/cpu.h | 4 +--- target/arm/cpu-qom.h | 4 +++- target/arm/cpu.h | 2 -- target/avr/cpu-qom.h | 4 +++- target/avr/cpu.h | 6 ++---- target/cris/cpu-qom.h | 4 +++- target/cris/cpu.h | 4 +--- target/hexagon/cpu.h | 2 +- target/hppa/cpu-qom.h | 4 +++- target/hppa/cpu.h | 4 +--- target/i386/cpu-qom.h | 4 +++- target/i386/cpu.h | 4 +--- target/m68k/cpu-qom.h | 4 +++- target/m68k/cpu.h | 4 +--- target/microblaze/cpu-qom.h | 4 +++- target/microblaze/cpu.h | 6 +++--- target/mips/cpu-qom.h | 4 +++- target/mips/cpu.h | 4 +--- target/nios2/cpu.h | 4 ++-- target/openrisc/cpu.h | 11 ++++------- target/ppc/cpu-qom.h | 4 +++- target/ppc/cpu.h | 4 +--- target/riscv/cpu.h | 5 ++--- target/rx/cpu-qom.h | 4 +++- target/rx/cpu.h | 4 +--- target/s390x/cpu-qom.h | 4 +++- target/s390x/cpu.h | 4 +--- target/sh4/cpu-qom.h | 4 +++- target/sh4/cpu.h | 4 +--- target/sparc/cpu-qom.h | 4 +++- target/sparc/cpu.h | 4 +--- target/tricore/cpu-qom.h | 4 +++- target/tricore/cpu.h | 4 +--- target/xtensa/cpu-qom.h | 4 +++- target/xtensa/cpu.h | 4 +--- 37 files changed, 76 insertions(+), 77 deletions(-)
include/qemu/typedefs.h +1 -0
@@ -26,6 +26,7 @@ typedef struct AddressSpace AddressSpace;typedef struct AioContext AioContext ;typedef struct Aml Aml ;typedef struct AnnounceTimer AnnounceTimer ; +typedef struct ArchCPU ArchCPU ;typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ;typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter ;typedef struct BlockBackend BlockBackend ;
target/alpha/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_ALPHA_CPU "alpha-cpu" -OBJECT_DECLARE_TYPE (AlphaCPU, AlphaCPUClass, +typedef struct ArchCPU AlphaCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, AlphaCPUClass,ALPHA_CPU )/**
target/alpha/cpu.h +1 -3
@@ -257,7 +257,7 @@ typedef struct CPUArchState {* * An Alpha CPU. */ -struct AlphaCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -283,8 +283,6 @@ int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);#define cpu_list alpha_cpu_list -typedef AlphaCPU ArchCPU ; -#include "exec/cpu-all.h" enum {
target/arm/cpu-qom.h +3 -1
@@ -27,7 +27,9 @@ struct arm_boot_info;#define TYPE_ARM_CPU "arm-cpu" -OBJECT_DECLARE_TYPE (ARMCPU , ARMCPUClass, +typedef struct ArchCPU ARMCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, ARMCPUClass, ARM_CPU)#define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPU
target/arm/cpu.h +0 -2
@@ -3410,8 +3410,6 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) } } -typedef ARMCPU ArchCPU ; -#include "exec/cpu-all.h" /*
target/avr/cpu-qom.h +3 -1
@@ -26,7 +26,9 @@#define TYPE_AVR_CPU "avr-cpu" -OBJECT_DECLARE_TYPE (AVRCPU , AVRCPUClass, +typedef struct ArchCPU AVRCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, AVRCPUClass,AVR_CPU )/**
target/avr/cpu.h +2 -4
@@ -143,14 +143,14 @@ typedef struct CPUArchState {* * A AVR CPU. */ -typedef struct AVRCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/ CPUNegativeOffsetState neg;CPUAVRState env; -}AVRCPU ; +};extern const struct VMStateDescription vms_avr_cpu;
@@ -245,8 +245,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); -typedef AVRCPU ArchCPU ; -#include "exec/cpu-all.h" #endif /* !defined (QEMU_AVR_CPU_H) */
target/cris/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_CRIS_CPU "cris-cpu" -OBJECT_DECLARE_TYPE (CRISCPU , CRISCPUClass, +typedef struct ArchCPU CRISCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, CRISCPUClass,CRIS_CPU )/**
target/cris/cpu.h +1 -3
@@ -173,7 +173,7 @@ typedef struct CPUArchState {* * A CRIS CPU. */ -struct CRISCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -265,8 +265,6 @@ static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)#define SFR_RW_MM_TLB_LO env->pregs[PR_SRS]][5#define SFR_RW_MM_TLB_HI env->pregs[PR_SRS]][6 -typedef CRISCPU ArchCPU ; -#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc,
target/hexagon/cpu.h +1 -1
@@ -143,7 +143,7 @@ typedef struct HexagonCPUClass {DeviceReset parent_reset; } HexagonCPUClass; -typedef struct HexagonCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/
target/hppa/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_HPPA_CPU "hppa-cpu" -OBJECT_DECLARE_TYPE (HPPACPU , HPPACPUClass, +typedef struct ArchCPU HPPACPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, HPPACPUClass,HPPA_CPU )/**
target/hppa/cpu.h +1 -3
@@ -213,7 +213,7 @@ typedef struct CPUArchState {* * An HPPA CPU. */ -struct HPPACPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -223,8 +223,6 @@ struct HPPACPU {QEMUTimer *alarm_timer; }; -typedef HPPACPU ArchCPU ; -#include "exec/cpu-all.h" static inline int cpu_mmu_index (CPUHPPAState *env,bool ifetch)
target/i386/cpu-qom.h +3 -1
@@ -30,7 +30,9 @@#define TYPE_X86_CPU "i386-cpu"#endif -OBJECT_DECLARE_TYPE (X86CPU , X86CPUClass, +typedef struct ArchCPU X86CPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, X86CPUClass, X86_CPU)typedef struct X86CPUModel X86CPUModel ;
target/i386/cpu.h +1 -3
@@ -1705,7 +1705,7 @@ struct kvm_msrs;* * An x86 CPU. */ -struct X86CPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -2072,8 +2072,6 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env)#define CC_SRC2 (env->cc_src2)#define CC_OP (env->cc_op) -typedef X86CPU ArchCPU ; -#include "exec/cpu-all.h" #include "svm.h"
target/m68k/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_M68K_CPU "m68k-cpu" -OBJECT_DECLARE_TYPE (M68kCPU, M68kCPUClass, +typedef struct ArchCPU M68kCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, M68kCPUClass,M68K_CPU )/*
target/m68k/cpu.h +1 -3
@@ -156,7 +156,7 @@ typedef struct CPUArchState {* * A Motorola 68k CPU. */ -struct M68kCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -574,8 +574,6 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); -typedef M68kCPU ArchCPU ; -#include "exec/cpu-all.h" /* TB flags */
target/microblaze/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_MICROBLAZE_CPU "microblaze-cpu" -OBJECT_DECLARE_TYPE (MicroBlazeCPU, MicroBlazeCPUClass, +typedef struct ArchCPU MicroBlazeCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, MicroBlazeCPUClass,MICROBLAZE_CPU )/**
target/microblaze/cpu.h +3 -3
@@ -25,6 +25,8 @@#include "fpu/softfloat-types.h" typedef struct CPUArchState CPUMBState ; +typedef struct ArchCPU MicroBlazeCPU ; +#if !defined(CONFIG_USER_ONLY )#include "mmu.h" #endif
@@ -339,7 +341,7 @@ typedef struct {* * A MicroBlaze CPU. */ -struct MicroBlazeCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;
@@ -394,8 +396,6 @@ void mb_tcg_init(void);#define MMU_USER_IDX 2/* See NB_MMU_MODES further up the file. */ -typedef MicroBlazeCPU ArchCPU ; -#include "exec/cpu-all.h" /* Ensure there is no overlap between the two masks. */
target/mips/cpu-qom.h +3 -1
@@ -29,7 +29,9 @@#define TYPE_MIPS_CPU "mips-cpu"#endif -OBJECT_DECLARE_TYPE (MIPSCPU , MIPSCPUClass, +typedef struct ArchCPU MIPSCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, MIPSCPUClass,MIPS_CPU )/**
target/mips/cpu.h +1 -3
@@ -1171,7 +1171,7 @@ typedef struct CPUArchState {* * A MIPS CPU. */ -struct MIPSCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -1217,8 +1217,6 @@ static inline int cpu_mmu_index(CPUMIPSState *env, bool ifetch)return hflags_mmu_index (env->hflags); } -typedef MIPSCPU ArchCPU ; -#include "exec/cpu-all.h" /* Exceptions */
target/nios2/cpu.h +2 -2
@@ -32,7 +32,7 @@ typedef struct CPUArchState CPUNios2State;#define TYPE_NIOS2_CPU "nios2-cpu" -OBJECT_DECLARE_TYPE (Nios2CPU, Nios2CPUClass, +OBJECT_DECLARE_TYPE (ArchCPU, Nios2CPUClass,NIOS2_CPU )/**
@@ -171,7 +171,7 @@ struct CPUArchState {* * A Nios2 CPU. */ -struct Nios2CPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
target/openrisc/cpu.h +4 -7
@@ -24,12 +24,11 @@#include "hw/core/cpu.h" #include "qom/object.h" -/* cpu_openrisc_map_address_* in CPUOpenRISCTLBContext need this decl. */ -struct OpenRISCCPU ; -#define TYPE_OPENRISC_CPU "or1k-cpu" -OBJECT_DECLARE_TYPE (OpenRISCCPU, OpenRISCCPUClass, +typedef struct ArchCPU OpenRISCCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, OpenRISCCPUClass,OPENRISC_CPU )/**
@@ -301,7 +300,7 @@ typedef struct CPUArchState {* * A OpenRISC CPU. */ -struct OpenRISCCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -348,8 +347,6 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu);#define OPENRISC_CPU_TYPE_NAME (model) model OPENRISC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU -typedef OpenRISCCPU ArchCPU ; -#include "exec/cpu-all.h" #define TB_FLAGS_SM SR_SM
target/ppc/cpu-qom.h +3 -1
@@ -29,7 +29,9 @@#define TYPE_POWERPC_CPU "powerpc-cpu"#endif -OBJECT_DECLARE_TYPE (PowerPCCPU, PowerPCCPUClass, +typedef struct ArchCPU PowerPCCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, PowerPCCPUClass, POWERPC_CPU)typedef struct CPUArchState CPUPPCState ;
target/ppc/cpu.h +1 -3
@@ -1278,7 +1278,7 @@ typedef struct PPCVirtualHypervisorClass PPCVirtualHypervisorClass;* * A PowerPC CPU. */ -struct PowerPCCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -1476,8 +1476,6 @@ void ppc_compat_add_property(Object *obj, const char *name, uint32_t *compat_pvr, const char *basedesc);#endif /* defined(TARGET_PPC64) */ -typedef PowerPCCPU ArchCPU ; -#include "exec/cpu-all.h" /*****************************************************************************/
target/riscv/cpu.h +2 -3
@@ -285,7 +285,7 @@ struct CPUArchState {uint64_t kvm_timer_frequency; }; -OBJECT_DECLARE_TYPE (RISCVCPU , RISCVCPUClass, +OBJECT_DECLARE_TYPE (ArchCPU, RISCVCPUClass,RISCV_CPU )/**
@@ -309,7 +309,7 @@ struct RISCVCPUClass {* * A RISCV CPU. */ -struct RISCVCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -430,7 +430,6 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MSTATUS_FS MSTATUS_FS#define TB_FLAGS_MSTATUS_VS MSTATUS_VS -typedef RISCVCPU ArchCPU ;#include "exec/cpu-all.h" FIELD (TB_FLAGS ,MEM_IDX ,0 ,3 )
target/rx/cpu-qom.h +3 -1
@@ -26,7 +26,9 @@#define TYPE_RX62N_CPU RX_CPU_TYPE_NAME("rx62n") -OBJECT_DECLARE_TYPE (RXCPU , RXCPUClass, +typedef struct ArchCPU RXCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, RXCPUClass,RX_CPU )/*
target/rx/cpu.h +1 -3
@@ -105,7 +105,7 @@ typedef struct CPUArchState {* * A RX CPU */ -struct RXCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -114,8 +114,6 @@ struct RXCPU {CPURXState env; }; -typedef RXCPU ArchCPU ; -#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU#define RX_CPU_TYPE_NAME (model) model RX_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_RX_CPU
target/s390x/cpu-qom.h +3 -1
@@ -25,7 +25,9 @@#define TYPE_S390_CPU "s390x-cpu" -OBJECT_DECLARE_TYPE (S390CPU , S390CPUClass, +typedef struct ArchCPU S390CPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, S390CPUClass, S390_CPU)typedef struct S390CPUModel S390CPUModel ;
target/s390x/cpu.h +1 -3
@@ -163,7 +163,7 @@ static inline uint64_t *get_freg(CPUS390XState *cs, int nr)* * An S/390 CPU. */ -struct S390CPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -840,8 +840,6 @@ uint64_t s390_cpu_get_psw_mask(CPUS390XState *env);/* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state (uint16_t cpu_addr); -typedef S390CPU ArchCPU ; -#include "exec/cpu-all.h" #endif
target/sh4/cpu-qom.h +3 -1
@@ -29,7 +29,9 @@#define TYPE_SH7751R_CPU SUPERH_CPU_TYPE_NAME("sh7751r")#define TYPE_SH7785_CPU SUPERH_CPU_TYPE_NAME("sh7785") -OBJECT_DECLARE_TYPE (SuperHCPU, SuperHCPUClass, +typedef struct ArchCPU SuperHCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, SuperHCPUClass,SUPERH_CPU )/**
target/sh4/cpu.h +1 -3
@@ -195,7 +195,7 @@ typedef struct CPUArchState {* * A SuperH CPU. */ -struct SuperHCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -264,8 +264,6 @@ static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch) } } -typedef SuperHCPU ArchCPU ; -#include "exec/cpu-all.h" /* MMU control register */
target/sparc/cpu-qom.h +3 -1
@@ -29,7 +29,9 @@#define TYPE_SPARC_CPU "sparc-cpu"#endif -OBJECT_DECLARE_TYPE (SPARCCPU , SPARCCPUClass, +typedef struct ArchCPU SPARCCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, SPARCCPUClass, SPARC_CPU)typedef struct sparc_def_t sparc_def_t ;
target/sparc/cpu.h +1 -3
@@ -556,7 +556,7 @@ struct CPUArchState {* * A SPARC CPU. */ -struct SPARCCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -743,8 +743,6 @@ static inline int cpu_pil_allowed(CPUSPARCState *env1, int pil)#endif } -typedef SPARCCPU ArchCPU ; -#include "exec/cpu-all.h" #ifdef TARGET_SPARC64
target/tricore/cpu-qom.h +3 -1
@@ -24,7 +24,9 @@#define TYPE_TRICORE_CPU "tricore-cpu" -OBJECT_DECLARE_TYPE (TriCoreCPU, TriCoreCPUClass, +typedef struct ArchCPU TriCoreCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, TriCoreCPUClass, TRICORE_CPU)struct TriCoreCPUClass {
target/tricore/cpu.h +1 -3
@@ -196,7 +196,7 @@ typedef struct CPUArchState {* * A TriCore CPU. */ -struct TriCoreCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -368,8 +368,6 @@ static inline int cpu_mmu_index(CPUTriCoreState *env, bool ifetch)return 0 ; } -typedef TriCoreCPU ArchCPU ; -#include "exec/cpu-all.h" void cpu_state_reset (CPUTriCoreState *s);
target/xtensa/cpu-qom.h +3 -1
@@ -34,7 +34,9 @@#define TYPE_XTENSA_CPU "xtensa-cpu" -OBJECT_DECLARE_TYPE (XtensaCPU, XtensaCPUClass, +typedef struct ArchCPU XtensaCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, XtensaCPUClass, XTENSA_CPU)typedef struct XtensaConfig XtensaConfig ;
target/xtensa/cpu.h +1 -3
@@ -553,7 +553,7 @@ struct CPUArchState {* * An Xtensa CPU. */ -struct XtensaCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
@@ -722,8 +722,6 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)#define XTENSA_CSBASE_LBEG_OFF_MASK 0x00ff0000#define XTENSA_CSBASE_LBEG_OFF_SHIFT 16 -typedef XtensaCPU ArchCPU ; -#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc,
Signature · 1 line
2.34.1
Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
Quoted 44 lines · Philippe Mathieu-Daudé
ArchCPU is our interface with target-specific code. Use it as a forward-declared opaque pointer (abstract type), having its structure defined by each target.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/typedefs.h | 1 + target/alpha/cpu-qom.h | 4 +++- target/alpha/cpu.h | 4 +--- target/arm/cpu-qom.h | 4 +++- target/arm/cpu.h | 2 -- target/avr/cpu-qom.h | 4 +++- target/avr/cpu.h | 6 ++---- target/cris/cpu-qom.h | 4 +++- target/cris/cpu.h | 4 +--- target/hexagon/cpu.h | 2 +- target/hppa/cpu-qom.h | 4 +++- target/hppa/cpu.h | 4 +--- target/i386/cpu-qom.h | 4 +++- target/i386/cpu.h | 4 +--- target/m68k/cpu-qom.h | 4 +++- target/m68k/cpu.h | 4 +--- target/microblaze/cpu-qom.h | 4 +++- target/microblaze/cpu.h | 6 +++--- target/mips/cpu-qom.h | 4 +++- target/mips/cpu.h | 4 +--- target/nios2/cpu.h | 4 ++-- target/openrisc/cpu.h | 11 ++++------- target/ppc/cpu-qom.h | 4 +++- target/ppc/cpu.h | 4 +--- target/riscv/cpu.h | 5 ++--- target/rx/cpu-qom.h | 4 +++- target/rx/cpu.h | 4 +--- target/s390x/cpu-qom.h | 4 +++- target/s390x/cpu.h | 4 +--- target/sh4/cpu-qom.h | 4 +++- target/sh4/cpu.h | 4 +--- target/sparc/cpu-qom.h | 4 +++- target/sparc/cpu.h | 4 +--- target/tricore/cpu-qom.h | 4 +++- target/tricore/cpu.h | 4 +--- target/xtensa/cpu-qom.h | 4 +++- target/xtensa/cpu.h | 4 +--- 37 files changed, 76 insertions(+), 77 deletions(-)
...
Quoted 28 lines
target/arm/cpu-qom.h +3
-1@@ -27,7 +27,9 @@ struct arm_boot_info;#define TYPE_ARM_CPU "arm-cpu" -OBJECT_DECLARE_TYPE (ARMCPU , ARMCPUClass, +typedef struct ArchCPU ARMCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, ARMCPUClass, ARM_CPU)#define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPUtarget/arm/cpu.h +0
-2@@ -3410,8 +3410,6 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) } } -typedef ARMCPU ArchCPU ; -#include "exec/cpu-all.h" /*
...
Quoted 23 lines
target/riscv/cpu.h +2
-2@@ -285,7 +285,7 @@ struct CPUArchState {uint64_t kvm_timer_frequency; }; -OBJECT_DECLARE_TYPE (RISCVCPU , RISCVCPUClass, +OBJECT_DECLARE_TYPE (ArchCPU, RISCVCPUClass,RISCV_CPU )/** @@ -309,7 +309,7 @@ struct RISCVCPUClass {* * A RISCV CPU. */ -struct RISCVCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
target/riscv/cpu.h void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong); · line 435
Quoted 7 lines
target/riscv/cpu.h +0
-1@@ -430,7 +430,6 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MSTATUS_FS MSTATUS_FS#define TB_FLAGS_MSTATUS_VS MSTATUS_VS -typedef RISCVCPU ArchCPU ;#include "exec/cpu-all.h" FIELD (TB_FLAGS ,MEM_IDX ,0 ,3 )
Sorry I messed while rebasing, this hunk is missing:
-- >8 --
target/arm/cpu.h +1 -1
@@ -774,7 +774,7 @@ typedef struct ARMISARegisters ARMISARegisters;* * An ARM CPU core. */ -struct ARMCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
target/nios2/cpu.h +2 -2
@@ -171,7 +171,7 @@ struct CPUArchState {* * A Nios2 CPU. */ -struct ArchCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/
@@ -188,7 +188,7 @@ struct ArchCPU {uint32_t reset_addr;uint32_t exception_addr;uint32_t fast_tlb_miss_addr; -}; +} Nios2CPU;void nios2_tcg_init (void );
target/riscv/cpu.h +2 -2
@@ -309,7 +309,7 @@ struct RISCVCPUClass {* * A RISCV CPU. */ -struct ArchCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/
@@ -357,7 +357,7 @@ struct ArchCPU {bool epmp;uint64_t resetvec; } cfg; -}; +}RISCVCPU ;static inline int riscv_has_ext (CPURISCVState *env,target_ulong ext) {
---
Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
target/nios2/cpu.h struct ArchCPU { · line 191
Quoted 11 lines · Philippe Mathieu-Daudé
target/nios2/cpu.h +2
-2-struct ArchCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/@@ -188,7 +188,7 @@ struct ArchCPU { uint32_t reset_addr; uint32_t exception_addr; uint32_t fast_tlb_miss_addr; -}; +} Nios2CPU;
I think keeping the typedef separate, as you have done for the other targets, is easier to read.
r~
Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
In reply to Philippe Mathieu-Daudé viatarget/hexagon/cpu.h typedef struct HexagonCPUClass { · line 149
Quoted 13 lines · Philippe Mathieu-Daudé
target/hexagon/cpu.h +1
-1@@ -143,7 +143,7 @@ typedef struct HexagonCPUClass {DeviceReset parent_reset; } HexagonCPUClass; -typedef struct HexagonCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/
There's still the typedef of ArchCPU below, which ought to be redundant now. It may or may not be less confusing to separate out the typedef for HexagonCPU. It definitely would be worthwhile to convert hexagon to OBJECT_DECLARE_TYPE (cc Taylor).
Quoted 20 lines
target/microblaze/cpu-qom.h +3
-1@@ -25,7 +25,9 @@#define TYPE_MICROBLAZE_CPU "microblaze-cpu" -OBJECT_DECLARE_TYPE (MicroBlazeCPU, MicroBlazeCPUClass, +typedef struct ArchCPU MicroBlazeCPU ; + +OBJECT_DECLARE_TYPE (ArchCPU, MicroBlazeCPUClass,MICROBLAZE_CPU )/** target/microblaze/cpu.h +0
-0
target/microblaze/cpu.h line 28
Quoted 4 lines
target/microblaze/cpu.h +1
-0@@ -25,6 +25,8 @@#include "fpu/softfloat-types.h" typedef struct CPUArchState CPUMBState ; +typedef struct ArchCPU MicroBlazeCPU ;
Duplicate typedef.
Quoted 14 lines
target/nios2/cpu.h +1
-1@@ -32,7 +32,7 @@ typedef struct CPUArchState CPUNios2State;#define TYPE_NIOS2_CPU "nios2-cpu" -OBJECT_DECLARE_TYPE (Nios2CPU, Nios2CPUClass, +OBJECT_DECLARE_TYPE (ArchCPU, Nios2CPUClass,NIOS2_CPU )/**
target/nios2/cpu.h struct CPUArchState { · line 177
Quoted 8 lines
target/nios2/cpu.h +1
-1@@ -171,7 +171,7 @@ struct CPUArchState {* * A Nios2 CPU. */ -struct Nios2CPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
Missing Nios2CPU typedef.
Still have the 'typedef Nios2CPU ArchCPU' below.
Quoted 23 lines
target/riscv/cpu.h +2
-2@@ -285,7 +285,7 @@ struct CPUArchState {uint64_t kvm_timer_frequency; }; -OBJECT_DECLARE_TYPE (RISCVCPU , RISCVCPUClass, +OBJECT_DECLARE_TYPE (ArchCPU, RISCVCPUClass,RISCV_CPU )/** @@ -309,7 +309,7 @@ struct RISCVCPUClass {* * A RISCV CPU. */ -struct RISCVCPU { +struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/
target/riscv/cpu.h void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong); · line 435
Quoted 7 lines
target/riscv/cpu.h +0
-1@@ -430,7 +430,6 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MSTATUS_FS MSTATUS_FS#define TB_FLAGS_MSTATUS_VS MSTATUS_VS -typedef RISCVCPU ArchCPU ;#include "exec/cpu-all.h" FIELD (TB_FLAGS ,MEM_IDX ,0 ,3 )
Missing RISCVCPU typedef.
r~
RE: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
Quoted 19 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Wednesday, February 9, 2022 4:48 PM
To: Philippe Mathieu-Daudé <[email protected]>; [email protected]
Cc: Paolo Bonzini <[email protected]>; Thomas Huth <[email protected]>; Taylor Simpson <[email protected]>
Subject: Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPUQuoted 8 lines · Philippe Mathieu-Daudé
target/hexagon/cpu.h index renamed from target/hexagon/cpu.h +0
-0
25c67e43a2..4dce40a360100644target/hexagon/cpu.h +0
-0@@ -143,7 +143,7 @@ typedef struct HexagonCPUClass {DeviceReset parent_reset; } HexagonCPUClass;
Quoted 12 lines
target/hexagon/cpu.h typedef struct HexagonCPUClass { · line 149
Quoted 5 lines
target/hexagon/cpu.h +1
-1-typedef struct HexagonCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/There's still the typedef of ArchCPU below, which ought to be redundant now.
It may or may not be less confusing to separate out the typedef for HexagonCPU.
It definitely would be worthwhile to convert hexagon toOBJECT_DECLARE_TYPE(cc Taylor).
IIUC, the change to convert to OBJECT_DECLARE_TYPE would be
target/hexagon/cpu.h +1 -6
@@ -131,12 +131,7 @@ struct CPUHexagonState {VTCMStoreLog vtcm_log; }; -#define HEXAGON_CPU_CLASS (klass) \ - OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU) -#define HEXAGON_CPU (obj) \ - OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU) -#define HEXAGON_CPU_GET_CLASS (obj) \ - OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU) +OBJECT_DECLARE_TYPE(HexagonCPU, HexagonCPUClass, HEXAGON_CPU) typedef struct HexagonCPUClass { /*< private >*/
If that's correct, the typedef struct HexagonCPUClass should NOT change to typedef struct ArchCPU, and the typdef of ArchCPU below would stay.
So, If I submit the above as a standalone patch, then Philippe wouldn't need to modify target/hexagon/cpu.h. Correct?
Thanks,
Taylor
Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
Quoted 11 lines · Taylor Simpson
target/hexagon/cpu.h +1
-6-#define HEXAGON_CPU_CLASS (klass) \ - OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU) -#define HEXAGON_CPU (obj) \ - OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU) -#define HEXAGON_CPU_GET_CLASS (obj) \ - OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU) +OBJECT_DECLARE_TYPE(HexagonCPU, HexagonCPUClass, HEXAGON_CPU) typedef struct HexagonCPUClass { /*< private >*/
Quoted 1 line
If that's correct, the typedef struct HexagonCPUClass should NOT change to typedef struct ArchCPU, and the typdef of ArchCPU below would stay.
This is the change you'd make with the current state of the world, yes.
Quoted 1 line
So, If I submit the above as a standalone patch, then Philippe wouldn't need to modify
target/hexagon/cpu.h. Correct?
But no, Phil would need a change, because he introduces
typedef struct ArchCPU ArchCPU;
as a generic typedef very early. You cannot then redefine
typedef struct HexagonCPU ArchCPU;
which means that we still have to rearrange the direction of to
typedef ArchCPU HexagonCPU;
etc. But it's definitely a smaller change (and matches all of the other targets).
I do think that the conversion to OBJECT_DECLARE_TYPE should happen first, via whichever tree you choose.
r~
RE: [PATCH 11/15] target: Use ArchCPU as interface to target CPU
Quoted 13 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Thursday, February 10, 2022 7:22 PM
To: Taylor Simpson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; [email protected]
Cc: Paolo Bonzini <[email protected]>; Thomas Huth <[email protected]>
Subject: Re: [PATCH 11/15] target: Use ArchCPU as interface to target CPUReview
Quoted 2 lines · Taylor Simpson
(quoted diff) +0
-2-#define HEXAGON_CPU_CLASS(klass) \ - OBJECT_CLASS_CHECK(HexagonCPUClass, (klass),
Quoted 11 lines
TYPE_HEXAGON_CPU)target/hexagon/cpu.h struct CPUHexagonState {
Quoted 5 lines
target/hexagon/cpu.h +1
-4-#define HEXAGON_CPU (obj) \ - OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU) -#define HEXAGON_CPU_GET_CLASS (obj) \ - OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU) +OBJECT_DECLARE_TYPE(HexagonCPU, HexagonCPUClass,
HEXAGON_CPU)Quoted 4 lines
typedef struct HexagonCPUClass { /*< private >*/
But it's definitely a smaller change (and matches all of the other targets).
Quoted 3 lines
I do think that the conversion to
OBJECT_DECLARE_TYPEshould happen first, via whichever tree you choose.
OK, I'll send a patch. Then, submit a pull request along with the other changes you just looked at.
Taylor
RFC PATCH 12/15 hw/m68k: Restrict M68kCPU type to target/ code
In reply to Philippe Mathieu-Daudé via--- include/hw/m68k/mcf.h | 3 +-- target/m68k/cpu-qom.h | 2 -- target/m68k/cpu.h | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-)
include/hw/m68k/mcf.h +1 -2
@@ -3,7 +3,6 @@/* Motorola ColdFire device prototypes. */ #include "exec/hwaddr.h" -#include "target/m68k/cpu-qom.h" /* mcf_uart.c */ uint64_t mcf_uart_read(void *opaque, hwaddr addr,
@@ -16,7 +15,7 @@ void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr);/* mcf_intc.c */ qemu_irq *mcf_intc_init (struct MemoryRegion *sysmem,hwaddr base, -M68kCPU *cpu); +ArchCPU *cpu);/* mcf5206.c */ #define TYPE_MCF5206_MBAR "mcf5206-mbar"
target/m68k/cpu-qom.h +0 -2
@@ -25,8 +25,6 @@#define TYPE_M68K_CPU "m68k-cpu" -typedef struct ArchCPU M68kCPU ; -OBJECT_DECLARE_TYPE (ArchCPU, M68kCPUClass,M68K_CPU )
target/m68k/cpu.h +2 -2
@@ -156,14 +156,14 @@ typedef struct CPUArchState {* * A Motorola 68k CPU. */ -struct ArchCPU { +typedef struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/ CPUNegativeOffsetState neg;CPUM68KState env; -}; +}M68kCPU ;#ifndef CONFIG_USER_ONLY
Signature · 1 line
2.34.1
Re: [RFC PATCH 12/15] hw/m68k: Restrict M68kCPU type to target/ code
Quoted 20 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/m68k/mcf.h | 3 +-- target/m68k/cpu-qom.h | 2 -- target/m68k/cpu.h | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-)include/hw/m68k/mcf.h +0
-1@@ -3,7 +3,6 @@/* Motorola ColdFire device prototypes. */ #include "exec/hwaddr.h" -#include "target/m68k/cpu-qom.h" /* mcf_uart.c */ uint64_t mcf_uart_read(void *opaque, hwaddr addr,
include/hw/m68k/mcf.h void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); · line 21
Quoted 8 lines
include/hw/m68k/mcf.h +1
-1@@ -16,7 +15,7 @@ void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr);/* mcf_intc.c */ qemu_irq *mcf_intc_init (struct MemoryRegion *sysmem,hwaddr base, -M68kCPU *cpu); +ArchCPU *cpu);/* mcf5206.c */ #define TYPE_MCF5206_MBAR "mcf5206-mbar"
This part is ok.
Quoted 21 lines
target/m68k/cpu-qom.h +0
-2@@ -25,8 +25,6 @@#define TYPE_M68K_CPU "m68k-cpu" -typedef struct ArchCPU M68kCPU ; -OBJECT_DECLARE_TYPE (ArchCPU, M68kCPUClass,M68K_CPU )target/m68k/cpu.h +0
-0@@ -156,14 +156,14 @@ typedef struct CPUArchState {* * A Motorola 68k CPU. */
target/m68k/cpu.h typedef struct CPUArchState { · line 166
Quoted 10 lines
target/m68k/cpu.h +2
-2-struct ArchCPU { +typedef struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/ CPUNegativeOffsetState neg;CPUM68KState env; -}; +}M68kCPU ;
I don't like these. Rationale?
r~
Re: [RFC PATCH 12/15] hw/m68k: Restrict M68kCPU type to target/ code
Quoted 51 lines · Richard Henderson
Quoted 18 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/m68k/mcf.h| 3 +--
target/m68k/cpu-qom.h| 2 --
target/m68k/cpu.h | 4 ++--3 files changed, 3 insertions(+), 6 deletions(-)include/hw/m68k/mcf.h +0
-1@@ -3,7 +3,6 @@ /* Motorola ColdFire device prototypes. */ #include "exec/hwaddr.h" -#include "target/m68k/cpu-qom.h" /* mcf_uart.c */ uint64_t mcf_uart_read(void *opaque, hwaddr addr,include/hw/m68k/mcf.h void mcf_uart_mm_init(hwaddr base, qemu_irq irq, · line 21
Quoted 8 lines
include/hw/m68k/mcf.h +1
-1@@ -16,7 +15,7 @@ void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); /* mcf_intc.c */ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem, hwaddr base, - M68kCPU *cpu); + ArchCPU *cpu); /* mcf5206.c */ #define TYPE_MCF5206_MBAR "mcf5206-mbar"This part is ok.
Quoted 21 lines
target/m68k/cpu-qom.h +0
-2@@ -25,8 +25,6 @@ #define TYPE_M68K_CPU "m68k-cpu" -typedef struct ArchCPU M68kCPU ; - OBJECT_DECLARE_TYPE(ArchCPU, M68kCPUClass, M68K_CPU)target/m68k/cpu.h +1
-1@@ -156,14 +156,14 @@ typedef struct CPUArchState {* * A Motorola 68k CPU. */ -struct ArchCPU { +typedef struct ArchCPU { /*< private >*/
Quoted 8 lines
target/m68k/cpu.h typedef struct CPUArchState { · line 166
Quoted 6 lines
target/m68k/cpu.h +1
-1CPUState parent_obj; /*< public >*/ CPUNegativeOffsetState neg; CPUM68KState env; -}; +} M68kCPU;I don't like these. Rationale?
Short-term idea: hw/ models only have access to cpu-qom.h declarations and opaque pointers to generic CPU objects.
hw/ should not include cpu.h at all. By restricting FooCPU to target/ code, hw/ files fail to compile if using FooCPU and not ArchCPU.
Long-term idea, each target/ is built as a module, exposing an uniform arch-API.
I'm still prototyping to see how to disentangle arch-specific hw which access CPU internals (such ARM NVIC or MIPS ITU).
Re: [RFC PATCH 12/15] hw/m68k: Restrict M68kCPU type to target/ code
Quoted 60 lines · Philippe Mathieu-Daudé
Quoted 50 lines · Richard Henderson
Quoted 18 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/m68k/mcf.h| 3 +--
target/m68k/cpu-qom.h| 2 --
target/m68k/cpu.h | 4 ++--3 files changed, 3 insertions(+), 6 deletions(-)include/hw/m68k/mcf.h +0
-1@@ -3,7 +3,6 @@ /* Motorola ColdFire device prototypes. */ #include "exec/hwaddr.h" -#include "target/m68k/cpu-qom.h" /* mcf_uart.c */ uint64_t mcf_uart_read(void *opaque, hwaddr addr,include/hw/m68k/mcf.h void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); · line 20
Quoted 7 lines
include/hw/m68k/mcf.h +1
-1@@ -16,7 +15,7 @@ void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); /* mcf_intc.c */ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem, hwaddr base, - M68kCPU *cpu); + ArchCPU *cpu); /* mcf5206.c */ #define TYPE_MCF5206_MBAR "mcf5206-mbar"This part is ok.
Quoted 21 lines
target/m68k/cpu-qom.h +0
-2@@ -25,8 +25,6 @@ #define TYPE_M68K_CPU "m68k-cpu" -typedef struct ArchCPU M68kCPU ; - OBJECT_DECLARE_TYPE(ArchCPU, M68kCPUClass, M68K_CPU)target/m68k/cpu.h +1
-1@@ -156,14 +156,14 @@ typedef struct CPUArchState {* * A Motorola 68k CPU. */ -struct ArchCPU { +typedef struct ArchCPU { /*< private >*/Quoted 8 lines
target/m68k/cpu.h typedef struct CPUArchState { · line 166
Quoted 6 lines
target/m68k/cpu.h +1
-1CPUState parent_obj; /*< public >*/ CPUNegativeOffsetState neg; CPUM68KState env; -}; +} M68kCPU;I don't like these. Rationale?
Quoted 5 lines
Short-term idea: hw/ models only have access to
cpu-qom.hdeclarations and opaque pointers to generic CPU objects.hw/ should not include
cpu.hat all. By restricting FooCPU to target/ code, hw/ files fail to compile if using FooCPU and not ArchCPU.
Yes, that would be ideal. If you do want to bring the typedef into cpu.h, please keep it separate; it's easier to read. Especially since one normally expects
typedef struct Foo {
...
} Foo;
and that's not what's happening here.
Quoted 2 lines
Long-term idea, each target/ is built as a module, exposing an uniform arch-API.
That would be awesome, yes.
Quoted 2 lines
I'm still prototyping to see how to disentangle arch-specific hw which access CPU internals (such ARM NVIC or MIPS ITU).
Complicated, yes. If it comes to it, I would not be opposed to having these tightly coupled devices live in target/, but let's see if you can avoid it.
r~
RFC PATCH 13/15 hw/mips: Restrict MIPSCPU type to target/ code
In reply to Philippe Mathieu-Daudé via--- include/hw/mips/cpudevs.h | 6 ++---- target/mips/cpu-qom.h | 2 -- target/mips/cpu.h | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-)
include/hw/mips/cpudevs.h +2 -4
@@ -1,14 +1,12 @@#ifndef HW_MIPS_CPUDEVS_H #define HW_MIPS_CPUDEVS_H -#include "target/mips/cpu-qom.h" -/* Definitions for MIPS CPU internal devices. */ /* mips_int.c */ -void cpu_mips_irq_init_cpu (MIPSCPU *cpu); +void cpu_mips_irq_init_cpu (ArchCPU *cpu);/* mips_timer.c */ -void cpu_mips_clock_init (MIPSCPU *cpu); +void cpu_mips_clock_init (ArchCPU *cpu);#endif
target/mips/cpu-qom.h +0 -2
@@ -29,8 +29,6 @@#define TYPE_MIPS_CPU "mips-cpu"#endif -typedef struct ArchCPU MIPSCPU ; -OBJECT_DECLARE_TYPE (ArchCPU, MIPSCPUClass,MIPS_CPU )
target/mips/cpu.h +2 -2
@@ -1171,7 +1171,7 @@ typedef struct CPUArchState {* * A MIPS CPU. */ -struct ArchCPU { +typedef struct ArchCPU { /*< private >*/ CPUState parent_obj; /*< public >*/
@@ -1187,7 +1187,7 @@ struct ArchCPU {* pipeline clock of the processor, not the issue width of the processor. */ unsigned cp0_count_rate; -}; +}MIPSCPU ;void mips_cpu_list (void );
Signature · 1 line
2.34.1
RFC PATCH 14/15 hw/sparc: Restrict SPARCCPU type to target/ code
In reply to Philippe Mathieu-Daudé via--- include/hw/sparc/sparc64.h | 4 +--- target/sparc/cpu-qom.h | 2 -- target/sparc/cpu.h | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-)
include/hw/sparc/sparc64.h +1 -3
@@ -1,11 +1,9 @@#ifndef HW_SPARC_SPARC64_H #define HW_SPARC_SPARC64_H -#include "target/sparc/cpu-qom.h" -#define IVEC_MAX 0x40 -SPARCCPU *sparc64_cpu_devinit (const char *cpu_type,uint64_t prom_addr); +ArchCPU *sparc64_cpu_devinit (const char *cpu_type,uint64_t prom_addr);void sparc64_cpu_set_ivec_irq (void *opaque,int irq,int level);
target/sparc/cpu-qom.h +0 -2
@@ -29,8 +29,6 @@#define TYPE_SPARC_CPU "sparc-cpu"#endif -typedef struct ArchCPU SPARCCPU ; -OBJECT_DECLARE_TYPE (ArchCPU, SPARCCPUClass,SPARC_CPU )
target/sparc/cpu.h +2 -2
@@ -556,14 +556,14 @@ struct CPUArchState {* * A SPARC CPU. */ -struct ArchCPU { +typedef struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/ CPUNegativeOffsetState neg;CPUSPARCState env; -}; +}SPARCCPU ;#ifndef CONFIG_USER_ONLY
Signature · 1 line
2.34.1
RFC PATCH 15/15 hw/sh4: Restrict SuperHCPU type to target/ code
In reply to Philippe Mathieu-Daudé via--- include/hw/sh4/sh.h | 3 +-- target/sh4/cpu-qom.h | 2 -- target/sh4/cpu.h | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-)
include/hw/sh4/sh.h +1 -2
@@ -28,7 +28,6 @@#define QEMU_HW_SH_H #include "hw/sh4/sh_intc.h" -#include "target/sh4/cpu-qom.h" #define A7ADDR (x) ((x) & 0x1fffffff)#define P4ADDR (x) ((x) | 0xe0000000)
@@ -36,7 +35,7 @@/* sh7750.c */ struct SH7750State ; -struct SH7750State *sh7750_init (SuperHCPU *cpu,MemoryRegion *sysmem); +struct SH7750State *sh7750_init (ArchCPU *cpu,MemoryRegion *sysmem); typedef struct { /* The callback will be triggered if any of the designated lines change */
target/sh4/cpu-qom.h +0 -2
@@ -29,8 +29,6 @@#define TYPE_SH7751R_CPU SUPERH_CPU_TYPE_NAME("sh7751r")#define TYPE_SH7785_CPU SUPERH_CPU_TYPE_NAME("sh7785") -typedef struct ArchCPU SuperHCPU ; -OBJECT_DECLARE_TYPE (ArchCPU, SuperHCPUClass,SUPERH_CPU )
target/sh4/cpu.h +2 -2
@@ -195,14 +195,14 @@ typedef struct CPUArchState {* * A SuperH CPU. */ -struct ArchCPU { +typedef struct ArchCPU {/*< private >*/ CPUState parent_obj;/*< public >*/ CPUNegativeOffsetState neg;CPUSH4State env; -}; +}SuperHCPU ;void superh_cpu_dump_state (CPUState *cpu,FILE *f,int flags);
Signature · 1 line
2.34.1