From patchwork Mon Dec 9 00:40:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205815 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RQMi4yof"; dkim-atps=neutral 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47WPY63Dkwz9sPK for ; Mon, 9 Dec 2019 11:42:34 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73F18816AC; Mon, 9 Dec 2019 01:42:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RQMi4yof"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D5E381672; Mon, 9 Dec 2019 01:41:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham 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 3997D81653 for ; Mon, 9 Dec 2019 01:41:50 +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-xd42.google.com with SMTP id x1so12918997iop.7 for ; Sun, 08 Dec 2019 16:41:50 -0800 (PST) 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=DqVf3I5t9wlDIVxuesho4lIKBhJnN2s4L0K3Kz+P8B8=; b=RQMi4yofjOQrI/fObA7PNMASD9oEx6hZajE2L3Sp8F/5Z85vmimbGi7UtUZTWs5B3D XQBnWtvdhV09k61c3+4/XusrmS3OF5omUtSA8fbWZ4GLb8w8iFqO+gPmJFAphkWaxCog G/Xcx2jlRayaypbqGAD7sBGJr8krono9eW+8k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DqVf3I5t9wlDIVxuesho4lIKBhJnN2s4L0K3Kz+P8B8=; b=opQibPiJtFWr8cYDPKs+RxA3oxWMAiC4psmAsIPT44o9CYHTGK9oeXI4iByuRowpqq ABWZvG1GNnbCQ9RWtpJEYLiLClCssWEI8ds+uOBdrsNcBnGaK4fb5N0/Dio5LskSz4Cb +jdjRx5EOHfEBi8DQeW9BwGVUhSlAXm6Otthmu5ILsdNFFJOThu8WJ5pJf+w9nIiCmz7 dwvM6hBhruW8oyZ/dGjEE4N4SGLQYpoTtPIpz84U3NqNDPZBUTzdCDcEzWXCLviwc+q2 K06qiF1X546F8SXWy5ca0pXYzjby2U+s6AsJsZCSbPM+ZZdziTD5qptIIE2b+dW5Bioe ZGww== X-Gm-Message-State: APjAAAVw8ADeWunFvGWfjkl0H7CiJoTIBOwPxT3h//Pg1TAzL6XQEwwN W7IdQty0rBqm5nAE7eiTpYGACZM5lTM= X-Google-Smtp-Source: APXvYqyUuZNi2gvATr6fYfRR23J7xLsCP/Wu07Wov9rzYYZGcM6Pqp5c5ldXOogUNsbwU+isWwvAVw== X-Received: by 2002:a6b:8d57:: with SMTP id p84mr19077416iod.194.1575852108914; Sun, 08 Dec 2019 16:41:48 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id n3sm6286212ilm.74.2019.12.08.16.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 16:41:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v7 09/17] spl: Add methods to find the position/size of next phase Date: Sun, 8 Dec 2019 17:40:12 -0700 Message-Id: <20191208173929.v7.9.Ie1276d645c7828fd8b97bdf1ec2b20d2e6b36e2f@changeid> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191208173929.v7.4.I5ba86662e42269ac50c05b6db34832a966dad79a@changeid> References: <20191208173929.v7.4.I5ba86662e42269ac50c05b6db34832a966dad79a@changeid> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 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.101.4 at phobos.denx.de X-Virus-Status: Clean Binman supports writing the position and size of U-Boot proper and SPL into the previous phase of U-Boot. This allows the next phase to be easily located and loaded. Add functions to return these useful values, along with symbols to allow TPL to load SPL. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v7: None Changes in v6: - Add new patch with methods to find the position/size of next SPL phase Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None common/spl/spl.c | 20 ++++++++++++++++++++ include/spl.h | 21 ++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index d51dbe9942..c1fce62b91 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -42,6 +42,12 @@ u32 *boot_params_ptr = NULL; /* See spl.h for information about this */ binman_sym_declare(ulong, u_boot_any, image_pos); +binman_sym_declare(ulong, u_boot_any, size); + +#ifdef CONFIG_TPL +binman_sym_declare(ulong, spl, image_pos); +binman_sym_declare(ulong, spl, size); +#endif /* Define board data structure */ static bd_t bdata __attribute__ ((section(".data"))); @@ -120,6 +126,20 @@ void spl_fixup_fdt(void) #endif } +ulong spl_get_image_pos(void) +{ + return spl_phase() == PHASE_TPL ? + binman_sym(ulong, spl, image_pos) : + binman_sym(ulong, u_boot_any, image_pos); +} + +ulong spl_get_image_size(void) +{ + return spl_phase() == PHASE_TPL ? + binman_sym(ulong, spl, size) : + binman_sym(ulong, u_boot_any, size); +} + /* * Weak default function for board specific cleanup/preparation before * Linux boot. Some boards/platforms might not need it, so just provide diff --git a/include/spl.h b/include/spl.h index 08ffddac29..02aa1ff85d 100644 --- a/include/spl.h +++ b/include/spl.h @@ -169,10 +169,29 @@ struct spl_load_info { * We need to know the position of U-Boot in memory so we can jump to it. We * allow any U-Boot binary to be used (u-boot.bin, u-boot-nodtb.bin, * u-boot.img), hence the '_any'. These is no checking here that the correct - * image is found. For * example if u-boot.img is used we don't check that + * image is found. For example if u-boot.img is used we don't check that * spl_parse_image_header() can parse a valid header. + * + * Similarly for SPL, so that TPL can jump to SPL. */ binman_sym_extern(ulong, u_boot_any, image_pos); +binman_sym_extern(ulong, u_boot_any, size); +binman_sym_extern(ulong, spl, image_pos); +binman_sym_extern(ulong, spl, size); + +/** + * spl_get_image_pos() - get the image position of the next phase + * + * This returns the image position to use to load the next phase of U-Boot + */ +ulong spl_get_image_pos(void); + +/** + * spl_get_image_size() - get the size of the next phase + * + * This returns the size to use to load the next phase of U-Boot + */ +ulong spl_get_image_size(void); /** * spl_load_simple_fit_skip_processing() - Hook to allow skipping the FIT