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 8D262C433FE for ; Thu, 13 Oct 2022 12:36:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64AE784F64; Thu, 13 Oct 2022 14:32:34 +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="Z5pAxomJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DBAC84F82; Thu, 13 Oct 2022 14:31:16 +0200 (CEST) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 19C8A84F57 for ; Thu, 13 Oct 2022 14:30:47 +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-xd33.google.com with SMTP id 137so1163924iou.9 for ; Thu, 13 Oct 2022 05:30:47 -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=S0gw3xXogGkRxh4YTayBM99cKQhUjje2o6jV9F/yPuk=; b=Z5pAxomJiFnrTbIOBh5a511ZULePkI9dIx43ruGZ2Vv78JbOk0JWpLAkk4es49fayh iC431l34GofUMO79eYpTyJ1JYMH2sZfJTFl9nj8l/dh1pnXN8x8Nkkzpwu1dg27OREXP ozQx53G8EkQ1SyA2mecT9UQEyB61yGh8u3YAM= 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=S0gw3xXogGkRxh4YTayBM99cKQhUjje2o6jV9F/yPuk=; b=dbovq3KH1ecYehQZd4VEQks/ct6iJrLn31mGr25XQyb7qq6qW3QZM0nv0wwOqRInyw Nr1Zbg24ooQmua8XFCVLzBwtBnQ/rthY5n35nSRMK75+SS7jzo/zMhlbZlUhTt15ZZA0 0G6Yn554W9Ic/1RzYzJGdpAgmz3N4iarSOzNmcZlCtcBRN1lJ2ClgBiT3Gl/VcLydK9S lXkxjpx0AFflM17QCdQYKsJGerbAuHFGXcOfSMc/PUEaSiHTXYPdwNPGdVc6tkwbibX9 BS9g1S9QkN1kaAG3i7hJyDTIOKpcT3uFwDiu36MbPjFzELMwQYCC21+P564oGY4KfoZu +jiQ== X-Gm-Message-State: ACrzQf0oSUKOmDHoLpi8kDPUNW9z6VWY3JRmnD3aS2Cv+m7UMCU6+r1+ q0zHoIO9h13YzaNYhotCJZUR56O/8hZCHw== X-Google-Smtp-Source: AMsMyM7xejL43sqHgckEkXshX3OQhjM4AYuG792gu7RoE1RNl/G9tvhy13iQzNpe3lk2Q3d7O2QLWA== X-Received: by 2002:a05:6638:338a:b0:363:bcaf:1017 with SMTP id h10-20020a056638338a00b00363bcaf1017mr10316345jav.176.1665664234054; Thu, 13 Oct 2022 05:30:34 -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 a9-20020a027a09000000b003635ab4a7b7sm7321626jac.3.2022.10.13.05.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 05:30:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alper Nebi Yasak , Andre Przywara , Heiko Schocher , Heiko Thiery , Heinrich Schuchardt , Lokesh Vutla , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Ricardo Salveti , Vaishnav Achath Subject: [PATCH v2 25/45] sandbox: Generalise SPL booting Date: Thu, 13 Oct 2022 06:29:07 -0600 Message-Id: <20221013122927.636867-26-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221013122927.636867-1-sjg@chromium.org> References: <20221013122927.636867-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. 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; -- 2.38.0.rc1.362.ged0d419d3c-goog