From nobody Thu Mar 10 23:41:32 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CEB3819F8E8D; Thu, 10 Mar 2022 23:41:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KF5Dr5Mt0z3jNb; Thu, 10 Mar 2022 23:41:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646955692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DjfDUSJzJLlqfq5kWJUw5xxqDxrZUTDmjJls/DJ8sWY=; b=dnhQ6Pwt/LfRIHceabadpKq86RYPrFw2+Bw97s3YJBaAbmPeN3KsvNf1Hd5SC1nJmPvg6/ 5l5bNBDGx/Ipt0UHKhwLYeO0x/9xejvA+4XyJ4m48IRbHbRCRJcyvQWnVSaN8zPSjv7IGZ 4D+sKhK7PfYMKKSAIBL8/uuFfzwPeW79/1ahbwk0iqVX809FJjoAcXJUBe4mo/nqtumcWe regOsEFeARN5hN7gPrBXvxu9W3Tq4PuwdQvJJlsv0sUWXJD19xkeJ/yR4uBxSGQTIdlpCF EfSVq26PLXBJwlrSTSUZARF0/FYPrXCcasgHZzdhjN7aSJroIHVDVJnjzyzMNQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 99CC46668; Thu, 10 Mar 2022 23:41:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22ANfWs2025016; Thu, 10 Mar 2022 23:41:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22ANfWdC025015; Thu, 10 Mar 2022 23:41:32 GMT (envelope-from git) Date: Thu, 10 Mar 2022 23:41:32 GMT Message-Id: <202203102341.22ANfWdC025015@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 904a13759cf6 - main - ddb: Add 'show gic ' and 'show all gics' commands. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 904a13759cf68fc2eb60bcdd2fecc1e9c3546c5c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646955692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DjfDUSJzJLlqfq5kWJUw5xxqDxrZUTDmjJls/DJ8sWY=; b=EEiJIuKZVx5AGO7dv6hdg8hp0mVefQYUcbvaE9DiVfemC0vTiv2dCgzplvPzn9JYOMcayn KczFMY5bCVXfQ5C500X27LpzjP+6QqoNWzZSXJ7K9oO8ldWTkfZTBzyGL9PHGTZTMl9BCA E2Kpsgd2yQa9qW0nKpCFyVkS56p2V89O15Q371h8FKzV2TVFQtQ2mJyOspuVwlq/10u+IN imaRr3Or+duBzB4FMAFRg7HYT2UP3WceATLOeI8deqYAHp5dH63RN1oyLd+90s0v8ZIpkn uupRRzzUGWSXiju0F1+Gs2YY3F75V+7pXmHrYDiBW3m1QPoweUz0ICFG0vjcVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646955692; a=rsa-sha256; cv=none; b=DCzpCYQI/xsmTpXfCzz4/W/ItGAjrXtDNAkEPiGPDPcnVs7M1LqwZ4Uq1PaCUp/VcnqTzy ZjhVZjfbCHbKGDiz4vSNVdXn+RYWL3+0IHGVZ3kx93vCaOKz8hQHZ/ookXWxfmTZZ14oXm um+MQGYUJ8EVAPxhdljj/8VOtzfv+hi8Q3ulnKaDyG5sCJ6X8gPK/Jy0yw4l9xFk+YVesh PDBe6Y2xOMBkbufWVQ08gWVFZsEkrKGd20MGgmOqpRdERIx2tSX5VWF7qNo4+vgnmbuLsI KmC8IrE/MPyB1pt5FoQRN08ecp00Imf27HvM4kJd0JBSNS8yqdiBHktO5auSIg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=904a13759cf68fc2eb60bcdd2fecc1e9c3546c5c commit 904a13759cf68fc2eb60bcdd2fecc1e9c3546c5c Author: John Baldwin AuthorDate: 2022-03-10 23:39:37 +0000 Commit: John Baldwin CommitDate: 2022-03-10 23:39:37 +0000 ddb: Add 'show gic ' and 'show all gics' commands. To handle the different register layouts for different versions, add a GIC_DB_SHOW() method. Currently this hook is only implemented for versions 1 and 2. Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34415 --- sys/arm/arm/gic.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ sys/arm/arm/gic_if.m | 4 ++ 2 files changed, 113 insertions(+) diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index e285747678de..434c491b4d56 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_ddb.h" #include "opt_platform.h" #include @@ -72,6 +73,11 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef DDB +#include +#include +#endif + #include #include @@ -1147,6 +1153,58 @@ arm_gic_release_msix(device_t dev, struct intr_irqsrc *isrc) return (0); } +#ifdef DDB +static void +arm_gic_db_show(device_t dev) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + uint32_t val; + u_int i; + + db_printf("%s CPU registers:\n", device_get_nameunit(dev)); + db_printf(" CTLR: %08x PMR: %08x BPR: %08x RPR: %08x\n", + gic_c_read_4(sc, GICC_CTLR), gic_c_read_4(sc, GICC_PMR), + gic_c_read_4(sc, GICC_BPR), gic_c_read_4(sc, GICC_RPR)); + db_printf("HPPIR: %08x IIDR: %08x\n", gic_c_read_4(sc, GICC_HPPIR), + gic_c_read_4(sc, GICC_IIDR)); + + db_printf("%s Distributor registers:\n", device_get_nameunit(dev)); + db_printf(" CTLR: %08x TYPER: %08x IIDR: %08x\n", + gic_d_read_4(sc, GICD_CTLR), gic_d_read_4(sc, GICD_TYPER), + gic_d_read_4(sc, GICD_IIDR)); + for (i = 0; i < sc->nirqs; i++) { + if (i <= GIC_LAST_SGI) + db_printf("SGI %2u ", i); + else if (i <= GIC_LAST_PPI) + db_printf("PPI %2u ", i - GIC_FIRST_PPI); + else + db_printf("SPI %2u ", i - GIC_FIRST_SPI); + db_printf(" grp:%u", + !!(gic_d_read_4(sc, GICD_IGROUPR(i)) & GICD_I_MASK(i))); + db_printf(" enable:%u pend:%u active:%u", + !!(gic_d_read_4(sc, GICD_ISENABLER(i)) & GICD_I_MASK(i)), + !!(gic_d_read_4(sc, GICD_ISPENDR(i)) & GICD_I_MASK(i)), + !!(gic_d_read_4(sc, GICD_ISACTIVER(i)) & GICD_I_MASK(i))); + db_printf(" pri:%u", + (gic_d_read_4(sc, GICD_IPRIORITYR(i)) >> 8 * (i & 0x3)) & + 0xff); + db_printf(" trg:%u", + (gic_d_read_4(sc, GICD_ITARGETSR(i)) >> 8 * (i & 0x3)) & + 0xff); + val = gic_d_read_4(sc, GICD_ICFGR(i)) >> 2 * (i & 0xf); + if ((val & GICD_ICFGR_POL_MASK) == GICD_ICFGR_POL_LOW) + db_printf(" LO"); + else + db_printf(" HI"); + if ((val & GICD_ICFGR_TRIG_MASK) == GICD_ICFGR_TRIG_LVL) + db_printf(" LV"); + else + db_printf(" ED"); + db_printf("\n"); + } +} +#endif + static device_method_t arm_gic_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, arm_gic_print_child), @@ -1179,6 +1237,9 @@ static device_method_t arm_gic_methods[] = { DEVMETHOD(gic_release_msi, arm_gic_release_msi), DEVMETHOD(gic_alloc_msix, arm_gic_alloc_msix), DEVMETHOD(gic_release_msix, arm_gic_release_msix), +#ifdef DDB + DEVMETHOD(gic_db_show, arm_gic_db_show), +#endif { 0, 0 } }; @@ -1186,6 +1247,54 @@ static device_method_t arm_gic_methods[] = { DEFINE_CLASS_0(gic, arm_gic_driver, arm_gic_methods, sizeof(struct arm_gic_softc)); +#ifdef DDB +DB_FUNC(gic, db_show_gic, db_show_table, CS_OWN, NULL) +{ + device_t dev; + int t; + bool valid; + + valid = false; + t = db_read_token(); + if (t == tIDENT) { + dev = device_lookup_by_name(db_tok_string); + valid = true; + } + db_skip_to_eol(); + if (!valid) { + db_printf("usage: show gic \n"); + return; + } + + if (dev == NULL) { + db_printf("device not found\n"); + return; + } + + GIC_DB_SHOW(dev); +} + +DB_SHOW_ALL_COMMAND(gics, db_show_all_gics) +{ + devclass_t dc; + device_t dev; + int i; + + dc = devclass_find("gic"); + if (dc == NULL) + return; + + for (i = 0; i < devclass_get_maxunit(dc); i++) { + dev = devclass_get_device(dc, i); + if (dev != NULL) + GIC_DB_SHOW(dev); + if (db_pager_quit) + break; + } +} + +#endif + /* * GICv2m support -- the GICv2 MSI/MSI-X controller. */ diff --git a/sys/arm/arm/gic_if.m b/sys/arm/arm/gic_if.m index ba722c3b1250..d6458cf177c4 100644 --- a/sys/arm/arm/gic_if.m +++ b/sys/arm/arm/gic_if.m @@ -67,3 +67,7 @@ METHOD int release_msix { device_t dev; struct intr_irqsrc *isrc; }; + +METHOD void db_show { + device_t dev; +};