summaryrefslogtreecommitdiff
path: root/common/console.c
AgeCommit message (Collapse)AuthorFilesLines
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>
2017-08-28common: console: Fix duplicated CONFIG in silent env callbackWilson Lee1-2/+2
The silent environment callback function does not update the silent flag during silent env set or unset. That is because of duplicated CONFIG keyword at preprocessor condition in silent environment callback function and cause silent env callback unable to work. This patch is to remove the duplicated CONFIG keywork in silent environment callback function. Signed-off-by: Wilson Lee <wilson.lee@ni.com> Cc: Keng Soon Cheah <keng.soon.cheah@ni.com> Cc: Chen Yee Chew <chen.yee.chew@ni.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass1-5/+5
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename setenv() to env_set()Simon Glass1-2/+2
We are now using an env_ prefix for environment functions. Rename setenv() for consistency. Also add function comments in common.h. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-31dm: console: Check for serial devices properlySimon Glass1-1/+10
With driver model the serial device is often not called "serial". Mark driver-model stdio devices so that they can be detected and we can look up the uclass. This is a more reliable way of finding out whether the console is connected to a serial device or not. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-31console: Unify the check for a serial consoleSimon Glass1-2/+17
Put the check for whether a console is a serial device in a function so that we can share the code in the two places that use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-28console: simplify puts()Masahiro Yamada1-42/+2
Current puts() and putc() have similar #ifdef / if() conditionals. Make puts() iterate over putc() to avoid code duplication. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-07-11sandbox: Drop special case console code for sandboxSimon Glass1-13/+0
At present sandbox has a special case where it directly calls os_putc() when it does not have a console yet. Now that we have the pre-console buffer enabled we can drop this. Any early characters will be buffered and output later. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2017-07-11console: Use map_sysmem() for the pre-relocation consoleSimon Glass1-2/+9
At present this feature casts the address to a pointer. Use the map_sysmem() function so that it will work correctly on sandbox. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2017-07-11Allow displaying the U-Boot banner on a video displaySimon Glass1-4/+13
At present the U-Boot banner is only displayed on the serial console. If this is not visible to the user, the banner does not show. Some devices have a video display which can usefully display this information. Add a banner which is printed after relocation only on non-serial devices if CONFIG_DISPLAY_BOARDINFO_LATE is defined. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2017-02-06console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPLSimon Glass1-15/+15
CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV are not applicable for SPL. Update the console code to use CONFIG_IS_ENABLED(), so that these options will be inactive in SPL. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>