@@ -37,6 +37,7 @@
#include "loader.h"
#include "mc146818rtc.h"
#include "rc4030.h"
+#include "sysbus.h"
enum jazz_model_e
{
@@ -274,6 +275,14 @@ void mips_pica61_init (ram_addr_t ram_size,
mips_jazz_init(ram_size, cpu_model, JAZZ_PICA61);
}
+static
+void empty_init (ram_addr_t ram_size,
+ const char *boot_device,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+}
+
static QEMUMachine mips_magnum_machine = {
.name = "magnum",
.desc = "MIPS Magnum",
@@ -288,10 +297,79 @@ static QEMUMachine mips_pica61_machine = {
.use_scsi = 1,
};
+static QEMUMachine empty_machine = {
+ .name = "empty",
+ .desc = "Empty machine",
+ .init = empty_init,
+};
+
static void mips_jazz_machine_init(void)
{
qemu_register_machine(&mips_magnum_machine);
qemu_register_machine(&mips_pica61_machine);
+ qemu_register_machine(&empty_machine);
}
machine_init(mips_jazz_machine_init);
+
+typedef struct MipsBoardState {
+ SysBusDevice busdev;
+
+ char *romfile;
+ uint32_t romsize;
+ uint32_t ramsize;
+} MipsBoardState;
+
+static int mips_board_device_init(SysBusDevice *dev)
+{
+ MipsBoardState *s = FROM_SYSBUS(MipsBoardState, dev);
+ int bios_size;
+ ram_addr_t ram_size;
+ ram_addr_t ram_offset;
+ ram_addr_t bios_offset;
+
+ /* allocate RAM */
+ ram_size = s->ramsize * 1024 * 1024;
+ ram_offset = qemu_ram_alloc(NULL, "mips_jazz.ram", ram_size);
+ cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
+
+ /* load the BIOS image */
+ if (s->romfile) {
+ bios_offset = qemu_ram_alloc(NULL, "mips_jazz.bios", s->romsize);
+ cpu_register_physical_memory(0x1fc00000LL,
+ s->romsize, bios_offset | IO_MEM_ROM);
+ cpu_register_physical_memory(0xfff00000LL,
+ s->romsize, bios_offset | IO_MEM_ROM);
+
+ bios_size = load_image_targphys(s->romfile,
+ 0x1fc00000LL,
+ s->romsize);
+
+ bios_size = load_image_targphys(s->romfile,
+ 0xfff00000LL,
+ s->romsize);
+ if (bios_size != s->romsize) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static SysBusDeviceInfo board_device_info = {
+ .qdev.name = "mips-board",
+ .qdev.size = sizeof(MipsBoardState),
+ .init = mips_board_device_init,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_STRING("romfile", MipsBoardState, romfile),
+ DEFINE_PROP_HEX32("romsize", MipsBoardState, romsize, 0x40000),
+ DEFINE_PROP_UINT32("ramsize", MipsBoardState, ramsize, 64),
+ DEFINE_PROP_END_OF_LIST(),
+ },
+};
+
+static void mips_register_devices(void)
+{
+ sysbus_register_withprop(&board_device_info);
+}
+
+device_init(mips_register_devices)
@@ -455,6 +455,12 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
BusState *child, *ret;
int match = 1;
+ if (!bus) {
+ if (!main_system_bus) {
+ main_system_bus = qbus_create(&system_bus_info, NULL, "main-system-bus");
+ }
+ return main_system_bus;
+ }
if (name && (strcmp(bus->name, name) != 0)) {
match = 0;
}
Also add an empty machine (to be used with the mips board device) Finally, add a workaround to be able to create the initial system bus Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> --- hw/mips_jazz.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.c | 6 ++++ 2 files changed, 84 insertions(+), 0 deletions(-)