提交 3150fa50 编写于 作者: A Avi Kivity

sun4m: convert to memory API

Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 eb2fefbc
...@@ -593,19 +593,25 @@ static void idreg_init(target_phys_addr_t addr) ...@@ -593,19 +593,25 @@ static void idreg_init(target_phys_addr_t addr)
cpu_physical_memory_write_rom(addr, idreg_data, sizeof(idreg_data)); cpu_physical_memory_write_rom(addr, idreg_data, sizeof(idreg_data));
} }
typedef struct IDRegState {
SysBusDevice busdev;
MemoryRegion mem;
} IDRegState;
static int idreg_init1(SysBusDevice *dev) static int idreg_init1(SysBusDevice *dev)
{ {
ram_addr_t idreg_offset; IDRegState *s = FROM_SYSBUS(IDRegState, dev);
idreg_offset = qemu_ram_alloc(NULL, "sun4m.idreg", sizeof(idreg_data)); memory_region_init_ram(&s->mem, NULL, "sun4m.idreg", sizeof(idreg_data));
sysbus_init_mmio(dev, sizeof(idreg_data), idreg_offset | IO_MEM_ROM); memory_region_set_readonly(&s->mem, true);
sysbus_init_mmio_region(dev, &s->mem);
return 0; return 0;
} }
static SysBusDeviceInfo idreg_info = { static SysBusDeviceInfo idreg_info = {
.init = idreg_init1, .init = idreg_init1,
.qdev.name = "macio_idreg", .qdev.name = "macio_idreg",
.qdev.size = sizeof(SysBusDevice), .qdev.size = sizeof(IDRegState),
}; };
static void idreg_register_devices(void) static void idreg_register_devices(void)
...@@ -615,6 +621,11 @@ static void idreg_register_devices(void) ...@@ -615,6 +621,11 @@ static void idreg_register_devices(void)
device_init(idreg_register_devices); device_init(idreg_register_devices);
typedef struct AFXState {
SysBusDevice busdev;
MemoryRegion mem;
} AFXState;
/* SS-5 TCX AFX register */ /* SS-5 TCX AFX register */
static void afx_init(target_phys_addr_t addr) static void afx_init(target_phys_addr_t addr)
{ {
...@@ -630,17 +641,17 @@ static void afx_init(target_phys_addr_t addr) ...@@ -630,17 +641,17 @@ static void afx_init(target_phys_addr_t addr)
static int afx_init1(SysBusDevice *dev) static int afx_init1(SysBusDevice *dev)
{ {
ram_addr_t afx_offset; AFXState *s = FROM_SYSBUS(AFXState, dev);
afx_offset = qemu_ram_alloc(NULL, "sun4m.afx", 4); memory_region_init_ram(&s->mem, NULL, "sun4m.afx", 4);
sysbus_init_mmio(dev, 4, afx_offset | IO_MEM_RAM); sysbus_init_mmio_region(dev, &s->mem);
return 0; return 0;
} }
static SysBusDeviceInfo afx_info = { static SysBusDeviceInfo afx_info = {
.init = afx_init1, .init = afx_init1,
.qdev.name = "tcx_afx", .qdev.name = "tcx_afx",
.qdev.size = sizeof(SysBusDevice), .qdev.size = sizeof(AFXState),
}; };
static void afx_register_devices(void) static void afx_register_devices(void)
...@@ -650,6 +661,11 @@ static void afx_register_devices(void) ...@@ -650,6 +661,11 @@ static void afx_register_devices(void)
device_init(afx_register_devices); device_init(afx_register_devices);
typedef struct PROMState {
SysBusDevice busdev;
MemoryRegion prom;
} PROMState;
/* Boot PROM (OpenBIOS) */ /* Boot PROM (OpenBIOS) */
static uint64_t translate_prom_address(void *opaque, uint64_t addr) static uint64_t translate_prom_address(void *opaque, uint64_t addr)
{ {
...@@ -693,17 +709,18 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name) ...@@ -693,17 +709,18 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name)
static int prom_init1(SysBusDevice *dev) static int prom_init1(SysBusDevice *dev)
{ {
ram_addr_t prom_offset; PROMState *s = FROM_SYSBUS(PROMState, dev);
prom_offset = qemu_ram_alloc(NULL, "sun4m.prom", PROM_SIZE_MAX); memory_region_init_ram(&s->prom, NULL, "sun4m.prom", PROM_SIZE_MAX);
sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM); memory_region_set_readonly(&s->prom, true);
sysbus_init_mmio_region(dev, &s->prom);
return 0; return 0;
} }
static SysBusDeviceInfo prom_info = { static SysBusDeviceInfo prom_info = {
.init = prom_init1, .init = prom_init1,
.qdev.name = "openprom", .qdev.name = "openprom",
.qdev.size = sizeof(SysBusDevice), .qdev.size = sizeof(PROMState),
.qdev.props = (Property[]) { .qdev.props = (Property[]) {
{/* end of property list */} {/* end of property list */}
} }
...@@ -719,19 +736,17 @@ device_init(prom_register_devices); ...@@ -719,19 +736,17 @@ device_init(prom_register_devices);
typedef struct RamDevice typedef struct RamDevice
{ {
SysBusDevice busdev; SysBusDevice busdev;
MemoryRegion ram;
uint64_t size; uint64_t size;
} RamDevice; } RamDevice;
/* System RAM */ /* System RAM */
static int ram_init1(SysBusDevice *dev) static int ram_init1(SysBusDevice *dev)
{ {
ram_addr_t RAM_size, ram_offset;
RamDevice *d = FROM_SYSBUS(RamDevice, dev); RamDevice *d = FROM_SYSBUS(RamDevice, dev);
RAM_size = d->size; memory_region_init_ram(&d->ram, NULL, "sun4m.ram", d->size);
sysbus_init_mmio_region(dev, &d->ram);
ram_offset = qemu_ram_alloc(NULL, "sun4m.ram", RAM_size);
sysbus_init_mmio(dev, RAM_size, ram_offset);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册