From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13897C433EF for ; Mon, 1 Nov 2021 01:22:24 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B53660F4A for ; Mon, 1 Nov 2021 01:22:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8B53660F4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE5D883606; Mon, 1 Nov 2021 02:21:25 +0100 (CET) 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="b7Lu6rBO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9AA3E83602; Mon, 1 Nov 2021 02:20:13 +0100 (CET) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 B8A5A835D4 for ; Mon, 1 Nov 2021 02:19:27 +0100 (CET) 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-xd33.google.com with SMTP id v65so19711672ioe.5 for ; Sun, 31 Oct 2021 18:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uvc89vsTu5+XmQGuyTXAVzWkDpRLmSqfnkalDp1MKoM=; b=b7Lu6rBO8Aar5AOlmj2y8KWwqfzTjX7oi9+N2vpIbVMjc7eToLrF/VFy5GEKXOaVte rrLDa/zaaP04o21JA1jeM9KkpmgIbyfFnsYgUpSCPff3FsXguoM5e5F2y+ZXgWw5g1R5 kibhqG5m3GBy0703ifR3FFxmWqXfTD2hooiNw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uvc89vsTu5+XmQGuyTXAVzWkDpRLmSqfnkalDp1MKoM=; b=Vxg2Fs7fgC7yRugcyD1Ap/vgYwpTjLCaTniLRz0XvmTyxmE4YqZValuzW7jjq/fHBT owtPVnA2EVpFjeKTxAGyaPAXIdJCRKgguujjx18X/uMYKaKJzVE4w77UtY7O2NQ1uNuB b0PX1BKopiqOYsWpgRo+Ot75fxrfQasD4er2rVddyVn0Tmx+CbZOoFCpIm3pWEQhsiN9 xjwdZvIM1SNbHwmASH9xHypmxqfSYL2gxFdmbZA2HL8k6DfeOzgj7tRqixYtrXMTNHYw iRtNX/BeU9OnQkOfWhO8fop4oQgiHcVyqrJM5QkbbY5pZ7ujj7YKt3OJsDE3OPpPEn2O rZ5w== X-Gm-Message-State: AOAM530MbovT0Xndbd+CTxkvKkJdJB5JYeXQfNtaYzsQ+p9iVABq4F1a RXPnj/cYV1J0OOV2akOgILk00ofl141roQ== X-Google-Smtp-Source: ABdhPJxIt+cq+Wd1EA2sYIyfuncNS50HLu18qVYJlZlyXgyd2zOoQM+/yHLOTqfy2YoO2+2D8a1lqA== X-Received: by 2002:a02:ccfb:: with SMTP id l27mr19274719jaq.98.1635729566213; Sun, 31 Oct 2021 18:19:26 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id f11sm4351109ilu.82.2021.10.31.18.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 18:19:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Ilias Apalodimas , Bill Mills , Heinrich Schuchardt , =?UTF-8?q?Fran=C3=A7ois=20Ozog?= , Simon Glass Subject: [PATCH 16/31] passage: Support an incoming passage Date: Sun, 31 Oct 2021 19:17:18 -0600 Message-Id: <20211101011734.1614781-17-sjg@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211101011734.1614781-1-sjg@chromium.org> References: <20211101011734.1614781-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Plumb in the ability for U-Boot proper to accept an incoming standard passage from a previous phase, such as SPL or TF-A. This allows data to be passed from binary to binary when firmware is booting. Signed-off-by: Simon Glass --- common/Kconfig | 31 ++++++++++++++++++++++++++++++ common/bloblist.c | 4 ++++ common/board_f.c | 32 ++++++++++++++++--------------- include/asm-generic/global_data.h | 21 ++++++++++++++++++++ include/bloblist.h | 9 +++++++++ lib/asm-offsets.c | 5 +++++ 6 files changed, 87 insertions(+), 15 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index 2c6f5901c8a..fa7915d2acc 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -740,6 +740,14 @@ config BLOBLIST_ALLOC specify a fixed address on systems where this is unknown or can change at runtime. +config BLOBLIST_PASSAGE + bool "Obtain bloblist from standard passage information" + help + Rather than allocating the bloblist, get it from the standard + passage provided by an earlier phase, e.g. SPL. The bloblist address + and size are used as is, except that the bloblist is of course + relocated when U-Boot relocates. + endchoice config BLOBLIST_ADDR @@ -798,6 +806,13 @@ config SPL_BLOBLIST_ALLOC specify a fixed address on systems where this is unknown or can change at runtime. +config SPL_BLOBLIST_PASSAGE + bool "Obtain bloblist from standard passage information" + help + Rather than allocating the bloblist, get it from the standard + passage provided by an earlier phase, e.g. TPL. The bloblist address + and size are used as is within SPL, then passed on to U-Boot. + endchoice endif # SPL_BLOBLIST @@ -833,6 +848,22 @@ endif # TPL_BLOBLIST endmenu +config PASSAGE_IN + bool "Support the standard-passage protocol (in)" + help + This enables a standard protocol for entering U-Boot, providing + parameters in a bloblist with a devicetree. It allows the various + firmware phases to communicate state and settings to following + phases. + +config SPL_PASSAGE_IN + bool "Support the standard-passage protocol in SPL (in)" + help + This enables a standard protocol for entering SPL, providing + parameters in a bloblist and a devicetree. It allows the various + firmware phases to communicate state and settings to following + phases. + source "common/spl/Kconfig" config IMAGE_SIGN_INFO diff --git a/common/bloblist.c b/common/bloblist.c index 29164c9b901..d36e0a94dff 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -444,6 +444,10 @@ int bloblist_init(void) addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR); size = CONFIG_BLOBLIST_SIZE; if (expected) { + if (CONFIG_IS_ENABLED(BLOBLIST_PASSAGE)) { + addr = gd->passage_bloblist; + size = 0; + } ret = bloblist_check(addr, size); if (ret) { log_warning("Expected bloblist at %lx not found (err=%d)\n", diff --git a/common/board_f.c b/common/board_f.c index 14e9286a70f..86c77a42847 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -570,11 +570,13 @@ static int reserve_stacks(void) static int reserve_bloblist(void) { #ifdef CONFIG_BLOBLIST + int new_size = CONFIG_BLOBLIST_SIZE_RELOC; + + if (!new_size) + new_size = bloblist_get_size(); /* Align to a 4KB boundary for easier reading of addresses */ - gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - - CONFIG_BLOBLIST_SIZE_RELOC, 0x1000); - gd->new_bloblist = map_sysmem(gd->start_addr_sp, - CONFIG_BLOBLIST_SIZE_RELOC); + gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - new_size, 0x1000); + gd->new_bloblist = map_sysmem(gd->start_addr_sp, new_size); #endif return 0; @@ -655,21 +657,21 @@ static int reloc_bootstage(void) static int reloc_bloblist(void) { #ifdef CONFIG_BLOBLIST - /* - * Relocate only if we are supposed to send it - */ - if ((gd->flags & GD_FLG_SKIP_RELOC) && - CONFIG_BLOBLIST_SIZE == CONFIG_BLOBLIST_SIZE_RELOC) { + int size = bloblist_get_size(); + int new_size = CONFIG_BLOBLIST_SIZE_RELOC; + + if (!new_size) + new_size = size; + + /* Relocate only if we are supposed to send it */ + if ((gd->flags & GD_FLG_SKIP_RELOC) && size == new_size) { debug("Not relocating bloblist\n"); return 0; } if (gd->new_bloblist) { - int size = CONFIG_BLOBLIST_SIZE; - - debug("Copying bloblist from %p to %p, size %x\n", - gd->bloblist, gd->new_bloblist, size); - bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC, - gd->bloblist, size); + debug("Copying bloblist from %p size %x to %p, size %x\n", + gd->bloblist, size, gd->new_bloblist, new_size); + bloblist_reloc(gd->new_bloblist, new_size, gd->bloblist, size); gd->bloblist = gd->new_bloblist; } #endif diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 99daa20c765..ef4119f27f4 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -119,6 +119,27 @@ struct global_data { */ unsigned long precon_buf_idx; #endif + /** + * @passage_bloblist: Incoming bloblist from the passage + * + * Provides the address of the bloblist passed in by the previous stage + * or phase. If this is zero, there is none. + */ + ulong passage_bloblist; + + /** + * @passage_dtb_off: Offset of dtb within the passage + * + * Provides the offset within the bloblist where the control DTB is + * stored. If this is zero, there is none. + * + * Note: This must be set to the correct value if the control DTB exists + * since SPL may use this and ignore the bloblist, e.g. if bloblist + * support is not enabled for code-size reasons. If this value is not + * valid, any devicetree passed in the passage_bloblist is ignored. + */ + ulong passage_dtb_off; + /** * @env_addr: address of environment structure * diff --git a/include/bloblist.h b/include/bloblist.h index 88c62b54c54..2ede0ce3150 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -292,6 +292,15 @@ int bloblist_finish(void); */ void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp); +ulong bloblist_get_base(void); + +/** + * bloblist_get_size() - Get the size of the bloblist + * + * @returns the size in bytes + */ +ulong bloblist_get_size(void); + /** * bloblist_get_base() - Get the base address of the bloblist * diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index c691066332d..5467b95cb47 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -43,5 +43,10 @@ int main(void) DEFINE(GD_ENV_ADDR, offsetof(struct global_data, env_addr)); + DEFINE(GD_PASSAGE_BLOBLIST, + offsetof(struct global_data, passage_bloblist)); + DEFINE(GD_PASSAGE_DTB_OFF, + offsetof(struct global_data, passage_dtb_off)); + return 0; } -- 2.33.1.1089.g2158813163f-goog