aboutsummaryrefslogtreecommitdiff
path: root/common/console.c
AgeCommit message (Collapse)AuthorFilesLines
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"WIP/20May2024-nextTom Rini1-1/+0
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini1-0/+1
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06common: Remove <common.h> and add needed includesTom Rini1-1/+0
Remove <common.h> from all "commmon/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-01-24common: console: Fix print complete stdio device listPatrice Chotard1-15/+12
In case CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on and stdin or stdout or stderr are missing in environment, as fallback, get these either from stdio_devices[std] or stdio_devices[std]->name. Fixes: 6b343ab38d ("console: Print out complete stdio device list") Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-01-09lib: membuff: fix readline not returning line in case of overflowIon Agorria1-1/+1
If line overflows readline it will not be returned, fix this behavior, make it optional and documented properly. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20240105072212.6615-6-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-01-09common: console: record console from the beginningIon Agorria1-0/+3
Set flag to enable console record on console_record_init and not only on console_record_reset_enable. This fixes missing start of U-Boot log for fastboot oem console command. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20240105072212.6615-5-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-01-09common: console: introduce console_record_isempty helperIon Agorria1-0/+5
Add console_record_isempty to check if console record buffer contains any data. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20240105072212.6615-4-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-12-13video: Add a function to clear the displaySimon Glass1-0/+31
Move the code from the 'cls' command into the console file, so it can be called from elsewhere. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02console: Print out complete stdio device listBin Meng1-9/+21
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed. For such case, we can print out the stdio device name from the environment variables. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-02console: Refactor stdio_print_current_devices() a little bitBin Meng1-15/+15
In preparation to future changes, refactor this routine a little bit. Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-08-02console: Make stdio_print_current_devices() staticBin Meng1-1/+1
As it is only called in common/console.c Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> # qemu-x86_64
2023-03-14console: Use only 0x00 as line separator for console recordingMarek Vasut1-1/+1
In case character 0x20 (space) is used as line separator, character 0x9 (tab) is treated end of line. Commands which output a lot of tabs, i.e. various tree printing commands like 'fdt print' then end up generating a lot of newlines in the recorded output, and the recorded output is corrupted. Use character 0x00 (NUL) as separator instead to treat the tabs as valid part of recorded line. Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-12console: Add option to keep it silent until env is loadedHarald Seiler1-0/+5
Add a config-option which forces the console to stay silent until the proper environment is loaded from flash. This is important when the default environment does not silence the console but no output must be printed when 'silent' is set in the flash environment. After the environment from flash is loaded, the console will be silenced/unsilenced depending on it. If PRE_CONSOLE_BUFFER is also used, the buffer will now be flushed if the console should not be silenced. Signed-off-by: Harald Seiler <hws@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-02console: file should always be non-negativeHeinrich Schuchardt1-5/+5
We use the parameter file in console functions to choose from an array after checking against MAX_FILES but we never check if the value of file is negative. Running ./u-boot -T -l and issuing the poweroff command has resulted in crashes because os_exit() results in std::ostream::flush() calling U-Boot's fflush with file being a pointer which when converted to int may be represented by a negative number. This shows that checking against MAX_FILES is not enough. We have to ensure that the file argument is always positive. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-24serial: Implement serial_flush() function for console flush() fallbackPali Rohár1-0/+3
Like in all other console functions, implement also serial_flush() function as a fallback int console flush() function. Flush support is available only when config option CONSOLE_FLUSH_SUPPORT is enabled. So when it is disabled then provides just empty static inline function serial_flush(). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-24console: Implement flush() functionPali Rohár1-0/+61
On certain places it is required to flush output print buffers to ensure that text strings were sent to console or serial devices. For example when printing message that U-Boot is going to boot kernel or when U-Boot is going to change baudrate of terminal device. Therefore introduce a new flush() and fflush() functions into console code. These functions will call .flush callback of associated stdio_dev device. As this function may increase U-Boot side, allow to compile U-Boot without this function. For this purpose there is a new config CONSOLE_FLUSH_SUPPORT which is enabled by default and can be disabled. It is a good idea to have this option enabled for all boards which have enough space for it. When option is disabled when U-Boot defines just empty static inline function fflush() to avoid ifdefs in other code. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-19Merge branch 'master' into nextTom Rini1-1/+9
Signed-off-by: Tom Rini <trini@konsulko.com>
2022-09-18cyclic: Use schedule() instead of WATCHDOG_RESET()Stefan Roese1-1/+1
Globally replace all occurances of WATCHDOG_RESET() with schedule(), which handles the HW_WATCHDOG functionality and the cyclic infrastructure. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Tom Rini <trini@konsulko.com> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
2022-08-31common/console.c: prevent pre-console buffer contents from being added to itselfRasmus Villemoes1-1/+9
I do not have any non-serial output devices, so a print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL) does nothing for me. However, I was manually inspected the pre-console buffer using md.b, and I noticed that the early part of it was repeated. The reason is that the first call of print_pre_console_buffer(), from console_init_f(), ends up invoking puts() with the contents of the buffer at that point, and puts() at that point ends up in the else branch of if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fputs(stdout, s); } else { /* Send directly to the handler */ pre_console_puts(s); serial_puts(s); } so indeed the contents is added again. That can be somewhat confusing (both when reading the buffer manually, but also if it did actually come out on some device). So disable all use of the pre-console buffer while print_pre_console_buffer() is emitting it. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-10common: Drop display_options.h from common headerSimon Glass1-0/+1
Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-05-11common/console.c: use CONFIG_VAL() with PRE_CON_BUF_* variablesRasmus Villemoes1-6/+6
There is currently no support for PRE_CONSOLE_BUFFER in SPL, but if and when that gets implemented, one would almost certainly want to use a different address and/or size for the buffer (e.g., U-Boot proper might specify an address in DRAM and a generous buffer, while SPL would be much more constrained). So a prerequisite for adding SPL_PRE_CONSOLE_BUFFER is to make the code use SPL_-specific values. No functional change. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt1-1/+1
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-26console: Avoid serial output before the console is runningSimon Glass1-2/+4
The video driver uses this for debugging, but if used before relocation it crashes at present. Avoid trying to output debugging before the console is ready. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-11-28common: Allow a smaller console-recording pre-relocSimon Glass1-1/+3
Before relocation there is generally not as much available memory and not that much console output. At present the console-output buffer is the same side before and after relocation. Add a separate Kconfig option to remove this limitation. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-23test: add first autoboot unit testsSteffen Jaeckel1-0/+5
This adds tests for the crypt-based and plain SHA256-based password hashing algorithms in the autoboot flow. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-08console: Report an error when output buffer is exhaustedSimon Glass1-4/+14
If the console output buffer is exhausted, characters are silently dropped from the end. Detect this condition and report an error when reading back the characters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-02-16IOMUX: Split out for_each_console_dev() helper macroAndy Shevchenko1-10/+5
It is not only less lines of code, but also better readability when new macro is being in use. Introduce for_each_console_dev() helper macro and convert current users to it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-02-16IOMUX: Split out iomux_match_device() helperAndy Shevchenko1-4/+3
Deduplicate the code used in a few places by splitting out a common helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-02-16console: Set file and devices at one goAndy Shevchenko1-10/+12
Logical continuation of the change that brought console_devices_set() is to unify console_setfile() with it and replace in the callers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-02-16console: Set console device counter in console_devices_set()Andy Shevchenko1-0/+1
console_devices_set() missed the console device counter to be set correctly. Fixes: 45375adc9799 ("console: add function console_devices_set") Cc: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-02-16console: Switch to use stdio_file_to_flags()Andy Shevchenko1-11/+3
Deduplicate code by replacing with stdio_file_to_flags() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass1-0/+1
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-16console: cosmetics: remove #if 0Patrick Delaunay1-10/+0
Remove the #if 0 present since the first version of console.c Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: rename search_device() to console_search_dev()Andy Shevchenko1-9/+9
Rename search_device() to console_search_dev() since it's in console.h. Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: Keep ->start() and ->stop() balancedAndy Shevchenko1-0/+37
There is no need to call ->start() for already started device. All the same, there is no need to call ->stop() for devices still in use. For now enforce this only for IOMUX case. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: Introduce console_start() and console_stop()Andy Shevchenko1-7/+23
In the future we would like to stop unused consoles and also add a reference counting to avoid imbalanced calls to ->start() and ->stop() in some cases. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: add console_has_tstc helper function for CONSOLE_MUXPatrick Delaunay1-12/+25
Add the helper function console_has_tstc() and replace the test #if CONFIG_IS_ENABLED(CONSOLE_MUX) to a simple 'if' test to respect the U-Boot coding rule. No functional change. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: remove #ifdef CONFIG_CONSOLE_RECORDPatrick Delaunay1-22/+73
Add helper functions to access to gd->console_out and gd->console_in with membuff API and replace the #ifdef CONFIG_CONSOLE_RECORD test by if (IS_ENABLED(CONFIG_CONSOLE_RECORD)) to respect the U-Boot coding rule. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: add function console_devices_setPatrick Delaunay1-7/+13
Add a new function to access to console_devices only defined if CONFIG_IS_ENABLED(CONSOLE_MUX). This path allows to remove #if CONFIG_IS_ENABLED(CONSOLE_MUX) in console_getc function. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-01-15console: remove #ifdef CONFIG when it is possiblePatrick Delaunay1-94/+64
Remove #ifdef or #ifndef for CONFIG when it is possible to simplify the console.c code and respect the U-Boot coding rules. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: allow to record console output before readyPatrick Delaunay1-8/+8
Allow to record the console output before before U-Boot has a console ready. This patch allows to test the console output in sandbox test based on console record. It is possible because GD_FLG_RECORD and GD_FLG_SERIAL_READY are 2 independent flags. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-15console: remove duplicated test on gd valuePatrick Delaunay1-8/+8
Reorder test on gd value and remove the duplicated test (!gd) in putc and puts function. This patch is a preliminary step for rework of this function. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-22common: rename getc() to getchar()Heinrich Schuchardt1-6/+6
The sandbox is built with the SDL2 library with invokes the X11 library which in turn calls getc(). But getc() in glibc is defined as int getc(FILE *) This does not match our definition. int getc(void) The sandbox crashes when called with parameter -l. Rename our library symbol getc() to getchar(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-07console: Always define the console-recording functionsSimon Glass1-1/+3
On boards without console recording these function are currently missing. It is more convenient for them to be present but to return dummy values. That way if we know that a test needs recording, we can check if it is available, and skip the test if not, while avoiding #ifdefs. Update the header file according and adjust console_record_reset_enable() to return an error if recording is not available. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09console: Add a way to output to serial onlySimon Glass1-6/+22
In the video drivers it is useful to print errors while debugging but doing so risks an infinite loop as the debugging info itself may go through the video drivers. Add a new console function that prints information only to the serial device, thus making it safe for use in debugging. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-07-06video: restore CONFIG_VIDCONSOLE_AS_LCD as booleanPatrick Delaunay1-3/+3
This patch restores CONFIG_VIDCONSOLE_AS_LCD as boolean and introduce a separate sting as CONFIG_VIDCONSOLE_AS_NAME to search this string in stdout used as videoconsole. This patch avoid issue with board defconfig or code expecting CONFIG_VIDCONSOLE_AS_LCD as boolean. Fixes: 22b897a12323 ("video: extend stdout video console work-around for 'vga'") Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2020-06-18video: extend stdout video console work-around for 'vga'Anatolij Gustschin1-3/+4
cfb_console driver uses 'vga' console name and we still have board environments defining this name. Re-use existing DM_VIDEO work- around for console name to support 'vga' name in stdout environment. Signed-off-by: Anatolij Gustschin <agust@denx.de> Tested-by: Soeren Moch <smoch@web.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2020-05-18common: Drop linux/delay.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-02-13common/console.c: discard volatileHeinrich Schuchardt1-10/+13
Avoid errors of like common/console.c: In function ‘console_record_reset’: common/console.c:615:16: error: passing argument 1 of ‘membuff_purge’ discards ‘volatile’ qualifier from pointer target type [-Werror=discarded-qualifiers] 615 | membuff_purge(&gd->console_out); | ^~~~~~~~~~~~~~~~ by casting to non-volatile. The volatile property stems from declarations like arch/arm/include/asm/global_data.h:114: But there is no need to treat gd->console_out and gd->console_in as volatile in the context of common/console.c. Fixes: b612312816ff ("console: Add a function to read a line of the output / eof") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-02-05console: Add a function to read a line of the output / eofSimon Glass1-0/+11
When recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output. Add a console function to return the next line and another to see how must data is left. Signed-off-by: Simon Glass <sjg@chromium.org>