Hello, Here's an improved and extended series on incrementally converting CPUState to QOM, rebased onto Anthony's qom-upstream.14 plus some master updates.
The general idea behind the series is to cease having CPU-dependent code in generic functions, in favor of storing constant data in CPU classes and letting instance methods either be dumb initializations or overwritten. After the initial introduction of the types, this series is mainly mechanical code movement. This series does NOT yet... ...model ARM CPU has-a cp15 register, ...introduce SoCs (child<CPU> plus devices), ...touch machines. Patch 1 rearranges module init for QOM, so that objects can really be used beyond devices. Introduces a neutral type_init() macro for new types. Does not depend on 3rd QOM series and could be cherry-picked. Patch 2 adds QOM support to the user emulators. Note that more dependencies and some stubs were now needed to successfully compile. Patch 3 introduces the QOM CPU base class. Patches 4-19 derive and start using a QOM CPU for ARM. Patch 5 integrates legacy CPUARMState into QOM. Patch 7 is a proof of concept for CPUState -> CPU lookup. Patch 19 completes freeing cpu_reset() and cpu_arm_init() of any model logic. Patch 20 adds a sample read-only property accessing legacy CPUState. Patch 21 is a hack to allow inspecting this using QMP/qmp qom-list --path=/cpu --property=halted For some reason the logic seems inverted (False for -S, True while running)... Available at: http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu.v3 TODO: We might want to sort -cpu ? alphabetically; object_class_foreach() prints them in hash table order. Agenda: AF: Convert one other target as proof of concept. Once Anthony's 3rd QOM series is merged, sort out and merge (what is now) 1-19. all: Incrementally (hopefully in parallel) derive QOM CPUs for all targets. Only when all targets are converted will it be possible to move fields from CPU_COMMON into CPU, to add properties in common code, to simplify some function names and to eliminate CPUState *env in core code! Regards, Andreas Cc: Anthony Liguori <anth...@codemonkey.ws> Cc: Peter Maydell <peter.mayd...@linaro.org> v2 -> v3: * Rebased against qom-upstream.14 branch (and that against master). * Build common dependencies for user emulators in libuser/. * New dependencies needed after moving properties into object.c. * Add a qemu-user.c with stubs needed for successful linking. * Move cpu.c from hw/ to qom/ (built only once). * Use proper GPL headers. * Rename target-arm/cpu-core.c to cpu.c now that we no longer need VPATH. * Leave cpu-core.h as is to separate from legacy cpu.h. * Fix -cpu alias "pxa270": handled in cpu_arm_init(). * Use proper GPL headers. * Start removing CPUID uses in cpu_reset_model_id() and cpu.h. * Fully convert cpu_reset_model_id() to ARMCPUInfo or per-model code. * Experiment with adding properties. v1 -> v2: * Cherry-pick Anthony's object_class_foreach() patch. * Don't introduce extra early_init(), just relocate former MODULE_INIT_DEVICE. * Provide new type_init() macro to be used instead of device_init(). * Drop processor_init() and MODULE_INIT_CPU in favor of MODULE_INIT_DEVICE. * Prepare cast macros for CPU. * Add documentation. * Fix ARMCPUClass type name (arm-cpu-core -> arm-cpu). * Add documentation. * Rename ARMCPUDef to ARMCPUInfo. * Use a C99-style table for initializing the classes through class_data instead of individual class_init functions (suggested by Anthony). * Prepare reset callback. * Make ENV_GET_OBJECT() use an inline function for readability. * Invoke the CPU's reset method from cpu_reset(). * Do feature initialization via table where sensible. * Add feature flags to ARMCPU as well (suggested by PMM for future tweaking, also simplifies load/save a bit) and initialize them from ARMCPUClass. * Make feature inference work for ARMCPU as well by not passing the ARMCPUClass. Use function-local macros to avoid the ugliness of deferencing the features pointer. Andreas Färber (21): qom: Register QOM infrastructure early qom: Add QOM support to user emulators qom: Introduce CPU class target-arm: Introduce QOM CPU and use it for CPUID lookup target-arm: Embed CPUARMState in QOM ARMCPU target-arm: Prepare model-specific class_init function target-arm: Overwrite reset handler for ti925t target-arm: Move CPU feature flags out of CPUState target-arm: No longer abort on unhandled CPUIDs on reset target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass target-arm: Store cp15 c0_cachetype register in ARMCPUClass target-arm: Move cp15 c1_sys register to ARMCPUClass target-arm: Store JTAG_ID in ARMCPUClass target-arm: Move the PXA270's iwMMXt reset to pxa270_reset() target-arm: Store VFP FPSID register in ARMCPUClass target-arm: Store VFP MVFR0 and MVFR1 in ARMCPUClass target-arm: Store CLIDR in ARMCPUClass target-arm: Store CCSIDRs in ARMCPUClass target-arm: Kill off cpu_reset_model_id() target-arm: Prepare halted property for CPU target-arm: Just for testing! Makefile.objs | 6 + Makefile.target | 1 + Makefile.user | 1 + bsd-user/main.c | 2 + configure | 2 + darwin-user/main.c | 3 + include/qemu/cpu.h | 73 ++++++ linux-user/main.c | 2 + module.h | 5 +- qemu-user.c | 37 +++ qom/Makefile | 1 + qom/cpu.c | 50 ++++ target-arm/cpu-core.h | 93 ++++++++ target-arm/cpu.c | 631 +++++++++++++++++++++++++++++++++++++++++++++++++ target-arm/cpu.h | 27 +-- target-arm/helper.c | 425 +++------------------------------ target-arm/machine.c | 6 +- vl.c | 4 +- 18 files changed, 944 insertions(+), 425 deletions(-) create mode 100644 include/qemu/cpu.h create mode 100644 qemu-user.c create mode 100644 qom/cpu.c create mode 100644 target-arm/cpu-core.h create mode 100644 target-arm/cpu.c -- 1.7.7