Skip to contentSkip to conversation

scripts: minikconf: support config titles

PATCH New Enrico Weigelt, metux IT consult 1 participant 5 messages Nov 27, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 scripts: minikconf: support config titles

Add support for config option titles, like the real kconfig does. Even though they're not presented anywhere yet (since minikconf only acts in the background), it's good to have them supported, so we can start adding descriptions in the Kconfig files.

---
 scripts/minikconf.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/minikconf.py +14 -0
index bcd91015d3..28c67906cb 100644
@@ -206,6 +206,7 @@ class KconfigData:
         self.defined_vars = set()
         self.referenced_vars = dict()
         self.clauses = list()
+        self.title = None
 
     # semantic analysis -------------
 
@@ -290,6 +291,9 @@ class KconfigData:
         cond = (cond & var) if cond is not None else var
         self.clauses.append(KconfigData.SelectClause(symbol, cond))
 
+    def do_title(self, title):
+        self.title = title
+
     def do_imply(self, var, symbol, cond=None):
         # "config X imply Y [if COND]" is the same as
         # "config Y default y if X [&& COND]"
@@ -323,6 +327,7 @@ TOK_BOOL = 15;    TOKENS[TOK_BOOL] = '"bool"';
 TOK_IF = 16;      TOKENS[TOK_IF] = '"if"';
 TOK_ID = 17;      TOKENS[TOK_ID] = 'identifier';
 TOK_EOF = 18;     TOKENS[TOK_EOF] = 'end of file';
+TOK_QUOTED = 19;  TOKENS[TOK_QUOTED] = 'quoted string';
 
 class KconfigParserError(Exception):
     def __init__(self, parser, msg, tok=None):
@@ -501,6 +506,7 @@ class KconfigParser:
     # property: DEFAULT y_or_n condition
     #       | DEPENDS ON expr
     #       | SELECT var condition
+    #       | BOOL "comment"
     #       | BOOL
     def parse_property(self, var):
         if self.tok == TOK_DEFAULT:
@@ -526,6 +532,9 @@ class KconfigParser:
             self.data.do_imply(var, symbol, cond)
         elif self.tok == TOK_BOOL:
             self.get_token()
+            if self.tok == TOK_QUOTED:
+                self.data.do_title(self.val)
+                self.get_token()
         else:
             raise KconfigParserError(self, 'Error in recursive descent?')
 
@@ -645,6 +654,11 @@ class KconfigParser:
             self.cursor = self.src.find('\n', self.cursor)
             self.val = self.src[start:self.cursor]
             return TOK_SOURCE
+        elif self.tok == '"':
+            start = self.cursor
+            self.cursor = self.src.find('"', self.cursor)+1
+            self.val = self.src[start:self.cursor]
+            return TOK_QUOTED;
         elif self.tok.isalnum():
             # identifier
             while self.src[self.cursor].isalnum() or self.src[self.cursor] == '_':
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/5 backends: introduce gpio backend subsystem

