Commit 82634c2d748f6d418ee51bcc61c3dc7a99c9911b

Authored by Paul Brook
1 parent 3950f18b

ARM RealView sytem controller qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
Showing 1 changed file with 25 additions and 6 deletions
hw/arm_sysctl.c
... ... @@ -7,13 +7,14 @@
7 7 * This code is licenced under the GPL.
8 8 */
9 9  
10   -#include "hw.h"
  10 +#include "sysbus.h"
11 11 #include "primecell.h"
12 12 #include "sysemu.h"
13 13  
14 14 #define LOCK_VALUE 0xa05f
15 15  
16 16 typedef struct {
  17 + SysBusDevice busdev;
17 18 uint32_t sys_id;
18 19 uint32_t leds;
19 20 uint16_t lockval;
... ... @@ -188,18 +189,36 @@ static CPUWriteMemoryFunc *arm_sysctl_writefn[] = {
188 189 arm_sysctl_write
189 190 };
190 191  
191   -void arm_sysctl_init(uint32_t base, uint32_t sys_id)
  192 +static void arm_sysctl_init1(SysBusDevice *dev)
192 193 {
193   - arm_sysctl_state *s;
  194 + arm_sysctl_state *s = FROM_SYSBUS(arm_sysctl_state, dev);
194 195 int iomemtype;
195 196  
196   - s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
197   - s->sys_id = sys_id;
  197 + s->sys_id = qdev_get_prop_int(&dev->qdev, "sys_id", 0);
198 198 /* The MPcore bootloader uses these flags to start secondary CPUs.
199 199 We don't use a bootloader, so do this here. */
200 200 s->flags = 3;
201 201 iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
202 202 arm_sysctl_writefn, s);
203   - cpu_register_physical_memory(base, 0x00001000, iomemtype);
  203 + sysbus_init_mmio(dev, 0x1000, iomemtype);
204 204 /* ??? Save/restore. */
205 205 }
  206 +
  207 +/* Legacy helper function. */
  208 +void arm_sysctl_init(uint32_t base, uint32_t sys_id)
  209 +{
  210 + DeviceState *dev;
  211 +
  212 + dev = qdev_create(NULL, "realview_sysctl");
  213 + qdev_set_prop_int(dev, "sys_id", sys_id);
  214 + qdev_init(dev);
  215 + sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
  216 +}
  217 +
  218 +static void arm_sysctl_register_devices(void)
  219 +{
  220 + sysbus_register_dev("realview_sysctl", sizeof(arm_sysctl_state),
  221 + arm_sysctl_init1);
  222 +}
  223 +
  224 +device_init(arm_sysctl_register_devices)
... ...