Add a note about the pager to the console documentation, with some more
information in the developer section. Also include the pager API.
Series-to: concept
Cover-letter:
Introduce a pager for the console
Some U-Boot commands can produce a lot of output and this can run off
top of the display. This series introduces a simple pager feature, to
allow the output to be read, before pressing SPACE to continue.
A fixed buffer size (4K) is used, which sets a limit on the permmited
output before paging fails and the output is simply written all in one
lot. In most cases this is plenty, but 'env print' does print the whole
environment as one string, so if the legacy distro-boot scripts are used
it could happen.
The default number of visible lines is set with a Kconfig option. Where
a video terminal is being used, the page size is set to match that. In
general U-Boot cannot guess the number of visible lines, since a serial
terminal may be in use.
There is also a 'pager' environment variable which can override any
detected value.
This initial series only counts newlines. It has no support for counting
characters so the result will be sub-optimal if very long lines are
written. This could be addressed in a future patch.
Some effort is made to handle common cases correctly. For example, if
stdout is changed to a serial or vidconsole device, that is used to
determine the page length. When redirecting sandbox to a file, no
attempt is made.
Future work may detect the terminal size by sending an ANSI sequence.
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-version: 2
Add tests for checking:
- environment variable override with hex values
- invalid environment variable handling
- Kconfig-default behavior with device detection
- precedence rules (environment overrides device detection)
- serial terminal detection by manipulating sandbox state
Also expose calc_check_console_lines() in console.h for testing
and update pager functionality to use bypass mode when serial
is not connected to a terminal.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
It is annoying to have the pager use the line count from the display
when console output is actually using serial. Check this when stdio
changes and recaculate as needed.
Signed-off-by: Simon Glass <sjg@chromium.org>
If there is a serial console, use that to set the number of lines for the
pager.
This is controlled by CONFIG_SERIAL_TERM_PRESENT
Enable SERIAL_TERM_PRESENT by default if the pager is being used, since
people generally have a serial console enabled.
Make the serial a lower priority than the vidconsole.
We don't want to use the pager when the output of sandbox is being
redirected. So in that case, put the pager in bypass mode.
Series-changes: 2
- Only use the vidconsole if we believe it is visible
Signed-off-by: Simon Glass <sjg@chromium.org>
If there is a video console, use that to set the number of lines for the
pager.
For sandbox, only do this if the -l flag was provided, i.e. the emulated
LCD is visible.
Series-changes: 2
- Only use the vidconsole if we believe it is visible
Signed-off-by: Simon Glass <sjg@chromium.org>
Show the actual value being used by the pager, if enabled.
Series-changes: 2
- Add new patch to show the pager page_len value
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
We don't want the pager appearing when entering commands, so add a way
to bypass it. Reset the line count to zero before executing the command.
Signed-off-by: Simon Glass <sjg@chromium.org>
Provide a test that the prompt is displayed and another that paging
happens but does not appear in the recorded console-output.
Signed-off-by: Simon Glass <sjg@chromium.org>
A single character may result in a stall waiting for user input, which
means that it may request that a string be output. So when the pager is
active we never actually use the devices' putc() methods. Add a special
case so they don't go to wrack and ruin.
As before, the pager is only supported with CONFIG_CONSOLE_MUX enabled.
Series-changes: 2
- Drop unnecessary '!= NULL'
Signed-off-by: Simon Glass <sjg@chromium.org>
We generally don't want the pager to be active when running tests,
since U-Boot appears to hang forever. Perhaps we could detect when the
tests are being run interactively and use the pager in that case. But
for now, just bypass it.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
Add a new -A sandbox command-line option that sets a flag to assume no
terminal is present. This causes serial_query_size() to return -ENOENT
immediately, similar to when CONFIG_SERIAL_TERM_PRESENT is disabled.
This option is useful for testing pager behavior in non-interactive
environments without needing to modify configuration options.
Co-developed-by: Claude <noreply@anthropic.com>
The pager gets in the way of most tests, since it kicks in (by default)
when a command results in more than 25 lines of output. Use the -P flag
to bypass it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new -P command line flag to sandbox that enables pager-bypass
mode. This is useful for tests and automated scripts that need to
disable pager interrupts.
The implementation stores the bypass request in sandbox_state during
command line parsing, then applies it in sandbox_main_loop_init()
after the pager has been initialized.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Rename console_puts() to console_puts_pager() and console_putc() to
console_putc_pager() to prepare for implementing a console-pager
feature.
All normal output goes through the pager.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Sometimes output should be sent ignoring the pager, such as when it is
a message related to paging. Add a parameter to support this.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Cover the various cases in the base code. Put the tests in the 'common'
suite to match where the pager implementation is.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add an implementation of the pager. It has quite a simple API:
- call pager_post() to send some output, which returns what should
actually be sent to the console devices
- then call pager_next() repeatedly, outputting what it returns,
until it returns NULL
There is one special case: pager_next() returns PAGER_WAITING if it is
waiting for the user to press a key. In that case, the caller should
read a key and then pass it to the next pager_next() call.
Internally, there is a simple state machine to cope with hitting the
limit (and outputing a prompt), waiting for the user and the clearing
the prompt, before continuing in the normal PAGEST_OK state.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tweak the documentation to look better when viewed. Use 'write' instead
of 'put'.
Series-to: concept
Series-cc: heinrich
Series-version: 3
Cover-letter:
console: Refactor in preparation for the pager
This series tidies up a few small things the serial and console areas:
- Move detection of serial-console size to the serial module
- Provide a Kconfig to disable serial detection
- Fix some missing driver-model flags in stdio devices
- Move console docs into the main documentation
This series is marked v2 since some of the patches were sent in any
earlier series. With various tweaks that series grew too large to be
sent as a single series.
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 2:17
This function has lots of return statements in a switch statement. Move
them out so we can (later) do something else in this function.
Series-changes: 2
- Add new patch to refactor handling of the result in on_console()
Signed-off-by: Simon Glass <sjg@chromium.org>
Move the environment callbacks lower so that we can call functions
elsewhere in common/console.c
Series-changes: 2
- Add new patch to move environment handling lower in the file
Signed-off-by: Simon Glass <sjg@chromium.org>
When an stdio device is provided by a driver model device, optionally
show the uclass.
Be careful to avoid increasing code size, since this is a common
command.
Signed-off-by: Simon Glass <sjg@chromium.org>
The 'dev' variable is generally used for driver model, so change
do_coninfo() to use sdev, to avoid confusion.
Signed-off-by: Simon Glass <sjg@chromium.org>
Detect if there is no terminal present (this only works on sandbox) and
skip sending ANSI characters when the CLI starts up. This avoids having
them in logs, for example.
Signed-off-by: Simon Glass <sjg@chromium.org>
The post system requires use of CFG_xxx values which are only included
via the config.h header. Most files don't include this now.
The serial.h header includes post.h which causes a build error on any
platform which enables CONFIG_POST, such as pg_wcom_seli8
Add an explicit #include of config.h in the post.h header file.
Signed-off-by: Simon Glass <sjg@chromium.org>
Sandbox is often run with the display disabled, so even though it has a
video device, it is not being shown. Provide a way to detect this. For
all other platforms, we assume the display is shown, when there is a
video device.
Series-changes: 2
- Add new patch to provide a way to tell if the video is visible
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a serial_is_tty() function that determines if the serial console
is connected to a terminal. For sandbox, this uses os_isatty() to
check stdin, except for cooked mode, where we don't want to assume
anything about the terminal.
For other platforms, it always returns true.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add serial_priv structure to serial uclass to cache terminal dimensions.
When serial_query_size() successfully queries the terminal, store the
results in the uclass-private data for later retrieval.
This avoids repeated terminal queries and improves performance when
different subsystems need the terminal size.
Series-changes: 3
- Drop unnecessary 'dev' argument
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI loader has some code to check the size (rows and columns) of an
attached terminal. Move this over to the serial uclass so that it can be
used elsewhere.
Create a new CONFIG_SERIAL_TERM_PRESENT to control whether it should be
used. Enable that for the EFI loader to preserve existing behaviour.
Adjust the implementation so that it returns a useful error code on
failure. Put the ESC and cESC values in the serial.h header.
Series-changes: 3
- Update comment for serial_query_size()
Signed-off-by: Simon Glass <sjg@chromium.org>
Add support for sorting EFI variables by name when using printenv -e.
The -s flag sorts variables alphabetically before display, useful when
dealing with large numbers of variables.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Improvements to env print -e
Printing EFI variables can be quite verbose, with many hundreds of lines
of text. Part of this is because GUIDs and hex dumps are included. It
can also be hard to find a few variables visually in an unsorted list.
This series makes the feature more user-friendly:
- Puts verbose output behind a -v flag, so that 'env print -e' behaves
more like 'env print'
- Adds a -s option to sort the list
END
Series-links: 1:15
Rather than printing as we go, add variables to an alist so they can be
printed when all variables are present.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than freeing the variable in several places, put it at the end.
Assume failure by default, returning success only if all steps passed.
Signed-off-by: Simon Glass <sjg@chromium.org>
This variable name is quite long. There is only one 'name' (the variable
name) and it has to be u16 as it is an EFI variable. So rename it to
'name'.
Signed-off-by: Simon Glass <sjg@chromium.org>
Change the default behavior of 'printenv -e' to show only EFI variable
names. The previous verbose output is now available with the -v flag.
This makes the command more user-friendly for quick variable listing.
Update documentation to reflect the new behavior and provide examples
of all three output modes: default (names only), -n (details without
hex dump), and -v (full verbose output).
It might be nicer to use -d to enable the dump, rather than have it on
by default.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Now that the EFI app supports booting Ubuntu via the EFI bootmeth, add
a test for this, for ARM. This uses the sjg lab.
Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: app: Support booting an OS
This series completes the work to get the EFI app booting an EFI
application (e.g. Ubuntu):
- efidebug dh now works, and is slightly enhanced
- device paths which refer to the underlying EFI layer can now be
requested by the app
- a test is provided, for EFI on ARM booting into Ubuntu using the sjg
lab
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:12