console: Implement an environment var to control the pager
The 'pager' environment variable can be used to set the number of lines on the display. Provide a callback for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#define LOG_CATEGORY LOGC_CONSOLE
|
||||
|
||||
#include <env.h>
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <pager.h>
|
||||
@@ -161,6 +162,33 @@ void pager_reset(struct pager *pag)
|
||||
pag->line_count = 0;
|
||||
}
|
||||
|
||||
static int on_pager(const char *name, const char *value, enum env_op op,
|
||||
int flags)
|
||||
{
|
||||
struct pager *pag = gd_pager();
|
||||
int new_page_len;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_CONSOLE_PAGER) || !pag)
|
||||
return 0;
|
||||
|
||||
switch (op) {
|
||||
case env_op_create:
|
||||
case env_op_overwrite:
|
||||
if (value) {
|
||||
new_page_len = simple_strtoul(value, NULL, 16);
|
||||
pager_set_page_len(pag, new_page_len);
|
||||
}
|
||||
break;
|
||||
case env_op_delete:
|
||||
/* Reset to default when deleted */
|
||||
pager_set_page_len(pag, CONFIG_CONSOLE_PAGER_LINES);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
U_BOOT_ENV_CALLBACK(pager, on_pager);
|
||||
|
||||
void pager_uninit(struct pager *pag)
|
||||
{
|
||||
abuf_uninit(&pag->buf);
|
||||
|
||||
@@ -335,6 +335,9 @@ netretry
|
||||
Useful on scripts which control the retry operation
|
||||
themselves.
|
||||
|
||||
pager
|
||||
Decimal number of visible lines on the display, or serial console.
|
||||
|
||||
rng_seed_size
|
||||
Size of random value added to device-tree node /chosen/rng-seed.
|
||||
This variable is given as a decimal number.
|
||||
|
||||
@@ -75,6 +75,12 @@
|
||||
#define DFU_CALLBACK
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CONSOLE_PAGER
|
||||
#define PAGER_CALLBACK "pager:pager,"
|
||||
#else
|
||||
#define PAGER_CALLBACK
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This list of callback bindings is static, but may be overridden by defining
|
||||
* a new association in the ".callbacks" environment variable.
|
||||
@@ -88,6 +94,7 @@
|
||||
DFU_CALLBACK \
|
||||
"loadaddr:loadaddr," \
|
||||
SILENT_CALLBACK \
|
||||
PAGER_CALLBACK \
|
||||
"stdin:console,stdout:console,stderr:console," \
|
||||
"serial#:serialno," \
|
||||
CFG_ENV_CALLBACK_LIST_STATIC
|
||||
|
||||
Reference in New Issue
Block a user