[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/7] hw/display: add ramfb-testdev
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH v2 4/7] hw/display: add ramfb-testdev |
Date: |
Fri, 23 Mar 2018 13:25:17 +0100 |
Standalone device using ramfb. Intended for testing only. Offers
optional logging of vga port access, for debugging purposes.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/display/ramfb-testdev.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++
hw/display/Makefile.objs | 1 +
2 files changed, 97 insertions(+)
create mode 100644 hw/display/ramfb-testdev.c
diff --git a/hw/display/ramfb-testdev.c b/hw/display/ramfb-testdev.c
new file mode 100644
index 0000000000..1e65cf4957
--- /dev/null
+++ b/hw/display/ramfb-testdev.c
@@ -0,0 +1,96 @@
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/loader.h"
+#include "hw/isa/isa.h"
+#include "hw/display/ramfb.h"
+#include "ui/console.h"
+#include "sysemu/sysemu.h"
+
+#define TYPE_RAMFB "ramfb-testdev"
+#define RAMFB(obj) OBJECT_CHECK(ISARAMFBState, (obj), TYPE_RAMFB)
+
+typedef struct ISARAMFBState {
+ ISADevice parent_obj;
+ QemuConsole *con;
+ RAMFBState *state;
+ PortioList vga_port_list;
+ bool vgalog;
+} ISARAMFBState;
+
+/* log vga port activity, for trouble-shooting purposes */
+static uint32_t vga_log_read(void *opaque, uint32_t addr)
+{
+ fprintf(stderr, "%s: port 0x%x\n", __func__, addr);
+ return -1;
+}
+
+static void vga_log_write(void *opaque, uint32_t addr, uint32_t val)
+{
+ fprintf(stderr, "%s: port 0x%x, value 0x%x\n", __func__, addr, val);
+}
+
+static const MemoryRegionPortio vga_portio_list[] = {
+ { 0x04, 2, 1, .read = vga_log_read, .write = vga_log_write }, /* 3b4 */
+ { 0x0a, 1, 1, .read = vga_log_read, .write = vga_log_write }, /* 3ba */
+ { 0x10, 16, 1, .read = vga_log_read, .write = vga_log_write }, /* 3c0 */
+ { 0x24, 2, 1, .read = vga_log_read, .write = vga_log_write }, /* 3d4 */
+ { 0x2a, 1, 1, .read = vga_log_read, .write = vga_log_write }, /* 3da */
+ PORTIO_END_OF_LIST(),
+};
+
+static void display_update_wrapper(void *dev)
+{
+ ISARAMFBState *ramfb = RAMFB(dev);
+
+ if (0 /* native driver active */) {
+ /* non-test device would run native display update here */;
+ } else {
+ ramfb_display_update(ramfb->con, ramfb->state);
+ }
+}
+
+static const GraphicHwOps wrapper_ops = {
+ .gfx_update = display_update_wrapper,
+};
+
+static void ramfb_realizefn(DeviceState *dev, Error **errp)
+{
+ ISARAMFBState *ramfb = RAMFB(dev);
+
+ ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
+ ramfb->state = ramfb_setup(errp);
+
+ if (ramfb->vgalog) {
+ isa_register_portio_list(ISA_DEVICE(dev), &ramfb->vga_port_list,
+ 0x3b0, vga_portio_list, NULL, "log-vga");
+ }
+}
+
+static Property ramfb_properties[] = {
+ DEFINE_PROP_BOOL("vgalog", struct ISARAMFBState, vgalog, false),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void ramfb_class_initfn(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
+ dc->realize = ramfb_realizefn;
+ dc->props = ramfb_properties;
+ dc->desc = "ram framebuffer test device";
+}
+
+static const TypeInfo ramfb_info = {
+ .name = TYPE_RAMFB,
+ .parent = TYPE_ISA_DEVICE,
+ .instance_size = sizeof(ISARAMFBState),
+ .class_init = ramfb_class_initfn,
+};
+
+static void ramfb_register_types(void)
+{
+ type_register_static(&ramfb_info);
+}
+
+type_init(ramfb_register_types)
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index fae17fd5ea..07d2f48782 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -1,4 +1,5 @@
common-obj-y += ramfb.o
+common-obj-$(CONFIG_VGA_ISA) += ramfb-testdev.o
common-obj-$(CONFIG_ADS7846) += ads7846.o
common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
--
2.9.3
- [Qemu-devel] [PATCH v2 0/7] ramfb: simple boot framebuffer, no legacy vga, Gerd Hoffmann, 2018/03/23
- [Qemu-devel] [PATCH v2 6/7] hw/vfio/display: add ramfb support, Gerd Hoffmann, 2018/03/23
- [Qemu-devel] [PATCH v2 5/7] hw/display: add virtio-ramfb, Gerd Hoffmann, 2018/03/23
- [Qemu-devel] [PATCH v2 4/7] hw/display: add ramfb-testdev,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH v2 7/7] [wip] hw/display: add qxl-ramfb, Gerd Hoffmann, 2018/03/23
- [Qemu-devel] [PATCH v2 3/7] hw/display: add ramfb, a simple boot framebuffer living in guest ram, Gerd Hoffmann, 2018/03/23
- [Qemu-devel] [PATCH v2 1/7] [testing] update bios, add vgabios-ramfb, Gerd Hoffmann, 2018/03/23
- Re: [Qemu-devel] [PATCH v2 0/7] ramfb: simple boot framebuffer, no legacy vga, Laszlo Ersek, 2018/03/23
- Re: [Qemu-devel] [PATCH v2 0/7] ramfb: simple boot framebuffer, no legacy vga, Ard Biesheuvel, 2018/03/23
[Qemu-devel] [PATCH v2 2/7] [testing] add ovmf build with ramfb support, Gerd Hoffmann, 2018/03/23