Module Name: src Committed By: jmcneill Date: Thu Feb 17 02:55:16 UTC 2011
Modified Files: src/usr.sbin/acpitools/acpidump: acpi.c acpidump.c acpidump.h Log Message: dump bytes for tables that acpidump doesn't decode, and print them as characters instead of hex if '-c' flag is provided To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/acpitools/acpidump/acpi.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/acpitools/acpidump/acpidump.c \ src/usr.sbin/acpitools/acpidump/acpidump.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/acpitools/acpidump/acpi.c diff -u src/usr.sbin/acpitools/acpidump/acpi.c:1.6 src/usr.sbin/acpitools/acpidump/acpi.c:1.7 --- src/usr.sbin/acpitools/acpidump/acpi.c:1.6 Sun Dec 19 16:25:16 2010 +++ src/usr.sbin/acpitools/acpidump/acpi.c Thu Feb 17 02:55:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.6 2010/12/19 16:25:16 jruoho Exp $ */ +/* $NetBSD: acpi.c,v 1.7 2011/02/17 02:55:16 jmcneill Exp $ */ /*- * Copyright (c) 1998 Doug Rabson @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: acpi.c,v 1.6 2010/12/19 16:25:16 jruoho Exp $"); +__RCSID("$NetBSD: acpi.c,v 1.7 2011/02/17 02:55:16 jmcneill Exp $"); #include <sys/param.h> #include <sys/endian.h> @@ -103,6 +103,7 @@ static void acpi_handle_wdat(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); @@ -1896,6 +1897,32 @@ } static void +acpi_dump_bytes(ACPI_TABLE_HEADER *sdp) +{ + unsigned int i; + uint8_t *p; + + p = (uint8_t *)sdp + sizeof(*sdp); + printf("\n\tData={"); + for (i = 0; i < sdp->Length; i++) { + if (cflag) { + if (i % 64 == 0) + printf("\n\t "); + else if (i % 16 == 0) + printf(" "); + printf("%c", (p[i] >= ' ' && p[i] <= '~') ? p[i] : '.'); + } else { + if (i % 16 == 0) + printf("\n\t\t"); + else if (i % 8 == 0) + printf(" "); + printf(" %02x", p[i]); + } + } + printf("\n\t}\n"); +} + +static void acpi_print_rsdt(ACPI_TABLE_HEADER *rsdp) { ACPI_TABLE_RSDT *rsdt; @@ -2241,6 +2268,7 @@ else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp); + acpi_dump_bytes(sdp); printf(END_COMMENT); } } Index: src/usr.sbin/acpitools/acpidump/acpidump.c diff -u src/usr.sbin/acpitools/acpidump/acpidump.c:1.2 src/usr.sbin/acpitools/acpidump/acpidump.c:1.3 --- src/usr.sbin/acpitools/acpidump/acpidump.c:1.2 Tue Dec 22 08:44:03 2009 +++ src/usr.sbin/acpitools/acpidump/acpidump.c Thu Feb 17 02:55:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpidump.c,v 1.2 2009/12/22 08:44:03 cegger Exp $ */ +/* $NetBSD: acpidump.c,v 1.3 2011/02/17 02:55:16 jmcneill Exp $ */ /*- * Copyright (c) 2000 Mitsuru IWASAKI <iwas...@freebsd.org> @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: acpidump.c,v 1.2 2009/12/22 08:44:03 cegger Exp $"); +__RCSID("$NetBSD: acpidump.c,v 1.3 2011/02/17 02:55:16 jmcneill Exp $"); #include <sys/param.h> @@ -45,13 +45,14 @@ int dflag; /* Disassemble AML using iasl(8) */ int tflag; /* Dump contents of SDT tables */ int vflag; /* Use verbose messages */ +int cflag; /* Dump unknown table data as characters */ static void usage(void) { const char *progname = getprogname(); - fprintf(stderr, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] " + fprintf(stderr, "usage: %s [-c] [-d] [-t] [-h] [-v] [-f dsdt_input] " "[-o dsdt_output]\n", progname); fprintf(stderr, "To send ASL:\n\t%s -dt | gzip -c9 > foo.asl.gz\n", progname); @@ -70,8 +71,11 @@ if (argc < 2) usage(); - while ((c = getopt(argc, argv, "dhtvf:o:")) != -1) { + while ((c = getopt(argc, argv, "cdhtvf:o:")) != -1) { switch (c) { + case 'c': + cflag = 1; + break; case 'd': dflag = 1; break; Index: src/usr.sbin/acpitools/acpidump/acpidump.h diff -u src/usr.sbin/acpitools/acpidump/acpidump.h:1.2 src/usr.sbin/acpitools/acpidump/acpidump.h:1.3 --- src/usr.sbin/acpitools/acpidump/acpidump.h:1.2 Tue Dec 22 08:44:03 2009 +++ src/usr.sbin/acpitools/acpidump/acpidump.h Thu Feb 17 02:55:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpidump.h,v 1.2 2009/12/22 08:44:03 cegger Exp $ */ +/* $NetBSD: acpidump.h,v 1.3 2011/02/17 02:55:16 jmcneill Exp $ */ /*- * Copyright (c) 1999 Doug Rabson @@ -81,6 +81,7 @@ int acpi_checksum(void *, size_t); /* Command line flags */ +extern int cflag; extern int dflag; extern int tflag; extern int vflag;