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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3F58FC54EE9 for ; Sun, 25 Sep 2022 15:04:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0193D84C36; Sun, 25 Sep 2022 17:03: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="h+vY7fdQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48FB484A9C; Sun, 25 Sep 2022 17:03:22 +0200 (CEST) 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 3E01D84AD6 for ; Sun, 25 Sep 2022 17:03:17 +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 e205so3447475iof.1 for ; Sun, 25 Sep 2022 08:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jS9Q31eJxEeZzerZY19AWvDOQpxuqah63BVv5YA9W2g=; b=h+vY7fdQDenjgfPvlPTqM/Uc4e82anDTt3B+FbwVNvmbvyailWqm59FpQBT8ery1HX 7FMs+dI8icEpSwzoVOGCXHdYw6M6OMnTv07O81kLarybvQ3WaPQtc4Us1ltaoXDmIqei L/9VZDLdexAKXhH+y0TL2TmJQTQy7Gab6q1bs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=jS9Q31eJxEeZzerZY19AWvDOQpxuqah63BVv5YA9W2g=; b=FNLWRWZvlAofobNhzF5mMQifJ7aR3m8ctI2krjVcIaLhZl4YshWtSjl2tM2zzknbLj 1s/jlIEw9z4VhidL+OpX8z1dUhoMACNerso/pjF0QjywibtXcjkmSm6jk48KDsO/fyUm RmSKh0qQeNhLUu8gjXMguCDzo3QmPl308RBhxVV1kAGAOKrJoRwXIcyqN1gigzUdiMxC x4J+gZnF9bNJAa7WQJYstAQP8oKFCw3UXlm7sEpPNK4scOmLxui+2dN6+rsKqTRHxFMX cYfMbpYQioqSouVghbg+1SfBJQWkT+bKERRtGwyeyj6/WX6gftU2gtZUEN/5cdn9AzNe +ZEQ== X-Gm-Message-State: ACrzQf1KqZj68i/CmucNW2JxikQJxf8MME7U23P0WhpsJgE/UBUprSOm Xjgi2GgxPGXDeK54rOSZ1Et3zFSeTMV8cw== X-Google-Smtp-Source: AMsMyM7TnRRb5vXWBHjaXZElxoctY5vtMIdlQ+U3V/682iVggb20rvRjoLRO4saWjx/VE3MNHGL7aA== X-Received: by 2002:a05:6638:2414:b0:35a:b7f0:492a with SMTP id z20-20020a056638241400b0035ab7f0492amr9724430jat.78.1664118195400; Sun, 25 Sep 2022 08:03:15 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id u19-20020a926013000000b002f19d9838c6sm5360578ilb.25.2022.09.25.08.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 08:03:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alper Nebi Yasak , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Stefan Roese Subject: [PATCH 06/45] spl: Split up the board_init_r() function Date: Sun, 25 Sep 2022 09:02:09 -0600 Message-Id: <20220925150248.2524421-7-sjg@chromium.org> X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog In-Reply-To: <20220925150248.2524421-1-sjg@chromium.org> References: <20220925150248.2524421-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean This function is quite long and does two separate things: init and booting. Split it into two. Signed-off-by: Simon Glass --- common/spl/spl.c | 64 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 55b638209ae..edf24b05162 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -720,16 +720,15 @@ void board_init_f(ulong dummy) } #endif -void board_init_r(gd_t *dummy1, ulong dummy2) +/** + * spl_init_r() - Set up SPL ready for use + * + * Calls all required init functions to get SPL up and running + * + * @return 0 if OK, -ve on error (meaning boot cannot proceed) + */ +static int spl_init_r(void) { - u32 spl_boot_list[] = { - BOOT_DEVICE_NONE, - BOOT_DEVICE_NONE, - BOOT_DEVICE_NONE, - BOOT_DEVICE_NONE, - BOOT_DEVICE_NONE, - }; - struct spl_image_info spl_image; int ret; debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); @@ -741,8 +740,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) gd->flags |= GD_FLG_FULL_MALLOC_INIT; #endif if (!(gd->flags & GD_FLG_SPL_INIT)) { - if (spl_init()) - hang(); + ret = spl_init(); + if (ret) + return log_msg_ret("init", ret); } #if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) /* @@ -754,10 +754,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (CONFIG_IS_ENABLED(BLOBLIST)) { ret = bloblist_init(); if (ret) { - debug("%s: Failed to set up bloblist: ret=%d\n", - __func__, ret); + log_debug("Failed to set up bloblist: ret=%d\n", ret); puts(SPL_TPL_PROMPT "Cannot set up bloblist\n"); - hang(); + return log_msg_ret("bl", ret); } } if (CONFIG_IS_ENABLED(HANDOFF)) { @@ -766,7 +765,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) ret = setup_spl_handoff(); if (ret) { puts(SPL_TPL_PROMPT "Cannot set up SPL handoff\n"); - hang(); + return log_msg_ret("ho", ret); } } @@ -795,6 +794,29 @@ void board_init_r(gd_t *dummy1, ulong dummy2) dm_dump_mem(&mem); } + return 0; +} + +/** + * spl_boot() - Boot into the next U-Boot phase + * + * Figures out which boot device to use, loads the image and jumps to it + * + * This function does not return. If something goes wrong, it tries to print a + * message, then hangs. + */ +static void spl_boot(void) +{ + u32 spl_boot_list[] = { + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + BOOT_DEVICE_NONE, + }; + struct spl_image_info spl_image; + int ret; + memset(&spl_image, '\0', sizeof(spl_image)); #ifdef CONFIG_SYS_SPL_ARGS_ADDR spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; @@ -880,6 +902,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2) jump_to_image_no_args(&spl_image); } +void board_init_r(gd_t *dummy1, ulong dummy2) +{ + int ret; + + ret = spl_init_r(); + if (!ret) + spl_boot(); + + puts("SPL fail\n"); + hang(); +} + /* * This requires UART clocks to be enabled. In order for this to work the * caller must ensure that the gd pointer is valid. -- 2.37.3.998.g577e59143f-goog