70 lines
2.1 KiB
C
70 lines
2.1 KiB
C
#include "boot.h"
|
|
#include "cpu-qom.h"
|
|
#include "system/address-spaces.h"
|
|
#include "hw/boards.h"
|
|
#include "hw/misc/unimp.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu/units.h"
|
|
#include "qom/object.h"
|
|
|
|
typedef struct VirtMachineState {
|
|
MachineState parent_obj;
|
|
CR16CCPU cpu;
|
|
MemoryRegion flash;
|
|
MemoryRegion mmio_alias;
|
|
} VirtMachineState;
|
|
|
|
typedef struct VirtMachineClass {
|
|
MachineClass parent_class;
|
|
} VirtMachineClass;
|
|
|
|
#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
|
|
|
|
DECLARE_OBJ_CHECKERS(VirtMachineState, VirtMachineClass, VIRT_MACHINE, TYPE_VIRT_MACHINE)
|
|
|
|
static void virt_init(MachineState* machine)
|
|
{
|
|
VirtMachineState* m_state = VIRT_MACHINE(machine);
|
|
|
|
object_initialize_child(OBJECT(machine), "cpu", &m_state->cpu, TYPE_CR16C_CPU);
|
|
object_property_set_bool(OBJECT(&m_state->cpu), "realized", true, &error_abort);
|
|
|
|
memory_region_init_ram(&m_state->flash, NULL, "flash", 16*MiB - 64*KiB, &error_fatal);
|
|
memory_region_add_subregion(get_system_memory(), 0, &m_state->flash);
|
|
|
|
create_unimplemented_device("mmio", 0xFF0000, 0xFFBFFF - 0xFF0000);
|
|
//memory_region_init_alias(&m_state->mmio_alias, NULL, "mmio_alias", &m_state->flash, 0xF0000, 0xFFFFF - 0xF0000);
|
|
|
|
create_unimplemented_device("icu", 0xFFFC00, 0xFFFFFF - 0xFFFC00); // interrupt controller unit
|
|
|
|
if (machine->firmware) {
|
|
if (!cr16c_load_firmware(&m_state->cpu, &m_state->flash, machine->firmware)) {
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void virt_class_init(ObjectClass* oc, const void* data)
|
|
{
|
|
MachineClass* mc = MACHINE_CLASS(oc);
|
|
mc->desc = "Generic CR16C board for debugging, testing and development";
|
|
mc->init = virt_init;
|
|
mc->default_cpus = 1;
|
|
mc->min_cpus = 1;
|
|
mc->max_cpus = 1;
|
|
mc->no_floppy = 1;
|
|
mc->no_cdrom = 1;
|
|
mc->no_parallel = 1;
|
|
mc->is_default = 1;
|
|
}
|
|
|
|
static const TypeInfo virt_machine_types[] = {
|
|
{
|
|
.name = TYPE_VIRT_MACHINE,
|
|
.parent = TYPE_MACHINE,
|
|
.instance_size = sizeof(VirtMachineState),
|
|
.class_size = sizeof(VirtMachineClass),
|
|
.class_init = virt_class_init,
|
|
}
|
|
};
|
|
DEFINE_TYPES(virt_machine_types);
|