video: add support for QEMU ramfb
Subsystems (4)
v2 cover video: add support for QEMU ramfb
QEMU's ramfb is a very simple Qemu fw_cfg protocol, where the guest need only write a video settings structure to /etc/ramfb to get DMA from the framebuffer working. Add a driver for this on top of a newly added character device interface.
Adrian Negreanu (1):
video: add support for QEMU ramfb
Ahmad Fatoum (3):
fs: devfs: implement cdev_fdopen
asm-generic: avoid compiler warnings due to PCI_IOBASE
firmware: add QEMU FW CFG driver
drivers/firmware/Kconfig | 10 + drivers/firmware/Makefile | 1 + drivers/firmware/qemu_fw_cfg.c | 307 +++++++++++++++++++++++++++++++ drivers/video/Kconfig | 6 + drivers/video/Makefile | 1 + drivers/video/ramfb.c | 191 +++++++++++++++++++ fs/devfs-core.c | 20 ++ include/asm-generic/io.h | 3 +- include/driver.h | 1 + include/filetype.h | 1 + include/uapi/linux/qemu_fw_cfg.h | 100 ++++++++++ 11 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/qemu_fw_cfg.c create mode 100644 drivers/video/ramfb.c create mode 100644 include/uapi/linux/qemu_fw_cfg.h
Signature · 1 line
2.38.1
PATCH v2 1/4 fs: devfs: implement cdev_fdopen
As an alternative to cdev_open and using cdev_read/write, we define a new cdev_fdopen function that returns a file descriptor. The benefit of this is that code using it may use all the more high level helpers we have for reading/writing file descriptors.
--- fs/devfs-core.c | 20 ++++++++++++++++++++ include/driver.h | 1 + 2 files changed, 21 insertions(+)
fs/devfs-core.c +20 -0
@@ -177,6 +177,26 @@ int cdev_open(struct cdev *cdev, unsigned long flags)return 0 ; } +int cdev_fdopen (struct cdev *cdev,unsigned long flags) +{ +char *path; +int fd; + +if (!cdev) +return -ENODEV ; +if (IS_ERR (cdev)) +return PTR_ERR (cdev); + + path =basprintf ("/dev/%s" , cdev->name); +if (!path) +return -ENOMEM ; + + fd =open (path, flags); + +free (path); +return fd; +} +struct cdev *cdev_open_by_name (const char *name,unsigned long flags) {struct cdev *cdev;
include/driver.h +1 -0
@@ -535,6 +535,7 @@ struct cdev *cdev_open_by_name(const char *name, unsigned long flags);struct cdev *cdev_create_loop (const char *path,ulong flags,loff_t offset);void cdev_remove_loop (struct cdev *cdev);int cdev_open (struct cdev *,unsigned long flags); +int cdev_fdopen (struct cdev *cdev,unsigned long flags);void cdev_close (struct cdev *cdev);int cdev_flush (struct cdev *cdev);ssize_t cdev_read (struct cdev *cdev,void *buf,size_t count,loff_t offset,ulong flags);
Signature · 1 line
2.38.1
PATCH v2 2/4 asm-generic: avoid compiler warnings due to PCI_IOBASE
In reply to Ahmad FatoumSome GCC versions take offence at PCI_IOBASE's default value of 0. Hide warnings about this.
--- include/asm-generic/io.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/asm-generic/io.h +2 -1
@@ -12,6 +12,7 @@#define __ASM_GENERIC_IO_H#include <linux/string.h> /* for memset() and memcpy() */ +#include <linux/compiler.h> #include <linux/types.h> #include <asm/byteorder.h>
@@ -86,7 +87,7 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr)#endif #ifndef PCI_IOBASE -#define PCI_IOBASE ((void __iomem *)0) +#define PCI_IOBASE ((void __iomem *)RELOC_HIDE((void *)0, 0))#endif #ifndef IO_SPACE_LIMIT
Signature · 1 line
2.38.1
PATCH v2 3/4 firmware: add QEMU FW CFG driver
In reply to Ahmad FatoumQuoting the QEMU Docs[1]:
The QEMU Firmware Configuration (fw_cfg) Device allows the guest to retrieve various data items (blobs) that can influence how the firmware configures itself, or may contain tables to be installed for the guest OS. Examples include device boot order, ACPI and SMBIOS tables, virtual machine UUID, SMP and NUMA information, kernel/initrd images for direct (Linux) kernel booting, etc.
The driver added here is mostly based on the Linux driver.
[1]: https://www.qemu.org/docs/master/specs/fw_cfg.html
---
v1 -> v2:
- split off into own file
- add cdev/fd API
- DMA map written buffers
- reuse kernel headers and part of kernel code
- handle unaligned buffers correctly
--- drivers/firmware/Kconfig | 10 + drivers/firmware/Makefile | 1 + drivers/firmware/qemu_fw_cfg.c | 307 +++++++++++++++++++++++++++++++ include/filetype.h | 1 + include/uapi/linux/qemu_fw_cfg.h | 100 ++++++++++ 5 files changed, 419 insertions(+) create mode 100644 drivers/firmware/qemu_fw_cfg.c create mode 100644 include/uapi/linux/qemu_fw_cfg.h
drivers/firmware/Kconfig +10 -0
@@ -32,4 +32,14 @@ config ARM_SCMI_PROTOCOL set of operating system-independent software interfaces that are used in system management. +config QEMU_FW_CFG + bool "QEMU FW CFG interface" + help + This driver exposes the QEMU FW CFG conduit as a single + character device. + + The selector key can be set via ioctl or device parameter + and read/writes are translated to the MMIO/IO port appropriate + for the platform. + endmenu
drivers/firmware/Makefile +1 -0
@@ -2,4 +2,5 @@ obj-$(CONFIG_FIRMWARE_ALTERA_SERIAL) += altera_serial.o obj-$(CONFIG_FIRMWARE_ALTERA_SOCFPGA) += socfpga.o socfpga_sdr.o obj-$(CONFIG_FIRMWARE_ZYNQMP_FPGA) += zynqmp-fpga.o +obj-$(CONFIG_QEMU_FW_CFG) += qemu_fw_cfg.o obj-y += arm_scmi/
drivers/firmware/qemu_fw_cfg.c new file +307 -0
307 lines not on this page · raw message
include/filetype.h +1 -0
@@ -58,6 +58,7 @@ enum filetype { filetype_mxs_sd_image, filetype_rockchip_rkns_image, filetype_fip, + filetype_qemu_fw_cfg, filetype_max, };
include/uapi/linux/qemu_fw_cfg.h new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.38.1
PATCH v2 4/4 video: add support for QEMU ramfb
In reply to Ahmad FatoumFrom: Adrian Negreanu <[email protected]>
QEMU's ramfb is a very simple Qemu fw_cfg protocol, where the guest need only write a video settings structure to /etc/ramfb to get DMA from the framebuffer working. We don't yet have FS support for fw_cfg, so we use the character device interface.
As barebox display mode handling only supports selecting predefined modes and has no accommodation yet for arbitrary resolution support like on QEMU, for now we just provide a fixed 640x480@XRGB8888 mode.
Tested with:
qemu-system-aarch64 -M virt -vga none -device ramfb \ -kernel images/barebox-dt-2nd.img -cpu cortex-a57 -serial mon:stdio
---
v1 -> v2:
- rebased on new /dev/fw_cfg API
- remove Kconfig resolution setup as no other driver does this
- replace own PACKED definition with __packed
- use <video/fourcc.h> instead of duplicating DMA_FORMAT_* definitions
- allocate etc/ramfb buffer with dma_alloc
- map framebuffer coherent
- replaces RISC-V example in commit message with arm64, because that's what I last tested with (probably too old qemu for RISC-V on my side)
--- drivers/video/Kconfig | 6 ++ drivers/video/Makefile | 1 + drivers/video/ramfb.c | 191 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 drivers/video/ramfb.c
drivers/video/Kconfig +6 -0
@@ -123,6 +123,12 @@ config DRIVER_VIDEO_SIMPLEFB Add support for setting up the kernel's simple framebuffer driver based on the active barebox framebuffer. +config DRIVER_VIDEO_RAMFB + bool "QEMU RamFB support" + select QEMU_FW_CFG + help + Add support for setting up a QEMU RamFB driver. + config DRIVER_VIDEO_EDID bool "Add EDID support" help
drivers/video/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRIVER_VIDEO_OMAP) += omap.o obj-$(CONFIG_DRIVER_VIDEO_BCM283X) += bcm2835.o obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB_CLIENT) += simplefb-client.o obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb-fixup.o +obj-$(CONFIG_DRIVER_VIDEO_RAMFB) += ramfb.o obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += imx-ipu-v3/ obj-$(CONFIG_DRIVER_VIDEO_EFI_GOP) += efi_gop.o obj-$(CONFIG_DRIVER_VIDEO_FB_SSD1307) += ssd1307fb.o
drivers/video/ramfb.c new file +191 -0
191 lines not on this page · raw message
Signature · 1 line
2.38.1
Sascha Hauer
AppliedQuoted 5 lines · Ahmad Fatoum
QEMU's ramfb is a very simple Qemu
fw_cfgprotocol, where the guest need only write a video settings structure to/etc/ramfbto get DMA from the framebuffer working. Add a driver for this on top of a newly added character device interface.
Quoted 7 lines
Adrian Negreanu (1):
video: add support for QEMU ramfbAhmad Fatoum (3):
fs: devfs: implementcdev_fdopen
asm-generic: avoid compiler warnings due toPCI_IOBASE
firmware: add QEMU FW CFG driver
Applied, thanks
Sascha
Quoted 22 lines
drivers/firmware/Kconfig | 10 + drivers/firmware/Makefile | 1 + drivers/firmware/qemu_fw_cfg.c | 307 +++++++++++++++++++++++++++++++ drivers/video/Kconfig | 6 + drivers/video/Makefile | 1 + drivers/video/ramfb.c | 191 +++++++++++++++++++ fs/devfs-core.c | 20 ++ include/asm-generic/io.h | 3 +- include/driver.h | 1 + include/filetype.h | 1 + include/uapi/linux/qemu_fw_cfg.h | 100 ++++++++++ 11 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/qemu_fw_cfg.c create mode 100644 drivers/video/ramfb.c create mode 100644 include/uapi/linux/qemu_fw_cfg.hSignature · 1 line
2.38.1
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |