diff --git a/hw/cr16c/Kconfig b/hw/cr16c/Kconfig index 8118288ae1..2dcda4fbe7 100644 --- a/hw/cr16c/Kconfig +++ b/hw/cr16c/Kconfig @@ -6,3 +6,8 @@ config VIRT config DE410 bool select DIALOG_UART + +config DH9 + bool + select UNIMP + select DIALOG_UART diff --git a/hw/cr16c/dh9.c b/hw/cr16c/dh9.c new file mode 100644 index 0000000000..6b8cab84c4 --- /dev/null +++ b/hw/cr16c/dh9.c @@ -0,0 +1,62 @@ +#include "boot.h" +#include "system/memory.h" +#include "hw/boards.h" +#include "hw/sysbus.h" +#include "qapi/error.h" +#include "qemu/units.h" +#include "qom/object.h" +#include "sc14445.h" + +typedef struct DH9MachineState { + MachineState parent_obj; + SC14445McuState mcu; + + MemoryRegion firmware; +} DH9MachineState; + +typedef struct DH9MachineClass { + MachineClass parent_class; +} DH9MachineClass; + +#define TYPE_DH9_MACHINE MACHINE_TYPE_NAME("dh9") + +DECLARE_OBJ_CHECKERS(DH9MachineState, DH9MachineClass, DH9_MACHINE, TYPE_DH9_MACHINE) + +static void dh9_init(MachineState* machine) +{ + DH9MachineState* m_state = DH9_MACHINE(machine); + + object_initialize_child(OBJECT(machine), "mcu", &m_state->mcu, TYPE_SC14445_MCU); + sysbus_realize(SYS_BUS_DEVICE(&m_state->mcu), &error_abort); + + // Provide an option to load a small program until the peripherals are implemented + if (machine->firmware) { + memory_region_init_ram(&m_state->firmware, NULL, "firmware", (0xA000-0x8080)*KiB, &error_fatal); + memory_region_add_subregion(&m_state->mcu.non_shared_ram_or_dcache, 0x80, &m_state->firmware); + cr16c_load_firmware(&m_state->mcu.cpu, &m_state->firmware, machine->firmware); + } +} + +static void dh9_class_init(ObjectClass* oc, const void* data) +{ + MachineClass* mc = MACHINE_CLASS(oc); + mc->desc = "Ascom DH9/DH10 OEM DECT phone (also known as Mitel 7xx series)"; + mc->init = dh9_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; +} + +static const TypeInfo dh9_machine_types[] = { + { + .name = TYPE_DH9_MACHINE, + .parent = TYPE_MACHINE, + .instance_size = sizeof(DH9MachineState), + .class_size = sizeof(DH9MachineClass), + .class_init = dh9_class_init, + } +}; +DEFINE_TYPES(dh9_machine_types); diff --git a/hw/cr16c/meson.build b/hw/cr16c/meson.build index c67d517a36..2c196c69bc 100644 --- a/hw/cr16c/meson.build +++ b/hw/cr16c/meson.build @@ -4,5 +4,6 @@ cr16c_ss.add(files('sc14445.c')) cr16c_ss.add(files('sc14461.c')) cr16c_ss.add(files('sc14480.c')) cr16c_ss.add(files('de410.c')) +cr16c_ss.add(files('dh9.c')) cr16c_ss.add(files('boot.c')) hw_arch += {'cr16c': cr16c_ss}