From patchwork Thu Oct 22 12:01:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 534382 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 478B914131E for ; Thu, 22 Oct 2015 23:02:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=compulab.co.il header.i=@compulab.co.il header.b=UmfHa9Ce; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9A884A74C7; Thu, 22 Oct 2015 14:02:21 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7l6upObu7Rhl; Thu, 22 Oct 2015 14:02:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0754BA74A0; Thu, 22 Oct 2015 14:01:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3D324B88C for ; Thu, 22 Oct 2015 14:01:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H2K_o35AbCPS for ; Thu, 22 Oct 2015 14:01:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 0688E4B86D for ; Thu, 22 Oct 2015 14:01:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=mCJeBpCC/Ka4kp4cIdHLh7FkrovTMtFe3YBl5YMoXos=; b=UmfHa9CebHeJS Z+HiHnBo8IRuvzkiyl9RlTfA8TQdsBKWhCNxv4KW0zypXw6gB7Ocgf//6NgeUmIGvBmvPp0NdHvCe 6de9vcJGEDmv8yiF/EYcaoffTzLfNbjQBFK/2Eu/T+RTiKuzlKNIypR/JWp9SqpqST74lF6aTmUUm 2+B4=; Received: from [62.90.235.247] (port=45948 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.86) (envelope-from ) id 1ZpEYg-0001jR-PT; Thu, 22 Oct 2015 15:01:26 +0300 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 83F4248D532; Thu, 22 Oct 2015 15:01:25 +0300 (IDT) Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id vA3ssByV9wbo; Thu, 22 Oct 2015 15:01:25 +0300 (IDT) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 42D7348D58B; Thu, 22 Oct 2015 15:01:24 +0300 (IDT) X-Virus-Scanned: amavisd-new at zimbra-mta.compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rU25SxmvykUi; Thu, 22 Oct 2015 15:01:24 +0300 (IDT) Received: from skynet.compulab.local (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 100B048D582; Thu, 22 Oct 2015 15:01:24 +0300 (IDT) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Thu, 22 Oct 2015 15:01:18 +0300 Message-Id: <1445515280-21389-11-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445515280-21389-1-git-send-email-nikita@compulab.co.il> References: <1445515280-21389-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_recent_authed_mail_ips_text_entry: nikita@compulab.co.il|compulab.co.il X-Authenticated-Sender: softlayer.compulab.co.il: nikita@compulab.co.il Cc: Tom Rini Subject: [U-Boot] [PATCH 10/12] spl: add support for alternative boot device X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce spl_boot_list array, which defines a list of boot devices that SPL will try before hanging. By default this list will consist of only spl_boot_device(), but board_boot_order() can be overridden by board code to populate the array with custom values. Signed-off-by: Nikita Kiryanov Cc: Igor Grinberg Cc: Tom Rini Cc: Simon Glass --- common/spl/spl.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 56fccca..7913c52 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -178,6 +178,23 @@ int spl_init(void) return 0; } +#ifndef BOOT_DEVICE_NONE +#define BOOT_DEVICE_NONE 0xdeadbeef +#endif + +static u32 spl_boot_list[] = { + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, +}; + +__weak void board_boot_order(u32 *spl_boot_list) +{ + spl_boot_list[0] = spl_boot_device(); +} + static int spl_load_image(u32 boot_device) { switch (boot_device) { @@ -247,7 +264,7 @@ static int spl_load_image(u32 boot_device) void board_init_r(gd_t *dummy1, ulong dummy2) { - u32 boot_device; + int i; debug(">>spl:board_init_r()\n"); @@ -272,10 +289,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_board_init(); #endif - boot_device = spl_boot_device(); - debug("boot device - %d\n", boot_device); - if (spl_load_image(boot_device)) + board_boot_order(spl_boot_list); + for (i = 0; i < ARRAY_SIZE(spl_boot_list) && + spl_boot_list[i] != BOOT_DEVICE_NONE; i++) { + if (!spl_load_image(spl_boot_list[i])) + break; + } + + if (i == ARRAY_SIZE(spl_boot_list) || + spl_boot_list[i] == BOOT_DEVICE_NONE) { + puts("SPL: failed to boot from all boot devices\n"); hang(); + } switch (spl_image.os) { case IH_OS_U_BOOT: