Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
q800: move CPU object into Q800MachineState
Also change the instantiation of the CPU to use object_initialize_child()
followed by a separate realisation.
Restrict valid CPU types to m68040.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230621085353.113233-6-mark.cave-ayland@ilande.co.uk>
[lv: update commit message]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
  • Loading branch information
mcayland authored and vivier committed Jun 22, 2023
1 parent 1a514d3 commit 36e2e33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 13 additions & 5 deletions hw/m68k/q800.c
Expand Up @@ -364,7 +364,7 @@ static uint8_t fake_mac_rom[] = {

static void q800_machine_init(MachineState *machine)
{
M68kCPU *cpu = NULL;
Q800MachineState *m = Q800_MACHINE(machine);
int linux_boot;
int32_t kernel_size;
uint64_t elf_entry;
Expand Down Expand Up @@ -407,8 +407,9 @@ static void q800_machine_init(MachineState *machine)
}

/* init CPUs */
cpu = M68K_CPU(cpu_create(machine->cpu_type));
qemu_register_reset(main_cpu_reset, cpu);
object_initialize_child(OBJECT(machine), "cpu", &m->cpu, machine->cpu_type);
qdev_realize(DEVICE(&m->cpu), NULL, &error_fatal);
qemu_register_reset(main_cpu_reset, &m->cpu);

/* RAM */
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
Expand All @@ -430,7 +431,8 @@ static void q800_machine_init(MachineState *machine)

/* IRQ Glue */
glue = qdev_new(TYPE_GLUE);
object_property_set_link(OBJECT(glue), "cpu", OBJECT(cpu), &error_abort);
object_property_set_link(OBJECT(glue), "cpu", OBJECT(&m->cpu),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(glue), &error_fatal);

/* VIA 1 */
Expand Down Expand Up @@ -605,7 +607,7 @@ static void q800_machine_init(MachineState *machine)

macfb_mode = (NUBUS_MACFB(dev)->macfb).mode;

cs = CPU(cpu);
cs = CPU(&m->cpu);
if (linux_boot) {
uint64_t high;
void *param_blob, *param_ptr, *param_rng_seed;
Expand Down Expand Up @@ -735,13 +737,19 @@ static GlobalProperty hw_compat_q800[] = {
};
static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800);

static const char *q800_machine_valid_cpu_types[] = {
M68K_CPU_TYPE_NAME("m68040"),
NULL
};

static void q800_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);

mc->desc = "Macintosh Quadra 800";
mc->init = q800_machine_init;
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
mc->valid_cpu_types = q800_machine_valid_cpu_types;
mc->max_cpus = 1;
mc->block_default_type = IF_SCSI;
mc->default_ram_id = "m68k_mac.ram";
Expand Down
3 changes: 3 additions & 0 deletions include/hw/m68k/q800.h
Expand Up @@ -25,13 +25,16 @@

#include "hw/boards.h"
#include "qom/object.h"
#include "target/m68k/cpu-qom.h"

/*
* The main Q800 machine
*/

struct Q800MachineState {
MachineState parent_obj;

M68kCPU cpu;
};

#define TYPE_Q800_MACHINE MACHINE_TYPE_NAME("q800")
Expand Down

0 comments on commit 36e2e33

Please sign in to comment.