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 6/9] PlatBus: Add serial-platbus device
Date: Mon, 22 Jul 2013 19:50:08 +0200 [thread overview]
Message-ID: <1374515411-43818-7-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1374515411-43818-1-git-send-email-agraf@suse.de>
We want to be able to spawn a serial console on the platform bus. Create
a small platbus wrapper device very similar to the ISA one.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/char/Makefile.objs | 1 +
hw/char/serial-platbus.c | 100 +++++++++++++++++++++++++++++++++++++++
include/hw/char/serial-platbus.h | 56 ++++++++++++++++++++++
3 files changed, 157 insertions(+)
create mode 100644 hw/char/serial-platbus.c
create mode 100644 include/hw/char/serial-platbus.h
diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs
index f8f3dbc..777796c 100644
--- a/hw/char/Makefile.objs
+++ b/hw/char/Makefile.objs
@@ -3,6 +3,7 @@ common-obj-$(CONFIG_ESCC) += escc.o
common-obj-$(CONFIG_PARALLEL) += parallel.o
common-obj-$(CONFIG_PL011) += pl011.o
common-obj-$(CONFIG_SERIAL) += serial.o serial-isa.o
+common-obj-$(CONFIG_SERIAL_PLATBUS) += serial-platbus.o
common-obj-$(CONFIG_SERIAL_PCI) += serial-pci.o
common-obj-$(CONFIG_VIRTIO) += virtio-console.o
common-obj-$(CONFIG_XILINX) += xilinx_uartlite.o
diff --git a/hw/char/serial-platbus.c b/hw/char/serial-platbus.c
new file mode 100644
index 0000000..ee3019c
--- /dev/null
+++ b/hw/char/serial-platbus.c
@@ -0,0 +1,100 @@
+/*
+ * QEMU 16550A UART emulation
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ * Copyright (c) 2008 Citrix Systems, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "hw/char/serial.h"
+#include "hw/char/serial-platbus.h"
+#include "hw/platbus/platbus.h"
+#include "hw/platbus/device.h"
+
+static void serial_platbus_realizefn(DeviceState *dev, Error **errp)
+{
+ PlatBusSerialClass *psc = PLATBUS_SERIAL_GET_CLASS(dev);
+ PlatBusSerialState *p = PLATBUS_SERIAL(dev);
+ SerialState *s = &p->state;
+
+ /* super() */
+ psc->parent_realize(dev, errp);
+
+ /* Initialize serial port */
+ s->baudbase = 115200;
+ serial_realize_core(s, errp);
+}
+
+static void serial_platbus_init(Object *obj)
+{
+ PlatBusSerialState *p = PLATBUS_SERIAL(obj);
+ SerialState *s = &p->state;
+ PlatBusDeviceState *pdev = &p->parent_obj;
+
+ /* Initialize static data */
+ memory_region_init_io(&s->io, OBJECT(p), &serial_io_ops, s, "serial", 8);
+
+ /* Populate parent fields */
+ platbus_device_set_irqs(pdev, &s->irq);
+ platbus_device_set_regions(pdev, &s->io);
+}
+
+static const VMStateDescription vmstate_platbus_serial = {
+ .name = "serial",
+ .version_id = 3,
+ .minimum_version_id = 2,
+ .fields = (VMStateField[]) {
+ VMSTATE_STRUCT(state, PlatBusSerialState, 0, vmstate_serial, SerialState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static Property serial_platbus_properties[] = {
+ DEFINE_PROP_CHR("chardev", PlatBusSerialState, state.chr),
+ DEFINE_PROP_UINT32("wakeup", PlatBusSerialState, state.wakeup, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void serial_platbus_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ PlatBusSerialClass *psc = PLATBUS_SERIAL_CLASS(oc);
+
+ psc->parent_realize = dc->realize;
+ dc->realize = serial_platbus_realizefn;
+ dc->vmsd = &vmstate_platbus_serial;
+ dc->props = serial_platbus_properties;
+}
+
+static const TypeInfo serial_platbus_info = {
+ .name = TYPE_PLATBUS_SERIAL,
+ .parent = TYPE_PLATBUS_DEVICE,
+ .instance_size = sizeof(PlatBusSerialState),
+ .instance_init = serial_platbus_init,
+ .class_init = serial_platbus_class_init,
+ .class_size = sizeof(PlatBusSerialClass),
+};
+
+static void serial_register_types(void)
+{
+ type_register_static(&serial_platbus_info);
+}
+
+type_init(serial_register_types)
diff --git a/include/hw/char/serial-platbus.h b/include/hw/char/serial-platbus.h
new file mode 100644
index 0000000..182ab77
--- /dev/null
+++ b/include/hw/char/serial-platbus.h
@@ -0,0 +1,56 @@
+/*
+ * QEMU 16550A UART emulation
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ * Copyright (c) 2008 Citrix Systems, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef HW_CHAR_SERIAL_PLATBUS_H
+#define HW_CHAR_SERIAL_PLATBUS_H
+
+#include "hw/char/serial.h"
+#include "hw/platbus/device.h"
+
+#define TYPE_PLATBUS_SERIAL "platbus-serial"
+#define PLATBUS_SERIAL(obj) OBJECT_CHECK(PlatBusSerialState, (obj), \
+ TYPE_PLATBUS_SERIAL)
+
+typedef struct PlatBusSerialState {
+ /*< private >*/
+ PlatBusDeviceState parent_obj;
+ /*< public >*/
+
+ SerialState state;
+} PlatBusSerialState;
+
+#define PLATBUS_SERIAL_CLASS(class) \
+ OBJECT_CLASS_CHECK(PlatBusSerialClass, (class), TYPE_PLATBUS_SERIAL)
+#define PLATBUS_SERIAL_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(PlatBusSerialClass, (obj), TYPE_PLATBUS_SERIAL)
+
+typedef struct PlatBusSerialClass {
+ /*< private >*/
+ DeviceClass parent_class;
+ /*< public >*/
+
+ DeviceRealize parent_realize;
+} PlatBusSerialClass;
+
+#endif /* !HW_CHAR_SERIAL_PLATBUS_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 ` [Qemu-devel] [PATCH 3/9] PlatBus: Add Sysbus/Platform bridge device Alexander Graf
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 ` Alexander Graf [this message]
2013-07-22 18:26 ` [Qemu-devel] [PATCH 6/9] PlatBus: Add serial-platbus device 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-7-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).