qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"László Érsek" <lersek@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 4/7] hw/display: add ramfb-testdev
Date: Fri, 23 Mar 2018 13:25:17 +0100	[thread overview]
Message-ID: <20180323122520.11270-5-kraxel@redhat.com> (raw)
In-Reply-To: <20180323122520.11270-1-kraxel@redhat.com>

Standalone device using ramfb.  Intended for testing only.  Offers
optional logging of vga port access, for debugging purposes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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

  parent reply	other threads:[~2018-03-23 12:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23 12:25 [Qemu-devel] [PATCH v2 0/7] ramfb: simple boot framebuffer, no legacy vga Gerd Hoffmann
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 1/7] [testing] update bios, add vgabios-ramfb Gerd Hoffmann
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 2/7] [testing] add ovmf build with ramfb support Gerd Hoffmann
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 3/7] hw/display: add ramfb, a simple boot framebuffer living in guest ram Gerd Hoffmann
2018-03-23 12:25 ` Gerd Hoffmann [this message]
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 5/7] hw/display: add virtio-ramfb Gerd Hoffmann
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 6/7] hw/vfio/display: add ramfb support Gerd Hoffmann
2018-03-23 12:25 ` [Qemu-devel] [PATCH v2 7/7] [wip] hw/display: add qxl-ramfb Gerd Hoffmann
2018-03-23 13:27 ` [Qemu-devel] [PATCH v2 0/7] ramfb: simple boot framebuffer, no legacy vga Laszlo Ersek
2018-03-23 14:51   ` Gerd Hoffmann
2018-03-23 15:12     ` Laszlo Ersek
2018-03-23 17:07       ` Gerd Hoffmann
2018-03-23 18:29         ` Laszlo Ersek
2018-03-24  3:51   ` Ard Biesheuvel
2018-04-25 14:07   ` Gerd Hoffmann
2018-04-25 20:43     ` Laszlo Ersek
2018-05-31  8:43       ` Gerd Hoffmann
2018-05-31  9:11         ` Laszlo Ersek
2018-06-05 11:06           ` Gerd Hoffmann
2018-06-05 12:07             ` Laszlo Ersek
2018-06-05 13:16               ` Gerd Hoffmann
2018-06-05 13:23                 ` Laszlo Ersek
2018-06-06  8:49                   ` Gerd Hoffmann
2018-06-06 12:43                     ` Laszlo Ersek
2018-06-06 13:21                       ` Gerd Hoffmann

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=20180323122520.11270-5-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@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).