From patchwork Tue Sep 22 20:54:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1369262 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org 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=Y8uO4RXe; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BwtrG0jWGz9sS8 for ; Wed, 23 Sep 2020 06:55:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C13678265D; Tue, 22 Sep 2020 22:55:18 +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="Y8uO4RXe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 05D5A823DC; Tue, 22 Sep 2020 22:55:09 +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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) (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 5DD9082304 for ; Tue, 22 Sep 2020 22:55:02 +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-ot1-x342.google.com with SMTP id o8so16930553otl.4 for ; Tue, 22 Sep 2020 13:55:02 -0700 (PDT) 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=+sEPnyD/NmlV6dImAe61DU27a/OcIYuVbWpwKNhY5w8=; b=Y8uO4RXeJOmerkgeQiW5ns48Upa6Rh+cGI81gOdzH6C1VFldZs8nhDst8OZrBbm9Hn yIad+LabtmRLIyRGCLKr85w8W5qliet5t4rtFu3AHfz4iO72B11m4opIs4qhpy9ku331 S+yml+FHifCxarBcf2AlB8INwyi0kAfKJEldA= 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=+sEPnyD/NmlV6dImAe61DU27a/OcIYuVbWpwKNhY5w8=; b=pgRpeYPFPZ0PVPo9iDm5BxrVSIDjoR1BbTXOxk5g6wQVnGA0vsD6orV1NwTpBB2BuO UcE5YlVmcEIlimmawxTOKbW3wcXg2ipjd1kf19J4uSCnDjH8awHHRDHIbOl2asRBVm6F JQ0v+z8xftn7+0wTI0um0CTmghY7KPFG6UN1rTpRcVNCrNxEtn57STCZCv7whvoyuaed 41wJ98MWhpdorpEh0MJWZ5buGQeSniPzoVwp/FnhHFhfk2U3vThH3zXwLX2HCumpFyXk Dz2cTPacqa6HMjtQVnVFZvhsuS+X7DAXbWv2bjbwdeNsVkJFEu3GT2EGHT+NqkNeYI3M wb/g== X-Gm-Message-State: AOAM532RHkd8gtqX2LrVIlyPWI+RfZcmlek+yAinbMc0Kx6N36+TCAPm z1Y5Nw6xmyftDcAXk98g0eH370UHGpJD0z6o X-Google-Smtp-Source: ABdhPJxnFEX0yguvlMUF11fTa7vG6o2mwCGLAzP8y7OlUoBGm10Nr/hmDrGaiZPbpjxh6OUnyb91sg== X-Received: by 2002:a9d:61c1:: with SMTP id h1mr4234631otk.103.1600808100868; Tue, 22 Sep 2020 13:55:00 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r5sm7205541otk.74.2020.09.22.13.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 13:55:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Bin Meng Subject: [PATCH v2 3/5] x86: Allow showing details about a HOB entry Date: Tue, 22 Sep 2020 14:54:50 -0600 Message-Id: <20200922145447.v2.3.Ia5660394c5732506673bfe5de470c85746ea9cce@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200922205452.2955712-1-sjg@chromium.org> References: <20200922205452.2955712-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 Some HOBs include information that can be decoded. Add a -v option to the hob command, to allow this to be displayed. Add the ability to decode a resource descriptor. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v2: - Capitalise 'System' cmd/x86/hob.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c index 98a67600086..9e555c778c2 100644 --- a/cmd/x86/hob.c +++ b/cmd/x86/hob.c @@ -27,6 +27,16 @@ static char *hob_type[] = { "Capsule", }; +static char *res_type[] = { + "System", + "Memory-mapped I/O", + "I/O", + "Firmware device", + "Memory-mapped I/O port", + "Reserved", + "I/O reserved", +}; + static struct guid_name { efi_guid_t guid; const char *name; @@ -58,6 +68,26 @@ static const char *guid_to_name(const efi_guid_t *guid) return NULL; } +static void show_hob_details(const struct hob_header *hdr) +{ + const void *ptr = hdr; + + switch (hdr->type) { + case HOB_TYPE_RES_DESC: { + const struct hob_res_desc *res = ptr; + const char *typename; + + typename = res->type > 0 && res->type <= RES_MAX_MEM_TYPE ? + res_type[res->type] : "unknown"; + + printf(" base = %08llx, len = %08llx, end = %08llx, type = %d (%s)\n\n", + res->phys_start, res->len, res->phys_start + res->len, + res->type, typename); + break; + } + } +} + static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { const struct hob_header *hdr; @@ -66,12 +96,20 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int i = 0; efi_guid_t *guid; char uuid[UUID_STR_LEN + 1]; + bool verbose = false; int seq = -1; /* Show all by default */ argc--; argv++; - if (argc) - seq = simple_strtol(*argv, NULL, 16); + if (argc) { + if (!strcmp("-v", *argv)) { + verbose = true; + argc--; + argv++; + } + if (argc) + seq = simple_strtol(*argv, NULL, 16); + } hdr = gd->arch.hob_list; printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); @@ -111,13 +149,16 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) printf("%36s", "Not Available"); } printf("\n"); + if (verbose) + show_hob_details(hdr); } return 0; } -U_BOOT_CMD(hob, 2, 1, do_hob, - "[seq] Print Hand-Off Block (HOB) information" +U_BOOT_CMD(hob, 3, 1, do_hob, + "[-v] [seq] Print Hand-Off Block (HOB) information" + " -v - Show detailed HOB information where available" " seq - Record # to show (all by default)", "" );