From patchwork Sat Dec 7 04:43:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205428 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="ijL/aUqO"; 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 47VHSG3jMtz9sPL for ; Sat, 7 Dec 2019 16:04:30 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 005E4817E0; Sat, 7 Dec 2019 05:54:59 +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="ijL/aUqO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 75F65817D9; Sat, 7 Dec 2019 05:54:56 +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-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 773CD817D4 for ; Sat, 7 Dec 2019 05:54:53 +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-xd41.google.com with SMTP id x1so9490121iop.7 for ; Fri, 06 Dec 2019 20:54:53 -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=k5vyQd8bTLNIpA1Iz3ritGvWxSflv7/Zb3z6nVIn3ZQ=; b=ijL/aUqOF57TlW9mTM+BKUJ+MOcErXIO0oWc8uxbOr54ALC+Xcd+6jXM+Wm7BPc8uL gkb5dXZQzxIp0tCaJZajUrtGrlvZKtCE/c/mizZmGMBUr3BCkPuUIkJoQ7d+u1RdU/Ib pnRMiMA9cXz6tEAt9xdDdSXEmPTUvHKO4Wugc= 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=k5vyQd8bTLNIpA1Iz3ritGvWxSflv7/Zb3z6nVIn3ZQ=; b=jEHqER3Z/hayvfIY4okix4CfbgM8Io1Uw1RH7tb07w1D0NQ4bmAHu4XrDaapB59D4k IcxwEp8uYHJoQf6jhtkEMATPuBjAF92p2vMRFr8ofDkzEkSobMa74R9Rm8+6gfJnYZkX qhT7nZtTpKbD+wprqOASy2/jEWyvVCA+jit4Ab9IDYo6MgyHA+O/3iBHZjN4zOQikvgi /9+pGsKffJEak+bXHQyQ1RIWxFRPym1E53PlOxwABsIfRHo2j+gnVYNQCC9b8BONpf5r VCurGinail2fhzeGk2SOc9hrPrpxIbMdcIvXbI+nKA7Ef/aOoZqlkoJDCR/hyG3DM6QG ZBsA== X-Gm-Message-State: APjAAAU+uWzJtRXNeg1GEsYnC9aZPTkPGjOjIpQSukr+uoN0lTt6WtO8 +wZWj4jW7NmcH7nnBpg4kxFMOE7KBTQ= X-Google-Smtp-Source: APXvYqzKdVkjI2pvW9sjRTGd6EbQR0/z4F3NQ6DRo1FXrDqBv8YKMNXj0pG2QjvGvylYFOmCKeYmfw== X-Received: by 2002:a6b:db12:: with SMTP id t18mr12721384ioc.11.1575694492217; Fri, 06 Dec 2019 20:54:52 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id o7sm4549410ilo.58.2019.12.06.20.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 20:54:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v6 094/102] spl: Add methods to find the position/size of next phase Date: Fri, 6 Dec 2019 21:43:07 -0700 Message-Id: <20191206213936.v6.94.Ie1276d645c7828fd8b97bdf1ec2b20d2e6b36e2f@changeid> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191207044315.51770-1-sjg@chromium.org> References: <20191207044315.51770-1-sjg@chromium.org> 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 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