summaryrefslogtreecommitdiff
path: root/common/console.c
AgeCommit message (Collapse)AuthorFilesLines
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-27console: 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-29common: 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-08console: 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-19common: 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-06console: 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>
2019-11-07common/console.c: Fix unused warning with console_doenv()Tom Rini1-0/+4
Newer versions of LLVM-7 will provide an unused function warning over console_doenv() in the case of SYS_CONSOLE_IS_IN_ENV not being enabled as can be the case in SPL. Add guards around this function. Signed-off-by: Tom Rini <trini@konsulko.com>
2019-08-12env: Rename environment.h to env_internal.hSimon Glass1-1/+1
This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-08-11env: Move env_set() to env.hSimon Glass1-0/+1
Move env_set() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-07console: execute flush on uart when silent is removedPatrick Delaunay1-9/+36
Avoid to flush buffer when silent console is activated as the console can be reactivate later, after relocation, when the env will be updated with the saved one. Solve issue (missing beginning of U-Boot trace) when: - CONFIG_SILENT_CONSOLE is activated - silent=1 is defined in default environment (CONFIG_EXTRA_ENV_SETTINGS) - silent is removed in saved environment with: > env delete silent; env save Only functional when PRE_CONSOLE_BUFFER is activated. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
2019-08-07console: update silent tag after env loadPatrick Delaunay1-0/+4
Update the "silent" property with the variable "silent" get from saved environment, it solves the issue when: - CONFIG_SILENT_CONSOLE and CONFIG_SYS_CONSOLE_IS_IN_ENV are activated - silent is not defined in default environment - silent is requested in saved environment with: > env set silent 1; env save On next reboot the console is not disabled as expected after relocation and the environment load from flash (the callback is not called when the INSERT is requested in the created hash table) Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
2018-11-26sandbox: Allow puts() output before global_data is set upSimon Glass1-0/+7
We support putc() in this case but not puts(), but this is more useful since it is what printf() uses. This particularly affects debugging early in SPL, where currently printf() statements result in no output. Fix this by adding a special case into puts() for sandbox, just like putc(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2018-09-11console: unify fgetc function when console MUX is deactivatedPatrick Delaunay1-4/+5
Unify the fgetc function when MUX is activated or not: - always call tstc() : it is the normal behavior expected by serial uclass (call tstc then getc) and that avoids issue when SERIAL_RX_BUFFER is activated - reload WATCHDOG in the char waiting loop This patch allow to have the same behavior when CONSOLE_MUX is activated or not and avoid regression when this feature is deactivated. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-26sandbox: Don't disable ctrlc() on sandbox if in raw modeJoe Hershberger1-2/+0
In raw mode, handle ctrl-c as normal. This allows normal ctrl-c behavior such as aborting a command that is timing out without completely terminating the sandbox executable. In [1], Simon disabled this. His reason for it was that it interferes with piping test scripts. Piping should be done in cooked mode, so this change should still not interfere. [1] commit 8969ea3e9f2db04a6b3675 ("sandbox: Disable Ctrl-C") Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-26console: Remember if ctrlc is disabled in console_tstc()Joe Hershberger1-3/+4
We don't necessarily want to re-enable ctrl-c if it was already disabled when calling tstc(). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-06-18console: Fix handling of NULL global_dataSimon Glass1-2/+6
Both putc() and puts() can be called before global_data is set up. Some of the code paths don't handle this correctly. Add an explicit test before any member is accessed. Reported-by: Coverity (CID: 169030) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-06stdio_names: Ensure MAX_NAMES is defined before use, don't use 3 directlyTom Rini1-2/+2
With tighter build flags the fact that <stdio_dev.h> doesn't have a reference back to MAX_NAMES causes an error. Include <stdio.h> here and then in common/console.c use MAX_NAMES rather than 3 when working with stdio_names. Reported-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com> Tested-by: Peter Robinson <pbrobinson@gmail.com>
2017-12-07Revert "sandbox: Drop special case console code for sandbox"Simon Glass1-0/+7
While sandbox works OK without the special-case code, it does result in console output being stored in the pre-console buffer while sandbox starts up. If there is a crash or a problem then there is no indication of what is going on. For ease of debugging it seems better to revert this change also. This reverts commit d8c6fb8cedbc35eee27730a7fa544e499b3c81cc. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-11-13Revert "console: simplify puts()"Soeren Moch1-2/+42
This reverts commit c61d0009feb966e0e93254a8c435a1889085e6b8. A tbs2910 board user reported a very slow console frambuffer as regression in current u-boot. I could bisect this down to the above mentioned commit. This revert brings back the fast framebuffer console (one cache flush per string in puts(), not after each char). Reported-by: Uwe Scheffler <scheffler.u@web.de> Signed-off-by: Soeren Moch <smoch@web.de> Tested-by: Uwe Scheffler <scheffler.u@web.de> Reviewed-by: Simon Glass <sjg@chromium.org>