Introducing a backend subsys for hardware GPIOs, so we can now let simulated GPIO devices actually do something, by talking to pluggable GPIO backends (eg. speaking to host's gpio subsystem, gpiod, custom simulation, etc).

This patch does not implement any actual gpio backend, nor any any any hw simulation drivers yet - just the generic infrastructure.

---
 MAINTAINERS           |   6 ++
 backends/Kconfig      |   4 +
 backends/gpio.c       | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++
 backends/meson.build  |   1 +
 include/sysemu/gpio.h |  76 +++++++++++++++
 5 files changed, 342 insertions(+)
 create mode 100644 backends/gpio.c
 create mode 100644 include/sysemu/gpio.h
MAINTAINERS +6 -0
index 68bc160f41..bfa29a4560 100644
@@ -2288,6 +2288,12 @@ S: Maintained
 F: gdbstub*
 F: gdb-xml/
 
+GPIO Backend API
+M: Enrico Weigelt, metux IT consult <[email protected]>
+S: Supported
+F: backends/gpio.c
+F: include/sysemu/gpio.h
+
 Memory API
 M: Paolo Bonzini <[email protected]>
 S: Supported
backends/Kconfig +4 -0
index f35abc1609..2f17189472 100644
@@ -1 +1,5 @@
 source tpm/Kconfig
+
+config BACKEND_GPIO
+    bool "Enable GPIO backends"
+    default y
backends/gpio.c new file +255 -0

255 lines not on this page · raw message

backends/meson.build +1 -0
index 484456ece7..332ad7379a 100644
@@ -15,5 +15,6 @@ softmmu_ss.add(when: ['CONFIG_VHOST_USER', 'CONFIG_VIRTIO'], if_true: files('vho
 softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c'))
 softmmu_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VHOST_CRYPTO'], if_true: files('cryptodev-vhost-user.c'))
 softmmu_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus-vmstate.c'), gio])
+softmmu_ss.add(when: 'CONFIG_BACKEND_GPIO', if_true: files('gpio.c'))
 
 subdir('tpm')
include/sysemu/gpio.h new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

PATCH 3/5 backends: gpio: dummy builtin backend

In reply to Enrico Weigelt, metux IT consult

Adding a dummy GPIO backend driver. Essentially stores the states in memory and gives some debug output. The current state can be accessed as a string property.

---
 MAINTAINERS             |   1 +
 backends/Kconfig        |   5 ++
 backends/gpio-builtin.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
 backends/meson.build    |   1 +
 include/sysemu/gpio.h   |   2 +
 5 files changed, 146 insertions(+)
 create mode 100644 backends/gpio-builtin.c
MAINTAINERS +1 -0
index bfa29a4560..d3873121e2 100644
@@ -2292,6 +2292,7 @@ GPIO Backend API
 M: Enrico Weigelt, metux IT consult <[email protected]>
 S: Supported
 F: backends/gpio.c
+F: backends/gpio-builtin.c
 F: include/sysemu/gpio.h
 
 Memory API
backends/Kconfig +5 -0
index 2f17189472..1c8a462b57 100644
@@ -3,3 +3,8 @@ source tpm/Kconfig
 config BACKEND_GPIO
     bool "Enable GPIO backends"
     default y
+
+config BACKEND_GPIO_BUILTIN
+    bool "Dummy GPIO backend"
+    depends on BACKEND_GPIO
+    default y
backends/gpio-builtin.c new file +137 -0

137 lines not on this page · raw message

backends/meson.build +1 -0
index 332ad7379a..efba675fa7 100644
@@ -16,5 +16,6 @@ softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c')
 softmmu_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VHOST_CRYPTO'], if_true: files('cryptodev-vhost-user.c'))
 softmmu_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus-vmstate.c'), gio])
 softmmu_ss.add(when: 'CONFIG_BACKEND_GPIO', if_true: files('gpio.c'))
+softmmu_ss.add(when: 'CONFIG_BACKEND_GPIO_BUILTIN', if_true: files('gpio-builtin.c'))
 
 subdir('tpm')
include/sysemu/gpio.h +2 -0
index 0cfd62b192..374630ee49 100644
@@ -15,6 +15,8 @@
 #define TYPE_GPIO_BACKEND "gpio-backend"
 OBJECT_DECLARE_TYPE(GpioBackend, GpioBackendClass, GPIO_BACKEND)
 
+#define TYPE_GPIO_BUILTIN "gpio-builtin"
+
 /* dont change them - drivers rely on these values */
 #define QEMU_GPIO_DIRECTION_OUTPUT  0
 #define QEMU_GPIO_DIRECTION_INPUT   1
Signature · 1 line
2.11.0
#3 lore raw

PATCH 4/5 standard-headers: virtio-gpio protocol headers

In reply to Enrico Weigelt, metux IT consult

Introduce virtio-gpio protocol headers from Linux kernel. (work in progress, not mainlined yet)

---
 include/standard-headers/linux/virtio_gpio.h | 39 ++++++++++++++++++++++++++++
 include/standard-headers/linux/virtio_ids.h  |  1 +
 2 files changed, 40 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_gpio.h
include/standard-headers/linux/virtio_gpio.h new file +39 -0
new file mode 100644
index 0000000000..d1db0ef1fe
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#ifndef _LINUX_VIRTIO_GPIO_H
+#define _LINUX_VIRTIO_GPIO_H
+
+#include <linux/types.h>
+
+enum virtio_gpio_event_type {
+	// requests from quest to host
+	VIRTIO_GPIO_EV_GUEST_REQUEST		= 0x01,	// ->request()
+	VIRTIO_GPIO_EV_GUEST_DIRECTION_INPUT	= 0x02,	// ->direction_input()
+	VIRTIO_GPIO_EV_GUEST_DIRECTION_OUTPUT	= 0x03,	// ->direction_output()
+	VIRTIO_GPIO_EV_GUEST_GET_DIRECTION	= 0x04,	// ->get_direction()
+	VIRTIO_GPIO_EV_GUEST_GET_VALUE		= 0x05,	// ->get_value()
+	VIRTIO_GPIO_EV_GUEST_SET_VALUE		= 0x06,	// ->set_value()
+
+	// messages from host to guest
+	VIRTIO_GPIO_EV_HOST_LEVEL		= 0x11,	// gpio state changed
+
+	/* mask bit set on host->guest reply */
+	VIRTIO_GPIO_EV_REPLY			= 0xF000,
+};
+
+struct virtio_gpio_config {
+	__u8    version;
+	__u8    reserved0;
+	__u16   num_gpios;
+	__u32   names_size;
+	__u8    reserved1[24];
+	__u8    name[32];
+};
+
+struct virtio_gpio_event {
+	__le16 type;
+	__le16 pin;
+	__le32 value;
+};
+
+#endif /* _LINUX_VIRTIO_GPIO_H */
include/standard-headers/linux/virtio_ids.h +1 -0
index b052355ac7..053fe59c73 100644
@@ -48,5 +48,6 @@
 #define VIRTIO_ID_FS           26 /* virtio filesystem */
 #define VIRTIO_ID_PMEM         27 /* virtio pmem */
 #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
+#define VIRTIO_ID_GPIO		 30 /* virtio GPIO */
 
 #endif /* _LINUX_VIRTIO_IDS_H */
Signature · 1 line
2.11.0
#4 lore raw

PATCH 5/5 hw: virtio: add virtio-gpio device emulation

In reply to Enrico Weigelt, metux IT consult

Adding a driver for virtio-based GPIOs. The driver connects to specified gpio backend and routes all requests there.

---
 MAINTAINERS             |   7 +
 hw/virtio/Kconfig       |   7 +
 hw/virtio/meson.build   |   1 +
 hw/virtio/virtio-gpio.c | 371 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 386 insertions(+)
 create mode 100644 hw/virtio/virtio-gpio.c
MAINTAINERS +7 -0
index d3873121e2..57deed6c20 100644
@@ -2294,6 +2294,13 @@ S: Supported
 F: backends/gpio.c
 F: backends/gpio-builtin.c
 F: include/sysemu/gpio.h
+F: include/standard-headers/linux/virtio_gpio.h
+
+GPIO Virtio backend
+M: Enrico Weigelt, metux IT consult <[email protected]>
+S: Supported
+F: hw/virtio/virtio-gpio.c
+F: include/hw/virtio/virtio-gpio.h
 
 Memory API
 M: Paolo Bonzini <[email protected]>
hw/virtio/Kconfig +7 -0
index 0eda25c4e1..81da1ee763 100644
@@ -33,6 +33,13 @@ config VIRTIO_BALLOON
     default y
     depends on VIRTIO
 
+config VIRTIO_GPIO
+    bool
+    default y
+    depends on VIRTIO
+    select BACKEND_GPIO
+    select BACKEND_GPIO_BUILTIN
+
 config VIRTIO_CRYPTO
     bool
     default y
hw/virtio/meson.build +1 -0
index fbff9bc9d4..88577ff812 100644
@@ -25,6 +25,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.
 virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
+virtio_ss.add(when: 'CONFIG_VIRTIO_GPIO', if_true: files('virtio-gpio.c'))
 
 virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
hw/virtio/virtio-gpio.c new file +371 -0

371 lines not on this page · raw message

Signature · 1 line
2.11.0