Skip to contentSkip to conversation

drivers: add VirtIO console, block device support

PATCH Applied Ahmad Fatoum 2 participants 12 messages Feb 22, 2021

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

cover drivers: add VirtIO console, block device support

To make it easier to exchange data with paravirtualized barebox during testing, import parts of the VirtIO support in Linux and U-Boot.

API basically looks like U-Boot's, but driver boilerplate (like having a virtio bus) is taken from Linux. Headers are the Linux ones with some necessary modifications on top.

Quite nifty thing is that Qemu will fix up the device tree appropriately, so just compile in the drivers and it works. The vexpress_defconfig already does this, so this just works:

  $ qemu-system-arm -m 256M -M virt -nographic                  \
 	-kernel ./images/barebox-dt-2nd.img                     \
  	-device virtio-rng-device                               \
  	-drive if=none,file=/tmp/first.hdimg,format=raw,id=hd0  \
  	-device virtio-blk-device,drive=hd0		        \

Ahmad Fatoum (8):
kbuild: add include/uapi to path
driver: Don't throw an error on probes that didn't find the device
drivers: add support for memory-mapped VirtIO paravirtualization
hw_random: add VirtIO RNG driver
serial: add basic VirtIO console driver
block: add VirtIO block device driver
ARM: vexpress: config: update for VirtIO support
Documentation: add Documentation on VirtIO for barebox

 Documentation/user/user-manual.rst  |   1 +
 Documentation/user/virtio.rst       |  80 +++++
 Makefile                            |  10 +-
 arch/arm/configs/vexpress_defconfig |  15 +-
 drivers/Kconfig                     |   1 +
 drivers/Makefile                    |   1 +
 drivers/ata/Kconfig                 |   2 +
 drivers/base/driver.c               |   5 +-
 drivers/block/Kconfig               |   6 +
 drivers/block/Makefile              |   1 +
 drivers/block/virtio_blk.c          | 133 ++++++++
 drivers/hw_random/Kconfig           |   7 +
 drivers/hw_random/Makefile          |   1 +
 drivers/hw_random/virtio-rng.c      | 120 +++++++
 drivers/serial/Kconfig              |   8 +
 drivers/serial/Makefile             |   1 +
 drivers/serial/virtio_console.c     | 166 ++++++++++
 drivers/virtio/Kconfig              |  28 ++
 drivers/virtio/Makefile             |   3 +
 drivers/virtio/virtio.c             | 347 ++++++++++++++++++++
 drivers/virtio/virtio_mmio.c        | 465 +++++++++++++++++++++++++++
 drivers/virtio/virtio_ring.c        | 365 +++++++++++++++++++++
 include/linux/typecheck.h           |  25 ++
 include/linux/virtio.h              | 128 ++++++++
 include/linux/virtio_byteorder.h    |  64 ++++
 include/linux/virtio_config.h       | 480 ++++++++++++++++++++++++++++
 include/linux/virtio_ring.h         | 330 +++++++++++++++++++
 include/uapi/linux/virtio_blk.h     | 203 ++++++++++++
 include/uapi/linux/virtio_config.h  |  95 ++++++
 include/uapi/linux/virtio_console.h |  78 +++++
 include/uapi/linux/virtio_ids.h     |  58 ++++
 include/uapi/linux/virtio_mmio.h    | 152 +++++++++
 include/uapi/linux/virtio_ring.h    | 244 ++++++++++++++
 include/uapi/linux/virtio_rng.h     |   8 +
 include/uapi/linux/virtio_types.h   |  46 +++
 35 files changed, 3673 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/user/virtio.rst
 create mode 100644 drivers/block/Kconfig
 create mode 100644 drivers/block/virtio_blk.c
 create mode 100644 drivers/hw_random/virtio-rng.c
 create mode 100644 drivers/serial/virtio_console.c
 create mode 100644 drivers/virtio/Kconfig
 create mode 100644 drivers/virtio/Makefile
 create mode 100644 drivers/virtio/virtio.c
 create mode 100644 drivers/virtio/virtio_mmio.c
 create mode 100644 drivers/virtio/virtio_ring.c
 create mode 100644 include/linux/typecheck.h
 create mode 100644 include/linux/virtio.h
 create mode 100644 include/linux/virtio_byteorder.h
 create mode 100644 include/linux/virtio_config.h
 create mode 100644 include/linux/virtio_ring.h
 create mode 100644 include/uapi/linux/virtio_blk.h
 create mode 100644 include/uapi/linux/virtio_config.h
 create mode 100644 include/uapi/linux/virtio_console.h
 create mode 100644 include/uapi/linux/virtio_ids.h
 create mode 100644 include/uapi/linux/virtio_mmio.h
 create mode 100644 include/uapi/linux/virtio_ring.h
 create mode 100644 include/uapi/linux/virtio_rng.h
 create mode 100644 include/uapi/linux/virtio_types.h
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/8 kbuild: add include/uapi to path

