[Concept,05/13] console: Add length-based debug UART support

Message ID 20260204001002.2638622-6-sjg@u-boot.org
State New
Headers
Series Add putsn() for length-based console output |

Commit Message

Simon Glass Feb. 4, 2026, 12:09 a.m. UTC
  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(+)
  

Patch

diff --git a/include/debug_uart.h b/include/debug_uart.h
index 714b369e6fe..f5664271f1c 100644
--- a/include/debug_uart.h
+++ b/include/debug_uart.h
@@ -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) \
 	{ \