]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
drivers/ukbus/platform: Make fdt discovery optional
authorMichalis Pappas <michalis@unikraft.io>
Fri, 15 Sep 2023 07:58:37 +0000 (09:58 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
Make fdt-based discovery optional to allow the platform bus to be
selected for virtio-mmio on x86_64.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1116

drivers/ukbus/platform/Config.uk
drivers/ukbus/platform/include/uk/bus/platform.h
drivers/ukbus/platform/platform_bus.c

index 9a0843370aca1e1b7b75b8efcaf85f165ca2274e..26ec9cb53cf8af6d9d7b346ca46e77b5c28dab2e 100644 (file)
@@ -1,8 +1,9 @@
 config LIBUKBUS_PLATFORM
        bool "Platform bus"
-       depends on ARCH_ARM_64
-       depends on LIBUKBUS
-       select LIBUKOFW
-       select LIBUKINTCTLR_GIC if ARCH_ARM_64
+       select LIBUKBUS
        help
                Platform bus for non-auto-discoverable devices
+
+config LIBUKBUS_PLATFORM_FDT
+       bool
+       default y if (LIBUKOFW && LIBFDT)
index 9c797f642d81d78214d381747c40204420c5eb2c..44f04a6be36066fd20d283b9d9caf9cd6827fb15 100644 (file)
@@ -33,6 +33,7 @@
 #ifndef __UK_BUS_PLATFORM_H__
 #define __UK_BUS_PLATFORM_H__
 
+#include <stdint.h>
 #include <uk/bus.h>
 #include <uk/alloc.h>
 
index fb4bcbed9adef09c822ad51ace2b01ed1bd5158f..abe4eb8f784ac794714aea017b18a0485e9d251f 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdint.h>
 #include <string.h>
 #include <uk/print.h>
 #include <uk/plat/memory.h>
 #include <uk/plat/common/cpu.h>
 #include <uk/bus/platform.h>
+#include <uk/plat/common/bootinfo.h>
+
+#if CONFIG_LIBUKBUS_PLATFORM_FDT
 #include <libfdt.h>
 #include <uk/ofw/fdt.h>
-#include <uk/intctlr/gic.h>
-#include <uk/plat/common/bootinfo.h>
 
 static void *dtb;
 
+static const char *pf_device_compatible_list[] = {
+       "virtio,mmio",
+       "pci-host-ecam-generic",
+       NULL
+};
+#endif /* CONFIG_LIBUKBUS_PLATFORM_FDT */
+
+static struct pf_bus_handler pfh;
+
 struct pf_bus_handler {
        struct uk_bus b;
        struct uk_alloc *a;
@@ -49,13 +60,6 @@ struct pf_bus_handler {
        int drv_list_initialized;
        struct pf_device_list dev_list;  /**< List of platform devices */
 };
-static struct pf_bus_handler pfh;
-
-static const char *pf_device_compatible_list[] = {
-       "virtio,mmio",
-       "pci-host-ecam-generic",
-       NULL
-};
 
 static inline int pf_device_id_match(const struct pf_device_id *id0,
                                        const struct pf_device_id *id1)
@@ -131,7 +135,8 @@ static inline int pf_driver_probe_device(struct pf_driver *drv,
        return 0;
 }
 
-static int pf_probe(void)
+#if CONFIG_LIBUKBUS_PLATFORM_FDT
+static int pf_probe_fdt(void)
 {
        struct pf_driver *drv;
        int idx = 0;
@@ -184,7 +189,18 @@ static int pf_probe(void)
 
        return ret;
 }
+#endif /* CONFIG_LIBUKBUS_PLATFORM_FDT */
 
+static int pf_probe(void)
+{
+       int rc = -ENODEV;
+
+#if CONFIG_LIBUKBUS_PLATFORM_FDT
+       rc = pf_probe_fdt();
+#endif /* CONFIG_LIBUKBUS_PLATFORM_FDT */
+
+       return rc;
+}
 
 static int pf_init(struct uk_alloc *a)
 {
@@ -225,11 +241,11 @@ void _pf_register_driver(struct pf_driver *drv)
        UK_TAILQ_INSERT_TAIL(&pfh.drv_list, drv, next);
 }
 
-
 /* Register this bus driver to libukbus:
  */
 static struct pf_bus_handler pfh = {
        .b.init = pf_init,
        .b.probe = pf_probe
 };
+
 UK_BUS_REGISTER_PRIORITY(&pfh.b, 1);