4 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $FreeBSD: src/usr.sbin/acpi/acpidump/acpidump.c,v 1.13 2009/08/25 20:35:57 jhb Exp $
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: acpi.c,v 1.4 2008/02/13 18:59:18 drochner Exp $");
35 #include <sys/param.h>
45 int dflag
; /* Disassemble AML using iasl(8) */
46 int tflag
; /* Dump contents of SDT tables */
47 int vflag
; /* Use verbose messages */
52 const char *progname
= getprogname();
54 fprintf(stderr
, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] "
55 "[-o dsdt_output]\n", progname
);
56 fprintf(stderr
, "To send ASL:\n\t%s -dt | gzip -c9 > foo.asl.gz\n",
62 main(int argc
, char *argv
[])
64 ACPI_TABLE_HEADER
*rsdt
, *sdt
;
66 char *dsdt_input_file
, *dsdt_output_file
;
68 dsdt_input_file
= dsdt_output_file
= NULL
;
73 while ((c
= getopt(argc
, argv
, "dhtvf:o:")) != -1) {
85 dsdt_input_file
= optarg
;
88 dsdt_output_file
= optarg
;
99 /* Get input either from file or /dev/mem */
100 if (dsdt_input_file
!= NULL
) {
101 if (dflag
== 0 && tflag
== 0) {
102 warnx("Need to specify -d or -t with DSDT input file");
104 } else if (tflag
!= 0) {
105 warnx("Can't use -t with DSDT input file");
109 warnx("loading DSDT file: %s", dsdt_input_file
);
110 rsdt
= dsdt_load_file(dsdt_input_file
);
113 warnx("loading RSD PTR from /dev/mem");
114 rsdt
= sdt_load_devmem();
117 /* Display misc. SDT tables (only available when using /dev/mem) */
120 warnx("printing various SDT tables");
124 /* Translate RSDT to DSDT pointer */
125 if (dsdt_input_file
== NULL
) {
126 sdt
= sdt_from_rsdt(rsdt
, ACPI_SIG_FADT
, NULL
);
127 sdt
= dsdt_from_fadt((ACPI_TABLE_FADT
*)sdt
);
133 /* Dump the DSDT and SSDTs to a file */
134 if (dsdt_output_file
!= NULL
) {
136 warnx("saving DSDT file: %s", dsdt_output_file
);
137 dsdt_save_file(dsdt_output_file
, rsdt
, sdt
);
140 /* Disassemble the DSDT into ASL */
143 warnx("disassembling DSDT, iasl messages follow");
144 aml_disassemble(rsdt
, sdt
);
146 warnx("iasl processing complete");