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