From patchwork Wed Feb 4 00:09:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1795 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163821; bh=BLKPUJEyRzKAppzhYJLd5bzIzOR4pcLZ/DWM9ee4rt0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=S6MuhnoUQ8FSn7aKAFiaqn9aZjIP/mugDE5y/OMpn4PowH/FbdL9CJ9MIbQkSt+Z2 2rZBItKfn/0OrIjHLLJKvU8BeFvVdVV9xaLERmb+lzCqILGxzpdwS9sSZZqL/qaGGn CcUVfatipF2o6S9iQl/eA6j1cY92kFjgR71/TFfizJiyUbmmfCdT8ykI6AAtcPTTX+ KoeDrFv/XTrYRFEVkRJ+l5G2mZ1MNQhfAWLqMxwcDDyn+IvwSBrlze9Jl7cEVH1Z2A 3H03Pn2J+0XnEiQOq5R+ZGpvXE+U2gvY3ZhFD3BMLqtUPoO3nqiwhiBeZJsAEB+Wrm ju4W2mm1aOFfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7BD4769914 for ; Tue, 3 Feb 2026 17:10:21 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6YRR2RKBETCN for ; Tue, 3 Feb 2026 17:10:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163821; bh=BLKPUJEyRzKAppzhYJLd5bzIzOR4pcLZ/DWM9ee4rt0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=S6MuhnoUQ8FSn7aKAFiaqn9aZjIP/mugDE5y/OMpn4PowH/FbdL9CJ9MIbQkSt+Z2 2rZBItKfn/0OrIjHLLJKvU8BeFvVdVV9xaLERmb+lzCqILGxzpdwS9sSZZqL/qaGGn CcUVfatipF2o6S9iQl/eA6j1cY92kFjgR71/TFfizJiyUbmmfCdT8ykI6AAtcPTTX+ KoeDrFv/XTrYRFEVkRJ+l5G2mZ1MNQhfAWLqMxwcDDyn+IvwSBrlze9Jl7cEVH1Z2A 3H03Pn2J+0XnEiQOq5R+ZGpvXE+U2gvY3ZhFD3BMLqtUPoO3nqiwhiBeZJsAEB+Wrm ju4W2mm1aOFfg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6BED869911 for ; Tue, 3 Feb 2026 17:10:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163820; bh=4in2X8C2YIsTjXNRRbyH3mZtsLAhHCsIi3oe4naUhnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isffnfIS3itTI42S6ZmrcitCT5DtWmmixGolHERYmauI8rFwznLQEZrhFkPCdnsus cMedNuOgwywEaVnf2+xGlS/aOMg3bYGR7/1fI9edu2HHKxJ1qJ3l+OGaxBfMAJXF3S dj/Wchklh0KaGcQhez2dXiGwoqTgG405rwAsvgrie7ANp02eDieOs/lZmmigTStpxd 6ZHdaKWlYzZny9FhbQ3CPB5r6QJ2UN3DxMC1xk8yMclelotzjBs8Y0dGWq5E2KB/zF g7LxV2qGBTSRRQ5nJCGtZdPQiP1xFGorDhyo6HsQwvV9DSaAsSSaADXgg01gso1T97 sFHmzxsRQv5Cw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 64B2469868; Tue, 3 Feb 2026 17:10:20 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id KD4_oJAYSOvb; Tue, 3 Feb 2026 17:10:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163816; bh=oB20OPc7EeBhApQPUmjQTZAzxOWQ2FwsbySJt9OAkos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ry27vshvCz+ADCSIRohaHoPggVh+aLMlj/dOu7vxXz9SKqO5fio0nkOFjnZ9HvOez dmln5aHgaAtUSasv6JyWm+68KZ3c+EEm8x/KE0iXWSWv27G2ps/PJxcoT5LpHOyYw0 f1fNtROWB6KVTLmKSWiIupaLT43NLC16uB4xy4KSU+Q/GglPUpzqK2ZBoPLBrpvQt0 rO67t98WBo9rFcp4BQxnZV6lMrAIRP0BlpbRRlkFQNQbYaE7Nah8dMH6CepvhfKV53 1siKuK1W5gsJImWA5I/8TDkhGcl0Z3syRFzWZGb61NU8pkWz5y1f333GR6C6uplRVz /ELO7vmzAKTYQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 134A869909; Tue, 3 Feb 2026 17:10:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:45 -0700 Message-ID: <20260204001002.2638622-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QJDBY5QBIMKSL7YG3J544QBKHXYF7ASI X-Message-ID-Hash: QJDBY5QBIMKSL7YG3J544QBKHXYF7ASI X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/13] console: Add a Kconfig option for putsn() support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add CONFIG_CONSOLE_PUTSN option to enable the putsn() function for length-based string output. This allows printing strings without requiring nul-termination. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/Kconfig b/common/Kconfig index c709df753bf..fd1f9cc5bcb 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -54,6 +54,15 @@ config CONSOLE_RECORD_IN_SIZE The buffer is allocated immediately after the malloc() region is ready. +config CONSOLE_PUTSN + bool "Enable putsn() function for length-based output" + default y if SANDBOX + help + Enable the putsn() function which outputs a string with a + specified length without requiring nul-termination. This is + useful for printing substrings or binary data without + allocating temporary buffers. + config SYS_CBSIZE int "Console input buffer size" default 2048 if ARCH_TEGRA || ARCH_VERSAL || ARCH_ZYNQ || ARCH_ZYNQMP || \ From patchwork Wed Feb 4 00:09:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1796 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163825; bh=ukR0qkx8LCGYWxtJnhrsBFEUKCqqlCQyriSLCEL6H34=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=w1zkE5Yf+8IACeTp59A0s+BR7XD5SL0ZsimQr8WFuKKTV8yz0Bu3G8ElafW3p/n3R Od2OMwGBNty5pePJTGX8Uls8VLF8DhlbpniRvQx7mWCduAboj0XbE6xLY0AIGNs3UX 4dUVNlqUDdK6eeyVwJj+OkAEz+P44yHQ+fbFHRKFxqW4PrngbisEWJdM9ALYXxwDK1 /3/il2Pnb1q6hOo0GupNa55tH3yxJbgOJU2SZcXohJpGszJdW5UGQSsIIy3wACmKhd q6+9OPR4KrSnb96CUb7oNxnwUkR97lequrVbSHGN6oRBhwmkuBb1hde3vS+vFSmOpC 5j/xBEd4LqXnw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3ACA69917 for ; Tue, 3 Feb 2026 17:10:25 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2ET8VW-KrQFJ for ; Tue, 3 Feb 2026 17:10:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163825; bh=ukR0qkx8LCGYWxtJnhrsBFEUKCqqlCQyriSLCEL6H34=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=w1zkE5Yf+8IACeTp59A0s+BR7XD5SL0ZsimQr8WFuKKTV8yz0Bu3G8ElafW3p/n3R Od2OMwGBNty5pePJTGX8Uls8VLF8DhlbpniRvQx7mWCduAboj0XbE6xLY0AIGNs3UX 4dUVNlqUDdK6eeyVwJj+OkAEz+P44yHQ+fbFHRKFxqW4PrngbisEWJdM9ALYXxwDK1 /3/il2Pnb1q6hOo0GupNa55tH3yxJbgOJU2SZcXohJpGszJdW5UGQSsIIy3wACmKhd q6+9OPR4KrSnb96CUb7oNxnwUkR97lequrVbSHGN6oRBhwmkuBb1hde3vS+vFSmOpC 5j/xBEd4LqXnw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D245569911 for ; Tue, 3 Feb 2026 17:10:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163825; bh=85vKIurHozCxZ+huyQ4eyfLMpf6ltggeL1WnouRTWDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHFVn/xdOZOEO9eQn8FuTOCRJ4bD1qM/Us1CBxL5foc51jEPCWMcF8UkVdtt0J0Yu aorY6b1gTWGCUbvQxJQumI5ToHpVExaO9xujvvb43SlhE5pTXEUuun3ffzHJu0Uhwv EoXKRiSjYGNF37WeNrhxnai3FY/LU/feM9BF2HvizxxWCjPoXOGph7kcPchV6yrDbE j+JfCnhb3bhUjDJvyB4xsSqlQXasvLa5g9HnSbMRHQGM6o5rZwyF0rDiw1BKK1zmPO SKZkiAuUHCZAY0sVNBbY8vNQT7mbk8i1pWfRC91Nj4r01i1zqMXA+htnmt19LG5EKS +A8rfWddf1Nyg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 09DA469868; Tue, 3 Feb 2026 17:10:25 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id K1CUcWwqGTty; Tue, 3 Feb 2026 17:10:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163820; bh=igHR0s76RuhOd/W+MqK3ytzOlHbqAe4sb0CxfZtb9Uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r9lYwDG6S/vVqWyXbF/xFEm40siFaCNX55dMYJU10bn486nIvwZCYupsn/uTCI7rA l94kjtLHxTzr7ZfLC5RJ1bE2+/WlRTPmVKHGp7+ayKXp8JqGoGbfyW46oU3n44WwYA GP77Rk6Pl370AVIcYRlJ1VAtq9I/PQm9QedPHBZhZAaXrVwtdGWyNsBdjvPHKShC3i rWt+rf0F55DdZflfnOtALcTk2/EwwZFmSHMgb87OrILlQF+Lyvl3a3DWwsmdZXkEKH mjQTEWTQWzMTvix3XOpFCQxQxukJHlb5Gn9dB2Qo80rTxHf77rnAMXFI6V2adx2495 ZQtixLoywyumQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A714169909; Tue, 3 Feb 2026 17:10:20 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:46 -0700 Message-ID: <20260204001002.2638622-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QDGQ752NEONISGX2CBVNIHYL2BT6PMQW X-Message-ID-Hash: QDGQ752NEONISGX2CBVNIHYL2BT6PMQW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/13] serial: Support length-based serial output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add serial_putsn() to output a string with a specified length through the serial port. The serial uclass already supports length-based writes via __serial_puts(), so this just provides a public wrapper function. Add a test to check it. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- drivers/serial/serial-uclass.c | 34 ++++++++++++++++++++++++++++++++++ include/serial.h | 12 ++++++++++++ test/dm/serial.c | 20 ++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 8d330d687a3..93fb4a0c2e3 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -309,6 +309,34 @@ static void _serial_puts(struct udevice *dev, const char *str) } while (*str); } +static void _serial_putsn(struct udevice *dev, const char *str, size_t len) +{ + struct dm_serial_ops *ops = serial_get_ops(dev); + + if (!CONFIG_IS_ENABLED(SERIAL_PUTS) || !ops->puts) { + while (len--) + _serial_putc(dev, *str++); + return; + } + + while (len) { + const char *newline = memchr(str, '\n', len); + size_t seg_len = newline ? newline - str : len; + + if (__serial_puts(dev, str, seg_len)) + return; + + if (newline && __serial_puts(dev, "\r\n", 2)) + return; + + if (IS_ENABLED(CONFIG_CONSOLE_FLUSH_ON_NEWLINE) && newline) + _serial_flush(dev); + + str += seg_len + !!newline; + len -= seg_len + !!newline; + } +} + static int __serial_getc(struct udevice *dev) { struct dm_serial_ops *ops = serial_get_ops(dev); @@ -391,6 +419,12 @@ void serial_puts(const char *str) _serial_puts(gd->cur_serial_dev, str); } +void serial_putsn(const char *str, int len) +{ + if (gd->cur_serial_dev) + _serial_putsn(gd->cur_serial_dev, str, len); +} + #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT void serial_flush(void) { diff --git a/include/serial.h b/include/serial.h index 51977d8d7b7..66bf17a7cc0 100644 --- a/include/serial.h +++ b/include/serial.h @@ -392,6 +392,18 @@ void serial_setbrg(void); void serial_putc(const char ch); void serial_putc_raw(const char ch); void serial_puts(const char *str); + +/** + * serial_putsn() - Write a string with specified length to the serial console + * + * This outputs exactly @len characters from @str, regardless of any nul + * characters that may be present. This is useful for printing substrings or + * binary data that may contain embedded nuls. + * + * @str: String to output (need not be nul-terminated) + * @len: Number of characters to output + */ +void serial_putsn(const char *str, int len); #if defined(CONFIG_CONSOLE_FLUSH_SUPPORT) && CONFIG_IS_ENABLED(DM_SERIAL) void serial_flush(void); #else diff --git a/test/dm/serial.c b/test/dm/serial.c index 4acb14f41bc..8ed18726dd7 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -88,3 +88,23 @@ static int dm_test_serial(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_serial, UTF_SCAN_FDT); + +/* Test serial_putsn() function */ +static int dm_test_serial_putsn(struct unit_test_state *uts) +{ + const char *test_str = "testing string"; + size_t test_len = 4; + size_t start, written; + + /* Test that serial_putsn() writes the correct number of characters */ + sandbox_serial_endisable(false); + start = sandbox_serial_written(); + serial_putsn(test_str, test_len); + sandbox_serial_endisable(true); + + written = sandbox_serial_written() - start; + ut_asserteq(test_len, written); + + return 0; +} +DM_TEST(dm_test_serial_putsn, UTF_SCAN_FDT); From patchwork Wed Feb 4 00:09:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1797 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163831; bh=eS5JbmmEuuJjNUM9mY7nYwRBnAFJFYEbhLOvafhy1vs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=vcxa8WPxMSzxC2KNgcBBBaozSN8UvtLs2DdYMyFUiiLQwW/+/326isAjcvTLbjAtm MnGr0fw/9+99bEzxpQKhQBFlaA7/7H0ZkE8d2IzgtX8gVy8a9Os6tqx6l6tj5ET8de TsOFVak9mKsrj433e0U8zqrHZkubKM+ECl3rWr5hHdT6EIKrTW7BQhZCv0iKHI/mVK kGUH9Ok1pKqcCuyBjVCEsUQTml3xtxi3yHbFRjfD71f4OrTGwPXYK5lwhEMXNaoXbK GEGswBkYJGeO/nU52WdhAZJhPRX90KWRlCXdmVFRvEkeC1GsixlCXhzpQezOFL6cbL /IbXt6BTTampg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC2276991C for ; Tue, 3 Feb 2026 17:10:31 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6QDyDHDRXjPm for ; Tue, 3 Feb 2026 17:10:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163831; bh=eS5JbmmEuuJjNUM9mY7nYwRBnAFJFYEbhLOvafhy1vs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=vcxa8WPxMSzxC2KNgcBBBaozSN8UvtLs2DdYMyFUiiLQwW/+/326isAjcvTLbjAtm MnGr0fw/9+99bEzxpQKhQBFlaA7/7H0ZkE8d2IzgtX8gVy8a9Os6tqx6l6tj5ET8de TsOFVak9mKsrj433e0U8zqrHZkubKM+ECl3rWr5hHdT6EIKrTW7BQhZCv0iKHI/mVK kGUH9Ok1pKqcCuyBjVCEsUQTml3xtxi3yHbFRjfD71f4OrTGwPXYK5lwhEMXNaoXbK GEGswBkYJGeO/nU52WdhAZJhPRX90KWRlCXdmVFRvEkeC1GsixlCXhzpQezOFL6cbL /IbXt6BTTampg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BBDF369911 for ; Tue, 3 Feb 2026 17:10:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163829; bh=weWBGBOUleNlM23R4zAHTj9CEuUd6GK7JlrXXdhz6pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jg8UDnMVEw2XuTJGsIyan/5PzPG1Fh/g1vxbGnUWTg932yZtpKYvAfRvf2WcV5L4i tOFh1TmZ6vT7F/0p/BPlYzN6CsGuQd66Pghm3pob2XYIR7VxH4e09RoekjWPkxZpa+ gTW//nAsSjIfw6+1RodrhV5TB1kPGqhRsltErxI3h+93xxfioMTQtCjnvvIv5OKZT0 sPahhWoV9qbwaSkoR6sMXVR59UCOJBlslPbRyQvvvcjd4VADlGEFoKF1K8nwj5MVsQ u6uGkebLx9pfOINuLKvZ+aIlB2t46k6BpFnb4xQgV8eMNue3/jcpdJ9wHGxhFuPgyL XJlVvpJnA7wbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93F2C69868; Tue, 3 Feb 2026 17:10:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id escAFRaM8nbo; Tue, 3 Feb 2026 17:10:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163825; bh=gRdQHD+TRJVOT6p8ydWZG3Ov/qCaRXLwBAX/2uPesyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dicbreWjm+GZ868ZqJ/jEz6CER6snGjNSNmEIb0Z62IXwVrKBNQxctwvDkxntfA47 s8iZHTJbT3NOe0vGvul1iByKyrVGK+qjREFdrYi146MvYA9sjE1USNXmorrVnu/u+1 0BLRLEtUwfCfja4GBYQhycWQke4R85utqeyCypybRdN1T/6c8iWd6k9CetFvbQS8w1 106mfWkPFSlQ024GuqGp7QCxVsRnhFN4QT38r5XsumhowNABtdXd39EzW4102B4LLm 8lekeMl6y7+bRkIEc+pURnWXCk0XEgsz1SqKh7rFVPXyOCDKCMVUQqQrqWRZ0pJ4ys 7qeQB4uxaf8bg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4A58669909; Tue, 3 Feb 2026 17:10:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:47 -0700 Message-ID: <20260204001002.2638622-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5ASO3NIGZFK7SN3L56BC3XFDKQIWSNJF X-Message-ID-Hash: 5ASO3NIGZFK7SN3L56BC3XFDKQIWSNJF X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/13] console: Add length-based console-recording support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Console recording uses membuf_put() which already supports length-based writes. Add console_record_putsn() to accept a length parameter directly instead of calling strlen() internally. Refactor console_record_puts() to use console_record_putsn() to reduce code duplication. Since console recording is a size-increasing feature for testing, this refactoring is appropriate. This provides the foundation for a public putsn() API that can output strings without requiring nul-termination. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/console.c b/common/console.c index 6ce2c4d361d..581c383ce5e 100644 --- a/common/console.c +++ b/common/console.c @@ -43,12 +43,11 @@ static void console_record_putc(const char c) } } -static void console_record_puts(const char *s) +static void console_record_putsn(const char *s, int len) { if (!(gd->flags & GD_FLG_RECORD)) return; if (gd->console_out.start) { - int len = strlen(s); int written; written = membuf_put((struct membuf *)&gd->console_out, s, len); @@ -59,6 +58,11 @@ static void console_record_puts(const char *s) } } +static void console_record_puts(const char *s) +{ + console_record_putsn(s, strlen(s)); +} + static int console_record_getc(void) { if (!(gd->flags & GD_FLG_RECORD)) @@ -84,6 +88,10 @@ static void console_record_putc(char c) { } +static void __maybe_unused console_record_putsn(const char *s, int len) +{ +} + static void console_record_puts(const char *s) { } From patchwork Wed Feb 4 00:09:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1798 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163835; bh=86Ov3Ls5sILHyaMzGy82+z4sWzfc5OPhkLnd6owaoJk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nsbB/RGZ1yEIPsoxleVhoujitjc2evRjPiztELr47NIsoohTNDFCD7H7hX4DSQJ9g OopN9coFXqFGxCKqDdZEKqfap/SNrc9iO8gxZ6zf3NzlkARtUSWyZ4ElJVfzBGPP/Y xDLlo9BaDPYcpz/b/STvjxmamIlweBtHyqC39kL7NEvlkQrMNR1wiKDNIkNPC1kh27 se7eKR1dqcX0X04kwJzojh2z6cZ1Bi0MGtkZIgO5Tv5/VTJwSRIKr/WVmEC0EyW3Dm B30TFXXOae4Dro1Ocl6YRqf1dDczhpSDOlIDwdZdocWIdamWSpd68wviMzK6oWBUF7 m6wltqfhecJ3g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52EBC69868 for ; Tue, 3 Feb 2026 17:10:35 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id w_LpZLPjKEW8 for ; Tue, 3 Feb 2026 17:10:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163835; bh=86Ov3Ls5sILHyaMzGy82+z4sWzfc5OPhkLnd6owaoJk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nsbB/RGZ1yEIPsoxleVhoujitjc2evRjPiztELr47NIsoohTNDFCD7H7hX4DSQJ9g OopN9coFXqFGxCKqDdZEKqfap/SNrc9iO8gxZ6zf3NzlkARtUSWyZ4ElJVfzBGPP/Y xDLlo9BaDPYcpz/b/STvjxmamIlweBtHyqC39kL7NEvlkQrMNR1wiKDNIkNPC1kh27 se7eKR1dqcX0X04kwJzojh2z6cZ1Bi0MGtkZIgO5Tv5/VTJwSRIKr/WVmEC0EyW3Dm B30TFXXOae4Dro1Ocl6YRqf1dDczhpSDOlIDwdZdocWIdamWSpd68wviMzK6oWBUF7 m6wltqfhecJ3g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 42A0E69911 for ; Tue, 3 Feb 2026 17:10:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163834; bh=HRi398B+O1oDX5Du6zg6On9cD/sQotRot3aR0XU+5dE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1/Kxzvg9phTqj6fvi6gW7q5jvx1HMjCcfpA7414hzqlVCP9JCOd7Z+vNvXRKfOzh KVMoP4cX9fJbKotAE07zlSCpSnWcGohukVuz0mtZte3tCVud+aeqV5g8VJD6ilpK6N 7j/1qEPFv15wiqJ3lFBS7uD7yk4YRJizmmP3y5BlSEqIqb/08oJGgnXb4g5jhHJr2h OdhrSmTQlQMUao32TGuF926pflmNCFpTHWR9G7raZlKKxBDs5bgK7AT6mCaDLeCTxy 5GZr+seLL+T9RFdAZxLc2oOHFrZV/FFq2/+pKBSfBScILYOoXjB2DTe2ycb/k13m4p 6klXsQWuduxZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3659369868; Tue, 3 Feb 2026 17:10:34 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 9scKOpxsls9W; Tue, 3 Feb 2026 17:10:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163830; bh=o4whZ2pasVa42R1IBFHIlLSanGLdBiLUUJM2Ma/IbHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=veKGmA609OzWoj3QRFTC3ez+jgFWwiwZrb5QCcBRlvnGn8425uXBGXeNgGmnJ4pZL MSKRAnXZFDiUwHwnoo8VFfMpa5Noig6u9D44Y+SzwqDq6trSqlGixXbI2runyyii8G S8Se4/uXkKD2KAwyo7aOY3UySO1zf7St6ohU/VM+/2hXDMCooMi/ED8HFYdQA1jdiW Jkk25IycmLmL/0sXM32PV9sqm2PRHiyfhrtvk7tBf2ToLnsQlJ+sY0T/ZuOrOU11YH 0EiEc/tEFu6pSA+BSyTKcjWGSrF3af6sBIKDKaVkRNnxWz+yl9YEhzBan3RlfkGZJ8 Yy+yvivKdW1fA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D7AD069909; Tue, 3 Feb 2026 17:10:29 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:48 -0700 Message-ID: <20260204001002.2638622-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YPQWCV373EEOZU46XB6EWKH4GPKQ27XW X-Message-ID-Hash: YPQWCV373EEOZU46XB6EWKH4GPKQ27XW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/13] console: Add length-based pre-console support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add pre_console_putsn() for length-based output to the pre-console buffer. This allows putsn() to work correctly before the console is fully initialised. Refactor pre_console_puts() to use pre_console_putsn() to reduce code duplication. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/console.c b/common/console.c index 581c383ce5e..c058d3d30a2 100644 --- a/common/console.c +++ b/common/console.c @@ -721,15 +721,20 @@ static void pre_console_putc(const char c) unmap_sysmem(buffer); } -static void pre_console_puts(const char *s) +static void pre_console_putsn(const char *s, int len) { if (gd->precon_buf_idx < 0) return; - while (*s) + while (len--) pre_console_putc(*s++); } +static void pre_console_puts(const char *s) +{ + pre_console_putsn(s, strlen(s)); +} + static void print_pre_console_buffer(int flushpoint) { long in = 0, out = 0; @@ -762,6 +767,7 @@ static void print_pre_console_buffer(int flushpoint) } #else static inline void pre_console_putc(const char c) {} +static inline void pre_console_putsn(const char *s, int len) {} static inline void pre_console_puts(const char *s) {} static inline void print_pre_console_buffer(int flushpoint) {} #endif From patchwork Wed Feb 4 00:09:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1799 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163840; bh=A6d84HkspN98cFas0psCk5wDyCNIdFmusCioXslfW+U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=tBKMijflM+kDAVqePZxrbGnYa8m/elZG+MOEn63f5/8uV7MGn7Ak+BiUUEQQjpvlB Eah+JxXRP5VMaXUpISvz6RLAhD18qpix+qGFWRHBuYwTDL5flnvyCFcGURVsErkmY6 DAeKYmppCGRnU79pZlAFOnIAig7AoFCQ0MH+DXW21Mp/h3szNohO2zSp4uvj5wEpUj lLvZJ31VYSx/ERzac0tsphvPfwUr0oXA+6BwtasnpfPbD9RsVNX6Tgl6/ZgwFaMaHM TiS61poy2YTgnIwK44h/BNWadaHR7wXWQ0KT95GiNWGAmdjjADth9W06YzmHUgiQyb MTglz8NjLc9bQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C460569868 for ; Tue, 3 Feb 2026 17:10:40 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GIrVCso-sMJk for ; Tue, 3 Feb 2026 17:10:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163840; bh=A6d84HkspN98cFas0psCk5wDyCNIdFmusCioXslfW+U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=tBKMijflM+kDAVqePZxrbGnYa8m/elZG+MOEn63f5/8uV7MGn7Ak+BiUUEQQjpvlB Eah+JxXRP5VMaXUpISvz6RLAhD18qpix+qGFWRHBuYwTDL5flnvyCFcGURVsErkmY6 DAeKYmppCGRnU79pZlAFOnIAig7AoFCQ0MH+DXW21Mp/h3szNohO2zSp4uvj5wEpUj lLvZJ31VYSx/ERzac0tsphvPfwUr0oXA+6BwtasnpfPbD9RsVNX6Tgl6/ZgwFaMaHM TiS61poy2YTgnIwK44h/BNWadaHR7wXWQ0KT95GiNWGAmdjjADth9W06YzmHUgiQyb MTglz8NjLc9bQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0EBA69911 for ; Tue, 3 Feb 2026 17:10:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163838; bh=EZUXQmS8heLiCSicHxBfKo3xzX2qNEuKzMHjom3+Me4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vpJVkpbFyeOVzo5HjisSac1krA0SoU6PXAjL/ytZv5at7SjYiXOhpvLSmtEb+hWSi 4qkF8EnOMT4Ndszk1yn2f4z0MLe/TOU2AecW37oonBFRtMnzva0jo23HRgOd91yRR9 cSGeQW0WZ3VuBLcgfXj7I0eXRJsoMAwZUziBMSE2a7eOsrHaGDjNzbgGqsnlbUx+wn Pl9VxHplZdy9k+/exa8gSV5phTf+R2reSYjPlPVDmISDf25BjwqPgE2jMsSjl7/fNr Pkpig5EO8O4jIz8RjjzpGamtbLfW9t1EyI/xsGNPbGKa66OWlBQhuQyfQRZQ43xG1r zbcxrrU1MEldw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B867969868; Tue, 3 Feb 2026 17:10:38 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id axIwJHSEVr2w; Tue, 3 Feb 2026 17:10:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163834; bh=Ml180oVneysOP/IJ1Ydf5bawhWtvUfkt7eeL2Te7vZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0Mvn0W9zMZ6Yk3g8XGIUVglEodrQvtrFgJlbBCXf5HvTpBToO2FNTWHzDfapPhIB oeI94vfsRS9Ugpktkxmy0tSqK4qF+mdF47R9LDcq24aOhuEkzoD0Ja4y991+JjKmRe RB0nNCbMI3KXvb5xdJll1I9r3KN4MDyT1XfEFitbJNFhtvfBaZAvGXmvpN/bsGbRGe iawUfJfi9fk/t52hIns2iq5ndZTlbMsqjg9Tf4MzNl29eXTosLG0UegtMIk9itxXOa /QLA4MVsrrih2AMzKFX8U6ExjbIRj9bYrs82QZ82htv5g8WN3MBw+mhoyjRVqdRB0O k6O1HfbdJ9U2A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6F62A69909; Tue, 3 Feb 2026 17:10:34 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:49 -0700 Message-ID: <20260204001002.2638622-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HJ4J2BGQ5JTV4ESXMBVORFMUCAPVJYA6 X-Message-ID-Hash: HJ4J2BGQ5JTV4ESXMBVORFMUCAPVJYA6 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/13] console: Add length-based debug UART support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 Signed-off-by: Simon Glass --- include/debug_uart.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) \ { \ From patchwork Wed Feb 4 00:09:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1800 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163844; bh=zRUwA0X1RjOYJgbwmctfRMSSRzyFEEtiVrvWbG+EQkQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NS09OD0tGsMWPLIimEHFM+OjzflpvfsKoUwjGQgFMnTXnGYQqi+wAxFJ+oe+J0X4v 1BipQLOtkKqu+LoFJJya04Q1wWQCx6toYPbtP2By9RRtjiJ4/0J9sHYRDSi6vMod9k NLCgO2jIhsHVW/Px/IqTEhvOwW9KtCPgF6ELLGfsS1KKnzdpK5j9yTnKVM2g1oNr2w mU1Smb17DuVFuX1r6TGdsGAgarsI5hZlL0xbpDpU7x+rZXb37rOCuWqfafyR0KHttB kn9v/N6vxIeHRVcZbE+EZ/Vvh1I5/0oglwXor5EJALvnoKQHf1VJOX3XX23H+ALdnf OOXuLRU3j5qlA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C0A669868 for ; Tue, 3 Feb 2026 17:10:44 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id tbP_v_9BG8Rj for ; Tue, 3 Feb 2026 17:10:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163844; bh=zRUwA0X1RjOYJgbwmctfRMSSRzyFEEtiVrvWbG+EQkQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NS09OD0tGsMWPLIimEHFM+OjzflpvfsKoUwjGQgFMnTXnGYQqi+wAxFJ+oe+J0X4v 1BipQLOtkKqu+LoFJJya04Q1wWQCx6toYPbtP2By9RRtjiJ4/0J9sHYRDSi6vMod9k NLCgO2jIhsHVW/Px/IqTEhvOwW9KtCPgF6ELLGfsS1KKnzdpK5j9yTnKVM2g1oNr2w mU1Smb17DuVFuX1r6TGdsGAgarsI5hZlL0xbpDpU7x+rZXb37rOCuWqfafyR0KHttB kn9v/N6vxIeHRVcZbE+EZ/Vvh1I5/0oglwXor5EJALvnoKQHf1VJOX3XX23H+ALdnf OOXuLRU3j5qlA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41CD369911 for ; Tue, 3 Feb 2026 17:10:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163843; bh=0raAGp77Q+tVSk6xc7VaekH9BlDcHAVAKQON78AVCw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKS1aFdvv3Ci9PfsaudB1BFzNiVoOBmhp/Hk0FD7P5Zkyo1vPgB+02fxf4SXLRwj/ uv84VeiEjutAhfR5/WBPr6Tlt/V4rRI78Pr0x0zW5oGdQmp2v1SzCLgRuewDrr9HpF iBKEMiD78Pyxl5MxQnRM/dyHsqI8zqPB6zEG8AjSk/1qpEpg0CDs5vvqcQV5AalUFP G9lkngeZruQfGdvbGKQXl/6jgzd0NShzA0UxQG3e2srAJDohRDr4MAvFk8qUDIsijU y4GQGyakx7m8TRcop4Miii1a6EE+AEKlhKLHY014thmwD9aFEiCcOwlQtlzf8AT7GV 2V1sdwHOHIBtg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 56AC369868; Tue, 3 Feb 2026 17:10:43 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id jAL_y06-66dI; Tue, 3 Feb 2026 17:10:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163839; bh=t3KIvymdqfLBHVbuST7NVcebbnLrb7euSpfo8ew33FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SKmico2eOOdR8C8SvFYZRPym9gmfH5U2bA3Wg9M5EOZegy5Fl58TOfvjIEkD5Q1/j ZisSfl5ToYAay9AGw2c9bU+6tboWwxvndkbvrb+gKG36b8p4sleUjS7UODhTuah/Wa F3Ibo41DKO1Z+ga+r5oycC38cfjLCQkLIw54uHk2U4UCeCR73pY2ZPCEafhjEFtVFL PQm4Y/sNkEJfyXbBCijOvRXFvmB2NyvAOHu6jGFaFMvoLif+SfBwqhCYj89XhE2z+2 pw/GMvA6dDJbDjQJTE6A1sSo7UJ7UtlMGX99ZRshDYPmAiKw8qTchLYQb7T5eR7GUS 3XED4O1ruAdWA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 05E5769909; Tue, 3 Feb 2026 17:10:38 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:50 -0700 Message-ID: <20260204001002.2638622-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XGT6LVNLQTR5P2WUA35ORTUR7QYB7N3Z X-Message-ID-Hash: XGT6LVNLQTR5P2WUA35ORTUR7QYB7N3Z X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/13] sandbox: Add support for length-based console output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add os_putsn() to support length-based output in sandbox environments. This allows putsn() to work correctly before the serial console is initialised. The implementation uses os_write() directly for efficiency, and os_puts() is refactored to use os_putsn() to reduce code duplication. Note this changes sandbox to write all characters in one call. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 8 ++++++-- include/os.h | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5278ce55766..142b685e031 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -827,10 +827,14 @@ void os_putc(int ch) os_write(1, &ch, 1); } +void os_putsn(const char *str, int len) +{ + os_write(1, str, len); +} + void os_puts(const char *str) { - while (*str) - os_putc(*str++); + os_putsn(str, strlen(str)); } void os_flush(void) diff --git a/include/os.h b/include/os.h index 3ea88230af3..bc556f2195f 100644 --- a/include/os.h +++ b/include/os.h @@ -385,6 +385,19 @@ void os_putc(int ch); */ void os_puts(const char *str); +/** + * os_putsn() - write a string with length to controlling OS terminal + * + * This bypasses the U-Boot console support and writes directly to the OS + * stdout file descriptor. + * + * Outputs exactly @len characters from @str, regardless of any nul characters. + * + * @str: String to write (need not be nul-terminated) + * @len: Number of characters to write + */ +void os_putsn(const char *str, int len); + /** * os_flush() - flush controlling OS terminal * From patchwork Wed Feb 4 00:09:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1801 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163849; bh=nl1EVOwRNOainkezL8nCQo3gxj8wagoWVXPf0LzKDnM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=txvMLlDkGvvkC9hKKDmaIz8yM6S3VOFUgmQ9KCKi2G4indUJZ3TPreWPnxIhW69HA YLorvXNL3f9SNwQk7g7YPA9YPfW0YhLC509lSENDeHvCeisgY4fV/+09K55Alq4a4a LwGeqB5du1136cKeqcq1q7B7TPg54sGnNpoztTcRl2R6OYnOi91TDJ6yTTzE9r1VAO EpsxwUfX0dGeITx2HV/c8STqmgVPwwsgtXiKFeYGDLoPGM7BNS6UtHUDDUey/ZEcUu 5WNXKaxVZUEbo4zAj5aaa1sxxo6YYYQ0wHmh7rdjIo/q7tQFCIUPvsTokWESQbD73b FiA+GA12TXOtQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4CD4669917 for ; Tue, 3 Feb 2026 17:10:49 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id C1SaPqV4W1na for ; Tue, 3 Feb 2026 17:10:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163849; bh=nl1EVOwRNOainkezL8nCQo3gxj8wagoWVXPf0LzKDnM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=txvMLlDkGvvkC9hKKDmaIz8yM6S3VOFUgmQ9KCKi2G4indUJZ3TPreWPnxIhW69HA YLorvXNL3f9SNwQk7g7YPA9YPfW0YhLC509lSENDeHvCeisgY4fV/+09K55Alq4a4a LwGeqB5du1136cKeqcq1q7B7TPg54sGnNpoztTcRl2R6OYnOi91TDJ6yTTzE9r1VAO EpsxwUfX0dGeITx2HV/c8STqmgVPwwsgtXiKFeYGDLoPGM7BNS6UtHUDDUey/ZEcUu 5WNXKaxVZUEbo4zAj5aaa1sxxo6YYYQ0wHmh7rdjIo/q7tQFCIUPvsTokWESQbD73b FiA+GA12TXOtQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C80F69911 for ; Tue, 3 Feb 2026 17:10:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163847; bh=1YIr9NOKjk/SNQyVy344bcXA2m3rRPxdaox0rkF+azM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcEsvv4I9Mo58DZHj1SjNNE4WcoPyFk87fnbeRO+4TtTJUGA0JZBjQToraAIfKp4a L3fVgCWsHt24yqMGqmq+GrFQSqrwSTze541WEUkw/QGRGai5DGWm3Jlv6Xrcm+C874 5Fx8VuPxUrJHN4MQGlY6kldUCTgiVplXLs4LRhVcYh1U+IMCaWWh/MejK+nXYjl2ja KZ5IiroUT+Q+q2Nno38XzyVJl6RTR7w4FInkqqH7pKKwiDCZOwJ/SSCKlCtgNQKrDL gBGiCmL48Ev8VVDYcYYgYFzmvz6qzg2dDe+yjT0kzz98xJj2znm/gHDOQmTr/NLk1a 23Mb9suri4JTQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F1ADA69868; Tue, 3 Feb 2026 17:10:47 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id XsZq9bbZZYnn; Tue, 3 Feb 2026 17:10:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163843; bh=SNmoxeeO0L8g8irBpxz7gGV0ldjNlhPUflESnhfaPKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Le0sGfXdOTKF0S8N350WLi5gUqiTjpJi4ju8RFAw/+kvXKuTZWF1XWKsIBCEOBTVe lJNBhIaF8KSaz3V8X2UwUGPTPlOTd7ojsPBUPS0G2M632CmisNLyLtYLNddn9PRJ7S NsLgfi0DDivbIoyXdeWz/hRhTLkIMjUjPVi3CUdOBqULhbTPGZGZ/qllnNlT6oTtXt kNBeL8oBBHBG4/O6q9QAnqOlZ0MlFA/9eBjfcfQppXTbUn3q7fbPv+gKw5RLX+LvKk AYeLp4+uznorFtg+Hti70puOplMHf5OwPs1QKIVdpZq5A2Iv1YbZAEmsHUtQpfoHtf BMy3pybwOuCIg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 956C469909; Tue, 3 Feb 2026 17:10:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:51 -0700 Message-ID: <20260204001002.2638622-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IPWR6TRYFSJIXHYIIOENMN4AQIZUGSFP X-Message-ID-Hash: IPWR6TRYFSJIXHYIIOENMN4AQIZUGSFP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/13] console: Add putsn() support to struct stdio_dev List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add an optional putsn() method to struct stdio_dev to allow devices to provide optimised length-based output. The field is added unconditionally but only used when CONFIG_CONSOLE_PUTSN is enabled. Add console_putsn_pager() and fputsn() to route length-based output through console devices. If a device provides a putsn method, it is used; otherwise, the output falls back to calling putc in a loop. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 31 ++++++++++++++++++++++++------- include/stdio_dev.h | 12 ++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/common/console.c b/common/console.c index c058d3d30a2..67d87c6edfa 100644 --- a/common/console.c +++ b/common/console.c @@ -271,6 +271,7 @@ static int console_tstc(int file) } static void console_puts_pager(int file, const char *s); +static void console_putsn_pager(int file, const char *s, int len); static void console_putc_pager(int file, const char c) { @@ -355,18 +356,28 @@ static void console_puts(int file, bool use_pager, const char *s) } } +static void console_putsn_pager(int file, const char *s, int len) +{ + struct stdio_dev *dev; + int i; + + for_each_console_dev(i, file, dev) { + if (dev->putsn) + dev->putsn(dev, s, len); + else if (dev->puts) + dev->puts(dev, s); + else + while (len--) + dev->putc(dev, *s++); + } +} + static void console_puts_pager(int file, const char *s) { if (IS_ENABLED(CONFIG_CONSOLE_PAGER) && gd_pager()) { console_puts(file, true, s); } else { - struct stdio_dev *dev; - int i; - - for_each_console_dev(i, file, dev) { - if (dev->puts != NULL) - dev->puts(dev, s); - } + console_putsn_pager(file, s, strlen(s)); } } @@ -629,6 +640,12 @@ void fputs(int file, const char *s) console_puts_pager(file, s); } +void fputsn(int file, const char *s, int len) +{ + if ((unsigned int)file < MAX_FILES) + console_putsn_pager(file, s, len); +} + #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT void fflush(int file) { diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 4e3c4708f80..2b2334c9918 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -38,6 +38,18 @@ struct stdio_dev { void (*putc)(struct stdio_dev *dev, const char c); /* To put a string (accelerator) */ void (*puts)(struct stdio_dev *dev, const char *s); + /** + * putsn() - Output a string with specified length + * + * This outputs exactly @len characters from @s, regardless of any nul + * characters that may be present. This is an optional accelerator - if + * NULL, the console will fall back to calling putc() in a loop. + * + * @dev: Device to output to + * @s: String to output (need not be nul-terminated) + * @len: Number of characters to output + */ + void (*putsn)(struct stdio_dev *dev, const char *s, int len); #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT /* To flush output queue */ void (*flush)(struct stdio_dev *dev); From patchwork Wed Feb 4 00:09:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1802 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163854; bh=L9XAAhPA/ft0NgJCGnytxhy31/V01a9XaLP5v6mGpRU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=d0vOEomemFWyeOZfKTA6qbdJdqW6m7JkXD5n7pr8tWshD4B9w1UtDg2AdU81ltRNP CrXDEeIoJCEgI9Nni388UmTlX0KjnmWO4EWnOpx7U8Xzh+LqYE7kHUvGq8c7uXLbCj ZiSp5tLs4QgToHHv9SsWuxOnAWD4BgTxTh0y234VE16kPQ0mf3dTHlNWjILXGtOe+x kkMt0KQyGRWO5IwGPSYdi0fKNDO0y62Pn8sePcaeMMPaqAzaogxFzymJ+3xcF8JBgv SfWijkTH+DKmodHA9t0dM9QTT8m2MLNHuInyXsnn6CJAWW3qOehQaKxHQcbzdUJUWO bQfnMWPmTr4Fg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B33D469917 for ; Tue, 3 Feb 2026 17:10:54 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q-yV5eW3gEfh for ; Tue, 3 Feb 2026 17:10:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163854; bh=L9XAAhPA/ft0NgJCGnytxhy31/V01a9XaLP5v6mGpRU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=d0vOEomemFWyeOZfKTA6qbdJdqW6m7JkXD5n7pr8tWshD4B9w1UtDg2AdU81ltRNP CrXDEeIoJCEgI9Nni388UmTlX0KjnmWO4EWnOpx7U8Xzh+LqYE7kHUvGq8c7uXLbCj ZiSp5tLs4QgToHHv9SsWuxOnAWD4BgTxTh0y234VE16kPQ0mf3dTHlNWjILXGtOe+x kkMt0KQyGRWO5IwGPSYdi0fKNDO0y62Pn8sePcaeMMPaqAzaogxFzymJ+3xcF8JBgv SfWijkTH+DKmodHA9t0dM9QTT8m2MLNHuInyXsnn6CJAWW3qOehQaKxHQcbzdUJUWO bQfnMWPmTr4Fg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A2B3269911 for ; Tue, 3 Feb 2026 17:10:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163852; bh=s1WbtGI2CIjTbMOXS/aS1UqOH+xkHsWnvGrc4Xu5v8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYzv6F5G6fCSFBEgmixyGPr1u+s8czuynop/wThOMJzF4G3BJngM6CUGVAcf111LH AJIlbm3O8anJ/EIBf2KENBjhPDqZuiyzj8Ifsi3VoqCF6azEd1LTPzCb1cvCtfQv+Z 5SueOdHYQdbYsVMdcjqBBQ2l181tHJxjNg9CUikCj32uIr5Raa8Qg8BisFbhMLZVim sinE0ji2/IBk2jUYon1oR6UyLjKoKd+ArmDqE8anHgHfzMPpesd0EIXPMcV06hVnHd ZIKFdtaQhuxliZ9bd+McdUKPXi+HfzBnLJDXlM5O+cfa5NGfS+icXEd3yEJJDmMTBy mmsQCBwsZRHQQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A44169868; Tue, 3 Feb 2026 17:10:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id kg2hPX45g8Z4; Tue, 3 Feb 2026 17:10:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163848; bh=hUYDnevpKx5sVKHtD8XMpzl8p3G7yvGGvqnQnLpLizU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wxJRz4/6vOrcgT9bwZsxO/V6N0b8djNCYpdZPN1+auNwQ48W3Hb9c1hh3mWVG9ShV u4PKaPtPfxJxeYcvZ1XvgCOsH8ovNcXUjMSP9kZG9Lkv/W48jP3KrXyG+A4YYpparp 5dO2s+e3pBADh7/mwMN/+2P5WCpKBBk4KFdRL1/T1WYibpXxW224bm5XXwI+CScyrD UMeg8CyocbkGb33IQi8J5kjv/E/2e/JRezCBxXhj1NzYz988caRu7flgN0ZMLMk8Vr x354tiwKeIVS4zNbKudAEob5WrkHyWaqHyKNFu2UTVmVelHfZXVMOGRmK4oMaSbS14 T/NWmAKGkauZg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3F4F569909; Tue, 3 Feb 2026 17:10:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:52 -0700 Message-ID: <20260204001002.2638622-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IFOKOFEIEBPKJG2GR2J5M7GCH6SLAQVS X-Message-ID-Hash: IFOKOFEIEBPKJG2GR2J5M7GCH6SLAQVS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/13] console: Add vidconsole support for length-based output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add putsn() support to the video console driver to enable efficient rendering of length-specified strings. The vidconsole infrastructure already supports length-based operations through vidconsole_put_stringn(), so this just adds the stdio_dev wrapper. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index d13b4eac272..3d440e8e672 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -589,7 +589,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) } } -static void vidconsole_puts(struct stdio_dev *sdev, const char *s) +static void vidconsole_putsn(struct stdio_dev *sdev, const char *s, int len) { struct udevice *dev = sdev->priv; struct vidconsole_priv *priv = dev_get_uclass_priv(dev); @@ -597,12 +597,12 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) if (priv->quiet) return; - ret = vidconsole_put_string(dev, NULL, s); + ret = vidconsole_put_stringn(dev, NULL, s, len); if (ret) { #ifdef DEBUG char str[30]; - snprintf(str, sizeof(str), "[vc err: puts %d]", ret); + snprintf(str, sizeof(str), "[vc err: putsn %d]", ret); console_puts_select_stderr(true, str); #endif } @@ -614,6 +614,11 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) } } +static void vidconsole_puts(struct stdio_dev *sdev, const char *s) +{ + vidconsole_putsn(sdev, s, strlen(s)); +} + void vidconsole_list_fonts(struct udevice *dev) { struct vidfont_info info; @@ -950,6 +955,7 @@ static int vidconsole_post_probe(struct udevice *dev) sdev->flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_DM; sdev->putc = vidconsole_putc; sdev->puts = vidconsole_puts; + sdev->putsn = vidconsole_putsn; sdev->priv = dev; return stdio_register(sdev); From patchwork Wed Feb 4 00:09:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1803 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163859; bh=LHxasfJxVobFul6aEI5tLMdqvbbojYjPmf8Rv7WD7Rw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lKyfOJnanfnWJux3opBHjQOokAbujsBDeuQNbyn1Mx+ilQ2DkAKf0FiAktMHlae4j qm+djoZqgHJ9kRkeiWB4AEqwCdURG3zjPPzCLIYCYqFh6IZWNR830vsgUROmwcWw3F CXf5G9YmW3kXEMi5hJFh0HWu1XzDaahRCUQ6K2kC8OpPBIU32ocMHc8QUmeFSnVJJR NkPZEWpAnC4lp0JGy0bNd8foWDAxWN/vp5O1KO4Cqa/ymt+KszLhgrr1zseeIjCw+K tq/l4Tt47Vmij3xiXEbx2wnHrXL/PKASAaG/ooI94jcSwvjD0ew2R/HSplkp6MRI+Z BB9LpkHcWzCrg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2985F69917 for ; Tue, 3 Feb 2026 17:10:59 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q-w-B9B5DnL5 for ; Tue, 3 Feb 2026 17:10:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163859; bh=LHxasfJxVobFul6aEI5tLMdqvbbojYjPmf8Rv7WD7Rw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lKyfOJnanfnWJux3opBHjQOokAbujsBDeuQNbyn1Mx+ilQ2DkAKf0FiAktMHlae4j qm+djoZqgHJ9kRkeiWB4AEqwCdURG3zjPPzCLIYCYqFh6IZWNR830vsgUROmwcWw3F CXf5G9YmW3kXEMi5hJFh0HWu1XzDaahRCUQ6K2kC8OpPBIU32ocMHc8QUmeFSnVJJR NkPZEWpAnC4lp0JGy0bNd8foWDAxWN/vp5O1KO4Cqa/ymt+KszLhgrr1zseeIjCw+K tq/l4Tt47Vmij3xiXEbx2wnHrXL/PKASAaG/ooI94jcSwvjD0ew2R/HSplkp6MRI+Z BB9LpkHcWzCrg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18C6469911 for ; Tue, 3 Feb 2026 17:10:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163857; bh=VZ32tMvsgfPD1lnkwIQX0D3zBHcePxKM2f5h32fu+CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tVlM9et3nAx1BLNj5wPgygftd35P6qeMjmTQKMehlpBmjtEzeNNOcAvDbn9q3AFgw a3TsmL63S+CVCmBJFY85jql1a2JRDaHbB24Td7RuvfjES8O95WgwsED/ysVLDH1Qad n0CY4637WbuyzNR5AyL8X5mmjUwdMtDLZWyT0fBIChw8sivIwXbIby1o2wq7y2XdFv 1+N3+ygQE8X841XGRR4vD8d9eop8qylVLpM7kpvfnVLGX9UPFoaXDjoEOxwQRHrXeW Bj+cg7ogss34nuydQtzSkBq32/5aFLZ/ereENCLWx65bOGfvs0eCk1EZNEXgQsO/3n OONElJsvu6oDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2AA0D69868; Tue, 3 Feb 2026 17:10:57 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id wjILhpyHNRZ2; Tue, 3 Feb 2026 17:10:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163853; bh=zLa8jJimBKgmn6FE0OCvOuwZPNGimwEmAKXe2XooFOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWUtMoR2pql+H+2dMJ6ktwZF4/BLLwFkgzc7y+uSU63cgycN0PI5qOUWEJP4qbhYd nxu2m94rjb2hAGJvnXzFu72+8HYzod40AhdBpdSEv38wgDDTYGhNcMFzE7kR2K8Crj xSHbcr06h+NZ2sTVRO8zrXM9uhGSM27okuxGkXjJ1G7Xf+mD++HsQI+lo6tuq4zrUq GBvUQzBCDPsKZu29pNhJ3wjvHrgTLNGObSFZRY/O+YkbiGFaboeRiCHSng1cKz1rOn Fbi+RMsRFRuJ5YqRKt7ikDQSMgXS9/ZYm6bJNv8oeFnWzrkIaToDe0f1WxuSGftUAa DhBV/mmRdPnTg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CFC0269909; Tue, 3 Feb 2026 17:10:52 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:53 -0700 Message-ID: <20260204001002.2638622-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6L6WW2SV4FPXDLV2LQUXFRDZVFUHQBSO X-Message-ID-Hash: 6L6WW2SV4FPXDLV2LQUXFRDZVFUHQBSO X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/13] console: Add the putsn() API for length-based string output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add putsn() function that outputs exactly a specified number of characters, regardless of any nul characters that may be present in the data. This is useful for printing substrings or binary data without allocating temporary buffers. The function follows the same routing logic as puts(), supporting all console modes (sandbox, debug UART, silent console, etc.). The underlying infrastructure already supports length-based operations, so this mainly adds the public API wrapper. The feature is controlled by CONFIG_CONSOLE_PUTSN. Example use cases: - Print a substring: putsn(str + offset, count) - Print binary data with embedded nuls: putsn(data, size) - Print fixed-width fields: putsn(field, width) Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 97 +++++++++++++++++++++++++++++++++++++------ include/stdio.h | 12 ++++++ test/common/console.c | 48 +++++++++++++++++++++ 3 files changed, 144 insertions(+), 13 deletions(-) diff --git a/common/console.c b/common/console.c index 67d87c6edfa..fbf2c875428 100644 --- a/common/console.c +++ b/common/console.c @@ -88,11 +88,11 @@ static void console_record_putc(char c) { } -static void __maybe_unused console_record_putsn(const char *s, int len) +static void console_record_puts(const char *s) { } -static void console_record_puts(const char *s) +static void console_record_putsn(const char *s, int len) { } @@ -358,17 +358,26 @@ static void console_puts(int file, bool use_pager, const char *s) static void console_putsn_pager(int file, const char *s, int len) { - struct stdio_dev *dev; - int i; + if (IS_ENABLED(CONFIG_CONSOLE_PAGER) && gd_pager()) { + /* + * Pager only works with nul-terminated strings, so output + * character by character for length-based strings + */ + while (len--) + console_putc_pager(file, *s++); + } else { + struct stdio_dev *dev; + int i; - for_each_console_dev(i, file, dev) { - if (dev->putsn) - dev->putsn(dev, s, len); - else if (dev->puts) - dev->puts(dev, s); - else - while (len--) - dev->putc(dev, *s++); + for_each_console_dev(i, file, dev) { + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN) && dev->putsn) + dev->putsn(dev, s, len); + else if (dev->puts) + dev->puts(dev, s); + else + while (len--) + dev->putc(dev, *s++); + } } } @@ -475,6 +484,17 @@ static inline void console_puts_pager(int file, const char *s) stdio_devices[file]->puts(stdio_devices[file], s); } +static inline void console_putsn_pager(int file, const char *s, int len) +{ + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN) && stdio_devices[file]->putsn) + stdio_devices[file]->putsn(stdio_devices[file], s, len); + else if (stdio_devices[file]->puts) + stdio_devices[file]->puts(stdio_devices[file], s); + else + while (len--) + stdio_devices[file]->putc(stdio_devices[file], *s++); +} + #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT static inline void console_flush(int file) { @@ -642,6 +662,9 @@ void fputs(int file, const char *s) void fputsn(int file, const char *s, int len) { + if (!CONFIG_IS_ENABLED(CONSOLE_PUTSN)) + return; + if ((unsigned int)file < MAX_FILES) console_putsn_pager(file, s, len); } @@ -784,8 +807,8 @@ static void print_pre_console_buffer(int flushpoint) } #else static inline void pre_console_putc(const char c) {} -static inline void pre_console_putsn(const char *s, int len) {} static inline void pre_console_puts(const char *s) {} +static inline void pre_console_putsn(const char *s, int len) {} static inline void print_pre_console_buffer(int flushpoint) {} #endif @@ -830,8 +853,56 @@ void putc(const char c) } } +void putsn(const char *s, int len) +{ + if (!CONFIG_IS_ENABLED(CONSOLE_PUTSN)) + return; + + if (!gd) + return; + + console_record_putsn(s, len); + + /* sandbox can send characters to stdout before it has a console */ + if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) { + os_putsn(s, len); + return; + } + + if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & GD_FLG_SERIAL_READY)) { + printasciin(s, len); + return; + } + + if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT)) { + if (!(gd->flags & GD_FLG_DEVINIT)) + pre_console_putsn(s, len); + return; + } + + if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE)) + return; + + if (!(gd->flags & GD_FLG_HAVE_CONSOLE)) + return pre_console_putsn(s, len); + + if (gd->flags & GD_FLG_DEVINIT) { + /* Send to the standard output */ + fputsn(stdout, s, len); + } else { + /* Send directly to the handler */ + pre_console_putsn(s, len); + serial_putsn(s, len); + } +} + void puts(const char *s) { + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN)) { + putsn(s, strlen(s)); + return; + } + if (!gd) return; diff --git a/include/stdio.h b/include/stdio.h index d42fdd2728c..802cedb8f24 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -12,6 +12,18 @@ int tstc(void); #if !defined(CONFIG_XPL_BUILD) || CONFIG_IS_ENABLED(SERIAL) void putc(const char c); void puts(const char *s); + +/** + * putsn() - Output a string with specified length + * + * This outputs exactly @len characters from @s, regardless of any nul + * characters that may be present. This is useful for printing substrings + * or binary data with embedded nuls without allocating temporary buffers. + * + * @s: String to output (need not be nul-terminated) + * @len: Number of characters to output + */ +void putsn(const char *s, int len); #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT void flush(void); #else diff --git a/test/common/console.c b/test/common/console.c index 5558343d45b..c2ff8210a43 100644 --- a/test/common/console.c +++ b/test/common/console.c @@ -206,3 +206,51 @@ static int console_test_calc_lines_serial_tty(struct unit_test_state *uts) return 0; } COMMON_TEST(console_test_calc_lines_serial_tty, 0); + +/* Test putsn() with basic string */ +static int console_test_putsn_basic(struct unit_test_state *uts) +{ + putsn("hello", 5); + ut_assertok(ut_check_console_line(uts, "hello")); + ut_assert_console_end(); + + return 0; +} +COMMON_TEST(console_test_putsn_basic, UTF_CONSOLE); + +/* Test putsn() with substring */ +static int console_test_putsn_substring(struct unit_test_state *uts) +{ + const char *str = "hello world"; + + putsn(str, 5); + ut_assertok(ut_check_console_line(uts, "hello")); + ut_assert_console_end(); + + return 0; +} +COMMON_TEST(console_test_putsn_substring, UTF_CONSOLE); + +/* Test putsn() with zero length */ +static int console_test_putsn_zero(struct unit_test_state *uts) +{ + putsn("test", 0); + ut_assert_console_end(); + + return 0; +} +COMMON_TEST(console_test_putsn_zero, UTF_CONSOLE); + +/* Test putsn() outputs exactly len characters */ +static int console_test_putsn_exact_len(struct unit_test_state *uts) +{ + const char *str = "hello world"; + + /* Output exactly 5 characters from a longer string */ + putsn(str, 5); + ut_assertok(ut_check_console_line(uts, "hello")); + ut_assert_console_end(); + + return 0; +} +COMMON_TEST(console_test_putsn_exact_len, UTF_CONSOLE); From patchwork Wed Feb 4 00:09:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1804 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163863; bh=XyH4atoaSyars/9TMhgPzDXshzHmK3u2GbyI3gZYRoM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uyqwK/CqDSE/dM2FDHzMgB9zH9rgyTMCs9H7om4ljFP0Lbzo/FScnvUsSnRxaaijO cYa3+4djf6qA/WVnbnWHnT7Gv3MVFma5Jis/p/4K1b+yi04j7JkcgC7YTW0bvksJc/ x/P9QGSpwe5gGRqn2tkJp8iX1EXac/x73TZrSPDUAGWDZT0y0n6Fe7YHhxUaqiBnak iGBe+eHXDbAnB8434QGE/7PUi487cLNs2DJopwIldjewq6N9lyCvxbuUucZrjl2eic 3Zn/iToebmnNXS0OKnDgnjJ0tfQof30/g/OPav98+xq14D9md5t7hsn35XpnARcTMo fb9aghYfVy/nA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9974A698FD for ; Tue, 3 Feb 2026 17:11:03 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2u2RDgTF_HxF for ; Tue, 3 Feb 2026 17:11:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163863; bh=XyH4atoaSyars/9TMhgPzDXshzHmK3u2GbyI3gZYRoM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uyqwK/CqDSE/dM2FDHzMgB9zH9rgyTMCs9H7om4ljFP0Lbzo/FScnvUsSnRxaaijO cYa3+4djf6qA/WVnbnWHnT7Gv3MVFma5Jis/p/4K1b+yi04j7JkcgC7YTW0bvksJc/ x/P9QGSpwe5gGRqn2tkJp8iX1EXac/x73TZrSPDUAGWDZT0y0n6Fe7YHhxUaqiBnak iGBe+eHXDbAnB8434QGE/7PUi487cLNs2DJopwIldjewq6N9lyCvxbuUucZrjl2eic 3Zn/iToebmnNXS0OKnDgnjJ0tfQof30/g/OPav98+xq14D9md5t7hsn35XpnARcTMo fb9aghYfVy/nA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8690769911 for ; Tue, 3 Feb 2026 17:11:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163861; bh=i0aXs2s517a07u6JF7Ko58sdUQt2FbYOqL8RnXNKE8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JO9DR/bxjVsq5scnVJFTDiioErw4oO21D+uO7yzXpqlIeJfE3KHhWZc8eppp93Y3P VD8hpzgKqfUc1rJ+fODg7CR7HuLKQ+Fc/FEkjTXLyBmbpjEwrBMBVOY/LYr9FpvP1j acrK7prL6zskeyKUNS45EA4PAcx1wbthBzB0zjB9MPNtOSaihEV4zNTSTDKtNUOhVM WMsSsldksx+vhymu6P/xxIEuewi6HzbYneEDAtdJMdVSEJeh/Hjvi8ac95RGLYvuIl LLjhYxqYsxkO880JriGuLdghrQKR4m/Uhk4qrlF7sT6yNkQzfZiJaP/AGeKsW9rp/x 47jgeUi3WBIIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D3A78698FD; Tue, 3 Feb 2026 17:11:01 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id sYiAHVhbSelN; Tue, 3 Feb 2026 17:11:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163857; bh=GRYNnLC42C0RcLAqittkwAOlCYjvjzryLV0qyRsmfqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MiilDDLzUOiW0bRcsMEgC29EaUaen29scqjD0ClNh1z6xfPP/DuoLlZ4dICYPl0hA Bg0n/yCRcW9eWI8z4w+TMk0f4XLorXbb8lx0ftijq9nPfvjQSA8rsNny3Cb55bikmw 2Op75MkRRHRP3MPs55mOIUsBeD3VYtxwuj+odZXELAtDSF/4SgCnCIHTCMhwGUKjOx C5bQaJCQTDK+OX+QdS7ctqxhp1ir/kJTJ7rrYhTGZewupGAnOymyYxVa7Yuxu76Ca7 gopwzb1Fb2iDXfw1LJFUmKx9UAQ19tGAu1Epz+MwnxUpa7g/ni4bacFiDXt/xeltII 1knw4UifGwmsg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6FAC069909; Tue, 3 Feb 2026 17:10:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:54 -0700 Message-ID: <20260204001002.2638622-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6VZSXLV7XAHSBLJDHJT455GK4WLIITYM X-Message-ID-Hash: 6VZSXLV7XAHSBLJDHJT455GK4WLIITYM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/13] console: Shorten the console-error-output function names List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The current names are quite verbose. Rename console_puts_select_stderr() to err_puts() and console_printf_select_stderr() to err_printf() Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 6 +++--- drivers/video/console_truetype.c | 6 ++---- drivers/video/vidconsole-uclass.c | 21 ++++++++++----------- include/console.h | 8 ++++---- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/common/console.c b/common/console.c index fbf2c875428..f9669a0e028 100644 --- a/common/console.c +++ b/common/console.c @@ -311,13 +311,13 @@ static void console_puts_select(int file, bool serial_only, const char *s) } } -void console_puts_select_stderr(bool serial_only, const char *s) +void err_puts(bool serial_only, const char *s) { if (gd->flags & GD_FLG_DEVINIT) console_puts_select(stderr, serial_only, s); } -int console_printf_select_stderr(bool serial_only, const char *fmt, ...) +int err_printf(bool serial_only, const char *fmt, ...) { char buf[CONFIG_SYS_PBSIZE]; va_list args; @@ -330,7 +330,7 @@ int console_printf_select_stderr(bool serial_only, const char *fmt, ...) */ ret = vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); - console_puts_select_stderr(serial_only, buf); + err_puts(serial_only, buf); return ret; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 25df22e31b0..913ed4208e4 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -441,14 +441,12 @@ static int console_truetype_putc_xy(struct udevice *dev, void *vctx, uint x, last_cp = pos->cp; kern = stbtt_GetCodepointKernAdvance(font, last_cp, cp); if (_DEBUG) { - console_printf_select_stderr(true, "kern %c (%02x)", - last_cp, last_cp); + err_printf(true, "kern %c (%02x)", last_cp, last_cp); } xpos += met->scale * kern; } if (_DEBUG) { - console_printf_select_stderr(true, " %c (%02x)\n", - cp >= ' ' ? cp : ' ', cp); + err_printf(true, " %c (%02x)\n", cp >= ' ' ? cp : ' ', cp); } /* diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 3d440e8e672..fc2b443d0bd 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -122,7 +122,7 @@ static void vidconsole_newline(struct udevice *dev, struct vidconsole_ctx *ctx) ret = video_sync(dev->parent, false); if (ret) { #ifdef DEBUG - console_puts_select_stderr(true, "[vc err: video_sync]"); + err_puts(true, "[vc err: video_sync]"); #endif } } @@ -333,7 +333,7 @@ static void vidconsole_escape_char(struct udevice *dev, ret = video_sync(dev->parent, false); if (ret) { #ifdef DEBUG - console_puts_select_stderr(true, "[vc err: video_sync]"); + err_puts(true, "[vc err: video_sync]"); #endif } ctx->ycur = 0; @@ -460,11 +460,10 @@ static int vidconsole_output_glyph(struct udevice *dev, { int ret; - if (_DEBUG) { - console_printf_select_stderr(true, - "glyph last_ch '%c': ch '%c' (%02x): ", - ctx->last_ch, ch >= ' ' ? ch : ' ', ch); - } + if (_DEBUG) + err_printf(true, "glyph last_ch '%c': ch '%c' (%02x): ", + ctx->last_ch, ch >= ' ' ? ch : ' ', ch); + /* * Failure of this function normally indicates an unsupported * colour depth. Check this and return an error to help with @@ -578,13 +577,13 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) ret = vidconsole_put_char(dev, NULL, ch); if (ret) { #ifdef DEBUG - console_puts_select_stderr(true, "[vc err: putc]"); + err_puts(true, "[vc err: putc]"); #endif } ret = video_sync(dev->parent, false); if (ret) { #ifdef DEBUG - console_puts_select_stderr(true, "[vc err: video_sync]"); + err_puts(true, "[vc err: video_sync]"); #endif } } @@ -603,13 +602,13 @@ static void vidconsole_putsn(struct stdio_dev *sdev, const char *s, int len) char str[30]; snprintf(str, sizeof(str), "[vc err: putsn %d]", ret); - console_puts_select_stderr(true, str); + err_puts(true, str); #endif } ret = video_sync(dev->parent, false); if (ret) { #ifdef DEBUG - console_puts_select_stderr(true, "[vc err: video_sync]"); + err_puts(true, "[vc err: video_sync]"); #endif } } diff --git a/include/console.h b/include/console.h index 209b67f3535..83b8d4f642c 100644 --- a/include/console.h +++ b/include/console.h @@ -159,7 +159,7 @@ static inline bool console_record_isempty(void) int console_announce_r(void); /** - * console_puts_select_stderr() - Output a string to selected console devices + * err_puts() - Output a string to selected console devices * * This writes to stderr only. It is useful for outputting errors * @@ -167,10 +167,10 @@ int console_announce_r(void); * else * @s: String to output */ -void console_puts_select_stderr(bool serial_only, const char *s); +void err_puts(bool serial_only, const char *s); /** - * console_printf_select_stderr() - Output a formatted string to selected devs + * err_printf() - Output a formatted string to selected devs * * This writes to stderr only. It is useful for outputting errors. Note that it * uses its own buffer, separate from the print buffer, to allow printing @@ -181,7 +181,7 @@ void console_puts_select_stderr(bool serial_only, const char *s); * @fmt: Printf format string, followed by format arguments * Return: number of characters written */ -int console_printf_select_stderr(bool serial_only, const char *fmt, ...) +int err_printf(bool serial_only, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); /** From patchwork Wed Feb 4 00:09:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1805 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163868; bh=xBCNADqWb//JLjgEznKazz6FyRU0JSCrh+XImg49WS8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QoYP3jvIfiUsiO5SAzQOAb/F752/9BfZRPMt7oUjEIX37CqIqejMCzubjYStcVP8k hOSLL5a76fyZHvJ+hc+M3cEUnm3X0I33jNXt08Xmwbe+JKFzcGkFeM/SHx1W4ebEAp VVmcUvoJ7bpU3m9PdzIDSmLirzYtu72ig4crJCHoKsWmS9XulD2m0zKnSRbA8S3mQR oCFY9USi9Dw+YBUFlNDH1uyaCD7rmkIptmHT1zZzgzoDg1eWUTIu25w3+DKLqUrBmd CcSsSTgQ0Ljc5cWX98+k78+VzUQqFi6uh6Z1aP4lpcyWkSwhBhLQVgvW+zYnmFjTm6 w/0lboEjRgnuw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58503698FD for ; Tue, 3 Feb 2026 17:11:08 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id a591Fa7dAuOi for ; Tue, 3 Feb 2026 17:11:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163868; bh=xBCNADqWb//JLjgEznKazz6FyRU0JSCrh+XImg49WS8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QoYP3jvIfiUsiO5SAzQOAb/F752/9BfZRPMt7oUjEIX37CqIqejMCzubjYStcVP8k hOSLL5a76fyZHvJ+hc+M3cEUnm3X0I33jNXt08Xmwbe+JKFzcGkFeM/SHx1W4ebEAp VVmcUvoJ7bpU3m9PdzIDSmLirzYtu72ig4crJCHoKsWmS9XulD2m0zKnSRbA8S3mQR oCFY9USi9Dw+YBUFlNDH1uyaCD7rmkIptmHT1zZzgzoDg1eWUTIu25w3+DKLqUrBmd CcSsSTgQ0Ljc5cWX98+k78+VzUQqFi6uh6Z1aP4lpcyWkSwhBhLQVgvW+zYnmFjTm6 w/0lboEjRgnuw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4591B69911 for ; Tue, 3 Feb 2026 17:11:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163866; bh=H3tf9jSaESQ2b2pSOBCRLYCdoquouBheJNTSamUjEnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyYjXaKCUH/x1WvKYwS0wzYcalWWTshSdWA0PBBrs1ULUhCOY4UUAnjky2g5yL74u tBUJQaHrbUhX3w+WZF/XwGhpYEIR9jj+vGTgzUEnc4JC2DMikGM6RUESbfb2N4LfPt 64bmL0W+b4wdz6amshPmSC8Y31DHMl0J8EreL1c81VkFrEQglxDtxcahTBoZEzJWqU DOQ3u0DxFMgfpEf4g/JazFOu6T3JqDqwjsi9xD/f4evruOQ2e1MVoNFtwdGoEgKgYE 9RflWXKrIaq+ggEMULrrLYvi7YxoSyTlDMugyaVsmrp4QtxU7WNob50ARjtHrnmHfz 4RCktdK/9eS4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71AE2698FD; Tue, 3 Feb 2026 17:11:06 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id mB7l8i6Sdg9s; Tue, 3 Feb 2026 17:11:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163862; bh=FdAvMB64OpeSs+oh+g60SrCiUhbjFXoJqhqgBpsG2wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lq7FjPjvyFektI6KgWnrjtrewsWkOV6VxhkR4+mF/yCExZLH6nO1r3mY2TKlAPb1B 8TSVDvS+BQ+mVUWcDlHlQO2vr8TWAhRkiu1h8nr1INU/UMQeIlBjgxASrtKpXQK4hI dDZEwrUrC3tGH57MOoPmYrTHkbr/sMewl2IAk/3pIyDwBW9Ag2fyA4zlohj7Jc2JJB SVY+om1rnksN3bfbRji801Hw4BQHYVr6D+YFVODx3jetzCMGUqSI3akI8dGmeE61WP 1G0OVEiqkRzcn7XU6nW2sDEm3J9KqkAoHYpBoqBkkLQgYjilxlHR9slb+WJi5bwckz ISHgSCcLYv4Hw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2094A69909; Tue, 3 Feb 2026 17:11:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:55 -0700 Message-ID: <20260204001002.2638622-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3A5337S2K6DEWG7POTQO53COJQPSXQ24 X-Message-ID-Hash: 3A5337S2K6DEWG7POTQO53COJQPSXQ24 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/13] console: Add err_putsn() for length-based error output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add err_putsn() to output errors with a specified length, which is more efficient when the length is already known (e.g., from snprintf()). Create console_putsn_select() which uses device putsn() methods when CONFIG_CONSOLE_PUTSN is enabled, falling back to puts() otherwise. Refactor err_puts() to call err_putsn() and update err_printf() to use the length returned by vscnprintf(). Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 59 +++++++++++++++++++++++++++++++++++++++-------- include/console.h | 15 ++++++++++++ 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/common/console.c b/common/console.c index f9669a0e028..96e8977ce06 100644 --- a/common/console.c +++ b/common/console.c @@ -291,30 +291,56 @@ static void console_putc_pager(int file, const char c) } /** - * console_puts_select() - Output a string to all console devices + * console_putsn_select() - Output a string with length to console devices * * @file: File number to output to (e,g, stdout, see stdio.h) * @serial_only: true to output only to serial, false to output to everything * else * @s: String to output + * @len: Length of string to output */ -static void console_puts_select(int file, bool serial_only, const char *s) +static void console_putsn_select(int file, bool serial_only, const char *s, + int len) { + struct stdio_dev *sdev; int i; struct stdio_dev *dev; for_each_console_dev(i, file, dev) { bool is_serial = console_dev_is_serial(dev); - if (dev->puts && serial_only == is_serial) - dev->puts(dev, s); + if (serial_only == is_serial) { + sdev = dev; + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN) && sdev->putsn) + sdev->putsn(sdev, s, len); + else if (sdev->puts) + sdev->puts(sdev, s); + } } } -void err_puts(bool serial_only, const char *s) +/** + * console_puts_select() - Output a string to all console devices + * + * @file: File number to output to (e,g, stdout, see stdio.h) + * @serial_only: true to output only to serial, false to output to everything + * else + * @s: String to output + */ +static void console_puts_select(int file, bool serial_only, const char *s) +{ + console_putsn_select(file, serial_only, s, strlen(s)); +} + +void err_putsn(bool serial_only, const char *s, int len) { if (gd->flags & GD_FLG_DEVINIT) - console_puts_select(stderr, serial_only, s); + console_putsn_select(stderr, serial_only, s, len); +} + +void err_puts(bool serial_only, const char *s) +{ + err_putsn(serial_only, s, strlen(s)); } int err_printf(bool serial_only, const char *fmt, ...) @@ -330,7 +356,7 @@ int err_printf(bool serial_only, const char *fmt, ...) */ ret = vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); - err_puts(serial_only, buf); + err_putsn(serial_only, buf, ret); return ret; } @@ -472,11 +498,24 @@ static inline void console_putc_pager(int file, const char c) stdio_devices[file]->putc(stdio_devices[file], c); } -void console_puts_select(int file, bool serial_only, const char *s) +static inline void console_putsn_select(int file, bool serial_only, + const char *s, int len) { + struct stdio_dev *sdev; + if ((gd->flags & GD_FLG_DEVINIT) && - serial_only == console_dev_is_serial(stdio_devices[file])) - stdio_devices[file]->puts(stdio_devices[file], s); + serial_only == console_dev_is_serial(stdio_devices[file])) { + sdev = stdio_devices[file]; + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN) && sdev->putsn) + sdev->putsn(sdev, s, len); + else + sdev->puts(sdev, s); + } +} + +void console_puts_select(int file, bool serial_only, const char *s) +{ + console_putsn_select(file, serial_only, s, strlen(s)); } static inline void console_puts_pager(int file, const char *s) diff --git a/include/console.h b/include/console.h index 83b8d4f642c..486131f8bf7 100644 --- a/include/console.h +++ b/include/console.h @@ -158,6 +158,21 @@ static inline bool console_record_isempty(void) */ int console_announce_r(void); +/** + * err_putsn() - Output a string with length to selected console devices + * + * This writes to stderr only. It is useful for outputting errors when the + * length is already known. + * + * Outputs exactly @len characters from @s, regardless of any nul characters. + * + * @serial_only: true to output only to serial, false to output to everything + * else + * @s: String to output (need not be nul-terminated) + * @len: Number of characters to output + */ +void err_putsn(bool serial_only, const char *s, int len); + /** * err_puts() - Output a string to selected console devices * From patchwork Wed Feb 4 00:09:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1806 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163872; bh=X2h1VWokiaEtHOZOWSMjRQR5wOVC3P/z4tQ6Mig5w0E=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UE+SXvg1369VwcwvqC94KNQdKfaq7xKDgHHki4iZs4/0uPhy6dLKlH7NW1PeX+7pO yWOuzk4Es4cC/vk+t0mNM37u5R9960wjyD4H6nPrTcr+EyxqaTadSQMGDOxBqprPsl d2s6g9bDooYyZUYjnS7E/Q7XxJtypZECfWTfrKZdUf5tP1C4h8TSMPc2xT+5bgkO4j VGprrXjWOfjYSb/gPJH/RmNCr607Jx2eCHY5SGeARTfV1nURkgAAxiIQuvZ26gEaT6 Wu/hmH/s0VrVM1pTfsIMuVp7sstERI+Zl9t2t5HunqMiiYPtXzqnc247yvMwUD/AVm FXefxDC2E7O+w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D28C869914 for ; Tue, 3 Feb 2026 17:11:12 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VkqIilvS5aTC for ; Tue, 3 Feb 2026 17:11:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163872; bh=X2h1VWokiaEtHOZOWSMjRQR5wOVC3P/z4tQ6Mig5w0E=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UE+SXvg1369VwcwvqC94KNQdKfaq7xKDgHHki4iZs4/0uPhy6dLKlH7NW1PeX+7pO yWOuzk4Es4cC/vk+t0mNM37u5R9960wjyD4H6nPrTcr+EyxqaTadSQMGDOxBqprPsl d2s6g9bDooYyZUYjnS7E/Q7XxJtypZECfWTfrKZdUf5tP1C4h8TSMPc2xT+5bgkO4j VGprrXjWOfjYSb/gPJH/RmNCr607Jx2eCHY5SGeARTfV1nURkgAAxiIQuvZ26gEaT6 Wu/hmH/s0VrVM1pTfsIMuVp7sstERI+Zl9t2t5HunqMiiYPtXzqnc247yvMwUD/AVm FXefxDC2E7O+w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C1B41698FD for ; Tue, 3 Feb 2026 17:11:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163871; bh=/EKkGfhQ2KGHXiuJgi9ipcRpQbg4KDe1hILveoGM6YA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWXZlEte0Y7TclWsAHYgrA4+ji9p1SEHivqItQIJWMcJlPiMGVHYa3LzHaXogtYoo 8trY00Ni1okGBpHYbTUWn9AKAoZmA278UHs1ibNAhsLY7/RbJEV83FObZx0PraRNXj B14JO6wLGolWJuU0r5T0A3nZ0C8nlJII7p2RrX0joM1y53Fg/ws4ZnpBdMQVahOPm9 gZneyDUjuwojrVyxXzXyblqEAfFy6IS2wMGwYmoI04an4b4w4akMqQy87XE0Bu7j5k 55ppbbof2JRODYRncmiwt2+vTSr5dD2JiVK7eZRuVujOvIhLj7pE7Tek7joryWy8Wt HiRpDm/hy0RrQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 10959698FD; Tue, 3 Feb 2026 17:11:11 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id xTLEG3k-ZvSx; Tue, 3 Feb 2026 17:11:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163867; bh=kxh8r6n3KjTBh8FqgM14FdXh1Ch959Vx7FBOKPJ/8PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJ6i3VTLsDQB76NUmZnUnp0CSmFvfVjOxCFzwBes9dRApPXSv4qPEkETY84kbjkR3 jmcZkkxhCxcxjy74HIYnZ0h+5uDTm9FnjTRFwhyl92hAyemaU4rRZzTRTZ8F113Iku mjtgIEaOm6cCtfo1y7sNY9g6XjyyhCx7dXwiJA1nAHUr/98C0vfdoj3BM5HdnSV6WX DMbU4BoRHy7dWYhdZnVzl35+HnkpaCwReeXnK3YIZZga+tXkUMzDttsy0IWxjZoisr IKPBXv3xqB+AiDhpktsIGXfrSZzMfqhC1Wa4xjabuY7TqWP7xk8/c1k7swFAqJM1+K 01k8mBcKYZtpg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B432F69909; Tue, 3 Feb 2026 17:11:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:56 -0700 Message-ID: <20260204001002.2638622-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RXQGHM4ZLQZEN2LOOR645TL7CBYYBQKD X-Message-ID-Hash: RXQGHM4ZLQZEN2LOOR645TL7CBYYBQKD X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/13] console: Add putsn() to ulib List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add the ulib_putsn() function to the U-Boot library interface for standalone applications. This provides length-based string output without requiring nul-termination. The implementation outputs characters one at a time using the exported putc() function, making it available to standalone applications without requiring changes to the jump table. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- include/u-boot-lib.h | 15 +++++++++++++++ lib/ulib/ulib.c | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/u-boot-lib.h b/include/u-boot-lib.h index 934cc33eff5..034ff12a344 100644 --- a/include/u-boot-lib.h +++ b/include/u-boot-lib.h @@ -38,4 +38,19 @@ void ulib_uninit(void); */ const char *ulib_get_version(void); +/** + * ulib_putsn() - Write a string with specified length + * + * This outputs exactly @len characters from @s, regardless of any nul + * characters that may be present. This is useful for printing substrings + * or binary data with embedded nuls. + * + * If CONFIG_CONSOLE_PUTSN is enabled, this calls putsn() directly. + * Otherwise, it outputs characters one at a time using putc(). + * + * @s: String to output (need not be nul-terminated) + * @len: Number of characters to output + */ +void ulib_putsn(const char *s, int len); + #endif diff --git a/lib/ulib/ulib.c b/lib/ulib/ulib.c index c957ae6ba67..bb2cbc7cbac 100644 --- a/lib/ulib/ulib.c +++ b/lib/ulib/ulib.c @@ -6,6 +6,7 @@ * Written by Simon Glass */ +#include #include #include #include @@ -36,3 +37,12 @@ const char *ulib_get_version(void) { return version_string; } + +void ulib_putsn(const char *s, int len) +{ + if (CONFIG_IS_ENABLED(CONSOLE_PUTSN)) + putsn(s, len); + else + while (len--) + putc(*s++); +} From patchwork Wed Feb 4 00:09:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1807 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163875; bh=bOoVYnSOW1bEkMtgdGkJoDZ0uVV6xdMdemw5VCDrcNI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=DMaDxqHHYg30Ulue/Vzt7QRf6CoXxfIWUIRRV3Rfb/78LW1wUa0jTbJGgUkrHkw/O 54nCTdjfqduKATZtpYEZ3nH6JdOyPoVoOGYLPgJXsSB+LNHpJ5jbJwaOhKR4md5rG6 dZ4Du3qxICdhsjXOc+X2qsFaUpTSq70UlUVzSnfny5efZNFYW0UpRtnL3Wy/aPVbuT Uhg0UiBcyd0wMR3AoFh6BqPeXJNUK/8i5RFftcEzmjM/7ps8xeFJfn4wSbWJ3iDXOh zNz8eTTrqspZEjk5jSUzBtOdicnrWzlAI3vnwQ7XymQWlWNxtBgRpfzwFOGdM4YRQH r7qzUQhL4OqSg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4062A698FD for ; Tue, 3 Feb 2026 17:11:15 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id DGpguiDxL8Ln for ; Tue, 3 Feb 2026 17:11:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163874; bh=bOoVYnSOW1bEkMtgdGkJoDZ0uVV6xdMdemw5VCDrcNI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Yo1jgx1kyt7glb/e/3whx0Hfx+pW8YmOFRQfITUBD4oBgSc+Q4fC9haXlM+WgHa30 qhcL4RaJ3G3HuNfxskL7cvEeFIJDlzA5MvbxR85aCajoHZ2P3G1s8BKcCI6BWHYrHO LnGG8HwxYxBq3KWUYBM/bvPJ9JpkkGVadkR9mSIsDS343iIDzUrW1wZ+Bx4BP6DLqq C/CbaEzVDdtlDtfw4LJWCOA4W/M7A652M8ZAfKL0v1hFK95DnojNl1SXF0HXx+sHY0 3n0ZDBrd5s2zcH43+64TP7Tsm+qmCrFq2rIJDB8jqdLZw2R+NYiEdq5aDdikyvf5rS tUFvDOfRcFtAw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 89E4E69911 for ; Tue, 3 Feb 2026 17:11:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163872; bh=coGDcS9ALAOMe4YcWoK8alpC8YUh5YcnDIFVKNR6h5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvG7hxZyb5TZuaj2ZJh0QhS2u/pEoUtfNFsfe8dhvB8cegcPd1CCG3d9GptVnJSuA F325ZfcjJnyfg/Ji7un5xIuH+963Jc5FfJtf9r8tu/6JX3dDaUb6GnM/ry2hPgX/Ck UX6wkrAMxw3l7Wgb4ZY/7qTaUwaTdNdMAQbzek5uOEdrnW153tHv7dJ+cw4QizN/aB hMl9kk5idRrOJFgpdgY1wm+c6ZHWsrxiFwEkrO7GHZJALgY0DR9dApt1dGkVZKuqGn XWWB4d1MbhaGHXlL9Jr/m1onaIMHr2k21jiSBviagBG8gSuRVUQCFYyVyu/VokIbn5 zqz8HgNCsHCWQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 04517698FD; Tue, 3 Feb 2026 17:11:12 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id epQyxhyVTDx6; Tue, 3 Feb 2026 17:11:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163871; bh=fHW4SbAfsRqn04FY4qV/FuSMs2i21uqlUgdoe9FdgNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwuK3HeeANbhxpeDNhY/V8ZwBFBscPvNuJGQK8vsOBrRj3amxeEUhnidV5zyKcwQ5 hqZ7XFyxTSFEJ2AFPndTz49icZ51tweDpFdWvKdVmLTD16Qkq7f9QV4FvPsyAjfnNj SjQLY2aHh/fkb9WIRYqskhNdMBtGbhMchj7/AmehOelWEivHh0nKLcGpWxPiA3Hqm2 tRioh+uv9su1szmrJNp3K302SnO0h6vPuWROGB5v2lknWAj+we4A8R6iziGMYP4klb TuAQ6bEgYSG1yIOSiYZMUS3D2MNKgK7l8VGSTKn52GTlhRYlkPAIxq0Por1Nnn2Iqk gm8LUuN+D5hYQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 53B7069909; Tue, 3 Feb 2026 17:11:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:57 -0700 Message-ID: <20260204001002.2638622-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WUUWJCBT5ORPQXEKUWUNCYZUN77P4C2U X-Message-ID-Hash: WUUWJCBT5ORPQXEKUWUNCYZUN77P4C2U X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/13] CI: Add artifacts for the 'make check' CI jobs List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The python_check_template, used by the 'Check make check', 'Check make qcheck' and 'Check make tcheck' jobs, does not collect test artifacts. This means that when a test fails, the test-log.html file is not available for debugging. Add an after_script to copy the html/css files from the build directories, and an artifacts section to save them, matching what the buildman_and_testpy_template already does. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cbadb43a85..509a2956ecb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -418,6 +418,15 @@ Examples: # Set environment variables - export TOOLPATH="--toolpath ${pwd}/build-sandbox/tools --toolpath /opt/coreboot" - export PATH=/opt/qemu/bin:${PATH} + after_script: + - cp -v build-*/*.{html,css} . 2>/dev/null || true + - rm -rf /tmp/venv + artifacts: + when: always + paths: + - "*.html" + - "*.css" + expire_in: 1 week Check make check: extends: .python_check_template