summaryrefslogtreecommitdiff
path: root/hw/cs4231.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-10-24 16:20:32 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-10-24 16:20:32 +0000
commit82d4c6e683a05d507487be37757102c8ade77fc9 (patch)
tree461dabc14374f619187ad31f523084127028a036 /hw/cs4231.c
parent09330e90fe07debafb0cd49b9ffc90c6b2353cfb (diff)
downloadqemu-82d4c6e683a05d507487be37757102c8ade77fc9.tar.gz
qemu-82d4c6e683a05d507487be37757102c8ade77fc9.tar.bz2
qemu-82d4c6e683a05d507487be37757102c8ade77fc9.zip
sparc32: convert cs4231 to VMState, vmsd and reset
Also remove unused include directive. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/cs4231.c')
-rw-r--r--hw/cs4231.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/hw/cs4231.c b/hw/cs4231.c
index 843f86ed65..e161f19e27 100644
--- a/hw/cs4231.c
+++ b/hw/cs4231.c
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
-#include "sun4m.h"
#include "sysbus.h"
/* debug CS4231 */
@@ -54,9 +53,9 @@ typedef struct CSState {
#define DPRINTF(fmt, ...)
#endif
-static void cs_reset(void *opaque)
+static void cs_reset(DeviceState *d)
{
- CSState *s = opaque;
+ CSState *s = container_of(d, CSState, busdev.qdev);
memset(s->regs, 0, CS_REGS * 4);
memset(s->dregs, 0, CS_DREGS);
@@ -118,8 +117,9 @@ static void cs_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
case 2: // Read only
break;
case 4:
- if (val & 1)
- cs_reset(s);
+ if (val & 1) {
+ cs_reset(&s->busdev.qdev);
+ }
val &= 0x7f;
s->regs[saddr] = val;
break;
@@ -141,31 +141,17 @@ static CPUWriteMemoryFunc * const cs_mem_write[3] = {
cs_mem_writel,
};
-static void cs_save(QEMUFile *f, void *opaque)
-{
- CSState *s = opaque;
- unsigned int i;
-
- for (i = 0; i < CS_REGS; i++)
- qemu_put_be32s(f, &s->regs[i]);
-
- qemu_put_buffer(f, s->dregs, CS_DREGS);
-}
-
-static int cs_load(QEMUFile *f, void *opaque, int version_id)
-{
- CSState *s = opaque;
- unsigned int i;
-
- if (version_id > 1)
- return -EINVAL;
-
- for (i = 0; i < CS_REGS; i++)
- qemu_get_be32s(f, &s->regs[i]);
-
- qemu_get_buffer(f, s->dregs, CS_DREGS);
- return 0;
-}
+static const VMStateDescription vmstate_cs4231 = {
+ .name ="cs4231",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT32_ARRAY(regs, CSState, CS_REGS),
+ VMSTATE_UINT8_ARRAY(dregs, CSState, CS_DREGS),
+ VMSTATE_END_OF_LIST()
+ }
+};
static int cs4231_init1(SysBusDevice *dev)
{
@@ -176,9 +162,7 @@ static int cs4231_init1(SysBusDevice *dev)
sysbus_init_mmio(dev, CS_SIZE, io);
sysbus_init_irq(dev, &s->irq);
- register_savevm("cs4231", -1, 1, cs_save, cs_load, s);
- qemu_register_reset(cs_reset, s);
- cs_reset(s);
+ cs_reset(&s->busdev.qdev);
return 0;
}
@@ -186,6 +170,8 @@ static SysBusDeviceInfo cs4231_info = {
.init = cs4231_init1,
.qdev.name = "SUNW,CS4231",
.qdev.size = sizeof(CSState),
+ .qdev.vmsd = &vmstate_cs4231,
+ .qdev.reset = cs_reset,
.qdev.props = (Property[]) {
{.name = NULL}
}