From patchwork Sun Sep 20 15:49:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1367913 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; 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=ffA5qLmq; 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 4BvX8B65XRz9sSW for ; Mon, 21 Sep 2020 01:50:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25CD1823FC; Sun, 20 Sep 2020 17:49:46 +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="ffA5qLmq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C37E7824A5; Sun, 20 Sep 2020 17:49:41 +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=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) (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 AE46982482 for ; Sun, 20 Sep 2020 17:49:27 +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-oi1-x241.google.com with SMTP id x14so13957726oic.9 for ; Sun, 20 Sep 2020 08:49:27 -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=NwauYeu0Yhi/VHzwNu9u4DJ5EL1cbknfgWLfsVVzByw=; b=ffA5qLmqRqUyIo55KUbPChjqTOuB+3rEsq0SC5dP2ZBTW5MVoKcc52ZMea8sIMeeM+ ci8jHjsq+eLt1oa6v6fuKb26OXakaS1fqMj+xTDQeI+Iy63GzxYM7hwDtAabHvH5hfKK X48/QpJDW6YclhOiHkBCxeFjSCmUTLl3BR3Dc= 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=NwauYeu0Yhi/VHzwNu9u4DJ5EL1cbknfgWLfsVVzByw=; b=PJPLlTZZR4/NPU/j8Rhxyl20HvidtB5F9YZ01ZfMYIdOTiw69cltbe9rVnBoZGUi92 oQXCCvQBwtWd8J6mpEBSlzJS+sG1X5kmH/KIFyohYP7VuO3iodkytmcKbGcI3/Lxy2rL xcl/K4kl6VP+qV/C/nLnbVQhUxi2w7B8G66iTxz93LeVmP8GUDZ8+THum6VXmLXtA1wP ddyc1rMGvz6w9nNNg66pUEFJGn+kp798u7byWcaZ2uppqhTTkqZBCfeOpYNYdyirFbtg l6rm4+1+4GaindpptEoxt8/UZIfCWyzIoYKeVEqBWULvcwLtxN26oz0ei14LhBuhhJNb yn0A== X-Gm-Message-State: AOAM5315trqQzf/+hYdM13sOeMNy9y1NeIQRBluv8rImHgvTTYnhCSZa lpxrngT/5DfNota4ho/U4ibvqyfwcFbzN14k X-Google-Smtp-Source: ABdhPJwlnpSq/Eggbybu4zIz+pSP+GB3IkA9ZiGt8vtUyopbUQw7jnY8K3xuxEf2a/9IUVYrnZW0Tw== X-Received: by 2002:a05:6808:5ca:: with SMTP id d10mr15317355oij.27.1600616966370; Sun, 20 Sep 2020 08:49:26 -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 d1sm5500682otb.80.2020.09.20.08.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 08:49:25 -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 3/5] x86: Allow showing details about a HOB entry Date: Sun, 20 Sep 2020 09:49:17 -0600 Message-Id: <20200920094914.3.Ia5660394c5732506673bfe5de470c85746ea9cce@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200920154919.2275229-1-sjg@chromium.org> References: <20200920154919.2275229-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 --- 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 bbe38bbf20e..2933bc08c76 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)", "" );