Import the necessary bits out of the Linux Makefile, so include/uapi goes into the path. This allows importing Linux headers without changing the includes too much. Like with Linux <linux/*.h> is first searched in include/, then include/uapi. Code that explicitly needs the uapi header can include <uapi/linux/*.h>.

---
 Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Makefile +9 -1
index f3c85cff9430..67efcc11f2e1 100644
@@ -408,13 +408,21 @@ LDFLAGS_MODULE  = -T common/module.lds
 # even be read-only.
 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
 
+# Use USERINCLUDE when you must reference the UAPI directories only.
+USERINCLUDE    := \
+		-I$(srctree)/arch/$(SRCARCH)/include/uapi \
+		-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
+		-I$(srctree)/include/uapi \
+		-I$(objtree)/include/generated/uapi \
+                -include $(srctree)/include/linux/kconfig.h
+
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := -Iinclude -I$(srctree)/dts/include \
                    $(if $(building_out_of_srctree), -I$(srctree)/include) \
 		   -I$(srctree)/arch/$(SRCARCH)/include \
 		   -I$(objtree)/arch/$(SRCARCH)/include \
-                   -include $(srctree)/include/linux/kconfig.h
+		   $(USERINCLUDE)
 
 KBUILD_CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
 
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/8 driver: Don't throw an error on probes that didn't find the device

In reply to Ahmad Fatoum

As the name suggests, determining that a device doesn't match is a valid thing for probe to do. Unlike Linux, we throw an error in that case. This will becomes annoying if we start probing virtio-mmio devices, because Qemu registers a bunch and only assigns functions on demand. Thus don't print an error message for ENXIO and ENODEV like Linux does.

---
 drivers/base/driver.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/driver.c +4 -1
index 6763bbc6f512..f60533c59eb1 100644
@@ -102,7 +102,10 @@ int device_probe(struct device_d *dev)
 	list_del(&dev->active);
 	INIT_LIST_HEAD(&dev->active);
 
-	dev_err(dev, "probe failed: %s\n", strerror(-ret));
+	if (ret == -ENODEV || ret == -ENXIO)
+		dev_dbg(dev, "probe failed: %s\n", strerror(-ret));
+	else
+		dev_err(dev, "probe failed: %s\n", strerror(-ret));
 
 	return ret;
 }
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/8 drivers: add support for memory-mapped VirtIO paravirtualization

In reply to Ahmad Fatoum

Sandbox is only useful to test barebox in isolation. For interaction between barebox and firmware/OS, Qemu is the better choice. Qemu supports specifying VirtIO devices on the command line, which it automatically fixes up into the device tree. This is nice. Add support for that.

---
 drivers/Kconfig                    |   1 +
 drivers/Makefile                   |   1 +
 drivers/virtio/Kconfig             |  28 ++
 drivers/virtio/Makefile            |   3 +
 drivers/virtio/virtio.c            | 347 +++++++++++++++++++++
 drivers/virtio/virtio_mmio.c       | 465 ++++++++++++++++++++++++++++
 drivers/virtio/virtio_ring.c       | 365 ++++++++++++++++++++++
 include/linux/typecheck.h          |  25 ++
 include/linux/virtio.h             | 128 ++++++++
 include/linux/virtio_byteorder.h   |  64 ++++
 include/linux/virtio_config.h      | 480 +++++++++++++++++++++++++++++
 include/linux/virtio_ring.h        | 330 ++++++++++++++++++++
 include/uapi/linux/virtio_config.h |  95 ++++++
 include/uapi/linux/virtio_ids.h    |  58 ++++
 include/uapi/linux/virtio_mmio.h   | 152 +++++++++
 include/uapi/linux/virtio_ring.h   | 244 +++++++++++++++
 include/uapi/linux/virtio_rng.h    |   8 +
 include/uapi/linux/virtio_types.h  |  46 +++
 18 files changed, 2840 insertions(+)
 create mode 100644 drivers/virtio/Kconfig
 create mode 100644 drivers/virtio/Makefile
 create mode 100644 drivers/virtio/virtio.c
 create mode 100644 drivers/virtio/virtio_mmio.c
 create mode 100644 drivers/virtio/virtio_ring.c
 create mode 100644 include/linux/typecheck.h
 create mode 100644 include/linux/virtio.h
 create mode 100644 include/linux/virtio_byteorder.h
 create mode 100644 include/linux/virtio_config.h
 create mode 100644 include/linux/virtio_ring.h
 create mode 100644 include/uapi/linux/virtio_config.h
 create mode 100644 include/uapi/linux/virtio_ids.h
 create mode 100644 include/uapi/linux/virtio_mmio.h
 create mode 100644 include/uapi/linux/virtio_ring.h
 create mode 100644 include/uapi/linux/virtio_rng.h
 create mode 100644 include/uapi/linux/virtio_types.h
drivers/Kconfig +1 -0
index 0b87c2af2a83..787d36693309 100644
@@ -44,5 +44,6 @@ source "drivers/soc/imx/Kconfig"
 source "drivers/nvme/Kconfig"
 source "drivers/ddr/Kconfig"
 source "drivers/power/Kconfig"
+source "drivers/virtio/Kconfig"
 
 endmenu
drivers/Makefile +1 -0
index fab3790288f7..5e440b573635 100644
@@ -43,4 +43,5 @@ obj-y	+= soc/imx/
 obj-y	+= nvme/
 obj-y	+= ddr/
 obj-y	+= power/
+obj-y	+= virtio/
 obj-$(CONFIG_SOUND) += sound/
drivers/virtio/Kconfig new file +28 -0
new file mode 100644
index 000000000000..59e3d3c3f54b
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIRTIO
+	bool
+	help
+	  This option is selected by any driver which implements the virtio
+	  bus, such as CONFIG_VIRTIO_MMIO.
+
+config ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
+	bool
+	help
+	  This option is selected if the architecture may need to enforce
+	  VIRTIO_F_ACCESS_PLATFORM
+
+menuconfig VIRTIO_MENU
+	bool "Virtio drivers"
+	default y
+
+if VIRTIO_MENU
+
+config VIRTIO_MMIO
+	bool "Platform bus driver for memory mapped virtio devices"
+	depends on HAS_DMA
+	select VIRTIO
+	help
+	 This drivers provides support for memory mapped virtio
+	 platform device driver. This is usually used with Qemu.
+
+endif # VIRTIO_MENU
drivers/virtio/Makefile new file +3 -0
new file mode 100644
index 000000000000..94ff1398fb3c
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o
+obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
drivers/virtio/virtio.c new file +347 -0

347 lines not on this page · raw message

drivers/virtio/virtio_mmio.c new file +465 -0

465 lines not on this page · raw message

drivers/virtio/virtio_ring.c new file +365 -0

365 lines not on this page · raw message

include/linux/typecheck.h new file +25 -0
new file mode 100644
index 000000000000..20d310331eb5
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef TYPECHECK_H_INCLUDED
+#define TYPECHECK_H_INCLUDED
+
+/*
+ * Check at compile time that something is of a particular type.
+ * Always evaluates to 1 so you may use it easily in comparisons.
+ */
+#define typecheck(type,x) \
+({	type __dummy; \
+	typeof(x) __dummy2; \
+	(void)(&__dummy == &__dummy2); \
+	1; \
+})
+
+/*
+ * Check at compile time that 'function' is a certain type, or is a pointer
+ * to that type (needs to use typedef for the function type.)
+ */
+#define typecheck_fn(type,function) \
+({	typeof(type) __tmp = function; \
+	(void)__tmp; \
+})
+
+#endif		/* TYPECHECK_H_INCLUDED */
include/linux/virtio.h new file +128 -0

