2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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
31 #include <sys/param.h>
41 int dflag; /* Disassemble AML using iasl(8) */
42 int tflag; /* Dump contents of SDT tables */
43 int vflag; /* Use verbose messages */
46 usage(const char *progname)
49 fprintf(stderr, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] "
50 "[-o dsdt_output]\n", progname);
51 fprintf(stderr, "To send ASL:\n\t%s -dt | gzip -c9 > foo.asl.gz\n",
57 main(int argc, char *argv[])
59 ACPI_TABLE_HEADER *rsdt, *sdt;
62 char *dsdt_input_file, *dsdt_output_file;
64 dsdt_input_file = dsdt_output_file = NULL;
70 while ((c = getopt(argc, argv, "dhtvf:o:")) != -1) {
82 dsdt_input_file = optarg;
85 dsdt_output_file = optarg;
96 /* Get input either from file or /dev/mem */
97 if (dsdt_input_file != NULL) {
98 if (dflag == 0 && tflag == 0) {
99 warnx("Need to specify -d or -t with DSDT input file");
101 } else if (tflag != 0) {
102 warnx("Can't use -t with DSDT input file");
106 warnx("loading DSDT file: %s", dsdt_input_file);
107 rsdt = dsdt_load_file(dsdt_input_file);
110 warnx("loading RSD PTR from /dev/mem");
111 rsdt = sdt_load_devmem();
114 /* Display misc. SDT tables (only available when using /dev/mem) */
117 warnx("printing various SDT tables");
121 /* Translate RSDT to DSDT pointer */
122 if (dsdt_input_file == NULL) {
123 sdt = sdt_from_rsdt(rsdt, ACPI_SIG_FADT, NULL);
124 sdt = dsdt_from_fadt((ACPI_TABLE_FADT *)sdt);
130 /* Dump the DSDT and SSDTs to a file */
131 if (dsdt_output_file != NULL) {
133 warnx("saving DSDT file: %s", dsdt_output_file);
134 dsdt_save_file(dsdt_output_file, rsdt, sdt);
137 /* Disassemble the DSDT into ASL */
140 warnx("disassembling DSDT, iasl messages follow");
141 aml_disassemble(rsdt, sdt);
143 warnx("iasl processing complete");