@@ -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
new file mode 100644
@@ -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)
new file mode 100644
@@ -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 */
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