128 lines not on this page · raw message

include/linux/virtio_byteorder.h new file +64 -0

64 lines not on this page · raw message

include/linux/virtio_config.h new file +480 -0

480 lines not on this page · raw message

include/linux/virtio_ring.h new file +330 -0

330 lines not on this page · raw message

include/uapi/linux/virtio_config.h new file +95 -0

95 lines not on this page · raw message

include/uapi/linux/virtio_ids.h new file +58 -0

58 lines not on this page · raw message

include/uapi/linux/virtio_mmio.h new file +152 -0

152 lines not on this page · raw message

include/uapi/linux/virtio_ring.h new file +244 -0

244 lines not on this page · raw message

include/uapi/linux/virtio_rng.h new file +8 -0
new file mode 100644
index 000000000000..c4d5de896f0c
@@ -0,0 +1,8 @@
+#ifndef _LINUX_VIRTIO_RNG_H
+#define _LINUX_VIRTIO_RNG_H
+/* This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers. */
+#include <linux/virtio_ids.h>
+#include <linux/virtio_config.h>
+
+#endif /* _LINUX_VIRTIO_RNG_H */
include/uapi/linux/virtio_types.h new file +46 -0

46 lines not on this page · raw message

Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 4/8 hw_random: add VirtIO RNG driver

