console: Plumb in the pager
Send all console output via the pager. If it is disabled, it will do nothing. The pager is only supported if CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are enabled. This is the common case for more richly featured boards, i.e. those that can cope with the extra code size of this feature. Series-changes: 2 - Drop an unnecessary direct call to the pager - Repeat the old code in console_puts_pager() to avoid 16-byte growth Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <malloc.h>
|
||||
#include <mapmem.h>
|
||||
#include <os.h>
|
||||
#include <pager.h>
|
||||
#include <serial.h>
|
||||
#include <stdio_dev.h>
|
||||
#include <exports.h>
|
||||
@@ -312,14 +313,39 @@ int console_printf_select_stderr(bool serial_only, const char *fmt, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void console_puts(int file, bool use_pager, const char *s)
|
||||
{
|
||||
int key = 0;
|
||||
|
||||
for (s = pager_post(gd_pager(), use_pager, s); s;
|
||||
s = pager_next(gd_pager(), use_pager, key)) {
|
||||
struct stdio_dev *dev;
|
||||
int i;
|
||||
|
||||
key = 0;
|
||||
if (IS_ENABLED(CONFIG_CONSOLE_PAGER) && s == PAGER_WAITING) {
|
||||
key = getchar();
|
||||
} else if (*s) {
|
||||
for_each_console_dev(i, file, dev) {
|
||||
if (dev->puts != NULL)
|
||||
dev->puts(dev, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void console_puts_pager(int file, const char *s)
|
||||
{
|
||||
int i;
|
||||
struct stdio_dev *dev;
|
||||
if (IS_ENABLED(CONFIG_CONSOLE_PAGER)) {
|
||||
console_puts(file, true, s);
|
||||
} else {
|
||||
struct stdio_dev *dev;
|
||||
int i;
|
||||
|
||||
for_each_console_dev(i, file, dev) {
|
||||
if (dev->puts != NULL)
|
||||
dev->puts(dev, s);
|
||||
for_each_console_dev(i, file, dev) {
|
||||
if (dev->puts != NULL)
|
||||
dev->puts(dev, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +368,8 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
|
||||
iomux_doenv(file, dev->name);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
#else /* !CONSOLE_MUX */
|
||||
|
||||
static void console_devices_set(int file, struct stdio_dev *dev)
|
||||
{
|
||||
@@ -1101,6 +1128,21 @@ static int on_silent(const char *name, const char *value, enum env_op op,
|
||||
U_BOOT_ENV_CALLBACK(silent, on_silent);
|
||||
#endif
|
||||
|
||||
static void setup_pager(void)
|
||||
{
|
||||
/* Init pager now that console is ready */
|
||||
if (IS_ENABLED(CONFIG_CONSOLE_PAGER)) {
|
||||
int lines = IF_ENABLED_INT(CONFIG_CONSOLE_PAGER,
|
||||
CONFIG_CONSOLE_PAGER_LINES);
|
||||
int ret;
|
||||
|
||||
ret = pager_init(gd_pagerp(), env_get_hex("pager", lines),
|
||||
PAGER_BUF_SIZE);
|
||||
if (ret)
|
||||
printf("Failed to init pager\n");
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
|
||||
/* Called after the relocation - use desired console functions */
|
||||
int console_init_r(void)
|
||||
@@ -1185,6 +1227,7 @@ done:
|
||||
}
|
||||
|
||||
gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
|
||||
setup_pager();
|
||||
|
||||
print_pre_console_buffer(flushpoint);
|
||||
return 0;
|
||||
@@ -1252,6 +1295,7 @@ int console_init_r(void)
|
||||
}
|
||||
|
||||
gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
|
||||
setup_pager();
|
||||
|
||||
print_pre_console_buffer(flushpoint);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user