projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net: fm: add TFABOOT support
[oweals/u-boot.git]
/
common
/
console.c
diff --git
a/common/console.c
b/common/console.c
index 0e0295514b21687fadced9a8827a0c7e4700eb6c..0b0dd76256c7c865668add13a2ae89eb1530cb3f 100644
(file)
--- a/
common/console.c
+++ b/
common/console.c
@@
-1,8
+1,7
@@
+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2000
* Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
/*
* (C) Copyright 2000
* Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
*/
#include <common.h>
@@
-197,20
+196,21
@@
static int console_tstc(int file)
{
int i, ret;
struct stdio_dev *dev;
{
int i, ret;
struct stdio_dev *dev;
+ int prev;
- disable_ctrlc(1);
+
prev =
disable_ctrlc(1);
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->tstc != NULL) {
ret = dev->tstc(dev);
if (ret > 0) {
tstcdev = dev;
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->tstc != NULL) {
ret = dev->tstc(dev);
if (ret > 0) {
tstcdev = dev;
- disable_ctrlc(
0
);
+ disable_ctrlc(
prev
);
return ret;
}
}
}
return ret;
}
}
}
- disable_ctrlc(
0
);
+ disable_ctrlc(
prev
);
return 0;
}
return 0;
}
@@
-311,12
+311,12
@@
int serial_printf(const char *fmt, ...)
int fgetc(int file)
{
if (file < MAX_FILES) {
int fgetc(int file)
{
if (file < MAX_FILES) {
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
/*
* Effectively poll for input wherever it may be available.
*/
for (;;) {
WATCHDOG_RESET();
/*
* Effectively poll for input wherever it may be available.
*/
for (;;) {
WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
/*
* Upper layer may have already called tstc() so
* check for that first.
/*
* Upper layer may have already called tstc() so
* check for that first.
@@
-324,6
+324,10
@@
int fgetc(int file)
if (tstcdev != NULL)
return console_getc(file);
console_tstc(file);
if (tstcdev != NULL)
return console_getc(file);
console_tstc(file);
+#else
+ if (console_tstc(file))
+ return console_getc(file);
+#endif
#ifdef CONFIG_WATCHDOG
/*
* If the watchdog must be rate-limited then it should
#ifdef CONFIG_WATCHDOG
/*
* If the watchdog must be rate-limited then it should
@@
-332,9
+336,6
@@
int fgetc(int file)
udelay(1);
#endif
}
udelay(1);
#endif
}
-#else
- return console_getc(file);
-#endif
}
return -1;
}
return -1;
@@
-503,8
+504,10
@@
void putc(const char c)
return;
}
#endif
return;
}
#endif
+ if (!gd)
+ return;
#ifdef CONFIG_CONSOLE_RECORD
#ifdef CONFIG_CONSOLE_RECORD
- if (
gd &&
(gd->flags & GD_FLG_RECORD) && gd->console_out.start)
+ if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
membuff_putbyte(&gd->console_out, c);
#endif
#ifdef CONFIG_SILENT_CONSOLE
membuff_putbyte(&gd->console_out, c);
#endif
#ifdef CONFIG_SILENT_CONSOLE
@@
-532,6
+535,13
@@
void putc(const char c)
void puts(const char *s)
{
void puts(const char *s)
{
+#ifdef CONFIG_SANDBOX
+ /* sandbox can send characters to stdout before it has a console */
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ os_puts(s);
+ return;
+ }
+#endif
#ifdef CONFIG_DEBUG_UART
if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
#ifdef CONFIG_DEBUG_UART
if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
@@
-542,8
+552,10
@@
void puts(const char *s)
return;
}
#endif
return;
}
#endif
+ if (!gd)
+ return;
#ifdef CONFIG_CONSOLE_RECORD
#ifdef CONFIG_CONSOLE_RECORD
- if (
gd &&
(gd->flags & GD_FLG_RECORD) && gd->console_out.start)
+ if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
membuff_put(&gd->console_out, s, strlen(s));
#endif
#ifdef CONFIG_SILENT_CONSOLE
membuff_put(&gd->console_out, s, strlen(s));
#endif
#ifdef CONFIG_SILENT_CONSOLE
@@
-600,7
+612,6
@@
static int ctrlc_disabled = 0; /* see disable_ctrl() */
static int ctrlc_was_pressed = 0;
int ctrlc(void)
{
static int ctrlc_was_pressed = 0;
int ctrlc(void)
{
-#ifndef CONFIG_SANDBOX
if (!ctrlc_disabled && gd->have_console) {
if (tstc()) {
switch (getc()) {
if (!ctrlc_disabled && gd->have_console) {
if (tstc()) {
switch (getc()) {
@@
-612,7
+623,6
@@
int ctrlc(void)
}
}
}
}
}
}
-#endif
return 0;
}
return 0;
}
@@
-847,7
+857,7
@@
done:
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
/* set the environment variables (will overwrite previous env settings) */
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
/* set the environment variables (will overwrite previous env settings) */
- for (i = 0; i <
3
; i++) {
+ for (i = 0; i <
MAX_FILES
; i++) {
env_set(stdio_names[i], stdio_devices[i]->name);
}
#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
env_set(stdio_names[i], stdio_devices[i]->name);
}
#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
@@
-926,7
+936,7
@@
int console_init_r(void)
#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
/* Setting environment variables */
#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
/* Setting environment variables */
- for (i = 0; i <
3
; i++) {
+ for (i = 0; i <
MAX_FILES
; i++) {
env_set(stdio_names[i], stdio_devices[i]->name);
}
env_set(stdio_names[i], stdio_devices[i]->name);
}