From patchwork Fri Oct 21 00:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1692769 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jfzxFGVR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mtlg90wNrz23jk for ; Fri, 21 Oct 2022 11:28:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B6A284FF3; Fri, 21 Oct 2022 02:25:42 +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="jfzxFGVR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C69584FCC; Fri, 21 Oct 2022 02:24:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 0E72884FCC for ; Fri, 21 Oct 2022 02:24: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-il1-x12b.google.com with SMTP id y17so817874ilq.8 for ; Thu, 20 Oct 2022 17:24:16 -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 :message-id:reply-to; bh=epaDQSjeqcrvyQlcGNOjWYUnThV4H+IowKhePjeXkZs=; b=jfzxFGVR6sNOa3vImhw1sGw/r26JP+Bw2Og3afYckBrsViGd+1Jt0XyHF4f1QcAay+ /Bj6AxuuXs590TYHcElHt5EICDalcnePVuFzcK5j2euMC7449UgJNJEseskVihCmk1az oH2Z4XYJ/8PDOnZN16kdqyfSN6ZWA8aCjNbWo= 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:message-id:reply-to; bh=epaDQSjeqcrvyQlcGNOjWYUnThV4H+IowKhePjeXkZs=; b=1RGyhqhxQofbS8t6TLtef6a0jsh+R7soUi5J0wKHJ0fHJ6M2XbwxYMd0Y+mFb6PprI uJ7iFp+7IO2M/ZpB6oqOR3muQAaz43WcdF55FSRMJbpycW217h+lVclR5PwBJRk299xD KZ2HoKDYDxbJwGkumOfiZyG7rX8QYnmJCTUIVzhurTFvM1ctYKZ/vj+HxRjKf60vL9// iB4WtkC7pmvF6uOcJegiAarEorz7+mZ6nSVGy6tpFtyx0ItBtyCxPSM/37IciD6TTePn o9H2N8btTIc8eFMkmt57rx8BIzjh7bEylP+oicCwrDs/6S/r8EM7Mud7dYcDJX9/qZOp 2BNA== X-Gm-Message-State: ACrzQf1hazY/rp3I84PRDtkD2BLQUeTavdUalUczS+cJ91g7MiP6OWQf 8eU1h8hTEHcXiDEOZiaaEE2gVRMy0GfN2w== X-Google-Smtp-Source: AMsMyM4vWNyAX6hp2MmBvslxo6lrbtvp2LKM2XAlnslJZdGLnjrxHTY8PyHELy7XpuBz8edkKJa/mQ== X-Received: by 2002:a05:6e02:1a65:b0:2ff:3115:f199 with SMTP id w5-20020a056e021a6500b002ff3115f199mr5216410ilv.31.1666311834828; Thu, 20 Oct 2022 17:23:54 -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 f8-20020a02a108000000b00356738a2aa2sm3646131jag.55.2022.10.20.17.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 17:23:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v3 24/43] sandbox: Generalise SPL booting Date: Thu, 20 Oct 2022 18:23:01 -0600 Message-Id: <20221021002320.1169603-25-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221021002320.1169603-1-sjg@chromium.org> References: <20221021002320.1169603-1-sjg@chromium.org> MIME-Version: 1.0 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. Also use the 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 --- (no changes since v1) 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 9c59cc26163..2678370481a 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;