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 1623FC433FE for ; Thu, 13 Oct 2022 12:35:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABB1384F74; Thu, 13 Oct 2022 14:31:58 +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="LdmbCM20"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A56984F3F; Thu, 13 Oct 2022 14:30:55 +0200 (CEST) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 EAC8684F38 for ; Thu, 13 Oct 2022 14:30:35 +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-xd2f.google.com with SMTP id e15so1186748iof.2 for ; Thu, 13 Oct 2022 05:30:35 -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=VtYo5koYqidqg0UcUGxYdjXS8igF3K0Wf9zHs4J2jrg=; b=LdmbCM20++2WRjtX8F7ZyLNO7HrwcGwQlncYNC4puXRleJGl19AMqNvQBdPMrKU94c 1IpvI8QaI+BuTDPhe+0Qzl0f1VxsjtZoAXA8R7ys7JKnLqGSX73Kof8EpFyxaRaSzjPj wc1B19GqPB7xK1BStqF/y+W6PE0MS3usnYUwk= 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=VtYo5koYqidqg0UcUGxYdjXS8igF3K0Wf9zHs4J2jrg=; b=ZgpriY9sI2CHdiNfe/B1RDk0q3fSPhy8ELNTm2DfIanBagrgx0k+IZsPfnUBYWR7eF 3z8BPCNYqfhwYT2WF4itNdE616k9kEPhx5LnBYmdcIEHBJrX1lVfQLiuvE1R8TMuwRlK D/gerdJTk6GoMtvpE5B/Tp7tkDVo+AM4fF4/5DteQ0UGw2GB0bLC4Ia57fWqlcVXv4UV uX/rKaeF99IuP7+sgRPHkZnwEf1ojARmrSkcE40NCKutoKou73mBAjaWx5U0/rf6uGVP PpcRGeR8sfoLq/HbL5WeAnBaW/MUgkwlormj2gSSSeKMntIoP4NhS5WQKLTPUpAcIBzp ZWEg== X-Gm-Message-State: ACrzQf0ErKfpNzJzrgB2IWfho24iB/XMIZWRN4/ePhw+y0u2cGsNGbDp pDQ6Ya7ab7h+aAr+h9SvMT95yS3SQSiE+g== X-Google-Smtp-Source: AMsMyM4eUMzhhFhEZWARJRVG0Y3C2S3JmNbS2qVDtYZYzfRnMWdvih8eiaNY/vgQjDe9zsLoamO+NQ== X-Received: by 2002:a05:6638:238a:b0:35a:25b7:a1a7 with SMTP id q10-20020a056638238a00b0035a25b7a1a7mr18901575jat.92.1665664235089; Thu, 13 Oct 2022 05:30:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 05:30:34 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Andrew Scull , Heinrich Schuchardt Subject: [PATCH v2 26/45] sandbox: Add a way to specify the sandbox executable Date: Thu, 13 Oct 2022 06:29:08 -0600 Message-Id: <20221013122927.636867-27-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 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 */ -- 2.38.0.rc1.362.ged0d419d3c-goog