From patchwork Mon Oct 14 22:31:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997102 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=UCze7ALA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBnF3wP8z1xsc for ; Tue, 15 Oct 2024 09:32:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E4CD089228; Tue, 15 Oct 2024 00:32:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UCze7ALA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5872C88703; Tue, 15 Oct 2024 00:32:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4D5F8891AA for ; Tue, 15 Oct 2024 00:32:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-835393376e1so295078939f.1 for ; Mon, 14 Oct 2024 15:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945137; x=1729549937; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yFEx0c0sJB1E97HMSZgPHLAAiSR/v3dkcFGFSL2x0+4=; b=UCze7ALAgp/Mg/vXQ9xPhCwSnYrI4SDEf4NDUpIHih8KLbL+/JZbmhHdHA0CC94kMi j9PK+UlK63xsukCHqyHpiJXFWwFSg09ZRTmJqzLf5yLroRkyJc3/pO352xkDBsuPoCwJ bgk44eWjC4/0MwgQRmX9d0FLDCq1ItI3Ybaug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945137; x=1729549937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yFEx0c0sJB1E97HMSZgPHLAAiSR/v3dkcFGFSL2x0+4=; b=lDmR28Y5sXn6ZZbwWrIetFBYbusciz/U+oloTmLepTEq0Fws8bOe6FlzBuCiFmydQF Zf122OsIrCQYtxjOf85C9mwDV6lahegewZ4MMfheJXpnZOPPzZf0Y+3QYQKwOUpMbqM4 /s7pzmp7tyNzMhUiB5dUqfFe4bnL8Oq6GnnxhYcEAAU8giY0ZDE8JGOPMqsVLdVRmqDP 2JVm7p4vYQW00h/2D+0KteBv3U5aqnBNE+uJd1tjvxodmPekqHHXuDx3/wJiLlE7NqVY QF+iZxPe9wUUQ+2RlxaOmqQ23geJlsCxWf7ynTcEKZluDc7SVqKmn2XxWGjQgjJhxo/i ZhTQ== X-Gm-Message-State: AOJu0YxIlhhaevn4uIMZCxwnhTHscXbUpPoyzbQxzZ2TA/fbj/aB4UhQ GiKgEyEN8eAB5qYhfYnc6WzsoRmWYhHAIv/De81swfVcRXd1hODdG0LyaW7x2wfh/31H+2zYm/P LMg== X-Google-Smtp-Source: AGHT+IEUgBGo03TEXjxuJYUl//XIc/OM7Sjx+/mew8+rhy1TRZNpa0L7+ro7kFFR7NKXjG+8VFuCdg== X-Received: by 2002:a05:6e02:2185:b0:3a0:bd91:3842 with SMTP id e9e14a558f8ab-3a3bce0b188mr84614385ab.24.1728945136989; Mon, 14 Oct 2024 15:32:16 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Devarsh Thakkar , Nikhil M Jain , Peter Robinson , Sughosh Ganu Subject: [PATCH v3 01/20] video: Add a dark-grey console colour Date: Mon, 14 Oct 2024 16:31:53 -0600 Message-Id: <20241014223212.2212442-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This is useful for highlighting something with a black background, as is needed with cedit when using a white-on-black console. Add this as a new colour. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/scene.c | 2 +- drivers/video/video-uclass.c | 3 +++ include/video.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/boot/scene.c b/boot/scene.c index 270c9c67233..0135287cfcb 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -339,7 +339,7 @@ static void scene_render_background(struct scene_obj *obj, bool box_only) /* draw a background for the object */ if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) { - fore = VID_BLACK; + fore = VID_DARK_GREY; back = VID_WHITE; } else { fore = VID_LIGHT_GRAY; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 9823673f817..a5b3e898066 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -294,6 +294,9 @@ static const struct vid_rgb colours[VID_COLOUR_COUNT] = { { 0xff, 0x00, 0xff }, /* bright magenta */ { 0x00, 0xff, 0xff }, /* bright cyan */ { 0xff, 0xff, 0xff }, /* white */ + + /* an extra one for menus */ + { 0x40, 0x40, 0x40 }, /* dark gray */ }; u32 video_index_to_colour(struct video_priv *priv, enum colour_idx idx) diff --git a/include/video.h b/include/video.h index 606c8a37fb8..fd19723b1d2 100644 --- a/include/video.h +++ b/include/video.h @@ -181,6 +181,7 @@ enum colour_idx { VID_LIGHT_MAGENTA, VID_LIGHT_CYAN, VID_WHITE, + VID_DARK_GREY, VID_COLOUR_COUNT }; From patchwork Mon Oct 14 22:31:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997103 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Fli02y6P; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBnS5d2Dz1xsc for ; Tue, 15 Oct 2024 09:32:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5743789239; Tue, 15 Oct 2024 00:32:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Fli02y6P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CC36891D7; Tue, 15 Oct 2024 00:32:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 45C7F87042 for ; Tue, 15 Oct 2024 00:32:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3a3b67cd89dso9904955ab.0 for ; Mon, 14 Oct 2024 15:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945138; x=1729549938; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hde+A2aGugAGPVzN2TBL7e0E6hNE+JbQXef09t7SH9g=; b=Fli02y6PrjBhL2LWs//hqyREU1Vrmri1fmLvv6Bcz+XNyJvHHjkVPc1YXf+c9A0Sfh Ysa+di0o/JjS7YQJifX5XkQ++p4nubSCxoChr2hOrnZXhVA426LyVMTcUYYSx0Ny4s0I X0Q9PK0B9xdljF7lafRciEuooGmiE7QajGPQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945138; x=1729549938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hde+A2aGugAGPVzN2TBL7e0E6hNE+JbQXef09t7SH9g=; b=g9BEQ44hwwCjqfy6Fw0oBGrO+YH0FYtFGYP6Db+1uFFYCPcHoeyPEBORPGBiAhmARs vi2AlgZ9F9o1EXXVLUQnwoZn70C+OnhxPakSVC/KErFmcVyIZ7G9lLxpi1Pnujr90ULR WcG8jsGDfd7j0x/qrqht/+Uu87IyJT8lF2U+gywFJL+ht+Xa+l+653c7GcmX874EC6xu NuOyxcyCT46sxP5bzRGK9KSNZlUmsq6ly9dx/jXMPld7suQOeWEQ/cU9EeQ+Pnaf6PJZ uIWgKMI7NIMcyY0mUltPRyekZySW3gOzWKcmS4E3LTWWwohXZaHUdVmqoTiW0SqM7nUA viOQ== X-Gm-Message-State: AOJu0Yz/I0axxknTA5R15DBZScON+voXFysz17U+oOxX80nFBn7Vzyo9 ZiHk4A1hYVStpoPGDASn6Su+ebQElPKnZPj8Jk8351VL1eSJfGg4zn3cx0i2G1YCvSWj/T1wefg 4VQ== X-Google-Smtp-Source: AGHT+IHuLyI7y624xurKJq1twWNugBOT2pLphEfmFfoYCMKinHFBwp8yfvL9RX8cOraGxeoQq6amNQ== X-Received: by 2002:a05:6e02:b4e:b0:3a0:ca91:2b4e with SMTP id e9e14a558f8ab-3a3a709ddfbmr108866625ab.3.1728945137882; Mon, 14 Oct 2024 15:32:17 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:17 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Janne Grunau , Peter Robinson Subject: [PATCH v3 02/20] video: Avoid starting a new line to close to the bottom Date: Mon, 14 Oct 2024 16:31:54 -0600 Message-Id: <20241014223212.2212442-3-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When starting a new text line, an assumption is made that the current vertical position is a multiple of the character height. When this is not true, characters can be written after the end of the framebuffer. This can causes crashes and strange errors from QEMU. Adjust the scrolling check when processing a newline character, to avoid any problems. Add some comments to make things a little clearer. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) drivers/video/vidconsole-uclass.c | 4 +++- include/video.h | 3 ++- include/video_console.h | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 80e7adf6a1a..ebe96bf0c2f 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -94,7 +94,9 @@ static void vidconsole_newline(struct udevice *dev) priv->ycur += priv->y_charsize; /* Check if we need to scroll the terminal */ - if ((priv->ycur + priv->y_charsize) / priv->y_charsize > priv->rows) { + if (vid_priv->rot % 2 ? + priv->ycur + priv->x_charsize > vid_priv->xsize : + priv->ycur + priv->y_charsize > vid_priv->ysize) { vidconsole_move_rows(dev, 0, rows, priv->rows - rows); for (i = 0; i < rows; i++) vidconsole_set_row(dev, priv->rows - i - 1, diff --git a/include/video.h b/include/video.h index fd19723b1d2..c7afe22d823 100644 --- a/include/video.h +++ b/include/video.h @@ -78,7 +78,8 @@ enum video_format { * * @xsize: Number of pixel columns (e.g. 1366) * @ysize: Number of pixels rows (e.g.. 768) - * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.) + * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.). THis + * does not affect @xsize and @ysize * @bpix: Encoded bits per pixel (enum video_log2_bpp) * @format: Pixel format (enum video_format) * @vidconsole_drv_name: Driver to use for the text console, NULL to diff --git a/include/video_console.h b/include/video_console.h index 8b5928dc5eb..723d2315606 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -27,6 +27,14 @@ enum { * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe() * method. Drivers may set up @xstart_frac if desired. * + * Note that these values relate to the rotated console, so that an 80x25 + * console which is rotated 90 degrees will have rows=80 and cols=25 + * + * The xcur_frac and ycur values refer to the unrotated coordinates, that is + * xcur_frac always advances with each character, even if its limit might be + * vid_priv->ysize instead of vid_priv->xsize if the console is rotated 90 or + * 270 degrees. + * * @sdev: stdio device, acting as an output sink * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) * @ycur: Current Y position in pixels (0=top) From patchwork Mon Oct 14 22:31:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997104 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DJ171IOf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBnd11dpz1xsc for ; Tue, 15 Oct 2024 09:32:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2CA789245; Tue, 15 Oct 2024 00:32:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DJ171IOf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2147889232; Tue, 15 Oct 2024 00:32:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 31E5A8921A for ; Tue, 15 Oct 2024 00:32:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x143.google.com with SMTP id e9e14a558f8ab-3a3b0247d67so14724275ab.3 for ; Mon, 14 Oct 2024 15:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945139; x=1729549939; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rwtJ3qCMwKhDLCmzfGqu9LCr6i8OXbEteGE6DNQQ/qI=; b=DJ171IOf2Vx/lkE7iJ/Ql0gi3kWKSHuCWG1YQ/9FRj0W3dZ1bEI1///3FHCJLifnPS uKHs/Gh3JqIya/FeqfqhPz/FECPIXiiJqNQ9teORlOU2g4jNrXD1/i6KwlMsy7k9Lugw 6Ii1w7zvYwWAyjbWpYnsR4ann9i5gKndJmISk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945139; x=1729549939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rwtJ3qCMwKhDLCmzfGqu9LCr6i8OXbEteGE6DNQQ/qI=; b=bh4Kp75Wwy9g92wKymWHtnQSlPHYA5n+Rs2l9uTj4ITGxeGg7UPp9M1+jir7muyq6d W9QmjZCw1mIeNm5uGNJMGL7IiX9AJsannHF0vxPpZfLyMnMHKKXYp4lfM/tMQZ1MTShc R7jMfX9tYQGLKKR5kkszNBUT2f/gqUsMW9ZC3CGuTQCgaWuQ5AjkTGFN+c6NP0iWDeUz l9mJGqAFn7bNj0ngKuE8tcu/Z1u35YvyRaxtOE+gFV4zK9I9SB8RH5/T9dQqct6+mnlD 5s6W4sx5tUd1UPAZjbd40qGafHH3J5BmzsXpC5jAj7nA59Bov0+nWhF7i3LPAJ09N0h4 9fXg== X-Gm-Message-State: AOJu0YzzfYngsUUP05Je4kGzIc7v1u7nbLb/KImZGurDlAtn2NPLWNUl Rj8Kxng2PjDoL/BrZi2JmmYZJ4TzaR+KN6h/4+U7eO8BBUpPSyLSF2STo4Ko+XSXlzuwmpZUVyw mTDcf X-Google-Smtp-Source: AGHT+IG+XeioruTkUZ7ioPadRMSJeFE3jli3QUWzo+5HW3Uy+L2Y16FYcW/zrCyXX/VERCYfwObvuw== X-Received: by 2002:a05:6e02:17cd:b0:3a0:915d:a4a7 with SMTP id e9e14a558f8ab-3a3bcd962d8mr79681575ab.2.1728945138781; Mon, 14 Oct 2024 15:32:18 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v3 03/20] expo: Place menu items to the right of all labels Date: Mon, 14 Oct 2024 16:31:55 -0600 Message-Id: <20241014223212.2212442-4-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean At present a fixed position is used for menu items, 200 pixels to the right of the left side of the labels. This means that a menu item with a very long label may overlap the items. It seems better to calculate the maximum label width and then place the items to the right of all of them. To implement this, add a new struct to containing arrangement information. Calculate it before doing the actual arrangement. Add a new style item which sets the amount of space from the right side of the labels to left side of the items. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/cedit.c | 13 ++++++++--- boot/expo.c | 2 ++ boot/scene.c | 52 +++++++++++++++++++++++++++++++++++++++++-- boot/scene_internal.h | 20 +++++++++++++++-- boot/scene_menu.c | 9 +++++--- boot/scene_textline.c | 3 ++- doc/develop/expo.rst | 4 ++++ include/expo.h | 12 ++++++++++ 8 files changed, 104 insertions(+), 11 deletions(-) diff --git a/boot/cedit.c b/boot/cedit.c index c29a2be14ce..5758cc5a0d6 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -51,10 +51,11 @@ struct cedit_iter_priv { int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id) { + struct expo_arrange_info arr; struct scene_obj_txt *txt; struct scene_obj *obj; struct scene *scn; - int y; + int y, ret; scn = expo_lookup_scene_id(exp, scene_id); if (!scn) @@ -68,6 +69,11 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id) if (txt) scene_obj_set_pos(scn, txt->obj.id, 200, 10); + memset(&arr, '\0', sizeof(arr)); + ret = scene_calc_arrange(scn, &arr); + if (ret < 0) + return log_msg_ret("arr", ret); + y = 100; list_for_each_entry(obj, &scn->obj_head, sibling) { switch (obj->type) { @@ -77,12 +83,13 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id) break; case SCENEOBJT_MENU: scene_obj_set_pos(scn, obj->id, 50, y); - scene_menu_arrange(scn, (struct scene_obj_menu *)obj); + scene_menu_arrange(scn, &arr, + (struct scene_obj_menu *)obj); y += 50; break; case SCENEOBJT_TEXTLINE: scene_obj_set_pos(scn, obj->id, 50, y); - scene_textline_arrange(scn, + scene_textline_arrange(scn, &arr, (struct scene_obj_textline *)obj); y += 50; break; diff --git a/boot/expo.c b/boot/expo.c index ed01483f1d3..c7ce19e834b 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -258,6 +258,8 @@ int expo_apply_theme(struct expo *exp, ofnode node) ofnode_read_u32(node, "font-size", &theme->font_size); ofnode_read_u32(node, "menu-inset", &theme->menu_inset); ofnode_read_u32(node, "menuitem-gap-y", &theme->menuitem_gap_y); + ofnode_read_u32(node, "menu-title-margin-x", + &theme->menu_title_margin_x); list_for_each_entry(scn, &exp->scene_head, sibling) { ret = scene_apply_theme(scn, theme); diff --git a/boot/scene.c b/boot/scene.c index 0135287cfcb..a4836000b28 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -471,11 +471,59 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) return 0; } +int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr) +{ + struct scene_obj *obj; + + arr->label_width = 0; + list_for_each_entry(obj, &scn->obj_head, sibling) { + uint label_id = 0; + int width; + + switch (obj->type) { + case SCENEOBJT_NONE: + case SCENEOBJT_IMAGE: + case SCENEOBJT_TEXT: + break; + case SCENEOBJT_MENU: { + struct scene_obj_menu *menu; + + menu = (struct scene_obj_menu *)obj, + label_id = menu->title_id; + break; + } + case SCENEOBJT_TEXTLINE: { + struct scene_obj_textline *tline; + + tline = (struct scene_obj_textline *)obj, + label_id = tline->label_id; + break; + } + } + + if (label_id) { + int ret; + + ret = scene_obj_get_hw(scn, label_id, &width); + if (ret < 0) + return log_msg_ret("hei", ret); + arr->label_width = max(arr->label_width, width); + } + } + + return 0; +} + int scene_arrange(struct scene *scn) { + struct expo_arrange_info arr; struct scene_obj *obj; int ret; + ret = scene_calc_arrange(scn, &arr); + if (ret < 0) + return log_msg_ret("arr", ret); + list_for_each_entry(obj, &scn->obj_head, sibling) { switch (obj->type) { case SCENEOBJT_NONE: @@ -486,7 +534,7 @@ int scene_arrange(struct scene *scn) struct scene_obj_menu *menu; menu = (struct scene_obj_menu *)obj, - ret = scene_menu_arrange(scn, menu); + ret = scene_menu_arrange(scn, &arr, menu); if (ret) return log_msg_ret("arr", ret); break; @@ -495,7 +543,7 @@ int scene_arrange(struct scene *scn) struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj, - ret = scene_textline_arrange(scn, tline); + ret = scene_textline_arrange(scn, &arr, tline); if (ret) return log_msg_ret("arr", ret); break; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index e72202c9821..be25f6a8b96 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -96,10 +96,12 @@ int scene_calc_dims(struct scene *scn, bool do_menus); * if not already done * * @scn: Scene to update + * @arr: Arrangement information * @menu: Menu to process * Returns: 0 if OK, -ve on error */ -int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu); +int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_menu *menu); /** * scene_textline_arrange() - Set the position of things in a textline @@ -108,10 +110,12 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu); * positioned correctly relative to the textline. * * @scn: Scene to update + * @arr: Arrangement information * @tline: textline to process * Returns: 0 if OK, -ve on error */ -int scene_textline_arrange(struct scene *scn, struct scene_obj_textline *tline); +int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_textline *tline); /** * scene_apply_theme() - Apply a theme to a scene @@ -358,4 +362,16 @@ int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline); */ int scene_textline_close(struct scene *scn, struct scene_obj_textline *tline); +/** + * scene_calc_arrange() - Calculate sizes needed to arrange a scene + * + * Checks the size of some objects and stores this info to help with a later + * scene arrangement + * + * @scn: Scene to check + * @arr: Place to put scene-arrangement info + * Returns: 0 if OK, -ve on error + */ +int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr); + #endif /* __SCENE_INTERNAL_H */ diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 80bd7457cb1..c331f6670cc 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -168,7 +168,8 @@ int scene_menu_calc_dims(struct scene_obj_menu *menu) return 0; } -int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) +int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_menu *menu) { const bool open = menu->obj.flags & SCENEOF_OPEN; struct expo *exp = scn->expo; @@ -182,16 +183,18 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) x = menu->obj.dim.x; y = menu->obj.dim.y; if (menu->title_id) { + int width; + ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.dim.x, y); if (ret < 0) return log_msg_ret("tit", ret); - ret = scene_obj_get_hw(scn, menu->title_id, NULL); + ret = scene_obj_get_hw(scn, menu->title_id, &width); if (ret < 0) return log_msg_ret("hei", ret); if (stack) - x += 200; + x += arr->label_width + theme->menu_title_margin_x; else y += ret * 2; } diff --git a/boot/scene_textline.c b/boot/scene_textline.c index bba8663b98d..6adef7cc173 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -87,7 +87,8 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline) return 0; } -int scene_textline_arrange(struct scene *scn, struct scene_obj_textline *tline) +int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_textline *tline) { const bool open = tline->obj.flags & SCENEOF_OPEN; bool point; diff --git a/doc/develop/expo.rst b/doc/develop/expo.rst index c87b6ec8128..f7b636e5fc6 100644 --- a/doc/develop/expo.rst +++ b/doc/develop/expo.rst @@ -176,6 +176,10 @@ menu-inset menuitem-gap-y Number of pixels between menu items +menu-title-margin-x + Number of pixels between right side of menu title to the left size of the + menu labels + Pop-up mode ----------- diff --git a/include/expo.h b/include/expo.h index c235fa2709d..50e11cd118c 100644 --- a/include/expo.h +++ b/include/expo.h @@ -59,11 +59,14 @@ struct expo_action { * @font_size: Default font size for all text * @menu_inset: Inset width (on each side and top/bottom) for menu items * @menuitem_gap_y: Gap between menu items in pixels + * @menu_title_margin_x: Gap between right side of menu title and left size of + * menu label */ struct expo_theme { u32 font_size; u32 menu_inset; u32 menuitem_gap_y; + u32 menu_title_margin_x; }; /** @@ -341,6 +344,15 @@ struct scene_obj_textline { uint pos; }; +/** + * struct expo_arrange_info - Information used when arranging a scene + * + * @label_width: Maximum width of labels in scene + */ +struct expo_arrange_info { + int label_width; +}; + /** * expo_new() - create a new expo * From patchwork Mon Oct 14 22:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997105 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DtsWGS5N; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBnp3514z1xsc for ; Tue, 15 Oct 2024 09:33:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4708789253; Tue, 15 Oct 2024 00:32:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DtsWGS5N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1889F8922B; Tue, 15 Oct 2024 00:32:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F3ECD89220 for ; Tue, 15 Oct 2024 00:32:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-8354845c5dcso204369239f.0 for ; Mon, 14 Oct 2024 15:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945139; x=1729549939; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NUi38tGBqreCxf4mTrq9+emHy68lYmQ8BebZcFwooqg=; b=DtsWGS5N/aGtjMQCKzYOVvlX9FgYzo5T4VGxn7fr83aGBMOLqi4q7lYUkO+GwKg3iC SP3Jg6ixvoPTQwdkR9DgbAw//qs7V6r1nuc9JVRqhQZD+LJtJ5RhPNiLk7RoBNPYLPQJ 5op9lsHn/GeAYU6+qs5epwt/ddBhf2vjFmdX0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945139; x=1729549939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NUi38tGBqreCxf4mTrq9+emHy68lYmQ8BebZcFwooqg=; b=gdH1VrD3Q60HuOlDEVgX4biBqUarjkdogYx3vvjW4q58oo4rYcJlrWkbR6xBI/gacp FD5F3UNQlx7664xb8anMce0hQ53Dd9GJz9Z7exQJsaYg2Kgkz93zmX+5BeSq45J4FijW NzeqEx5l9PO1l7FaVRpKPDf1KSUhh9V5TWHzSqdOqDpGISb4DwxGGq2UHmOzqgOU4aCj Ug3lF/0ZllVmevPeqHUwop5g4Q/29itMdztMihuCAQS4jhi6lzzLuVblBA6sQLQvsEya SPZe+Px8g509wOK2Gl/K8kNGL4hetz8SvzFC6O7oGIlFuxHjIotI/iuFzmE2x96Dogz+ WcNg== X-Gm-Message-State: AOJu0YymcbDCRAJG8vLtryUvglE+xm81yCrhtuf4IRb1cTDg1QACfkyX 1/GfnelwSDMjlVYVTTkEM3VvtAXT7VOI4LvyzfCo6gjuU3rEgburMgpTKPi9DcGkQVI99gCwyQO VSQ== X-Google-Smtp-Source: AGHT+IE8eeq45BQIzp7/MgZh7ttRYeosEZqOJ9c+BuOmj6s8xwKn9KM5j2RNMJ327PERbWSfjFe/Fg== X-Received: by 2002:a05:6e02:13a8:b0:3a0:a385:911d with SMTP id e9e14a558f8ab-3a3b5c71f26mr118440865ab.0.1728945139619; Mon, 14 Oct 2024 15:32:19 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 04/20] expo: Set the initial next_id to 1 Date: Mon, 14 Oct 2024 16:31:56 -0600 Message-Id: <20241014223212.2212442-5-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean If expo_set_dynamic_start() is never called, the first scene created will have an ID of 0, which is invalid. Correct this by setting a default value. Add a test to check this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/expo.c | 1 + test/boot/expo.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/boot/expo.c b/boot/expo.c index c7ce19e834b..700786ec0cc 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -29,6 +29,7 @@ int expo_new(const char *name, void *priv, struct expo **expp) exp->priv = priv; INIT_LIST_HEAD(&exp->scene_head); INIT_LIST_HEAD(&exp->str_head); + exp->next_id = 1; *expp = exp; diff --git a/test/boot/expo.c b/test/boot/expo.c index 9b4aa803eb1..f6a6b4fd2cb 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -91,7 +91,7 @@ static int expo_base(struct unit_test_state *uts) *name = '\0'; ut_assertnonnull(exp); ut_asserteq(0, exp->scene_id); - ut_asserteq(0, exp->next_id); + ut_asserteq(1, exp->next_id); /* Make sure the name was allocated */ ut_assertnonnull(exp->name); @@ -130,7 +130,7 @@ static int expo_scene(struct unit_test_state *uts) ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); scn = NULL; - ut_asserteq(0, exp->next_id); + ut_asserteq(1, exp->next_id); strcpy(name, SCENE_NAME1); id = scene_new(exp, name, SCENE1, &scn); *name = '\0'; @@ -167,6 +167,25 @@ static int expo_scene(struct unit_test_state *uts) } BOOTSTD_TEST(expo_scene, UTF_DM | UTF_SCAN_FDT); +/* Check creating a scene with no ID */ +static int expo_scene_no_id(struct unit_test_state *uts) +{ + struct scene *scn; + struct expo *exp; + char name[100]; + int id; + + ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); + ut_asserteq(1, exp->next_id); + + strcpy(name, SCENE_NAME1); + id = scene_new(exp, SCENE_NAME1, 0, &scn); + ut_asserteq(1, scn->id); + + return 0; +} +BOOTSTD_TEST(expo_scene_no_id, UTF_DM | UTF_SCAN_FDT); + /* Check creating a scene with objects */ static int expo_object(struct unit_test_state *uts) { From patchwork Mon Oct 14 22:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997107 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nrFIx1ZB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBp84qPsz1xsc for ; Tue, 15 Oct 2024 09:33:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 304B88926F; Tue, 15 Oct 2024 00:32:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="nrFIx1ZB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E55348924E; Tue, 15 Oct 2024 00:32:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 324BD87042 for ; Tue, 15 Oct 2024 00:32:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id ca18e2360f4ac-83549342f09so133279539f.0 for ; Mon, 14 Oct 2024 15:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945140; x=1729549940; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PlRJ5hAGmdutzsO7A2TFdpdJmu1z8idPI0+9ytD9qAg=; b=nrFIx1ZBrtvZvFb6Yf7xKIaz0PBtv3fA2pcJjyO9UDBS0bZRXMs2Df+QVoFQvxT5iZ Bwcy1hDrL1fqtCWqlMn4mXrfW7WoIybUgGJ695Bqn0p6mnDPZ1vihOTtQt9wGUuEcXUD OqTMmyWiTLrAS4WP8ivHcZKbgCbJkaJM9DhNc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945140; x=1729549940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlRJ5hAGmdutzsO7A2TFdpdJmu1z8idPI0+9ytD9qAg=; b=tv8g/bnlJtalx5kSLcZbY3sCPQJ6SSiqt7pzYL1SoG7YHraAv35vjJ6C2ZhWGrtn9t 6sBvDdXpB2gB/Y9ctTABK2ij5/bQU+tSsoSLTRWET0Zw2TfwlIEjOm27aEw0bUN/qrWA 7qXDC4Qjf/uI1Cj7Y8RK4dLNzAN/q99+fuF9mlf3e7xMFKq8VNOKQo6gun5qU5unnuBZ yJc2kdzVVqMDr5KD3F0BW4eSHAv6TwaqHRPhkkg8rRgW1YgABWkD4g4Wu6a3kPlI4dw6 fsNXZmOilc0RbyF3PNIz5yQbXeEc+L/hw0nYYdJPt90zPT7PWUlbWDCWFVksMCrH4J3F 8fvg== X-Gm-Message-State: AOJu0YzQgqbXP+wkIvxuBLhEGADY9Zt61t3XfAD1xNK3yYfTsWVOi2qb 4txRKBwxKs24UIxJh4Ajcte2v7G7q9dka5VUH/FQcb5hwpQrOWn97Mi+A0urQX1UUy/kvUJWLkm 2M7DC X-Google-Smtp-Source: AGHT+IF4k12P13A5Pr+kGo8ulsz/IAHxkC0hrvEviX2hjne7woqxQVSe0TshYImiIf0o2u+LNvwoRg== X-Received: by 2002:a5d:91c4:0:b0:82c:ec0f:a081 with SMTP id ca18e2360f4ac-835486861e2mr1124793339f.4.1728945140466; Mon, 14 Oct 2024 15:32:20 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 05/20] expo: Use standard numbering for save and discard Date: Mon, 14 Oct 2024 16:31:57 -0600 Message-Id: <20241014223212.2212442-6-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Set aside some expo IDs for 'save' and 'discard' buttons. This avoids needing to store the IDs for these. Adjust the documentation and expo tool for the new EXPOID_BASE_ID value. Ignore these objects when saving and loading the cedit, since they do not contain real data. Adjust 'cedit run' to return failure when the user exits the expo without saving. Update the test for this change as well. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/cedit.c | 24 +++++++++++++++++++++--- boot/expo.c | 2 +- doc/develop/cedit.rst | 7 ++++++- doc/develop/expo.rst | 12 ++++++++---- include/expo.h | 20 ++++++++++++++++++++ include/test/cedit-test.h | 30 +++++++++++++++--------------- test/boot/cedit.c | 14 ++++++++------ test/boot/expo.c | 8 ++++---- test/boot/files/expo_ids.h | 3 +-- tools/expo.py | 33 ++++++++++++++++++++++++++++----- 10 files changed, 112 insertions(+), 41 deletions(-) diff --git a/boot/cedit.c b/boot/cedit.c index 5758cc5a0d6..cd935d4beba 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -154,7 +154,7 @@ int cedit_run(struct expo *exp) struct video_priv *vid_priv; uint scene_id; struct scene *scn; - bool done; + bool done, save; int ret; cli_ch_init(cch); @@ -164,6 +164,7 @@ int cedit_run(struct expo *exp) scene_id = ret; done = false; + save = false; do { struct expo_action act; int ichar, key; @@ -208,6 +209,15 @@ int cedit_run(struct expo *exp) case EXPOACT_OPEN: scene_set_open(scn, act.select.id, true); cedit_arange(exp, vid_priv, scene_id); + switch (scn->highlight_id) { + case EXPOID_SAVE: + done = true; + save = true; + break; + case EXPOID_DISCARD: + done = true; + break; + } break; case EXPOACT_CLOSE: scene_set_open(scn, act.select.id, false); @@ -229,6 +239,8 @@ int cedit_run(struct expo *exp) if (ret) return log_msg_ret("end", ret); + if (!save) + return -EACCES; return 0; } @@ -477,6 +489,9 @@ static int h_write_settings_env(struct scene_obj *obj, void *vpriv) const char *str; int val, ret; + if (obj->id < EXPOID_BASE_ID) + return 0; + snprintf(var, sizeof(var), "c.%s", obj->name); switch (obj->type) { @@ -549,6 +564,9 @@ static int h_read_settings_env(struct scene_obj *obj, void *vpriv) char var[60]; int val; + if (obj->id < EXPOID_BASE_ID) + return 0; + snprintf(var, sizeof(var), "c.%s", obj->name); switch (obj->type) { @@ -644,7 +662,7 @@ static int h_write_settings_cmos(struct scene_obj *obj, void *vpriv) int val, ret; uint i, seq; - if (obj->type != SCENEOBJT_MENU) + if (obj->type != SCENEOBJT_MENU || obj->id < EXPOID_BASE_ID) return 0; menu = (struct scene_obj_menu *)obj; @@ -734,7 +752,7 @@ static int h_read_settings_cmos(struct scene_obj *obj, void *vpriv) int val, ret; uint i; - if (obj->type != SCENEOBJT_MENU) + if (obj->type != SCENEOBJT_MENU || obj->id < EXPOID_BASE_ID) return 0; menu = (struct scene_obj_menu *)obj; diff --git a/boot/expo.c b/boot/expo.c index 700786ec0cc..786f665f53c 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -29,7 +29,7 @@ int expo_new(const char *name, void *priv, struct expo **expp) exp->priv = priv; INIT_LIST_HEAD(&exp->scene_head); INIT_LIST_HEAD(&exp->str_head); - exp->next_id = 1; + exp->next_id = EXPOID_BASE_ID; *expp = exp; diff --git a/doc/develop/cedit.rst b/doc/develop/cedit.rst index 82305b921f0..310be889240 100644 --- a/doc/develop/cedit.rst +++ b/doc/develop/cedit.rst @@ -94,7 +94,7 @@ them. Expo supports doing this with an enum, where every ID is listed in the enum:: enum { - ZERO, + ID_PROMPT = EXPOID_BASE_ID, ID_PROMPT, @@ -130,6 +130,11 @@ that means that something is wrong with your syntax, or perhaps you have an ID in the `.dts` file that is not mentioned in your enum. Check both files and try again. +Note that the first ID in your file must be no less that `EXPOID_BASE_ID` since +IDs before that are reserved. The `expo.py` tool automatically obtains this +value from the `expo.h` header file, but you must set the first ID to this +enum value. + Use the command interface ------------------------- diff --git a/doc/develop/expo.rst b/doc/develop/expo.rst index f7b636e5fc6..d8115c463c1 100644 --- a/doc/develop/expo.rst +++ b/doc/develop/expo.rst @@ -88,8 +88,13 @@ or even the IDs of objects. Programmatic creation of many items in a loop can be handled by allocating space in the enum for a maximum number of items, then adding the loop count to the enum values to obtain unique IDs. -Where dynamic IDs are need, use expo_set_dynamic_start() to set the start value, -so that they are allocated above the starting (enum) IDs. +Some standard IDs are reserved for certain purposes. These are defined by +`enum expo_id_t` and start at 1. `EXPOID_BASE_ID` defines the first ID which +can be used for an expo. + +An ID of 0 is invalid. If this is specified in an expo call then a valid +'dynamic IDs is allocated. Use expo_set_dynamic_start() to set the start +value, so that they are allocated above the starting (enum) IDs. All text strings are stored in a structure attached to the expo, referenced by a text ID. This makes it easier at some point to implement multiple languages or @@ -417,8 +422,7 @@ strings are provided inline in the nodes where they are used. /* this comment is parsed by the expo.py tool to insert the values below enum { - ZERO, - ID_PROMPT, + ID_PROMPT = EXPOID_BASE_ID, ID_SCENE1, ID_SCENE1_TITLE, diff --git a/include/expo.h b/include/expo.h index 50e11cd118c..d6e2ccee41b 100644 --- a/include/expo.h +++ b/include/expo.h @@ -15,6 +15,26 @@ struct udevice; #include +/** + * enum expo_id_t - standard expo IDs + * + * These are assumed to be in use at all times. Expos should use IDs starting + * from EXPOID_BASE_ID, + * + * @EXPOID_NONE: Not used, invalid ID 0 + * @EXPOID_SAVE: User has requested that the expo data be saved + * @EXPOID_DISCARD: User has requested that the expo data be discarded + * @EXPOID_BASE_ID: First ID which can be used for expo objects + */ +enum expo_id_t { + EXPOID_NONE, + + EXPOID_SAVE, + EXPOID_DISCARD, + + EXPOID_BASE_ID = 5, +}; + /** * enum expoact_type - types of actions reported by the expo * diff --git a/include/test/cedit-test.h b/include/test/cedit-test.h index 475ecc9c2dc..0d38a953415 100644 --- a/include/test/cedit-test.h +++ b/include/test/cedit-test.h @@ -9,24 +9,24 @@ #ifndef __cedit_test_h #define __cedit_test_h -#define ID_PROMPT 1 -#define ID_SCENE1 2 -#define ID_SCENE1_TITLE 3 +#define ID_PROMPT 5 +#define ID_SCENE1 6 +#define ID_SCENE1_TITLE 7 -#define ID_CPU_SPEED 4 -#define ID_CPU_SPEED_TITLE 5 -#define ID_CPU_SPEED_1 6 -#define ID_CPU_SPEED_2 7 -#define ID_CPU_SPEED_3 8 +#define ID_CPU_SPEED 8 +#define ID_CPU_SPEED_TITLE 9 +#define ID_CPU_SPEED_1 10 +#define ID_CPU_SPEED_2 11 +#define ID_CPU_SPEED_3 12 -#define ID_POWER_LOSS 9 -#define ID_AC_OFF 10 -#define ID_AC_ON 11 -#define ID_AC_MEMORY 12 +#define ID_POWER_LOSS 13 +#define ID_AC_OFF 14 +#define ID_AC_ON 15 +#define ID_AC_MEMORY 16 -#define ID_MACHINE_NAME 13 -#define ID_MACHINE_NAME_EDIT 14 +#define ID_MACHINE_NAME 17 +#define ID_MACHINE_NAME_EDIT 18 -#define ID_DYNAMIC_START 15 +#define ID_DYNAMIC_START 19 #endif diff --git a/test/boot/cedit.c b/test/boot/cedit.c index 1f7af8e5d79..0f2c2e73dd3 100644 --- a/test/boot/cedit.c +++ b/test/boot/cedit.c @@ -31,9 +31,11 @@ static int cedit_base(struct unit_test_state *uts) * ^N Move down to second item * ^M Select item * \e Quit + * + * cedit_run() returns -EACCESS so this command returns CMD_RET_FAILURE */ console_in_puts("\x0e\x0d\x0e\x0d\e"); - ut_assertok(run_command("cedit run", 0)); + ut_asserteq(1, run_command("cedit run", 0)); exp = cur_exp; scn = expo_lookup_scene_id(exp, exp->scene_id); @@ -147,14 +149,14 @@ static int cedit_env(struct unit_test_state *uts) strcpy(str, "my-machine"); ut_assertok(run_command("cedit write_env -v", 0)); - ut_assert_nextlinen("c.cpu-speed=7"); + ut_assert_nextlinen("c.cpu-speed=11"); ut_assert_nextlinen("c.cpu-speed-str=2.5 GHz"); - ut_assert_nextlinen("c.power-loss=10"); + ut_assert_nextlinen("c.power-loss=14"); ut_assert_nextlinen("c.power-loss-str=Always Off"); ut_assert_nextlinen("c.machine-name=my-machine"); ut_assert_console_end(); - ut_asserteq(7, env_get_ulong("c.cpu-speed", 10, 0)); + ut_asserteq(11, env_get_ulong("c.cpu-speed", 10, 0)); ut_asserteq_str("2.5 GHz", env_get("c.cpu-speed-str")); ut_asserteq_str("my-machine", env_get("c.machine-name")); @@ -163,8 +165,8 @@ static int cedit_env(struct unit_test_state *uts) *str = '\0'; ut_assertok(run_command("cedit read_env -v", 0)); - ut_assert_nextlinen("c.cpu-speed=7"); - ut_assert_nextlinen("c.power-loss=10"); + ut_assert_nextlinen("c.cpu-speed=11"); + ut_assert_nextlinen("c.power-loss=14"); ut_assert_nextlinen("c.machine-name=my-machine"); ut_assert_console_end(); diff --git a/test/boot/expo.c b/test/boot/expo.c index f6a6b4fd2cb..b0bf2988bf0 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -91,7 +91,7 @@ static int expo_base(struct unit_test_state *uts) *name = '\0'; ut_assertnonnull(exp); ut_asserteq(0, exp->scene_id); - ut_asserteq(1, exp->next_id); + ut_asserteq(EXPOID_BASE_ID, exp->next_id); /* Make sure the name was allocated */ ut_assertnonnull(exp->name); @@ -130,7 +130,7 @@ static int expo_scene(struct unit_test_state *uts) ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); scn = NULL; - ut_asserteq(1, exp->next_id); + ut_asserteq(EXPOID_BASE_ID, exp->next_id); strcpy(name, SCENE_NAME1); id = scene_new(exp, name, SCENE1, &scn); *name = '\0'; @@ -176,11 +176,11 @@ static int expo_scene_no_id(struct unit_test_state *uts) int id; ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); - ut_asserteq(1, exp->next_id); + ut_asserteq(EXPOID_BASE_ID, exp->next_id); strcpy(name, SCENE_NAME1); id = scene_new(exp, SCENE_NAME1, 0, &scn); - ut_asserteq(1, scn->id); + ut_asserteq(EXPOID_BASE_ID, scn->id); return 0; } diff --git a/test/boot/files/expo_ids.h b/test/boot/files/expo_ids.h index a86e0d06f6b..ffb511364b1 100644 --- a/test/boot/files/expo_ids.h +++ b/test/boot/files/expo_ids.h @@ -4,8 +4,7 @@ */ enum { - ZERO, - ID_PROMPT, + ID_PROMPT = EXPOID_BASE_ID, ID_SCENE1, ID_SCENE1_TITLE, diff --git a/tools/expo.py b/tools/expo.py index ea80c70f04e..44995f28a38 100755 --- a/tools/expo.py +++ b/tools/expo.py @@ -20,17 +20,22 @@ from u_boot_pylib import tools # Parse: # SCENE1 = 7, +# or SCENE1 = EXPOID_BASE_ID, # or SCENE2, -RE_ENUM = re.compile(r'(\S*)(\s*= (\d))?,') +RE_ENUM = re.compile(r'(\S*)(\s*= ([0-9A-Z_]+))?,') # Parse #define "string" RE_DEF = re.compile(r'#define (\S*)\s*"(.*)"') -def calc_ids(fname): +# Parse EXPOID_BASE_ID = 5, +RE_BASE_ID = re.compile(r'\s*EXPOID_BASE_ID\s*= (\d+),') + +def calc_ids(fname, base_id): """Figure out the value of the enums in a C file Args: fname (str): Filename to parse + base_id (int): Base ID (value of EXPOID_BASE_ID) Returns: OrderedDict(): @@ -55,8 +60,12 @@ def calc_ids(fname): if not line or line.startswith('/*'): continue m_enum = RE_ENUM.match(line) - if m_enum.group(3): - cur_id = int(m_enum.group(3)) + enum_name = m_enum.group(3) + if enum_name: + if enum_name == 'EXPOID_BASE_ID': + cur_id = base_id + else: + cur_id = int(enum_name) vals[m_enum.group(1)] = cur_id cur_id += 1 else: @@ -67,10 +76,24 @@ def calc_ids(fname): return vals +def find_base_id(): + fname = 'include/expo.h' + base_id = None + with open(fname, 'r', encoding='utf-8') as inf: + for line in inf.readlines(): + m_base_id = RE_BASE_ID.match(line) + if m_base_id: + base_id = int(m_base_id.group(1)) + if base_id is None: + raise ValueError('EXPOID_BASE_ID not found in expo.h') + #print(f'EXPOID_BASE_ID={base_id}') + return base_id + def run_expo(args): """Run the expo program""" + base_id = find_base_id() fname = args.enum_fname or args.layout - ids = calc_ids(fname) + ids = calc_ids(fname, base_id) if not ids: print(f"Warning: No enum ID values found in file '{fname}'") From patchwork Mon Oct 14 22:31:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997106 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XFbt3UTm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBnz6lqwz1xsc for ; Tue, 15 Oct 2024 09:33:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA4278921F; Tue, 15 Oct 2024 00:32:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XFbt3UTm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 212AB89248; Tue, 15 Oct 2024 00:32:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 172B189231 for ; Tue, 15 Oct 2024 00:32:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-8354845c5dcso204370439f.0 for ; Mon, 14 Oct 2024 15:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945141; x=1729549941; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XqAl579Sb/B5OROKNKli/gMiX2fZ4RdkqUkbYq8D8Ok=; b=XFbt3UTmmrxwDqHna5qUJ2J5QT1nc6V4OsBf8mTAzgDNWN72PXgvRrAZUwr55d4aAr tkhWCySZqBlGRR9W7Te2OItFRnDdiiYV+7E42tamFAo9dFP9mKmjhyYQtt18w13EfUDK FXgiWbeYd6s8hzTpuFeGV25UEydBFQSe+zOP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945141; x=1729549941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XqAl579Sb/B5OROKNKli/gMiX2fZ4RdkqUkbYq8D8Ok=; b=VK1be4ZujCxAmcO1IVqrrJlScZO2x3+J2Q4mX6afJdsabCssnD195NfH6qWNRCluwY oDw4qMShRK8Lb0Vi+hdAhquRlsLmCrYQveRfqpEhfe0YucWfOLqb1VDNhetFuDRshOdn s096VS8yl8m5ztDmHN6lP3bVpjpAYW+rILRRWMCcm/1S80dRXzQwkeCaBSrf3tWfzuiN r2FKmUB6xmbYv4y6UPDqX4OiWMsJbTAQ3EYWr1PHblM3U5qUDVEh5z31nNhpLNL1R9cS r1qrrfSmUFPGYQ4nEgnWDkNuGifi7B8uzcw49qQYEkTpjUy0dWBe9Cug28BLRZaxlPKA 0rrA== X-Gm-Message-State: AOJu0YwFlKVJYAwiTRSjxu4w1YSHnPZuzXfS6yrmM0Pee+ZW4IiwIeN7 QI5uKmkpsnfchN/+2qqhM2XFNEGYoB0GU9/iPwjCWknSVh78w4RUOc9Gih5UY/HRLdMaQ+FCOts 8OQ== X-Google-Smtp-Source: AGHT+IGaAX4WUHR8wIxl80P/7HRnRZPc3LO3Z9zhlYCOmR33wxhOt8aa1vD7sQYoFXoPUXSSBw3Crw== X-Received: by 2002:a05:6e02:13a8:b0:3a0:a385:911d with SMTP id e9e14a558f8ab-3a3b5c71f26mr118441415ab.0.1728945141565; Mon, 14 Oct 2024 15:32:21 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:21 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 06/20] expo: Allow menu items to have values Date: Mon, 14 Oct 2024 16:31:58 -0600 Message-Id: <20241014223212.2212442-7-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean At present menu items are stored according to their sequence number in the menu. In some cases we may want to have holes in that sequence, or not use a sequence at all. Add a new 'value' property for menu items. This will be used for reading and writing, if present. If there is no 'value' property, then the normal sequence number will be used instead. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/cedit.dtsi | 3 +++ boot/expo_build.c | 16 ++++++++++++---- boot/scene_internal.h | 10 ++++++++++ boot/scene_menu.c | 17 +++++++++++++++++ doc/develop/expo.rst | 10 ++++++++++ include/expo.h | 2 ++ test/boot/expo.c | 1 + test/boot/files/expo_layout.dts | 3 +++ 8 files changed, 58 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/dts/cedit.dtsi b/arch/sandbox/dts/cedit.dtsi index 9bd84e62936..facd7a49bef 100644 --- a/arch/sandbox/dts/cedit.dtsi +++ b/arch/sandbox/dts/cedit.dtsi @@ -39,6 +39,9 @@ /* IDs for the menu items */ item-id = ; + + /* values for the menu items */ + item-value = <0 3 6>; }; power-loss { diff --git a/boot/expo_build.c b/boot/expo_build.c index a4df798adeb..fece3ea67f9 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -227,10 +227,10 @@ static void list_strings(struct build_info *info) static int menu_build(struct build_info *info, ofnode node, struct scene *scn, uint id, struct scene_obj **objp) { + const u32 *item_ids, *item_values; struct scene_obj_menu *menu; + int ret, size, i, num_items; uint title_id, menu_id; - const u32 *item_ids; - int ret, size, i; const char *name; name = ofnode_get_name(node); @@ -254,9 +254,15 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn, return log_msg_ret("itm", -EINVAL); if (!size || size % sizeof(u32)) return log_msg_ret("isz", -EINVAL); - size /= sizeof(u32); + num_items = size / sizeof(u32); - for (i = 0; i < size; i++) { + item_values = ofnode_read_prop(node, "item-value", &size); + if (item_values) { + if (size != num_items * sizeof(u32)) + return log_msg_ret("vsz", -EINVAL); + } + + for (i = 0; i < num_items; i++) { struct scene_menitem *item; uint label, key, desc; @@ -280,6 +286,8 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn, desc, 0, 0, &item); if (ret < 0) return log_msg_ret("mi", ret); + if (item_values) + item->value = fdt32_to_cpu(item_values[i]); } *objp = &menu->obj; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index be25f6a8b96..ec9008ea593 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -281,6 +281,16 @@ struct scene_menitem *scene_menuitem_find(const struct scene_obj_menu *menu, struct scene_menitem *scene_menuitem_find_seq(const struct scene_obj_menu *menu, uint seq); +/** + * scene_menuitem_find_val() - Find the menu item with a given value + * + * @menu: Menu to check + * @find_val: Value to look for + * Return: menu item if found, else NULL + */ +struct scene_menitem *scene_menuitem_find_val(const struct scene_obj_menu *menu, + int val); + /** * scene_bbox_union() - update bouding box with the demensions of an object * diff --git a/boot/scene_menu.c b/boot/scene_menu.c index c331f6670cc..04ff1590bc1 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -61,6 +61,22 @@ struct scene_menitem *scene_menuitem_find_seq(const struct scene_obj_menu *menu, return NULL; } +struct scene_menitem *scene_menuitem_find_val(const struct scene_obj_menu *menu, + int val) +{ + struct scene_menitem *item; + uint i; + + i = 0; + list_for_each_entry(item, &menu->item_head, sibling) { + if (item->value == val) + return item; + i++; + } + + return NULL; +} + /** * update_pointers() - Update the pointer object and handle highlights * @@ -416,6 +432,7 @@ int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id, item->desc_id = desc_id; item->preview_id = preview_id; item->flags = flags; + item->value = INT_MAX; list_add_tail(&item->sibling, &menu->item_head); if (itemp) diff --git a/doc/develop/expo.rst b/doc/develop/expo.rst index d8115c463c1..cc7c36173db 100644 --- a/doc/develop/expo.rst +++ b/doc/develop/expo.rst @@ -361,6 +361,13 @@ item-id Specifies the ID for each menu item. These are used for checking which item has been selected. +item-value + type: u32 list, optional + + Specifies the value for each menu item. These are used for saving and + loading. If this is omitted the value is its position in the menu (0..n-1). + Valid values are positive and negative integers INT_MIN...(INT_MAX - 1). + item-label / item-label-id type: string list / u32 list, required @@ -474,6 +481,9 @@ strings are provided inline in the nodes where they are used. /* IDs for the menu items */ item-id = ; + + /* values for the menu items */ + item-value = <(-1) 3 6>; }; power-loss { diff --git a/include/expo.h b/include/expo.h index d6e2ccee41b..acff98ea65b 100644 --- a/include/expo.h +++ b/include/expo.h @@ -330,6 +330,7 @@ enum scene_menuitem_flags_t { * @desc_id: ID of text object to use as the description text * @preview_id: ID of the preview object, or 0 if none * @flags: Flags for this item + * @value: Value for this item, or INT_MAX to use sequence * @sibling: Node to link this item to its siblings */ struct scene_menitem { @@ -340,6 +341,7 @@ struct scene_menitem { uint desc_id; uint preview_id; uint flags; + int value; struct list_head sibling; }; diff --git a/test/boot/expo.c b/test/boot/expo.c index b0bf2988bf0..1c2e746decc 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -717,6 +717,7 @@ static int expo_test_build(struct unit_test_state *uts) ut_asserteq(0, item->desc_id); ut_asserteq(0, item->preview_id); ut_asserteq(0, item->flags); + ut_asserteq(0, item->value); txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE); ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id)); diff --git a/test/boot/files/expo_layout.dts b/test/boot/files/expo_layout.dts index bed552288f4..ebe5adb27bb 100644 --- a/test/boot/files/expo_layout.dts +++ b/test/boot/files/expo_layout.dts @@ -39,6 +39,9 @@ item-id = ; + /* values for the menu items */ + item-value = <(-1) 3 6>; + start-bit = <0x400>; bit-length = <2>; }; From patchwork Mon Oct 14 22:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997108 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=C5Tisx++; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBpK6xkYz1xsc for ; Tue, 15 Oct 2024 09:33:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B355189247; Tue, 15 Oct 2024 00:32:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="C5Tisx++"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D7918921B; Tue, 15 Oct 2024 00:32:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E800A8921C for ; Tue, 15 Oct 2024 00:32:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id ca18e2360f4ac-835464abfa7so158517339f.0 for ; Mon, 14 Oct 2024 15:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945142; x=1729549942; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y5H08RIShF2uL9zUQ6iF/E3wVm0Tzik7+Gq1/q8sFQc=; b=C5Tisx++OTqsjU8K5UMvsdHe0BFc8YYcSmrvYyuzKuEbloD8u5PXvol8HaW/GcbRn9 Y7EFCX6olEMpb8F8NjpD9aRYMBwNkHhbJWkPz3/OQoooaji0boS+ZRtBaOfSgFFB4B5k fzFhHfU5oAIlaGhwxtM15vvnfB0AsXGJJ+aok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945142; x=1729549942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y5H08RIShF2uL9zUQ6iF/E3wVm0Tzik7+Gq1/q8sFQc=; b=Tk6EcAHRc+/3rDPMMNksiBP6Zxb0Af5qMuI3LnOLF9xQQU0yx6vRRuC6yU606GaFRm shdcDzVvdrM26poGicVoICqpfLhgAiT0jO9HlfBFBqLTAJtME4GqAgf2K2qpgRgyBid3 wtAsnQDcws9XvKW6vx3/+OZRXH/uEGeJa8mmcxxUK3g9IXhV31CNuc/suGQPvo1g1JLH 7NiUV+06kb0b9Oztgd3+713RSn4U7cB1Dtbo4ukFE0gg1/W5NIGlHOeFLe2wl9oCWcpu prriaI4I+RQtMF/wn3zWUvxCLl/yzL/ciJQ0Si1oDhD2WVOkpkOcd1TyWq0rXCQN4ME2 uKCg== X-Gm-Message-State: AOJu0YwZHakHpkyrjsckH5uwX4j+KmfOCf7wn5awIkQn6UV6PRD/Q1qs Ew4QfV2OBcw5zKe1wRkmotv+0TPV/qGfuN2Ms70X/zXHi1DoXfYVTniIVIgoiBx6fxy5LgqTB2p 8128g X-Google-Smtp-Source: AGHT+IFhRJfHRAlVoQuDRNFm/NrMpq1mnmU2wQi6YPcPK2RQADkvk8Yw0o9DFs94EUNIZ65OfOaiOQ== X-Received: by 2002:a05:6e02:b49:b0:3a2:e9ff:255a with SMTP id e9e14a558f8ab-3a3bcdfe432mr82302505ab.22.1728945142565; Mon, 14 Oct 2024 15:32:22 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 07/20] expo: Add a little more cedit CMOS logging Date: Mon, 14 Oct 2024 16:31:59 -0600 Message-Id: <20241014223212.2212442-8-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add some more logging in the CMOS read/write code. Tidy up a few comments while we are here. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/cedit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/boot/cedit.c b/boot/cedit.c index cd935d4beba..9d48d3ed50b 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -584,7 +584,7 @@ static int h_read_settings_env(struct scene_obj *obj, void *vpriv) /* * note that no validation is done here, to make sure the ID is - * valid * and actually points to a menu item + * valid and actually points to a menu item */ menu->cur_item_id = val; break; @@ -718,6 +718,7 @@ int cedit_write_settings_cmos(struct expo *exp, struct udevice *dev, } /* write the data to the RTC */ + log_debug("Writing CMOS\n"); first = CMOS_MAX_BYTES; last = -1; for (i = 0, count = 0; i < CMOS_MAX_BYTES; i++) { @@ -785,6 +786,7 @@ static int h_read_settings_cmos(struct scene_obj *obj, void *vpriv) } /* update the current item */ + log_debug("look for menuitem value %d in menu %d\n", val, menu->obj.id); mi = scene_menuitem_find_seq(menu, val); if (!mi) return log_msg_ret("seq", -ENOENT); @@ -819,7 +821,7 @@ int cedit_read_settings_cmos(struct expo *exp, struct udevice *dev, goto done; } - /* read the data to the RTC */ + /* indicate what bytes were read from the RTC */ first = CMOS_MAX_BYTES; last = -1; for (i = 0, count = 0; i < CMOS_MAX_BYTES; i++) { From patchwork Mon Oct 14 22:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997109 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZvIJXtx2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBpW3mqtz1xsc for ; Tue, 15 Oct 2024 09:33:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C8E989285; Tue, 15 Oct 2024 00:32:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZvIJXtx2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4076589235; Tue, 15 Oct 2024 00:32:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CF1868922C for ; Tue, 15 Oct 2024 00:32:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id ca18e2360f4ac-8354851fcabso196684639f.2 for ; Mon, 14 Oct 2024 15:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945143; x=1729549943; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a+dDkCRanyP1MT1+/9Uck799Jqf/n5Mr5ow7egTo2mQ=; b=ZvIJXtx2L/9aaAWOLzHxsSDYTZRM2Zd60WpauFr8DcYgPI6AO//z85/te6ThlGWe66 nrdgEzRZOq2xIyfJH5R9lHwKCv4XIfYUTo0SoiefgklLNzPcNBWMWPID9liJ4yhah76z HhEeaN3amiu2rahiyna3Nqs19+akJXWbH5bvw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945143; x=1729549943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a+dDkCRanyP1MT1+/9Uck799Jqf/n5Mr5ow7egTo2mQ=; b=eWdlMxT/WBjKwfcCagtWYV/ulXrzeb+Rfnle7EGZPONeDtG/amxCREqT7MMoMZbNQH wHhKrrTYzDldAMBv2//9HbkoLehlRevoBso/MLmyic1B4k8aYyYsG2W5EHkWGq5M5GiU ue1LrZHJdgHLi/K6wSHhj65/lpHfZqdRcTSM9SZDksp066J0MmAtWujPt8eJ0wVNvBxd 35C0kS6+Ea5FKCDE+qh99YouwBB03s8DWzLfeNrSmWb5ba5DrA84+xJoOO01vuclg0EO TjOHeLk4WAG7MT7a7S9diZo6RBMx005QeN6hLqhr4XaBjAEd1LLw9V/oAA73i8Z21tqO f8tg== X-Gm-Message-State: AOJu0Yx8kzotimk5dS2mzogFWZ6ThBAGln9wQJcbQjTDc7q4goEyGXcT qt73YuT0LZzTlXRukeKSV5pCofu9af4R1qXEcfdO596XP7O5/25Y4BFwy+VQi/x7kb66L6/7i+K PdpQh X-Google-Smtp-Source: AGHT+IEz1quTEVNJJe6qi4ShgiFddgu+0CY9ZlkynnlSKWlR8J+QX4N4/TxbS0B8yx5ckjKKodykLA== X-Received: by 2002:a05:6e02:1c4c:b0:3a0:933a:2a0a with SMTP id e9e14a558f8ab-3a3b5f44f8amr117218665ab.7.1728945143394; Mon, 14 Oct 2024 15:32:23 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt , Mattijs Korpershoek Subject: [PATCH v3 08/20] expo: Support menu-item values in cedit Date: Mon, 14 Oct 2024 16:32:00 -0600 Message-Id: <20241014223212.2212442-9-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Update the cedit read/write functions to support menu items with values. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/cedit.c | 148 +++++++++++++++++++++----------- boot/scene_menu.c | 2 +- doc/usage/cmd/cedit.rst | 15 +++- test/boot/cedit.c | 8 +- test/boot/files/expo_layout.dts | 4 +- 5 files changed, 117 insertions(+), 60 deletions(-) diff --git a/boot/cedit.c b/boot/cedit.c index 9d48d3ed50b..d12892fbc4a 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -293,11 +293,49 @@ static int get_cur_menuitem_text(const struct scene_obj_menu *menu, return 0; } +/** + * get_cur_menuitem_val() - Get the value of a menu's current item + * + * Obtains the value of the current item in the menu. If no value, then + * enumerates the items of a menu (0, 1, 2) and returns the sequence number of + * the currently selected item. If the first item is selected, this returns 0; + * if the second, 1; etc. + * + * @menu: Menu to check + * @valp: Returns current-item value / sequence number + * Return: 0 on success, else -ve error value + */ +static int get_cur_menuitem_val(const struct scene_obj_menu *menu, int *valp) +{ + const struct scene_menitem *mi; + int seq; + + seq = 0; + list_for_each_entry(mi, &menu->item_head, sibling) { + if (mi->id == menu->cur_item_id) { + *valp = mi->value == INT_MAX ? seq : mi->value; + return 0; + } + seq++; + } + + return log_msg_ret("nf", -ENOENT); +} + +/** + * write_dt_string() - Write a string to the devicetree, expanding if needed + * + * If this fails, it tries again after expanding the devicetree a little + * + * @buf: Buffer containing the devicetree + * @name: Property name to use + * @str: String value + * Return: 0 if OK, -EFAULT if something went horribly wrong + */ static int write_dt_string(struct abuf *buf, const char *name, const char *str) { int ret, i; - /* write the text of the current item */ ret = -EAGAIN; for (i = 0; ret && i < 2; i++) { ret = fdt_property_string(abuf_data(buf), name, str); @@ -315,6 +353,38 @@ static int write_dt_string(struct abuf *buf, const char *name, const char *str) return 0; } +/** + * write_dt_u32() - Write an int to the devicetree, expanding if needed + * + * If this fails, it tries again after expanding the devicetree a little + * + * @buf: Buffer containing the devicetree + * @name: Property name to use + * @lva: Integer value + * Return: 0 if OK, -EFAULT if something went horribly wrong + */ +static int write_dt_u32(struct abuf *buf, const char *name, uint val) +{ + int ret, i; + + /* write the text of the current item */ + ret = -EAGAIN; + for (i = 0; ret && i < 2; i++) { + ret = fdt_property_u32(abuf_data(buf), name, val); + if (!i) { + ret = check_space(ret, buf); + if (ret) + return log_msg_ret("rs2", -ENOMEM); + } + } + + /* this should not happen */ + if (ret) + return log_msg_ret("str", -EFAULT); + + return 0; +} + static int h_write_settings(struct scene_obj *obj, void *vpriv) { struct cedit_iter_priv *priv = vpriv; @@ -339,23 +409,21 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv) const struct scene_obj_menu *menu; const char *str; char name[80]; - int i; + int val; /* write the ID of the current item */ menu = (struct scene_obj_menu *)obj; - ret = -EAGAIN; - for (i = 0; ret && i < 2; i++) { - ret = fdt_property_u32(abuf_data(buf), obj->name, - menu->cur_item_id); - if (!i) { - ret = check_space(ret, buf); - if (ret) - return log_msg_ret("res", -ENOMEM); - } - } - /* this should not happen */ + ret = write_dt_u32(buf, obj->name, menu->cur_item_id); if (ret) - return log_msg_ret("wrt", -EFAULT); + return log_msg_ret("wrt", ret); + + snprintf(name, sizeof(name), "%s-value", obj->name); + ret = get_cur_menuitem_val(menu, &val); + if (ret < 0) + return log_msg_ret("cur", ret); + ret = write_dt_u32(buf, name, val); + if (ret) + return log_msg_ret("wr2", ret); ret = get_cur_menuitem_text(menu, &str); if (ret) @@ -521,6 +589,14 @@ static int h_write_settings_env(struct scene_obj *obj, void *vpriv) ret = env_set(name, str); if (ret) return log_msg_ret("st2", ret); + + ret = get_cur_menuitem_val(menu, &val); + if (ret < 0) + return log_msg_ret("cur", ret); + snprintf(name, sizeof(name), "c.%s-value", obj->name); + if (priv->verbose) + printf("%s=%d\n", name, val); + break; case SCENEOBJT_TEXTLINE: { const struct scene_obj_textline *tline; @@ -624,43 +700,12 @@ int cedit_read_settings_env(struct expo *exp, bool verbose) return 0; } -/** - * get_cur_menuitem_seq() - Get the sequence number of a menu's current item - * - * Enumerates the items of a menu (0, 1, 2) and returns the sequence number of - * the currently selected item. If the first item is selected, this returns 0; - * if the second, 1; etc. - * - * @menu: Menu to check - * Return: Sequence number on success, else -ve error value - */ -static int get_cur_menuitem_seq(const struct scene_obj_menu *menu) -{ - const struct scene_menitem *mi; - int seq, found; - - seq = 0; - found = -1; - list_for_each_entry(mi, &menu->item_head, sibling) { - if (mi->id == menu->cur_item_id) { - found = seq; - break; - } - seq++; - } - - if (found == -1) - return log_msg_ret("nf", -ENOENT); - - return found; -} - static int h_write_settings_cmos(struct scene_obj *obj, void *vpriv) { const struct scene_obj_menu *menu; struct cedit_iter_priv *priv = vpriv; int val, ret; - uint i, seq; + uint i; if (obj->type != SCENEOBJT_MENU || obj->id < EXPOID_BASE_ID) return 0; @@ -668,11 +713,10 @@ static int h_write_settings_cmos(struct scene_obj *obj, void *vpriv) menu = (struct scene_obj_menu *)obj; val = menu->cur_item_id; - ret = get_cur_menuitem_seq(menu); + ret = get_cur_menuitem_val(menu, &val); if (ret < 0) return log_msg_ret("cur", ret); - seq = ret; - log_debug("%s: seq=%d\n", menu->obj.name, seq); + log_debug("%s: val=%d\n", menu->obj.name, val); /* figure out where to place this item */ if (!obj->bit_length) @@ -680,11 +724,11 @@ static int h_write_settings_cmos(struct scene_obj *obj, void *vpriv) if (obj->start_bit + obj->bit_length > CMOS_MAX_BITS) return log_msg_ret("bit", -E2BIG); - for (i = 0; i < obj->bit_length; i++, seq >>= 1) { + for (i = 0; i < obj->bit_length; i++, val >>= 1) { uint bitnum = obj->start_bit + i; priv->mask[CMOS_BYTE(bitnum)] |= 1 << CMOS_BIT(bitnum); - if (seq & 1) + if (val & 1) priv->value[CMOS_BYTE(bitnum)] |= BIT(CMOS_BIT(bitnum)); log_debug("bit %x %x %x\n", bitnum, priv->mask[CMOS_BYTE(bitnum)], @@ -787,7 +831,7 @@ static int h_read_settings_cmos(struct scene_obj *obj, void *vpriv) /* update the current item */ log_debug("look for menuitem value %d in menu %d\n", val, menu->obj.id); - mi = scene_menuitem_find_seq(menu, val); + mi = scene_menuitem_find_val(menu, val); if (!mi) return log_msg_ret("seq", -ENOENT); diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 04ff1590bc1..17150af145d 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -69,7 +69,7 @@ struct scene_menitem *scene_menuitem_find_val(const struct scene_obj_menu *menu, i = 0; list_for_each_entry(item, &menu->item_head, sibling) { - if (item->value == val) + if (item->value == INT_MAX ? val == i : item->value == val) return item; i++; } diff --git a/doc/usage/cmd/cedit.rst b/doc/usage/cmd/cedit.rst index 5670805a00e..f29f1b3f388 100644 --- a/doc/usage/cmd/cedit.rst +++ b/doc/usage/cmd/cedit.rst @@ -107,8 +107,10 @@ That results in:: / { cedit-values { cpu-speed = <0x00000006>; + cpu-speed-value = <0x00000003>; cpu-speed-str = "2 GHz"; power-loss = <0x0000000a>; + power-loss-value = <0x00000000>; power-loss-str = "Always Off"; }; } @@ -118,16 +120,23 @@ That results in:: This shows settings being stored in the environment:: => cedit write_env -v - c.cpu-speed=7 + c.cpu-speed=11 c.cpu-speed-str=2.5 GHz - c.power-loss=12 - c.power-loss-str=Memory + c.cpu-speed-value=3 + c.power-loss=14 + c.power-loss-str=Always Off + c.power-loss-value=0 + c.machine-name=my-machine + c.cpu-speed=11 + c.power-loss=14 + c.machine-name=my-machine => print ... c.cpu-speed=6 c.cpu-speed-str=2 GHz c.power-loss=10 c.power-loss-str=Always Off + c.machine-name=my-machine ... => cedit read_env -v diff --git a/test/boot/cedit.c b/test/boot/cedit.c index 0f2c2e73dd3..4d1b99bc2ea 100644 --- a/test/boot/cedit.c +++ b/test/boot/cedit.c @@ -96,14 +96,16 @@ static int cedit_fdt(struct unit_test_state *uts) ut_asserteq(ID_CPU_SPEED_2, ofnode_read_u32_default(node, "cpu-speed", 0)); + ut_asserteq(3, + ofnode_read_u32_default(node, "cpu-speed-value", 0)); ut_asserteq_str("2.5 GHz", ofnode_read_string(node, "cpu-speed-str")); ut_asserteq_str("my-machine", ofnode_read_string(node, "machine-name")); - /* There should only be 5 properties */ + /* There should only be 7 properties */ for (i = 0, ofnode_first_property(node, &prop); ofprop_valid(&prop); i++, ofnode_next_property(&prop)) ; - ut_asserteq(5, i); + ut_asserteq(7, i); ut_assert_console_end(); @@ -151,8 +153,10 @@ static int cedit_env(struct unit_test_state *uts) ut_assertok(run_command("cedit write_env -v", 0)); ut_assert_nextlinen("c.cpu-speed=11"); ut_assert_nextlinen("c.cpu-speed-str=2.5 GHz"); + ut_assert_nextlinen("c.cpu-speed-value=3"); ut_assert_nextlinen("c.power-loss=14"); ut_assert_nextlinen("c.power-loss-str=Always Off"); + ut_assert_nextlinen("c.power-loss-value=0"); ut_assert_nextlinen("c.machine-name=my-machine"); ut_assert_console_end(); diff --git a/test/boot/files/expo_layout.dts b/test/boot/files/expo_layout.dts index ebe5adb27bb..9bc1e4950b9 100644 --- a/test/boot/files/expo_layout.dts +++ b/test/boot/files/expo_layout.dts @@ -40,10 +40,10 @@ ID_CPU_SPEED_3>; /* values for the menu items */ - item-value = <(-1) 3 6>; + item-value = <0 3 6>; start-bit = <0x400>; - bit-length = <2>; + bit-length = <3>; }; power-loss { From patchwork Mon Oct 14 22:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997110 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eHHqUEKo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBpj1w1sz1xsc for ; Tue, 15 Oct 2024 09:33:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ACC6C8921C; Tue, 15 Oct 2024 00:32:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eHHqUEKo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D54889294; Tue, 15 Oct 2024 00:32:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2358389251 for ; Tue, 15 Oct 2024 00:32:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a1a90bd015so13019385ab.1 for ; Mon, 14 Oct 2024 15:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945144; x=1729549944; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/oxrt4YqIxAERj24WV+Erm5om9gFl0fh+xMwjJZkScQ=; b=eHHqUEKoR/MEoi2TUF/hQrv9+eOhAjmhmY+LtRxStwm79fPy8VV9W+rh3sOxBJGNkY wGblW2zhYK6dYuA++OLA1zq9oBaczzh5puaLoiLRfY7I/nsVkTxDRh8YH6B06JI09UX4 jERSuhrzj95LBz+GCB/PgIEt47Vp8vv69m4/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945144; x=1729549944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/oxrt4YqIxAERj24WV+Erm5om9gFl0fh+xMwjJZkScQ=; b=Fne3lHJAhlrl12Wk7hp2FOgHmg0g6eVXDB5fhPi4SbH5ib5rGWLFpukH0Ri/p70vBs PhoRj22EPlxx1JrAQEY54dK2f7QXimiV5n2iarNt6BOXexANJckt3UE04Ki6C4Inf2un m9H19TzikChpAhaU1V9c8A3zGyHAMDDY186p8iHgw5jQUfmA+7y9FmmUg+a/5zRlURo3 8wD+8b5jlTSB2bFHDbG250Q9Mk8QNjosAUU5HaIlhlyamZ4lRG5pLN1ZQdvd1CEoDrzD YCIzpWBsjnZud6wUsnFFWMJWHvGlSEu0gjsFpdQgw6gdCNgJIpFF6wbpZloQEzAyHqzp KHAw== X-Gm-Message-State: AOJu0YzW+iUI5M3+kCM9hm0qBgOUu81uHERJEwO1XNSJJvocYSsyBhmn yAOcxDTX/AK50In+GKg0rG5ePSqSQz9mjTYKzvctMCD5zS7kHYc4/nkFEq8HtlXcZBM9vMLYREn f1g== X-Google-Smtp-Source: AGHT+IFgeQ808qv+w1Zee6P2OH2nB3+Xr+mbxmGnJAmIb45VxUv+0Y6fmcqA9PHaq1eUxhkNMg7xfg== X-Received: by 2002:a05:6e02:1c88:b0:3a3:b1c4:8176 with SMTP id e9e14a558f8ab-3a3b5fc417amr105143265ab.24.1728945144135; Mon, 14 Oct 2024 15:32:24 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 09/20] expo: Drop unneceesary calls to expo_str() Date: Mon, 14 Oct 2024 16:32:01 -0600 Message-Id: <20241014223212.2212442-10-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The scene_txt_str() function calls expo_str() so there is no need to call it beforehand. Drop this unnecessary code. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/expo_build.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/boot/expo_build.c b/boot/expo_build.c index fece3ea67f9..930cc40ec07 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -46,7 +46,6 @@ int add_txt_str(struct build_info *info, ofnode node, struct scene *scn, const char *find_name, uint obj_id) { const char *text; - uint str_id; int ret; info->err_prop = find_name; @@ -67,12 +66,7 @@ int add_txt_str(struct build_info *info, ofnode node, struct scene *scn, return log_msg_ret("id", -EINVAL); } - ret = expo_str(scn->expo, find_name, 0, text); - if (ret < 0) - return log_msg_ret("add", ret); - str_id = ret; - - ret = scene_txt_str(scn, find_name, obj_id, str_id, text, NULL); + ret = scene_txt_str(scn, find_name, obj_id, 0, text, NULL); if (ret < 0) return log_msg_ret("add", ret); @@ -94,7 +88,6 @@ int add_txt_str_list(struct build_info *info, ofnode node, struct scene *scn, const char *find_name, int index, uint obj_id) { const char *text; - uint str_id; int ret; ret = ofnode_read_string_index(node, find_name, index, &text); @@ -114,12 +107,7 @@ int add_txt_str_list(struct build_info *info, ofnode node, struct scene *scn, return log_msg_ret("id", -EINVAL); } - ret = expo_str(scn->expo, find_name, 0, text); - if (ret < 0) - return log_msg_ret("add", ret); - str_id = ret; - - ret = scene_txt_str(scn, find_name, obj_id, str_id, text, NULL); + ret = scene_txt_str(scn, find_name, obj_id, 0, text, NULL); if (ret < 0) return log_msg_ret("add", ret); From patchwork Mon Oct 14 22:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997111 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IHupdONV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBps6RZ2z1xsc for ; Tue, 15 Oct 2024 09:33:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3345189294; Tue, 15 Oct 2024 00:32:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="IHupdONV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3735E8925E; Tue, 15 Oct 2024 00:32:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9147489256 for ; Tue, 15 Oct 2024 00:32:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-83542d9d7c1so206953839f.2 for ; Mon, 14 Oct 2024 15:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945145; x=1729549945; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hbMdb8Gao9Swi5XTfv6LFdV8qPuVGjgZfIFKj/x4dck=; b=IHupdONVTYbU11QDYkCvQBytxeV5PSAI0ODAihwM3/iXetYm1JGY0Yq5pVidZyY/+W ihPM5TZjW/bQMcKbCpKZ+Oi90xZDRLh/SVp86ILE2/fPmpbO4KTNeSv3v79fqxI6iPNn KihynnodVJa9m9eYk83PcIJkGgH0/YcEdWBi8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945145; x=1729549945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hbMdb8Gao9Swi5XTfv6LFdV8qPuVGjgZfIFKj/x4dck=; b=NPFk2H8mp0dJZMHbzK/+RYkY+S0cgaXnxXtYLH0GJlxkQ9Oh6UXxLSKA7Dt5AGp59S IeSqnv27hc74IMTvgrSmhxnKvAyQ4F+H/XQe1M63ARBadqI7H8w0rqgk3EYYcsMSF22f SDpJU1j794y5PNBHeqCJxd4awzwZ7P5Cg/QlFKmHa9/QIR1ySobE5oQ7H1TzfyTEntDs 49BoUtTrAl8CiLnzMqBuUP41CoJLaeW33q4pgfMn7O2zKAujCR30o+VomwZ9i+8z8R5Y oh4n2kDHZ2zlXEOSB9Wmo8dwQApGvvncC+WLHQgmekpFGfepzct+XvC+nXc8xYCLc1dY nAww== X-Gm-Message-State: AOJu0YydvWIpBMnA0HKRwkQ4X9wfAfbXVad5R8hG5w/PgYAoFOftiETn Y8C0NCruZOPXC5z4WOtzvg1XRZ7mIpRILyNzKEhOS554zBoXX+TPI9HG8tSTeTBlxQ1UFhEHXSG K9Q== X-Google-Smtp-Source: AGHT+IFXd5zvziF22tEW4VLwEHh2YY7HYjJNVB1EF1rXijsgsY3G+5DGTXfawyLphuKSp7G677G1eQ== X-Received: by 2002:a05:6e02:1d8d:b0:3a0:533e:3c0a with SMTP id e9e14a558f8ab-3a3b5f31b3bmr119359495ab.7.1728945145170; Mon, 14 Oct 2024 15:32:25 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:24 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 10/20] expo: Drop scene_title_set() Date: Mon, 14 Oct 2024 16:32:02 -0600 Message-Id: <20241014223212.2212442-11-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This function is really just an assignment, so serves no useful purpose. Drop it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/expo_build.c | 4 ++-- boot/scene.c | 7 ------- include/expo.h | 9 --------- test/boot/expo.c | 2 +- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/boot/expo_build.c b/boot/expo_build.c index 930cc40ec07..d97347e1725 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -404,7 +404,7 @@ static int scene_build(struct build_info *info, ofnode scn_node, if (ret < 0) return log_msg_ret("tit", ret); title_id = ret; - scene_title_set(scn, title_id); + scn->title_id = title_id; ret = add_txt_str(info, scn_node, scn, "prompt", 0); if (ret < 0) @@ -420,7 +420,7 @@ static int scene_build(struct build_info *info, ofnode scn_node, return 0; } -int build_it(struct build_info *info, ofnode root, struct expo **expp) +static int build_it(struct build_info *info, ofnode root, struct expo **expp) { ofnode scenes, node; struct expo *exp; diff --git a/boot/scene.c b/boot/scene.c index a4836000b28..3290a40222a 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -70,13 +70,6 @@ void scene_destroy(struct scene *scn) free(scn); } -int scene_title_set(struct scene *scn, uint id) -{ - scn->title_id = id; - - return 0; -} - int scene_obj_count(struct scene *scn) { return list_count_nodes(&scn->obj_head); diff --git a/include/expo.h b/include/expo.h index acff98ea65b..8cb37260db5 100644 --- a/include/expo.h +++ b/include/expo.h @@ -540,15 +540,6 @@ void scene_set_highlight_id(struct scene *scn, uint id); */ int scene_set_open(struct scene *scn, uint id, bool open); -/** - * scene_title_set() - set the scene title - * - * @scn: Scene to update - * @title_id: Title ID to set - * Returns: 0 if OK - */ -int scene_title_set(struct scene *scn, uint title_id); - /** * scene_obj_count() - Count the number of objects in a scene * diff --git a/test/boot/expo.c b/test/boot/expo.c index 1c2e746decc..db14ff86f8b 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -151,7 +151,7 @@ static int expo_scene(struct unit_test_state *uts) scn = NULL; id = scene_new(exp, SCENE_NAME2, 0, &scn); ut_assertnonnull(scn); - ut_assertok(scene_title_set(scn, title_id)); + scn->title_id = title_id; ut_asserteq(STR_SCENE_TITLE + 1, id); ut_asserteq(STR_SCENE_TITLE + 2, exp->next_id); ut_asserteq_ptr(exp, scn->expo); From patchwork Mon Oct 14 22:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997112 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Y47au7zk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBq30p83z1xsc for ; Tue, 15 Oct 2024 09:34:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5D2389246; Tue, 15 Oct 2024 00:32:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Y47au7zk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 902CF89256; Tue, 15 Oct 2024 00:32:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 627CF8921C for ; Tue, 15 Oct 2024 00:32:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-82aac438539so199001039f.1 for ; Mon, 14 Oct 2024 15:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945146; x=1729549946; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=905M5qZ5jVKL5O0WyD3QI9Wh7lOj1Sf2iljvk3vfyhk=; b=Y47au7zkwyyOp91OoH1zXgvSOYuDg31Lr1vJWxjnhFm5fMwD2yExsRQnHoFk7hK4wH agJ5zGh0a+S2FdUTFnaCWsmj5sWYj+ShkQ2FLZhr8U5rcc5rt0ideOgmJqgjbFcSE28t UDvRAj3lXBJJETbfrmdWd4jejioZAfi3zU5FQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945146; x=1729549946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=905M5qZ5jVKL5O0WyD3QI9Wh7lOj1Sf2iljvk3vfyhk=; b=h9mi1VQzNoNmM529eVcrfKP1a8HS5UxmLr2fhM/8lTdlML9wRuNhzZUHYCmfjikpV6 LgmOguNrXPaaklv1M/tyxDpsYvUE98u71kc4fOYeK3x4yUF6zgKAJ+VaOUuOkoTv1gDv meetqnF8rPSPHl/HMi/U5ATfFl7Mh9QkV4vO9xh1HtX+0Tz0devmBEU4HAWSp0HJPsXQ pAJPqOG+MsqKbdY5xVbYlYPlG0dbMhKmuj9RO9hmrbNcch7ObA8bO7Pxye3nh/jB8oU/ waYG+mVJPQSM5eEqhU37+ZHNULfLZnmIe6mpPkFKDClnsoxmW3F0obHvqXmMd9UEXvij GmZw== X-Gm-Message-State: AOJu0YyLfCeArp2NJzuaZsYkWBaqW/K1UoJy8kr+pYJwsJRJS99hby2k XA4NzRT1yFNJsexZlmVxls/AtADWTa2acimW0KZgT03By6wYGrfqMvMDlkoeYoINWOwk/hfHOEN e+g== X-Google-Smtp-Source: AGHT+IEhd3mdJjAdL3BpiEQglvTSig4B8knaiyzw0EyF++RSvAn4RxeWwfeLdvtZubRuySYCRbZxfw== X-Received: by 2002:a92:cd85:0:b0:3a0:8c5f:90d8 with SMTP id e9e14a558f8ab-3a3bcdb3e15mr60801205ab.6.1728945146013; Mon, 14 Oct 2024 15:32:26 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 11/20] expo: Add forward declaration for udevice to cedit Date: Mon, 14 Oct 2024 16:32:03 -0600 Message-Id: <20241014223212.2212442-12-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Some files may include this header file without first including dm.h so add a forward declaration. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) include/cedit.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/cedit.h b/include/cedit.h index a31b4245247..856509f0c7f 100644 --- a/include/cedit.h +++ b/include/cedit.h @@ -14,6 +14,7 @@ struct abuf; struct expo; struct scene; +struct udevice; struct video_priv; struct udevice; From patchwork Mon Oct 14 22:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997113 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JhNmLDLs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBqD5x4qz1xsc for ; Tue, 15 Oct 2024 09:34:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2712E89270; Tue, 15 Oct 2024 00:32:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JhNmLDLs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57B9B89294; Tue, 15 Oct 2024 00:32:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 500778922C for ; Tue, 15 Oct 2024 00:32:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3a3b4663e40so21630675ab.2 for ; Mon, 14 Oct 2024 15:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945147; x=1729549947; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=31A4pf2UJu7sXN2OTVNmRnpoZ9C09gUVe0pgYrM+fUk=; b=JhNmLDLsvYZlOmxk6eZonodHCKjA6Q2daRjsr32K58eU9WYMJ3+6QqPdoPS0Biv5wH vkSZBXudZh0mZiwP4eDuFcsrYnexoWtZHYwQa4tiRigkFwbnhEnvKiYpei+fst1XRPDX KuIyYV6GOtI/ZAvkgwcBEP/7JvQPjULlVJMZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945147; x=1729549947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=31A4pf2UJu7sXN2OTVNmRnpoZ9C09gUVe0pgYrM+fUk=; b=CIXIVhRzmZszNemkl7BpzaHxMWf+Esc3UBGMp/6qjxefj4F+ANYLveQfuDaQzv7cMy +fH4m3XiMgitHX1tjZRKbuFOlqUgQQ5wvvq6C+kGP5DF4oMaa4v3y+lJfResShfm27PT +mM+z5u7Yde1SulgmkMEtQBUWh3MbnYWisBKxywfD5ukDFkJeWopBt2zibZOg3NqUV8r 2dhQCnGFUXjKxp9Vb129sXRXLuVEM8xw9RxrtzsQAxzkJ4OJDub3hQ8wravMSvbm+q81 CkPJ6Xs0FptKEKJ6CzoyffeLzeSifWJ8iVu8Gt+GZQ1diEPSjFYUczxbzyWLFrZOC5mS gybg== X-Gm-Message-State: AOJu0YxwiescW+JMZcqXyvkNFqWjXUziQszeZ6YHMQx4V+Pdto6ZLZa3 I+BBFvlePYqyq2ZUIHzSKYBFevvsd8Ax+xOOpl1NEjrKkI1PbJ0+Msap4w89349mMp1AGIRKy/i TRg== X-Google-Smtp-Source: AGHT+IFExjABfLSj9Oz8z5/cGvumMx9h+NW8+W4Tz8qsuMWN2PE67+EdA2nfqwFP8ZScNHFWkp/HNQ== X-Received: by 2002:a05:6e02:19cb:b0:3a3:3e17:994e with SMTP id e9e14a558f8ab-3a3bcdc0bdamr83867035ab.9.1728945146973; Mon, 14 Oct 2024 15:32:26 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:26 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 12/20] x86: coreboot: Enable unit tests Date: Mon, 14 Oct 2024 16:32:04 -0600 Message-Id: <20241014223212.2212442-13-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Enable unit tests so we can run command-line tests in coreboot. Enable console recording, with enough space for the 'cbsysinfo' command. Add to the pre-relocation malloc() space to make room for this. Signed-off-by: Simon Glass --- (no changes since v1) configs/coreboot_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index 0b103efe16d..fdf978a539a 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -1,6 +1,7 @@ CONFIG_X86=y CONFIG_TEXT_BASE=0x1110000 CONFIG_SYS_MALLOC_LEN=0x2000000 +CONFIG_SYS_MALLOC_F_LEN=0x1000 CONFIG_NR_DRAM_BANKS=8 CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="coreboot" @@ -15,6 +16,8 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" CONFIG_BOOTCOMMAND="bootflow scan -l; if bootflow menu; then cls; bootflow boot; fi" +CONFIG_CONSOLE_RECORD=y +CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_LOG=y @@ -59,3 +62,4 @@ CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_CMD_DHRYSTONE=y # CONFIG_GZIP is not set CONFIG_SMBIOS_PARSER=y +CONFIG_UNIT_TEST=y From patchwork Mon Oct 14 22:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997114 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=RsAVBKWF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBqP12Ngz1xsc for ; Tue, 15 Oct 2024 09:34:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 915AC892C6; Tue, 15 Oct 2024 00:32:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RsAVBKWF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 71EAC89237; Tue, 15 Oct 2024 00:32:34 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0857689246 for ; Tue, 15 Oct 2024 00:32:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x142.google.com with SMTP id e9e14a558f8ab-3a3a3075af2so26076775ab.3 for ; Mon, 14 Oct 2024 15:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945148; x=1729549948; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NHZ3mvNWi+Lu1Xb8Yw/3NgFVKeYynoJDk0hF0/2vuLo=; b=RsAVBKWFMyDkhRbyARXrKU68K9q8fXXz5/9Hhi4rcVxZIeja6LRVsBv9jT1k8sxrWY eTkGPLKzty75Ouvh9kH25kuHXPe7qreqQsFY1UzIlVK7NkecUkvjJn4tylY2PeBhUbRO EERlaWnz2F5UjtS/7LJV5I/JteSUMpfEwDUtc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945148; x=1729549948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NHZ3mvNWi+Lu1Xb8Yw/3NgFVKeYynoJDk0hF0/2vuLo=; b=M116YLCIdK2YHLaSoYnmmkqw0vJJOkgCqeqTfDnVohpdC7d3eFjIDHPtg0T/Kp0iHk 4SeVsvRA3XlXXli3iMNLBmdkuvIEskQe5BK3L+Ho6PQVFYGU95MjKDS2OqpUlIlxRK+u dTRKnNldw5qmEwYMKntpJ5i70IH7UGz6suCfhjUerQUeb11WuPoA3xhfRc9IvYp/xMUp LSTu9sVDZtFbP2tITALrufky/4jlXPfbEm5SWcifwCbN4cguGBnoe9mgs4XeHIC3LL4c DWUXSYFrbzCSp8k3mOc3f5QmXBPlyghYTVw1MArVLdoQ9y6Jg3sgLy8hc/FqFSUbAKAn z+Ig== X-Gm-Message-State: AOJu0Yzvu1cr0yUPvSRSyb5Va/09kFQWzxVWVdLYhlcpnWYQ1g4/ulSf KGCPXxk0GLxZFQSWpys4kG0iZylUwx9qilWPMKFWONxr7dV8ZqfIoceSjQrj1CQ0s9zuT2g6ydj 3A1GD X-Google-Smtp-Source: AGHT+IG7yrxgbJnxEg9O2H+ebBN4QP/Ez1tN7osRcqLtG6A52pOtE+OulBKaTX/Jmb+LfjxuaHfRqg== X-Received: by 2002:a05:6e02:1c88:b0:3a2:aed1:1285 with SMTP id e9e14a558f8ab-3a3bccade28mr81019075ab.0.1728945148104; Mon, 14 Oct 2024 15:32:28 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:27 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt Subject: [PATCH v3 13/20] docker: Update coreboot Date: Mon, 14 Oct 2024 16:32:05 -0600 Message-Id: <20241014223212.2212442-14-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Update to a newer version which supports settings in CMOS RAM and linear framebuffer. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Reviewed-by: Tom Rini --- Changes in v3: - Update Dockerfile instead tools/docker/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index c401170b1e1..967ac89fbde 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -244,12 +244,15 @@ RUN mkdir /tmp/trace && \ rm -rf /tmp/trace # Build coreboot -RUN wget -O - https://coreboot.org/releases/coreboot-4.22.01.tar.xz | tar -C /tmp -xJ && \ - cd /tmp/coreboot-4.22.01 && \ +RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \ + cd /tmp/coreboot-24.08 && \ make crossgcc-i386 CPUS=$(nproc) && \ make -C payloads/coreinfo olddefconfig && \ make -C payloads/coreinfo && \ make olddefconfig && \ + echo CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y | tee -a .config && \ + echo CONFIG_USE_OPTION_TABLE=y | tee -a .config && \ + make olddefconfig && \ make -j $(nproc) && \ sudo mkdir /opt/coreboot && \ sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/ From patchwork Mon Oct 14 22:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997115 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=OTBsxZf9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBqZ2Fbyz1xsc for ; Tue, 15 Oct 2024 09:34:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A1EA89280; Tue, 15 Oct 2024 00:32:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="OTBsxZf9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1747988DEA; Tue, 15 Oct 2024 00:32:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3447889270 for ; Tue, 15 Oct 2024 00:32:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3a39f73a2c7so18456795ab.0 for ; Mon, 14 Oct 2024 15:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945149; x=1729549949; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lVvfME+AG/WoQlXxQ2/am0Q9+Mhbq1pAcg9qSDtFdAE=; b=OTBsxZf93UyKEJWau5JJRIrLs9RFfn27n0hL9uTAgSTamKaLyt8AFiNRCqGk4yeibs r7ZOFSl03BzFldmIczqfBWYnK52EZfHJo3qe8VlvWBC/IMlPAn01SasksxHYZr8HBhTJ oiJV9kPAjHbtJoaOsXM7aGgZyR/7lMBcmYPog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945149; x=1729549949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lVvfME+AG/WoQlXxQ2/am0Q9+Mhbq1pAcg9qSDtFdAE=; b=Z9shdTNSKOiDTqF36+BnOj8v5bNPbAHQqdvWHzDZn6mcp/EetcYRc+eDtQk/qtBwmo WrGQo1TcNwYpvvjWxnKqfmSCPiPY3BeITFgKWJmfBH/38ypnmdc2evPiKFkQ0bfYk5yA 0whjWif4X4023PCkCJpp8uHOS05UxNDEGyBsFth6mX7WTcvt2O2r1zk9pJPhgoTGOZ52 rAnhc0XbFmbeKAuZvRbdedJRGovhgOvVJdkFXtXMHH6WOv29QhIErrwEa3NIaJbNVJTi y0sNAHN1XQzK+p4oaPP3Cc5lHpJzg0HpkXPSYnpeGt5NzAwDAMUvGl2EGCv1XDb2RzYY hzug== X-Gm-Message-State: AOJu0YyDEIFJzFl/1lbzdEwzSJnM1hbLrTeTd4rJij7PN6DlavZ+Oy3m LguDq/tbAHGelEfTM5TZQ35oew96is7E2zvv0bSrc6KEg8sOCnO2GCkLHtU/agvw+xULxScLc3+ vOw== X-Google-Smtp-Source: AGHT+IHdfr6V+IV76k9NEqTjqyDkUFKnAKGFj9nfu8h211E+7Ev7XLacsfznu6aSSlcZBmhJ06lSZw== X-Received: by 2002:a05:6e02:19c9:b0:3a0:9aff:5047 with SMTP id e9e14a558f8ab-3a3b5fbd5b1mr118910235ab.22.1728945148802; Mon, 14 Oct 2024 15:32:28 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:28 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 14/20] doc: Update coreboot's CI information Date: Mon, 14 Oct 2024 16:32:06 -0600 Message-Id: <20241014223212.2212442-15-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This is in the Dockerfile now, so update this section of the docs. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) doc/board/coreboot/coreboot.rst | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/doc/board/coreboot/coreboot.rst b/doc/board/coreboot/coreboot.rst index 7154f59c374..a177265c16e 100644 --- a/doc/board/coreboot/coreboot.rst +++ b/doc/board/coreboot/coreboot.rst @@ -181,16 +181,4 @@ coreboot in CI CI runs tests using a pre-built coreboot image. This ensures that U-Boot can boot as a coreboot payload, based on a known-good build of coreboot. -To update the `coreboot.rom` file which is used: - -#. Build coreboot with `CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y`. If using - `make menuconfig`, this is under - `Devices->Display->Framebuffer mode->Linear "high resolution" framebuffer`. - -#. Compress the resulting `coreboot.rom`:: - - xz -c /path/to/coreboot/build/coreboot.rom > coreboot.rom.xz - -#. Upload the file to Google drive - -#. Send a patch to change the file ID used by wget in the CI yaml files. +To update the `coreboot.rom` file which is used, see ``tools/Dockerfile`` From patchwork Mon Oct 14 22:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997116 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=TMQ2j5R8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBql2NyXz1xsc for ; Tue, 15 Oct 2024 09:34:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77ED989220; Tue, 15 Oct 2024 00:32:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TMQ2j5R8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0FC0892D4; Tue, 15 Oct 2024 00:32:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1F84B89280 for ; Tue, 15 Oct 2024 00:32:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-835426c0fefso157978039f.1 for ; Mon, 14 Oct 2024 15:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945150; x=1729549950; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rc8+5sDXJN82oBKx4MC4MsfaqPJQezLgNsq8FzJNHMA=; b=TMQ2j5R8vInmUhb5moXrxdhrdtB4pwtFsIu2qTKfZy63rIZAyVRUcnAkJp41frcVx4 i/j242S385B8Nxpb/yXg7YE6WU9d1Gdph7Bgozf8nJQdM0H7V8Rl+f2c7VlIrbeFovBT DWRM6BXlLiigpNudevtIHIMHD+94ed8YDEpb0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945150; x=1729549950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rc8+5sDXJN82oBKx4MC4MsfaqPJQezLgNsq8FzJNHMA=; b=BMIGubnlaNuBnMyVKE2DQZGrFdRf0RChMLWJ/rhQICqvXiL/Dp5maPde8IXOR+Hgn3 sFWh1rarapQYlZJWmA33LanTFEj/uwxUUxheKziWVUMEiKkU6fMiwRuENFrIWOmjKSyf nSIlhhNJ48RP3ylMwJTBOkrbvpdk6+BjdJ6XDlLgZN6euKhJcCN5pKrNCOQQfjk2NzdS JwsW4BQcX0rpBlzSj46qq9pZ25XFp+sP1XlZF621xSllgySg7X21KXCEV1e9ZrhY7yWZ PPW3XstDOM+xJV2tol42EvG862mJv+HnsC7pQDskoUakFUDQCDvcXkuGVOwhRFfTry46 aY8Q== X-Gm-Message-State: AOJu0YwNiMdAwr9lHA7bK0MNmAJ24jMRe+4ves5IkconG1hDAafEoOlj pd+ACXiXnY9ndqvEKdnh4gjtWPO0m+mkMLqC6dLcjz3LDsaicpk9Y/1gZD93udYTOWWeyBsJWIL 1Xw== X-Google-Smtp-Source: AGHT+IGChFsFfkNsw+DdZqdnG2PiHjAzTfCJe4UFAHsWIOA477wr7CF8cyUdKYT130bMSkd/pyRKIA== X-Received: by 2002:a05:6602:610f:b0:835:3dfc:5ba5 with SMTP id ca18e2360f4ac-835486a6280mr1145676639f.5.1728945149738; Mon, 14 Oct 2024 15:32:29 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Alexander Gendin , Rasmus Villemoes Subject: [PATCH v3 15/20] x86: coreboot: Add a test for cbsysinfo command Date: Mon, 14 Oct 2024 16:32:07 -0600 Message-Id: <20241014223212.2212442-16-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a simple test for this command, checking that coreboot has the required features. Signed-off-by: Simon Glass --- (no changes since v1) test/cmd/Makefile | 1 + test/cmd/coreboot.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/cmd/coreboot.c diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 8f2134998ad..f2955cd4e53 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -14,6 +14,7 @@ endif obj-y += exit.o mem.o obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o obj-$(CONFIG_CMD_BDI) += bdinfo.o +obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o obj-$(CONFIG_CMD_HISTORY) += history.o diff --git a/test/cmd/coreboot.c b/test/cmd/coreboot.c new file mode 100644 index 00000000000..4a00bad2b8f --- /dev/null +++ b/test/cmd/coreboot.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for coreboot commands + * + * Copyright 2023 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include + +/** + * test_cmd_cbsysinfo() - test the cbsysinfo command produces expected output + * + * This includes ensuring that the coreboot build has the expected options + * enabled + */ +static int test_cmd_cbsysinfo(struct unit_test_state *uts) +{ + ut_assertok(run_command("cbsysinfo", 0)); + ut_assert_nextlinen("Coreboot table at"); + + /* Make sure the linear frame buffer is enabled */ + ut_assert_skip_to_linen("Framebuffer"); + ut_assert_nextlinen(" Phys addr"); + + ut_assert_skip_to_line("Chrome OS VPD: 00000000"); + ut_assert_nextlinen("RSDP"); + ut_assert_nextlinen("Unimpl."); + ut_assert_console_end(); + + return 0; +} +CMD_TEST(test_cmd_cbsysinfo, UTF_CONSOLE); From patchwork Mon Oct 14 22:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997117 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XtyY17Fc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBqv69mFz1xsc for ; Tue, 15 Oct 2024 09:34:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E93DF89281; Tue, 15 Oct 2024 00:32:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XtyY17Fc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C7914891E2; Tue, 15 Oct 2024 00:32:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 27F5089259 for ; Tue, 15 Oct 2024 00:32:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-8353b41369fso313980339f.3 for ; Mon, 14 Oct 2024 15:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945151; x=1729549951; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pitotrk34w/2X2wWpT1VIgL/lwAEYsYC0vs+eeA4wmY=; b=XtyY17FcCTK18+aNDa+2KpVmJBx1XKfRwYuyC1J+hwrxS93vwmSecACSHsce9KchKu nD9tuJhXX1KGJoV7zLaCIzE0gqYxZTBqeaQrE0EjxAIrEUTX2TKiH8qKe9XwL1KLgym4 Cykn0qexSI531zytZaOtgFefq82pNVVElxk60= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945151; x=1729549951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pitotrk34w/2X2wWpT1VIgL/lwAEYsYC0vs+eeA4wmY=; b=Bv8iHn115qR4srVD0gACv+1dKgliD9lin97TYjppkPlSCXFQR86q8RKxt4j+wRswD/ FEgHBvR2kjuMRWgAAc7yLDnVTbo3pZHDj2VkRdHgww9FUv1+96YOAmvRV0o+5H2TCVZv 1AdEZATI8yizGKWllJGiBBZ8dgBuvTy/BpSxORpMKXvlzqkOtJJsXkvHRy45VdBro4J9 YN6XDGKe3mdDDzBmnzhO1fdYJ3qmiUuj+TGg5vkZquhyligWMET66lp7eLb3W8I4y0Yt inZDpx76B44uJQaGdllUYYn6EV4ToCgVFjEyVg/ycozTL/KH8vUVjUaglCNYKpqVznji V8zg== X-Gm-Message-State: AOJu0YxcxWjY5V2444JlMoY5fyhDHbdF/0G6C+0SqB46zc5yr8W2U1B/ CyLxLpkZXjttA2N8V0Z0+zRzt+OQACJ07wf5mBDHaudLCl1ZY2bgVrLfPaVX+4V8lMzkUj37Amt jPQ== X-Google-Smtp-Source: AGHT+IHzs5lYleglab2EOgq9yYiorexZsn4ZALskLymdVgASNmuULlUH/ZBQZAPMExquTxgQ449gDQ== X-Received: by 2002:a05:6e02:156d:b0:3a0:92b1:ec4c with SMTP id e9e14a558f8ab-3a3bce0ba83mr67457475ab.23.1728945150735; Mon, 14 Oct 2024 15:32:30 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , Heinrich Schuchardt Subject: [PATCH v3 16/20] x86: coreboot: Show the option table Date: Mon, 14 Oct 2024 16:32:08 -0600 Message-Id: <20241014223212.2212442-17-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Update the cbsysinfo command to show the contents of the CMOS option table. While we are here, add some example output for this command, along with mention of what the unimplemented tags are. Signed-off-by: Simon Glass --- (no changes since v1) cmd/x86/cbsysinfo.c | 73 ++++++++++++++++++++++++++- doc/usage/cmd/cbsysinfo.rst | 99 +++++++++++++++++++++++++++++++++++++ test/cmd/coreboot.c | 7 +++ 3 files changed, 178 insertions(+), 1 deletion(-) diff --git a/cmd/x86/cbsysinfo.c b/cmd/x86/cbsysinfo.c index 7ca2e13ae2f..ea4d89616f6 100644 --- a/cmd/x86/cbsysinfo.c +++ b/cmd/x86/cbsysinfo.c @@ -184,6 +184,77 @@ static const char *timestamp_name(uint32_t id) return ""; } +static void show_option_vals(const struct cb_cmos_option_table *tab, + uint id) +{ + const void *ptr, *end; + bool found = false; + + end = (void *)tab + tab->size; + for (ptr = (void *)tab + tab->header_length; ptr < end;) { + const struct cb_record *rec = ptr; + + switch (rec->tag) { + case CB_TAG_OPTION_ENUM: { + const struct cb_cmos_enums *enums = ptr; + + if (enums->config_id == id) { + if (!found) + printf(" "); + printf(" %d:%s", enums->value, enums->text); + found = true; + } + break; + } + break; + case CB_TAG_OPTION_DEFAULTS: + case CB_TAG_OPTION_CHECKSUM: + case CB_TAG_OPTION: + break; + default: + printf("tag %x\n", rec->tag); + break; + } + ptr += rec->size; + } +} + +static void show_option_table(const struct cb_cmos_option_table *tab) +{ + const void *ptr, *end; + + print_ptr("option_table", tab); + if (!tab->size) + return; + + printf(" Bit Len Cfg ID Name\n"); + end = (void *)tab + tab->size; + for (ptr = (void *)tab + tab->header_length; ptr < end;) { + const struct cb_record *rec = ptr; + + switch (rec->tag) { + case CB_TAG_OPTION: { + const struct cb_cmos_entries *entry = ptr; + + printf("%4x %4x %3c %3x %-20s", entry->bit, + entry->length, entry->config, entry->config_id, + entry->name); + show_option_vals(tab, entry->config_id); + printf("\n"); + break; + } + case CB_TAG_OPTION_ENUM: + case CB_TAG_OPTION_DEFAULTS: + case CB_TAG_OPTION_CHECKSUM: + break; + default: + printf("tag %x\n", rec->tag); + break; + } + ptr += rec->size; + } +} + static void show_table(struct sysinfo_t *info, bool verbose) { struct cb_serial *ser = info->serial; @@ -218,7 +289,7 @@ static void show_table(struct sysinfo_t *info, bool verbose) printf("%12d: %02x:%-8s %016llx %016llx\n", i, mr->type, get_mem_name(mr->type), mr->base, mr->size); } - print_ptr("option_table", info->option_table); + show_option_table(info->option_table); print_hex("CMOS start", info->cmos_range_start); if (info->cmos_range_start) { diff --git a/doc/usage/cmd/cbsysinfo.rst b/doc/usage/cmd/cbsysinfo.rst index 80d8ba1b662..28f61d9c63e 100644 --- a/doc/usage/cmd/cbsysinfo.rst +++ b/doc/usage/cmd/cbsysinfo.rst @@ -23,3 +23,102 @@ Example :: => cbsysinfo + Coreboot table at 500, size 5c4, records 1d (dec 29), decoded to 000000007dce4520, forwarded to 000000007ff9a000 + + CPU KHz : 0 + Serial I/O port: 00000000 + base : 00000000 + pointer : 000000007ff9a370 + type : 1 + base : 000003f8 + baud : 0d115200 + regwidth : 1 + input_hz : 0d1843200 + PCI addr : 00000010 + Mem ranges : 7 + id: type || base || size + 0: 10:table 0000000000000000 0000000000001000 + 1: 01:ram 0000000000001000 000000000009f000 + 2: 02:reserved 00000000000a0000 0000000000060000 + 3: 01:ram 0000000000100000 000000007fe6d000 + 4: 10:table 000000007ff6d000 0000000000093000 + 5: 02:reserved 00000000fec00000 0000000000001000 + 6: 02:reserved 00000000ff800000 0000000000800000 + option_table: 000000007ff9a018 + Bit Len Cfg ID Name + 0 180 r 0 reserved_memory + 180 1 e 4 boot_option 0:Fallback 1:Normal + 184 4 h 0 reboot_counter + 190 8 r 0 reserved_century + 1b8 8 r 0 reserved_ibm_ps2_century + 1c0 1 e 1 power_on_after_fail 0:Disable 1:Enable + 1c4 4 e 6 debug_level 5:Notice 6:Info 7:Debug 8:Spew + 1d0 80 r 0 vbnv + 3f0 10 h 0 check_sum + CMOS start : 1c0 + CMOS end : 1cf + CMOS csum loc: 3f0 + VBNV start : ffffffff + VBNV size : ffffffff + CB version : 4.21-5-g7e6eae9679e3-dirty + Extra : + Build : Thu Sep 07 14:52:41 UTC 2023 + Time : 14:52:41 + Framebuffer : 000000007ff9a410 + Phys addr : fd000000 + X res : 0d800 + X res : 0d600 + Bytes / line: c80 + Bpp : 0d32 + pos/size red 16/8, green 8/8, blue 0/8, reserved 24/8 + GPIOs : 0 + id: port polarity val name + MACs : 0d10 + 0: 12:00:00:00:28:00 + 1: 00:00:00:fd:00:00 + 2: 20:03:00:00:58:02 + 3: 80:0c:00:00:20:10 + 4: 08:00:08:18:08:00 + 5: 16:00:00:00:10:00 + 6: 00:d0:fd:7f:00:00 + 7: 17:00:00:00:10:00 + 8: 00:e0:fd:7f:00:00 + 9: 37:00:00:00:10:00 + Multiboot tab: 0000000000000000 + CB header : 000000007ff9a000 + CB mainboard: 000000007ff9a344 + vendor : 0: Emulation + part_number : 10: QEMU x86 i440fx/piix4 + vboot handoff: 0000000000000000 + size : 0 + vdat addr : 0000000000000000 + size : 0 + SMBIOS : 7ff6d000 + size : 8000 + ROM MTRR : 0 + Tstamp table: 000000007ffdd000 + CBmem cons : 000000007ffde000 + Size : 1fff8 + Cursor : 3332 + MRC cache : 0000000000000000 + ACPI GNVS : 0000000000000000 + Board ID : ffffffff + RAM code : ffffffff + WiFi calib : 0000000000000000 + Ramoops buff: 0 + size : 0 + SF size : 0 + SF sector : 0 + SF erase cmd: 0 + FMAP offset : 0 + CBFS offset : 200 + CBFS size : 3ffe00 + Boot media size: 400000 + MTC start : 0 + MTC size : 0 + Chrome OS VPD: 0000000000000000 + RSDP : 000000007ff75000 + Unimpl. : 10 37 40 + => + +Note that "Unimpl." shows tags which U-Boot does not currently implement. diff --git a/test/cmd/coreboot.c b/test/cmd/coreboot.c index 4a00bad2b8f..0fcf66ac71b 100644 --- a/test/cmd/coreboot.c +++ b/test/cmd/coreboot.c @@ -22,6 +22,13 @@ static int test_cmd_cbsysinfo(struct unit_test_state *uts) ut_assertok(run_command("cbsysinfo", 0)); ut_assert_nextlinen("Coreboot table at"); + /* Make sure CMOS options are enabled */ + ut_assert_skip_to_line( + " 1c0 1 e 1 power_on_after_fail 0:Disable 1:Enable"); + ut_assert_skip_to_line("CMOS start : 1c0"); + ut_assert_nextline(" CMOS end : 1cf"); + ut_assert_nextline(" CMOS csum loc: 3f0"); + /* Make sure the linear frame buffer is enabled */ ut_assert_skip_to_linen("Framebuffer"); ut_assert_nextlinen(" Phys addr"); From patchwork Mon Oct 14 22:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997118 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SqlUgafj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBr472bGz1xsc for ; Tue, 15 Oct 2024 09:35:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 598F4892B8; Tue, 15 Oct 2024 00:32:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SqlUgafj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CE1048921B; Tue, 15 Oct 2024 00:32:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CD9A889288 for ; Tue, 15 Oct 2024 00:32:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-8377fd76112so169746239f.1 for ; Mon, 14 Oct 2024 15:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945151; x=1729549951; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d/8iOh6iv/Mo9+lQt3g18GdsWjvEPCXBldWBGKf5KHY=; b=SqlUgafj0yFkWtK3lXSNgUSCsWR5wULHx1PPQgdcH8y9zG0lmTW8yJEo3PEl8wkA/5 DoOcGUoQXSC+B3Xloa+14GlYHQ8pLxkMoPLq1CPjvzKXyfspEisJS0PNE4Y2nQwod8cQ nwUz8Ht7RAgs32zLIEuPMoulN/OTogjLwd1LE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945151; x=1729549951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d/8iOh6iv/Mo9+lQt3g18GdsWjvEPCXBldWBGKf5KHY=; b=At+BrR/zuVV8XmGzTgT1yF9W1kGvQeXzBRql9H9FNhgwGNrNAwlR3FRYh6vXV0ZjO+ brLKD88bznu0H++3dwApIPpZ4UIbzV1wIIluD/9lOXE9Aeui7hpbIPFlkhlAYZ/Xh5fQ 8VdR5DxIvLhyNGeMsiXa6U8Oh0v+MnV4Vsy9uR8hxnopo0F7+i+p8rthDlbvsRubMKcs 2XcLvGU0dTsNWhi0IinpnDJkci9hB5OgyRuDNW8jBD5D1dKxY9SLHongPHRCQInNympK yNyWNz7Hc33uZoTMjnbhnvCw7I08H7WSaekcUZuUEh9+su1YCh0xY+LCWdVlokiIDx9b kptw== X-Gm-Message-State: AOJu0Yw2Kzt7oC9p2Uca3fDtq0GfuPI5egcfk/hqijHFyh4WUzt2ZDh9 4KJxoNj4cwYjqAvdplMXmc+pVG1oZv4++GQahWg1PamnKundbezvqof5CBmd0Ha4MomrIPuzRCA OxQ== X-Google-Smtp-Source: AGHT+IEdECbcUhI4H/c4D8Fe9JktrBpr3MVkTDkYRsryxIsTZ1NQJ5vbNNeZCf9xxZmUDh+Ye2NdGQ== X-Received: by 2002:a92:b743:0:b0:3a3:c036:e3ab with SMTP id e9e14a558f8ab-3a3c036e518mr55821955ab.18.1728945151537; Mon, 14 Oct 2024 15:32:31 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng Subject: [PATCH v3 17/20] x86: coreboot: Enable support for the configuration editor Date: Mon, 14 Oct 2024 16:32:09 -0600 Message-Id: <20241014223212.2212442-18-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Enable cedit support along with required options and a simple style. Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/dts/coreboot.dts | 7 +++++++ configs/coreboot64_defconfig | 2 ++ configs/coreboot_defconfig | 2 ++ 3 files changed, 11 insertions(+) diff --git a/arch/x86/dts/coreboot.dts b/arch/x86/dts/coreboot.dts index b867468e16c..39d1d325db9 100644 --- a/arch/x86/dts/coreboot.dts +++ b/arch/x86/dts/coreboot.dts @@ -54,6 +54,13 @@ menu-inset = <3>; menuitem-gap-y = <1>; }; + + cedit-theme { + font-size = <30>; + menu-inset = <3>; + menuitem-gap-y = <1>; + menu-title-margin-x = <30>; + }; }; sysinfo { diff --git a/configs/coreboot64_defconfig b/configs/coreboot64_defconfig index da42ad0a20a..148c2494587 100644 --- a/configs/coreboot64_defconfig +++ b/configs/coreboot64_defconfig @@ -17,6 +17,7 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" CONFIG_BOOTCOMMAND="bootflow scan -l; if bootflow menu; then cls; bootflow boot; fi" +CONFIG_CEDIT=y CONFIG_SYS_PBSIZE=532 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y @@ -46,6 +47,7 @@ CONFIG_TFTP_TSIZE=y CONFIG_USE_ROOTPATH=y CONFIG_REGMAP=y CONFIG_SYSCON=y +CONFIG_OFNODE_MULTI_TREE=y # CONFIG_ACPIGEN is not set CONFIG_SYS_IDE_MAXDEVICE=4 CONFIG_SYS_ATA_DATA_OFFSET=0 diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index fdf978a539a..ed3de2677d1 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -16,6 +16,7 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" CONFIG_BOOTCOMMAND="bootflow scan -l; if bootflow menu; then cls; bootflow boot; fi" +CONFIG_CEDIT=y CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_PRE_CONSOLE_BUFFER=y @@ -43,6 +44,7 @@ CONFIG_TFTP_TSIZE=y CONFIG_USE_ROOTPATH=y CONFIG_REGMAP=y CONFIG_SYSCON=y +CONFIG_OFNODE_MULTI_TREE=y # CONFIG_ACPIGEN is not set CONFIG_SYS_IDE_MAXDEVICE=4 CONFIG_SYS_ATA_DATA_OFFSET=0 From patchwork Mon Oct 14 22:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997119 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hAl3EU2C; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBrH35JLz1xvK for ; Tue, 15 Oct 2024 09:35:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D25B3891E2; Tue, 15 Oct 2024 00:32:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hAl3EU2C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47A92891E2; Tue, 15 Oct 2024 00:32:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 273EB89248 for ; Tue, 15 Oct 2024 00:32:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3a3a309154aso16669895ab.2 for ; Mon, 14 Oct 2024 15:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945153; x=1729549953; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vBpyfrMvM3+2KW+ClisdBm7vrKe8JXJEQMRroCcpewk=; b=hAl3EU2CNlePtwdAE6qeU1PeSAoUr0SvTVyJ3CyRkF+otWejPi6B8ZfEXtDMV7SAsu OdlRkgFd05PuphywnTCmtIRgNwkmVg/u158LoCLVCl1aB6CTaQVYQ7YJT8Gyv7Au90IZ h73g7R2tyTUvjFZ2RUs5JsEvszDEsNJLTF6Y4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945153; x=1729549953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vBpyfrMvM3+2KW+ClisdBm7vrKe8JXJEQMRroCcpewk=; b=b/VouSxGSthDwtS5miOHc2lB4P4Rnv9T8v1L+ctC4U1mXmct0H8F5gUUCEjslt+o+t Bfk5vgyBV+hIUKIzFnFx/weaDqbJctO0eOw+R9G/bmkkOL+F4P+phcBrceB9E7vTOxov 6iLHBNXn20qzVGFfYPPryEhIYlGjETuKDFNRLnkzHF+nSVZlq/iYVkQlh5v93wrqy8w0 6Hio875CVd0V90p4k2PkXL60B9jikcIXPfAAP8C9v40N5WSidcsa+qqhYDRrpq1tl+Hx AoR1hDu6HEbSr3Ny/qnXeWx8ObO0QfQHtZmhcaWphrD/fflLj4fYafYeegUVeKZPXRa5 AdlQ== X-Gm-Message-State: AOJu0YzVmpa3zXlrT2+i5xF2n+Mkl5TV3d94LmobSMpg5pkT1ctw0IkG Ossf5K0u2Gu5T5we8559Am+/lJAIhHrQ6LHAxPoLAcXxgIEOobJGbSKxSTojIc0zw1sSsioIGqM pAg== X-Google-Smtp-Source: AGHT+IEzHnI3IjV+urdjWZQyQ9Hw0/tYHrdD7nkvxi02yfej2gJYXna3pPs93HmntWbsEXcrykZpoA== X-Received: by 2002:a05:6e02:1a0b:b0:3a0:aa15:3497 with SMTP id e9e14a558f8ab-3a3b5f23e86mr116201655ab.1.1728945152672; Mon, 14 Oct 2024 15:32:32 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , AKASHI Takahiro , Etienne Carriere , Francis Laniel , Heinrich Schuchardt , Ilias Apalodimas , Mattijs Korpershoek , Tom Fitzhenry Subject: [PATCH v3 18/20] x86: coreboot: Add a command to check and update CMOS RAM Date: Mon, 14 Oct 2024 16:32:10 -0600 Message-Id: <20241014223212.2212442-19-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Coreboot tables provide information about the CMOS-RAM checksum. Add a command which can check and update this. With this it is possible to adjust CMOS-RAM settings and tidy up the checksum afterwards. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Avoid using common.h cmd/Kconfig | 11 ++++ cmd/x86/Makefile | 1 + cmd/x86/cbcmos.c | 139 +++++++++++++++++++++++++++++++++++++++ doc/usage/cmd/cbcmos.rst | 42 ++++++++++++ doc/usage/index.rst | 1 + test/cmd/coreboot.c | 41 ++++++++++++ 6 files changed, 235 insertions(+) create mode 100644 cmd/x86/cbcmos.c create mode 100644 doc/usage/cmd/cbcmos.rst diff --git a/cmd/Kconfig b/cmd/Kconfig index 37894eb80d6..031a4f5e9bf 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2846,6 +2846,17 @@ config CMD_CBSYSINFO memory by coreboot before jumping to U-Boot. It can be useful for debugging the beaaviour of coreboot or U-Boot. +config CMD_CBCMOS + bool "cbcmos" + depends on X86 + default y if SYS_COREBOOT + help + This provides information options to check the CMOS RAM checksum, + if present, as well as to update it. + + It is useful when coreboot CMOS-RAM settings must be examined or + updated. + config CMD_CYCLIC bool "cyclic - Show information about cyclic functions" depends on CYCLIC diff --git a/cmd/x86/Makefile b/cmd/x86/Makefile index b1f39d3bfde..68029e6cad2 100644 --- a/cmd/x86/Makefile +++ b/cmd/x86/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o +obj-$(CONFIG_CMD_CBCMOS) += cbcmos.o obj-y += mtrr.o obj-$(CONFIG_CMD_EXCEPTION) += exception.o obj-$(CONFIG_USE_HOB) += hob.o diff --git a/cmd/x86/cbcmos.c b/cmd/x86/cbcmos.c new file mode 100644 index 00000000000..fe5582fbf51 --- /dev/null +++ b/cmd/x86/cbcmos.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Support for booting from coreboot + * + * Copyright 2021 Google LLC + */ + +#define LOG_CATEGORY UCLASS_RTC + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +const struct sysinfo_t *get_table(void) +{ + if (!gd->arch.coreboot_table) { + printf("No coreboot sysinfo table found\n"); + return NULL; + } + + return &lib_sysinfo; +} + +static int calc_sum(struct udevice *dev, uint start_bit, uint bit_count) +{ + uint start_byte = start_bit / 8; + uint byte_count = bit_count / 8; + int ret, i; + uint sum; + + log_debug("Calc sum from %x: %x bytes\n", start_byte, byte_count); + sum = 0; + for (i = 0; i < bit_count / 8; i++) { + ret = rtc_read8(dev, start_bit / 8 + i); + if (ret < 0) + return ret; + sum += ret; + } + + return (sum & 0xff) << 8 | (sum & 0xff00) >> 8; +} + +/** + * prep_cbcmos() - Prepare for a CMOS-RAM command + * + * @tab: coreboot table + * @devnum: RTC device name to use, or NULL for the first one + * @dep: Returns RTC device on success + * Return: calculated checksum for CMOS RAM or -ve on error + */ +static int prep_cbcmos(const struct sysinfo_t *tab, const char *devname, + struct udevice **devp) +{ + struct udevice *dev; + int ret; + + if (!tab) + return CMD_RET_FAILURE; + if (devname) + ret = uclass_get_device_by_name(UCLASS_RTC, devname, &dev); + else + ret = uclass_first_device_err(UCLASS_RTC, &dev); + if (ret) { + printf("Failed to get RTC device: %dE\n", ret); + return ret; + } + + ret = calc_sum(dev, tab->cmos_range_start, + tab->cmos_range_end + 1 - tab->cmos_range_start); + if (ret < 0) { + printf("Failed to read RTC device: %dE\n", ret); + return ret; + } + *devp = dev; + + return ret; +} + +static int do_cbcmos_check(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const struct sysinfo_t *tab = get_table(); + struct udevice *dev; + u16 cur, sum; + int ret; + + ret = prep_cbcmos(tab, argv[1], &dev); + if (ret < 0) + return CMD_RET_FAILURE; + sum = ret; + + ret = rtc_read16(dev, tab->cmos_checksum_location / 8, &cur); + if (ret < 0) { + printf("Failed to read RTC device: %dE\n", ret); + return CMD_RET_FAILURE; + } + if (sum != cur) { + printf("Checksum %04x error: calculated %04x\n", cur, sum); + return CMD_RET_FAILURE; + } + + return 0; +} + +static int do_cbcmos_update(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const struct sysinfo_t *tab = get_table(); + struct udevice *dev; + u16 sum; + int ret; + + ret = prep_cbcmos(tab, argv[1], &dev); + if (ret < 0) + return CMD_RET_FAILURE; + sum = ret; + + ret = rtc_write16(dev, tab->cmos_checksum_location / 8, sum); + if (ret < 0) { + printf("Failed to read RTC device: %dE\n", ret); + return CMD_RET_FAILURE; + } + printf("Checksum %04x written\n", sum); + + return 0; +} + +U_BOOT_LONGHELP(cbcmos, + "check - check CMOS RAM\n" + "cbcmos update - Update CMOS-RAM checksum"; +); + +U_BOOT_CMD_WITH_SUBCMDS(cbcmos, "coreboot CMOS RAM", cbcmos_help_text, + U_BOOT_SUBCMD_MKENT(check, 2, 1, do_cbcmos_check), + U_BOOT_SUBCMD_MKENT(update, 2, 1, do_cbcmos_update)); diff --git a/doc/usage/cmd/cbcmos.rst b/doc/usage/cmd/cbcmos.rst new file mode 100644 index 00000000000..156521dd02b --- /dev/null +++ b/doc/usage/cmd/cbcmos.rst @@ -0,0 +1,42 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +cbcmos +====== + +Synopis +------- + +:: + + cbcmos check [] + cbcmos update [] + + +Description +----------- + +This checks or updates the CMOS-RAM checksum value against the CMOS-RAM +contents. It is used with coreboot, which provides information about where to +find the checksum and what part of the CMOS RAM it covers. + +If `` is provided then the named real-time clock (RTC) device is used. +Otherwise the default RTC is used. + +Example +------- + +This shows checking and updating a checksum across bytes 38 and 39 of the +CMOS RAM:: + + => rtc read 38 2 + 00000038: 71 00 q. + => cbc check + => rtc write 38 66 + => rtc read 38 2 + 00000038: 66 00 f. + => cbc check + Checksum 7100 error: calculated 6600 + => cbc update + Checksum 6600 written + => cbc check + => diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 70563374899..d6c58f3dec2 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -43,6 +43,7 @@ Shell commands cmd/bootz cmd/button cmd/cat + cmd/cbcmos cmd/cbsysinfo cmd/cedit cmd/cli diff --git a/test/cmd/coreboot.c b/test/cmd/coreboot.c index 0fcf66ac71b..e1acf8697e8 100644 --- a/test/cmd/coreboot.c +++ b/test/cmd/coreboot.c @@ -7,10 +7,16 @@ */ #include +#include +#include #include #include #include +enum { + CSUM_LOC = 0x3f0 / 8, +}; + /** * test_cmd_cbsysinfo() - test the cbsysinfo command produces expected output * @@ -41,3 +47,38 @@ static int test_cmd_cbsysinfo(struct unit_test_state *uts) return 0; } CMD_TEST(test_cmd_cbsysinfo, UTF_CONSOLE); + +/* test cbcmos command */ +static int test_cmd_cbcmos(struct unit_test_state *uts) +{ + u16 old_csum, new_csum; + struct udevice *dev; + + /* initially the checksum should be correct */ + ut_assertok(run_command("cbcmos check", 0)); + ut_assert_console_end(); + + /* make a change to the checksum */ + ut_assertok(uclass_first_device_err(UCLASS_RTC, &dev)); + ut_assertok(rtc_read16(dev, CSUM_LOC, &old_csum)); + ut_assertok(rtc_write16(dev, CSUM_LOC, old_csum + 1)); + + /* now the command should fail */ + ut_asserteq(1, run_command("cbcmos check", 0)); + ut_assert_nextline("Checksum %04x error: calculated %04x", + old_csum + 1, old_csum); + ut_assert_console_end(); + + /* now get it to fix the checksum */ + ut_assertok(run_command("cbcmos update", 0)); + ut_assert_nextline("Checksum %04x written", old_csum); + ut_assert_console_end(); + + /* check the RTC looks right */ + ut_assertok(rtc_read16(dev, CSUM_LOC, &new_csum)); + ut_asserteq(old_csum, new_csum); + ut_assert_console_end(); + + return 0; +} +CMD_TEST(test_cmd_cbcmos, UTF_CONSOLE); From patchwork Mon Oct 14 22:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997120 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=c12LYmbu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBrS5SHlz1xvK for ; Tue, 15 Oct 2024 09:35:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 448D789287; Tue, 15 Oct 2024 00:32:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="c12LYmbu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D54789288; Tue, 15 Oct 2024 00:32:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2E372892AA for ; Tue, 15 Oct 2024 00:32:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-8369b14fb91so140510039f.3 for ; Mon, 14 Oct 2024 15:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945154; x=1729549954; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TSh5REMcqfmdcO8Ias5PyDBG11iZcGv68X1/+BXlpHg=; b=c12LYmbuDLAkzHLEs+c/N7I+BK/jxtNY5xTdTqNdzfyPRJfVm0M8ZP3Oj+jX1YtNc4 PurQnTTR6UgpyyOq9+QfLhIDXi1Zl/hXMfnvE+16Lmdgs9caD//X9bTRMhUPC0NVVpdU z6S53HLvWmfzSfo/NBTUFAjkM8ZSPLmi5skto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945154; x=1729549954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TSh5REMcqfmdcO8Ias5PyDBG11iZcGv68X1/+BXlpHg=; b=vE7SXLbe/vs9HGD5xEjNYjVCKXNlgAR/cny9Y/lIp/hyzQaOfyiZ6ppMKFq38el+da f+HK/HNq5n9/IDEowDNknnlS4j3aqsg3X6KnYwFhdk+mqb56obodTklaglrD1jeY2H6p BLIBUgm2Nat3N0HhNsFatCB3zAvRGRGPuGXoRj2TM+xyroetI2L6gF2iTrrHcHrsXc/9 S1H7HfCzs5Nax4TsfbOrcwIlGtYG1eQ3IDdvvt9GY1zopEAhR5Lwvx6yvKzYjnEYku6y CMYjV/tFzqY8tK78l5JLpdlHnyZY0JbDzvBfWMMfVaE4z+tCgvS1Wtaa1MTBIYhg6LYW dZBQ== X-Gm-Message-State: AOJu0Yx+y+3m86xg+pfxuTdphT/zX6DPcUgtnByKudwF6ofxvnOxLQor JNIxVUvwL1xzbLK6zKIhLhx2IjtdEsWIVkk7tUJB5Wl/29IJyBV6O5HkI9JAkdYcrzfgA2iscbQ 4VQ== X-Google-Smtp-Source: AGHT+IG+73nRO57nHzCLdYENhgr5D/3E+J04F2NCdw6IDXttnYF3RaTMApk20Dj144ONRECkvTPILQ== X-Received: by 2002:a05:6e02:1c4b:b0:3a3:b3f4:af4c with SMTP id e9e14a558f8ab-3a3b5ffd784mr95029955ab.25.1728945153614; Mon, 14 Oct 2024 15:32:33 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , AKASHI Takahiro , Heinrich Schuchardt , Julien Masson , Mattijs Korpershoek Subject: [PATCH v3 19/20] x86: coreboot: Allow building an expo for editing CMOS config Date: Mon, 14 Oct 2024 16:32:11 -0600 Message-Id: <20241014223212.2212442-20-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Coreboot provides the CMOS layout in the tables it passes to U-Boot. Use that to build an editor for the CMOS settings. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Avoid using common.h boot/Makefile | 3 + boot/expo_build_cb.c | 245 ++++++++++++++++++++++++++++++++ cmd/cedit.c | 28 ++++ doc/board/coreboot/coreboot.rst | 6 + doc/develop/cedit.rst | 2 +- doc/usage/cmd/cbcmos.rst | 3 + doc/usage/cmd/cedit.rst | 76 ++++++++++ include/expo.h | 8 ++ test/cmd/coreboot.c | 35 +++++ 9 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 boot/expo_build_cb.c diff --git a/boot/Makefile b/boot/Makefile index b24f806d5bf..e83ff8b465b 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -62,6 +62,9 @@ obj-$(CONFIG_$(PHASE_)LOAD_FIT) += common_fit.o obj-$(CONFIG_$(PHASE_)EXPO) += expo.o scene.o expo_build.o obj-$(CONFIG_$(PHASE_)EXPO) += scene_menu.o scene_textline.o +ifdef CONFIG_COREBOOT_SYSINFO +obj-$(CONFIG_$(SPL_TPL_)EXPO) += expo_build_cb.o +endif obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE) += vbe.o obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_REQUEST) += vbe_request.o diff --git a/boot/expo_build_cb.c b/boot/expo_build_cb.c new file mode 100644 index 00000000000..442ad760e79 --- /dev/null +++ b/boot/expo_build_cb.c @@ -0,0 +1,245 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Building an expo from an FDT description + * + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_EXPO + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * struct build_info - Information to use when building + */ +struct build_info { + const struct cb_cmos_option_table *tab; + struct cedit_priv *priv; +}; + +/** + * convert_to_title() - Convert text to 'title' format and allocate a string + * + * Converts "this_is_a_test" to "This is a test" so it looks better + * + * @text: Text to convert + * Return: Allocated string, or NULL if out of memory + */ +static char *convert_to_title(const char *text) +{ + int len = strlen(text); + char *buf, *s; + + buf = malloc(len + 1); + if (!buf) + return NULL; + + for (s = buf; *text; s++, text++) { + if (s == buf) + *s = toupper(*text); + else if (*text == '_') + *s = ' '; + else + *s = *text; + } + *s = '\0'; + + return buf; +} + +/** + * menu_build() - Build a menu and add it to a scene + * + * See doc/developer/expo.rst for a description of the format + * + * @info: Build information + * @entry: CMOS entry to build a menu for + * @scn: Scene to add the menu to + * @objp: Returns the object pointer + * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format + * error, -ENOENT if there is a references to a non-existent string + */ +static int menu_build(struct build_info *info, + const struct cb_cmos_entries *entry, struct scene *scn, + struct scene_obj **objp) +{ + struct scene_obj_menu *menu; + const void *ptr, *end; + uint menu_id; + char *title; + int ret, i; + + ret = scene_menu(scn, entry->name, 0, &menu); + if (ret < 0) + return log_msg_ret("men", ret); + menu_id = ret; + + title = convert_to_title(entry->name); + if (!title) + return log_msg_ret("con", -ENOMEM); + + /* Set the title */ + ret = scene_txt_str(scn, "title", 0, 0, title, NULL); + if (ret < 0) + return log_msg_ret("tit", ret); + menu->title_id = ret; + + end = (void *)info->tab + info->tab->size; + for (ptr = (void *)info->tab + info->tab->header_length, i = 0; + ptr < end; i++) { + const struct cb_cmos_enums *enums = ptr; + struct scene_menitem *item; + uint label; + + ptr += enums->size; + if (enums->tag != CB_TAG_OPTION_ENUM || + enums->config_id != entry->config_id) + continue; + + ret = scene_txt_str(scn, enums->text, 0, 0, enums->text, NULL); + if (ret < 0) + return log_msg_ret("tit", ret); + label = ret; + + ret = scene_menuitem(scn, menu_id, simple_xtoa(i), 0, 0, label, + 0, 0, 0, &item); + if (ret < 0) + return log_msg_ret("mi", ret); + item->value = enums->value; + } + *objp = &menu->obj; + + return 0; +} + +/** + * scene_build() - Build a scene and all its objects + * + * See doc/developer/expo.rst for a description of the format + * + * @info: Build information + * @scn: Scene to add the object to + * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format + * error, -ENOENT if there is a references to a non-existent string + */ +static int scene_build(struct build_info *info, struct expo *exp) +{ + struct scene_obj_menu *menu; + const void *ptr, *end; + struct scene_obj *obj; + struct scene *scn; + uint label, menu_id; + int ret; + + ret = scene_new(exp, "cmos", 0, &scn); + if (ret < 0) + return log_msg_ret("scn", ret); + + ret = scene_txt_str(scn, "title", 0, 0, "CMOS RAM settings", NULL); + if (ret < 0) + return log_msg_ret("add", ret); + scn->title_id = ret; + + ret = scene_txt_str(scn, "prompt", 0, 0, + "UP and DOWN to choose, ENTER to select", NULL); + if (ret < 0) + return log_msg_ret("add", ret); + + end = (void *)info->tab + info->tab->size; + for (ptr = (void *)info->tab + info->tab->header_length; ptr < end;) { + const struct cb_cmos_entries *entry; + const struct cb_record *rec = ptr; + + entry = ptr; + ptr += rec->size; + if (rec->tag != CB_TAG_OPTION) + continue; + switch (entry->config) { + case 'e': + ret = menu_build(info, entry, scn, &obj); + break; + default: + continue; + } + if (ret < 0) + return log_msg_ret("add", ret); + + obj->start_bit = entry->bit; + obj->bit_length = entry->length; + } + + ret = scene_menu(scn, "save", EXPOID_SAVE, &menu); + if (ret < 0) + return log_msg_ret("men", ret); + menu_id = ret; + + ret = scene_txt_str(scn, "save", 0, 0, "Save and exit", NULL); + if (ret < 0) + return log_msg_ret("sav", ret); + label = ret; + ret = scene_menuitem(scn, menu_id, "save", 0, 0, label, + 0, 0, 0, NULL); + if (ret < 0) + return log_msg_ret("mi", ret); + + ret = scene_menu(scn, "nosave", EXPOID_DISCARD, &menu); + if (ret < 0) + return log_msg_ret("men", ret); + menu_id = ret; + + ret = scene_txt_str(scn, "nosave", 0, 0, "Exit without saving", NULL); + if (ret < 0) + return log_msg_ret("nos", ret); + label = ret; + ret = scene_menuitem(scn, menu_id, "exit", 0, 0, label, + 0, 0, 0, NULL); + if (ret < 0) + return log_msg_ret("mi", ret); + + return 0; +} + +static int build_it(struct build_info *info, struct expo **expp) +{ + struct expo *exp; + int ret; + + ret = expo_new("coreboot", NULL, &exp); + if (ret) + return log_msg_ret("exp", ret); + expo_set_dynamic_start(exp, EXPOID_BASE_ID); + + ret = scene_build(info, exp); + if (ret < 0) + return log_msg_ret("scn", ret); + + *expp = exp; + + return 0; +} + +int cb_expo_build(struct expo **expp) +{ + struct build_info info; + struct expo *exp; + int ret; + + info.tab = lib_sysinfo.option_table; + if (!info.tab) + return log_msg_ret("tab", -ENOENT); + + ret = build_it(&info, &exp); + if (ret) + return log_msg_ret("bui", ret); + *expp = exp; + + return 0; +} diff --git a/cmd/cedit.c b/cmd/cedit.c index fec67a8e334..f696356419e 100644 --- a/cmd/cedit.c +++ b/cmd/cedit.c @@ -67,6 +67,28 @@ static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } +#ifdef CONFIG_COREBOOT_SYSINFO +static int do_cedit_cb_load(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct expo *exp; + int ret; + + if (argc > 1) + return CMD_RET_USAGE; + + ret = cb_expo_build(&exp); + if (ret) { + printf("Failed to build expo: %dE\n", ret); + return CMD_RET_FAILURE; + } + + cur_exp = exp; + + return 0; +} +#endif /* CONFIG_COREBOOT_SYSINFO */ + static int do_cedit_write_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -271,6 +293,9 @@ static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc, U_BOOT_LONGHELP(cedit, "load - load config editor\n" +#ifdef CONFIG_COREBOOT_SYSINFO + "cb_load - load coreboot CMOS editor\n" +#endif "cedit read_fdt - read settings\n" "cedit write_fdt - write settings\n" "cedit read_env [-v] - read settings from env vars\n" @@ -281,6 +306,9 @@ U_BOOT_LONGHELP(cedit, U_BOOT_CMD_WITH_SUBCMDS(cedit, "Configuration editor", cedit_help_text, U_BOOT_SUBCMD_MKENT(load, 5, 1, do_cedit_load), +#ifdef CONFIG_COREBOOT_SYSINFO + U_BOOT_SUBCMD_MKENT(cb_load, 5, 1, do_cedit_cb_load), +#endif U_BOOT_SUBCMD_MKENT(read_fdt, 5, 1, do_cedit_read_fdt), U_BOOT_SUBCMD_MKENT(write_fdt, 5, 1, do_cedit_write_fdt), U_BOOT_SUBCMD_MKENT(read_env, 2, 1, do_cedit_read_env), diff --git a/doc/board/coreboot/coreboot.rst b/doc/board/coreboot/coreboot.rst index a177265c16e..f52b24ff43d 100644 --- a/doc/board/coreboot/coreboot.rst +++ b/doc/board/coreboot/coreboot.rst @@ -182,3 +182,9 @@ CI runs tests using a pre-built coreboot image. This ensures that U-Boot can boot as a coreboot payload, based on a known-good build of coreboot. To update the `coreboot.rom` file which is used, see ``tools/Dockerfile`` + +Editing CMOS RAM settings +------------------------- + +U-Boot supports creating a configuration editor to edit coreboot CMOS-RAM +settings. See :ref:`cedit_cb_load`. diff --git a/doc/develop/cedit.rst b/doc/develop/cedit.rst index 310be889240..1ac55ab1219 100644 --- a/doc/develop/cedit.rst +++ b/doc/develop/cedit.rst @@ -172,4 +172,4 @@ Cedit provides several options for persistent settings: For now, reading and writing settings is not automatic. See the :doc:`../usage/cmd/cedit` for how to do this on the command line or in a -script. +script. For x86 devices, see :ref:`cedit_cb_load`. diff --git a/doc/usage/cmd/cbcmos.rst b/doc/usage/cmd/cbcmos.rst index 156521dd02b..9395cf1cbd7 100644 --- a/doc/usage/cmd/cbcmos.rst +++ b/doc/usage/cmd/cbcmos.rst @@ -40,3 +40,6 @@ CMOS RAM:: Checksum 6600 written => cbc check => + +See also :ref:`cedit_cb_load` which shows an example that includes the +configuration editor. diff --git a/doc/usage/cmd/cedit.rst b/doc/usage/cmd/cedit.rst index f29f1b3f388..e54ea204b9f 100644 --- a/doc/usage/cmd/cedit.rst +++ b/doc/usage/cmd/cedit.rst @@ -18,6 +18,7 @@ Synopsis cedit write_env [-v] cedit read_env [-v] cedit write_cmos [-v] [dev] + cedit cb_load Description ----------- @@ -92,6 +93,13 @@ updated. Normally the first RTC device is used to hold the data. You can specify a different device by name using the `dev` parameter. +.. _cedit_cb_load: + +cedit cb_load +~~~~~~~~~~~~~ + +This is supported only on x86 devices booted from coreboot. It creates a new +configuration editor which can be used to edit CMOS settings. Example ------- @@ -158,3 +166,71 @@ Here is an example with the device specified:: => cedit write_cmos rtc@43 => + +This example shows editing coreboot CMOS-RAM settings. A script could be used +to automate this:: + + => cbsysinfo + Coreboot table at 500, size 5c4, records 1d (dec 29), decoded to 000000007dce3f40, forwarded to 000000007ff9a000 + + CPU KHz : 0 + Serial I/O port: 00000000 + base : 00000000 + pointer : 000000007ff9a370 + type : 1 + base : 000003f8 + baud : 0d115200 + regwidth : 1 + input_hz : 0d1843200 + PCI addr : 00000010 + Mem ranges : 7 + id: type || base || size + 0: 10:table 0000000000000000 0000000000001000 + 1: 01:ram 0000000000001000 000000000009f000 + 2: 02:reserved 00000000000a0000 0000000000060000 + 3: 01:ram 0000000000100000 000000007fe6d000 + 4: 10:table 000000007ff6d000 0000000000093000 + 5: 02:reserved 00000000fec00000 0000000000001000 + 6: 02:reserved 00000000ff800000 0000000000800000 + option_table: 000000007ff9a018 + Bit Len Cfg ID Name + 0 180 r 0 reserved_memory + 180 1 e 4 boot_option 0:Fallback 1:Normal + 184 4 h 0 reboot_counter + 190 8 r 0 reserved_century + 1b8 8 r 0 reserved_ibm_ps2_century + 1c0 1 e 1 power_on_after_fail 0:Disable 1:Enable + 1c4 4 e 6 debug_level 5:Notice 6:Info 7:Debug 8:Spew + 1d0 80 r 0 vbnv + 3f0 10 h 0 check_sum + CMOS start : 1c0 + CMOS end : 1cf + CMOS csum loc: 3f0 + VBNV start : ffffffff + VBNV size : ffffffff + ... + Unimpl. : 10 37 40 + +Check that the CMOS RAM checksum is correct, then create a configuration editor +and load the settings from CMOS RAM:: + + => cbcmos check + => cedit cb + => cedit read_cmos + +Now run the cedit. In this case the user selected 'save' so `cedit run` returns +success:: + + => if cedit run; then cedit write_cmos -v; fi + Write 2 bytes from offset 30 to 38 + => echo $? + 0 + +Update the checksum in CMOS RAM:: + + => cbcmos check + Checksum 6100 error: calculated 7100 + => cbcmos update + Checksum 7100 written + => cbcmos check + => diff --git a/include/expo.h b/include/expo.h index 8cb37260db5..3c383d2e2ee 100644 --- a/include/expo.h +++ b/include/expo.h @@ -762,4 +762,12 @@ int expo_apply_theme(struct expo *exp, ofnode node); */ int expo_build(ofnode root, struct expo **expp); +/** + * cb_expo_build() - Build an expo for coreboot CMOS RAM + * + * @expp: Returns the expo created + * Return: 0 if OK, -ve on error + */ +int cb_expo_build(struct expo **expp); + #endif /*__EXPO_H */ diff --git a/test/cmd/coreboot.c b/test/cmd/coreboot.c index e1acf8697e8..a99898d15c4 100644 --- a/test/cmd/coreboot.c +++ b/test/cmd/coreboot.c @@ -6,12 +6,16 @@ * Written by Simon Glass */ +#include #include #include +#include #include +#include #include #include #include +#include "../../boot/scene_internal.h" enum { CSUM_LOC = 0x3f0 / 8, @@ -82,3 +86,34 @@ static int test_cmd_cbcmos(struct unit_test_state *uts) return 0; } CMD_TEST(test_cmd_cbcmos, UTF_CONSOLE); + +/* test 'cedit cb_load' command */ +static int test_cmd_cedit_cb_load(struct unit_test_state *uts) +{ + struct scene_obj_menu *menu; + struct video_priv *vid_priv; + struct scene_obj_txt *txt; + struct scene *scn; + struct expo *exp; + int scn_id; + + ut_assertok(run_command("cedit cb_load", 0)); + ut_assertok(run_command("cedit read_cmos", 0)); + ut_assert_console_end(); + + exp = cur_exp; + scn_id = cedit_prepare(exp, &vid_priv, &scn); + ut_assert(scn_id > 0); + ut_assertnonnull(scn); + + /* just do a very basic test that the first menu is present */ + menu = scene_obj_find(scn, scn->highlight_id, SCENEOBJT_NONE); + ut_assertnonnull(menu); + + txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE); + ut_assertnonnull(txt); + ut_asserteq_str("Boot option", expo_get_str(exp, txt->str_id)); + + return 0; +} +CMD_TEST(test_cmd_cedit_cb_load, UTF_CONSOLE); From patchwork Mon Oct 14 22:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1997122 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Cy+7pfdA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSBrf1Nqbz1xw2 for ; Tue, 15 Oct 2024 09:35:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3693892C5; Tue, 15 Oct 2024 00:32:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Cy+7pfdA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8EA5387042; Tue, 15 Oct 2024 00:32:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DFCC9892C5 for ; Tue, 15 Oct 2024 00:32:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-8354d853f91so182784239f.0 for ; Mon, 14 Oct 2024 15:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728945154; x=1729549954; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J742mQZS5jPLv/vpb4OaUzyAC9isUaTB5rS8acqZO3g=; b=Cy+7pfdAn+99DSy8q2xc946X3YOgnN3LkxtPPT5pejhmjknYgb0uJzT3rHW+UPEgHp srObm/TE7jfcIAJIF9NAnrQP4LKYFJTaGobJr36I4TokJPWxv0MmmJ1hkC0pKbgNrW1t 4/OJJ2tb5SzvTpDWIM+9i72ailpp8DfGMFRHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945154; x=1729549954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J742mQZS5jPLv/vpb4OaUzyAC9isUaTB5rS8acqZO3g=; b=r5+zMbOVVgstQhLt9MKNvq75CdsJxBum+wkFGFe7ITvX1U4d7o7JyfKzX59N1p323e 3aV9mLohASm78zp+1fwubLgYO5ZklF/eyz4gXFUekfj+WFArE+RLwp24IkuQIhf0U7hB s6JZHGqTGB2D40rONOOchZk4GyTLd3fIq555e37fGt3reAn9WfAxqGoLZJdCSDBXXTcU 3R9zOxUvuBMjcuEhiHI9dUs+q/qHIT2qzyOQa741ONBVS0aaamQvXLaXPgF1tos2uY3f kZOujDyXyhMNtc651mfdJfjoDkeKQFMqIE0BWxIdEfiIBzueqVx51sbY38sZ+mQ4tIBK qQPA== X-Gm-Message-State: AOJu0YypyKq4SkBPpbp0HlDNo/rZQ+BCsiVJ/2/xFk4I1B5pmWF11tOO BUN3F3CQ1XRXGazNZNsjYiKY9QwB4tTPrZZ3lp07UXerIgSAsr5WiEVHvU6Q8NMX9ljQnTi2Re7 CAw== X-Google-Smtp-Source: AGHT+IFV5YOdmt40NQhnw0bUfUCrYmbB6M5kK5WsqKN4csmKUkMcmxrOG9J7DL2iwKHBlKikXJfebA== X-Received: by 2002:a92:c241:0:b0:3a0:926a:8d31 with SMTP id e9e14a558f8ab-3a3b5fa4d7emr104592905ab.16.1728945154620; Mon, 14 Oct 2024 15:32:34 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbecc4924dsm14847173.153.2024.10.14.15.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:32:34 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Anatolij Gustschin , Simon Glass , Bin Meng , AKASHI Takahiro , Francis Laniel , Heinrich Schuchardt , Ilias Apalodimas , Mattijs Korpershoek Subject: [PATCH v3 20/20] x86: Enable RTC command by default Date: Mon, 14 Oct 2024 16:32:12 -0600 Message-Id: <20241014223212.2212442-21-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014223212.2212442-1-sjg@chromium.org> References: <20241014223212.2212442-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The real-time clock is needed for most X86 systems and it is useful to be able to read from it. Enable the rtc command by default. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Rebase to -next cmd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 031a4f5e9bf..48461e70d67 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2266,6 +2266,7 @@ config CMD_DATE config CMD_RTC bool "rtc" depends on DM_RTC + default y if X86 help Enable the 'rtc' command for low-level access to RTC devices.