In reply to Ahmad Fatoum

With this driver enabled, -device virtio-rng-device can now be passed to Qemu for barebox to detect a VirtIO RNG device. If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary.

---
 drivers/hw_random/Kconfig      |   7 ++
 drivers/hw_random/Makefile     |   1 +
 drivers/hw_random/virtio-rng.c | 120 +++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)
 create mode 100644 drivers/hw_random/virtio-rng.c
drivers/hw_random/Kconfig +7 -0
index 1923c755dbba..a84c03efef90 100644
@@ -29,4 +29,11 @@ config HWRNG_DEV_RANDOM
 	  This driver allows use of the host provided /dev/urandom
 	  as barebox HWRNGs.
 
+config HW_RANDOM_VIRTIO
+	tristate "VirtIO Random Number Generator support"
+	depends on VIRTIO
+	help
+	  This driver provides guest-side support for the virtual Random Number
+	  Generator hardware.
+
 endif
drivers/hw_random/Makefile +1 -0
index 2e318be738c5..4bab3967fc4d 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_HWRNG)		+= core.o
 obj-$(CONFIG_HWRNG_MXC_RNGC) += mxc-rngc.o
 obj-$(CONFIG_HWRNG_STM32) += stm32-rng.o
 obj-$(CONFIG_HWRNG_DEV_RANDOM) += dev-random.o
+obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
drivers/hw_random/virtio-rng.c new file +120 -0

120 lines not on this page · raw message

Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/8 serial: add basic VirtIO console driver

In reply to Ahmad Fatoum

With this driver enabled, -device virtio-serial-device can now be passed to Qemu for barebox to detect a VirtIO console device. If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary.

Example:

  $ qemu-system-arm -m 256M -M virt -nographic             \
  	-kernel build/images/barebox-dt-2nd.img            \
  	-device virtio-serial-device                       \
  	-chardev socket,path=/tmp/foo,server,nowait,id=foo \
  	-device virtconsole,chardev=foo,name=console.foo
---
 drivers/serial/Kconfig              |   8 ++
 drivers/serial/Makefile             |   1 +
 drivers/serial/virtio_console.c     | 166 ++++++++++++++++++++++++++++
 include/uapi/linux/virtio_console.h |  78 +++++++++++++
 4 files changed, 253 insertions(+)
 create mode 100644 drivers/serial/virtio_console.c
 create mode 100644 include/uapi/linux/virtio_console.h
drivers/serial/Kconfig +8 -0
index 5c6f0e88e398..09434c1ba86c 100644
@@ -156,4 +156,12 @@ config DRIVER_SERIAL_LPUART
 	default y
 	bool "LPUART serial driver"
 
+config VIRTIO_CONSOLE
+	tristate "Virtio console"
+	select VIRTIO
+	help
+	  Virtio console for use with hypervisors.
+
+	  Also serves as a general-purpose serial device for data
+	  transfer between the guest and host.
 endmenu
drivers/serial/Makefile +1 -0
index 8a2abbbe45cf..7ff41cd5c744 100644
@@ -22,3 +22,4 @@ obj-$(CONFIG_DRIVER_SERIAL_CADENCE)		+= serial_cadence.o
 obj-$(CONFIG_DRIVER_SERIAL_EFI_STDIO)		+= efi-stdio.o
 obj-$(CONFIG_DRIVER_SERIAL_DIGIC)		+= serial_digic.o
 obj-$(CONFIG_DRIVER_SERIAL_LPUART)		+= serial_lpuart.o
+obj-$(CONFIG_VIRTIO_CONSOLE)			+= virtio_console.o
drivers/serial/virtio_console.c new file +166 -0

166 lines not on this page · raw message

