[Concept,05/13] console: Add length-based debug UART support
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Add printasciin() to support length-based output through the debug
UART. This allows putsn() to work correctly with the early debug
console.
Co-developed-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
include/debug_uart.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
@@ -83,6 +83,17 @@ void printch(int ch);
*/
void printascii(const char *str);
+/**
+ * printasciin() - Output a string with specified length to the debug UART
+ *
+ * This outputs exactly @len characters from @str, regardless of any nul
+ * characters that may be present.
+ *
+ * @str: String to output (need not be nul-terminated)
+ * @len: Number of characters to output
+ */
+void printasciin(const char *str, int len);
+
/**
* printhex2() - Output a 2-digit hex value
*
@@ -150,6 +161,12 @@ void printdec(unsigned int value);
while (*str) \
_printch(*str++); \
} \
+\
+ void printasciin(const char *str, int len) \
+ { \
+ while (len--) \
+ _printch(*str++); \
+ } \
\
static inline void printhex1(unsigned int digit) \
{ \