diff --git a/include/debug.h b/include/debug.h index 86739cb2e7..cc406d0a98 100644 --- a/include/debug.h +++ b/include/debug.h @@ -29,6 +29,7 @@ #include #include +#include #ifdef CONFIG_ARCH_DEBUG_H # include @@ -1318,6 +1319,26 @@ # define resetinfodumpbuffer(m,b,n) #endif +/**************************************************************************** + * Name: lowsyslog + * + * Description: + * lowsyslog() is used for output debug information at early boot-stage. + * + * The NuttX implementation does not support any special formatting + * characters beyond those supported by printf. + * + ****************************************************************************/ + +#define lowsyslog(...) \ + do \ + { \ + struct lib_outstream_s stream; \ + lib_lowoutstream(&stream); \ + lib_sprintf(&stream, __VA_ARGS__); \ + } \ + while (0) + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 53b6f73728..f442ba474e 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -2820,6 +2820,18 @@ int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg, void up_putc(int ch); +/**************************************************************************** + * Name: up_lowputc + * + * Description: + * Output one character in early boot-stages. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LOWPUTC +void up_lowputc(int ch); +#endif + /**************************************************************************** * Name: up_puts * diff --git a/libs/libc/stream/lib_lowoutstream.c b/libs/libc/stream/lib_lowoutstream.c index 82d67734f6..6fe9fbf794 100644 --- a/libs/libc/stream/lib_lowoutstream.c +++ b/libs/libc/stream/lib_lowoutstream.c @@ -67,7 +67,7 @@ static void lowoutstream_putc(FAR struct lib_outstream_s *self, int ch) { DEBUGASSERT(self); - up_putc(ch); + up_lowputc(ch); if (ch != EOF) { @@ -82,10 +82,16 @@ static void lowoutstream_putc(FAR struct lib_outstream_s *self, int ch) static ssize_t lowoutstream_puts(FAR struct lib_outstream_s *self, FAR const void *buf, size_t len) { + FAR const char *str = (FAR const char *)buf; + size_t idx = 0; DEBUGASSERT(self); - self->nput += len; - up_nputs(buf, len); + while (str[idx] != 0 && idx < len) + { + lowoutstream_putc(self, str[idx]); + idx++; + } + return len; }