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 934C7C04A95 for ; Sun, 25 Sep 2022 15:06:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B302984D6F; Sun, 25 Sep 2022 17:04:11 +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="DEB6qbgG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF06C84B67; Sun, 25 Sep 2022 17:03:38 +0200 (CEST) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 E7D4C84A37 for ; Sun, 25 Sep 2022 17:03:31 +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-il1-x12f.google.com with SMTP id h14so2400557ila.12 for ; Sun, 25 Sep 2022 08:03:31 -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=fBz2I+NlIUQBRWLV1tKAHLD2CYjqexvUebBel6Zk6Jg=; b=DEB6qbgGSnhAjzBvpLDj7zbluKBCs0uCl7TiF4xHrzlYDMLO0FztIRs/xJS81WoOAp +kDyGhbe+4VZlaDG+QdcqN6GwPQa6fPHa0fGTPuTihWSEOL7u9UJkaeaCqDaGFgNlxTV pCaQ6KP3UeNJut/mFMyFT+FkL4l8Ls+lWaFXM= 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=fBz2I+NlIUQBRWLV1tKAHLD2CYjqexvUebBel6Zk6Jg=; b=fB3cwzqY4aJA9jktsW6hLKGameTmLTvrJYwh41MX0LNYKrA9hra0sbCG9UipOpF5ki EoBLGXaUCcVqVKXKONBtqm1/XItNonNI1kQH3McpNvJtH/3SyHwIN4R1NvJzca8RhXRL MHMHeHIqjpaAQHV/vx9x6M4BqHREmAxSdPc8fbZWKJhxoEOInOOHU3+2Ii2lXRHL/YT8 9IIIp5VRfIyStwC7FMlO1Ng8TMUK6ZjVnbkxy+YJq0lVtmGEAVS0E1zguavgKnMX7ruI cxeBQxmgwLQhNj637TRdMAtnLLdOhJV7Ux+cZf0Gq2n8elRjOyEszwvD+a6RVrMaR8CR yukg== X-Gm-Message-State: ACrzQf3HszHiZ4rnCJE6O81HFkhnGRfkdFdSfh1Ou7yEG9xMgaYGlPXo O+FlbwAOwhfoKkv4YjTMWDu/HBU9LYjt2Q== X-Google-Smtp-Source: AMsMyM78Yb+re3vH+mEO8oiFjHtcFaz4p6z6mBgZ3NWqK59PAFgsj9iklhwg10rLgWomFiklEQdW/Q== X-Received: by 2002:a05:6e02:17cb:b0:2f6:a177:65d1 with SMTP id z11-20020a056e0217cb00b002f6a17765d1mr8010976ilu.193.1664118210012; Sun, 25 Sep 2022 08:03:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 08:03:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alper Nebi Yasak , Heiko Schocher , Heiko Thiery , Heinrich Schuchardt , Lokesh Vutla , Michael Walle , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Ricardo Salveti , Vaishnav Achath Subject: [PATCH 19/45] sandbox: Generalise SPL booting Date: Sun, 25 Sep 2022 09:02:22 -0600 Message-Id: <20220925150248.2524421-20-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 At present sandbox only supports jumping to a file, to get to the next U-Boot phase. We want to support other methods, so update the code to use an enum for the method. Use board_boot_order() to set the order, so we can add more options. Also add the MMC methods into the BOOT_DEVICE enum so that booting from MMC can be supported. Signed-off-by: Simon Glass --- arch/sandbox/cpu/spl.c | 33 +++++++++++++++++++++------------ arch/sandbox/include/asm/spl.h | 3 +++ include/spl.h | 9 +++++++++ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 1d49a9bd102..6d4981152bb 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -49,13 +49,13 @@ void board_init_f(ulong flag) preloader_console_init(); } -u32 spl_boot_device(void) +void board_boot_order(u32 *spl_boot_list) { - return BOOT_DEVICE_BOARD; + spl_boot_list[0] = BOOT_DEVICE_BOARD; } -static int spl_board_load_image(struct spl_image_info *spl_image, - struct spl_boot_device *bootdev) +static int spl_board_load_file(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) { char fname[256]; int ret; @@ -74,10 +74,11 @@ static int spl_board_load_image(struct spl_image_info *spl_image, if (!spl_image->arg) return log_msg_ret("exec", -ENOMEM); strcpy(spl_image->arg, fname); + spl_image->flags = SPL_SANDBOXF_ARG_IS_FNAME; return 0; } -SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image); +SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_file); void spl_board_init(void) { @@ -96,13 +97,21 @@ void spl_board_init(void) void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { - const char *fname = spl_image->arg; - - if (fname) { - os_fd_restore(); - os_spl_to_uboot(fname); - } else { - printf("No filename provided for U-Boot\n"); + switch (spl_image->flags) { + case SPL_SANDBOXF_ARG_IS_FNAME: { + const char *fname = spl_image->arg; + + if (fname) { + os_fd_restore(); + os_spl_to_uboot(fname); + } else { + log_err("No filename provided for U-Boot\n"); + } + break; + } + default: + log_err("Invalid flags\n"); + break; } hang(); } diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h index bf5a585622b..312aef72086 100644 --- a/arch/sandbox/include/asm/spl.h +++ b/arch/sandbox/include/asm/spl.h @@ -7,6 +7,9 @@ #define __asm_spl_h enum { + BOOT_DEVICE_MMC1, + BOOT_DEVICE_MMC2, + BOOT_DEVICE_MMC2_2, BOOT_DEVICE_BOARD, }; diff --git a/include/spl.h b/include/spl.h index a89830d24fd..e711fb13654 100644 --- a/include/spl.h +++ b/include/spl.h @@ -228,6 +228,15 @@ static inline const char *spl_phase_prefix(enum u_boot_phase phase) # define SPL_TPL_PROMPT "" #endif +/** + * enum spl_sandbox_flags - flags for sandbox's use of spl_image_info->flags + * + * @SPL_SANDBOXF_ARG_IS_FNAME: arg is the filename to jump to (default) + */ +enum spl_sandbox_flags { + SPL_SANDBOXF_ARG_IS_FNAME = 0, +}; + struct spl_image_info { const char *name; u8 os; -- 2.37.3.998.g577e59143f-goog