From patchwork Fri Aug 22 14:21:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 106 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=1755872535; bh=xl91DcKmCIPAfq9GtlZP382LaxEuxqPvFHbR53X19Wo=; 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=nrVgBfJzHSKPvvGqNFCXAHyKjyLix29UQrQJSVQfXTxXlkJTE+OAlYgtok/EE5cJI 33mfQ7Y5anmNbivP/h9/VfX3D11cVQK8iMJiArYxwNXQn4uysClyaAHP/YeS0Vynye Pp9vauo/HIU2l7bN56fzbwAMbe1F9GxlIEO7MmEZ9wz7NFvabVcNRuvBeykXaAFr9b FM7IEzjJgK1HGadSbQbDuTOD++I8aRAFAtlk7/WuWYTBSIjWlOdIJU9Qhq8q//Ng4o BEHU13v401n9q/dp/8b2NEOHIGrVAlIVU0S7Yqulw+tkOLEeyGpbJgjWcpJGvOgWFR 7WctqVHM+naRQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB73E676EF for ; Fri, 22 Aug 2025 08:22:15 -0600 (MDT) 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 6ApDKUm5Mlwd for ; Fri, 22 Aug 2025 08:22:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872535; bh=xl91DcKmCIPAfq9GtlZP382LaxEuxqPvFHbR53X19Wo=; 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=nrVgBfJzHSKPvvGqNFCXAHyKjyLix29UQrQJSVQfXTxXlkJTE+OAlYgtok/EE5cJI 33mfQ7Y5anmNbivP/h9/VfX3D11cVQK8iMJiArYxwNXQn4uysClyaAHP/YeS0Vynye Pp9vauo/HIU2l7bN56fzbwAMbe1F9GxlIEO7MmEZ9wz7NFvabVcNRuvBeykXaAFr9b FM7IEzjJgK1HGadSbQbDuTOD++I8aRAFAtlk7/WuWYTBSIjWlOdIJU9Qhq8q//Ng4o BEHU13v401n9q/dp/8b2NEOHIGrVAlIVU0S7Yqulw+tkOLEeyGpbJgjWcpJGvOgWFR 7WctqVHM+naRQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A2E7676DB for ; Fri, 22 Aug 2025 08:22:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872533; bh=O6Yk3zo6sshGWSV6AomLaDVVCj8P1pRGfjpdwm9fj5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJyvIs/7UCIXhTz2NAvES8QEBS4Dn0PMkHiz9/I+BWedGQ85suI1b6hzw+tv97f+5 ur5APgn014vjnPl+0bfO+SKIKSrGefyOMsb/W227X+Ds2dJwsFCH6liZYnhqYrekZq Io0nimPJYgikOvUPbpbNn1/l+Jn/kYmQFfHFD0zNOq33THEriXc1e9iyVo6dSJQ0ar lGN7BgEvBDLcnVGqsScIsr2UluWrOVMjrwyqFRXjn783F4QYzNMGeCOFXjvG19pJO2 aoar74IWblwCjvZpnmcaX9xC2SXcyB2E4JEtKXie/3CVVej+8QKvDorR6kR683Nck6 LIFCTM0aYnRfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79D81676DB; Fri, 22 Aug 2025 08:22:13 -0600 (MDT) 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 9jDyynpFSC6a; Fri, 22 Aug 2025 08:22:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872532; bh=miwwxHxy19w/Q51v8mj3lTBbSrK4lR0tE6TL0zlDxCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1VPo/YpZh2KGTa9+7D5EtxBcqniy5W7bePEP1Ip/cLTa22eYd5e7zQn/KsKHq2sP qveHIbqT5qfQ41UV3lUYw+VHwuuflvFzOIRPXZyqqBRMYGzvPtwF8nJ7RnpXoi0QQd G+SuQ1NCcCGqnZt5D5GiNCilQ539NuuZcUkg4E0ZIGHI87WY5paqcANY1uvl44/oEa GxvzoQYkpy5CEN8+VSRCBCQHdsxm0oCIYrdbA5A/6CO73U0SNm2MSNcKotK0DDX7HY o8TyZq53T4wIjDwUU5DudrN2Wn4tzI25Cpdu+wneoFig6yaDmkTqbzgdcfen2YPKsz 1dctKQkRVda1Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B8250676C4; Fri, 22 Aug 2025 08:22:12 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:32 -0600 Message-ID: <20250822142153.3404275-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XHHU4U3PL5Q2MQ3VZMTIMFJBAPZ5S2R2 X-Message-ID-Hash: XHHU4U3PL5Q2MQ3VZMTIMFJBAPZ5S2R2 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/16] console: Add the basic pager implementation 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 implementation of the pager. It has quite a simple API: - call pager_post() to send some output, which returns what should actually be sent to the console devices - then call pager_next() repeatedly, outputting what it returns, until it returns NULL There is one special case: pager_next() returns PAGER_WAITING if it is waiting for the user to press a key. In that case, the caller should read a key and then pass it to the next pager_next() call. Internally, there is a simple state machine to cope with hitting the limit (and outputing a prompt), waiting for the user and the clearing the prompt, before continuing in the normal PAGEST_OK state. Signed-off-by: Simon Glass --- common/Kconfig | 11 ++++ common/Makefile | 2 + common/pager.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ include/pager.h | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 298 insertions(+) create mode 100644 common/pager.c create mode 100644 include/pager.h diff --git a/common/Kconfig b/common/Kconfig index 0db3b6babca..048530adff3 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -332,6 +332,17 @@ config SYS_DEVICE_NULLDEV operation of the console by setting stdout to "nulldev". Enable this to use a serial console under board control. +config CONSOLE_PAGER + bool "Enable console output paging" + depends on CONSOLE_MUX + default y if SANDBOX + help + Enable pager functionality for console output. When enabled, long + output will be paused after a configurable number of lines, waiting + for user input (SPACE) to continue. The number of lines per page is + controlled by the 'pager' environment variable. If the variable is + not set or is empty, paging is disabled. + endmenu menu "Logging" diff --git a/common/Makefile b/common/Makefile index 048e4a6b3e2..7270af457f5 100644 --- a/common/Makefile +++ b/common/Makefile @@ -26,6 +26,8 @@ obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o +obj-$(CONFIG_CONSOLE_PAGER) += pager.o + obj-$(CONFIG_USB_HOST) += usb.o usb_hub.o obj-$(CONFIG_USB_GADGET) += usb.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o diff --git a/common/pager.c b/common/pager.c new file mode 100644 index 00000000000..084c741989f --- /dev/null +++ b/common/pager.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Deals with splitting up text output into separate screenfuls + * + * Copyright 2025 Simon Glass + */ + +#define LOG_CATEGORY LOGC_CONSOLE + +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +const char *pager_post(struct pager *pag, const char *s) +{ + struct membuf old; + int ret, len; + + if (!pag) + return s; + + len = strlen(s); + if (!len) + return NULL; + + old = pag->mb; + ret = membuf_put(&pag->mb, s, len); + if (ret == len) { + /* all is well */ + } else { + /* + * We couldn't store any of the text, so we'll store none of + * it. The pager is now in an non-functional state until it + * can eject the overflow text. + * + * The buffer is presumably empty, since callers are not allowed + * to call pager_post() unless all the output from the previous + * call was provided via pager_next(). + */ + pag->overflow = s; + pag->mb = old; + } + + return pager_next(pag, 0); +} + +const char *pager_next(struct pager *pag, int key) +{ + char *str, *p, *end; + int ret; + + /* replace the real character we overwrite with nul, if needed */ + if (pag->nulch) { + *pag->nulch = pag->oldch; + pag->nulch = NULL; + } + + /* if we're at the limit, wait */ + switch (pag->state) { + case PAGERST_OK: + break; + case PAGERST_AT_LIMIT: + pag->state = PAGERST_WAIT_USER; + return "\n: Press SPACE to continue"; + case PAGERST_WAIT_USER: + if (key != ' ') + return PAGER_WAITING; + pag->state = PAGERST_CLEAR_PROMPT; + return "\r \r"; + case PAGERST_CLEAR_PROMPT: + pag->state = PAGERST_OK; + break; + } + + ret = membuf_getraw(&pag->mb, pag->buf.size - 1, false, &str); + if (!ret) { + if (pag->overflow) { + const char *oflow = pag->overflow; + + pag->overflow = NULL; + return oflow; + } + return NULL; + } + + /* return lines until we reach the limit */ + for (p = str, end = str + ret; p < end; p++) { + if (*p == '\n' && ++pag->line_count == pag->page_len - 1) { + /* remember to display the pager message next time */ + pag->state = PAGERST_AT_LIMIT; + pag->line_count = 0; + + /* skip the newline, since our prompt has one */ + p++; + break; + } + } + + /* remove the used bytes from the membuf */ + ret = membuf_getraw(&pag->mb, p - str, true, &str); + + /* don't output the newline, since our prompt has one */ + if (pag->state == PAGERST_AT_LIMIT) + p--; + + /* terminate the string */ + pag->nulch = p; + pag->oldch = *pag->nulch; + *pag->nulch = '\0'; + + return str; +} + +void pager_uninit(struct pager *pag) +{ + abuf_uninit(&pag->buf); + free(pag); +} + +int pager_init(struct pager **pagp, int page_len, int buf_size) +{ + struct pager *pag; + + pag = malloc(sizeof(struct pager)); + if (!pag) + return log_msg_ret("pag", -ENOMEM); + memset(pag, '\0', sizeof(struct pager)); + pag->page_len = page_len; + if (!abuf_init_size(&pag->buf, buf_size)) + return log_msg_ret("pah", -ENOMEM); + + /* + * nul-terminate the buffer, which will come in handy if we need to + * return up to the last byte + */ + ((char *)pag->buf.data)[buf_size - 1] = '\0'; + membuf_init(&pag->mb, pag->buf.data, buf_size); + *pagp = pag; + + return 0; +} diff --git a/include/pager.h b/include/pager.h new file mode 100644 index 00000000000..16739d41119 --- /dev/null +++ b/include/pager.h @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Deals with splitting up text output into separate screenfuls + * + * Copyright 2025 Simon Glass + */ + +#ifndef __PAGER_H +#define __PAGER_H + +#include +#include +#include +#include + +#define PAGER_BUF_SIZE SZ_4K + +/* Special return value from pager_next() indicating it's waiting for user input */ +#define PAGER_WAITING ((const char *)1) + +/** + * enum pager_state: Tracks the state of the pager + * + * @PAGERST_OK: Normal output is happening + * @PAGERST_AT_LIMIT: No more output can be provided; the next call to + * pager_next() will return a user prompt + * @PAGERST_WAIT_USER: Waiting for the user to press a key + * @PAGERST_CLEAR_PROMPT: Clearing the prompt ready for more output + */ +enum pager_state { + PAGERST_OK, + PAGERST_AT_LIMIT, + PAGERST_WAIT_USER, + PAGERST_CLEAR_PROMPT, +}; + +/** + * struct pager - pager state + * + * The pager uses a buffer @buf to hold text that it is in the process of + * sending out. This helps deal with the stdio puts() interface, which does not + * permit passing a string length, only a string, which means that strings must + * be nul-terminated. The termination is handled automatically by the pager. + * + * If the text passed to pager_post() is too large for @buf then all the next + * will be written at once, without any paging, in the next call to + * pager_next(). + * + * The membuf @mb is only used to feed out text in chunks, with a pager message + * (and a keypress wait) inserted between each chunk. + * + * @line_count: Number of lines output since last pause + * @page_len: Sets the height of the page in lines. The maximum lines to display + * before pausing is one less than this. Set from 'pager' env variable + * @buf: Buffer containing text to eventually be returned + * @mb: Circular buffer to manage @buf + * @overflow: pointer to overflow text to send nexts + * @nulch: pointer to where a nul character was written, NULL if none + * @oldch: old character that was at @nulch + */ +struct pager { + int line_count; + int page_len; + struct abuf buf; + struct membuf mb; + const char *overflow; + char *nulch; + int oldch; + enum pager_state state; +}; + +#if CONFIG_IS_ENABLED(CONSOLE_PAGER) + +/** + * pager_post() - Add text to the input buffer for later handling + * + * The text is added to the pager buffer and fed out a screenful + * at a time. This function calls pager_post() after storing the text. + * + * After calling pager_post(), if it returns anything other than NULL, you must + * repeatedly call pager_next() until it returns NULL, otherwise text may be + * lost + * + * If @pag is NULL, this does nothing but return @s + * + * @pag: Pager to use, may be NULL + * @s: Text to add + * Return: text which should be sent to output, or NULL if there is no more. + */ +const char *pager_post(struct pager *pag, const char *s); + +/** + * pager_next() - Returns the next screenful of text to show + * + * If this function returns PAGER_WAITING then the caller must check for user + * input and pass in the keypress in the next call to pager_next(). It can + * busy-wait for a keypress, if desired, since pager_next() will only ever + * return PAGER_WAITING until @ch is non-zero. + * + * @pag: Pager to use + * @ch: Key that the user has pressed, or 0 if none + * + * Return: text which should be sent to output, or PAGER_WAITING if waiting for + * the user to press a key, or NULL if there is no more text. + */ +const char *pager_next(struct pager *pag, int ch); + +/** + * pager_uninit() - Uninit the pager + * + * Frees all memory and also @pag + * + * @pag: Pager to uninit + */ +void pager_uninit(struct pager *pag); + +#else +static inline const char *pager_post(struct pager *pag, const char *s) +{ + return s; +} + +static inline const char *pager_next(struct pager *pag, int ch) +{ + return NULL; +} + +#endif + +/** + * pager_init() - Set up a new pager + * + * @pagp: Returns allocaed pager, on success + * @pagelen: Number of lines per page + * @buf_size: Buffer size to use in bytes, this is the maximum amount of output + * that can be paged + * Return: 0 if OK, -ENOMEM if out of memory + */ +int pager_init(struct pager **pagp, int page_len, int buf_size); + +#endif From patchwork Fri Aug 22 14:21:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 107 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=1755872544; bh=dKYxFR0jNfMvYZoCiMNpTL+0GyqtDH4/WlpSgdFj6l4=; 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=iM9IutAjvnmKoELH1wZirR7JGE3QFsQx4cwEZQNa/f5VarwprXLM055ZG77ItUSKQ 6GHEXRbLmV8A7OxfASHNBvHutAx5NX3Z7lwDqeFCn7yuLFlIbDBdTh/1GfgsUOt7Tn iyjNEeWY0XJ7BRHQOjyfiKP8B5Jy4L4MN7x8el9Uq0Vf+Fa2DwAGyXciphzHDAV27P Ql2+DGew4z9hvpPRICTYlh3nvgvXi4VqzOR6NF2eBwgBJ+f1hrbSSL3LNdMgsYf6Wn hxXkpt10JTap2a9IHrrTKPMTRTsOR2GHXJLgRI3fxIlV/WggaH302kqPsHC0WfZATp AXHCse8o6LTFA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12AEE67702 for ; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) 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 bpXGmRSnkdtS for ; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872544; bh=dKYxFR0jNfMvYZoCiMNpTL+0GyqtDH4/WlpSgdFj6l4=; 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=iM9IutAjvnmKoELH1wZirR7JGE3QFsQx4cwEZQNa/f5VarwprXLM055ZG77ItUSKQ 6GHEXRbLmV8A7OxfASHNBvHutAx5NX3Z7lwDqeFCn7yuLFlIbDBdTh/1GfgsUOt7Tn iyjNEeWY0XJ7BRHQOjyfiKP8B5Jy4L4MN7x8el9Uq0Vf+Fa2DwAGyXciphzHDAV27P Ql2+DGew4z9hvpPRICTYlh3nvgvXi4VqzOR6NF2eBwgBJ+f1hrbSSL3LNdMgsYf6Wn hxXkpt10JTap2a9IHrrTKPMTRTsOR2GHXJLgRI3fxIlV/WggaH302kqPsHC0WfZATp AXHCse8o6LTFA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02E26676F0 for ; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872542; bh=wSrhWyBgyD479z/oregXBZ1+LEknY6Uw3mKbfbvvxyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RL2KSLQQooHTgBKgmyhVQ1MLU0PYSwILPZ6Hxf2+2Q0k/6yvMrb2uRz+l7WiMIw3n mxlnSdqLfZOmS06UC+s48FApqxPykDXB8Tpmg24uR8jip7zydV/m6cTOcYU1P3i762 nLepSQobnXhU25WEg8YUufRftf52NGJMWIEWU1KahhZc4BcC45W+ZPVqp2VRDgqKOa eU9aU4vnQYQrDnzClgcoeiM28nffJub0Skch8gvEEpTqZPsxRKPtEL2vE94Jy5q5n3 mP7Tf3ytohK8cePPLcUj3PgVmdamiFf+fo8EgojjPeyULsTa2HMapBpqQCtCONQ6gg E6WnF8EucDcfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54071676DB; Fri, 22 Aug 2025 08:22:22 -0600 (MDT) 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 FRCl3NKRSB9x; Fri, 22 Aug 2025 08:22:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872541; bh=QVawyu9m+Unj/HmSTUcOYAuVR6MAIluZC2NMOhoF8n4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nsi4dKPxOYt9qdp4l/xM9I2bOrSMmiSqluvBWC9vSebA6RfPUBgNKrvS5NTUnDGeW m7e42sJ0OGMS7yHDe4130DG5+7M3SQBREKp23JLQFapAUnSQ1GPhLqCKBd1tXWjtn2 BZyScMpaoudFN4Q2lbDntvEe+/sdEtfaqfDfMGb/eW66JyWN0T8Zf2NXhZxaqvh6u+ vKLXfGxWizdPQEZtgUcQs7wCAyaZ0d6IXNk6rXPIC4soEgsREhKviW6RgGjOXOaEQh 4BflEkm0Wju/8/gYJYsQE2ayr7Xp3eRgKsdElyirbsSj5Mv0h0GrVJgyUmwfHQOvKM gZ/JInjHoxACw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9C8A7676C4; Fri, 22 Aug 2025 08:22:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:33 -0600 Message-ID: <20250822142153.3404275-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: I6XCG2IJQPO3L3ECBPWYSM22SWPBPYB6 X-Message-ID-Hash: I6XCG2IJQPO3L3ECBPWYSM22SWPBPYB6 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/16] console: Add tests for the basic functionality 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 Cover the various cases in the base code. Put the tests in the 'common' suite to match where the pager implementation is. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/common/Makefile | 1 + test/common/pager.c | 324 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 325 insertions(+) create mode 100644 test/common/pager.c diff --git a/test/common/Makefile b/test/common/Makefile index baefc7b3622..ea1317c41dc 100644 --- a/test/common/Makefile +++ b/test/common/Makefile @@ -10,4 +10,5 @@ endif obj-$(CONFIG_CYCLIC) += cyclic.o obj-$(CONFIG_EVENT_DYNAMIC) += event.o obj-y += cread.o +obj-$(CONFIG_CONSOLE_PAGER) += pager.o obj-$(CONFIG_$(PHASE_)CMDLINE) += print.o diff --git a/test/common/pager.c b/test/common/pager.c new file mode 100644 index 00000000000..37796494f79 --- /dev/null +++ b/test/common/pager.c @@ -0,0 +1,324 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2025 Simon Glass + * + * Test for pager functionality + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Test basic pager init and cleanup */ +static int pager_test_basic_init(struct unit_test_state *uts) +{ + struct pager *pag; + + /* Test successful init */ + ut_assertok(pager_init(&pag, 20, 1024)); + ut_assertnonnull(pag); + ut_asserteq(20, pag->page_len); + ut_asserteq(0, pag->line_count); + ut_assertnull(pag->overflow); + ut_assertnull(pag->nulch); + + /* Clean up */ + pager_uninit(pag); + + /* Test init with different parameters */ + ut_assertok(pager_init(&pag, 10, 2048)); + ut_assertnonnull(pag); + ut_asserteq(10, pag->page_len); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_basic_init, 0); + +/* Test pager with simple text */ +static int pager_test_simple_text(struct unit_test_state *uts) +{ + struct pager *pag; + const char *text = "Hello, World!"; + const char *result; + + ut_assertok(pager_init(&pag, 20, 1024)); + + /* Post some text and get it back */ + result = pager_post(pag, text); + ut_assertnonnull(result); + ut_asserteq_str(text, result); + + /* Should be no more text */ + result = pager_next(pag, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_simple_text, 0); + +/* Test pager with multiple lines */ +static int pager_test_multiline(struct unit_test_state *uts) +{ + struct pager *pag; + const char *text1 = "Line 1\n"; + const char *text2 = "Line 2\n"; + const char *text3 = "Line 3\n"; + const char *result; + + ut_assertok(pager_init(&pag, 20, 1024)); + + /* Post multiple pieces of text */ + result = pager_post(pag, text1); + ut_assertnonnull(result); + ut_asserteq_str(text1, result); + + /* Should be no more text after first post */ + result = pager_next(pag, 0); + ut_assertnull(result); + + result = pager_post(pag, text2); + ut_assertnonnull(result); + ut_asserteq_str(text2, result); + + /* Should be no more text after second post */ + result = pager_next(pag, 0); + ut_assertnull(result); + + result = pager_post(pag, text3); + ut_assertnonnull(result); + ut_asserteq_str(text3, result); + + /* Should be no more text after third post */ + result = pager_next(pag, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_multiline, 0); + +/* Test pager with large text that fills the buffer */ +static int pager_test_large_text(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + ut_assertok(pager_init(&pag, 20, 16)); /* Small buffer */ + + /* Post large text - should fit in buffer */ + result = pager_post(pag, "this is 16 chars"); + ut_assertnonnull(result); + ut_asserteq_str("this is 16 chars", result); + ut_assertnull(pager_next(pag, 0)); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_large_text, 0); + +/* Test pager overflow handling */ +static int pager_test_overflow(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + ut_assertok(pager_init(&pag, 20, 4)); /* Small buffer */ + + /* send some text which is too long for the buffer */ + result = pager_post(pag, "test1"); + ut_assertnonnull(result); + + /* overflow handling should return the text */ + ut_asserteq_str("test1", result); + ut_assertnull(pager_next(pag, 0)); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_overflow, 0); + +/* Test pager with NULL input */ +static int pager_test_null_input(struct unit_test_state *uts) +{ + const char *result; + + /* Test pager_post with NULL pager */ + result = pager_post(NULL, "test"); + ut_asserteq_str("test", result); + + return 0; +} +COMMON_TEST(pager_test_null_input, 0); + +/* Test pager with empty strings */ +static int pager_test_empty_strings(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + ut_assertok(pager_init(&pag, 20, 1024)); + + /* Post empty string */ + result = pager_post(pag, ""); + ut_assertnull(result); + + /* Should be no more text */ + result = pager_next(pag, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_empty_strings, 0); + +/* Test pager buffer management */ +static int pager_test_buffer_management(struct unit_test_state *uts) +{ + struct pager *pag; + const char *text = "Test buffer management"; + const char *result; + + ut_assertok(pager_init(&pag, 20, 1024)); + + /* Verify buffer is properly inited */ + ut_assertnonnull(pag->buf.data); + ut_asserteq(1024, pag->buf.size); + + /* Post text and verify buffer state */ + result = pager_post(pag, text); + ut_assertnonnull(result); + + /* Verify the buffer contains our text */ + ut_asserteq_str(text, result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_buffer_management, 0); + +/* Test pager with very long single line */ +static int pager_test_long_single_line(struct unit_test_state *uts) +{ + struct pager *pag; + char long_line[1000]; + const char *result; + int i; + + ut_assertok(pager_init(&pag, 20, 1024)); + + /* Create a very long line without newlines */ + for (i = 0; i < sizeof(long_line) - 1; i++) + long_line[i] = 'X'; + long_line[sizeof(long_line) - 1] = '\0'; + + /* Post the long line */ + result = pager_post(pag, long_line); + ut_assertnonnull(result); + + /* Should get our text back */ + ut_asserteq_str(long_line, result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_long_single_line, 0); + +/* Test pager line counting and page breaks */ +static int pager_test_line_counting(struct unit_test_state *uts) +{ + struct pager *pag; + const char *multiline_text = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"; + const char *result; + + /* Init with page length of 4 lines */ + ut_assertok(pager_init(&pag, 4, 1024)); + + /* Post multiline text */ + result = pager_post(pag, multiline_text); + ut_assertnonnull(result); + + /* Should get first 3 lines (excluding the 3rd newline) */ + ut_asserteq_str("Line 1\nLine 2\nLine 3", result); + /* line_count is reset to 0 when page limit is reached */ + ut_asserteq(0, pag->line_count); + + /* Next call should return pager prompt */ + result = pager_next(pag, 0); + ut_assertnonnull(result); + ut_asserteq_str("\n: Press SPACE to continue", result); + + /* Press space to continue */ + result = pager_next(pag, ' '); + ut_assertnonnull(result); + ut_asserteq_str("\r \r", result); + + /* Get remaining lines */ + result = pager_next(pag, 0); + ut_assertnonnull(result); + ut_asserteq_str("Line 4\nLine 5\n", result); + + /* Should be no more text */ + result = pager_next(pag, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_line_counting, 0); + +/* Test that PAGER_WAITING is returned when pager waits for user input */ +static int pager_test_pager_waiting(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + /* Create pager with small page size to trigger waiting quickly */ + ut_assertok(pager_init(&pag, 3, 1024)); + + /* Post text that fills exactly the page limit */ + result = pager_post(pag, "Line 1\nLine 2\n"); + ut_assertnonnull(result); + ut_asserteq_str("Line 1\nLine 2", result); + + /* Next call should return the prompt */ + result = pager_next(pag, 0); + ut_assertnonnull(result); + ut_asserteq_str("\n: Press SPACE to continue", result); + + /* Next call without space key should return PAGER_WAITING */ + result = pager_next(pag, 0); + ut_asserteq_ptr(PAGER_WAITING, result); + + /* Another call without space should still return PAGER_WAITING */ + result = pager_next(pag, 'x'); /* Wrong key */ + ut_asserteq_ptr(PAGER_WAITING, result); + + /* Pressing space should clear the prompt */ + result = pager_next(pag, ' '); + ut_assertnonnull(result); + ut_asserteq_str("\r \r", result); + + /* Now should return NULL (no more content) */ + result = pager_next(pag, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_pager_waiting, 0); From patchwork Fri Aug 22 14:21:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 108 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=1755872546; bh=fjXFZc19++r4pbvJxXGtjoZSIMczHC/wES2wKNQj468=; 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=jCYNiStp/zdYGuKlkOyxVX4T3bVKpyBqtvV6RSY2cfR1L/4akUtvEyRgbPEuDI0P9 EmSJcO2zVktC5VgmsD6zPVn6k5Ov7Km4bXWPER1Fv4Vd6npVCu4HyZtJJXuXPr4o6j F19jeGr003VpdAoLaoxxzOWuvVHaciZti0IXTChogSMoTbGhkAP4LOE3gDtOIKIMH6 tWtcVcUTGgXMQkBgBEu7nboX3IpBBs9LxD6kqM3dOLd7X1Ttao5QPo4hRSK7M/yXcz F6RXkW/4YSHg+dEzC5fOj5pOaHiIguhKzA0PYjg3NEidRxpeyRycIFFFfQPqiLwcu8 m67qZT9TfydQw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C291676DB for ; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) 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 3uz9t98B9cdA for ; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872545; bh=fjXFZc19++r4pbvJxXGtjoZSIMczHC/wES2wKNQj468=; 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=HGtf1FWMsxQFSPnav+wdSlnEkHxSfPlCCIvvBKMHsfkVOrGw7cMMg7WoUegwXFTp4 uw2DY5ObdX+PyodVAKEBVUP7CMuXIHH/n/rd/GA6FHMTotZFo3mxhGaTNf17NJV1Ur tTV7hun98iLFts8qbG8PncqNtqHqnA0YhrrpvV0pdvrBEXspsuNT2e/R1RXI2Du1tf x83KfQfWN3ox9KvgAKAEWTmNpxv7HsX7QLnqtRvUR1ool2MWDupQoTggCvd15eo7IJ yxyxS14kuaQs5savkbfe4VLFuG6cMXDhy2Nj7LCV3F4GjOcMRsFV6M2cn/EAHVV0uV FXcoXJzwHH6gQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 60412676C4 for ; Fri, 22 Aug 2025 08:22:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872543; bh=XiG1jc49IvXhaoolq6g6DOq+Ago/4LogIE1s/JpqOWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlbsttqUreJ1kw5Yo0/UmAuE0LjFnbnq8p6GVpbZezNKmzta2xy1r8i10amP1zOD5 11D4z6A9M2TLhc4ODwp6fDsoBnHTbqSgfgoPXeImOqpXwrZO2D+/p0LoNH17iEIHkW NGLevaibR+cu6HmtDfcxZ5l05/Nn5QyBkMdi7MYQm2swFj2jWfI5QdwE5EbJh9e0/A iGfguaDFwpwIKvYUT3ySwX3jUL4KbZ3Fc2pGJavsA3xxatkBD1dCzDSX3wbRL29TF2 BI6s9M75SMKJdhfuiq3Lpu5b7SWGuBcb7ilNmRLWV+QEBUHenG/kk7HSl7zNVHe8on pE6A9wWG09cEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6266E5E45E; Fri, 22 Aug 2025 08:22:23 -0600 (MDT) 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 FJwCV4VTAUxR; Fri, 22 Aug 2025 08:22:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872542; bh=xS2lKKuSRMHv+hMxeRCAS6FnNnYH7+Pjklun4yxOEn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J0mO85eNzYQYbuVejAj5Un+1159iYxxTTPVUQjAncqWnYnExSOlj10zvmwTC3nCVW E3DfqZwouF7goqLuDTHASngiuN34m6OTnxUrajEeocHSKcMzp7SY47HqS7IXtDA3Q9 +FDYLApA/ylORcC8Bge/7FYCzk1MdF0GsXlcc+1QJqBm5UmtHXBu27t3JADDatOKPG V/RSP8Rf4IfjUJbYMmpDgEwatWEI3/54mPVMAlA2yKAJMjUIroSV/Du8fOocDEQblg QLTh+/4kYWp613tGi0SOfSkrkASO+P0pomjs11hbnPq//xg8MRlxfw5MhGlU6CIInw HpP7MyrnnjtZg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9470A676C4; Fri, 22 Aug 2025 08:22:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:34 -0600 Message-ID: <20250822142153.3404275-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YYRPQZOYPKYSBPRWTZK5LRBGDYIYQNPG X-Message-ID-Hash: YYRPQZOYPKYSBPRWTZK5LRBGDYIYQNPG 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/16] console: Provide a way to output without the pager 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 Sometimes output should be sent ignoring the pager, such as when it is a message related to paging. Add a parameter to support this. Co-developed-by: Claude Signed-off-by: Simon Glass --- common/pager.c | 11 ++-- include/pager.h | 15 ++++-- test/common/pager.c | 123 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 112 insertions(+), 37 deletions(-) diff --git a/common/pager.c b/common/pager.c index 084c741989f..20aa8558654 100644 --- a/common/pager.c +++ b/common/pager.c @@ -14,12 +14,12 @@ DECLARE_GLOBAL_DATA_PTR; -const char *pager_post(struct pager *pag, const char *s) +const char *pager_post(struct pager *pag, bool use_pager, const char *s) { struct membuf old; int ret, len; - if (!pag) + if (!pag || !use_pager) return s; len = strlen(s); @@ -44,14 +44,17 @@ const char *pager_post(struct pager *pag, const char *s) pag->mb = old; } - return pager_next(pag, 0); + return pager_next(pag, true, 0); } -const char *pager_next(struct pager *pag, int key) +const char *pager_next(struct pager *pag, bool use_pager, int key) { char *str, *p, *end; int ret; + if (!use_pager) + return NULL; + /* replace the real character we overwrite with nul, if needed */ if (pag->nulch) { *pag->nulch = pag->oldch; diff --git a/include/pager.h b/include/pager.h index 16739d41119..7f7df690d7f 100644 --- a/include/pager.h +++ b/include/pager.h @@ -74,7 +74,7 @@ struct pager { /** * pager_post() - Add text to the input buffer for later handling * - * The text is added to the pager buffer and fed out a screenful + * If @use_pager the text is added to the pager buffer and fed out a screenful * at a time. This function calls pager_post() after storing the text. * * After calling pager_post(), if it returns anything other than NULL, you must @@ -84,10 +84,12 @@ struct pager { * If @pag is NULL, this does nothing but return @s * * @pag: Pager to use, may be NULL + * @use_pager: Whether or not to use the pager functionality * @s: Text to add * Return: text which should be sent to output, or NULL if there is no more. + * If !@use_pager this just returns @s and does not affect the pager state */ -const char *pager_post(struct pager *pag, const char *s); +const char *pager_post(struct pager *pag, bool use_pager, const char *s); /** * pager_next() - Returns the next screenful of text to show @@ -98,12 +100,14 @@ const char *pager_post(struct pager *pag, const char *s); * return PAGER_WAITING until @ch is non-zero. * * @pag: Pager to use + * @use_pager: Whether or not to use the pager functionality * @ch: Key that the user has pressed, or 0 if none * * Return: text which should be sent to output, or PAGER_WAITING if waiting for * the user to press a key, or NULL if there is no more text. + * If !@use_pager this just returns NULL and does not affect the pager state */ -const char *pager_next(struct pager *pag, int ch); +const char *pager_next(struct pager *pag, bool use_pager, int ch); /** * pager_uninit() - Uninit the pager @@ -115,12 +119,13 @@ const char *pager_next(struct pager *pag, int ch); void pager_uninit(struct pager *pag); #else -static inline const char *pager_post(struct pager *pag, const char *s) +static inline const char *pager_post(struct pager *pag, bool use_pager, + const char *s) { return s; } -static inline const char *pager_next(struct pager *pag, int ch) +static inline const char *pager_next(struct pager *pag, bool use_pager, int ch) { return NULL; } diff --git a/test/common/pager.c b/test/common/pager.c index 37796494f79..f72d0f40304 100644 --- a/test/common/pager.c +++ b/test/common/pager.c @@ -50,12 +50,12 @@ static int pager_test_simple_text(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 20, 1024)); /* Post some text and get it back */ - result = pager_post(pag, text); + result = pager_post(pag, true, text); ut_assertnonnull(result); ut_asserteq_str(text, result); /* Should be no more text */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); pager_uninit(pag); @@ -76,28 +76,28 @@ static int pager_test_multiline(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 20, 1024)); /* Post multiple pieces of text */ - result = pager_post(pag, text1); + result = pager_post(pag, true, text1); ut_assertnonnull(result); ut_asserteq_str(text1, result); /* Should be no more text after first post */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); - result = pager_post(pag, text2); + result = pager_post(pag, true, text2); ut_assertnonnull(result); ut_asserteq_str(text2, result); /* Should be no more text after second post */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); - result = pager_post(pag, text3); + result = pager_post(pag, true, text3); ut_assertnonnull(result); ut_asserteq_str(text3, result); /* Should be no more text after third post */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); pager_uninit(pag); @@ -115,10 +115,10 @@ static int pager_test_large_text(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 20, 16)); /* Small buffer */ /* Post large text - should fit in buffer */ - result = pager_post(pag, "this is 16 chars"); + result = pager_post(pag, true, "this is 16 chars"); ut_assertnonnull(result); ut_asserteq_str("this is 16 chars", result); - ut_assertnull(pager_next(pag, 0)); + ut_assertnull(pager_next(pag, true, 0)); pager_uninit(pag); @@ -135,12 +135,12 @@ static int pager_test_overflow(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 20, 4)); /* Small buffer */ /* send some text which is too long for the buffer */ - result = pager_post(pag, "test1"); + result = pager_post(pag, true, "test1"); ut_assertnonnull(result); /* overflow handling should return the text */ ut_asserteq_str("test1", result); - ut_assertnull(pager_next(pag, 0)); + ut_assertnull(pager_next(pag, true, 0)); pager_uninit(pag); @@ -154,7 +154,7 @@ static int pager_test_null_input(struct unit_test_state *uts) const char *result; /* Test pager_post with NULL pager */ - result = pager_post(NULL, "test"); + result = pager_post(NULL, true, "test"); ut_asserteq_str("test", result); return 0; @@ -170,11 +170,11 @@ static int pager_test_empty_strings(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 20, 1024)); /* Post empty string */ - result = pager_post(pag, ""); + result = pager_post(pag, true, ""); ut_assertnull(result); /* Should be no more text */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); pager_uninit(pag); @@ -197,7 +197,7 @@ static int pager_test_buffer_management(struct unit_test_state *uts) ut_asserteq(1024, pag->buf.size); /* Post text and verify buffer state */ - result = pager_post(pag, text); + result = pager_post(pag, true, text); ut_assertnonnull(result); /* Verify the buffer contains our text */ @@ -225,7 +225,7 @@ static int pager_test_long_single_line(struct unit_test_state *uts) long_line[sizeof(long_line) - 1] = '\0'; /* Post the long line */ - result = pager_post(pag, long_line); + result = pager_post(pag, true, long_line); ut_assertnonnull(result); /* Should get our text back */ @@ -248,7 +248,7 @@ static int pager_test_line_counting(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 4, 1024)); /* Post multiline text */ - result = pager_post(pag, multiline_text); + result = pager_post(pag, true, multiline_text); ut_assertnonnull(result); /* Should get first 3 lines (excluding the 3rd newline) */ @@ -257,22 +257,22 @@ static int pager_test_line_counting(struct unit_test_state *uts) ut_asserteq(0, pag->line_count); /* Next call should return pager prompt */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnonnull(result); ut_asserteq_str("\n: Press SPACE to continue", result); /* Press space to continue */ - result = pager_next(pag, ' '); + result = pager_next(pag, true, ' '); ut_assertnonnull(result); ut_asserteq_str("\r \r", result); /* Get remaining lines */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnonnull(result); ut_asserteq_str("Line 4\nLine 5\n", result); /* Should be no more text */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); pager_uninit(pag); @@ -291,30 +291,30 @@ static int pager_test_pager_waiting(struct unit_test_state *uts) ut_assertok(pager_init(&pag, 3, 1024)); /* Post text that fills exactly the page limit */ - result = pager_post(pag, "Line 1\nLine 2\n"); + result = pager_post(pag, true, "Line 1\nLine 2\n"); ut_assertnonnull(result); ut_asserteq_str("Line 1\nLine 2", result); /* Next call should return the prompt */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnonnull(result); ut_asserteq_str("\n: Press SPACE to continue", result); /* Next call without space key should return PAGER_WAITING */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_asserteq_ptr(PAGER_WAITING, result); /* Another call without space should still return PAGER_WAITING */ - result = pager_next(pag, 'x'); /* Wrong key */ + result = pager_next(pag, true, 'x'); /* Wrong key */ ut_asserteq_ptr(PAGER_WAITING, result); /* Pressing space should clear the prompt */ - result = pager_next(pag, ' '); + result = pager_next(pag, true, ' '); ut_assertnonnull(result); ut_asserteq_str("\r \r", result); /* Now should return NULL (no more content) */ - result = pager_next(pag, 0); + result = pager_next(pag, true, 0); ut_assertnull(result); pager_uninit(pag); @@ -322,3 +322,70 @@ static int pager_test_pager_waiting(struct unit_test_state *uts) return 0; } COMMON_TEST(pager_test_pager_waiting, 0); + +/* Test use_pager parameter - output text directly, while buffer is non-empty */ +static int pager_test_use_pager_param(struct unit_test_state *uts) +{ + struct pager *pag; + const char *buffered_text = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"; + const char *direct_text = "This should be written immediately"; + const char *result; + + /* Init with small page length to ensure paging occurs */ + ut_assertok(pager_init(&pag, 3, 1024)); + + /* Post text with use_pager=true - should trigger paging */ + result = pager_post(pag, true, buffered_text); + ut_assertnonnull(result); + /* Should get first 2 lines */ + ut_asserteq_str("Line 1\nLine 2", result); + + /* Now call pager_post with use_pager=false while text is still buffered */ + result = pager_post(pag, false, direct_text); + /* Should get the text immediately, not from buffer */ + ut_asserteq_ptr(direct_text, result); + + /* Call pager_next with use_pager=false - should return NULL */ + result = pager_next(pag, false, 0); + ut_assertnull(result); + + /* Now continue with use_pager=true to get buffered text */ + result = pager_next(pag, true, 0); + ut_assertnonnull(result); + /* Should get the pager prompt */ + ut_asserteq_str("\n: Press SPACE to continue", result); + + /* Press space to continue */ + result = pager_next(pag, true, ' '); + ut_assertnonnull(result); + ut_asserteq_str("\r \r", result); + + /* Get remaining buffered lines - should be next 2 lines due to page limit */ + result = pager_next(pag, true, 0); + ut_assertnonnull(result); + ut_asserteq_str("Line 3\nLine 4", result); + + /* Should get pager prompt again */ + result = pager_next(pag, true, 0); + ut_assertnonnull(result); + ut_asserteq_str("\n: Press SPACE to continue", result); + + /* Press space to continue */ + result = pager_next(pag, true, ' '); + ut_assertnonnull(result); + ut_asserteq_str("\r \r", result); + + /* Get final line */ + result = pager_next(pag, true, 0); + ut_assertnonnull(result); + ut_asserteq_str("Line 5\n", result); + + /* Should be no more text */ + result = pager_next(pag, true, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_use_pager_param, 0); From patchwork Fri Aug 22 14:21:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 109 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=1755872546; bh=h0Zgbbd/J6tKYDr+JrwKQ9hP9uTntceleeCMFMq2f3o=; 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=NLUnopqFQne1MpOZgPdsyKYkpRZd6TAeoDOOVT+Rp215qxzgDIQzGIHOlbJbPyAte +vF6LsPQ0VarkLiIcMyAI0py9gqNAbTs22+zB9iGi3+s8pNyCAGWM7zK1Q49mSJJd7 xZkr5IynolrLOtsaTszzljzNEtKyVPwIkKgEYBEsJnoJVPAHLVNxeB0WQyKw6T/EIs d6scI/OinXNsEIGu2+iqMWJEzKMZkgaj5meZWs6oIrfMBLi8hPYmNR//cmqOkelC84 SFPFfcxltCPuRLGEsWszFpeMqxPOjiQg89Oht6Db74+HVU2Hm9Q9FBgvUlEPNrAlie 2nlItzRhDXESA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD99B6770C for ; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) 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 DcKEdDLmC021 for ; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872546; bh=h0Zgbbd/J6tKYDr+JrwKQ9hP9uTntceleeCMFMq2f3o=; 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=NLUnopqFQne1MpOZgPdsyKYkpRZd6TAeoDOOVT+Rp215qxzgDIQzGIHOlbJbPyAte +vF6LsPQ0VarkLiIcMyAI0py9gqNAbTs22+zB9iGi3+s8pNyCAGWM7zK1Q49mSJJd7 xZkr5IynolrLOtsaTszzljzNEtKyVPwIkKgEYBEsJnoJVPAHLVNxeB0WQyKw6T/EIs d6scI/OinXNsEIGu2+iqMWJEzKMZkgaj5meZWs6oIrfMBLi8hPYmNR//cmqOkelC84 SFPFfcxltCPuRLGEsWszFpeMqxPOjiQg89Oht6Db74+HVU2Hm9Q9FBgvUlEPNrAlie 2nlItzRhDXESA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2F5B06770E for ; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872544; bh=9b0siq+1lmLYBfFer8QQKzu11a1cNXr+gHtFa74Q9eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQpn6YXE0fkka64QhQfaLAwAwWEftqkj+DejkWBbbiOC77LMzVSmZjcAoSPaGJ2BN znEBlX7mQyLR3Lo0K2F6NCF7Io2gaL+i0EG2qQUayz9acI0ZzcVt60cz/4pfMmOWaz 0wQKJX+c5IBmgKNxtqwZcPH03IconLZrzHJaNhiUb2K3wKuvxXOdx6cwBNffpxxed+ Ojkr72bEjPr9Qu5p0OuTz2rZKvcM91VTUBI9hfO4xvHFVhzOhvoKbe+k4+v0HZmplt PrAcwl+4YqwTveYA1tVMdWhaSsd6kDT0UAzF3AS0mw3ecgGmsflbqOdpNe1ouN340h RusDYxZ3fvfZw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 304AD6770C; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) 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 3iYV7Aq9e38i; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872543; bh=z7NYc+Xvx9e+8+BXrf1hRdPONZ9BOfsFJ+cMQXJygNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PRiMqvIyOmELL4cn0STPFWtWwZSs+zR/uiIDJtxadpxNhaF804KJnDD/FagVKsxxL HzvWc4gfp7Juo73Z/ngqd98DcJrNltXlsljBEDWM0qO48n7bj4UtPvGCebt6MHwsA3 upfkwnESYQbb/Up/UJXI8VMs9kyzdsNmUCKw4V/zCYVKyUfY3sHCf0liMMgUWey16M ofOfYjhEyb6JHD9+oiKX6xLEuAtAXvpLJpAH9OWAm3Ua342NPrdOYh+ovbvOF73LKw wPIxnK8iLJlw3MzpY2MhdrbRv5p4r3mjulUXMmDpUCLLmXU3L2TX25uVOmgdtyhbDi 4Xuz21UFH3m2A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A4E5C676BE; Fri, 22 Aug 2025 08:22:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:35 -0600 Message-ID: <20250822142153.3404275-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZVBFWUDW2KJYJMKJYIFVL7PHSM3YXMMH X-Message-ID-Hash: ZVBFWUDW2KJYJMKJYIFVL7PHSM3YXMMH 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/16] console: Rename console-put functions to prepare for pager 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 Rename console_puts() to console_puts_pager() and console_putc() to console_putc_pager() to prepare for implementing a console-pager feature. All normal output goes through the pager. Co-developed-by: Claude Signed-off-by: Simon Glass --- common/console.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/console.c b/common/console.c index c6dfed6e201..fdccf156b5a 100644 --- a/common/console.c +++ b/common/console.c @@ -321,7 +321,7 @@ static int console_tstc(int file) return 0; } -static void console_putc(int file, const char c) +static void console_putc_pager(int file, const char c) { int i; struct stdio_dev *dev; @@ -377,7 +377,7 @@ int console_printf_select_stderr(bool serial_only, const char *fmt, ...) return ret; } -static void console_puts(int file, const char *s) +static void console_puts_pager(int file, const char *s) { int i; struct stdio_dev *dev; @@ -433,7 +433,7 @@ static inline int console_tstc(int file) return stdio_devices[file]->tstc(stdio_devices[file]); } -static inline void console_putc(int file, const char c) +static inline void console_putc_pager(int file, const char c) { stdio_devices[file]->putc(stdio_devices[file], c); } @@ -445,7 +445,7 @@ void console_puts_select(int file, bool serial_only, const char *s) stdio_devices[file]->puts(stdio_devices[file], s); } -static inline void console_puts(int file, const char *s) +static inline void console_puts_pager(int file, const char *s) { stdio_devices[file]->puts(stdio_devices[file], s); } @@ -562,13 +562,13 @@ int ftstc(int file) void fputc(int file, const char c) { if ((unsigned int)file < MAX_FILES) - console_putc(file, c); + console_putc_pager(file, c); } void fputs(int file, const char *s) { if ((unsigned int)file < MAX_FILES) - console_puts(file, s); + console_puts_pager(file, s); } #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT From patchwork Fri Aug 22 14:21:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 110 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=1755872551; bh=3tW3zR5U5VmoeuPie/wUjk8fYxIy6ZVGo81Oq5d/k3g=; 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=lpSiYIkv1h3YArmMBUS0nZBfMGgoA0UqkfDQkDyvHyeIGvwHz3G3decaNj3l5gXp7 bNN8WDwEPjZsZ3LHYsl33UuRlQ/lW97TjTKeauH0XisaYKZ7hpk3tCdtCwlUj+fVx5 dyGd3I9GO1uv/VmvcBlx+HGWVlQ1iJKcV5tNbc0igMIG78S27xb+1RYL5pgIlS+2xu EO+bw2+cCzQlZh4CeC09ySo+LKsbrOUhLY9DBhIf81SKtc6CPhXRhmzmwjuCrjZnk1 OsYXLyVxmDNpHveWbX+OxQ649+Pd96f2LG6dqT5gJ3RRf4B5hBqVoJR2dB7jpHjngR nhEHw3wMjEPew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5B98767719 for ; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) 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 D1FMMGM5SVml for ; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872547; bh=3tW3zR5U5VmoeuPie/wUjk8fYxIy6ZVGo81Oq5d/k3g=; 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=HvJKsrCBFfkZLgc9N31deva1lY6WNRYZBppBYVxXap1J6Bkw51gZ3JN3nvUv2ZIeP Cer5XblZMP6PVo4GLr+cRWfJDPyvjc6Qg1+w9Q0XmuP+9QkwepqGfyVrTq5bLatOaK nMAu/8s1Qav6F891YjEefddzKJz16gthKsyOuaGgnZhBk8ue+QeP9F8Tp41IpJ0vzf ZFdMbfZLgw4Y6hUew2x9V6hGJrm3irgnJ/PVmQ793CjaeuLxg5bq9wo2+WSML/4gi2 gMsNa1TcOR2sqAJgLlSuBnhYatb9VXkKPjA35GolxXHpbASJ+qgmt9KZK4OMNdSTAj Do14daAniFycA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B436675E3 for ; Fri, 22 Aug 2025 08:22:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872546; bh=synMS3mw34wmdw9ES0aEeTlzV2cCCFYQ+8yS811lX/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZZyR5nnXHf+usGpSoKq1+E1cskLR2ZuXzVg2g6TX+p5vHf+HKZxbY2W4rMU/b4mF ii/G41WrfpxgCQQbVL8uVQ9fWdjntm1fWzvpfHbxI8fkHzpQ8LhtpoUk+2Hx6gDtun 87ILLOgt0MeHTTcFxk28JHiJUuVxzKisspxlDhBwm3niBED3MPqoDM6pIhPOhy0x6h Lazgg5X5mR2E2yj12oH9sFjKEnRK1cfNRgkkzFQmtG44GNYCeu9oeS/ed5jkIn9mx/ MDIPQe2fUp6DcAA7NfrBf8jjbooay1oxCR3lXR8tqjAwrq3EExzvjZl2jfHKV47Ezj j6SvfSfxbwfIw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6FC8267714; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) 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 AA79HGNxz_4j; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872544; bh=JbQS4NOGAI2cEVhTRI6H0g+0W3MGD/8QZJ+Pvw64CSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BWxQTQNHNXwRH76x+dkrwdLG65Huualco7e+hmztZrO3CyN72+woGCq9syCdghmFx AJhY3fPiUuZMl8B44z4/EIN/LDp7bufrlY8Utbelh+QNehQXRQfscLHuaQQtL9/sWs YRBrZmJjn6GTuh6aHJg7ExsPYsfxm4/h//uIdPu50mDI4FNvZfnCoqHkPJYxvvAOYv Yu6fkXP82+BoGGFG9ulag9uMCHpGrTn74Z6cUwKraZPVPvGXrEHEXXP+QDKfY0hQoo yFRCa9QwHbQIkXDSdovm1Bvcy42jMGOJQh9htZ4KbURrlHwnkkaIVvVl1e2hlJkXXH gpRuakatxYhkg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 730F5676DB; Fri, 22 Aug 2025 08:22:24 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:36 -0600 Message-ID: <20250822142153.3404275-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 425QMZDGZNRLUATVOAUWCSOD5BAP6XHB X-Message-ID-Hash: 425QMZDGZNRLUATVOAUWCSOD5BAP6XHB 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/16] console: Plumb in the pager 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 Send all console output via the pager. If it is disabled, it will do nothing. The pager is only supported if CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are enabled. This is the common case for more richly featured boards, i.e. those that can cope with the extra code size of this feature. Co-developed-by: Claude Signed-off-by: Simon Glass --- common/Kconfig | 9 ++++++ common/console.c | 52 +++++++++++++++++++++++++------ include/asm-generic/global_data.h | 11 +++++++ 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index 048530adff3..6c54f90109c 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -343,6 +343,15 @@ config CONSOLE_PAGER controlled by the 'pager' environment variable. If the variable is not set or is empty, paging is disabled. +config CONSOLE_PAGER_LINES + int "Number of lines per page" + depends on CONSOLE_PAGER + default 25 + help + Sets the default number of lines that the pager assumes is visible on + the display. This is used as a default if the "pager" environment + variable is unset. + endmenu menu "Logging" diff --git a/common/console.c b/common/console.c index fdccf156b5a..9bc506f0464 100644 --- a/common/console.c +++ b/common/console.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -377,17 +378,32 @@ int console_printf_select_stderr(bool serial_only, const char *fmt, ...) return ret; } -static void console_puts_pager(int file, const char *s) +static void console_puts(int file, bool use_pager, const char *s) { - int i; - struct stdio_dev *dev; + int key = 0; - for_each_console_dev(i, file, dev) { - if (dev->puts != NULL) - dev->puts(dev, s); + for (s = pager_post(gd_pager(), use_pager, s); s; + s = pager_next(gd_pager(), use_pager, key)) { + struct stdio_dev *dev; + int i; + + key = 0; + if (s == PAGER_WAITING) { + key = getchar(); + } else if (*s) { + for_each_console_dev(i, file, dev) { + if (dev->puts != NULL) + dev->puts(dev, s); + } + } } } +static void console_puts_pager(int file, const char *s) +{ + console_puts(file, true, s); +} + #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT static void console_flush(int file) { @@ -407,7 +423,8 @@ static inline void console_doenv(int file, struct stdio_dev *dev) iomux_doenv(file, dev->name); } #endif -#else + +#else /* !CONSOLE_MUX */ static void console_devices_set(int file, struct stdio_dev *dev) { @@ -780,8 +797,8 @@ void puts(const char *s) return pre_console_puts(s); if (gd->flags & GD_FLG_DEVINIT) { - /* Send to the standard output */ - fputs(stdout, s); + /* Send to the standard output through pager system */ + console_puts_pager(stdout, s); } else { /* Send directly to the handler */ pre_console_puts(s); @@ -1101,6 +1118,21 @@ static void stdio_print_current_devices(void) printf("%s\n", stderrname); } +static void setup_pager(void) +{ + /* Init pager now that console is ready */ + if (IS_ENABLED(CONFIG_CONSOLE_PAGER)) { + int lines = IF_ENABLED_INT(CONFIG_CONSOLE_PAGER, + CONFIG_CONSOLE_PAGER_LINES); + int ret; + + ret = pager_init(gd_pagerp(), env_get_hex("pager", lines), + PAGER_BUF_SIZE); + if (ret) + printf("Failed to init pager\n"); + } +} + #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) /* Called after the relocation - use desired console functions */ int console_init_r(void) @@ -1185,6 +1217,7 @@ done: } gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ + setup_pager(); print_pre_console_buffer(flushpoint); return 0; @@ -1252,6 +1285,7 @@ int console_init_r(void) } gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ + setup_pager(); print_pre_console_buffer(flushpoint); return 0; diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 464b9c3eee1..0157fead337 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -477,6 +477,9 @@ struct global_data { */ struct upl *upl; #endif +#if CONFIG_IS_ENABLED(CONSOLE_PAGER) + struct pager *pager; +#endif }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); @@ -618,6 +621,14 @@ static_assert(sizeof(struct global_data) == GD_SIZE); #define gd_passage_dtb() 0 #endif +#if CONFIG_IS_ENABLED(CONSOLE_PAGER) +#define gd_pager() gd->pager +#define gd_pagerp() &gd->pager +#else +#define gd_pager() NULL +#define gd_pagerp() NULL +#endif + /** * enum gd_flags - global data flags * From patchwork Fri Aug 22 14:21:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 112 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=1755872556; bh=uG1K8sQRAdg1MCl+czBEnVCZBbyYI4eDUP4yjZ7qUrY=; 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=abZzKL229Y7JUt4Pnzgw2P6hU5RB/rZ9oY+jE+W9YpG3FsWVNCYlqWn+LBJgH682X 81hBqMnRC+Q6xm7n6uFXHEa+eK/XvC2pADJ/DTSf7LtmWm1mp/bKnkepUACLrY2PHH OLVzAW5u9ITX6jZNXRbkh/53uP0aNTHj8+n5COtifhZ1qV+3puh604ZNLMENb+gmcB xR96CzIErM/3CY6a0SAoDs/sdETRHTnHG8GMyqNwB7JQmp/4WZSXWa4mi/Yyrxmlqc axUi8BWqXs/wufTyv1JPg2Z+XxzcH9G3t0Xyp2DeloY2M/SD5LKyP26TtJ87WWqbeD UweLVkHFkgV9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4EA95674C7 for ; Fri, 22 Aug 2025 08:22:36 -0600 (MDT) 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 xkoO-fvmZ-67 for ; Fri, 22 Aug 2025 08:22:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872551; bh=uG1K8sQRAdg1MCl+czBEnVCZBbyYI4eDUP4yjZ7qUrY=; 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=aaJGgvwqp4yz8VV5LbzhbRjlHayo2TuNzxHhc6w4KtPPe5XxprSHNQzD8atIU9kV5 sW/jiGJRnfI/0W82Edf01KYOSZBSVcmh73eTaJw2KFYU5pWpTnGxNtX7YA0EZlyktx /EOv3m62wBKLSJ294TQOevZqQxaGUIzR6DQUfYPUKtTrI1fNrUQpk5Har9enfPivec lbNIvFQeuTnaX8+nD1wuwtBdUVAmFhsrGxzUuWLwM2Z3xpsSTQFlG+bGRpxveyVoKe 7pMYq0/sfnFfi1TiBGzXcubdXnddWXbef+VPO1i/J7z854eTxKXGJPuF5RnZRn6P1N XqoeNXZC1Zy1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C720676C4 for ; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872549; bh=ThuRXuZPpncXUKSbywChOq9u7FybVvvdhqrkubfwmSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpTkjjBjouXIcL0sgyGhsj+Lu8u3a2BRoQ+HA+KLuj/hftJPhQ1Tj2TBtjFTqaUfy 4oJn5Wc9Osb92Cekk8RAAqI/uR5jmtUV/iqa0gQdde9lgEsuXcY/4BNU1poqPZJM5o xZGgMfrZ8HXli0mkv1q60ZGA/Aji9zZv1Wc6ooMIpgPVjQdkQnyDI+jAzS3CVm6qq2 AzrFiSKH/oiF3UWqV5XepqKGNm0aI+nfza8eBhsDL2k4795K/2O1CUFkDNWWnHFwd1 tRhr6k9+i1r/inH1R09wzJ2NDYJXJkJ4IaFL1sKuqJna9OOCh9cLLdjYb2JS5f5g49 Nrav/6FF9Wluw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 448A567712; Fri, 22 Aug 2025 08:22:29 -0600 (MDT) 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 oSzGxLvertG4; Fri, 22 Aug 2025 08:22:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872545; bh=ihyAgPMuUarEr89AjSs7yEJN28vCatspllQOtiKV+zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I3bM9VOL7Tem3A7+P2s0GFuD3pKS/zh4JlNBbf39AyWh0zAmhc40pGv8fAPpUMcJv 0tzsMBLChB0zyzP6hL0be9/+T2mVD0fP2fbtEeJgFiKuIKxPlB8Li10eeWZ+//Nqiv 28qIj/K5VGGHRaIgUQy5tJxdpG0Q0R+bwBKgHmaqlj2ftvV1r4gwOIwZTeNFd26QZp dKUDQnNKc48utBqQnnhiA/9v8OdvCZabDOkdQC0jB/D2OwnU7F9wdzDRBh2+zTWkXs q4/VrdcYAl1R+0vYfxEBtuLFmM0hlxgtoToUMqGIG03zKOWv1fHGLSL3LdVDZFq5xM aQeleVVnbAf8w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 62EC6676F1; Fri, 22 Aug 2025 08:22:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:37 -0600 Message-ID: <20250822142153.3404275-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PKY4DEPDMFKQ2VYQT73EVT7UDP67BPMX X-Message-ID-Hash: PKY4DEPDMFKQ2VYQT73EVT7UDP67BPMX 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/16] console: test: Allow tests to bypass the pager 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 We generally don't want the pager to be active when running tests, since U-Boot appears to hang forever. Perhaps we could detect when the tests are being run interactively and use the pager in that case. But for now, just bypass it. Co-developed-by: Claude Signed-off-by: Simon Glass --- common/pager.c | 20 +++++++++++++++++++- include/pager.h | 19 +++++++++++++++++++ test/common/pager.c | 36 ++++++++++++++++++++++++++++++++++++ test/test-main.c | 3 +++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/common/pager.c b/common/pager.c index 20aa8558654..a7ad77bea3b 100644 --- a/common/pager.c +++ b/common/pager.c @@ -19,7 +19,7 @@ const char *pager_post(struct pager *pag, bool use_pager, const char *s) struct membuf old; int ret, len; - if (!pag || !use_pager) + if (!pag || !use_pager || pag->state == PAGERST_TEST_BYPASS) return s; len = strlen(s); @@ -76,6 +76,8 @@ const char *pager_next(struct pager *pag, bool use_pager, int key) case PAGERST_CLEAR_PROMPT: pag->state = PAGERST_OK; break; + case PAGERST_TEST_BYPASS: + return NULL; } ret = membuf_getraw(&pag->mb, pag->buf.size - 1, false, &str); @@ -123,6 +125,22 @@ void pager_uninit(struct pager *pag) free(pag); } +bool pager_set_bypass(struct pager *pag, bool bypass) +{ + bool was_bypassed = false; + + if (!pag) + return false; + was_bypassed = pag->state == PAGERST_TEST_BYPASS; + + if (bypass) + pag->state = PAGERST_TEST_BYPASS; + else + pag->state = PAGERST_OK; + + return was_bypassed; +} + int pager_init(struct pager **pagp, int page_len, int buf_size) { struct pager *pag; diff --git a/include/pager.h b/include/pager.h index 7f7df690d7f..9bd99b5c959 100644 --- a/include/pager.h +++ b/include/pager.h @@ -26,12 +26,14 @@ * pager_next() will return a user prompt * @PAGERST_WAIT_USER: Waiting for the user to press a key * @PAGERST_CLEAR_PROMPT: Clearing the prompt ready for more output + * @PAGERST_TEST_BYPASS: Pager is being bypassed since tests are running */ enum pager_state { PAGERST_OK, PAGERST_AT_LIMIT, PAGERST_WAIT_USER, PAGERST_CLEAR_PROMPT, + PAGERST_TEST_BYPASS, }; /** @@ -109,6 +111,18 @@ const char *pager_post(struct pager *pag, bool use_pager, const char *s); */ const char *pager_next(struct pager *pag, bool use_pager, int ch); +/** + * pager_set_bypass() - put the pager into bypass mode + * + * This is used for tests. Bypass mode stops the pager from doing anything to + * interrupt output + * + * @pag: Pager to use, may be NULL in which case this function does nothing + * @bypass: true to put the pager in bypass mode, false to return to normal mode + * Return: old value of the bypass flag + */ +bool pager_set_bypass(struct pager *pag, bool bypass); + /** * pager_uninit() - Uninit the pager * @@ -130,6 +144,11 @@ static inline const char *pager_next(struct pager *pag, bool use_pager, int ch) return NULL; } +static inline bool pager_set_bypass(struct pager *pag, bool bypass) +{ + return true; +} + #endif /** diff --git a/test/common/pager.c b/test/common/pager.c index f72d0f40304..2512652ea01 100644 --- a/test/common/pager.c +++ b/test/common/pager.c @@ -389,3 +389,39 @@ static int pager_test_use_pager_param(struct unit_test_state *uts) return 0; } COMMON_TEST(pager_test_use_pager_param, 0); + +/* Test pager bypass mode */ +static int pager_test_bypass_mode(struct unit_test_state *uts) +{ + struct pager *pag; + const char *text = "This text should be returned directly"; + const char *result; + + /* Init with small page length to ensure paging would normally occur */ + ut_assertok(pager_init(&pag, 2, 1024)); + + /* Enable bypass mode */ + pager_set_bypass(pag, true); + + /* Post text - should get original string back directly */ + result = pager_post(pag, true, text); + ut_asserteq_ptr(text, result); /* Should be same pointer */ + + /* pager_next should return NULL in bypass mode */ + result = pager_next(pag, true, 0); + ut_assertnull(result); + + /* Disable bypass mode */ + pager_set_bypass(pag, false); + + /* Now pager should work normally */ + result = pager_post(pag, true, text); + ut_assertnonnull(result); + /* In normal mode, result should be different from original text */ + ut_assert(result != text); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_bypass_mode, 0); diff --git a/test/test-main.c b/test/test-main.c index 8515a77fe42..4238bb196eb 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -747,8 +748,10 @@ int ut_run_list(struct unit_test_state *uts, const char *category, memcpy(uts->fdt_copy, gd->fdt_blob, uts->fdt_size); } uts->force_run = force_run; + pager_set_bypass(gd_pager(), true); ret = ut_run_tests(uts, prefix, tests, count, select_name, test_insert); + pager_set_bypass(gd_pager(), false); /* Best efforts only...ignore errors */ if (has_dm_tests) From patchwork Fri Aug 22 14:21:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 111 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=1755872555; bh=1jkjJ9jKpmN2Hc867FqlL9YMK3D5YpZfzV+2WQtq7Bs=; 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=auChWIVkzitJiEdJt/r2l0/DTV8EatemLUmKZZQlrkVQzxN/YlF1ij8OJfbT7T3Aw BV5Q2fAgjHf+JgwBPiGkB7M+p2ybaQRzK49QNAsfyjUmP44MqrIvHCyqweBSgKoewL LbI+Or0MfLY9clg0Ii54FE8MCUdrWmn6GPpKcUDAqOa5+I0bccehV1V/AnU28nOnuo aM6+kva3dkQoftB0GFgcrYRF/QQ9JfA6ko8OlpNZs9d6Iwfoagf4hR9UG8qp+9JLF3 o3cYmUtYVDVMcS+4Iq5ajCAw4W8O1B70JbxkxmK7X0gF6YrICmytbsdMYrm5GyCCoq JcNiP8jiw0f2Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE7B16770E for ; Fri, 22 Aug 2025 08:22:35 -0600 (MDT) 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 rFuzrGCZbNjc for ; Fri, 22 Aug 2025 08:22:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872551; bh=1jkjJ9jKpmN2Hc867FqlL9YMK3D5YpZfzV+2WQtq7Bs=; 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=liZW6+ms226glJCOfeAmD8nfe9MdbaIOt0innk906GuV+OQEaFbwwE7jdBEHiPsh5 lyGHXtm5yIsOV+dEPPf+whDHfOI3ngOSN6MNKAkvqr5RzCDZG3eyp23nImKjzV0YAO a+NqHXjIQnpH8R+z0+bMT/rM/ECA6k1galoqpT+EtAzWnBFxKmkj5BRugf8tdleAme FM11ZS/SC/gKMsbfeqqF5ldglo+khsnwoAOAE57fiA7Dkg9xHRYlF4NE4h7HzZRFIv pedpgaXXPI+WHGyRez1kjIICeKhiPQ8x9mcUL6EMHcuspc1U1naj3f0qnDIpoQ6lVw KNiYUB7Fi/Ldw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 043B767712 for ; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872549; bh=TbZZ5yrWmmltJIoskhJZ9wp5l0/1hQ74oQ9GvFWPfmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3mPUPrZYyuw0KyQ4XxieLpadljTEfOXMjVAXyk0/lF4D5SUmZd6JGSld2HB6MTvJ k1L5FPazxIfZt/49NZE3nDoSV4oGP14BxMR0ENdIs+xfejnzc7lmpTjp0j/KruecCe HE8pGKbGn+BVWYUOwI83EiOlKAxTLTxCM/D+cj2qkBUJ/recOKHMm/qRyk2Jwc/vcd gUaoR0XW1qTUipCftvwgtQ+N2lvI/xLhvb450Avm4CMsRGY8TjwK5MwkRLCVaamqsC MHzeAsFS73mz/B/ImCZ4T7bxN4lT9laddWIbRcdU0VqctLBamn7fCvAJHbR7zSkyjU EYlA2QxDKOzOw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 44892676F0; Fri, 22 Aug 2025 08:22:29 -0600 (MDT) 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 fdhNVzV8jSQg; Fri, 22 Aug 2025 08:22:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872546; bh=ARwW9h+XE+uOk3FW+bW4uJmhy6mjHlUKzLndrfrpBpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ds5Xyk6Sy3mWgZVex+w/CHXIhAu3IMJXB1wYDWhGP0QqGfKjSfj5bJPGxRKc1/231 RkYG0HjBG0nG+LwAD6GJurSfq9PnoKLTy1iSPXA/PS2TzufCK4xcPhQ46EtCwt7o9h MKTbHVVtGsMbQMLQzkR/0BxUvDWIcpQ9AR9flUGQGOQUJMobc+K8QpjmCfUrFfzGRp aLMzWc8JtwDHRDwtgQlRacT1JDlA2wtv2Ww3ZLMMcRt7x2/QUmZb1Foq4cJMRGsuRB b6Xxjqlv/B/xY02NhaNzhg7dP+kWuIhlhJCBb8rY7gK7dHNJN8QZdJbZSpg0VpsZBT C+X+qDx+2gqsQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 58AF567711; Fri, 22 Aug 2025 08:22:26 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:38 -0600 Message-ID: <20250822142153.3404275-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FSTYQ73EJZKGZIDCOYXW3RFIRUUT4CW2 X-Message-ID-Hash: FSTYQ73EJZKGZIDCOYXW3RFIRUUT4CW2 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/16] console: Support paging with single characters 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 A single character may result in a stall waiting for user input, which means that it may request that a string be output. So when the pager is active we never actually use the devices' putc() methods. Add a special case so they don't go to wrack and ruin. As before, the pager is only supported with CONFIG_CONSOLE_MUX enabled. Signed-off-by: Simon Glass --- common/console.c | 22 +++++++++++++++------- test/common/pager.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/common/console.c b/common/console.c index 9bc506f0464..7bafe98375a 100644 --- a/common/console.c +++ b/common/console.c @@ -322,14 +322,22 @@ static int console_tstc(int file) return 0; } +static void console_puts_pager(int file, const char *s); + static void console_putc_pager(int file, const char c) { - int i; - struct stdio_dev *dev; + if (IS_ENABLED(CONFIG_CONSOLE_PAGER) && gd_pager()) { + char str[2] = {c, '\0'}; - for_each_console_dev(i, file, dev) { - if (dev->putc != NULL) - dev->putc(dev, c); + console_puts_pager(file, str); + } else { + int i; + struct stdio_dev *dev; + + for_each_console_dev(i, file, dev) { + if (dev->putc != NULL) + dev->putc(dev, c); + } } } @@ -757,8 +765,8 @@ void putc(const char c) return pre_console_putc(c); if (gd->flags & GD_FLG_DEVINIT) { - /* Send to the standard output */ - fputc(stdout, c); + /* Send to the standard output through pager system */ + console_putc_pager(stdout, c); } else { /* Send directly to the handler */ pre_console_putc(c); diff --git a/test/common/pager.c b/test/common/pager.c index 2512652ea01..c1c2d40f648 100644 --- a/test/common/pager.c +++ b/test/common/pager.c @@ -425,3 +425,43 @@ static int pager_test_bypass_mode(struct unit_test_state *uts) return 0; } COMMON_TEST(pager_test_bypass_mode, 0); + +/* Test that single character output via putc goes through pager */ +static int pager_test_putc(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + /* Init pager */ + ut_assertok(pager_init(&pag, 20, 1024)); + pager_set_bypass(pag, true); + + /* + * Test that individual characters can be posted via pager API + * This verifies that console_putc_pager() routes through the pager + * system + */ + result = pager_post(pag, true, "A"); + ut_asserteq_ptr("A", result); /* Bypass mode returns original pointer */ + + result = pager_post(pag, true, "\n"); + ut_asserteq_ptr("\n", result); + + result = pager_post(pag, true, "B"); + ut_asserteq_ptr("B", result); + + /* Disable bypass to test normal functionality with single chars */ + pager_set_bypass(pag, false); + + result = pager_post(pag, true, "X"); + ut_assertnonnull(result); + ut_asserteq_str("X", result); + + result = pager_next(pag, true, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_putc, 0); From patchwork Fri Aug 22 14:21:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 113 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=1755872559; bh=phHs83ZtF7fEGS36hE8CxeRUZ0RRw0HBOGZESNaDFww=; 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=P4wchXtV1XXnyhvklc6exSBUWUQhKnao0IjTQt9D9HUIccS5jM6r9+aQc9o08DzS0 e04+NXr7aSaEe4YyP/+xX97Na8zayY9Yn9BBsw6RpP/83cuv6ow6T6TYU2xbf89C9s cVXODr8HlzLJTil0hbh/mDRSCvu/jzLvv1QyXWFMdOQl1kDTk9gzjfgI61B3+StZPV ib60X9whNUGTx/eZJmC9PzcWm4v7gpm3KU58brtNa/VI0ODFtTNAYJOqo+x7BqyHaV Zdz9bb806I4m43ldjH7Qx+HztbQ42Y0P5SxNJ8OoxHSHjk064z2yKHwfkiQQXbbYmv X8xHvdJvMx4RA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02EB3675E3 for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) 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 PlqY4DH6iwNT for ; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872552; bh=phHs83ZtF7fEGS36hE8CxeRUZ0RRw0HBOGZESNaDFww=; 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=amWEQIcI2BWRmcp21TRq/8QtNEUfiJlZHjYwkxmB1XGLfrPdfCyHhDteDunWS7+8E f7HoAr4FklCZlR8v7YyZo5BSGdOaGc5LS+Hc42DfnydldKTTfSwQxP5jv4scsDQ248 fwsHu1wYfB4Ibl5BbRMqQhMrE8aQ0YZBwjMQomMtyj14OJBn3v22DaSN2QLPYlqp68 jxKPNSUuR63TJ1NCZBSjEe49MFHAafwcw33Kr0s6ExGZTJyHgdTunIeVeUmh/SSAvR TzDGVMjzJ42YidBMEDJQTRCCq80fEQCUrkVglaVkkp2FGYTJIlYHgtNm4ZmCSdFoIY FUsWSaj/HKOJg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D901D67718 for ; Fri, 22 Aug 2025 08:22:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872551; bh=mwPkGNpJkHC8Ak6hwU0k+2xFSvozb3p4PbF/UtilklY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgfTf6C8yLRONiEG9x9wFOohIsYHUSZBTMQUoC8GRi9yZ0IBW8W0qT2Q04bCxRxbh yb02kwP6nEv+v4tutclTZ1VAlcTZyB0+e7qyix2SIOYs99huDRABgTvo8hVzdCY6n+ I8GviiPQPJym6qvqZb4QWT0Em/AEHzGJLLTXsiZRRxJ/hja7UV3yiEny78E75WMaOu +yO9JftuSnZnWZJYUxt9pm7XjYNyUxBdOHFraPJRMpl8N/7z88DklPHeZ9Sf+vFnn1 Dy+A8WFBqBY2mufAYUKjbkzYqyJ6QePHmgCFaFHiIiv8z7g4JHHU7/w6CP0XPV4QNy pRQ+K3NA/rywQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 742C76771A; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) 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 R4uKZmnol_sS; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872547; bh=3ULt4ricpU0Am7nx/yMNGGV3IDNIhaFXwrnMC32mECc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=usn1TnVZ9Wg+fS0lpMKVS2dDGfKMY/wOAycX8zJ3NlLvbYdovJnqV8INkSN4nTifk LZvEVxJmhCT05MKMxyxbEBvCZUjWIBUIne8GaqLBX44yhfkoHjpgazs6+8nwjxhtL1 O+XX++KCam7lo7Ycf/1vDfVInAZXGUIwY6ZVTzg4b17JvaOlCQVfCfgfUDNHr6OBSO Qq/O+kx/Tjtv7SQKH30woQn/txS3T34OYHfXLJxsB/PVOcMw3v6ePl/goufyzj37LS 0nBDlO79KOyjR6+gHHHtt8A5wjut/3wVEby6hqCeJP86SAl0fDbqnQgQnSU59mDIQb 66teR1Qu3UclQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 237C3676C4; Fri, 22 Aug 2025 08:22:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:39 -0600 Message-ID: <20250822142153.3404275-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UATUFAJXNAKJWVD6D7FA2YEUPOH2K5NL X-Message-ID-Hash: UATUFAJXNAKJWVD6D7FA2YEUPOH2K5NL 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/16] console: Add a few more paging tests 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 Provide a test that the prompt is displayed and another that paging happens but does not appear in the recorded console-output. Signed-off-by: Simon Glass --- test/common/pager.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/common/pager.c b/test/common/pager.c index c1c2d40f648..792f5f24153 100644 --- a/test/common/pager.c +++ b/test/common/pager.c @@ -12,6 +12,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; /* Test basic pager init and cleanup */ static int pager_test_basic_init(struct unit_test_state *uts) @@ -465,3 +468,109 @@ static int pager_test_putc(struct unit_test_state *uts) return 0; } COMMON_TEST(pager_test_putc, 0); + +/* Test writing up to page limit then adding final newline */ +static int pager_test_limit_plus_newline(struct unit_test_state *uts) +{ + struct pager *pag; + const char *result; + + /* Init with page length of 3 lines */ + ut_assertok(pager_init(&pag, 3, 1024)); + + /* Write text that reaches exactly the page limit (2 newlines) */ + result = pager_post(pag, true, "Line 1\nLine 2"); + ut_assertnonnull(result); + ut_asserteq_str("Line 1\nLine 2", result); + ut_asserteq(1, pag->line_count); /* Should have 1 line counted */ + + /* Should be no more text yet - haven't hit limit */ + result = pager_next(pag, true, 0); + ut_assertnull(result); + + /* Now post a single newline - this should trigger the page limit */ + result = pager_post(pag, true, "\n"); + ut_assertnonnull(result); + /* + * Should get empty string since we hit the limit and the newline is + * consumed + */ + ut_asserteq_str("", result); + + /* Next call should return the pager prompt since we hit the limit */ + result = pager_next(pag, true, 0); + ut_assertnonnull(result); + ut_asserteq_str("\n: Press SPACE to continue", result); + + /* Press space to continue */ + result = pager_next(pag, true, ' '); + ut_assertnonnull(result); + ut_asserteq_str("\r \r", result); + + /* Should be no more text */ + result = pager_next(pag, true, 0); + ut_assertnull(result); + + pager_uninit(pag); + + return 0; +} +COMMON_TEST(pager_test_limit_plus_newline, 0); + +/* Test console integration - pager prompt appears in console output */ +static int pager_test_console(struct unit_test_state *uts) +{ + struct pager *pag, *orig_pag; + char line[100]; + int avail, ret; + + /* Save original pager */ + orig_pag = gd_pager(); + + /* Create our own pager for testing */ + ret = pager_init(&pag, 2, 1024); + if (ret) { + gd->pager = orig_pag; + return CMD_RET_FAILURE; + } + + /* Set up pager to be one away from limit (1 line already counted) */ + pag->line_count = 1; + + /* Assign our pager to the global data */ + gd->pager = pag; + + /* Trigger paging with a second newline */ + putc('\n'); + + /* Check if there's any console output available at all */ + avail = console_record_avail(); + + /* Restore original pager first */ + gd->pager = orig_pag; + pager_uninit(pag); + + /* Now check what we got */ + if (!avail) { + ut_reportf("No console output was recorded at all"); + return CMD_RET_FAILURE; + } + + /* Try to read the actual output */ + ret = console_record_readline(line, sizeof(line)); + if (ret < 0) { + ut_reportf("Failed to read first line, avail was %d", avail); + return CMD_RET_FAILURE; + } + + /* + * console recording does not see the pager prompt, so we should have + * just got a newline + */ + ut_asserteq_str("", line); + + ut_assert_console_end(); + + return 0; +} +COMMON_TEST(pager_test_console, UTF_CONSOLE); From patchwork Fri Aug 22 14:21:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 114 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=1755872559; bh=2woP0AgfnS1lA3/AKx4S+y09gC1103+EkDgv2im4JH8=; 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=rsLl9fxZajeQ1eX9gOhq8v11UpWI5Sit+Kzy+wMHW7fpWFkewCl/YaIdlvAXcXrn6 gm4mtegvcF5q5jRDBLQLmhi8Yz47194Qv7hxDS5rtqW6GutiKsNz1mN+a+eH7cg/mM 6LQGR78ZOwEpAMaUrUcliRvP3Yx5iMtG5fuWhVKzjtr6qAwR9gqNkSeasmp5nngxWF 11Q6q3xJaYGBjXJfYbmRdWL6Y5hPXuYXPVf5gBiycYEVWC0M0cm6d89rTe9I8rfdCQ Z9l2IHzNFysmG0yx2LuReVqijAN/7Wi5fuxz4nHDIZHyJkIuzSU0NsFgPtQTiWQuEJ pFACZPhjyDqHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70B7F676EF for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) 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 A7lDpO1PU6QS for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872555; bh=2woP0AgfnS1lA3/AKx4S+y09gC1103+EkDgv2im4JH8=; 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=O+0GDs7MvN/joYPbAe5NCRNK6ng689eYiCGszHwxzOVirHmDE4dLO08jnIipuSeo8 aM5SIy7Vs9j4xa7Gina8C/Xm1yXMEppzk9cE8JOWbfdQBZbJF3n9Y4Jzytg6wLjTUY 820hN5npyo8A5tEAiVXKtVr3oD7SOCfCifxy5B7RA5ZjyBXy5g4jWWSvQ482RC+9WY KNAKK0gyDJ+haY5PpRC3/p6Cl/mxsWGPBrZvApKyfMFhh8lGueL5ElkAA0mttGpBVF tJkD9kmNHBU8QsvBrrTFIQWvtr/bJXhVCKAHmszlDllFMkgRG1xr6ISz7/8s3h0MEu +F2jpg9mKxBhg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BAE80676F1 for ; Fri, 22 Aug 2025 08:22:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=PdWvNC39qec4gcm3EHTM5C1RWpurEYv9juclrKsMYiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwbA4lWMS2NfOM2jJ49exhOtbRoIcUU3tuzvQQF16cvv1K3JS/82Tx9Twxa8OIvqJ yDHNJ6Pr4difI3vTXICLuIqOlN19uvoZ1ooykkhCQ/U/rgimPaqOUTIahpw2DWR+Bx 7IzvrnGuZFzdkexxXiFu/4hnUpkZSHZK1fzZvpdsktNMTvejRFrgCihV2oX1uaigwh 7gcNVjuqy6LXc94svLAOWL0cVb1/imdUUAe290t9VhpT9dKNKxDiPoxQ4LI/evkwL1 f0ayh8WohYfHO0LZX6Veeypnf8H47cpw/fpXS/cWYKOuidtc5cHXIkc1VaniwjxRhQ 7VOioD+WW/0GA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B00FD67722; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) 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 bCTpPgYroYkL; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872548; bh=mwjhIRD64D8iNxjM8Z2ulbKVLhG6w3q+1hd/GzeR5Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6tKRFNxpL1PXHvPjfzXGRk5viwhEQhLajyb7GjIse0MCIS5R03M2W34GmnEUIHio tTrLawozAdR09FhJn6GPRlOORGlS1HX15/YiwPUjZOD1JJTzRAgC8KcKkGHYzLYlqP S0G06VtDrYFOMVDEacMHyfs9n1LBsSVtSAjTIL+cVXgI9ZH2HcPQeCX9qtHw2JTFqR VQgVjsyUm0OQ5DR31fBh3IXClJQPQbSuUatPGUUFLMTHLYhWWUN/I46+qc06On6WNJ pFAiplHiKw6x8Ul2JT2fszea037GREY2GShnC0G/G/TpWzcnqbqtrW75bKxOEp/MXj RJBHFEyKxBNDw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 045966770D; Fri, 22 Aug 2025 08:22:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:40 -0600 Message-ID: <20250822142153.3404275-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BYIIPTEZTNJ72JRXEZ6OHWUEYDE5EAX6 X-Message-ID-Hash: BYIIPTEZTNJ72JRXEZ6OHWUEYDE5EAX6 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] console: Reset the pager when entering a new command 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 We don't want the pager appearing when entering commands, so add a way to bypass it. Reset the line count to zero before executing the command. Signed-off-by: Simon Glass --- common/cli_readline.c | 13 +++++++++++-- common/pager.c | 15 +++++++++++++++ include/pager.h | 13 +++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/common/cli_readline.c b/common/cli_readline.c index 4e6797a1944..2326e4b4f37 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -650,6 +651,9 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, uint len = CONFIG_SYS_CBSIZE; int rc; static int initted; + bool old_bypass; + + old_bypass = pager_set_bypass(gd_pager(), true); /* * Say N to CMD_HISTORY_USE_CALLOC will skip runtime @@ -673,9 +677,14 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, puts(prompt); rc = cread_line(prompt, p, &len, timeout); - return rc < 0 ? rc : len; + rc = rc < 0 ? rc : len; } else { - return cread_line_simple(prompt, p); + rc = cread_line_simple(prompt, p); } + + pager_set_bypass(gd_pager(), old_bypass); + pager_reset(gd_pager()); + + return rc; } diff --git a/common/pager.c b/common/pager.c index a7ad77bea3b..69b05dac5cc 100644 --- a/common/pager.c +++ b/common/pager.c @@ -141,6 +141,21 @@ bool pager_set_bypass(struct pager *pag, bool bypass) return was_bypassed; } +void pager_set_page_len(struct pager *pag, int page_len) +{ + if (page_len < 2) + return; + pag->page_len = page_len; + pag->line_count = 0; + if (!page_len) + pag->state = PAGERST_TEST_BYPASS; +} + +void pager_reset(struct pager *pag) +{ + pag->line_count = 0; +} + int pager_init(struct pager **pagp, int page_len, int buf_size) { struct pager *pag; diff --git a/include/pager.h b/include/pager.h index 9bd99b5c959..fde502f3edd 100644 --- a/include/pager.h +++ b/include/pager.h @@ -123,6 +123,15 @@ const char *pager_next(struct pager *pag, bool use_pager, int ch); */ bool pager_set_bypass(struct pager *pag, bool bypass); +/** + * pager_reset() - reset the line count in the pager + * + * Sets line_count to zero so that the pager starts afresh with its counting. + * + * @pag: Pager to update + */ +void pager_reset(struct pager *pag); + /** * pager_uninit() - Uninit the pager * @@ -149,6 +158,10 @@ static inline bool pager_set_bypass(struct pager *pag, bool bypass) return true; } +static void pager_reset(struct pager *pag) +{ +} + #endif /** From patchwork Fri Aug 22 14:21:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 115 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=1755872559; bh=S2pSC79qiDU1qoe/Qn2A0jAWkP0S9nqZIRpAXtVRY0Q=; 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=G8CiGFVuKX8Vbt8FaLBmRCEgqduGLw2oAFaiErvVMT1FKVTKv6ebJ3DuUdDQb2RAe UQbNPukumifOSYzGu8Ec6yWWeySDLowWuRfNKbGsT4Yn7sBkqekt3TyBHH4JwDXRkn Kh3WISUj/QglwXFdYsBB+BkmVhP6lOLrsjWN9sOCxq0Do9ZjFFlY4EeVOL8Xpby6cd vQ1Quk/uWq8kChy0Yo3CLiGBCwDSAU8RhmgYqns1jQXb4mZSufrokc9Mi+EpDVRewW bT1yhn3Ick1Gh4cdPar1xk7Rw5C2kfGz0ly1WY96LGvQGF98kdMNNCm0mFGCeIJNZ1 Yj3SdO5A3Mb6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E00BE5E45E for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) 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 xrFKIjO_WLbu for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872557; bh=S2pSC79qiDU1qoe/Qn2A0jAWkP0S9nqZIRpAXtVRY0Q=; 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=jFeKX+BrD9xIWWcH4GUskLuhVvas7+v6tl45G6Y0+U0VEwkHFAi3CVbV5srGgsFrd hKcskKmt9XmKE2q6xV2Zpq32wNg8UU7r41tnxCF/uTugjglJ9HVtv1T48iwhP3ygiv wMvrZ9E9r6GBL7yfhZSIheZcI1HE3UUqrOiECu33Mh7E4+S1oMHrYrjwoyNjKcDgMd fdVCinVkgRH/DeYwGS5RW7i652mf2RbC9MzKW2jynJNiFEoD1W/BU0JLt9LTRaOrk0 88DBaRioq9Vrl0/E6CC7JJDDTbfxT8pZgJsvaq15Bf2PeoionAkYGHLjk62k4WLiw7 +yd1OYR4hpmvw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18F166770E for ; Fri, 22 Aug 2025 08:22:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=qZkH0AZHIiwPu7XdOo62OEzEZ68EAvI2owfWSr6k2cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOA1m4829DWRCFP7YSECR3OZvn1AlAi46PtwL9RsxTai6aGUskMVkpe8VBPbMeZ4h rQTv1oS6QVsfJW8HyseC9gD8JObPlebEC0s01FOa57PrbMUKSm/aunz/Ng5ztLGa51 rBRGkPslHXAhOtI8xBVaqG13pbK9dlZOJ8EBO8skoFIrkMOzcBIoltQ0c4RHmm9dUv Fa2KIBriIUHKWB6ZagzS2S5ZXrWnbiXqPP2GIYkvQl7i84g92PUJf4mPzq3gDdltdL D3WCUgcHX//I0+53oXS7F538R+DVXEQWEuEejpSKRjz5dRm8Q9Aen7e8E7fXgWJHkL RYHJwtDyBSw4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B00AB6771B; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) 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 cqYYnCy_KoIz; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872548; bh=DYQVf7R7V5yXdfXNUzXoLqM3MFbLphg/09xxxPhZVpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVlq6wMEGB5r6NYRWwQTWI8eRNIkGD9VER/RzrIKQRiUwO0Ux+AvGO78KYWmqoFvv K5sUs5WHZ1jedBEOjEz/e/JtG46eiQgBbAocMbHrEpLwlPW8aJhpe9MCcKis92NZyR yZStYlBubVn44vg0GAFzWxYtdLwHKBoic9DdA4/0sA0anWT9uTlKXWaI1hlI84TVwk 2k5Z9FwHQT4qoNailn2P2YwOmjTNwToym+TYb50hu1+lRTX8Pjw66mool7cWXUgmIY eR41uy39WWn9wbCUSKq+nvs7x0V0DLSTzDw1CZOjjwvyIsqYbItYYJDNSdqNFMDFGk ifL9SnZyfLbdw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B3CE86770E; Fri, 22 Aug 2025 08:22:28 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:41 -0600 Message-ID: <20250822142153.3404275-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XQQXFZTMCIU45OHUQME3BZKL4GUGXF7V X-Message-ID-Hash: XQQXFZTMCIU45OHUQME3BZKL4GUGXF7V 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/16] console: Implement an environment var to control the pager 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 'pager' environment variable can be used to set the number of lines on the display. Provide a callback for this. Signed-off-by: Simon Glass --- common/pager.c | 28 ++++++++++++++++++++++++++++ doc/usage/environment.rst | 3 +++ include/env_callback.h | 7 +++++++ 3 files changed, 38 insertions(+) diff --git a/common/pager.c b/common/pager.c index 69b05dac5cc..fda02c9a6c0 100644 --- a/common/pager.c +++ b/common/pager.c @@ -7,6 +7,7 @@ #define LOG_CATEGORY LOGC_CONSOLE +#include #include #include #include @@ -156,6 +157,33 @@ void pager_reset(struct pager *pag) pag->line_count = 0; } +static int on_pager(const char *name, const char *value, enum env_op op, + int flags) +{ + struct pager *pag = gd_pager(); + int new_page_len; + + if (!IS_ENABLED(CONFIG_CONSOLE_PAGER) || !pag) + return 0; + + switch (op) { + case env_op_create: + case env_op_overwrite: + if (value) { + new_page_len = simple_strtoul(value, NULL, 16); + pager_set_page_len(pag, new_page_len); + } + break; + case env_op_delete: + /* Reset to default when deleted */ + pager_set_page_len(pag, CONFIG_CONSOLE_PAGER_LINES); + break; + } + + return 0; +} +U_BOOT_ENV_CALLBACK(pager, on_pager); + int pager_init(struct pager **pagp, int page_len, int buf_size) { struct pager *pag; diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index 1ab3ee7ced9..6235d7276f0 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -335,6 +335,9 @@ netretry Useful on scripts which control the retry operation themselves. +pager + Decimal number of visible lines on the display, or serial console. + rng_seed_size Size of random value added to device-tree node /chosen/rng-seed. This variable is given as a decimal number. diff --git a/include/env_callback.h b/include/env_callback.h index bc8ff1923e1..dccf0bd1464 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -75,6 +75,12 @@ #define DFU_CALLBACK #endif +#ifdef CONFIG_CONSOLE_PAGER +#define PAGER_CALLBACK "pager:pager," +#else +#define PAGER_CALLBACK +#endif + /* * This list of callback bindings is static, but may be overridden by defining * a new association in the ".callbacks" environment variable. @@ -88,6 +94,7 @@ DFU_CALLBACK \ "loadaddr:loadaddr," \ SILENT_CALLBACK \ + PAGER_CALLBACK \ "stdin:console,stdout:console,stderr:console," \ "serial#:serialno," \ CFG_ENV_CALLBACK_LIST_STATIC From patchwork Fri Aug 22 14:21:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 117 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=1755872560; bh=ANRpv5pK8uqPgKxCcokd70Ld9X0knPl0vs5DpW3lUcA=; 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=DryiN5MUfKMGq3vSt8lOHLLn2iec1N1tiYyn65XWiWBBcOuDlsI9nyLkg5wGhh+CE rrncTME2joI3Npw3WkhUDkCkch3KIG0iA/4HZCwGq9HWBU5hBj6aYxsSDlOu1aKzW+ T2LUSKWrLyjw1CqAbwgKnBzU5XonUcnYbI5zHB+sJ7M45ncloRHsrP2JUbhU2ypFlc pymLvadiV/PUKE4hwi1iaL2/lxjFW2iCwOzaXbBVSwEieF7mQ6D1nSVLeiVJp6pv5y 7Yjd8KfTJBGbRJQJh/DBB0hnnFbKsB2EueB7Lq+igdKRjDwA/1KFbbM+AK7NAWlYtp Ba1/Rtv6k+KXA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA7DD67705 for ; Fri, 22 Aug 2025 08:22:40 -0600 (MDT) 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 Sv-FK8V9Pbxh for ; Fri, 22 Aug 2025 08:22:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872557; bh=ANRpv5pK8uqPgKxCcokd70Ld9X0knPl0vs5DpW3lUcA=; 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=wPxfWnr2eVx/LIfc0kHCsffxyGzkVY5dp9eRNp7YEKMUv5Qin2krg9Ak36DbJxnup uvdBEXxgiBU6dC4yIsOXFcXmAh1G4JQsJemCVxH0tj7X9Zvf1yWpwZtHkvAUGnzRRD UPq0w+9RdIhOeMeQ7wkxuuuc0KzORCBTnqZx2TVlkcVYfIbrrzE019qg3qgwUqgzcY Qi7v9Hced5bz4xfQlmq+JeKtGOv6ix58OD8/TSQzzGfWaOqM9lsi9F7ZDmrYVbwvMY FbzRSdoM3zMapuS8+JZkhYh9k11ZuGWB1lJbmRByM1qIkRWwrZ+iOu+5lgaIWsgFkc yjwvZISXdmqkQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C103D67727 for ; Fri, 22 Aug 2025 08:22:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=MhYhxbnUpPPoJbzQX68iyfaa6IycNwHUVE43TBXLwwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M6B82qsmDvtsgQFyaZi+d/Y8iv2e8W+fDrAv58cvCztJtSRhxYDrAc/PK+RQz7Tqs g8ngmhT4gQV6cZGcqmbLdB//U6jgH1PTT5vKVBuI7/Z/bOVTTIBjYb7SvEnIkSrnf4 jZg+DXYPYWkBDXDmGkbrH4BnKuzyBRiO6KJaoAd2bjqT3xBBLQ7BHTfefBiYj+ken9 rfVFtDCe33s+Yc1jqBs4Fzh/Zl885WELgHzDcOt3tKNpPAZo/Ui/bU14HnMmeAKImI +wC9K792aY2zwoBLCMnuqYsbFZkYpUky9p1ibtu190F1O3zMoxROa5K7f5lz3ItcF6 C//IB9hCNruhg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C35276770D; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) 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 7OiMJiqJfsXk; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872549; bh=izkZjVyCz9tWJoxC38FeVDnc2d2jIU9+fqFkBMVddv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CdS18z54f+Cg+BQwuStL140QVl7jT5OWPeT0q+nIN+1oddjfrDnWAjA6eKBmeFOeg ++9txcgbQxzOgVHFzjS5IoVAR8+tzb1TAECnmWNO4419QVQaBGWKN6QJFXh/Wzrf/j sHFmES7HXUg6rqsQ4pGTXOhAKW+TkAZJftK4UrATsHZS6zcz2pArVsgIsTycnvl25W Da47linxBtrlOK7K0CslADM26KkFWJn6F1IwAcsKyCMM8RITMIMzv9aJm0GUfR1sGB GOOB0Kj25fOMyoMxqZOFFX+yT5NTQTldYUkaPw2W0xzfSM6Ywu2xbdMkWivKML/TdQ GIe0jTUA5oq3A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 71FE1676F1; Fri, 22 Aug 2025 08:22:29 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:42 -0600 Message-ID: <20250822142153.3404275-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YXDHRLYHDURUADQ4E4DSL62CK72GA5IG X-Message-ID-Hash: YXDHRLYHDURUADQ4E4DSL62CK72GA5IG 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/16] console: Get the pager lines from the vidconsole 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 If there is a video console, use that to set the number of lines for the pager. Signed-off-by: Simon Glass --- common/console.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/console.c b/common/console.c index 7bafe98375a..bddbde9de5a 100644 --- a/common/console.c +++ b/common/console.c @@ -1134,6 +1134,21 @@ static void setup_pager(void) CONFIG_CONSOLE_PAGER_LINES); int ret; + /* get number of lines from the video console, if available */ + if (IS_ENABLED(CONFIG_VIDEO)) { + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_VIDEO_CONSOLE, + &dev); + if (!ret) { + struct vidconsole_priv *priv; + + priv = dev_get_uclass_priv(dev); + lines = priv->rows; + } + } + ret = pager_init(gd_pagerp(), env_get_hex("pager", lines), PAGER_BUF_SIZE); if (ret) From patchwork Fri Aug 22 14:21:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 116 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=1755872560; bh=VXGWvAAiv9PFTkdRm7KgGX9FgHjpDUfBGaHyYf2xiW4=; 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=Ql0DRxe1hfyHxHTnweNIvjDtjvTDG8ujnA7kD7Ch/9ZeMDwRh3aqSj6O6Kg9WZaei stG2ThFJw4/x9WWblqL4ffPck+NYIMB2bzRH77Zeeuab2a99kiaQRGrfgAq0DFXzJv EVbqrFszpJsGTqoWqvzFUKgHJJyRgaQaflGWfY1Mor5VgRSTpFMZA928zUe1lz7J+y n2pAp01Ab6Ro94Xtwh6Ac+NT18zOrNfhbz9+tTHnKaNNeY0b2eRCnfikQkTTtoDBHf 83fciZmcQpAObaVo60j5xoQVUByg373/uwosXn/pO0yFyvq9oDd4NQLAsHhnJXKZZs Tsbu/FoJHP5Rw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 59AAC6770B for ; Fri, 22 Aug 2025 08:22:40 -0600 (MDT) 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 PVNkVkT-bh-3 for ; Fri, 22 Aug 2025 08:22:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872557; bh=VXGWvAAiv9PFTkdRm7KgGX9FgHjpDUfBGaHyYf2xiW4=; 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=cczy7KZz3Xp0ISsO4Z+rzBnUtAeUaocqoZzJVestkBvGvr0GhmHVlAMkmADsgPcfA A7eLlMEp0Pqh5cPlOfuUHoiepij8uT91qBINqHaIU1RAofBlj1AuCXl9X8lcGhjfQW eu5wlc8HMhzNdr08OVEfZqbOQd1y2DKy2BhC8AU8KvklFNR3tW4OBx50nckh25AVZd rYCg/8YFm3eD9Yj+RMDOz+LeFIucjCSs0pV1ZoGfiqJEPc71ziWeKoiLaZdjRPZRZp 97ZmG69Y0lnqPwPJuLlB7wisFRGONbSTk51hMMbscfVS4ITVXsLJjpJWbzKMHE41dm pU758YqR4Ia+w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2D267722 for ; Fri, 22 Aug 2025 08:22:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=3HQfupHb2qo0iv570NJnKxMBP7sreoIaxHMUWYWpXyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBMQbN7JNhMDMWewi+N+jVkDmOsL7X5hwccHBDX4VBtA/1Bw+hFFwf2igfK9huLzO tNjnXX4zaMEQwP0NI0Wz62ZeujkCyNqc1zbKVQ2YgvtrFNf5SHUxJKrwv9Jxa9AaiQ nLkXg0FMqXEniG+Nj2uDIS8Z8ZPgHUqfH53Q4HMt0atBlUawU6XLe2pvF0CAWY+55g dryZQSgswzYYX8EV60szohPuniqETg8dibZuUXiQXgHEodWn3Njovy7Xies5/RqVsA QrUX7yR8sOMUvXeuVrEu6cmI6LYVEjy1upfr6VpzVzZtCWp2Yreykis+LzuTbcdD1w /8m8lqDXEzmpA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C35356770E; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) 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 D4LIHrLE4S7R; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872550; bh=frgQGl25udbekrBiufVEi1WnQ0vBdRiFuOJ7AoLq17A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JC9IL3jdccK6Mr+U/NW7lx/T4M2KUl/3DUavX0vY6+2RVCzJG1e6KWxGuK0oCWD0T 5ae7IStncOj7XOIDkQ4jvzcH9NpT1ThmSJREfA5svREbMaJmd87LI9pkS1CEfNR1LF X3Dc1XGECZTWMqIHyfVYAsNaXrXGYDEST+0KUBzThznnU7TPygfh68uebuua3O4/JU V1wo2HQZch+JQbn4RNBrbWhzylZlxi2RntRICTB4X2KqbWgDURyy05VHsPFO0T+1eS NGNAWFXXVVPmWQ6JPI9lhVqBVKuewAslnG0kUPIc7LLPEW7I0JE+8/E687GwYXyxS7 rYVju0NOGr9Ew== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2D6D6676F0; Fri, 22 Aug 2025 08:22:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:43 -0600 Message-ID: <20250822142153.3404275-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZHL57WZQQHHYTJL4RZTWO2YZP3BK7JZO X-Message-ID-Hash: ZHL57WZQQHHYTJL4RZTWO2YZP3BK7JZO 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/16] efi: Enable the console pager for the app 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 app can produce quite a bit of output, so enable the pager feature. Signed-off-by: Simon Glass --- lib/efi_client/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/efi_client/Kconfig b/lib/efi_client/Kconfig index 743181834bf..5726e91e814 100644 --- a/lib/efi_client/Kconfig +++ b/lib/efi_client/Kconfig @@ -22,6 +22,7 @@ config EFI_APP depends on X86 || ARM select CHARSET select EVENT + imply CONSOLE_PAGER help Build U-Boot as an application which can be started from EFI. This is useful for examining a platform in the early stages of porting From patchwork Fri Aug 22 14:21:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 119 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=1755872563; bh=p/6Xnzis1nQ/dV3bj5lOexcKI+Za6YCiS129USoT4G4=; 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=EJ76XmjQHb3kAyw0FctRcf0uiu07eCpgdd6l0CT5A96dyjz38JhyLlTK8TQfE+dMj ZAP2AbU4UCCoyydzFMVi4cUGq3DgIQUKZmNIN5uIcqq5YRtbpkFcUeRfFUZxb25LdN 5rsgLjmW+wndfnVgvTZJIBck8Lj8xQ+mefuLCyMW5gAr8se1yYtbY8D0EeNkDqilwN QA9EenKQHUKAO+AF04neN9zpKy0HFDhbMEbDmO4PsD8CDTDxgxuB8+C4Bsl1wEdlan PTzqrg00RXPqIqhzjiQNdJ1jPJPnYkvlgduMLNFarMXRQfEnC9NlA5Mj7KfcsvUVHM NDmskCTpQiaHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 84ACE676DB for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) 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 VbJTkyKjUumt for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872562; bh=p/6Xnzis1nQ/dV3bj5lOexcKI+Za6YCiS129USoT4G4=; 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=vgfgXIlOW/N1RKaZ6cPb0v2T9mRl50kY024CZhpdtIajxl+P2yhkJ3KgZ78pU4F7h ctE9/aB804J2ISaCk8gw29oWo0jK+Q0zlCUGNdx11e2V5taFAajgVWqMLcL78ZfC09 9IvpOnrsOYIefZBGvEAmLiJ0YaUXLBA41CQPa5uaR1wJOXo7tsYCxEiUBYs00TS/jV 4s1IMsuwT0OshH/6Y8vAh1psTouK5Fm0uu/Dh5s0phjvwN3cMyuaBxdgPgQrYgqkse EeMs4jUc3AZFYY2rd/8qWt8uTHscAe0Zgsfluiq2qoQUvdRSvirdd3OCQs1pb3i4fR zNZKZW+LWQENg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4ED605E45E for ; Fri, 22 Aug 2025 08:22:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872558; bh=mnHeidqBienHXMr3IZnndVA8+awErrXnzZH/gNsQ5XY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWPuBokTsFsNusUwi7nq9FGbPN9j741aTBQfDzNFSg2r6RhOpuB3FTk/7VtCkF7V+ aF1+2wyTUD94n4HAtx77BZogRdiX3NiAgUa+rHMV84i50lVa10XczkyY7ATt1y938p QMliwe4/+/ulBWKKQQJlyiINF49NTWEWxqZrdLUngI4l2T5LkRUJj7UTnR+XDYUvi8 V95j0P3a3PI6NGwuLLvN9uVfKgRsi2uWGBF2sYwHAlpMbnCLC0F/zLsRIkYpcBwPEh yobCAtsI+vTNfw6qD/UXQhB9S8khDLJ/z1q1vYAdYF/Ktu3fD+9jEmvzeyojXNJWEx BC9mHoHnHCWhQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D32FB676EF; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) 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 ad9hLPz48lsy; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872551; bh=50ucvM6XHctEpUB1ei/hsyx1s0sdrjMv0WDSpZDzXLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mw4XWCJ2Ds9gH9MgcQsxWyn2CKgFdwVFSLUyj+iiNW6Sjpqy0heh5oLHocBhxmWnR afUCCLgRAHOLvArXSguE6W5MxInW+ebvy99BJKp3QkxaIvPhiRCHGsyZz/ll5ezSHf c5TUg0D8hd97TMvd4FUhEIoiSsuxQsuYNcrWmgBBfRhtXcDQAwAGNxHsY8nOvygP89 5v0VheIBwZo79qcsjkL7N2+g0TlHClquIZvpkQNVB0jMP/Bj4ncMjs8st0GNRfT/rT 0gyl/fDEpcxw53wbuVnbyJGKoR/JE7Bc3qGHzq5ZrMZSjLUReqVE6yre+XgthSs1HY sJA7o6tB+nTEQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E75D167702; Fri, 22 Aug 2025 08:22:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:44 -0600 Message-ID: <20250822142153.3404275-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FFGUZIVQNM4QMZJESMZ73EBEUNUYJJWX X-Message-ID-Hash: FFGUZIVQNM4QMZJESMZ73EBEUNUYJJWX 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/16] doc: Remove obsolete text in README.console 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 latter part of this file is very out-of-date, so drop it. Signed-off-by: Simon Glass --- doc/README.console | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/doc/README.console b/doc/README.console index 9f5812c89d1..debef45760d 100644 --- a/doc/README.console +++ b/doc/README.console @@ -58,43 +58,3 @@ You can use the following functions to access the console: Remember that all FILE-related functions CANNOT be used before U-Boot relocation (done in 'board_init_r' in arch/*/lib/board.c). - -HOW CAN I USE STANDARD FILE INTO APPLICATIONS? ----------------------------------------------- - -Use the 'bd_mon_fnc' field of the bd_info structure passed to the -application to do everything you want with the console. - -But REMEMBER that that will work only if you have not overwritten any -U-Boot code while loading (or uncompressing) the image of your -application. - -For example, you won't get the console stuff running in the Linux -kernel because the kernel overwrites U-Boot before running. Only -some parameters like the framebuffer descriptors are passed to the -kernel in the high memory area to let the applications (the kernel) -use the framebuffers initialized by U-Boot. - -SUPPORTED DRIVERS ------------------ - -Working drivers: - - serial (architecture dependent serial stuff) - video (mpc8xx video controller) - -Work in progress: - - wl_kbd (Wireless 4PPM keyboard) - -Waiting for volounteers: - - lcd (mpc8xx lcd controller; to ) - -TESTED CONFIGURATIONS ---------------------- - -The driver has been tested with the following configurations (see -CREDITS for other contact informations): - -- MPC823FADS with AD7176 on a PAL TV (YCbYCr) - arsenio@tin.it From patchwork Fri Aug 22 14:21:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 118 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=1755872563; bh=zzxakl72BWRYUNLYShMwuh+iB9M380nsZqqmxDq2lMQ=; 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=KnEFxfTb8RWKKIhv39J5qaa4z9fk/vrm5WT01dBSsvJwH94oVhpcFXm1M5wtSk93m pzIbHTqFgsJaE/OnHI//IMeKaqUT8i64x9/E9Otm1y3nABiJD73tjSrFst51duA+Sf nNymV1cUOksWyDzwXDiBUZ+QRkdzCdTRmGxynj8QHesVs6v5f48scNYKP5qxn/Gllw Kqv1bSftebYyjoWkPVAIIQxslsSdMsRHtKrMCOlMQ+4S1mg9XtFl9oKkBLZQFVl6ne UFAxUqtm/ue0XYiiBgpkC2UJrLAPvYGlG2Rq8jtB+Zue4OekddIQXHReOs+M7XrT5/ fcVsyjBRo6QrA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4CA1967726 for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) 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 2Qzo50k4Lri7 for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872561; bh=zzxakl72BWRYUNLYShMwuh+iB9M380nsZqqmxDq2lMQ=; 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=db9W9Rw3GBvendpf9UuSD15k2wd0WNOtaEGjwRT2mgVgsEETOL4D6RMSZBWlpukQq LGcSqvGyB5AtZV6sn+0CHv4Sli+83DanjNrsyV9RjfAD9NuCDwXvjAIb2rspoxRWYg 76hPk+ga23emmWKUvm7DWB+ILhnI+p0oNQxHVLBgEmzDcezmqT3/wD0ApF44Fcb2bZ mPnX7/cvEavuFCfHBRh/nkDfnKlLwis8SLR4+dEB7l2V57sgp/PHqYlKRK7k9WmpKG UaMkkbvwg9ucicu8dBXGIpx/h3V53EmOFWp891q0ZCaXezllrdw5RYBHPtQJA6EZUU OJeuGR43LArkg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC8E7674C7 for ; Fri, 22 Aug 2025 08:22:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872558; bh=gD0Hg05UD6zPPnz9tQBeNsYzWZ3lqqFJXYI00r8NoNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYUIea7AiTYwLG1Mzv++MSqqW5tYG87QUwJAJR3FM1KQeQl7XYSEI+i7i8C5hAxAn bYQDyLB4UxyBmL/zpgfXnOCPq7kSPnnpfhoXQMBTr4Z066Kurydv/USaSglwzL8YlN AkLEu8lz3piYzjthQ5xE+Sm7r4y24uh/1DtGa3zyxtwDS8nyGFFSqzwO1VpWSnfsI5 30JWc/g3WROfQkrrJ47nPB7if+GDWnyaS2lioOl7XyxQ0jb+cx81KAhdqmx3G30TEL yAa2Q/3xmQf7e+PADV/gdOlJHKkqf5/hcpsBo2Y9P4KRw3TPY3YpJpmeODSDj9pFOb pC+kxTjbWaQew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2D895E45E; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) 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 JgMJC15LWdJf; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872551; bh=QLf/hCVLcGhCKh4y1fyfqlncy6qhK/9/DdWPzniE9nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SpBuEBgaA87OkG//c3XZVASK2X567bi3x3DQr6gydiI1Hp/dZ6rH8wAarIVNrInR4 31R+5+sdqYndovjFOl6+mwYytuALTJkDqM2ipubLVFVDLAr6OFRKCnb8dw1cP/3vWD jisPNbJ+YLHR8FtxAlGgJBnDXN+TeIMqPuHZFR93LY+NqhpLecH5C2sBGZzehburNu fr0giiwUW8SG4JEJnTPsFJTAxVqHiQekNMEjG0G6jDpOjyfZjNIHP8pyo6ymAHru+e 4pa3m37sEdCNOtLJLbCkKZuymLmZOxx4R5LhrqVBav6baIaSh3iY3tzhiRez+6p2wq bRBDF3HHlm0GA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B379D6771D; Fri, 22 Aug 2025 08:22:31 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:45 -0600 Message-ID: <20250822142153.3404275-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZBHDQ5KBKVSQBFFR563XRQ5OPMMY6F3H X-Message-ID-Hash: ZBHDQ5KBKVSQBFFR563XRQ5OPMMY6F3H 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/16] doc: Move console docs to rST 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 Move the console readme into the main documentation, with as few changes as possible. Signed-off-by: Simon Glass --- doc/{README.console => usage/console.rst} | 13 ++++++------- doc/usage/index.rst | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) rename doc/{README.console => usage/console.rst} (87%) diff --git a/doc/README.console b/doc/usage/console.rst similarity index 87% rename from doc/README.console rename to doc/usage/console.rst index debef45760d..f624cc58038 100644 --- a/doc/README.console +++ b/doc/usage/console.rst @@ -1,11 +1,10 @@ -SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2000 - * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it - */ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it +.. (C) Copyright 2000 +======================= U-Boot console handling -======================== +======================= HOW THE CONSOLE WORKS? ---------------------- @@ -57,4 +56,4 @@ You can use the following functions to access the console: fgetc (like getc but redirected to a file) Remember that all FILE-related functions CANNOT be used before -U-Boot relocation (done in 'board_init_r' in arch/*/lib/board.c). +U-Boot relocation (done in 'board_init_r' in `arch/*/lib/board.c`). diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 20465b8bff6..585aa3f9784 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -6,6 +6,7 @@ Use U-Boot spl_boot blkmap + console dfu environment fdt_overlays From patchwork Fri Aug 22 14:21:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 120 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=1755872563; bh=B+3raVdqDnH7s5ENm00tpS7PNFBY/J2j3qbaehJQpDk=; 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=at6ZdDvSL0oKPyZuEgybRK+O2yI65Ydeb/YqAsFgRp4tZ5ns1KmNT0CuSOf7HsGP1 tANfic2OpaKbKrzPBUmo4Ztgd8ZXDOviRXc5nZFluAadZq7LcY8DQxPQqia7DOG307 NFuFP8n6OaUuKSGX9Pf5TjUv307HKU+oGRvEEstci9FzgOg2FatZf5yUN9hsYKMa+L Idr6cpFuUHMFToERzokLU+ilEvX+fPKed2tqyh8HDXRb0leoF5YbM357AkPEHid6cw xFH1NEuwun0x/B4y0/g0ijfthL9O8GFOT0bFQs0rtToZSTBDYOEmSjJUY6DhvYNoxt kO1XNOtAeKfyw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD08667712 for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) 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 xm3qxmgmb6Fp for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872562; bh=B+3raVdqDnH7s5ENm00tpS7PNFBY/J2j3qbaehJQpDk=; 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=WU9ADNONhUcCz8aP0naTc//wwuEDbA2ss26QR0Zpk7Y2F2bAU4018YznZTv75XVJi 4+l8bc0NMwpnkR/Pt7JNRTnxQu6vjROGClxF0qTB5rbEvLrlsdNdAqW7aM4g0W13FO lD8T+ncDsSIUdpZtNnmjNerhBo4/w8A4LwXTqUzzB8cttnusGUdSRPFVKQDJlQj6ur QJzf/doZnDdcEumNVC6KGnRck/9E+fDlQ5KE2LE+H28kd3upAu/fpY6/zrm0Aeca/0 2EH25CYkQXiOwNx5qtFFeI7HGTzrjyVC9s7GM1uTcC+zACMuY3r5dV8T64fk06AWcI PR4KTDolD8lIQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACC606771A for ; Fri, 22 Aug 2025 08:22:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872558; bh=+/Y0QjxaPiuODvBrYaAtxGJWb8WdM3+qQQga+aHIbVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ouw/I/U24nvUnZ7Xwoc+ljp6pcMQBlyAXZjs2oegWUFXgPNK06BuoGbVuT/kO6PNR KH/xUcMxzqbbC7akQXdKQANSCzw8r5JidOQJg219osWhBdc4LxbHd4O8j8HBkJm58q kpQLN87qjV+ARN5715/wFMqKdrVkZjP9KoTxPXvgbEsZJN/qGePw0kqM1qkDbuPIkX v91E8wA79F5XLXMIcuk8JztFwEZq9VilL6Cs1rVABtN9c0SJd/XjEQs7b3QHsj0atL O7H+HC+g3jAyVRj4PL8RYQbaP3Fo7ZuQmvrzJCQIZaOKmscKDP1749iKVWRrNgW9MD fwOBbikGrS36g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E67E567702; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) 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 VdlgxuH00pD7; Fri, 22 Aug 2025 08:22:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872552; bh=RCgCxJfrcKlkWS8Q6aPkolvo1mRvA/v6sa4Daoqfs+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1F6hGCHbQ2NxMQfboW7dFelpO5Ew8J1unLpWxzEsOUBGK59fWNsSJlKaJVCMnUQX rU0tu2NehxyE0rIlbHFSA5CijnPRMYz13OlEOldYSRLjUsUF7XeC4+KIo7wZBhHdny Vi3vqE/SY3Urfnbvet4cTZuNSpg3en5efxeupJU55QYOB2g2gkjR1svVQiFE40k5D/ 3UpNdkPIOptBRpcGfLvHR5TqoikZRxrS4f8AoPqdh0UEaVwBfmAApAFw1AQYel60N+ BE0rAtKWQakYWH7wlLpWICp35jmLaYRxDhl//gfL1jdMqXQjGaNSR6cKS7nm64TEZG eBjS+CtlSIptQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6D9D1675E3; Fri, 22 Aug 2025 08:22:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:46 -0600 Message-ID: <20250822142153.3404275-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BSB5T4CNFD5ABZIBZ54NBGCWNTJJ7333 X-Message-ID-Hash: BSB5T4CNFD5ABZIBZ54NBGCWNTJJ7333 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/16] doc: Tidy up the console docs a little 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 Tweak the documentation to look better when viewed. Use 'write' instead of 'put'. Signed-off-by: Simon Glass --- doc/usage/console.rst | 69 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/doc/usage/console.rst b/doc/usage/console.rst index f624cc58038..d7d41bca187 100644 --- a/doc/usage/console.rst +++ b/doc/usage/console.rst @@ -6,10 +6,10 @@ U-Boot console handling ======================= -HOW THE CONSOLE WORKS? ----------------------- +Introduction +------------ -At system startup U-Boot initializes a serial console. When U-Boot +At system-startup U-Boot initializes a serial console. When U-Boot relocates itself to RAM, all console drivers are initialized (they will register all detected console devices to the system for further use). @@ -17,43 +17,46 @@ use). If not defined in the environment, the first input device is assigned to the 'stdin' file, the first output one to 'stdout' and 'stderr'. -You can use the command "coninfo" to see all registered console +You can use the command `coninfo` to see all registered console devices and their flags. You can assign a standard file (stdin, stdout or stderr) to any device you see in that list simply by assigning its name to the corresponding environment variable. For -example: +example:: - setenv stdin serial <- To use the serial input - setenv stdout video <- To use the video console + # Use the serial input + setenv stdin serial -Do a simple "saveenv" to save the console settings in the environment + # Use the video console + setenv stdout vidconsole + +Do a simple `saveenv` to save the console settings in the environment and get them working on the next startup, too. -HOW CAN I USE STANDARD FILE INTO THE SOURCES? ---------------------------------------------- +How to output text to the console +--------------------------------- You can use the following functions to access the console: -* STDOUT: - putc (to put a char to stdout) - puts (to put a string to stdout) - printf (to format and put a string to stdout) - -* STDIN: - tstc (to test for the presence of a char in stdin) - getc (to get a char from stdin) - -* STDERR: - eputc (to put a char to stderr) - eputs (to put a string to stderr) - eprintf (to format and put a string to stderr) - -* FILE (can be 'stdin', 'stdout', 'stderr'): - fputc (like putc but redirected to a file) - fputs (like puts but redirected to a file) - fprintf (like printf but redirected to a file) - ftstc (like tstc but redirected to a file) - fgetc (like getc but redirected to a file) - -Remember that all FILE-related functions CANNOT be used before -U-Boot relocation (done in 'board_init_r' in `arch/*/lib/board.c`). +stdout + - putc() - write a char to stdout + - puts() - write a string to stdout + - printf() - format and write a string to stdout + +stdin + - tstc() - test for the presence of a char in stdin + - getchar() - get a char from stdin + +stderr + - eputc() - write a char to stderr + - eputs() - write a string to stderr + - eprintf() - format and write a string to stderr + +file ('stdin', 'stdout' or 'stderr') + - fputc() - write a char to a file + - fputs() - write a string to a file + - fprintf() - format and write a string to a file + - ftstc() - test for the presence of a char in file + - fgetc() - get a char from a file + +Remember that FILE-related functions CANNOT be used before U-Boot relocation, +which is done in `board_init_r()`. From patchwork Fri Aug 22 14:21:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 121 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=1755872564; bh=hPObIfvqSuvYk6Rs/VPAILe2iRiHKmi/JmRjYk070k8=; 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=BdoAhtVkRnxt5jWcEsxQHTOAnaUrdjCCjtffRw3og1CPNkYjmo2Z0OGWdU7QPsFEF htlU/Og7i42WNk/U+Bsl54CsPR+ADwGalPtmivWXN4m4R8Fah03hfhWIgu3I08kEYK g3dVpJoJkr4XUeRC5MJdhSrZwtk53QW3j+wbjBAlUGBllkEYEGfLLohhf6QDHu/5Z3 v7iVj7G1TChx0jwWFBMY1SBq5QScm6NETLEg3uw2DncHWE2gI61C6kn7LIkbugJFMg B6vD4N5/ycHBsuaAM0m2Zulbyem2Rbf0m9u+ph7W1R872PMjrbUTG84L5W+Xe/gUUb +jTmQUPzkQ1AQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 015AF676F0 for ; Fri, 22 Aug 2025 08:22:44 -0600 (MDT) 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 rfiYgPj2ayjU for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872563; bh=hPObIfvqSuvYk6Rs/VPAILe2iRiHKmi/JmRjYk070k8=; 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=rpWr9KCekfz/Km6+o0JxPpNyg37g//QJXhT52H0t0HJF8OlJwMtLEeF0jt037QDUP ceoNA/wH1SghvwNeE5FmGMKZfG8H3CQ1umY1RGmQfHnQyYElk4qFbUDNEnMl2h0ShW mjBtCXbFyDeS28+guk1Gt7N/TwKTZ1D3jcK5mBUUD60koAHFPbd9WSe6bkl81c1tse 81Q4Id4I8uJ2W4xRHDxlkIQ2todDn5Uzbhfb2aHBSF9koO46D7tcGxk5F12NMoGcT+ M572LmGqNppjSPLVsEPeS+o4e37ZWfaiwQQN5yR2lEUrfz03IBPK+iYfjN4Xo+JZ7p CA3hlUTjT6+Jg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A43267721 for ; Fri, 22 Aug 2025 08:22:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872559; bh=7VVHHKIrxSVcqac/N7079jkRZ9f0lpTwUj98Zr0hb70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l2UE9C40pxuAK8zOoPy0Ia3LeMHrLQitiuB3zN3CbGViOuKgmkXy96Zw2LzS0977n EyhqXO6IDPXInZkWrl93XNgGDmzIVHNmHjRis3ueNEPyoRnjEFKyizs7DovZx1oGzb 8DKbEh6uE/WMZkLOZSk9P21b94sLnJBrabsPmzyq2pDpAEi/PWUDHXsIHmQX3XlclK DYJE9ptpu/uiH6Eukidr2B86XBNunx1IxwywzgH8lOjNGL/kD9NC2ZFNo9IkgIgXMM ErGKNKXwiIuyrWMEWjDxtx1/guDhFHU5ilaw57momApJbgkFJGRQT98PmhDk5NFb+K X7QxqFoOF5KPg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 48DFF6771B; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) 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 fgWu2MsxP3HK; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=qoGX9fSAjPDYz3FzDDh6oIkLcJY92gb3OgkSfDLV/OY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFj58dNhdoq7eLThazATT05AV6fYYgt6MyqtWIy5nwMrBtAXbXOKiEmzCi8zruQcL SGuq3xyER9idyYlwvhpNvPh/tLPWolrUto9LqAkWPfQtNwCU+Oa7zK3fSKZIMGbC4x OTJT4u+uQ7ki+cb3WWSK3QmdaP5Jx4My67d5HGeS6VOMHAqlKjfZfniDgjfN93T0uN 1KelFVDX8yr/njKkl/xXda6Kjttm6FyuyNCqO36QMWa0F3uJD74hsPM6WvMGBv+v3n aNNRFGmefNZ6BAe4J+Pu24ybYYqG+gaFniPcVcEsyYBnUqw+fq4O9NX/hTeBXHriuO 2CmhVfbXmoPQw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 35DE96771F; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:47 -0600 Message-ID: <20250822142153.3404275-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PUL74667B4YZBI5ZVZ63FI5DO6BR4KEX X-Message-ID-Hash: PUL74667B4YZBI5ZVZ63FI5DO6BR4KEX 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/16] pager: doc: Add mention of the pager feature 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 a note about the pager to the console documentation. Signed-off-by: Simon Glass --- doc/usage/console.rst | 16 ++++++++++++++++ doc/usage/environment.rst | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/doc/usage/console.rst b/doc/usage/console.rst index d7d41bca187..95424c43ee9 100644 --- a/doc/usage/console.rst +++ b/doc/usage/console.rst @@ -60,3 +60,19 @@ file ('stdin', 'stdout' or 'stderr') Remember that FILE-related functions CANNOT be used before U-Boot relocation, which is done in `board_init_r()`. + +Pager +----- + +U-Boot has a simple pager feature, enabled with `CONFIG_CONSOLE_PAGER`. It is +only available if both `CONFIG_CONSOLE_MUX` is enabled. + +When activated, the pager pauses at the end of each 'page' (screenful) of +output, shows a prompt and lets the user read the output. To continue, press +SPACE. + +The number of lines before the pager kicks in is configurable using the `pager` +environment variable, which should contain a decimal value. Set it to 0 (or +leave it unset) to disable the pager. If the variable is not present then the +number of lines in the video console is used. If there is no video console, then +`CONSOLE_PAGER_LINES` sets the number of lines. diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index 6235d7276f0..696acbfd6a5 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -336,7 +336,12 @@ netretry themselves. pager +<<<<<<< HEAD Decimal number of visible lines on the display, or serial console. +======= + Decimal number of visible lines on the display, or serial console. See + :doc:`/usage/console`. +>>>>>>> 949c148e39e (pager: doc: Add mention of the pager feature) rng_seed_size Size of random value added to device-tree node /chosen/rng-seed.