From patchwork Sat Jan 16 21:53:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1427625 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: 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=ExqcOC7u; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DJBjh1yS2z9s24 for ; Sun, 17 Jan 2021 08:57:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7CCDE82A22; Sat, 16 Jan 2021 22:54:31 +0100 (CET) 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="ExqcOC7u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EBF0829F7; Sat, 16 Jan 2021 22:54:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 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 EE808829BC for ; Sat, 16 Jan 2021 22:54:10 +0100 (CET) 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 d13so22166933ioy.4 for ; Sat, 16 Jan 2021 13:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oEd6HN76/orW2flSh8m+LF98CbUrrM5vG2wHlC73TYA=; b=ExqcOC7uTk646EFyY8IrXT93jAroqlvhk2jbyFcax75tUDmz/vjW4es/3Xoe/E/BAQ /VPkup5NV8bIf/ApdnxjeLMIkWEVySs+OVFazI5ReM5jtOgm8cKGx17I+8nG8PgPPC61 TYqARszhTJb/KnSh7FGisefW5+ZGoLVI/JDTE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oEd6HN76/orW2flSh8m+LF98CbUrrM5vG2wHlC73TYA=; b=fHCOoYbyBJFgkj54nPct0DAYFVx49ijJUIgxxryaXDRcUfp9qlC/WG1OjbqW7UHBD9 5iz/XHoHTThDUVzBGTRmaajCW2aaYYCtoVh8fs8BfSOsrri0AZeJtmEkYFpstCg5TZEN NuhawtL5Ke6YJ25p+6ycv/o4tpqtbGH27hkUa6OmAtpnpXEnbZbJcqNrnxhyp+C9rhlX rUy9Q+fJZZtYNPeZb13ZldzV518+AYw/KLST/WYvK5FON6ZLM449W7hl+HhRYBllRzxZ fEyH0I99sZWe8MF/zYLzhnCCxm7Gx7wgcZNupL/qYpG2Wm1J776OrsMTM8/shxJGCopH khww== X-Gm-Message-State: AOAM531OcloSsi/JtzFyFQhN6jjue1dRj4rYF6naB+nA8sTsElPKR6nX NZbrRifEZ9JUXye7nkmkIajCsVK1jU4ehHmp X-Google-Smtp-Source: ABdhPJz3HZQvBHGyIyYSz3qlkDq16qcRHDeycUk8Tj+Z5GF+TV/TI8/bD+g25gQuXc2Vfsl4EfxW1g== X-Received: by 2002:a5d:96c5:: with SMTP id r5mr12590070iol.62.1610834049563; Sat, 16 Jan 2021 13:54:09 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id a17sm7428746ilc.77.2021.01.16.13.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jan 2021 13:54:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Bin Meng , Igor Opaniuk Subject: [PATCH 07/12] x86: zimage: Allow dumping the image from outside the module Date: Sat, 16 Jan 2021 14:53:54 -0700 Message-Id: <20210116145343.7.I4cbe2bb13efa1af25d22b7d3ada88be0dc01b9a6@changeid> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog In-Reply-To: <20210116215359.1220766-1-sjg@chromium.org> References: <20210116215359.1220766-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present it is possible to dump an image within the zimage command, but it is also useful to be able to dump it from elsewhere, for example in a loader that has special handling for the different zimage stages. Export this feature as a new function. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/include/asm/zimage.h | 10 ++++++++++ arch/x86/lib/zimage.c | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h index 64c0e6e857b..6679767d16b 100644 --- a/arch/x86/include/asm/zimage.h +++ b/arch/x86/include/asm/zimage.h @@ -62,6 +62,16 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, ulong initrd_addr, ulong initrd_size, ulong cmdline_force); +/** + * zimage_dump() - Dump the metadata of a zimage + * + * This shows all available information in a zimage that has been loaded. + * + * @base_ptr: Pointer to the boot parameters, typically at address + * DEFAULT_SETUP_BASE + */ +void zimage_dump(struct boot_params *base_ptr); + void setup_video(struct screen_info *screen_info); void setup_efi_info(struct efi_info *efi_info); diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 708025b2071..3e9ee12400f 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -600,19 +600,12 @@ static void show_loader(struct setup_header *hdr) printf("\n"); } -int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +void zimage_dump(struct boot_params *base_ptr) { - struct boot_params *base_ptr = state.base_ptr; struct setup_header *hdr; const char *version; int i; - if (argc > 1) - base_ptr = (void *)simple_strtoul(argv[1], NULL, 16); - if (!base_ptr) { - printf("No zboot setup_base\n"); - return CMD_RET_FAILURE; - } printf("Setup located at %p:\n\n", base_ptr); print_num64("ACPI RSDP addr", base_ptr->acpi_rsdp_addr); @@ -688,6 +681,20 @@ int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) print_num("Handover offset", hdr->handover_offset); if (get_boot_protocol(hdr, false) >= 0x215) print_num("Kernel info offset", hdr->kernel_info_offset); +} + +static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct boot_params *base_ptr = state.base_ptr; + + if (argc > 1) + base_ptr = (void *)simple_strtoul(argv[1], NULL, 16); + if (!base_ptr) { + printf("No zboot setup_base\n"); + return CMD_RET_FAILURE; + } + zimage_dump(base_ptr); return 0; }