@@ -26,6 +26,7 @@
#include "hw/boards.h"
#include "qom/object.h"
#include "target/m68k/cpu-qom.h"
+#include "exec/memory.h"
/*
* The main Q800 machine
@@ -35,6 +36,7 @@ struct Q800MachineState {
MachineState parent_obj;
M68kCPU cpu;
+ MemoryRegion rom;
};
#define TYPE_Q800_MACHINE MACHINE_TYPE_NAME("q800")
@@ -372,7 +372,6 @@ static void q800_machine_init(MachineState *machine)
int bios_size;
ram_addr_t initrd_base;
int32_t initrd_size;
- MemoryRegion *rom;
MemoryRegion *io;
MemoryRegion *dp8393x_prom = g_new(MemoryRegion, 1);
uint8_t *prom;
@@ -646,11 +645,10 @@ static void q800_machine_init(MachineState *machine)
BOOTINFO1(param_ptr, BI_MAC_VROW, macfb_mode->stride);
BOOTINFO1(param_ptr, BI_MAC_SCCBASE, SCC_BASE);
- rom = g_malloc(sizeof(*rom));
- memory_region_init_ram_ptr(rom, NULL, "m68k_fake_mac.rom",
+ memory_region_init_ram_ptr(&m->rom, NULL, "m68k_fake_mac.rom",
sizeof(fake_mac_rom), fake_mac_rom);
- memory_region_set_readonly(rom, true);
- memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
+ memory_region_set_readonly(&m->rom, true);
+ memory_region_add_subregion(get_system_memory(), MACROM_ADDR, &m->rom);
if (kernel_cmdline) {
BOOTINFOSTR(param_ptr, BI_COMMAND_LINE,
@@ -692,11 +690,10 @@ static void q800_machine_init(MachineState *machine)
} else {
uint8_t *ptr;
/* allocate and load BIOS */
- rom = g_malloc(sizeof(*rom));
- memory_region_init_rom(rom, NULL, "m68k_mac.rom", MACROM_SIZE,
+ memory_region_init_rom(&m->rom, NULL, "m68k_mac.rom", MACROM_SIZE,
&error_abort);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
+ memory_region_add_subregion(get_system_memory(), MACROM_ADDR, &m->rom);
/* Load MacROM binary */
if (filename) {