From nobody Fri Oct 11 18:07:01 2024 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 4XQF2F6z6Pz5ZCcb; Fri, 11 Oct 2024 18:07:01 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XQF2F4Tqgz41W6; Fri, 11 Oct 2024 18:07:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728670021; 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=nAW3beSqTZGMO2fnsRhndESWqOwhuX8iS85oIhN/aYk=; b=JnYy9uTv5NS/hpAdCIFa2J59ofN+xijKyDnsNmXCYi6rg1YdnUTxp5jumcDWkUJchV/H+r kYS2kx/YTswbPQLvLSpi1PjFMjyjrBZjXMJMJAZ7ObiOZ5EaDXhf3XdDzZvA3v0gpMeEpq 56swLM2RRREDg77JD4v59ZbhzmbJS9jYirYZQ3/k16VXNgQ42AF1LVOa57lmESlCpnXj2/ HNcV+c1dht8LIayRTZR3BdpgIJ4qUrwuVwIu326WHcA/35Ncd4rWlfYhYZ+tYjV+pBdmfY YrLuXdZZdSO1gFOag4m5eL/VFtl0Ec7DxeaojuZ3eCDlwLzRP53Lj4T9+PYfow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728670021; 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=nAW3beSqTZGMO2fnsRhndESWqOwhuX8iS85oIhN/aYk=; b=hcHz5M1X9DdkvAbKMpkS5IwrzPAvUQ1Z89TwZdPvE9m4s9EJdOAg0PjmKGbOsa+dWN3Wgp L54cZutNQq8O47aCcUmbw3Vo2i15agBqhU1iBDvpufOPiuaOc0Oj8KffQCYUV9i5e2G0PA 6/CuEkmnQ4QqWwAHGwkyJgb1kZ1K69xeQ6VC8+C63J49D/6XEyAw0VOgCnxYBhMYRhg4oE BsCKnp3AqH55zG8Dh6mfFQrk08wLUrEw36mokiEXRqsZot3OZ0+VYRViD2eZmc0gOSSr4w 8o0d7QUPq3exxdaSWV1tXgdD1jq7ZbDK0XMOK1ziuhKtQHKhDn5N25KaU13yOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728670021; a=rsa-sha256; cv=none; b=ywAmz+Ogxhtzm7BZt/vVvX0Fl2TnyPyqEJGPhb4mkNMw2/O9F7mFbJUZl9CKHslaRkLgmf gMsji4v9sUQ6Iq6boLHTwDVBgM8nIn7aRbGnYYP6RGqYnaoVBy1eaqNBmcVe90W4kJ0ceP Ip5TkN0F6QDKC1EfEC+KHsaozl9X/MspMHNsb1z5BwcUou/pFt3ZuVFcyL9BBSYg6fjOKh zST5Tos+wxv7oANKB6SvDuyzTw2Hy/anUrDrMIyBeFrsj6rB/H4HKCO4jXkeUyLec8BHie sLMeEg07gKx7QmPKXjj7yhiC+ROUStNqPLEfFTEhgN+XuX3PXprWbIqZHUOSfA== 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 4XQF2F3wDDzrwf; Fri, 11 Oct 2024 18:07:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49BI71xP011851; Fri, 11 Oct 2024 18:07:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49BI71mf011848; Fri, 11 Oct 2024 18:07:01 GMT (envelope-from git) Date: Fri, 11 Oct 2024 18:07:01 GMT Message-Id: <202410111807.49BI71mf011848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5d57fad876ee - main - acpidump: Print SPCR v3 and v4 fields 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d57fad876ee6b55761a7643f5b94e3d6d54e3e0 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5d57fad876ee6b55761a7643f5b94e3d6d54e3e0 commit 5d57fad876ee6b55761a7643f5b94e3d6d54e3e0 Author: Warner Losh AuthorDate: 2024-10-11 17:51:57 +0000 Commit: Warner Losh CommitDate: 2024-10-11 18:06:33 +0000 acpidump: Print SPCR v3 and v4 fields This reapplies 593d7a1634b5 to implement printing of SPCR v3 and SPCR v4 fields after ACPI actble3.h update. ACPIca used different names and didn't do the weird nesting I did in the prior commit for better co-existance. Sponsored by: Netflix --- usr.sbin/acpi/acpidump/acpi.c | 143 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 1 deletion(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index fe68b5062351..4eb361a6f479 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -1257,6 +1257,7 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp) printf(END_COMMENT); } + static void acpi_handle_tpm2(ACPI_TABLE_HEADER *sdp) { ACPI_TABLE_TPM2 *tpm2; @@ -1268,7 +1269,145 @@ static void acpi_handle_tpm2(ACPI_TABLE_HEADER *sdp) printf ("\t\tStartMethod=%x\n", tpm2->StartMethod); printf (END_COMMENT); } - + +static int spcr_xlate_baud(uint8_t r) +{ + static int rates[] = { 9600, 19200, -1, 57600, 115200 }; + _Static_assert(nitems(rates) == 7 - 3 + 1, "rates array size incorrect"); + + if (r == 0) + return (0); + + if (r < 3 || r > 7) + return (-1); + + return (rates[r - 3]); +} + +static const char *spcr_interface_type(int ift) +{ + static const char *if_names[] = { + [0x00] = "Fully 16550-compatible", + [0x01] = "16550 subset compatible with DBGP Revision 1", + [0x02] = "MAX311xE SPI UART", + [0x03] = "Arm PL011 UART", + [0x04] = "MSM8x60 (e.g. 8960)", + [0x05] = "Nvidia 16550", + [0x06] = "TI OMAP", + [0x07] = "Reserved (Do Not Use)", + [0x08] = "APM88xxxx", + [0x09] = "MSM8974", + [0x0a] = "SAM5250", + [0x0b] = "Intel USIF", + [0x0c] = "i.MX 6", + [0x0d] = "(deprecated) Arm SBSA (2.x only) Generic UART supporting only 32-bit accesses", + [0x0e] = "Arm SBSA Generic UART", + [0x0f] = "Arm DCC", + [0x10] = "BCM2835", + [0x11] = "SDM845 with clock rate of 1.8432 MHz", + [0x12] = "16550-compatible with parameters defined in Generic Address Structure", + [0x13] = "SDM845 with clock rate of 7.372 MHz", + [0x14] = "Intel LPSS", + [0x15] = "RISC-V SBI console (any supported SBI mechanism)", + }; + + if (ift >= (int)nitems(if_names) || if_names[ift] == NULL) + return ("Reserved"); + return (if_names[ift]); +} + +static const char *spcr_interrupt_type(int ift) +{ + static char buf[100]; + +#define APPEND(b,s) \ + if ((ift & (b)) != 0) { \ + if (strlen(buf) > 0) \ + strlcat(buf, ",", sizeof(buf)); \ + strlcat(buf, s, sizeof(buf)); \ + } + + *buf = '\0'; + APPEND(0x01, "PC/AT IRQ"); + APPEND(0x02, "I/O APIC"); + APPEND(0x04, "I/O SAPIC"); + APPEND(0x08, "ARMH GIC"); + APPEND(0x10, "RISC-V PLIC/APLIC"); + +#undef APPEND + + return (buf); +} + +static const char *spcr_terminal_type(int type) +{ + static const char *term_names[] = { + [0] = "VT100", + [1] = "Extended VT100", + [2] = "VT-UTF8", + [3] = "ANSI", + }; + + if (type >= (int)nitems(term_names) || term_names[type] == NULL) + return ("Reserved"); + return (term_names[type]); +} + +static void acpi_handle_spcr(ACPI_TABLE_HEADER *sdp) +{ + ACPI_TABLE_SPCR *spcr; + + printf (BEGIN_COMMENT); + acpi_print_sdt(sdp); + + /* Rev 1 and 2 are the same size */ + spcr = (ACPI_TABLE_SPCR *) sdp; + printf ("\tInterfaceType=%d (%s)\n", spcr->InterfaceType, + spcr_interface_type(spcr->InterfaceType)); + printf ("\tSerialPort="); + acpi_print_gas(&spcr->SerialPort); + printf ("\n\tInterruptType=%#x (%s)\n", spcr->InterruptType, + spcr_interrupt_type(spcr->InterruptType)); + printf ("\tPcInterrupt=%d (%s)\n", spcr->PcInterrupt, + (spcr->InterruptType & 0x1) ? "Valid" : "Invalid"); + printf ("\tInterrupt=%d\n", spcr->Interrupt); + printf ("\tBaudRate=%d (%d)\n", spcr_xlate_baud(spcr->BaudRate), spcr->BaudRate); + printf ("\tParity=%d\n", spcr->Parity); + printf ("\tStopBits=%d\n", spcr->StopBits); + printf ("\tFlowControl=%d\n", spcr->FlowControl); + printf ("\tTerminalType=%d (%s)\n", spcr->TerminalType, + spcr_terminal_type(spcr->TerminalType)); + printf ("\tPciDeviceId=%#04x\n", spcr->PciDeviceId); + printf ("\tPciVendorId=%#04x\n", spcr->PciVendorId); + printf ("\tPciBus=%d\n", spcr->PciBus); + printf ("\tPciDevice=%d\n", spcr->PciDevice); + printf ("\tPciFunction=%d\n", spcr->PciFunction); + printf ("\tPciFlags=%d\n", spcr->PciFlags); + printf ("\tPciSegment=%d\n", spcr->PciSegment); + + /* Rev 3 added UartClkFrequency */ + if (sdp->Revision >= 3) { + printf("\tLanguage=%d\n", spcr->Language); + printf("\tUartClkFreq=%jd", + (uintmax_t)spcr->UartClkFreq); + } + + /* Rev 4 added PreciseBaudrate and NameSpace* */ + if (sdp->Revision >= 4) { + printf("\tPreciseBaudrate=%jd", + (uintmax_t)spcr->PreciseBaudrate); + if (spcr->NameSpaceStringLength > 0 && + spcr->NameSpaceStringOffset >= sizeof(*spcr) && + sdp->Length >= spcr->NameSpaceStringOffset + + spcr->NameSpaceStringLength) { + printf ("\tNameSpaceString='%s'\n", + (char *)sdp + spcr->NameSpaceStringOffset); + } + } + + printf (END_COMMENT); +} + static const char * devscope_type2str(int type) { @@ -2468,6 +2607,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) acpi_handle_lpit(sdp); else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4)) acpi_handle_tpm2(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_SPCR, 4)) + acpi_handle_spcr(sdp); else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp);