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 6448AC54EE9 for ; Sun, 25 Sep 2022 15:06:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 81DCC84D69; Sun, 25 Sep 2022 17:04:07 +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="RxiyOsH0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E6E984AF7; Sun, 25 Sep 2022 17:03:39 +0200 (CEST) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 F1A0E84C35 for ; Sun, 25 Sep 2022 17:03:32 +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-x132.google.com with SMTP id m16so2405904ili.9 for ; Sun, 25 Sep 2022 08:03:32 -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=cMOzCqmiyknCR88a1Oas+Qpkg+Qtlavmarfhe5jakek=; b=RxiyOsH0NxerxdARdEeKw12KE6qekEubKCGdT5tsgMPZiDe5OLl0Gplloc8VBY5kBq e/9i30AK/vwGhJldm7gAsw0igHQK7FEquGrpiKGY0uHoBzrNdHeros7yHH9qD44b3R+i paKVtiN5hys/Ra7LxnBV7r+pwMQkKvjIypvOc= 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=cMOzCqmiyknCR88a1Oas+Qpkg+Qtlavmarfhe5jakek=; b=MOCowWwmf3/KOvEAheO+kXn1DoySMDEaZP8Ci3+Jw/KnMqWOGSt1Yhd1GfzGkfCJxB mjFQHopKBSkF2d/gQ3UkKIQYZPrdd5FG4Xobou+O1Lj1uJd4yg96MpYkp/r6tECjN+YR s0z1Izjb3z9dYeqr7k5yVSrfWKLFJHnD4potULYFZjMgpnYi7zE5tqHIdSslxwvCQ4Eh 9OSSQKCjPdGBLrtGqsTpkAbEt6xO4CszKs5kUreP+HC90n7/+Z9s1hUs7WHqEjFo7+4S g2a+NCs3Ldc49ET3EALi7akL+TkF+Cw5hZPdkgLP71rUf7hrxxoY489FuWM7qrcNMZp9 Zy+A== X-Gm-Message-State: ACrzQf2Z/9Ep8vspnp8NYXJWY4N6kr1A0lmi3ubgysKpXQ8Cuyj78qQr L41Z8tDLk9ic32VVNJ7Dcnxko2v4UJbOBw== X-Google-Smtp-Source: AMsMyM6m5AWsW22y61W64QUjQ5lnUqcZwidF1wv80EFVxrAX+W8o3S7KnLqhrR5rtR2tPBFcnZKB4Q== X-Received: by 2002:a05:6e02:78a:b0:2f6:9f8b:e70c with SMTP id q10-20020a056e02078a00b002f69f8be70cmr8354965ils.111.1664118211075; Sun, 25 Sep 2022 08:03:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 08:03:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Andrew Scull , Heinrich Schuchardt Subject: [PATCH 20/45] sandbox: Add a way to specify the sandbox executable Date: Sun, 25 Sep 2022 09:02:23 -0600 Message-Id: <20220925150248.2524421-21-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 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 --- 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.37.3.998.g577e59143f-goog