mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2026-06-13 21:40:05 +00:00
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.
20 lines
376 B
C
20 lines
376 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2026, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
|
*/
|
|
|
|
#ifndef CONSOLE_H_
|
|
#define CONSOLE_H_
|
|
|
|
struct console {
|
|
void (*write)(int level, const char *prefix, const char *msg);
|
|
};
|
|
|
|
void console_register(const struct console *con);
|
|
|
|
void earlycon_register(void);
|
|
|
|
void early_console_init(void);
|
|
|
|
#endif // CONSOLE_H_
|