[PATCH 00/11] OpenSBI compile-time C arrays

Anup Patel apatel at ventanamicro.com
Tue May 3 09:24:21 PDT 2022


On Tue, May 3, 2022 at 9:07 PM Xiang W <wxjstz at 126.com> wrote:
>
> 在 2022-05-03星期二的 09:07 +0530,Anup Patel写道:
> > This series aims at removing hard-coded C arrays for drivers and modules
> > in OpenSBI sources and replace it with dynamically generated arrays at
> > compile-time. External firmwares which use OpenSBI as library will have
> > to create these arrays separately because they typically don't use OpenSBI
> > build system.
>
> The purpose of removing hardcoded arrays is to make it easier for users
> of the library to add their own drivers and modules? But this patch
> makes it necessary for end users to produce their own array of drivers
> and modules. We can implement this by simply putting these arrays into
> separate C files and distributing them with the library.

Only external firmware (which use OpenSBI as library) need to provide
their own array of drivers. These external firmwares have their own
build system and they generally compile only few required drivers
or modules.

For all OpenSBI firmware users, these arrays are generated at
compile time by the OpenSBI build system. Adding a new driver
or module to OpenSBI build system is easy and only need changes
in objects.mk.

Regards,
Anup

>
> Regards,
> Xiang W
>
> >
> > These patches can also be found in generated_carray_v1 branch at:
> > https://github.com/avpatel/opensbi.git
> >
> > Anup Patel (11):
> >   Makefile: Allow generated C source to be anywhere in build directory
> >   Makefile: Add support for generating C array at compile time
> >   lib: utils/reset: Generate FDT reset driver list at compile-time
> >   lib: utils/serial: Generate FDT serial driver list at compile-time
> >   lib: utils/timer: Generate FDT timer driver list at compile-time
> >   lib: utils/irqchip: Generate FDT irqchip driver list at compile-time
> >   lib: utils/ipi: Generate FDT ipi driver list at compile-time
> >   lib: utils/i2c: Generate FDT i2c adapter driver list at compile-time
> >   lib: utils/gpio: Generate FDT gpio driver list at compile-time
> >   platform: generic: Generate platform override module list at
> >     compile-time
> >   platform: generic: Move Sifive platform overrides into own directory
> >
> >  Makefile                                      | 17 +++-
> >  include/sbi_utils/gpio/fdt_gpio.h             |  2 +
> >  lib/utils/gpio/fdt_gpio.c                     | 18 ++---
> >  lib/utils/gpio/fdt_gpio_drivers.carray        |  3 +
> >  lib/utils/gpio/objects.mk                     |  4 +
> >  lib/utils/i2c/fdt_i2c.c                       | 14 ++--
> >  lib/utils/i2c/fdt_i2c_adapter_drivers.carray  |  3 +
> >  lib/utils/i2c/objects.mk                      |  4 +
> >  lib/utils/ipi/fdt_ipi.c                       | 12 ++-
> >  lib/utils/ipi/fdt_ipi_drivers.carray          |  3 +
> >  lib/utils/ipi/objects.mk                      |  4 +
> >  lib/utils/irqchip/fdt_irqchip.c               | 16 ++--
> >  lib/utils/irqchip/fdt_irqchip_drivers.carray  |  3 +
> >  lib/utils/irqchip/objects.mk                  |  8 ++
> >  lib/utils/reset/fdt_reset.c                   | 22 ++----
> >  lib/utils/reset/fdt_reset_drivers.carray      |  3 +
> >  lib/utils/reset/objects.mk                    | 12 +++
> >  lib/utils/serial/fdt_serial.c                 | 28 ++-----
> >  lib/utils/serial/fdt_serial_drivers.carray    |  3 +
> >  lib/utils/serial/objects.mk                   | 16 ++++
> >  lib/utils/timer/fdt_timer.c                   | 12 ++-
> >  lib/utils/timer/fdt_timer_drivers.carray      |  3 +
> >  lib/utils/timer/objects.mk                    |  4 +
> >  platform/generic/objects.mk                   |  3 +-
> >  platform/generic/platform.c                   | 14 ++--
> >  .../generic/platform_override_modules.carray  |  3 +
> >  .../{sifive_fu540.c => sifive/fu540.c}        |  0
> >  .../{sifive_fu740.c => sifive/fu740.c}        |  0
> >  platform/generic/sifive/objects.mk            |  9 +++
> >  scripts/carray.sh                             | 77 +++++++++++++++++++
> >  30 files changed, 224 insertions(+), 96 deletions(-)
> >  create mode 100644 lib/utils/gpio/fdt_gpio_drivers.carray
> >  create mode 100644 lib/utils/i2c/fdt_i2c_adapter_drivers.carray
> >  create mode 100644 lib/utils/ipi/fdt_ipi_drivers.carray
> >  create mode 100644 lib/utils/irqchip/fdt_irqchip_drivers.carray
> >  create mode 100644 lib/utils/reset/fdt_reset_drivers.carray
> >  create mode 100644 lib/utils/serial/fdt_serial_drivers.carray
> >  create mode 100644 lib/utils/timer/fdt_timer_drivers.carray
> >  create mode 100644 platform/generic/platform_override_modules.carray
> >  rename platform/generic/{sifive_fu540.c => sifive/fu540.c} (100%)
> >  rename platform/generic/{sifive_fu740.c => sifive/fu740.c} (100%)
> >  create mode 100644 platform/generic/sifive/objects.mk
> >  create mode 100755 scripts/carray.sh
> >
> > --
> > 2.34.1
> >
> >
>
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list