From patchwork Mon Jan 27 05:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229579 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PhRcODMm; 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 485dS60M9lz9sR1 for ; Mon, 27 Jan 2020 16:23:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 450EF81900; Mon, 27 Jan 2020 06:13:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PhRcODMm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A187481845; Mon, 27 Jan 2020 06:09:30 +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=-0.1 required=5.0 tests=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-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 D3945817A0 for ; Mon, 27 Jan 2020 06:08:58 +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-xd41.google.com with SMTP id n11so8552767iom.9 for ; Sun, 26 Jan 2020 21:08:58 -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=1dOo4WTpYFE5PZilJywqdVfEOy+qi3h6yCksx7vuEQo=; b=PhRcODMmeL1cskYDmiAWi2VfmRG0W0x1rE5YKOAUzAPQaI9xWlGX/1U90IiEYhgH/4 babAa3VSY+fi+AxPTsAfpB1IMsevvPwPNqzEo81xNpkg2OJLrCRhxnmvZD9KNjdvNLcT CtDSFZSBCq45zlzVbIe5WT5LlcLOKZebiqTzM= 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=1dOo4WTpYFE5PZilJywqdVfEOy+qi3h6yCksx7vuEQo=; b=AqvIBTXh7V14b6gr+NESq8y2CbtBBhCX4Tq5oh8sGQvHdnEkx95pwGnTVdPKapXQE7 5jexvHKFG55o+CwxoOvl2Oj0qWb/eCJeXe1oeSQAjFIzfJxoKKo0YwYaYdul48GqQsHG 9gpmB7eCkbZU+i5g2HnHXnJ0Ybo+2+AMebmZtPUo9+AQwPXP4Sv9BYCKVsH0LWCy1mdn mxarv3tZazTLupjRBGVXPook7BjCWgZGPo2OMaarFbNtTCloz8PyIUUQb47u4C3dRaIQ aXSAHD/q1FAjn8b7W2L6X/TL2ZIxy21CPatfv+3NZ7dlgyyp2D52d5yTFjJayLiccZhE dQDw== X-Gm-Message-State: APjAAAWSedlOIfs13yYy2jOct5n3U4c4lw+ahbAQ5aXfm4C2RlkY+jEo vk1nbaoHogvHLyI04hNkqG2EX9f4v0qRhg== X-Google-Smtp-Source: APXvYqxoiHKh57CmRO0l0ww531hZyxqXQ5F8FgjeOcl/AOob4fHsT+Hfi26Gqrln/dvA6SmoBU8vAA== X-Received: by 2002:a02:94e9:: with SMTP id x96mr11236707jah.68.1580101737549; Sun, 26 Jan 2020 21:08:57 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id h23sm4313195ilf.57.2020.01.26.21.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:57 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 042/108] acpi: Add an acpi split command Date: Sun, 26 Jan 2020 22:05:49 -0700 Message-Id: <20200126220508.42.I5894252b8fe4522e409528c497d882226f34ab9b@changeid> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200127050655.170614-1-sjg@chromium.org> References: <20200127050655.170614-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 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.101.4 at phobos.denx.de X-Virus-Status: Clean Add a command that shows the individual blocks of data generated by each device. This can be helpful for debugging. Signed-off-by: Simon Glass --- cmd/acpi.c | 15 +++++++++++++-- drivers/core/acpi.c | 18 ++++++++++++++++++ include/dm/acpi.h | 10 ++++++++++ test/dm/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/cmd/acpi.c b/cmd/acpi.c index b66c26265b..a472618628 100644 --- a/cmd/acpi.c +++ b/cmd/acpi.c @@ -146,6 +146,17 @@ static int do_acpi_list(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +static int do_acpi_items(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + bool dump; + + dump = argc >= 2 && !strcmp("-d", argv[1]); + acpi_dump_items(dump); + + return 0; +} + static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { @@ -153,8 +164,6 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, char sig[ACPI_NAME_LEN]; int ret; - if (argc < 2) - return CMD_RET_USAGE; name = argv[1]; if (strlen(name) != ACPI_NAME_LEN) { printf("Table name '%s' must be four characters\n", name); @@ -172,8 +181,10 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, static char acpi_help_text[] = "list - list ACPI tables\n" + "acpi items [-d] - List/dump each piece of ACPI data from devices\n" "acpi dump - Dump ACPI table"; U_BOOT_CMD_WITH_SUBCMDS(acpi, "ACPI tables", acpi_help_text, U_BOOT_SUBCMD_MKENT(list, 1, 1, do_acpi_list), + U_BOOT_SUBCMD_MKENT(items, 2, 1, do_acpi_items), U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_acpi_dump)); diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index ba02b04636..762cc40511 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -105,6 +105,22 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev, return 0; } +void acpi_dump_items(bool dump_contents) +{ + int i; + + for (i = 0; i < item_count; i++) { + struct acpi_item *item = &acpi_item[i]; + + printf("dev '%s', type %d, size %x\n", item->dev->name, + item->type, item->size); + if (dump_contents) { + print_buffer(0, item->buf, 1, item->size, 0); + printf("\n"); + } + } +} + struct acpi_item *find_item(const char *devname) { int i; @@ -203,6 +219,7 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx) int ret; log_debug("Writing SSDT tables\n"); + item_count = 0; ret = _acpi_fill_ssdt(ctx, dm_root()); log_debug("Writing SSDT finished, err=%d\n", ret); ret = build_type(ctx, start, TYPE_SSDT); @@ -248,6 +265,7 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx) int ret; log_debug("Writing DSDT tables\n"); + item_count = 0; ret = _acpi_inject_dsdt(ctx, dm_root()); log_debug("Writing DSDT finished, err=%d\n", ret); ret = build_type(ctx, start, TYPE_DSDT); diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 8de9296e71..ea3a615f60 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -162,6 +162,16 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx); */ int acpi_inject_dsdt(struct acpi_ctx *ctx); +/** + * acpi_dump_items() - Dump out the collected ACPI items + * + * This lists the ACPI DSDT and SSDT items generated by the various U-Boot + * drivers. + * + * @dump_contents: true to dump the binary contents, false to just show the list + */ +void acpi_dump_items(bool dump_contents); + #endif /* __ACPI__ */ #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index c87bd8569d..dbb4f26a71 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -437,3 +437,42 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test 'acpi items' command */ +static int dm_test_acpi_cmd_items(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + void *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + ut_assertok(acpi_fill_ssdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 1, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 1, size 2"); + ut_assert_console_end(); + + ctx.current = buf; + ut_assertok(acpi_inject_dsdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 0, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 0, size 2"); + ut_assert_console_end(); + + console_record_reset(); + run_command("acpi items -d", 0); + ut_assert_nextline("dev 'acpi-test', type 0, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_nextline("dev 'acpi-test2', type 0, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);