Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/usr.sbin/acpitools/acpidump Pull up the following, reques...
details: https://anonhg.NetBSD.org/src/rev/6429c4d69f5f
branches: netbsd-8
changeset: 852155:6429c4d69f5f
user: martin <martin%NetBSD.org@localhost>
date: Tue Dec 04 11:58:10 2018 +0000
description:
Pull up the following, requested by msaitoh in ticket #1121:
usr.sbin/acpitool/acpidump/acpi.c 1.30-1.37, 1.39 via patch
usr.sbin/acpitool/acpidump/acpidump.8 1.11-1.13 via patch
- Add ACPI LPIT (Low Power Idle Table) from FreeBSD r336185.
- Decode DMAR's ANDD (ACPI Name Space).
- Add X2APIC_MODE flag of DMAR.
- Remove extra newline in SPMI table.
- FACS is optional if the HW_REDUCED_ACPI flag is set in the FADT.
- Print SPCR's Interface Type and ARMH GIC Interrupt Type.
- Decode Generic Timer Description Table(GTDT).
- Don't print PM_TMR_BLK if the value is 0.
- Don't print X_PM_TMR_BLK if the address value is 0.
- Decode CSRT (Core System Resources Table).
diffstat:
usr.sbin/acpitools/acpidump/acpi.c | 574 +++++++++++++++++++++++++++++---
usr.sbin/acpitools/acpidump/acpidump.8 | 7 +-
2 files changed, 522 insertions(+), 59 deletions(-)
diffs (truncated from 838 to 300 lines):
diff -r 899f64f2c500 -r 6429c4d69f5f usr.sbin/acpitools/acpidump/acpi.c
--- a/usr.sbin/acpitools/acpidump/acpi.c Tue Dec 04 11:52:57 2018 +0000
+++ b/usr.sbin/acpitools/acpidump/acpi.c Tue Dec 04 11:58:10 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.15.8.1 2017/11/22 15:54:09 martin Exp $ */
+/* $NetBSD: acpi.c,v 1.15.8.2 2018/12/04 11:58:10 martin Exp $ */
/*-
* Copyright (c) 1998 Doug Rabson
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: acpi.c,v 1.15.8.1 2017/11/22 15:54:09 martin Exp $");
+__RCSID("$NetBSD: acpi.c,v 1.15.8.2 2018/12/04 11:58:10 martin Exp $");
#include <sys/param.h>
#include <sys/endian.h>
@@ -40,6 +40,7 @@
#include <err.h>
#include <fcntl.h>
#include <paths.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -53,7 +54,11 @@
#define BEGIN_COMMENT "/*\n"
#define END_COMMENT " */\n"
+/* Commonly used helper functions */
static void acpi_print_string(char *s, size_t length);
+static void acpi_print_tabs(unsigned int n);
+static void acpi_dump_bytes(uint8_t *p, uint32_t len, unsigned int ntabs);
+static void acpi_dump_table(ACPI_TABLE_HEADER *sdp);
static void acpi_print_gas(ACPI_GENERIC_ADDRESS *gas);
static void acpi_print_pci(uint16_t vendorid, uint16_t deviceid,
uint8_t seg, uint8_t bus, uint8_t device, uint8_t func);
@@ -68,6 +73,8 @@
void (*print_ins)(ACPI_WHEA_HEADER *),
void (*print_flags)(ACPI_WHEA_HEADER *));
static uint64_t acpi_select_address(uint32_t, uint64_t);
+
+/* Handlers for each table */
static void acpi_handle_fadt(ACPI_TABLE_HEADER *fadt);
static void acpi_print_cpu(u_char cpu_id);
static void acpi_print_cpu_uid(uint32_t uid, char *uid_string);
@@ -81,11 +88,14 @@
static void acpi_handle_bert(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_boot(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_cpep(ACPI_TABLE_HEADER *sdp);
+static void acpi_handle_csrt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_dbgp(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_dbg2(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_einj(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_erst(ACPI_TABLE_HEADER *sdp);
+static void acpi_handle_gtdt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_hest(ACPI_TABLE_HEADER *sdp);
+static void acpi_handle_lpit(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_madt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_msct(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp);
@@ -110,7 +120,6 @@
static void acpi_handle_wddt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_wdrt(ACPI_TABLE_HEADER *sdp);
static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp);
-static void acpi_dump_bytes(ACPI_TABLE_HEADER *sdp);
static void acpi_print_fadt(ACPI_TABLE_HEADER *sdp);
static void acpi_print_facs(ACPI_TABLE_FACS *facs);
static void acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp);
@@ -210,7 +219,7 @@
static void
acpi_print_gas(ACPI_GENERIC_ADDRESS *gas)
{
- switch(gas->SpaceId) {
+ switch (gas->SpaceId) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
if (gas->BitWidth <= 32)
printf("0x%08x:%u[%u] (Memory)",
@@ -813,11 +822,16 @@
fadt = (ACPI_TABLE_FADT *)sdp;
acpi_print_fadt(sdp);
- facs = (ACPI_TABLE_FACS *)acpi_map_sdt(
- acpi_select_address(fadt->Facs, fadt->XFacs));
- if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)
- errx(EXIT_FAILURE, "FACS is corrupt");
- acpi_print_facs(facs);
+ if (acpi_select_address(fadt->Facs, fadt->XFacs) == 0) {
+ if ((fadt->Flags & ACPI_FADT_HW_REDUCED) == 0)
+ errx(EXIT_FAILURE, "Missing FACS and HW_REDUCED_ACPI flag not set in FADT");
+ } else {
+ facs = (ACPI_TABLE_FACS *)acpi_map_sdt(
+ acpi_select_address(fadt->Facs, fadt->XFacs));
+ if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)
+ errx(EXIT_FAILURE, "FACS is corrupt");
+ acpi_print_facs(facs);
+ }
dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(
acpi_select_address(fadt->Dsdt, fadt->XDsdt));
@@ -1236,6 +1250,130 @@
}
static void
+acpi_print_csrt_resource_group(ACPI_CSRT_GROUP *grp)
+{
+ ACPI_CSRT_DESCRIPTOR *desc;
+
+ printf("\tLength=%u\n", grp->Length);
+ printf("\tVendorId=");
+ acpi_print_string((char *)&grp->VendorId, 4);
+ printf("\n");
+ if (grp->SubvendorId != 0) {
+ printf("\tSubvendorId=");
+ acpi_print_string((char *)&grp->SubvendorId, 4);
+ printf("\n");
+ }
+ printf("\tDeviceId=0x%08x\n", grp->DeviceId);
+ if (grp->SubdeviceId != 0)
+ printf("\tSubdeviceId=0x%08x\n", grp->SubdeviceId);
+ printf("\tRevision=%hu\n", grp->Revision);
+ printf("\tSharedInfoLength=%u\n", grp->SharedInfoLength);
+
+ /* Next is Shared Info */
+ if (grp->SharedInfoLength != 0) {
+ printf("\tShared Info ");
+ acpi_dump_bytes((uint8_t *)(grp + 1),
+ grp->SharedInfoLength, 1);
+ }
+
+ /* And then, Resource Descriptors */
+ desc = (ACPI_CSRT_DESCRIPTOR *)
+ ((vaddr_t)(grp + 1) + grp->SharedInfoLength);
+ while (desc < (ACPI_CSRT_DESCRIPTOR *)((vaddr_t)grp + grp->Length)) {
+ bool unknownsubytpe = false;
+ printf("\n\tLength=%u\n", desc->Length);
+ printf("\tResource Type=");
+ switch (desc->Type) {
+ case ACPI_CSRT_TYPE_INTERRUPT:
+ printf("Interrupt");
+ switch (desc->Subtype) {
+ case ACPI_CSRT_XRUPT_LINE:
+ printf("(Interrupt line)\n");
+ break;
+ case ACPI_CSRT_XRUPT_CONTROLLER:
+ printf("(Interrupt controller)\n");
+ break;
+ default:
+ unknownsubytpe = true;
+ break;
+ }
+ break;
+ case ACPI_CSRT_TYPE_TIMER:
+ printf("Timer");
+ switch (desc->Subtype) {
+ case ACPI_CSRT_TIMER:
+ printf("\n");
+ break;
+ default:
+ unknownsubytpe = true;
+ break;
+ }
+ break;
+ case ACPI_CSRT_TYPE_DMA:
+ printf("DMA");
+ switch (desc->Subtype) {
+ case ACPI_CSRT_DMA_CHANNEL:
+ printf("(DMA channel)\n");
+ break;
+ case ACPI_CSRT_DMA_CONTROLLER:
+ printf("(DMA controller)\n");
+ break;
+ default:
+ unknownsubytpe = true;
+ break;
+ }
+ break;
+ case 0x0004: /* XXX Platform Security */
+ printf("Platform Security");
+ switch (desc->Subtype) {
+ case 0x0001:
+ printf("\n");
+ /* Platform Security */
+ break;
+ default:
+ unknownsubytpe = true;
+ break;
+ }
+ break;
+ default:
+ printf("Unknown (%hx)\n", desc->Type);
+ break;
+ }
+ if (unknownsubytpe)
+ printf("(unknown subtype(%hx))\n", desc->Subtype);
+
+ printf("\tUID=0x%08x\n", desc->Uid);
+ printf("\tVendor defined info ");
+ acpi_dump_bytes((uint8_t *)(desc + 1),
+ desc->Length - sizeof(ACPI_CSRT_DESCRIPTOR), 1);
+
+ /* Next */
+ desc = (ACPI_CSRT_DESCRIPTOR *)((vaddr_t)desc + desc->Length);
+ }
+}
+
+static void
+acpi_handle_csrt(ACPI_TABLE_HEADER *sdp)
+{
+ ACPI_CSRT_GROUP *grp;
+ uint totallen = sdp->Length;
+
+ printf(BEGIN_COMMENT);
+ acpi_print_sdt(sdp);
+ grp = (ACPI_CSRT_GROUP *)(sdp + 1);
+
+ while (grp < (ACPI_CSRT_GROUP *)((vaddr_t)sdp + totallen)) {
+ printf("\n");
+ acpi_print_csrt_resource_group(grp);
+
+ /* Next */
+ grp = (ACPI_CSRT_GROUP *)((vaddr_t)grp + grp->Length);
+ }
+
+ printf(END_COMMENT);
+}
+
+static void
acpi_handle_dbgp(ACPI_TABLE_HEADER *sdp)
{
ACPI_TABLE_DBGP *dbgp;
@@ -1259,6 +1397,39 @@
printf(END_COMMENT);
}
+/* This function is used by DBG2 and SPCR. */
+static void
+acpi_print_dbg2_serial_subtype(uint16_t subtype)
+{
+
+ switch (subtype) {
+ case ACPI_DBG2_16550_COMPATIBLE:
+ printf("Fully 16550 compatible\n");
+ break;
+ case ACPI_DBG2_16550_SUBSET:
+ printf("16550 subset with DBGP Rev. 1\n");
+ break;
+ case ACPI_DBG2_ARM_PL011:
+ printf("ARM PL011\n");
+ break;
+ case ACPI_DBG2_ARM_SBSA_32BIT:
+ printf("ARM SBSA 32bit only\n");
+ break;
+ case ACPI_DBG2_ARM_SBSA_GENERIC:
+ printf("ARM SBSA Generic\n");
+ break;
+ case ACPI_DBG2_ARM_DCC:
+ printf("ARM DCC\n");
+ break;
+ case ACPI_DBG2_BCM2835:
+ printf("BCM2835\n");
+ break;
+ default:
+ printf("reserved (%04hx)\n", subtype);
+ break;
+ }
+}
+
static void
acpi_print_dbg2_device(ACPI_DBG2_DEVICE *dev)
{
@@ -1282,32 +1453,7 @@
switch (dev->PortType) {
case ACPI_DBG2_SERIAL_PORT:
printf("Serial\n" "\t\tPortSubtype=");
- switch (dev->PortSubtype) {
- case ACPI_DBG2_16550_COMPATIBLE:
- printf("Fully 16550 compatible\n");
- break;
- case ACPI_DBG2_16550_SUBSET:
- printf("16550 subset with DBGP Rev. 1\n");
- break;
- case ACPI_DBG2_ARM_PL011:
- printf("ARM PL011\n");
- break;
- case ACPI_DBG2_ARM_SBSA_32BIT:
- printf("ARM SBSA 32bit only\n");
- break;
- case ACPI_DBG2_ARM_SBSA_GENERIC:
- printf("ARM SBSA Generic\n");
- break;
- case ACPI_DBG2_ARM_DCC:
- printf("ARM DCC\n");
- break;
- case ACPI_DBG2_BCM2835:
- printf("BCM2835\n");
- break;
- default:
- printf("reserved (%04hx)\n", dev->PortSubtype);
Home |
Main Index |
Thread Index |
Old Index