include/uapi/linux/virtio_console.h new file +78 -0

78 lines not on this page · raw message

Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 6/8 block: add VirtIO block device driver

In reply to Ahmad Fatoum

With this driver enabled, -device virtio-blk-device can now be passed to Qemu for barebox to detect a VirtIO block device mapping a host file or block device.

If barebox is passed as argument to the Qemu -kernel option, no device tree changes are necessary.

Example:

  $ qemu-system-arm -m 256M -M virt -nographic                  \
  	-kernel build/images/barebox-dt-2nd.img                 \
  	-device virtio-rng-device                               \
  	-drive if=none,file=/tmp/first.hdimg,format=raw,id=hd0  \
  	-device virtio-blk-device,drive=hd0                     \
  	-drive if=none,file=/tmp/second.hdimg,format=raw,id=hd1 \
  	-device virtio-blk-device,drive=hd1
---
 drivers/ata/Kconfig             |   2 +
 drivers/block/Kconfig           |   6 +
 drivers/block/Makefile          |   1 +
 drivers/block/virtio_blk.c      | 133 +++++++++++++++++++++
 include/uapi/linux/virtio_blk.h | 203 ++++++++++++++++++++++++++++++++
 5 files changed, 345 insertions(+)
 create mode 100644 drivers/block/Kconfig
 create mode 100644 drivers/block/virtio_blk.c
 create mode 100644 include/uapi/linux/virtio_blk.h
drivers/ata/Kconfig +2 -0
index 040c5fd237fd..c0f0a3dbe3f3 100644
@@ -16,6 +16,8 @@ config DISK_WRITE
 	select BLOCK_WRITE
 	bool "support writing to disk drives"
 
+source "drivers/block/Kconfig"
+
 comment "drive types"
 
 config DISK_BIOS
drivers/block/Kconfig new file +6 -0
new file mode 100644
index 000000000000..b42571eca5c6
@@ -0,0 +1,6 @@
+config VIRTIO_BLK
+        bool "Virtio block driver"
+        depends on VIRTIO
+        help
+          This is the virtual block driver for virtio.  It can be used with
+          QEMU based VMMs (like KVM or Xen).
drivers/block/Makefile +1 -0
index 8812c0faecb1..23d634f00676 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_EFI_BOOTUP) += efi-block-io.o
+obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
drivers/block/virtio_blk.c new file +133 -0

133 lines not on this page · raw message

include/uapi/linux/virtio_blk.h new file +203 -0

203 lines not on this page · raw message

Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 7/8 ARM: vexpress: config: update for VirtIO support

In reply to Ahmad Fatoum

We have now support for VirtIO block, console and HWRNG. Check the boxes to get them enabled and usable. While at it, add some more useful options:

- CONFIG_CMD_POWEROFF: So Qemu can be exited from the barebox shell
- CONFIG_CMD_FILETYPE: For debugging

CONFIG_OF_OVERLAY=y is now selected on machine level, so it's dropped from the file.

---
 arch/arm/configs/vexpress_defconfig | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
arch/arm/configs/vexpress_defconfig +13 -2
index 760e39b44070..d58ca7ebd0ec 100644
@@ -1,6 +1,6 @@
 CONFIG_ARCH_VEXPRESS=y
-CONFIG_MACH_VIRT=y
 CONFIG_MACH_VEXPRESS=y
+CONFIG_MACH_VIRT=y
 CONFIG_AEABI=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_MALLOC_SIZE=0x0
@@ -14,6 +14,9 @@ CONFIG_MENU=y
 CONFIG_BOOTM_SHOW_TYPE=y
 CONFIG_BOOTM_VERBOSE=y
 CONFIG_BOOTM_INITRD=y
+CONFIG_CONSOLE_ACTIVATE_ALL=y
+CONFIG_CONSOLE_ALLOW_COLOR=y
+CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
@@ -28,6 +31,7 @@ CONFIG_CMD_PARTITION=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_SLEEP=y
 CONFIG_CMD_DHCP=y
@@ -45,21 +49,28 @@ CONFIG_CMD_CRC=y
 CONFIG_CMD_CRC_CMP=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_DETECT=y
+CONFIG_CMD_POWEROFF=y
 CONFIG_CMD_OFTREE=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
-CONFIG_OF_OVERLAY=y
 CONFIG_SERIAL_AMBA_PL011=y
