diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:09 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:09 +0100 |
commit | 5493e33f12b75207f8b1bb993ba97e47b3d8de85 (patch) | |
tree | af7cad82e49aa2d0aaf227f9d2bac88bb3bf5f27 /hw/ssi-sd.c | |
parent | 90d37239d4051281d2882117efc73020046c32ca (diff) |
Stellaris SSI qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/ssi-sd.c')
-rw-r--r-- | hw/ssi-sd.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/hw/ssi-sd.c b/hw/ssi-sd.c index a1af85b70c..3e78bd2ac3 100644 --- a/hw/ssi-sd.c +++ b/hw/ssi-sd.c @@ -1,14 +1,15 @@ /* * SSI to SD card adapter. * - * Copyright (c) 2007 CodeSourcery. + * Copyright (c) 2007-2009 CodeSourcery. * Written by Paul Brook * - * This code is licenced under the GPL. + * This code is licenced under the GNU GPL v2. */ -#include "hw.h" +#include "ssi.h" #include "sd.h" +#include "sysemu.h" //#define DEBUG_SSI_SD 1 @@ -32,6 +33,7 @@ typedef enum { } ssi_sd_mode; typedef struct { + SSISlave ssidev; ssi_sd_mode mode; int cmd; uint8_t cmdarg[4]; @@ -59,9 +61,9 @@ typedef struct { #define SSI_SDR_ADDRESS_ERROR 0x2000 #define SSI_SDR_PARAMETER_ERROR 0x4000 -int ssi_sd_xfer(void *opaque, int val) +static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) { - ssi_sd_state *s = (ssi_sd_state *)opaque; + ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, dev); /* Special case: allow CMD12 (STOP TRANSMISSION) while reading data. */ if (s->mode == SSI_SD_DATA_READ && val == 0x4d) { @@ -227,13 +229,25 @@ static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id) return 0; } -void *ssi_sd_init(BlockDriverState *bs) +static void ssi_sd_init(SSISlave *dev) { - ssi_sd_state *s; + ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, dev); + BlockDriverState *bs; - s = (ssi_sd_state *)qemu_mallocz(sizeof(ssi_sd_state)); s->mode = SSI_SD_CMD; + bs = qdev_init_bdrv(&dev->qdev, IF_SD); s->sd = sd_init(bs, 1); register_savevm("ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s); - return s; } + +static SSISlaveInfo ssi_sd_info = { + .init = ssi_sd_init, + .transfer = ssi_sd_transfer +}; + +static void ssi_sd_register_devices(void) +{ + ssi_register_slave("ssi-sd", sizeof(ssi_sd_state), &ssi_sd_info); +} + +device_init(ssi_sd_register_devices) |