aboutsummaryrefslogtreecommitdiff
path: root/hw/ssi.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:09 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:09 +0100
commit90d37239d4051281d2882117efc73020046c32ca (patch)
treee9861ffff211a45026d66271e4889b7d410e1a49 /hw/ssi.c
parent1de9610c8ff80aa2a47b6cbe8c198b935916feda (diff)
SSP bus framework
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/ssi.c')
-rw-r--r--hw/ssi.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/hw/ssi.c b/hw/ssi.c
new file mode 100644
index 0000000000..9dfdbe94f8
--- /dev/null
+++ b/hw/ssi.c
@@ -0,0 +1,52 @@
+/*
+ * QEMU Synchronous Serial Interface support
+ *
+ * Copyright (c) 2009 CodeSourcery.
+ * Written by Paul Brook
+ *
+ * This code is licenced under the GNU GPL v2.
+ */
+
+#include "ssi.h"
+
+struct SSIBus {
+ SSISlave *slave;
+};
+
+static void ssi_slave_init(DeviceState *dev, void *opaque)
+{
+ SSISlaveInfo *info = opaque;
+ SSISlave *s = SSI_SLAVE_FROM_QDEV(dev);
+ SSIBus *bus = qdev_get_bus(dev);
+
+ bus->slave = s;
+ s->info = info;
+ info->init(s);
+}
+
+void ssi_register_slave(const char *name, int size, SSISlaveInfo *info)
+{
+ assert(size >= sizeof(SSISlave));
+ qdev_register(name, size, ssi_slave_init, info);
+}
+
+DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
+{
+ DeviceState *dev;
+ dev = qdev_create(bus, name);
+ qdev_init(dev);
+ return dev;
+}
+
+SSIBus *ssi_create_bus(void)
+{
+ return qemu_mallocz(sizeof(SSIBus));
+}
+
+uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
+{
+ if (!bus->slave) {
+ return 0;
+ }
+ return bus->slave->info->transfer(bus->slave, val);
+}