aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-07-16 13:47:45 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-07-16 13:47:45 +0000
commitfa28ec521bbc132556a5379f28eff60207cf9d7d (patch)
treed770db3cd0d3c14c97ad9a74ac974142a02364c4
parentd3ffcafe25b5966b351ea6100160c2156688f22f (diff)
Sparc32: convert cs4231 to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--hw/cs4231.c36
-rw-r--r--hw/sun4m.c6
-rw-r--r--hw/sun4m.h3
3 files changed, 31 insertions, 14 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)
diff --git a/hw/sun4m.c b/hw/sun4m.c
index f9ef298513..5d23f31ac2 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -580,8 +580,10 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
espdma_memory_read, espdma_memory_write,
espdma, espdma_irq, esp_reset);
- if (hwdef->cs_base)
- cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
+ if (hwdef->cs_base) {
+ sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
+ slavio_irq[hwdef->cs_irq]);
+ }
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
RAM_size);
diff --git a/hw/sun4m.h b/hw/sun4m.h
index 1dda117d8d..510c6bc06b 100644
--- a/hw/sun4m.h
+++ b/hw/sun4m.h
@@ -57,9 +57,6 @@ void *slavio_misc_init(target_phys_addr_t base,
void slavio_set_power_fail(void *opaque, int power_failing);
void apc_init(target_phys_addr_t power_base, qemu_irq cpu_halt);
-/* cs4231.c */
-void cs_init(target_phys_addr_t base, int irq, void *intctl);
-
/* sparc32_dma.c */
#include "sparc32_dma.h"