* [PATCH 0/2] sandbox: error output
@ 2022-04-04 20:45 Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 1/2] sandbox: add function os_printf() Heinrich Schuchardt
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Heinrich Schuchardt @ 2022-04-04 20:45 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Heinrich Schuchardt
U-Boot's printf() cannot write to the console before the serial console
driver is set up. We need a function writing to the OS console.
Provide a new function os_printf() to print to the OS console.
Use the funciton to implement the error messages related to loading the
device-tree.
For sure there are more places where we need os_printf() instead of
printf() for error messages.
We also could use it to provide a debug console for the sandbox.
Heinrich Schuchardt (2):
sandbox: add function os_printf()
sandbox: show error if the device-tree cannot be loaded
arch/sandbox/cpu/cpu.c | 8 ++++----
arch/sandbox/cpu/os.c | 13 +++++++++++++
include/os.h | 7 +++++++
3 files changed, 24 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] sandbox: add function os_printf()
2022-04-04 20:45 [PATCH 0/2] sandbox: error output Heinrich Schuchardt
@ 2022-04-04 20:45 ` Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 2/2] sandbox: show error if the device-tree cannot be loaded Heinrich Schuchardt
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Heinrich Schuchardt @ 2022-04-04 20:45 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Heinrich Schuchardt
Before setting up the devices U-Boot's printf() function cannot be used
for console output. Provide function os_printf() to print to stderr.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/sandbox/cpu/os.c | 13 +++++++++++++
include/os.h | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d83c862182..ec1836f8f6 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -11,6 +11,7 @@
#include <getopt.h>
#include <setjmp.h>
#include <signal.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -51,6 +52,18 @@ ssize_t os_write(int fd, const void *buf, size_t count)
return write(fd, buf, count);
}
+int os_printf(const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = vfprintf(stdout, fmt, args);
+ va_end(args);
+
+ return i;
+}
+
off_t os_lseek(int fd, off_t offset, int whence)
{
if (whence == OS_SEEK_SET)
diff --git a/include/os.h b/include/os.h
index 10e198cf50..148178787b 100644
--- a/include/os.h
+++ b/include/os.h
@@ -16,6 +16,13 @@
struct rtc_time;
struct sandbox_state;
+/**
+ * os_printf() - print directly to OS console
+ *
+ * @format: format string
+ */
+int os_printf(const char *format, ...);
+
/**
* Access to the OS read() system call
*
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] sandbox: show error if the device-tree cannot be loaded
2022-04-04 20:45 [PATCH 0/2] sandbox: error output Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 1/2] sandbox: add function os_printf() Heinrich Schuchardt
@ 2022-04-04 20:45 ` Heinrich Schuchardt
2022-06-28 13:38 ` Simon Glass
2022-06-28 13:38 ` [PATCH 1/2] sandbox: add function os_printf() Simon Glass
3 siblings, 0 replies; 5+ messages in thread
From: Heinrich Schuchardt @ 2022-04-04 20:45 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Heinrich Schuchardt
U-Boot's printf() used before setting up U-Boot's serial driver does not
create any output. Use os_printf() for error messages related to loading
the device-tree.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/sandbox/cpu/cpu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index ff0fa8a685..9e379da17a 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -306,27 +306,27 @@ void *board_fdt_blob_setup(int *ret)
err = fdt_create_empty_tree(blob, 256);
if (!err)
goto done;
- printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
+ os_printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
*ret = -EINVAL;
goto fail;
}
err = os_get_filesize(fname, &size);
if (err < 0) {
- printf("Failed to find FDT file '%s'\n", fname);
+ os_printf("Failed to find FDT file '%s'\n", fname);
*ret = err;
goto fail;
}
fd = os_open(fname, OS_O_RDONLY);
if (fd < 0) {
- printf("Failed to open FDT file '%s'\n", fname);
+ os_printf("Failed to open FDT file '%s'\n", fname);
*ret = -EACCES;
goto fail;
}
if (os_read(fd, blob, size) != size) {
os_close(fd);
- printf("Failed to read FDT file '%s'\n", fname);
+ os_printf("Failed to read FDT file '%s'\n", fname);
*ret = -EIO;
goto fail;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] sandbox: show error if the device-tree cannot be loaded
2022-04-04 20:45 [PATCH 0/2] sandbox: error output Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 1/2] sandbox: add function os_printf() Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 2/2] sandbox: show error if the device-tree cannot be loaded Heinrich Schuchardt
@ 2022-06-28 13:38 ` Simon Glass
2022-06-28 13:38 ` [PATCH 1/2] sandbox: add function os_printf() Simon Glass
3 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2022-06-28 13:38 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: u-boot, Simon Glass
U-Boot's printf() used before setting up U-Boot's serial driver does not
create any output. Use os_printf() for error messages related to loading
the device-tree.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/sandbox/cpu/cpu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] sandbox: add function os_printf()
2022-04-04 20:45 [PATCH 0/2] sandbox: error output Heinrich Schuchardt
` (2 preceding siblings ...)
2022-06-28 13:38 ` Simon Glass
@ 2022-06-28 13:38 ` Simon Glass
3 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2022-06-28 13:38 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: u-boot, Simon Glass
Before setting up the devices U-Boot's printf() function cannot be used
for console output. Provide function os_printf() to print to stderr.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/sandbox/cpu/os.c | 13 +++++++++++++
include/os.h | 7 +++++++
2 files changed, 20 insertions(+)
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-28 13:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 20:45 [PATCH 0/2] sandbox: error output Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 1/2] sandbox: add function os_printf() Heinrich Schuchardt
2022-04-04 20:45 ` [PATCH 2/2] sandbox: show error if the device-tree cannot be loaded Heinrich Schuchardt
2022-06-28 13:38 ` Simon Glass
2022-06-28 13:38 ` [PATCH 1/2] sandbox: add function os_printf() Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.