diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-07-16 13:47:45 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-07-16 13:47:45 +0000 |
commit | fa28ec521bbc132556a5379f28eff60207cf9d7d (patch) | |
tree | d770db3cd0d3c14c97ad9a74ac974142a02364c4 /hw/cs4231.c | |
parent | d3ffcafe25b5966b351ea6100160c2156688f22f (diff) |
Sparc32: convert cs4231 to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/cs4231.c')
-rw-r--r-- | hw/cs4231.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/hw/cs4231.c b/hw/cs4231.c index a981b094fa..6d45be3ee1 100644 --- a/hw/cs4231.c +++ b/hw/cs4231.c @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" + #include "sun4m.h" +#include "sysbus.h" /* debug CS4231 */ //#define DEBUG_CS @@ -36,9 +37,10 @@ #define CS_MAXDREG (CS_DREGS - 1) typedef struct CSState { + SysBusDevice busdev; + qemu_irq irq; uint32_t regs[CS_REGS]; uint8_t dregs[CS_DREGS]; - void *intctl; } CSState; #define CS_RAP(s) ((s)->regs[0] & CS_MAXDREG) @@ -165,16 +167,32 @@ static int cs_load(QEMUFile *f, void *opaque, int version_id) return 0; } -void cs_init(target_phys_addr_t base, int irq, void *intctl) +static void cs4231_init1(SysBusDevice *dev) { - int cs_io_memory; - CSState *s; + int io; + CSState *s = FROM_SYSBUS(CSState, dev); - s = qemu_mallocz(sizeof(CSState)); + io = cpu_register_io_memory(cs_mem_read, cs_mem_write, s); + sysbus_init_mmio(dev, CS_SIZE, io); + sysbus_init_irq(dev, &s->irq); - cs_io_memory = cpu_register_io_memory(cs_mem_read, cs_mem_write, s); - cpu_register_physical_memory(base, CS_SIZE, cs_io_memory); - register_savevm("cs4231", base, 1, cs_save, cs_load, s); + register_savevm("cs4231", -1, 1, cs_save, cs_load, s); qemu_register_reset(cs_reset, s); cs_reset(s); } + +static SysBusDeviceInfo cs4231_info = { + .init = cs4231_init1, + .qdev.name = "SUNW,CS4231", + .qdev.size = sizeof(CSState), + .qdev.props = (DevicePropList[]) { + {.name = NULL} + } +}; + +static void cs4231_register_devices(void) +{ + sysbus_register_withprop(&cs4231_info); +} + +device_init(cs4231_register_devices) |