+CONFIG_VIRTIO_CONSOLE=y
 CONFIG_DRIVER_NET_SMC91111=y
 # CONFIG_SPI is not set
 CONFIG_MTD=y
 CONFIG_MTD_CONCAT=y
 CONFIG_DRIVER_CFI=y
+CONFIG_VIRTIO_BLK=y
 CONFIG_MCI=y
 CONFIG_MCI_MMCI=y
+CONFIG_HWRNG=y
+CONFIG_HW_RANDOM_VIRTIO=y
 # CONFIG_PINCTRL is not set
+CONFIG_VIRTIO_MMIO=y
+CONFIG_FS_EXT4=y
 CONFIG_FS_TFTP=y
+CONFIG_FS_FAT=y
 CONFIG_DIGEST_SHA1_GENERIC=y
 CONFIG_DIGEST_SHA256_GENERIC=y
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 8/8 Documentation: add Documentation on VirtIO for barebox

In reply to Ahmad Fatoum

Save users the trip to the commit log and reproduce some example qemu invocations in the documentation. The text around it is adapted from the U-Boot doc/README.virtio.

---
 Documentation/user/user-manual.rst |  1 +
 Documentation/user/virtio.rst      | 80 ++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+)
 create mode 100644 Documentation/user/virtio.rst
Documentation/user/user-manual.rst +1 -0
index 827683eaa0db..c80bfbf2639a 100644
@@ -36,6 +36,7 @@ Contents:
    optee
    debugging
    watchdog
+   virtio
 
 * :ref:`search`
 * :ref:`genindex`
Documentation/user/virtio.rst new file +80 -0

80 lines not on this page · raw message

Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH 1/1 fixup! Documentation: add Documentation on VirtIO for barebox

Fix case.

---
 Documentation/user/virtio.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/user/virtio.rst +1 -1
index 7233c001bcce..caf88ecf73b3 100644
@@ -77,4 +77,4 @@ and 2 block devices::
   	-device virtio-blk-device,drive=hd1
 
 .. _VirtIO: http://docs.oasis-open.org/virtio/virtio/v1.0/virtio-v1.0.pdf
-.. _qemu: https://www.qemu.org
+.. _QEMU: https://www.qemu.org
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

PATCH 1/1 fixup! fixup! Documentation: add Documentation on VirtIO for barebox

In reply to Ahmad Fatoum

Add note about how to access console.

---
 Documentation/user/virtio.rst | 2 ++
 1 file changed, 2 insertions(+)
Documentation/user/virtio.rst +2 -0
index caf88ecf73b3..8740c7046340 100644
@@ -59,6 +59,8 @@ a VirtIO console on ARM::
   	-chardev socket,path=/tmp/foo,server,nowait,id=foo \
   	-device virtconsole,chardev=foo,name=console.foo
 
+To access the console socket, you can use ``socat /tmp/foo -``.
+
 Note the use of ``-kernel ./images/barebox-dt-2nd.img`` instead of
 ``-bios ./images/barebox-$BOARD.img``. ``-kernel`` will cause QEMU
 to pass barebox a fixed-up device tree describing the ``virtio-mmio``
Signature · 7 lines
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#11 lore raw
In reply to Ahmad Fatoum
Quoted 17 lines · Ahmad Fatoum

To make it easier to exchange data with paravirtualized barebox during testing, import parts of the VirtIO support in Linux and U-Boot.

API basically looks like U-Boot's, but driver boilerplate (like having a virtio bus) is taken from Linux. Headers are the Linux ones with some necessary modifications on top.

Quite nifty thing is that Qemu will fix up the device tree appropriately, so just compile in the drivers and it works. The vexpress_defconfig already does this, so this just works:

  $ qemu-system-arm -m 256M -M virt -nographic                  \
 	-kernel ./images/barebox-dt-2nd.img                     \
  	-device virtio-rng-device                               \
  	-drive if=none,file=/tmp/first.hdimg,format=raw,id=hd0  \
  	-device virtio-blk-device,drive=hd0		        \
Quoted 9 lines

Ahmad Fatoum (8):
kbuild: add include/uapi to path
driver: Don't throw an error on probes that didn't find the device
drivers: add support for memory-mapped VirtIO paravirtualization
hw_random: add VirtIO RNG driver
serial: add basic VirtIO console driver
block: add VirtIO block device driver
ARM: vexpress: config: update for VirtIO support
Documentation: add Documentation on VirtIO for barebox

Applied, thanks

Sascha

Signature · 9 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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox