From patchwork Fri Oct 21 00:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1692786 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=85.214.62.61; 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=dl89fu1j; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4Mtln53D8dz23kD for ; Fri, 21 Oct 2022 11:33:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8FC8984FCB; Fri, 21 Oct 2022 02:33:08 +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="dl89fu1j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8B1384FF8; Fri, 21 Oct 2022 02:24:14 +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-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 3D6BB84FED for ; Fri, 21 Oct 2022 02:23:56 +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-xd29.google.com with SMTP id i65so1077299ioa.0 for ; Thu, 20 Oct 2022 17:23:56 -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=wr1lTaj7jRCUoHJ4I+7e06QBtfiz3wgTe5QewhQDfl8=; b=dl89fu1jVwAUyTIIcO37gywC3bgu2jJW8+7pk5IB4VjfhSlKZaLTsLuB0UG+PKVw7+ WSyLVgocLfDGvoORIpcedKtbgBUwI86J7IiVOvmzTDM4gIQXkg5chJB2I7n37iJZMzxt OJ0IJh+NuhzGimfyUo9LWGYMI40zK3K2Uw/sE= 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=wr1lTaj7jRCUoHJ4I+7e06QBtfiz3wgTe5QewhQDfl8=; b=dQo2xH/Pkt+oZGR5egtx7Sh63IQQuti4b/disUbsttmRDG2l4/uj9rwCUXIsHNRti8 riiFngX2W1HwQzFv5ESsOZOgWLo9oY1bzEjokrxGSOunCG64b6T8jcAls3j146Xo+drs rrGyzaKJM7jBsmaBquuzebDrkzMBSn8T46OjoYnkp9QZTP20ahEiuq5uz83lw6nAWKkd gXOoKkPZmysZJoD1XBBv72jo152tJltsWcZrWmMCMI6sIculPmXfMetmq8976EYVmCnN ris+XxrhaV5GnmC5l+zVE4N4vxzbA1bl0z3Ik3HlWLPCkNCv3DLuvKCivsg9OEB/Wo8i Ru3Q== X-Gm-Message-State: ACrzQf2f5qPT9noy8VYOy9Ga1Vh/0tSpW45PDVsghz4dyra+6rMIW/ZZ ZJh5SDOADpjNhjOkr3l3sDgmPoxopkqo3g== X-Google-Smtp-Source: AMsMyM4/tIITu34Wx7vBnhxdiH+burJLCSo5BYQjdzN0sEUF+75ogFOZ3kqmGrAvwnziTRUDVOYqcw== X-Received: by 2002:a6b:7d05:0:b0:68b:7243:63ff with SMTP id c5-20020a6b7d05000000b0068b724363ffmr11894333ioq.191.1666311835587; Thu, 20 Oct 2022 17:23:55 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 17:23:55 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v3 25/43] sandbox: Add a way to specify the sandbox executable Date: Thu, 20 Oct 2022 18:23:02 -0600 Message-Id: <20221021002320.1169603-26-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 the sandbox executable is assumed to be arg[0] but this only works for a single jump (e.g. from SPL to U-Boot). Add a new arg to solve this issue, along with a detailed comment. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/start.c | 30 ++++++++++++++++++++++++++++++ arch/sandbox/include/asm/state.h | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 642be164a39..622df41f54c 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -244,6 +244,36 @@ static int sandbox_cmdline_cb_jump(struct sandbox_state *state, } SANDBOX_CMDLINE_OPT_SHORT(jump, 'j', 1, "Jumped from previous U-Boot"); +static int sandbox_cmdline_cb_program(struct sandbox_state *state, + const char *arg) +{ + /* + * Record the program name to use when jumping to future phases. This + * is the original executable which holds all the phases. We need to + * use this instead of argv[0] since each phase is started by + * extracting a particular binary from the full program, then running + * it. Therefore in that binary, argv[0] contains only the + * current-phase executable. + * + * For example, sandbox TPL may be started using image file: + * + * ./image.bin + * + * but then TPL needs to run VPL, which it does by extracting the VPL + * image from the image.bin file. + * + * ./temp-vpl + * + * When VPL runs it needs access to the original image.bin so it can + * extract the next phase (SPL). This works if we use '-f image.bin' + * when starting the original image.bin file. + */ + state->prog_fname = arg; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(program, 'p', 1, "U-Boot program name"); + static int sandbox_cmdline_cb_memory(struct sandbox_state *state, const char *arg) { diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index fd42daad51c..49ea483d332 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -71,7 +71,8 @@ struct sandbox_state { const char *parse_err; /* Error to report from parsing */ int argc; /* Program arguments */ char **argv; /* Command line arguments */ - const char *jumped_fname; /* Jumped from previous U_Boot */ + const char *jumped_fname; /* Jumped from previous U-Boot */ + const char *prog_fname; /* U-Boot executable filename */ uint8_t *ram_buf; /* Emulated RAM buffer */ unsigned long ram_size; /* Size of RAM buffer */ const char *ram_buf_fname; /* Filename to use for RAM buffer */