#
6e8ec638 |
|
21-Oct-2019 |
Simon Shields <simon.shields@data61.csiro.au> |
elfloader: pick serial driver at runtime On ARM, each serial driver now has an ELFLOADER_DRIVER(...), which contains information about the compatible strings the driver matches, the driver type and an "init" function for the driver to do setup. hardware_gen is now used by the ELF loader to generate a list of interesting devices at compile-time, which go in a header file "devices_gen.h". The ELFLOADER_DRIVERs are put into a special "_driver_list" section by the linker, and accessed as an array via the special __start__driver_list and __stop__driver_list linker symbols. At boot, the ELF loader calls initialise_devices(), which does the following: for each device in devices_gen.h for each driver in elfloader_drivers array if (device compat matches driver compat) call driver->init(device, driver) end if end for end for For serial drivers, the serial driver calls uart_set_out with the elfloader_device that should be the output for the elfloader from the driver->init function. There is a 'common' plat_console_putchar implementation which uses the dynamically picked uart output. This eliminates the need for a lot of the platform-specific code we have. This implementation could one day be replaced with a in-ELF loader device tree. This could also (possibly) be used to handle dynamically picking SMP core bringup mechanisms. As all RISC-V platforms use SBI to provide a serial port, RISCV is only modified to register the SBI putc implementation as the fputc implementatin.
|