ramfb: simple boot framebuffer
v5 cover ramfb: simple boot framebuffer
Hi,
So, the first ramfb bits should be ready for merge. This series includes the ramfb core support bits, the ramfb standalone device and vfio-pci-ramfb device for vgpu boot display support.
If you want play with it I recommend getting the bits from
https://www.kraxel.org/cgit/qemu/log/?h=sirius/ramfb
because they come with an updated seabios and a new vgabios rom and an experimental OVMF build. Firmware patches are here:
https://www.kraxe.org/cgit/seabios/log/?h=ramfb
https://github.com/kraxel/edk2/commits/ramfb
They should land upstream soon.
changes:
v5: codestyle fixes.
cheers,
Gerd
Gerd Hoffmann (4):
hw/display: add ramfb, a simple boot framebuffer living in guest ram hw/display: add standalone ramfb device
hw/vfio/display: add ramfb support
Add ramfb MAINTAINERS entry
include/hw/display/ramfb.h | 12 ++++++ include/hw/vfio/vfio-common.h | 2 + hw/arm/sysbus-fdt.c | 7 ++++ hw/arm/virt.c | 2 + hw/display/ramfb-standalone.c | 62 ++++++++++++++++++++++++++++ hw/display/ramfb.c | 95 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc_piix.c | 2 + hw/i386/pc_q35.c | 2 + hw/vfio/display.c | 12 ++++++ hw/vfio/pci.c | 15 +++++++ MAINTAINERS | 6 +++ hw/display/Makefile.objs | 3 ++ 12 files changed, 220 insertions(+) create mode 100644 include/hw/display/ramfb.h create mode 100644 hw/display/ramfb-standalone.c create mode 100644 hw/display/ramfb.c
Signature · 1 line
2.9.3
PATCH v5 1/4 hw/display: add ramfb, a simple boot framebuffer living in guest ram
The boot framebuffer is expected to be configured by the firmware, so it uses fw_cfg as interface. Initialization goes as follows:
(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.
Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.
Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. For a boot display which is active for a short time only this isn't a big deal. As permanent guest display something better should be used (if possible).
This is the ramfb core code. Some windup is needed for display devices which want have a ramfb boot display.
--- include/hw/display/ramfb.h | 9 +++++ hw/display/ramfb.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ hw/display/Makefile.objs | 2 + 3 files changed, 106 insertions(+) create mode 100644 include/hw/display/ramfb.h create mode 100644 hw/display/ramfb.c
include/hw/display/ramfb.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef RAMFB_H +#define RAMFB_H + +/* ramfb.c */ +typedef struct RAMFBState RAMFBState ; +void ramfb_display_update (QemuConsole *con,RAMFBState *s); +RAMFBState *ramfb_setup (Error **errp); + +#endif /* RAMFB_H */
hw/display/ramfb.c new file +95 -0
95 lines not on this page · raw message
hw/display/Makefile.objs +2 -0
@@ -1,3 +1,5 @@ +common-obj-y += ramfb.o + common-obj-$(CONFIG_ADS7846) += ads7846.o common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o common-obj-$(CONFIG_G364FB) += g364fb.o
Signature · 1 line
2.9.3
Re: [Qemu-arm] [Qemu-devel] [PATCH v5 1/4] hw/display: add ramfb, a simple boot framebuffer living in guest ram
Quoted 20 lines · Gerd Hoffmann
The boot framebuffer is expected to be configured by the firmware, so it uses
fw_cfgas interface. Initialization goes as follows:(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.
Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. For a boot display which is active for a short time only this isn't a big deal. As permanent guest display something better should be used (if possible).
This is the ramfb core code. Some windup is needed for display devices which want have a ramfb boot display.
Quoted 8 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- include/hw/display/ramfb.h | 9 +++++ hw/display/ramfb.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ hw/display/Makefile.objs | 2 + 3 files changed, 106 insertions(+) create mode 100644 include/hw/display/ramfb.h create mode 100644 hw/display/ramfb.c
I tested this on KVM, built from Gerd's sirius/ramfb branch @ 778450b87275. Works fine with Gerd's corresponding edk2 QemuRamfbDxe driver (already merged):
[edk2] [PATCH v3 0/4] Add QemuRamfbDxe driver
http://mid.mail-archive.com/[email protected]
It also works fine with Ard's efifb patches:
[PATCH 0/2] efi: add support for cacheable efifb mappings
http://mid.mail-archive.com/[email protected]
So, for this patch (not the series):
Thanks!
Laszlo
PATCH v5 2/4 hw/display: add standalone ramfb device
In reply to Gerd Hoffmann--- include/hw/display/ramfb.h | 3 +++ hw/arm/sysbus-fdt.c | 7 +++++ hw/arm/virt.c | 2 ++ hw/display/ramfb-standalone.c | 62 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ hw/display/Makefile.objs | 1 + 7 files changed, 79 insertions(+) create mode 100644 hw/display/ramfb-standalone.c
include/hw/display/ramfb.h +3 -0
@@ -6,4 +6,7 @@ typedef struct RAMFBState RAMFBState;void ramfb_display_update (QemuConsole *con,RAMFBState *s);RAMFBState *ramfb_setup (Error **errp); +/* ramfb-standalone.c */ +#define TYPE_RAMFB_DEVICE "ramfb" +#endif /* RAMFB_H */
hw/arm/sysbus-fdt.c +7 -0
@@ -36,6 +36,7 @@#include "hw/vfio/vfio-platform.h" #include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-amd-xgbe.h" +#include "hw/display/ramfb.h" #include "hw/arm/fdt.h" /*
@@ -406,12 +407,18 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)#endif /* CONFIG_LINUX */ +static int no_fdt_node (SysBusDevice *sbdev,void *opaque) +{ +return 0 ; +} +/* list of supported dynamic sysbus devices */ static const NodeCreationPair add_fdt_node_functions[] = { #ifdef CONFIG_LINUX {TYPE_VFIO_CALXEDA_XGMAC , add_calxeda_midway_xgmac_fdt_node}, {TYPE_VFIO_AMD_XGBE , add_amd_xgbe_fdt_node}, #endif + {TYPE_RAMFB_DEVICE , no_fdt_node}, {"" ,NULL },/* last element */ };
hw/arm/virt.c +2 -0
@@ -36,6 +36,7 @@#include "hw/arm/virt.h" #include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-amd-xgbe.h" +#include "hw/display/ramfb.h" #include "hw/devices.h" #include "net/net.h" #include "sysemu/device_tree.h"
@@ -1659,6 +1660,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =255 ;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_VFIO_CALXEDA_XGMAC );machine_class_allow_dynamic_sysbus_dev (mc,TYPE_VFIO_AMD_XGBE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;
hw/display/ramfb-standalone.c new file +62 -0
62 lines not on this page · raw message
hw/i386/pc_piix.c +2 -0
@@ -28,6 +28,7 @@#include "hw/loader.h" #include "hw/i386/pc.h" #include "hw/i386/apic.h" +#include "hw/display/ramfb.h" #include "hw/smbios/smbios.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h"
@@ -423,6 +424,7 @@ static void pc_i440fx_machine_options(MachineClass *m) m->desc ="Standard PC (i440FX + PIIX, 1996)" ; m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; +machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); }static void pc_i440fx_3_0_machine_options (MachineClass *m)
hw/i386/pc_q35.c +2 -0
@@ -45,6 +45,7 @@#include "hw/i386/ich9.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/display/ramfb.h" #include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h"
@@ -305,6 +306,7 @@ static void pc_q35_machine_options(MachineClass *m) m->no_floppy =1 ;machine_class_allow_dynamic_sysbus_dev (m,TYPE_AMD_IOMMU_DEVICE );machine_class_allow_dynamic_sysbus_dev (m,TYPE_INTEL_IOMMU_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); m->max_cpus =288 ; }
hw/display/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ common-obj-y += ramfb.o +common-obj-y += ramfb-standalone.o common-obj-$(CONFIG_ADS7846) += ads7846.o common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 2/4] hw/display: add standalone ramfb device
Quoted 11 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/hw/display/ramfb.h | 3 +++ hw/arm/sysbus-fdt.c | 7 +++++ hw/arm/virt.c | 2 ++ hw/display/ramfb-standalone.c | 62 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ hw/display/Makefile.objs | 1 + 7 files changed, 79 insertions(+) create mode 100644 hw/display/ramfb-standalone.c
PATCH v5 3/4 hw/vfio/display: add ramfb support
In reply to Gerd HoffmannSo we have a boot display when using a vgpu as primary display.
Use vfio-pci-ramfb instead of vfio-pci to enable it.
--- include/hw/vfio/vfio-common.h | 2 ++ hw/vfio/display.c | 12 ++++++++++++ hw/vfio/pci.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+)
include/hw/vfio/vfio-common.h +2 -0
@@ -26,6 +26,7 @@#include "qemu/queue.h" #include "qemu/notify.h" #include "ui/console.h" +#include "hw/display/ramfb.h" #ifdef CONFIG_LINUX #include <linux/vfio.h> #endif
@@ -143,6 +144,7 @@ typedef struct VFIODMABuf { typedef struct VFIODisplay { QemuConsole *con; + RAMFBState *ramfb; struct { VFIORegion buffer; DisplaySurface *surface;
hw/vfio/display.c +12 -0
@@ -124,6 +124,9 @@ static void vfio_display_dmabuf_update(void *opaque) primary =vfio_display_get_dmabuf (vdev,DRM_PLANE_TYPE_PRIMARY );if (primary ==NULL ) { +if (dpy->ramfb) { +ramfb_display_update (dpy->con, dpy->ramfb); + }return ; }
@@ -181,6 +184,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) vdev->dpy->con =graphic_console_init (DEVICE (vdev),0 , &vfio_display_dmabuf_ops, vdev); +if (strcmp (object_get_typename (OBJECT (vdev)),"vfio-pci-ramfb" ) ==0 ) { + vdev->dpy->ramfb =ramfb_setup (errp); + }return 0 ; }
@@ -228,6 +234,9 @@ static void vfio_display_region_update(void *opaque)return ; }if (!plane.drm_format || !plane.size) { +if (dpy->ramfb) { +ramfb_display_update (dpy->con, dpy->ramfb); + }return ; } format =qemu_drm_format_to_pixman (plane.drm_format);
@@ -300,6 +309,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) vdev->dpy->con =graphic_console_init (DEVICE (vdev),0 , &vfio_display_region_ops, vdev); +if (strcmp (object_get_typename (OBJECT (vdev)),"vfio-pci-ramfb" ) ==0 ) { + vdev->dpy->ramfb =ramfb_setup (errp); + }return 0 ; }
hw/vfio/pci.c +15 -0
@@ -3234,9 +3234,24 @@ static const TypeInfo vfio_pci_dev_info = { }, }; +static void vfio_pci_ramfb_dev_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->hotpluggable = false; +} + +static const TypeInfo vfio_pci_ramfb_dev_info = { + .name ="vfio-pci-ramfb" , + .parent ="vfio-pci" , + .instance_size =sizeof (VFIOPCIDevice), + .class_init = vfio_pci_ramfb_dev_class_init, +}; +static void register_vfio_pci_dev_type (void ) {type_register_static (&vfio_pci_dev_info); +type_register_static (&vfio_pci_ramfb_dev_info); }type_init (register_vfio_pci_dev_type)
Signature · 1 line
2.9.3
PATCH v5 4/4 Add ramfb MAINTAINERS entry
In reply to Gerd Hoffmann--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -1331,6 +1331,12 @@ F: hw/display/bochs-display.c F: include/hw/display/vga.h F: include/hw/display/bochs-vbe.h +ramfb +M: Gerd Hoffmann <[email protected]> +S: Maintained +F: hw/display/ramfb*.c +F: include/hw/display/ramfb.h + virtio-gpu M: Gerd Hoffmann <[email protected]> S: Maintained
Signature · 1 line
2.9.3
Re: [Qemu-arm] [Qemu-devel] [PATCH v5 4/4] Add ramfb MAINTAINERS entry
Quoted 13 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)MAINTAINERS +0
-0@@ -1331,6 +1331,12 @@ F: hw/display/bochs-display.c F: include/hw/display/vga.h F: include/hw/display/bochs-vbe.h
MAINTAINERS F: hw/display/bochs-display.c · line 1342
Quoted 10 lines
MAINTAINERS +6
-0+ramfb +M: Gerd Hoffmann <[email protected]> +S: Maintained +F: hw/display/ramfb*.c +F: include/hw/display/ramfb.h + virtio-gpu M: Gerd Hoffmann <[email protected]> S: Maintained
I wonder if we should have a separate "display" section in this text file, or some such.
Thanks
Laszlo