From: Anton Johansson <[email protected]> Restructures the CPU class heirarchy to clarify model names and allow for per-model configuration options via HPPACPUDef. 32-bit HPPA is assumed to run a PA-7300LC, and 64-bit assumed to run a PA-8700. A new PA-8500 model is added, which will later be used by the A400 machine. All CPU models are made into children of the now abstract TYPE_HPPA_CPU base class.
Two fields are added to HPPACPUDef describing the size of the physical address space, and whether or not the CPU uses the PA-RISC 2.0 architecture. The latter was previously a field in CPUHPPAState. phys_addr_bits is currently set but unused, and will be used in the following commit. Likewise, PA-8700 is moved to use 44 bit physical addresses in a followup commit to not break bisection. References to "hppa/hppa64" models in test cases are also updated. Reviewed-by: Helge Deller <[email protected]> Signed-off-by: Anton Johansson <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- target/hppa/cpu-qom.h | 8 +++++- target/hppa/cpu.h | 24 +++++++++++++--- hw/hppa/machine.c | 21 ++++++++------ linux-user/hppa/elfload.c | 2 +- target/hppa/cpu.c | 50 +++++++++++++++++++++++++-------- tests/qtest/machine-none-test.c | 2 +- 6 files changed, 80 insertions(+), 27 deletions(-) diff --git a/target/hppa/cpu-qom.h b/target/hppa/cpu-qom.h index 5c454bf543b..7541c25b3d5 100644 --- a/target/hppa/cpu-qom.h +++ b/target/hppa/cpu-qom.h @@ -23,7 +23,13 @@ #include "hw/core/cpu.h" #define TYPE_HPPA_CPU "hppa-cpu" -#define TYPE_HPPA64_CPU "hppa64-cpu" + +#define HPPA_CPU_TYPE_SUFFIX "-" TYPE_HPPA_CPU +#define HPPA_CPU_TYPE_NAME(name) (name HPPA_CPU_TYPE_SUFFIX) + +#define TYPE_HPPA_CPU_PA_7300LC HPPA_CPU_TYPE_NAME("pa-7300lc") +#define TYPE_HPPA_CPU_PA_8500 HPPA_CPU_TYPE_NAME("pa-8500") +#define TYPE_HPPA_CPU_PA_8700 HPPA_CPU_TYPE_NAME("pa-8700") OBJECT_DECLARE_CPU_TYPE(HPPACPU, HPPACPUClass, HPPA_CPU) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 092e647ccf5..43b4882fb4f 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -270,8 +270,6 @@ typedef struct CPUArchState { /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; - bool is_pa20; - target_ulong kernel_entry; /* Linux kernel was loaded here */ target_ulong cmdline_or_bootorder; target_ulong initrd_base, initrd_end; @@ -290,6 +288,18 @@ struct ArchCPU { QEMUTimer *alarm_timer; }; +/** + * HPPACPUDef: + * @phys_addr_bits: Number of bits in the physical address space. + * @is_pa20: Whether the CPU model follows the PA-RISC 2.0 or 1.1 spec. + * + * Configuration options for a HPPA CPU model. + */ +typedef struct HPPACPUDef { + uint8_t phys_addr_bits; + bool is_pa20; +} HPPACPUDef; + /** * HPPACPUClass: * @parent_realize: The parent class' realize handler. @@ -302,11 +312,17 @@ struct HPPACPUClass { DeviceRealize parent_realize; ResettablePhases parent_phases; + const HPPACPUDef *def; }; -static inline bool hppa_is_pa20(const CPUHPPAState *env) +static inline const HPPACPUDef *hppa_def(CPUHPPAState *env) { - return env->is_pa20; + return HPPA_CPU_GET_CLASS(env_cpu(env))->def; +} + +static inline bool hppa_is_pa20(CPUHPPAState *env) +{ + return hppa_def(env)->is_pa20; } static inline int HPPA_BTLB_ENTRIES(CPUHPPAState *env) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index f55e84529f6..5d0d4de09ed 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -801,13 +801,13 @@ static void hppa_machine_common_class_init(ObjectClass *oc, const void *data) static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data) { static const char * const valid_cpu_types[] = { - TYPE_HPPA_CPU, + TYPE_HPPA_CPU_PA_7300LC, NULL }; MachineClass *mc = MACHINE_CLASS(oc); mc->desc = "HP B160L workstation"; - mc->default_cpu_type = TYPE_HPPA_CPU; + mc->default_cpu_type = TYPE_HPPA_CPU_PA_7300LC; mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_B160L_init; mc->is_default = true; @@ -817,13 +817,13 @@ static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data) static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data) { static const char * const valid_cpu_types[] = { - TYPE_HPPA64_CPU, + TYPE_HPPA_CPU_PA_8700, NULL }; MachineClass *mc = MACHINE_CLASS(oc); mc->desc = "HP C3700 workstation"; - mc->default_cpu_type = TYPE_HPPA64_CPU; + mc->default_cpu_type = TYPE_HPPA_CPU_PA_8700; mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_C3700_init; mc->max_cpus = HPPA_MAX_CPUS; @@ -833,13 +833,13 @@ static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data) static void HP_A400_machine_init_class_init(ObjectClass *oc, const void *data) { static const char * const valid_cpu_types[] = { - TYPE_HPPA64_CPU, + TYPE_HPPA_CPU_PA_8500, NULL }; MachineClass *mc = MACHINE_CLASS(oc); mc->desc = "HP A400-44 workstation"; - mc->default_cpu_type = TYPE_HPPA64_CPU; + mc->default_cpu_type = TYPE_HPPA_CPU_PA_8500; mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_A400_init; mc->max_cpus = HPPA_MAX_CPUS; @@ -849,13 +849,18 @@ static void HP_A400_machine_init_class_init(ObjectClass *oc, const void *data) static void HP_715_machine_init_class_init(ObjectClass *oc, const void *data) { static const char * const valid_cpu_types[] = { - TYPE_HPPA_CPU, + TYPE_HPPA_CPU_PA_7300LC, NULL }; MachineClass *mc = MACHINE_CLASS(oc); mc->desc = "HP 715/64 workstation"; - mc->default_cpu_type = TYPE_HPPA_CPU; + /* + * Although the 715 workstation should use a 7100LC, it can be safely + * modeled as a 7300LC as the difference is a moving of the L1 data cache + * to on-chip. + */ + mc->default_cpu_type = TYPE_HPPA_CPU_PA_7300LC; mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_715_init; /* can only support up to max. 8 CPUs due inventory major numbers */ diff --git a/linux-user/hppa/elfload.c b/linux-user/hppa/elfload.c index 46007087020..7f7ece6dc19 100644 --- a/linux-user/hppa/elfload.c +++ b/linux-user/hppa/elfload.c @@ -8,7 +8,7 @@ const char *get_elf_cpu_model(uint32_t eflags) { - return "hppa"; + return "pa-7300lc"; } const char *get_elf_platform(CPUState *cs) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 714f3bbdaf7..cc755da8be2 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -203,13 +203,6 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp) tcg_cflags_set(cs, CF_PCREL); } -static void hppa_cpu_initfn(Object *obj) -{ - CPUHPPAState *env = cpu_env(CPU(obj)); - - env->is_pa20 = !!object_dynamic_cast(obj, TYPE_HPPA64_CPU); -} - static void hppa_cpu_reset_hold(Object *obj, ResetType type) { HPPACPUClass *scc = HPPA_CPU_GET_CLASS(obj); @@ -236,9 +229,14 @@ static void hppa_cpu_reset_hold(Object *obj, ResetType type) static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model) { - g_autofree char *typename = g_strconcat(cpu_model, "-cpu", NULL); + ObjectClass *oc; + char *typename; - return object_class_by_name(typename); + typename = g_strdup_printf(HPPA_CPU_TYPE_NAME("%s"), cpu_model); + oc = object_class_by_name(typename); + g_free(typename); + + return oc; } #ifndef CONFIG_USER_ONLY @@ -279,6 +277,14 @@ static const TCGCPUOps hppa_tcg_ops = { #endif /* !CONFIG_USER_ONLY */ }; +static void hppa_cpu_class_base_init(ObjectClass *oc, const void *data) +{ + HPPACPUClass *acc = HPPA_CPU_CLASS(oc); + /* Make sure all CPU models define a HPPACPUDef */ + g_assert(!object_class_is_abstract(oc) && data != NULL); + acc->def = data; +} + static void hppa_cpu_class_init(ObjectClass *oc, const void *data) { DeviceClass *dc = DEVICE_CLASS(oc); @@ -313,14 +319,34 @@ static const TypeInfo hppa_cpu_type_infos[] = { .parent = TYPE_CPU, .instance_size = sizeof(HPPACPU), .instance_align = __alignof(HPPACPU), - .instance_init = hppa_cpu_initfn, - .abstract = false, + .abstract = true, .class_size = sizeof(HPPACPUClass), .class_init = hppa_cpu_class_init, + .class_base_init = hppa_cpu_class_base_init, }, { - .name = TYPE_HPPA64_CPU, + .name = TYPE_HPPA_CPU_PA_7300LC, .parent = TYPE_HPPA_CPU, + .class_data = &(const HPPACPUDef) { + .phys_addr_bits = 32, + .is_pa20 = false, + }, + }, + { + .name = TYPE_HPPA_CPU_PA_8500, + .parent = TYPE_HPPA_CPU, + .class_data = &(const HPPACPUDef) { + .phys_addr_bits = 40, + .is_pa20 = true, + }, + }, + { + .name = TYPE_HPPA_CPU_PA_8700, + .parent = TYPE_HPPA_CPU, + .class_data = &(const HPPACPUDef) { + .phys_addr_bits = 40, + .is_pa20 = true, + }, }, }; diff --git a/tests/qtest/machine-none-test.c b/tests/qtest/machine-none-test.c index c1e22dcecc7..bafd7d660ec 100644 --- a/tests/qtest/machine-none-test.c +++ b/tests/qtest/machine-none-test.c @@ -47,7 +47,7 @@ static struct arch2cpu cpus_map[] = { { "tricore", "tc1796" }, { "xtensa", "dc233c" }, { "xtensaeb", "fsf" }, - { "hppa", "hppa" }, + { "hppa", "pa-7300lc" }, { "riscv64", "rv64" }, { "riscv32", "rv32" }, { "rx", "rx62n" }, -- 2.53.0
