lib: utils/ipi: Generate FDT ipi driver list at compile-time
authorAnup Patel <apatel@ventanamicro.com>
Fri, 13 May 2022 03:56:35 +0000 (09:26 +0530)
committerAnup Patel <anup@brainfault.org>
Fri, 13 May 2022 03:56:35 +0000 (09:26 +0530)
Instead of having FDT ipi driver list hard-coded in the C source,
we generate it using carray.sh at compile-time.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
lib/utils/ipi/fdt_ipi.c
lib/utils/ipi/fdt_ipi_drivers.carray [new file with mode: 0644]
lib/utils/ipi/objects.mk

index 91f116f..66dc510 100644 (file)
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/ipi/fdt_ipi.h>
 
-extern struct fdt_ipi fdt_ipi_mswi;
-
-static struct fdt_ipi *ipi_drivers[] = {
-       &fdt_ipi_mswi
-};
+/* List of FDT ipi drivers generated at compile time */
+extern struct fdt_ipi *fdt_ipi_drivers[];
+extern unsigned long fdt_ipi_drivers_size;
 
 static struct fdt_ipi dummy = {
        .match_table = NULL,
@@ -47,8 +45,8 @@ static int fdt_ipi_cold_init(void)
        const struct fdt_match *match;
        void *fdt = fdt_get_address();
 
-       for (pos = 0; pos < array_size(ipi_drivers); pos++) {
-               drv = ipi_drivers[pos];
+       for (pos = 0; pos < fdt_ipi_drivers_size; pos++) {
+               drv = fdt_ipi_drivers[pos];
 
                noff = -1;
                while ((noff = fdt_find_match(fdt, noff,
diff --git a/lib/utils/ipi/fdt_ipi_drivers.carray b/lib/utils/ipi/fdt_ipi_drivers.carray
new file mode 100644 (file)
index 0000000..275fa9c
--- /dev/null
@@ -0,0 +1,3 @@
+HEADER: sbi_utils/ipi/fdt_ipi.h
+TYPE: struct fdt_ipi
+NAME: fdt_ipi_drivers
index 129eea8..0b0bc2d 100644 (file)
@@ -8,5 +8,9 @@
 #
 
 libsbiutils-objs-y += ipi/aclint_mswi.o
+
 libsbiutils-objs-y += ipi/fdt_ipi.o
+libsbiutils-objs-y += ipi/fdt_ipi_drivers.o
+
+carray-fdt_ipi_drivers-y += fdt_ipi_mswi
 libsbiutils-objs-y += ipi/fdt_ipi_mswi.o