For a while now, both simple-framebuffer and uart were hard-wired to
the debug library. You could alternate between each or have both running,
but the implementation was really ugly - ifdefs based on whether uart/simplefb
are compiled in or not.
As uniLoader has advanced enough to feature a sane-ish probing system for
drivers, we can start experimenting with things like:
- multiple framebuffers / UART devices
- support for more complex peripherals (USB, storage)
- multiple boot paths
Hence registering output sinks as console devices, just like how u-boot and
linux do, is a feature we should've had a long while ago. So let's begin working
on that by decoupling framebuffer and uart from the "debug" interface in uni and
rather allowing the registering of such sinks as "console" devices.
With that, make the simple-framebuffer driver handle the debug level colors as
well as the message assembling and writing to the framebuffer. That fully detaches
it from the debug interface, as all that is required now is to invoke console_register()
with the appropriate struct passed as an argument.
As the drivers for output sinks are now responsible for the formatting of the messages,
their set-up and writing, UART can be implemented as a sole driver as well. However,
drivers register late in the boot process (after assembly, board early_initand other
drivers with higher priority). With that in mind and all the leftover UART puts/c code in
board files for several of the currently supported devices, introduce an early console
path dedicated for debugging via UART.
Looking at the currently supported devices, the only one requiring set-up before
being able to output to UART is lucky7. For ease of use, make early_console_init
weak, allowing it to be overrided by board files such as board-lucky7.
Lastly, debug -> console, as that more correctly addresses the purpose of the library
now.
The current drivers/framework.c is useless, as REGISTER_DRIVER() is a macro
that just directly calls the driver probe function. Every board file has to
reference each driver's probe function by name. This was just done to make room
for proper driver probing in the future, where we are now, so implement that.
Make drivers self-register at link time by emitting a struct driver into a
.uniloader_drivers section via DRIVER_REGISTER(). The linker brackets
the section with __drivers_start / __drivers_end symbols.
Boards describe their hardware as a static struct with the format
{ driver_name, plat_data, label }. Remove the drivers_init hook from
struct board_ops as it's no longer necessary.
The drivers probe will now be placed between early_init and splash.
The framework looks up each device's driver_name up in the
linker section and calls probe(plat_data). A failed probe is logged.
Do --whole-archive as well to convince the linker to not drop the drivers
in archived .o files that aren't called outside the archive.
Adopt all boards to use the framework.
All of the changes in this commit are co-dependent on each other, as we're
doing a large change to the ABI.
The value 5 appeared bare in two places: simplefb.c (when text wraps
past the bottom of the screen) and debug.c (initial y position for
the printk overlay). Replace both with FB_TEXT_TOP_PADDING defined
once in simplefb.h.
Due to divmod performing division by subtracting in a linear loop,
it's *really* slow. When performing division with larger numbers (like
32-bit addresses), it goes thru massive amounts of iterations and causes
a stall-like appearance.
Instead, let the compiler handle it by using cpu instructions like
UDIV/MSUB for armv8.
Fixes#86.
As we can make use of the video_info struct for base address,
this argument is not required anymore and only breaks havoc on
boards that don't set the CONFIG option.
Jokes aside, commit adds support for colored indexes based on the
loglevel, introduces a better simplefb probing that does not depend
on hardcoded config options. Implementing support for fdt should be
easier now.
With support for this board also come the following changes:
- rework blobs handling to get past the 0 size bug
- basic cpu "set up" in start.S
- assembly memcpy
- uart debugging
Implement 8 loglevels to use with printk:
While at it, separate the font in a new "video" directory, which
also makes space for a proper video probing implementation. Fill
in the font from 32 to 256. Scale the font to render twice as big.
Implement dynamic line length detection. Change a few things here
and there to follow the linux kernel code style. Add a nice logo.
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
arch: aarch64: Load addresses via page + offset
arch: aarch64: Align the TEXT region
drivers: Introduce an empty framework
board: Rework to be PIC
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>