From: Alexander Graf <agraf@suse.de>
To: "qemu-ppc@nongnu.org list:PowerPC" <qemu-ppc@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 3/9] PlatBus: Add Sysbus/Platform bridge device
Date: Mon, 22 Jul 2013 19:50:05 +0200 [thread overview]
Message-ID: <1374515411-43818-4-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1374515411-43818-1-git-send-email-agraf@suse.de>
We have to be able to plug our platform bus into an existing system somehow.
To achieve this, we add a sysbus <-> platbus bridge device that maps an
arbitrary number of IRQ lines to a self-contained linear platform IRQ range.
It also provides a memory region that is the parent region for all platform
devices that get created below this bus.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/platbus/bridge.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
include/hw/platbus/bridge.h | 32 +++++++++++++++++++++++
2 files changed, 96 insertions(+)
create mode 100644 hw/platbus/bridge.c
create mode 100644 include/hw/platbus/bridge.h
diff --git a/hw/platbus/bridge.c b/hw/platbus/bridge.c
new file mode 100644
index 0000000..356d254
--- /dev/null
+++ b/hw/platbus/bridge.c
@@ -0,0 +1,64 @@
+/*
+ * Sysbus to Platform bus bridge device
+ *
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * Authors: Alexander Graf, <agraf@suse.de>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This bridge device allows you to plug a platform bus into your existing
+ * system bus.
+ */
+
+#include "qemu-common.h"
+#include "hw/platbus/bridge.h"
+
+static void platbus_bridge_realize(DeviceState *dev, Error **errp)
+{
+ SysBusDevice *d = SYS_BUS_DEVICE(dev);
+ PlatBusBridgeState *s = PLATBUS_BRIDGE(dev);
+ int i;
+
+ /* Create platform bus */
+ qbus_create_inplace(&s->bus.parent_obj, TYPE_PLAT_BUS, dev, NULL);
+
+ /* Wire up all platbus IRQs to sysbus IRQs. */
+ for (i = 0; i < s->nr_irqs; i++) {
+ sysbus_init_irq(d, &s->bus.irqs[i]);
+ platbus_add_irq(&s->bus, i);
+ }
+
+ /* Advertise our platbus memory hole to sysbus. Through this a guest OS
+ can access platbus devices */
+ sysbus_init_mmio(d, &s->bus.mem);
+}
+
+static Property platbus_bridge_properties[] = {
+ DEFINE_PROP_UINT32("nr_irqs", PlatBusBridgeState, nr_irqs, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void serial_platbus_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ dc->props = platbus_bridge_properties;
+ dc->realize = platbus_bridge_realize;
+}
+
+static const TypeInfo platbus_bridge_type_info = {
+ .name = TYPE_PLATBUS_BRIDGE,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(PlatBusBridgeState),
+ .class_init = serial_platbus_class_init,
+};
+
+static void platbus_bridge_register_types(void)
+{
+ type_register_static(&platbus_bridge_type_info);
+}
+
+type_init(platbus_bridge_register_types)
diff --git a/include/hw/platbus/bridge.h b/include/hw/platbus/bridge.h
new file mode 100644
index 0000000..4d31fcb
--- /dev/null
+++ b/include/hw/platbus/bridge.h
@@ -0,0 +1,32 @@
+/*
+ * Generic platform bus with dynamic IRQ and IO placement
+ *
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * Authors: Alexander Graf, <agraf@suse.de>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef QEMU_HW_PLATBUS_BRIDGE_H
+#define QEMU_HW_PLATBUS_BRIDGE_H
+
+#include "platbus.h"
+#include "hw/sysbus.h"
+
+#define TYPE_PLATBUS_BRIDGE "platbus-bridge"
+#define PLATBUS_BRIDGE(obj) OBJECT_CHECK(PlatBusBridgeState, (obj), TYPE_PLATBUS_BRIDGE)
+
+typedef struct PlatBusBridgeState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ PlatBusState bus;
+ uint32_t nr_irqs;
+} PlatBusBridgeState;
+
+#endif /* !QEMU_HW_PLATBUS_BRIDGE_H */
--
1.8.1.4
next prev parent reply other threads:[~2013-07-22 17:50 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 17:50 [Qemu-devel] [PATCH 0/9] Add platform bus Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 1/9] PlatBus: Add Platform Bus Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 2/9] PlatBus: Add abstract Platform Device Alexander Graf
2013-07-22 17:50 ` Alexander Graf [this message]
2013-07-22 17:50 ` [Qemu-devel] [PATCH 4/9] PlatBus: Hook up into Makefile system Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 5/9] PPC: Add platform bus to the default compile set Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 6/9] PlatBus: Add serial-platbus device Alexander Graf
2013-07-22 18:26 ` Peter Maydell
2013-07-22 18:56 ` Alexander Graf
2013-07-24 20:16 ` Scott Wood
2013-07-24 20:25 ` Peter Maydell
2013-07-22 17:50 ` [Qemu-devel] [PATCH 7/9] PPC: Add PlatBus Serial to default configs Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 8/9] PPC: E500: Spawn PlatBus bridge for ppce500 machine Alexander Graf
2013-07-22 17:50 ` [Qemu-devel] [PATCH 9/9] PPC: E500: Add PlatBus device tree walker Alexander Graf
2013-07-22 18:21 ` [Qemu-devel] [PATCH 0/9] Add platform bus Peter Maydell
2013-07-22 18:55 ` Alexander Graf
2013-07-23 12:19 ` Paolo Bonzini
2013-07-23 12:22 ` Peter Maydell
2013-07-23 12:34 ` Paolo Bonzini
2013-07-23 12:40 ` Peter Maydell
2013-07-23 13:06 ` Paolo Bonzini
2013-07-23 14:26 ` Anthony Liguori
2013-07-23 14:28 ` Peter Maydell
2013-07-23 12:29 ` François Revol
2013-07-22 19:38 ` Anthony Liguori
2013-07-22 19:44 ` Alexander Graf
2013-07-22 19:52 ` Anthony Liguori
2013-07-22 21:50 ` Peter Maydell
2013-07-22 22:05 ` Anthony Liguori
2013-07-22 22:34 ` Peter Maydell
2013-07-22 23:03 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374515411-43818-4-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).