From 82730a9cd4baaa8f2a37f2331c6e1e1cb896e760 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 3 Jan 2014 01:41:09 +0100 Subject: [PATCH] acpi: Fix building userland. As of this commit we're losing acpidb(8) which gets replaced by acpiexec(8). Additionally, we're getting: acpibin(8) acpiexec(8) acpihelp(8) acpinames(8) acpisrc(8) acpixtract(8) Manual pages for the new utilities have yet to be written. Also acpidump.8 and iasl.8 need to be updated, I guess. --- Makefile_upgrade.inc | 3 + etc/mtree/BSD.usr.dist | 2 + share/examples/Makefile | 4 +- share/examples/acpica/Makefile | 11 + sys/conf/acpi.mk | 19 +- usr.sbin/acpi/Makefile | 16 +- usr.sbin/acpi/Makefile.inc | 11 +- usr.sbin/acpi/acpibin/Makefile | 37 + usr.sbin/acpi/acpidb/Makefile | 54 -- usr.sbin/acpi/acpidb/acpidb.8 | 167 ---- usr.sbin/acpi/acpidb/acpidb.c | 495 ----------- usr.sbin/acpi/acpidb/osunixxf.c.patch | 27 - usr.sbin/acpi/acpidump/Makefile | 35 +- usr.sbin/acpi/acpidump/acpi.c | 1005 ----------------------- usr.sbin/acpi/acpidump/acpi_user.c | 213 ----- usr.sbin/acpi/acpidump/acpidump.c | 143 ---- usr.sbin/acpi/acpidump/acpidump.h | 418 ---------- usr.sbin/acpi/acpidump/osdragonflytbl.c | 904 ++++++++++++++++++++ usr.sbin/acpi/acpiexec/Makefile | 207 +++++ usr.sbin/acpi/acpihelp/Makefile | 30 + usr.sbin/acpi/acpinames/Makefile | 95 +++ usr.sbin/acpi/acpisrc/Makefile | 29 + usr.sbin/acpi/acpixtract/Makefile | 23 + usr.sbin/acpi/iasl/Makefile | 244 +++++- 24 files changed, 1604 insertions(+), 2588 deletions(-) create mode 100644 share/examples/acpica/Makefile create mode 100644 usr.sbin/acpi/acpibin/Makefile delete mode 100644 usr.sbin/acpi/acpidb/Makefile delete mode 100644 usr.sbin/acpi/acpidb/acpidb.8 delete mode 100644 usr.sbin/acpi/acpidb/acpidb.c delete mode 100644 usr.sbin/acpi/acpidb/osunixxf.c.patch delete mode 100644 usr.sbin/acpi/acpidump/acpi.c delete mode 100644 usr.sbin/acpi/acpidump/acpi_user.c delete mode 100644 usr.sbin/acpi/acpidump/acpidump.c delete mode 100644 usr.sbin/acpi/acpidump/acpidump.h create mode 100644 usr.sbin/acpi/acpidump/osdragonflytbl.c create mode 100644 usr.sbin/acpi/acpiexec/Makefile create mode 100644 usr.sbin/acpi/acpihelp/Makefile create mode 100644 usr.sbin/acpi/acpinames/Makefile create mode 100644 usr.sbin/acpi/acpisrc/Makefile create mode 100644 usr.sbin/acpi/acpixtract/Makefile diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index df3970aefb..75f1fe91a9 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -2404,6 +2404,9 @@ TO_REMOVE+=/usr/share/man/cat5/utf2.5.gz TO_REMOVE+=/usr/share/man/man5/utf2.5.gz TO_REMOVE+=/boot/kernel/if_ixgbe.ko TO_REMOVE+=/usr/include/bus/smbus/smb.h +TO_REMOVE+=/usr/sbin/acpidb +TO_REMOVE+=/usr/share/man/cat8/acpidb.8.gz +TO_REMOVE+=/usr/share/man/man8/acpidb.8.gz .if ${MACHINE_ARCH} == "x86_64" TO_REMOVE+=/usr/sbin/stlstats diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index f32166ac20..5e74994e5a 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -133,6 +133,8 @@ examples IPv6 .. + acpica + .. atm .. cvs diff --git a/share/examples/Makefile b/share/examples/Makefile index e287fe5b47..2f876e6940 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -3,7 +3,7 @@ # Doing a make install builds /usr/share/examples DIRS!= for i in *; do \ - if test -d $$i -a $$i != smbfs; then \ + if test -d $$i -a $$i != acpica -a $$i != smbfs; then \ echo $$i; \ fi; \ done @@ -40,7 +40,7 @@ etc-examples: .endif .if ${SHARED} != "symlinks" -SUBDIR= smbfs +SUBDIR= acpica smbfs .endif .include diff --git a/share/examples/acpica/Makefile b/share/examples/acpica/Makefile new file mode 100644 index 0000000000..69a33abd9f --- /dev/null +++ b/share/examples/acpica/Makefile @@ -0,0 +1,11 @@ +.PATH: ../../../sys/contrib/dev/acpica/source/tools/examples + +NOOBJ= noobj +BINDIR= /usr/share/examples/acpica +FILES= \ + examples.c \ + examples.h \ + exstubs.c \ + extables.c + +.include diff --git a/sys/conf/acpi.mk b/sys/conf/acpi.mk index cbbf24be07..4d971d74c4 100644 --- a/sys/conf/acpi.mk +++ b/sys/conf/acpi.mk @@ -1,4 +1,4 @@ -ACPICA_DIR?= contrib/dev/acpica-unix +ACPICA_DIR?= contrib/dev/acpica/source OSACPI_MI_DIR?= dev/acpica OSACPI_MD_DIR?= platform/${MACHINE_PLATFORM}/acpica @@ -20,10 +20,19 @@ ACPICA_KERN_PATHS = \ ${SYSDIR}/${ACPICA_DIR}/disassembler ACPICA_UTIL_PATHS = \ - ${ACPICA_KERN_PATHS} \ - ${SYSDIR}/${ACPICA_DIR} \ - ${SYSDIR}/${ACPICA_DIR}/compiler \ - ${SYSDIR}/${ACPICA_DIR}/common + ${SYSDIR}/${ACPICA_DIR}/common \ + ${SYSDIR}/${ACPICA_DIR}/components/debugger \ + ${SYSDIR}/${ACPICA_DIR}/components/disassembler \ + ${SYSDIR}/${ACPICA_DIR}/components/dispatcher \ + ${SYSDIR}/${ACPICA_DIR}/components/events \ + ${SYSDIR}/${ACPICA_DIR}/components/executer \ + ${SYSDIR}/${ACPICA_DIR}/components/hardware \ + ${SYSDIR}/${ACPICA_DIR}/components/namespace \ + ${SYSDIR}/${ACPICA_DIR}/components/parser \ + ${SYSDIR}/${ACPICA_DIR}/components/resources \ + ${SYSDIR}/${ACPICA_DIR}/components/tables \ + ${SYSDIR}/${ACPICA_DIR}/components/utilities \ + ${SYSDIR}/${ACPICA_DIR}/os_specific/service_layers ${.OBJDIR}/acpi.h: ${SYSDIR}/${ACPICA_DIR}/include/acpi.h cp ${.ALLSRC} ${.TARGET} diff --git a/usr.sbin/acpi/Makefile b/usr.sbin/acpi/Makefile index 5006f51469..93d331a6bc 100644 --- a/usr.sbin/acpi/Makefile +++ b/usr.sbin/acpi/Makefile @@ -1,8 +1,14 @@ -# Makefile for acpi tools -# $Id: Makefile,v 1.1 2000/07/14 18:16:22 iwasaki Exp $ -# $FreeBSD: src/usr.sbin/acpi/Makefile,v 1.3 2003/08/08 03:20:59 njl Exp $ -# $DragonFly: src/usr.sbin/acpi/Makefile,v 1.1 2004/07/05 00:22:40 dillon Exp $ +# XXX missing: examples -SUBDIR= acpiconf acpidb acpidump iasl +SUBDIR= \ + acpibin \ + acpiconf \ + acpidump \ + acpiexec \ + acpihelp \ + acpinames \ + acpisrc \ + acpixtract \ + iasl .include diff --git a/usr.sbin/acpi/Makefile.inc b/usr.sbin/acpi/Makefile.inc index bbc8fc6bdf..13cb79d02b 100644 --- a/usr.sbin/acpi/Makefile.inc +++ b/usr.sbin/acpi/Makefile.inc @@ -7,15 +7,12 @@ SYSDIR?= ${.CURDIR}/../../../sys .PATH: ${.OBJDIR} \ ${ACPICA_UTIL_PATHS} -CFLAGS+= -I${.OBJDIR} \ +CFLAGS+= \ + -I${.OBJDIR} \ -I${SYSDIR}/${OSACPI_MI_DIR} \ -I${SYSDIR}/${ACPICA_DIR}/include \ - -I${SYSDIR}/${ACPICA_DIR}/compiler - -SRCS+= ${.OBJDIR}/acpi.h ${.OBJDIR}/platform/acenv.h - -CLEANFILES+= ${.OBJDIR}/acpi.h -CLEANDIRS+= ${.OBJDIR}/platform + -I${SYSDIR}/${ACPICA_DIR}/compiler \ + -I${SYSDIR} WARNS?= 2 diff --git a/usr.sbin/acpi/acpibin/Makefile b/usr.sbin/acpi/acpibin/Makefile new file mode 100644 index 0000000000..b068b7efd6 --- /dev/null +++ b/usr.sbin/acpi/acpibin/Makefile @@ -0,0 +1,37 @@ +# +# acpibin - Binary ACPI table utility +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpibin + +.PATH: ${UTILDIR} + +PROG= acpibin +NOMAN= + +SRCS= \ + abcompare.c \ + abmain.c + +SRCS+= \ + utalloc.c \ + utbuffer.c \ + utcache.c \ + utdecode.c \ + utexcep.c \ + utglobal.c \ + utlock.c \ + utmath.c \ + utmisc.c \ + utmutex.c \ + utstate.c \ + utstring.c \ + utxferror.c \ + osunixxf.c \ + getopt.c + +CFLAGS+= \ + -DACPI_BIN_APP \ + -I${UTILDIR} + +.include diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile deleted file mode 100644 index c033c868cb..0000000000 --- a/usr.sbin/acpi/acpidb/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# $FreeBSD: src/usr.sbin/acpi/acpidb/Makefile,v 1.5 2004/05/25 02:56:55 njl Exp $ -# $DragonFly: src/usr.sbin/acpi/acpidb/Makefile,v 1.4 2007/01/17 17:31:19 y0netan1 Exp $ - -PROG= acpidb -SRCS+= acpidb.c -SRCS+= osunixxf.c -SRCS+= aehandlers.c aetables.c dbcmds.c dbdisply.c dbexec.c dbfileio.c \ - dbhistry.c dbinput.c dbstats.c dbutils.c dbmethod.c dbnames.c \ - dbxface.c dmbuffer.c dmnames.c dmobject.c \ - dmopcode.c dmresrc.c dmresrcl.c dmresrcs.c \ - dmutils.c dmwalk.c dsfield.c dsinit.c dscontrol.c \ - dsmethod.c dsmthdat.c dsobject.c dsopcode.c dsargs.c \ - dsutils.c dswexec.c dswload.c dswload2.c dswscope.c dswstate.c \ - evevent.c evglock.c evgpe.c evgpeutil.c evgpeinit.c evgpeblk.c evmisc.c \ - evregion.c evrgnini.c evsci.c evxface.c evxfgpe.c \ - evxfevnt.c evxfregn.c exconfig.c exconvrt.c \ - excreate.c exdump.c exdebug.c exfield.c exfldio.c \ - exmisc.c exmutex.c exnames.c exoparg1.c \ - exoparg2.c exoparg3.c exoparg6.c exprep.c \ - exregion.c exresnte.c exresolv.c exresop.c \ - exstore.c exstoren.c exstorob.c exsystem.c exutils.c \ - hwacpi.c hwgpe.c hwregs.c hwsleep.c hwvalid.c hwxface.c hwpci.c \ - nsaccess.c nsalloc.c nsdump.c nseval.c \ - nsinit.c nsload.c nsnames.c nsobject.c \ - nsparse.c nspredef.c nssearch.c nsutils.c nswalk.c \ - nsxfeval.c nsxfname.c nsxfobj.c nsrepair.c nsrepair2.c\ - psargs.c psloop.c psopcode.c psparse.c psscope.c \ - pstree.c psutils.c pswalk.c psxface.c \ - rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c \ - rsio.c rsirq.c rslist.c rsmemory.c \ - rsmisc.c rsutils.c rsxface.c \ - tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c tbxfroot.c \ - utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \ - uteval.c utglobal.c utinit.c utlock.c utmath.c \ - utmisc.c utmutex.c utobject.c utresrc.c utstate.c utxface.c utxferror.c \ - utdecode.c utids.c utosi.c - -SRCS+= aeexec.c - -.include -MAN= acpidb.8 -.PATH: ${SYSDIR}/${ACPICA_DIR}/tools/acpiexec - -CFLAGS+= -DACPI_APPLICATION -DACPI_DEBUG_OUTPUT -DACPI_DEBUGGER \ - -DACPI_DISASSEMBLER -DACPI_USE_ALTERNATE_TIMEOUT -D__cdecl= - -LDADD= -lpthread -DPADD= ${LIBPTHREAD} - -CONTRIBDIR= ${SYSDIR}/${ACPICA_DIR} -SRCS+= osunixxf.c.patch - -.include -OBJS:= ${OBJS:N*/*} diff --git a/usr.sbin/acpi/acpidb/acpidb.8 b/usr.sbin/acpi/acpidb/acpidb.8 deleted file mode 100644 index 6270bde28f..0000000000 --- a/usr.sbin/acpi/acpidb/acpidb.8 +++ /dev/null @@ -1,167 +0,0 @@ -.\"- -.\" Copyright (c) 2003 Nate Lawson -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer -.\" in this position and unchanged. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/usr.sbin/acpi/acpidb/acpidb.8,v 1.2 2004/06/06 17:49:57 ru Exp $ -.\" -.Dd August 7, 2003 -.Dt ACPIDB 8 -.Os -.Sh NAME -.Nm acpidb -.Nd ACPI DSDT debugger -.Sh SYNOPSIS -.Nm -.Ar input-file -.Sh DESCRIPTION -The -.Nm -utility is a debugger for the ACPI DSDT. -It can parse and execute various -AML methods and display the result. -.Sh COMMANDS -.Ss General-Purpose Commands -.Bl -tag -width indent -.It Ic Allocations -Display list of current memory allocations -.It Ic Dump Ar Address | Namepath Op Cm Byte | Word | Dword | Qword -Display ACPI objects or memory -.It Ic EnableAcpi -Enable ACPI (hardware) mode -.It Ic Help -Show various help screens -.It Ic History -Display command history buffer -.It Ic Level Ar DebugLevel Op Cm console -Get/Set debug level for file or console -.It Ic Locks -Current status of internal mutexes -.It Ic Quit No or Ic Exit -Exit the debugger -.It Ic Stats Op Cm Allocations | Memory | Misc | Objects | Tables -Display namespace and memory statistics -.It Ic Tables -Display info about loaded ACPI tables -.It Ic Unload Ar TableSig Op Ar Instance -Unload an ACPI table -.It Ic !\& Ar CommandNumber -Execute command from history buffer -.It Ic !! -Execute last command again -.El -.Ss Namespace Access Commands -.Bl -tag -width indent -.It Ic Event Cm F | G Ar Value -Generate AcpiEvent (Fixed/GPE) -.It Ic Find Ar Name -Find ACPI name(s) with wildcards -.Ql ( ?\& -is wildcard) -.It Ic Method -Display list of loaded control methods -.It Ic Namespace Oo Ar Addr | Path Oc Op Ar Depth -Display loaded namespace tree/subtree -.It Ic Notify Ar NamePath Value -Send a notification -.It Ic Objects Ar ObjectType -Display all objects of the given type -.It Ic Owner Ar OwnerId Op Ar Depth -Display loaded namespace by object owner -.It Ic Prefix Op Ar NamePath -Set or Get current execution prefix -.It Ic References Ar Addr -Find all references to object at addr -.It Ic Resources -Get and display resources -.It Ic Terminate -Delete namespace and all internal objects -.It Ic Thread Ar Threads Loops NamePath -Spawn threads to execute method(s) -.El -.Ss Control Method Execution Commands -.Bl -tag -width indent -.It Ic Arguments -.Pq Ic Args -Display method arguments -.It Ic Breakpoint Ar AmlOffset -Set an AML execution breakpoint -.It Ic Call -Run to next control method invocation -.It Ic Debug Ar Namepath Op Ar Arguments -Single Step a control method -.It Ic Execute Ar Namepath Op Arguments -Execute control method -.It Ic Go -Allow method to run to completion -.It Ic Information -Display info about the current method -.It Ic Into -Step into (not over) a method call -.It Ic List Op OpcodeCount -Display method ASL statements -.It Ic Locals -Display method local variables -.It Ic Results -Display method result stack -.It Ic Set Cm A | L Ar # Value -Set method data (Arguments/Locals) -.It Ic Stop -Terminate control method -.It Ic Tree -Display control method calling tree -.It Ic -Single step next AML opcode (over calls) -.El -.Ss File I/O Commands -.Bl -tag -width indent -.It Ic Close -Close debug output file -.It Ic Open Ar Filename -Open a file for debug output -.It Ic Load Ar Filename -Load ACPI table from a file -.El -.Sh SEE ALSO -.Xr acpi 4 , -.Xr acpidump 8 , -.Xr iasl 8 -.Sh HISTORY -The -.Nm -utility first appeared in the -.Nm acpicatools -port. -It was imported for -.Fx 5.2 . -.Sh AUTHORS -.An -nosplit -The -.Nm -utility was written by -.An Mitsuru Iwasaki Aq Mt iwasaki@FreeBSD.org -and uses Intel ACPI-CA for the backend. -This manual page was written by -.An Nate Lawson . diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c deleted file mode 100644 index baeae75efd..0000000000 --- a/usr.sbin/acpi/acpidb/acpidb.c +++ /dev/null @@ -1,495 +0,0 @@ -/*- - * Copyright (c) 2000-2002 Mitsuru IWASAKI - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/acpi/acpidb/acpidb.c,v 1.1 2003/08/07 16:51:50 njl Exp $ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* - * Dummy DSDT Table Header - */ - -ACPI_TABLE_HEADER dummy_dsdt_table = { - "DSDT", 123, 1, 123, "OEMID", "OEMTBLID", 1, "CRID", 1 -}; - -/* - * Region space I/O routines on virtual machine - */ - -int aml_debug_prompt = 1; - -UINT8 AcpiGbl_RegionFillValue = 0; - -struct ACPIRegionContent { - TAILQ_ENTRY(ACPIRegionContent) links; - int regtype; - ACPI_PHYSICAL_ADDRESS addr; - UINT8 value; -}; - -TAILQ_HEAD(ACPIRegionContentList, ACPIRegionContent); -struct ACPIRegionContentList RegionContentList; - -static int aml_simulation_initialized = 0; - -static void aml_simulation_init(void); -static int aml_simulate_regcontent_add(int regtype, - ACPI_PHYSICAL_ADDRESS addr, - UINT8 value); -static int aml_simulate_regcontent_read(int regtype, - ACPI_PHYSICAL_ADDRESS addr, - UINT8 *valuep); -static int aml_simulate_regcontent_write(int regtype, - ACPI_PHYSICAL_ADDRESS addr, - UINT8 *valuep); -static ACPI_INTEGER aml_simulate_prompt(char *msg, ACPI_INTEGER def_val); -static void aml_simulation_regload(const char *dumpfile); -static void aml_simulation_regdump(const char *dumpfile); - -static void -aml_simulation_init(void) -{ - - aml_simulation_initialized = 1; - TAILQ_INIT(&RegionContentList); - aml_simulation_regload("region.ini"); -} - -static int -aml_simulate_regcontent_add(int regtype, ACPI_PHYSICAL_ADDRESS addr, UINT8 value) -{ - struct ACPIRegionContent *rc; - - rc = malloc(sizeof(struct ACPIRegionContent)); - if (rc == NULL) { - return (-1); /* malloc fail */ - } - rc->regtype = regtype; - rc->addr = addr; - rc->value = value; - - TAILQ_INSERT_TAIL(&RegionContentList, rc, links); - return (0); -} - -static int -aml_simulate_regcontent_read(int regtype, ACPI_PHYSICAL_ADDRESS addr, UINT8 *valuep) -{ - struct ACPIRegionContent *rc; - - if (!aml_simulation_initialized) { - aml_simulation_init(); - } - TAILQ_FOREACH(rc, &RegionContentList, links) { - if (rc->regtype == regtype && rc->addr == addr) { - *valuep = rc->value; - return (1); /* found */ - } - } - - *valuep = 0; - return (aml_simulate_regcontent_add(regtype, addr, *valuep)); -} - -static int -aml_simulate_regcontent_write(int regtype, ACPI_PHYSICAL_ADDRESS addr, UINT8 *valuep) -{ - struct ACPIRegionContent *rc; - - if (!aml_simulation_initialized) { - aml_simulation_init(); - } - TAILQ_FOREACH(rc, &RegionContentList, links) { - if (rc->regtype == regtype && rc->addr == addr) { - rc->value = *valuep; - return (1); /* exists */ - } - } - - return (aml_simulate_regcontent_add(regtype, addr, *valuep)); -} - -static ACPI_INTEGER -aml_simulate_prompt(char *msg, ACPI_INTEGER def_val) -{ - char buf[16], *ep; - ACPI_INTEGER val; - - val = def_val; - printf("DEBUG"); - if (msg != NULL) { - printf("%s", msg); - } - printf("(default: 0x%jx ", (uintmax_t)val); - printf(" / %ju) >>", (uintmax_t)val); - fflush(stdout); - - bzero(buf, sizeof buf); - while (1) { - if (read(0, buf, sizeof buf) == 0) { - continue; - } - if (buf[0] == '\n') { - break; /* use default value */ - } - if (buf[0] == '0' && buf[1] == 'x') { - val = strtoq(buf, &ep, 16); - } else { - val = strtoq(buf, &ep, 10); - } - break; - } - return (val); -} - -static void -aml_simulation_regload(const char *dumpfile) -{ - char buf[256], *np, *ep; - struct ACPIRegionContent rc; - FILE *fp; - - if (!aml_simulation_initialized) { - return; - } - - if ((fp = fopen(dumpfile, "r")) == NULL) { - return; - } - - while (fgets(buf, sizeof buf, fp) != NULL) { - np = buf; - /* reading region type */ - rc.regtype = strtoq(np, &ep, 10); - if (np == ep) { - continue; - } - np = ep; - - /* reading address */ - rc.addr = strtoq(np, &ep, 16); - if (np == ep) { - continue; - } - np = ep; - - /* reading value */ - rc.value = strtoq(np, &ep, 16); - if (np == ep) { - continue; - } - aml_simulate_regcontent_write(rc.regtype, rc.addr, &rc.value); - } - - fclose(fp); -} - -static void -aml_simulation_regdump(const char *dumpfile) -{ - struct ACPIRegionContent *rc; - FILE *fp; - - if (!aml_simulation_initialized) { - return; - } - if ((fp = fopen(dumpfile, "w")) == NULL) { - warn("%s", dumpfile); - return; - } - while (!TAILQ_EMPTY(&RegionContentList)) { - rc = TAILQ_FIRST(&RegionContentList); - fprintf(fp, "%d 0x%jx 0x%x\n", - rc->regtype, (uintmax_t)rc->addr, rc->value); - TAILQ_REMOVE(&RegionContentList, rc, links); - free(rc); - } - - fclose(fp); - TAILQ_INIT(&RegionContentList); -} - -/* - * Space handlers on virtual machine - */ - -static ACPI_STATUS -aml_vm_space_handler( - UINT32 SpaceID, - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - ACPI_INTEGER *Value, - int Prompt) -{ - int state; - UINT8 val; - ACPI_INTEGER value, i; - char msg[256]; - static char *space_names[] = { - "SYSTEM_MEMORY", "SYSTEM_IO", "PCI_CONFIG", - "EC", "SMBUS", "CMOS", "PCI_BAR_TARGET"}; - - switch (Function) { - case ACPI_READ: - value = 0; - for (i = 0; (i * 8) < BitWidth; i++) { - state = aml_simulate_regcontent_read(SpaceID, - Address + i, &val); - if (state == -1) { - return (AE_NO_MEMORY); - } - value |= val << (i * 8); - } - *Value = value; - if (Prompt) { - sprintf(msg, "[read (%s, %2d, 0x%jx)]", - space_names[SpaceID], BitWidth, - (uintmax_t)Address); - *Value = aml_simulate_prompt(msg, value); - if (*Value != value) { - return(aml_vm_space_handler(SpaceID, - ACPI_WRITE, - Address, BitWidth, Value, 0)); - } - } - break; - - case ACPI_WRITE: - value = *Value; - if (Prompt) { - sprintf(msg, "[write(%s, %2d, 0x%jx)]", - space_names[SpaceID], BitWidth, - (uintmax_t)Address); - value = aml_simulate_prompt(msg, *Value); - } - *Value = value; - for (i = 0; (i * 8) < BitWidth; i++) { - val = value & 0xff; - state = aml_simulate_regcontent_write(SpaceID, - Address + i, &val); - if (state == -1) { - return (AE_NO_MEMORY); - } - value = value >> 8; - } - } - - return (AE_OK); -} - -#define DECLARE_VM_SPACE_HANDLER(name, id); \ -static ACPI_STATUS \ -aml_vm_space_handler_##name ( \ - UINT32 Function, \ - ACPI_PHYSICAL_ADDRESS Address, \ - UINT32 BitWidth, \ - ACPI_INTEGER *Value, \ - void *HandlerContext, \ - void *RegionContext) \ -{ \ - return (aml_vm_space_handler(id, Function, Address, \ - BitWidth, Value, aml_debug_prompt)); \ -} - -DECLARE_VM_SPACE_HANDLER(system_memory, ACPI_ADR_SPACE_SYSTEM_MEMORY); -DECLARE_VM_SPACE_HANDLER(system_io, ACPI_ADR_SPACE_SYSTEM_IO); -DECLARE_VM_SPACE_HANDLER(pci_config, ACPI_ADR_SPACE_PCI_CONFIG); -DECLARE_VM_SPACE_HANDLER(ec, ACPI_ADR_SPACE_EC); -DECLARE_VM_SPACE_HANDLER(smbus, ACPI_ADR_SPACE_SMBUS); -DECLARE_VM_SPACE_HANDLER(cmos, ACPI_ADR_SPACE_CMOS); -DECLARE_VM_SPACE_HANDLER(pci_bar_target,ACPI_ADR_SPACE_PCI_BAR_TARGET); - -static u_int8_t *mapped_rsdp; - -/* - * Load DSDT data file and invoke debugger - */ - -static int -load_dsdt(const char *dsdtfile) -{ - char filetmp[PATH_MAX]; - u_int8_t *code; - struct stat sb; - int fd, fd2; - int error; - - fd = open(dsdtfile, O_RDONLY, 0); - if (fd == -1) { - perror("open"); - return (-1); - } - if (fstat(fd, &sb) == -1) { - perror("fstat"); - return (-1); - } - code = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0); - if (code == NULL) { - perror("mmap"); - return (-1); - } - mapped_rsdp = code; - if ((error = AcpiInitializeSubsystem()) != AE_OK) { - err(1, "AcpiInitializeSubsystem returned %d", error); - return (-1); - } - - /* - * make sure DSDT data contains table header or not. - */ - if (strncmp((char *)code, "DSDT", 4) == 0) { - strncpy(filetmp, dsdtfile, sizeof(filetmp)); - } else { - mode_t mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - dummy_dsdt_table.Length = sizeof(ACPI_TABLE_HEADER) + sb.st_size; - snprintf(filetmp, sizeof(filetmp), "%s.tmp", dsdtfile); - fd2 = open(filetmp, O_WRONLY | O_CREAT | O_TRUNC, mode); - if (fd2 == -1) { - perror("open"); - return (-1); - } - write(fd2, &dummy_dsdt_table, sizeof(ACPI_TABLE_HEADER)); - - write(fd2, code, sb.st_size); - close(fd2); - } - - /* - * Install the virtual machine version of address space handlers. - */ - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_SYSTEM_MEMORY, - aml_vm_space_handler_system_memory, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise SystemMemory handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_SYSTEM_IO, - aml_vm_space_handler_system_io, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise SystemIO handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_PCI_CONFIG, - aml_vm_space_handler_pci_config, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise PciConfig handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, - aml_vm_space_handler_ec, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise EC handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_SMBUS, - aml_vm_space_handler_smbus, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise SMBUS handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_CMOS, - aml_vm_space_handler_cmos, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise CMOS handler: %d\n", error); - return (-1); - } - if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_PCI_BAR_TARGET, - aml_vm_space_handler_pci_bar_target, - NULL, NULL)) != AE_OK) { - fprintf(stderr, "could not initialise PCI BAR TARGET handler: %d\n", error); - return (-1); - } - - AcpiDbGetTableFromFile(filetmp, NULL); - - AcpiDbInitialize(); - AcpiGbl_DebuggerConfiguration = 0; - AcpiDbUserCommands(':', NULL); - - if (strcmp(dsdtfile, filetmp) != 0) { - unlink(filetmp); - } - - return (0); -} - -static void -usage(const char *progname) -{ - - printf("usage: %s dsdt_file\n", progname); - exit(1); -} - -BOOLEAN AcpiGbl_IgnoreErrors = FALSE; - -int -main(int argc, char *argv[]) -{ - char *progname; - - progname = argv[0]; - - if (argc == 1) { - usage(progname); - } - - AcpiDbgLevel = ACPI_DEBUG_DEFAULT; - AcpiGbl_EnableInterpreterSlack = TRUE; - - aml_simulation_regload("region.ini"); - if (load_dsdt(argv[1]) == 0) { - aml_simulation_regdump("region.dmp"); - } - - return (0); -} diff --git a/usr.sbin/acpi/acpidb/osunixxf.c.patch b/usr.sbin/acpi/acpidb/osunixxf.c.patch deleted file mode 100644 index c5403414ea..0000000000 --- a/usr.sbin/acpi/acpidb/osunixxf.c.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/sys/contrib/dev/acpica-unix/osunixxf.c b/sys/contrib/dev/acpica-unix/osunixxf.c -index 967d544..44162e5 100644 ---- a/sys/contrib/dev/acpica-unix/osunixxf.c -+++ b/sys/contrib/dev/acpica-unix/osunixxf.c -@@ -400,6 +400,7 @@ AcpiOsGetLine ( - UINT32 *BytesRead) - { - UINT8 Temp; -+ int c; - UINT32 i; - - -@@ -410,7 +411,13 @@ AcpiOsGetLine ( - return (AE_BUFFER_OVERFLOW); - } - -- scanf ("%1c", &Temp); -+ c = scanf ("%1c", &Temp); -+ if (c != 1) -+ { -+ AcpiGbl_DbTerminateThreads = TRUE; -+ break; -+ } -+ - if (!Temp || Temp == '\n') - { - break; diff --git a/usr.sbin/acpi/acpidump/Makefile b/usr.sbin/acpi/acpidump/Makefile index e1a7609439..23f9080ce1 100644 --- a/usr.sbin/acpi/acpidump/Makefile +++ b/usr.sbin/acpi/acpidump/Makefile @@ -1,8 +1,37 @@ -# $FreeBSD: src/usr.sbin/acpi/acpidump/Makefile,v 1.7 2003/08/28 03:33:07 njl Exp $ -# $DragonFly: src/usr.sbin/acpi/acpidump/Makefile,v 1.1 2004/07/05 00:22:43 dillon Exp $ +# +# acpidump - ACPI table dump utility (binary to ascii hex) +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpidump + +.PATH: ${UTILDIR} PROG= acpidump MAN= acpidump.8 -SRCS= acpi.c acpi_user.c acpidump.c + +SRCS= \ + apdump.c \ + apfiles.c \ + apmain.c + +SRCS+= \ + osunixdir.c \ + osunixmap.c \ + tbprint.c \ + tbxfroot.c \ + utbuffer.c \ + utexcep.c \ + utmath.c \ + utstring.c \ + utxferror.c \ + getopt.c + +SRCS+= \ + osdragonflytbl.c + +CFLAGS+= \ + -DACPI_DUMP_APP \ + -I${UTILDIR} \ + -D_FreeBSD .include diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c deleted file mode 100644 index 67cb43e7b4..0000000000 --- a/usr.sbin/acpi/acpidump/acpi.c +++ /dev/null @@ -1,1005 +0,0 @@ -/*- - * Copyright (c) 1998 Doug Rabson - * Copyright (c) 2000 Mitsuru IWASAKI - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/acpi/acpidump/acpi.c,v 1.31 2005/02/14 11:21:48 scottl Exp $ - * $DragonFly: src/usr.sbin/acpi/acpidump/acpi.c,v 1.7 2008/07/19 13:50:51 swildner Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acpidump.h" - -#define BEGIN_COMMENT "/*\n" -#define END_COMMENT " */\n" - -static void acpi_print_string(char *s, size_t length); -static void acpi_print_gas(struct ACPIgas *gas); -static int acpi_get_fadt_revision(struct FADTbody *fadt); -static void acpi_handle_fadt(struct ACPIsdt *fadt); -static void acpi_print_cpu(u_char cpu_id); -static void acpi_print_local_apic(u_char cpu_id, u_char apic_id, - u_int32_t flags); -static void acpi_print_io_apic(u_char apic_id, u_int32_t int_base, - u_int64_t apic_addr); -static void acpi_print_mps_flags(u_int16_t flags); -static void acpi_print_intr(u_int32_t intr, u_int16_t mps_flags); -static void acpi_print_madt(struct MADT_APIC *mp); -static void acpi_handle_madt(struct ACPIsdt *sdp); -static void acpi_handle_hpet(struct ACPIsdt *sdp); -static void acpi_print_sdt(struct ACPIsdt *sdp); -static void acpi_print_fadt(struct ACPIsdt *sdp); -static void acpi_print_facs(struct FACSbody *facs); -static void acpi_print_dsdt(struct ACPIsdt *dsdp); -static struct ACPIsdt *acpi_map_sdt(vm_offset_t pa); -static void acpi_print_rsd_ptr(struct ACPIrsdp *rp); -static void acpi_handle_rsdt(struct ACPIsdt *rsdp); - -/* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */ -static int addr_size; - -static void -acpi_print_string(char *s, size_t length) -{ - int c; - - /* Trim trailing spaces and NULLs */ - while (length > 0 && (s[length - 1] == ' ' || s[length - 1] == '\0')) - length--; - - while (length--) { - c = *s++; - putchar(c); - } -} - -static void -acpi_print_gas(struct ACPIgas *gas) -{ - switch(gas->address_space_id) { - case ACPI_GAS_MEMORY: - printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->address, - gas->bit_offset, gas->bit_width); - break; - case ACPI_GAS_IO: - printf("0x%02lx:%u[%u] (IO)", (u_long)gas->address, - gas->bit_offset, gas->bit_width); - break; - case ACPI_GAS_PCI: - printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->address >> 32), - (uint16_t)((gas->address >> 16) & 0xffff), - (uint16_t)gas->address); - break; - /* XXX How to handle these below? */ - case ACPI_GAS_EMBEDDED: - printf("0x%x:%u[%u] (EC)", (uint16_t)gas->address, - gas->bit_offset, gas->bit_width); - break; - case ACPI_GAS_SMBUS: - printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->address, - gas->bit_offset, gas->bit_width); - break; - case ACPI_GAS_CMOS: - case ACPI_GAS_PCIBAR: - case ACPI_GAS_DATATABLE: - case ACPI_GAS_FIXED: - default: - printf("0x%08lx (?)", (u_long)gas->address); - break; - } -} - -/* The FADT revision indicates whether we use the DSDT or X_DSDT addresses. */ -static int -acpi_get_fadt_revision(struct FADTbody *fadt) -{ - int fadt_revision; - - /* Set the FADT revision separately from the RSDP version. */ - if (addr_size == 8) { - fadt_revision = 2; - - /* - * A few systems (e.g., IBM T23) have an RSDP that claims - * revision 2 but the 64 bit addresses are invalid. If - * revision 2 and the 32 bit address is non-zero but the - * 32 and 64 bit versions don't match, prefer the 32 bit - * version for all subsequent tables. - */ - if (fadt->facs_ptr != 0 && - (fadt->x_facs_ptr & 0xffffffff) != fadt->facs_ptr) - fadt_revision = 1; - } else - fadt_revision = 1; - return (fadt_revision); -} - -static void -acpi_handle_fadt(struct ACPIsdt *sdp) -{ - struct ACPIsdt *dsdp; - struct FACSbody *facs; - struct FADTbody *fadt; - int fadt_revision; - - fadt = (struct FADTbody *)sdp->body; - acpi_print_fadt(sdp); - - fadt_revision = acpi_get_fadt_revision(fadt); - if (fadt_revision == 1) - facs = (struct FACSbody *)acpi_map_sdt(fadt->facs_ptr); - else - facs = (struct FACSbody *)acpi_map_sdt(fadt->x_facs_ptr); - if (memcmp(facs->signature, "FACS", 4) != 0 || facs->len < 64) - errx(1, "FACS is corrupt"); - acpi_print_facs(facs); - - if (fadt_revision == 1) - dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr); - else - dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr); - if (acpi_checksum(dsdp, dsdp->len)) - errx(1, "DSDT is corrupt"); - acpi_print_dsdt(dsdp); -} - -static void -acpi_print_cpu(u_char cpu_id) -{ - - printf("\tACPI CPU="); - if (cpu_id == 0xff) - printf("ALL\n"); - else - printf("%d\n", (u_int)cpu_id); -} - -static void -acpi_print_local_apic(u_char cpu_id, u_char apic_id, u_int32_t flags) -{ - acpi_print_cpu(cpu_id); - printf("\tFlags={"); - if (flags & ACPI_MADT_APIC_LOCAL_FLAG_ENABLED) - printf("ENABLED"); - else - printf("DISABLED"); - printf("}\n"); - printf("\tAPIC ID=%d\n", (u_int)apic_id); -} - -static void -acpi_print_io_apic(u_char apic_id, u_int32_t int_base, u_int64_t apic_addr) -{ - printf("\tAPIC ID=%d\n", (u_int)apic_id); - printf("\tINT BASE=%d\n", int_base); - printf("\tADDR=0x%016jx\n", apic_addr); -} - -static void -acpi_print_mps_flags(u_int16_t flags) -{ - - printf("\tFlags={Polarity="); - switch (flags & MPS_INT_FLAG_POLARITY_MASK) { - case MPS_INT_FLAG_POLARITY_CONFORM: - printf("conforming"); - break; - case MPS_INT_FLAG_POLARITY_HIGH: - printf("active-hi"); - break; - case MPS_INT_FLAG_POLARITY_LOW: - printf("active-lo"); - break; - default: - printf("0x%x", flags & MPS_INT_FLAG_POLARITY_MASK); - break; - } - printf(", Trigger="); - switch (flags & MPS_INT_FLAG_TRIGGER_MASK) { - case MPS_INT_FLAG_TRIGGER_CONFORM: - printf("conforming"); - break; - case MPS_INT_FLAG_TRIGGER_EDGE: - printf("edge"); - break; - case MPS_INT_FLAG_TRIGGER_LEVEL: - printf("level"); - break; - default: - printf("0x%x", (flags & MPS_INT_FLAG_TRIGGER_MASK) >> 2); - } - printf("}\n"); -} - -static void -acpi_print_intr(u_int32_t intr, u_int16_t mps_flags) -{ - - printf("\tINTR=%d\n", (u_int)intr); - acpi_print_mps_flags(mps_flags); -} - -const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI", - "Local NMI", "Local APIC Override", "IO SAPIC", - "Local SAPIC", "Platform Interrupt" }; -const char *platform_int_types[] = { "PMI", "INIT", - "Corrected Platform Error" }; - -static void -acpi_print_madt(struct MADT_APIC *mp) -{ - - printf("\tType=%s\n", apic_types[mp->type]); - switch (mp->type) { - case ACPI_MADT_APIC_TYPE_LOCAL_APIC: - acpi_print_local_apic(mp->body.local_apic.cpu_id, - mp->body.local_apic.apic_id, mp->body.local_apic.flags); - break; - case ACPI_MADT_APIC_TYPE_IO_APIC: - acpi_print_io_apic(mp->body.io_apic.apic_id, - mp->body.io_apic.int_base, - mp->body.io_apic.apic_addr); - break; - case ACPI_MADT_APIC_TYPE_INT_OVERRIDE: - printf("\tBUS=%d\n", (u_int)mp->body.int_override.bus); - printf("\tIRQ=%d\n", (u_int)mp->body.int_override.source); - acpi_print_intr(mp->body.int_override.intr, - mp->body.int_override.mps_flags); - break; - case ACPI_MADT_APIC_TYPE_NMI: - acpi_print_intr(mp->body.nmi.intr, mp->body.nmi.mps_flags); - break; - case ACPI_MADT_APIC_TYPE_LOCAL_NMI: - acpi_print_cpu(mp->body.local_nmi.cpu_id); - printf("\tLINT Pin=%d\n", mp->body.local_nmi.lintpin); - acpi_print_mps_flags(mp->body.local_nmi.mps_flags); - break; - case ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE: - printf("\tLocal APIC ADDR=0x%016jx\n", - mp->body.local_apic_override.apic_addr); - break; - case ACPI_MADT_APIC_TYPE_IO_SAPIC: - acpi_print_io_apic(mp->body.io_sapic.apic_id, - mp->body.io_sapic.int_base, - mp->body.io_sapic.apic_addr); - break; - case ACPI_MADT_APIC_TYPE_LOCAL_SAPIC: - acpi_print_local_apic(mp->body.local_sapic.cpu_id, - mp->body.local_sapic.apic_id, mp->body.local_sapic.flags); - printf("\tAPIC EID=%d\n", (u_int)mp->body.local_sapic.apic_eid); - break; - case ACPI_MADT_APIC_TYPE_INT_SRC: - printf("\tType=%s\n", - platform_int_types[mp->body.int_src.type]); - printf("\tCPU ID=%d\n", (u_int)mp->body.int_src.cpu_id); - printf("\tCPU EID=%d\n", (u_int)mp->body.int_src.cpu_id); - printf("\tSAPIC Vector=%d\n", - (u_int)mp->body.int_src.sapic_vector); - acpi_print_intr(mp->body.int_src.intr, - mp->body.int_src.mps_flags); - break; - default: - printf("\tUnknown type %d\n", (u_int)mp->type); - break; - } -} - -static void -acpi_handle_madt(struct ACPIsdt *sdp) -{ - struct MADTbody *madtp; - struct MADT_APIC *madt_apicp; - - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - madtp = (struct MADTbody *) sdp->body; - printf("\tLocal APIC ADDR=0x%08x\n", madtp->lapic_addr); - printf("\tFlags={"); - if (madtp->flags & ACPI_APIC_FLAG_PCAT_COMPAT) - printf("PC-AT"); - printf("}\n"); - madt_apicp = (struct MADT_APIC *)madtp->body; - while (((uintptr_t)madt_apicp) - ((uintptr_t)sdp) < sdp->len) { - printf("\n"); - acpi_print_madt(madt_apicp); - madt_apicp = (struct MADT_APIC *) ((char *)madt_apicp + - madt_apicp->len); - } - printf(END_COMMENT); -} - -static void -acpi_handle_hpet(struct ACPIsdt *sdp) -{ - struct HPETbody *hpetp; - - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - hpetp = (struct HPETbody *) sdp->body; - printf("\tHPET Number=%d\n", hpetp->hpet_number); - printf("\tADDR=0x%08x\n", hpetp->base_addr); - printf("\tHW Rev=0x%x\n", hpetp->block_hwrev); - printf("\tComparitors=%d\n", hpetp->block_comparitors); - printf("\tCounter Size=%d\n", hpetp->block_counter_size); - printf("\tLegacy IRQ routing capable={"); - if (hpetp->block_legacy_capable) - printf("TRUE}\n"); - else - printf("FALSE}\n"); - printf("\tPCI Vendor ID=0x%04x\n", hpetp->block_pcivendor); - printf("\tMinimal Tick=%d\n", hpetp->clock_tick); - printf(END_COMMENT); -} - -static void -acpi_handle_ecdt(struct ACPIsdt *sdp) -{ - struct ECDTbody *ecdt; - - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - ecdt = (struct ECDTbody *) sdp->body; - printf("\tEC_CONTROL="); - acpi_print_gas(&ecdt->ec_control); - printf("\n\tEC_DATA="); - acpi_print_gas(&ecdt->ec_data); - printf("\n\tUID=%#x, ", ecdt->uid); - printf("GPE_BIT=%#x\n", ecdt->gpe_bit); - printf("\tEC_ID=%s\n", ecdt->ec_id); - printf(END_COMMENT); -} - -static void -acpi_handle_mcfg(struct ACPIsdt *sdp) -{ - struct MCFGbody *mcfg; - u_int i, e; - - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - mcfg = (struct MCFGbody *) sdp->body; - - e = (sdp->len - ((caddr_t)&mcfg->s[0] - (caddr_t)sdp)) / - sizeof(*mcfg->s); - for (i = 0; i < e; i++, mcfg++) { - printf("\n"); - printf("\tBase Address= 0x%016jx\n", mcfg->s[i].baseaddr); - printf("\tSegment Group= 0x%04x\n", mcfg->s[i].seg_grp); - printf("\tStart Bus= %d\n", mcfg->s[i].start); - printf("\tEnd Bus= %d\n", mcfg->s[i].end); - } - printf(END_COMMENT); -} - -static void -acpi_print_srat_memory(struct SRAT_mem_affinity *mp) -{ - - printf("\tFlags={"); - printf(mp->flags & ACPI_SRAT_FLAG_MEM_ENABLED ? "ENABLED" : "DISABLED"); - if (mp->flags & ACPI_SRAT_FLAG_MEM_HOT_PLUGGABLE) - printf(",HOT_PLUGGABLE"); - if (mp->flags & ACPI_SRAT_FLAG_MEM_NON_VOLATILE) - printf(",NON_VOLATILE"); - printf("}\n"); - printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->base_address); - printf("\tLength=0x%016jx\n", (uintmax_t)mp->length); - printf("\tProximity Domain=%d\n", mp->proximity_domain); -} - -static void -acpi_print_srat_cpu(uint32_t apic_id, uint32_t pd, uint32_t flags) -{ - printf("\tFlags={"); - printf(flags & ACPI_SRAT_FLAG_CPU_ENABLED ? "ENABLED": "DISABLED"); - printf("}\n"); - printf("\tAPIC ID=%d\n", apic_id); - printf("\tProximity Domain=%d\n", pd); -} - -static void -acpi_print_srat_cpu_affinity(struct SRAT_cpu_affinity *cpu) -{ - uint32_t pd = - cpu->proximity_domain_hi[2] << 24 | cpu->proximity_domain_hi[1] << 16 | - cpu->proximity_domain_hi[0] << 0 | cpu->proximity_domain_lo; - acpi_print_srat_cpu(cpu->apic_id, pd, cpu->flags); -} - -static void -acpi_print_srat(struct SRAT_APIC *sp) -{ - const char *srat_types[] = { "CPU", "Memory", "X2APIC" }; - const unsigned char srat_types_n = - sizeof(srat_types) / sizeof(srat_types[0]); - - printf("\tType(%d)=%s\n", sp->type, - sp->type < srat_types_n ? srat_types[sp->type] : "(unknown)"); - - switch (sp->type) { - case ACPI_SRAT_APIC_TYPE_CPU_AFFINITY: - acpi_print_srat_cpu_affinity((struct SRAT_cpu_affinity *) &sp->body); - break; - case ACPI_SRAT_APIC_TYPE_MEMORY_AFFINITY: - acpi_print_srat_memory((struct SRAT_mem_affinity *) &sp->body); - break; - case ACPI_SRAT_APIC_TYPE_X2APIC_CPU_AFFINITY: { - struct SRAT_x2apic_cpu_affinity *cpu = - (struct SRAT_x2apic_cpu_affinity *) &sp->body; - acpi_print_srat_cpu(cpu->apic_id, cpu->proximity_domain, cpu->flags); - } break; - } -} - -static void -acpi_handle_srat(struct ACPIsdt *sdp) -{ - struct SRATbody *srat = (struct SRATbody *) sdp->body; - struct SRAT_APIC *apic = (struct SRAT_APIC *)srat->body; - - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - printf("\tRevision=0x%04x\n", srat->revision); - - for (; ((uintptr_t) apic) - ((uintptr_t) sdp) < sdp->len; - apic = (struct SRAT_APIC *) ((char *) apic + apic->len)) { - printf("\n"); - acpi_print_srat(apic); - } - printf(END_COMMENT); -} - -static void -acpi_print_sdt(struct ACPIsdt *sdp) -{ - printf(" "); - acpi_print_string(sdp->signature, 4); - printf(": Length=%d, Revision=%d, Checksum=%d,\n", - sdp->len, sdp->rev, sdp->check); - printf("\tOEMID="); - acpi_print_string(sdp->oemid, 6); - printf(", OEM Table ID="); - acpi_print_string(sdp->oemtblid, 8); - printf(", OEM Revision=0x%x,\n", sdp->oemrev); - printf("\tCreator ID="); - acpi_print_string(sdp->creator, 4); - printf(", Creator Revision=0x%x\n", sdp->crerev); -} - -static void -acpi_print_rsdt(struct ACPIsdt *rsdp) -{ - int i, entries; - u_long addr; - - printf(BEGIN_COMMENT); - acpi_print_sdt(rsdp); - entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size; - printf("\tEntries={ "); - for (i = 0; i < entries; i++) { - if (i > 0) - printf(", "); - switch (addr_size) { - case 4: - addr = le32dec((char*)rsdp->body + i * addr_size); - break; - case 8: - addr = le64dec((char*)rsdp->body + i * addr_size); - break; - default: - addr = 0; - } - printf("0x%08lx", addr); - } - printf(" }\n"); - printf(END_COMMENT); -} - -static const char *acpi_pm_profiles[] = { - "Unspecified", "Desktop", "Mobile", "Workstation", - "Enterprise Server", "SOHO Server", "Appliance PC" -}; - -static void -acpi_print_fadt(struct ACPIsdt *sdp) -{ - struct FADTbody *fadt; - const char *pm; - char sep; - - fadt = (struct FADTbody *)sdp->body; - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->facs_ptr, - fadt->dsdt_ptr); - printf("\tINT_MODEL=%s\n", fadt->int_model ? "APIC" : "PIC"); - if (fadt->pm_profile >= sizeof(acpi_pm_profiles) / sizeof(char *)) - pm = "Reserved"; - else - pm = acpi_pm_profiles[fadt->pm_profile]; - printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->pm_profile); - printf("\tSCI_INT=%d\n", fadt->sci_int); - printf("\tSMI_CMD=0x%x, ", fadt->smi_cmd); - printf("ACPI_ENABLE=0x%x, ", fadt->acpi_enable); - printf("ACPI_DISABLE=0x%x, ", fadt->acpi_disable); - printf("S4BIOS_REQ=0x%x\n", fadt->s4biosreq); - printf("\tPSTATE_CNT=0x%x\n", fadt->pstate_cnt); - printf("\tPM1a_EVT_BLK=0x%x-0x%x\n", - fadt->pm1a_evt_blk, - fadt->pm1a_evt_blk + fadt->pm1_evt_len - 1); - if (fadt->pm1b_evt_blk != 0) - printf("\tPM1b_EVT_BLK=0x%x-0x%x\n", - fadt->pm1b_evt_blk, - fadt->pm1b_evt_blk + fadt->pm1_evt_len - 1); - printf("\tPM1a_CNT_BLK=0x%x-0x%x\n", - fadt->pm1a_cnt_blk, - fadt->pm1a_cnt_blk + fadt->pm1_cnt_len - 1); - if (fadt->pm1b_cnt_blk != 0) - printf("\tPM1b_CNT_BLK=0x%x-0x%x\n", - fadt->pm1b_cnt_blk, - fadt->pm1b_cnt_blk + fadt->pm1_cnt_len - 1); - if (fadt->pm2_cnt_blk != 0) - printf("\tPM2_CNT_BLK=0x%x-0x%x\n", - fadt->pm2_cnt_blk, - fadt->pm2_cnt_blk + fadt->pm2_cnt_len - 1); - printf("\tPM_TMR_BLK=0x%x-0x%x\n", - fadt->pm_tmr_blk, - fadt->pm_tmr_blk + fadt->pm_tmr_len - 1); - if (fadt->gpe0_blk != 0) - printf("\tGPE0_BLK=0x%x-0x%x\n", - fadt->gpe0_blk, - fadt->gpe0_blk + fadt->gpe0_len - 1); - if (fadt->gpe1_blk != 0) - printf("\tGPE1_BLK=0x%x-0x%x, GPE1_BASE=%d\n", - fadt->gpe1_blk, - fadt->gpe1_blk + fadt->gpe1_len - 1, - fadt->gpe1_base); - if (fadt->cst_cnt != 0) - printf("\tCST_CNT=0x%x\n", fadt->cst_cnt); - printf("\tP_LVL2_LAT=%d us, P_LVL3_LAT=%d us\n", - fadt->p_lvl2_lat, fadt->p_lvl3_lat); - printf("\tFLUSH_SIZE=%d, FLUSH_STRIDE=%d\n", - fadt->flush_size, fadt->flush_stride); - printf("\tDUTY_OFFSET=%d, DUTY_WIDTH=%d\n", - fadt->duty_off, fadt->duty_width); - printf("\tDAY_ALRM=%d, MON_ALRM=%d, CENTURY=%d\n", - fadt->day_alrm, fadt->mon_alrm, fadt->century); - -#define PRINTFLAG(var, flag) do { \ - if ((var) & FADT_FLAG_## flag) { \ - printf("%c%s", sep, #flag); sep = ','; \ - } \ -} while (0) - - printf("\tIAPC_BOOT_ARCH="); - sep = '{'; - PRINTFLAG(fadt->iapc_boot_arch, LEGACY_DEV); - PRINTFLAG(fadt->iapc_boot_arch, 8042); - if (fadt->iapc_boot_arch != 0) - printf("}"); - printf("\n"); - - printf("\tFlags="); - sep = '{'; - PRINTFLAG(fadt->flags, WBINVD); - PRINTFLAG(fadt->flags, WBINVD_FLUSH); - PRINTFLAG(fadt->flags, PROC_C1); - PRINTFLAG(fadt->flags, P_LVL2_UP); - PRINTFLAG(fadt->flags, PWR_BUTTON); - PRINTFLAG(fadt->flags, SLP_BUTTON); - PRINTFLAG(fadt->flags, FIX_RTC); - PRINTFLAG(fadt->flags, RTC_S4); - PRINTFLAG(fadt->flags, TMR_VAL_EXT); - PRINTFLAG(fadt->flags, DCK_CAP); - PRINTFLAG(fadt->flags, RESET_REG); - PRINTFLAG(fadt->flags, SEALED_CASE); - PRINTFLAG(fadt->flags, HEADLESS); - PRINTFLAG(fadt->flags, CPU_SW_SLP); - PRINTFLAG(fadt->flags, PCI_EXPRESS_WAKE); - PRINTFLAG(fadt->flags, PLATFORM_CLOCK); - PRINTFLAG(fadt->flags, S4_RTC_VALID); - PRINTFLAG(fadt->flags, REMOTE_POWER_ON); - PRINTFLAG(fadt->flags, APIC_CLUSTER); - PRINTFLAG(fadt->flags, APIC_PHYSICAL); - if (fadt->flags != 0) - printf("}\n"); - -#undef PRINTFLAG - - if (fadt->flags & FADT_FLAG_RESET_REG) { - printf("\tRESET_REG="); - acpi_print_gas(&fadt->reset_reg); - printf(", RESET_VALUE=%#x\n", fadt->reset_value); - } - if (acpi_get_fadt_revision(fadt) > 1) { - printf("\tX_FACS=0x%08lx, ", (u_long)fadt->x_facs_ptr); - printf("X_DSDT=0x%08lx\n", (u_long)fadt->x_dsdt_ptr); - printf("\tX_PM1a_EVT_BLK="); - acpi_print_gas(&fadt->x_pm1a_evt_blk); - if (fadt->x_pm1b_evt_blk.address != 0) { - printf("\n\tX_PM1b_EVT_BLK="); - acpi_print_gas(&fadt->x_pm1b_evt_blk); - } - printf("\n\tX_PM1a_CNT_BLK="); - acpi_print_gas(&fadt->x_pm1a_cnt_blk); - if (fadt->x_pm1b_cnt_blk.address != 0) { - printf("\n\tX_PM1b_CNT_BLK="); - acpi_print_gas(&fadt->x_pm1b_cnt_blk); - } - if (fadt->x_pm1b_cnt_blk.address != 0) { - printf("\n\tX_PM2_CNT_BLK="); - acpi_print_gas(&fadt->x_pm2_cnt_blk); - } - printf("\n\tX_PM_TMR_BLK="); - acpi_print_gas(&fadt->x_pm_tmr_blk); - if (fadt->x_gpe0_blk.address != 0) { - printf("\n\tX_GPE0_BLK="); - acpi_print_gas(&fadt->x_gpe0_blk); - } - if (fadt->x_gpe1_blk.address != 0) { - printf("\n\tX_GPE1_BLK="); - acpi_print_gas(&fadt->x_gpe1_blk); - } - printf("\n"); - } - - printf(END_COMMENT); -} - -static void -acpi_print_facs(struct FACSbody *facs) -{ - printf(BEGIN_COMMENT); - printf(" FACS:\tLength=%u, ", facs->len); - printf("HwSig=0x%08x, ", facs->hw_sig); - printf("Firm_Wake_Vec=0x%08x\n", facs->firm_wake_vec); - - printf("\tGlobal_Lock="); - if (facs->global_lock != 0) { - if (facs->global_lock & FACS_FLAG_LOCK_PENDING) - printf("PENDING,"); - if (facs->global_lock & FACS_FLAG_LOCK_OWNED) - printf("OWNED"); - } - printf("\n"); - - printf("\tFlags="); - if (facs->flags & FACS_FLAG_S4BIOS_F) - printf("S4BIOS"); - printf("\n"); - - if (facs->x_firm_wake_vec != 0) { - printf("\tX_Firm_Wake_Vec=%08lx\n", - (u_long)facs->x_firm_wake_vec); - } - printf("\tVersion=%u\n", facs->version); - - printf(END_COMMENT); -} - -static void -acpi_print_dsdt(struct ACPIsdt *dsdp) -{ - printf(BEGIN_COMMENT); - acpi_print_sdt(dsdp); - printf(END_COMMENT); -} - -int -acpi_checksum(void *p, size_t length) -{ - u_int8_t *bp; - u_int8_t sum; - - bp = p; - sum = 0; - while (length--) - sum += *bp++; - - return (sum); -} - -static struct ACPIsdt * -acpi_map_sdt(vm_offset_t pa) -{ - struct ACPIsdt *sp; - - sp = acpi_map_physical(pa, sizeof(struct ACPIsdt)); - sp = acpi_map_physical(pa, sp->len); - return (sp); -} - -static void -acpi_print_rsd_ptr(struct ACPIrsdp *rp) -{ - printf(BEGIN_COMMENT); - printf(" RSD PTR: OEM="); - acpi_print_string(rp->oem, 6); - printf(", ACPI_Rev=%s (%d)\n", rp->revision < 2 ? "1.0x" : "2.0x", - rp->revision); - if (rp->revision < 2) { - printf("\tRSDT=0x%08x, cksum=%u\n", rp->rsdt_addr, rp->sum); - } else { - printf("\tXSDT=0x%08lx, length=%u, cksum=%u\n", - (u_long)rp->xsdt_addr, rp->length, rp->xsum); - } - printf(END_COMMENT); -} - -static void -acpi_handle_rsdt(struct ACPIsdt *rsdp) -{ - struct ACPIsdt *sdp; - vm_offset_t addr; - int entries, i; - - acpi_print_rsdt(rsdp); - entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size; - for (i = 0; i < entries; i++) { - switch (addr_size) { - case 4: - addr = le32dec((char*)rsdp->body + i * addr_size); - break; - case 8: - addr = le64dec((char*)rsdp->body + i * addr_size); - break; - default: - printf("invalid addr_size: %d", addr_size); - continue; - } - - sdp = (struct ACPIsdt *)acpi_map_sdt(addr); - if (acpi_checksum(sdp, sdp->len)) { - warnx("RSDT entry %d (sig %.4s) is corrupt", i, - sdp->signature); - continue; - } - if (!memcmp(sdp->signature, "FACP", 4)) - acpi_handle_fadt(sdp); - else if (!memcmp(sdp->signature, "APIC", 4)) - acpi_handle_madt(sdp); - else if (!memcmp(sdp->signature, "HPET", 4)) - acpi_handle_hpet(sdp); - else if (!memcmp(sdp->signature, "ECDT", 4)) - acpi_handle_ecdt(sdp); - else if (!memcmp(sdp->signature, "MCFG", 4)) - acpi_handle_mcfg(sdp); - else if (!memcmp(sdp->signature, "SRAT", 4)) - acpi_handle_srat(sdp); - else { - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - printf(END_COMMENT); - } - } -} - -struct ACPIsdt * -sdt_load_devmem(void) -{ - struct ACPIrsdp *rp; - struct ACPIsdt *rsdp; - - rp = acpi_find_rsd_ptr(); - if (!rp) - errx(1, "Can't find ACPI information"); - - if (tflag) - acpi_print_rsd_ptr(rp); - if (rp->revision < 2) { - rsdp = (struct ACPIsdt *)acpi_map_sdt(rp->rsdt_addr); - if (memcmp(rsdp->signature, "RSDT", 4) != 0 || - acpi_checksum(rsdp, rsdp->len) != 0) - errx(1, "RSDT is corrupted"); - addr_size = sizeof(uint32_t); - } else { - rsdp = (struct ACPIsdt *)acpi_map_sdt(rp->xsdt_addr); - if (memcmp(rsdp->signature, "XSDT", 4) != 0 || - acpi_checksum(rsdp, rsdp->len) != 0) - errx(1, "XSDT is corrupted"); - addr_size = sizeof(uint64_t); - } - return (rsdp); -} - -/* Write the DSDT to a file, concatenating any SSDTs (if present). */ -static int -write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt) -{ - struct ACPIsdt sdt; - struct ACPIsdt *ssdt; - uint8_t sum; - - /* Create a new checksum to account for the DSDT and any SSDTs. */ - sdt = *dsdt; - if (rsdt != NULL) { - sdt.check = 0; - sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR); - ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); - while (ssdt != NULL) { - sdt.len += ssdt->len - SIZEOF_SDT_HDR; - sum += acpi_checksum(ssdt->body, - ssdt->len - SIZEOF_SDT_HDR); - ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt); - } - sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR); - sdt.check -= sum; - } - - /* Write out the DSDT header and body. */ - write(fd, &sdt, SIZEOF_SDT_HDR); - write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR); - - /* Write out any SSDTs (if present.) */ - if (rsdt != NULL) { - ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); - while (ssdt != NULL) { - write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR); - ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt); - } - } - return (0); -} - -void -dsdt_save_file(char *outfile, struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) -{ - int fd; - mode_t mode; - - assert(outfile != NULL); - mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, mode); - if (fd == -1) { - perror("dsdt_save_file"); - return; - } - write_dsdt(fd, rsdt, dsdp); - close(fd); -} - -void -aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) -{ - char buf[PATH_MAX], tmpstr[PATH_MAX]; - const char *tmpdir; - char *tmpext; - FILE *fp; - size_t len; - int fd; - - tmpdir = getenv("TMPDIR"); - if (tmpdir == NULL) - tmpdir = _PATH_TMP; - strncpy(tmpstr, tmpdir, sizeof(tmpstr)); - strncat(tmpstr, "/acpidump.", sizeof(tmpstr) - strlen(tmpdir)); - if (realpath(tmpstr, buf) == NULL) { - perror("realpath tmp file"); - return; - } - strncpy(tmpstr, buf, sizeof(tmpstr)); - len = strlen(buf); - tmpext = tmpstr + len; - strncpy(tmpext, "XXXXXX", sizeof(tmpstr) - len); - fd = mkstemp(tmpstr); - if (fd < 0) { - perror("iasl tmp file"); - return; - } - write_dsdt(fd, rsdt, dsdp); - close(fd); - - /* Run iasl -d on the temp file */ - if (fork() == 0) { - close(STDOUT_FILENO); - if (vflag == 0) - close(STDERR_FILENO); - execl("/usr/sbin/iasl", "iasl", "-d", tmpstr, NULL); - err(1, "exec"); - } - - wait(NULL); - unlink(tmpstr); - - /* Dump iasl's output to stdout */ - strncpy(tmpext, "dsl", sizeof(tmpstr) - len); - fp = fopen(tmpstr, "r"); - unlink(tmpstr); - if (fp == NULL) { - perror("iasl tmp file (read)"); - return; - } - while ((len = fread(buf, 1, sizeof(buf), fp)) > 0) - fwrite(buf, 1, len, stdout); - fclose(fp); -} - -void -sdt_print_all(struct ACPIsdt *rsdp) -{ - acpi_handle_rsdt(rsdp); -} - -/* Fetch a table matching the given signature via the RSDT. */ -struct ACPIsdt * -sdt_from_rsdt(struct ACPIsdt *rsdt, const char *sig, struct ACPIsdt *last) -{ - struct ACPIsdt *sdt; - vm_offset_t addr; - int entries, i; - - entries = (rsdt->len - SIZEOF_SDT_HDR) / addr_size; - for (i = 0; i < entries; i++) { - switch (addr_size) { - case 4: - addr = le32dec((char*)rsdt->body + i * addr_size); - break; - case 8: - addr = le64dec((char*)rsdt->body + i * addr_size); - break; - default: - assert((addr = 0)); - } - sdt = (struct ACPIsdt *)acpi_map_sdt(addr); - if (last != NULL) { - if (sdt == last) - last = NULL; - continue; - } - if (memcmp(sdt->signature, sig, strlen(sig))) - continue; - if (acpi_checksum(sdt, sdt->len)) - errx(1, "RSDT entry %d is corrupt", i); - return (sdt); - } - - return (NULL); -} - -struct ACPIsdt * -dsdt_from_fadt(struct FADTbody *fadt) -{ - struct ACPIsdt *sdt; - - /* Use the DSDT address if it is version 1, otherwise use X_DSDT. */ - if (acpi_get_fadt_revision(fadt) == 1) - sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr); - else - sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr); - if (acpi_checksum(sdt, sdt->len)) - errx(1, "DSDT is corrupt\n"); - return (sdt); -} diff --git a/usr.sbin/acpi/acpidump/acpi_user.c b/usr.sbin/acpi/acpidump/acpi_user.c deleted file mode 100644 index d154849d41..0000000000 --- a/usr.sbin/acpi/acpidump/acpi_user.c +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * Copyright (c) 1999 Doug Rabson - * Copyright (c) 2000 Mitsuru IWASAKI - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/acpi/acpidump/acpi_user.c,v 1.12 2004/05/28 07:25:23 njl Exp $ - * $DragonFly: src/usr.sbin/acpi/acpidump/acpi_user.c,v 1.1 2004/07/05 00:22:43 dillon Exp $ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "acpidump.h" - -static char machdep_acpi_root[] = "machdep.acpi_root"; -static int acpi_mem_fd = -1; - -struct acpi_user_mapping { - LIST_ENTRY(acpi_user_mapping) link; - vm_offset_t pa; - caddr_t va; - size_t size; -}; - -LIST_HEAD(acpi_user_mapping_list, acpi_user_mapping) maplist; - -static void -acpi_user_init(void) -{ - - if (acpi_mem_fd == -1) { - acpi_mem_fd = open("/dev/mem", O_RDONLY); - if (acpi_mem_fd == -1) - err(1, "opening /dev/mem"); - LIST_INIT(&maplist); - } -} - -static struct acpi_user_mapping * -acpi_user_find_mapping(vm_offset_t pa, size_t size) -{ - struct acpi_user_mapping *map; - - /* First search for an existing mapping */ - for (map = LIST_FIRST(&maplist); map; map = LIST_NEXT(map, link)) { - if (map->pa <= pa && map->size >= pa + size - map->pa) - return (map); - } - - /* Then create a new one */ - size = round_page(pa + size) - trunc_page(pa); - pa = trunc_page(pa); - map = malloc(sizeof(struct acpi_user_mapping)); - if (!map) - errx(1, "out of memory"); - map->pa = pa; - map->va = mmap(0, size, PROT_READ, MAP_SHARED, acpi_mem_fd, pa); - map->size = size; - if ((intptr_t) map->va == -1) - err(1, "can't map address"); - LIST_INSERT_HEAD(&maplist, map, link); - - return (map); -} - -static struct ACPIrsdp * -acpi_get_rsdp(u_long addr) -{ - struct ACPIrsdp rsdp; - size_t len; - - /* Read in the table signature and check it. */ - pread(acpi_mem_fd, &rsdp, 8, addr); - if (memcmp(rsdp.signature, "RSD PTR ", 8)) - return (NULL); - - /* Read the entire table. */ - pread(acpi_mem_fd, &rsdp, sizeof(rsdp), addr); - - /* Run the checksum only over the version 1 header. */ - if (acpi_checksum(&rsdp, 20)) - return (NULL); - - /* If the revision is 0, assume a version 1 length. */ - if (rsdp.revision == 0) - len = 20; - else - len = rsdp.length; - - /* XXX Should handle ACPI 2.0 RSDP extended checksum here. */ - - return (acpi_map_physical(addr, len)); -} - -static struct ACPIrsdp * -acpi_scan_rsd_ptr(void) -{ -#if defined(__i386__) - struct ACPIrsdp *rsdp; - u_long addr, end; - - /* - * On ia32, scan physical memory for the RSD PTR if above failed. - * According to section 5.2.2 of the ACPI spec, we only consider - * two regions for the base address: - * 1. EBDA (1 KB area addressed by the 16 bit pointer at 0x40E - * 2. High memory (0xE0000 - 0xFFFFF) - */ - addr = RSDP_EBDA_PTR; - pread(acpi_mem_fd, &addr, sizeof(uint16_t), addr); - addr <<= 4; - end = addr + RSDP_EBDA_SIZE; - for (; addr < end; addr += 16) - if ((rsdp = acpi_get_rsdp(addr)) != NULL) - return (rsdp); - addr = RSDP_HI_START; - end = addr + RSDP_HI_SIZE; - for (; addr < end; addr += 16) - if ((rsdp = acpi_get_rsdp(addr)) != NULL) - return (rsdp); -#endif /* __i386__ */ - return (NULL); -} - -/* - * Public interfaces - */ -struct ACPIrsdp * -acpi_find_rsd_ptr(void) -{ - struct ACPIrsdp *rsdp; - u_long addr; - size_t len; - - acpi_user_init(); - - /* Attempt to use sysctl to find RSD PTR record. */ - len = sizeof(addr); - if (sysctlbyname(machdep_acpi_root, &addr, &len, NULL, 0) == 0) { - if ((rsdp = acpi_get_rsdp(addr)) != NULL) - return (rsdp); - else - warnx("sysctl %s does not point to RSDP", - machdep_acpi_root); - } - - return (acpi_scan_rsd_ptr()); -} - -void * -acpi_map_physical(vm_offset_t pa, size_t size) -{ - struct acpi_user_mapping *map; - - map = acpi_user_find_mapping(pa, size); - return (map->va + (pa - map->pa)); -} - -struct ACPIsdt * -dsdt_load_file(char *infile) -{ - struct ACPIsdt *sdt; - uint8_t *dp; - struct stat sb; - - if ((acpi_mem_fd = open(infile, O_RDONLY)) == -1) - errx(1, "opening %s", infile); - - LIST_INIT(&maplist); - - if (fstat(acpi_mem_fd, &sb) == -1) - errx(1, "fstat %s", infile); - - dp = mmap(0, sb.st_size, PROT_READ, MAP_PRIVATE, acpi_mem_fd, 0); - if (dp == NULL) - errx(1, "mmap %s", infile); - - sdt = (struct ACPIsdt *)dp; - if (strncmp(dp, "DSDT", 4) != 0 || acpi_checksum(sdt, sdt->len) != 0) - return (NULL); - - return (sdt); -} diff --git a/usr.sbin/acpi/acpidump/acpidump.c b/usr.sbin/acpi/acpidump/acpidump.c deleted file mode 100644 index 1afac7b682..0000000000 --- a/usr.sbin/acpi/acpidump/acpidump.c +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * Copyright (c) 2000 Mitsuru IWASAKI - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/acpi/acpidump/acpidump.c,v 1.11 2004/10/05 20:45: 05 njl Exp $ - * $DragonFly: src/usr.sbin/acpi/acpidump/acpidump.c,v 1.3 2007/01/10 08:44:29 hsu Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "acpidump.h" - -int dflag; /* Disassemble AML using iasl(8) */ -int tflag; /* Dump contents of SDT tables */ -int vflag; /* Use verbose messages */ - -static void -usage(const char *progname) -{ - - fprintf(stderr, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] " - "[-o dsdt_output]\n", progname); - exit(1); -} - -int -main(int argc, char *argv[]) -{ - char c, *progname; - char *dsdt_input_file, *dsdt_output_file; - struct ACPIsdt *rsdt, *sdt; - - dsdt_input_file = dsdt_output_file = NULL; - progname = argv[0]; - - if (argc < 2) - usage(progname); - - while ((c = getopt(argc, argv, "dhtvf:o:")) != -1) { - switch (c) { - case 'd': - dflag = 1; - break; - case 't': - tflag = 1; - break; - case 'v': - vflag = 1; - break; - case 'f': - dsdt_input_file = optarg; - break; - case 'o': - dsdt_output_file = optarg; - break; - case 'h': - default: - usage(progname); - /* NOTREACHED */ - } - } - argc -= optind; - argv += optind; - - /* Get input either from file or /dev/mem */ - if (dsdt_input_file != NULL) { - if (dflag == 0 && tflag == 0) { - warnx("Need to specify -d or -t with DSDT input file"); - usage(progname); - } else if (tflag != 0) { - warnx("Can't use -t with DSDT input file"); - usage(progname); - } - if (vflag) - warnx("loading DSDT file: %s", dsdt_input_file); - rsdt = dsdt_load_file(dsdt_input_file); - } else { - if (vflag) - warnx("loading RSD PTR from /dev/mem"); - rsdt = sdt_load_devmem(); - } - - /* Display misc. SDT tables (only available when using /dev/mem) */ - if (tflag) { - if (vflag) - warnx("printing various SDT tables"); - sdt_print_all(rsdt); - } - - /* Translate RSDT to DSDT pointer */ - if (dsdt_input_file == NULL) { - sdt = sdt_from_rsdt(rsdt, "FACP", NULL); - sdt = dsdt_from_fadt((struct FADTbody *)sdt->body); - } else { - sdt = rsdt; - rsdt = NULL; - } - - /* Dump the DSDT to a file */ - if (dsdt_output_file != NULL) { - if (vflag) - warnx("saving DSDT file: %s", dsdt_output_file); - dsdt_save_file(dsdt_output_file, rsdt, sdt); - } - - /* Disassemble the DSDT into ASL */ - if (dflag) { - if (vflag) - warnx("disassembling DSDT, iasl messages follow"); - aml_disassemble(rsdt, sdt); - if (vflag) - warnx("iasl processing complete"); - } - - exit(0); -} diff --git a/usr.sbin/acpi/acpidump/acpidump.h b/usr.sbin/acpi/acpidump/acpidump.h deleted file mode 100644 index 9417ec3af2..0000000000 --- a/usr.sbin/acpi/acpidump/acpidump.h +++ /dev/null @@ -1,418 +0,0 @@ -/*- - * Copyright (c) 1999 Doug Rabson - * Copyright (c) 2000 Mitsuru IWASAKI - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/usr.sbin/acpi/acpidump/acpidump.h,v 1.21 2005/02/17 21:09:26 scottl Exp $ - * $DragonFly: src/usr.sbin/acpi/acpidump/acpidump.h,v 1.4 2007/01/10 12:23:23 hsu Exp $ - */ - -#ifndef _ACPIDUMP_H_ -#define _ACPIDUMP_H_ - -/* Generic Address structure */ -struct ACPIgas { - u_int8_t address_space_id; -#define ACPI_GAS_MEMORY 0 -#define ACPI_GAS_IO 1 -#define ACPI_GAS_PCI 2 -#define ACPI_GAS_EMBEDDED 3 -#define ACPI_GAS_SMBUS 4 -#define ACPI_GAS_CMOS 5 -#define ACPI_GAS_PCIBAR 6 -#define ACPI_GAS_DATATABLE 7 -#define ACPI_GAS_FIXED 0x7f - u_int8_t bit_width; - u_int8_t bit_offset; - u_int8_t _reserved; - u_int64_t address; -} __packed; - -/* Root System Description Pointer */ -struct ACPIrsdp { - u_char signature[8]; - u_char sum; - u_char oem[6]; - u_char revision; - u_int32_t rsdt_addr; - u_int32_t length; - u_int64_t xsdt_addr; - u_char xsum; - u_char _reserved_[3]; -} __packed; - -/* System Description Table */ -struct ACPIsdt { - u_char signature[4]; - u_int32_t len; - u_char rev; - u_char check; - u_char oemid[6]; - u_char oemtblid[8]; - u_int32_t oemrev; - u_char creator[4]; - u_int32_t crerev; -#define SIZEOF_SDT_HDR 36 /* struct size except body */ - u_int32_t body[1]; /* This member should be casted */ -} __packed; - -/* Fixed ACPI Description Table (body) */ -struct FADTbody { - u_int32_t facs_ptr; - u_int32_t dsdt_ptr; - u_int8_t int_model; -#define ACPI_FADT_INTMODEL_PIC 0 /* Standard PC-AT PIC */ -#define ACPI_FADT_INTMODEL_APIC 1 /* Multiple APIC */ - u_int8_t pm_profile; - u_int16_t sci_int; - u_int32_t smi_cmd; - u_int8_t acpi_enable; - u_int8_t acpi_disable; - u_int8_t s4biosreq; - u_int8_t pstate_cnt; - u_int32_t pm1a_evt_blk; - u_int32_t pm1b_evt_blk; - u_int32_t pm1a_cnt_blk; - u_int32_t pm1b_cnt_blk; - u_int32_t pm2_cnt_blk; - u_int32_t pm_tmr_blk; - u_int32_t gpe0_blk; - u_int32_t gpe1_blk; - u_int8_t pm1_evt_len; - u_int8_t pm1_cnt_len; - u_int8_t pm2_cnt_len; - u_int8_t pm_tmr_len; - u_int8_t gpe0_len; - u_int8_t gpe1_len; - u_int8_t gpe1_base; - u_int8_t cst_cnt; - u_int16_t p_lvl2_lat; - u_int16_t p_lvl3_lat; - u_int16_t flush_size; - u_int16_t flush_stride; - u_int8_t duty_off; - u_int8_t duty_width; - u_int8_t day_alrm; - u_int8_t mon_alrm; - u_int8_t century; - u_int16_t iapc_boot_arch; -#define FADT_FLAG_LEGACY_DEV 1 /* System has legacy devices */ -#define FADT_FLAG_8042 2 /* 8042 keyboard controller */ - u_char reserved4[1]; - u_int32_t flags; -#define FADT_FLAG_WBINVD 1 /* WBINVD is correctly supported */ -#define FADT_FLAG_WBINVD_FLUSH 2 /* WBINVD flushes caches */ -#define FADT_FLAG_PROC_C1 4 /* C1 power state supported */ -#define FADT_FLAG_P_LVL2_UP 8 /* C2 power state works on SMP */ -#define FADT_FLAG_PWR_BUTTON 16 /* Power button uses control method */ -#define FADT_FLAG_SLP_BUTTON 32 /* Sleep button uses control method */ -#define FADT_FLAG_FIX_RTC 64 /* RTC wakeup not supported */ -#define FADT_FLAG_RTC_S4 128 /* RTC can wakeup from S4 state */ -#define FADT_FLAG_TMR_VAL_EXT 256 /* TMR_VAL is 32bit */ -#define FADT_FLAG_DCK_CAP 512 /* Can support docking */ -#define FADT_FLAG_RESET_REG 1024 /* Supports RESET_REG */ -#define FADT_FLAG_SEALED_CASE 2048 /* Case cannot be opened */ -#define FADT_FLAG_HEADLESS 4096 /* No monitor */ -#define FADT_FLAG_CPU_SW_SLP 8192 /* Supports CPU software sleep */ -#define FADT_FLAG_PCI_EXPRESS_WAKE (1<<14) /* PCIEXP_WAKE (STS/EN) bits */ -#define FADT_FLAG_PLATFORM_CLOCK (1<<15) /* OSPM should use platform-provided tmr */ -#define FADT_FLAG_S4_RTC_VALID (1<<16) /* RTC_STS valid after S4 wake */ -#define FADT_FLAG_REMOTE_POWER_ON (1<<17) /* System is compat. with remote pwr on */ -#define FADT_FLAG_APIC_CLUSTER (1<<18) /* All local APICs must use cluster model */ -#define FADT_FLAG_APIC_PHYSICAL (1<<19) /*All local xAPICs must use phys dest mode*/ - struct ACPIgas reset_reg; - u_int8_t reset_value; - u_int8_t reserved5[3]; - u_int64_t x_facs_ptr; - u_int64_t x_dsdt_ptr; - struct ACPIgas x_pm1a_evt_blk; - struct ACPIgas x_pm1b_evt_blk; - struct ACPIgas x_pm1a_cnt_blk; - struct ACPIgas x_pm1b_cnt_blk; - struct ACPIgas x_pm2_cnt_blk; - struct ACPIgas x_pm_tmr_blk; - struct ACPIgas x_gpe0_blk; - struct ACPIgas x_gpe1_blk; -} __packed; - -/* Firmware ACPI Control Structure */ -struct FACSbody { - u_char signature[4]; - u_int32_t len; - u_int32_t hw_sig; - /* - * NOTE This should be filled with physical address below 1MB!! - * sigh.... - */ - u_int32_t firm_wake_vec; - u_int32_t global_lock; -#define FACS_FLAG_LOCK_PENDING 1 /* 5.2.6.1 Global Lock */ -#define FACS_FLAG_LOCK_OWNED 2 - u_int32_t flags; -#define FACS_FLAG_S4BIOS_F 1 /* Supports S4BIOS_SEQ */ - u_int64_t x_firm_wake_vec; - u_int8_t version; - char reserved[31]; -} __packed; - -struct MADT_local_apic { - u_char cpu_id; - u_char apic_id; - u_int32_t flags; -#define ACPI_MADT_APIC_LOCAL_FLAG_ENABLED 1 -} __packed; - -struct MADT_io_apic { - u_char apic_id; - u_char reserved; - u_int32_t apic_addr; - u_int32_t int_base; -} __packed; - -struct MADT_int_override { - u_char bus; - u_char source; - u_int32_t intr; - u_int16_t mps_flags; -#define MPS_INT_FLAG_POLARITY_MASK 0x3 -#define MPS_INT_FLAG_POLARITY_CONFORM 0x0 -#define MPS_INT_FLAG_POLARITY_HIGH 0x1 -#define MPS_INT_FLAG_POLARITY_LOW 0x3 -#define MPS_INT_FLAG_TRIGGER_MASK 0xc -#define MPS_INT_FLAG_TRIGGER_CONFORM 0x0 -#define MPS_INT_FLAG_TRIGGER_EDGE 0x4 -#define MPS_INT_FLAG_TRIGGER_LEVEL 0xc -} __packed; - -struct MADT_nmi { - u_int16_t mps_flags; - u_int32_t intr; -} __packed; - -struct MADT_local_nmi { - u_char cpu_id; - u_int16_t mps_flags; - u_char lintpin; -} __packed; - -struct MADT_local_apic_override { - u_char reserved[2]; - u_int64_t apic_addr; -} __packed; - -struct MADT_io_sapic { - u_char apic_id; - u_char reserved; - u_int32_t int_base; - u_int64_t apic_addr; -} __packed; - -struct MADT_local_sapic { - u_char cpu_id; - u_char apic_id; - u_char apic_eid; - u_char reserved[3]; - u_int32_t flags; -} __packed; - -struct MADT_int_src { - u_int16_t mps_flags; - u_char type; -#define ACPI_MADT_APIC_INT_SOURCE_PMI 1 -#define ACPI_MADT_APIC_INT_SOURCE_INIT 2 -#define ACPI_MADT_APIC_INT_SOURCE_CPEI 3 /* Corrected Platform Error */ - u_char cpu_id; - u_char cpu_eid; - u_char sapic_vector; - u_int32_t intr; - u_char reserved[4]; -} __packed; - -struct MADT_APIC { - u_char type; -#define ACPI_MADT_APIC_TYPE_LOCAL_APIC 0 -#define ACPI_MADT_APIC_TYPE_IO_APIC 1 -#define ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2 -#define ACPI_MADT_APIC_TYPE_NMI 3 -#define ACPI_MADT_APIC_TYPE_LOCAL_NMI 4 -#define ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5 -#define ACPI_MADT_APIC_TYPE_IO_SAPIC 6 -#define ACPI_MADT_APIC_TYPE_LOCAL_SAPIC 7 -#define ACPI_MADT_APIC_TYPE_INT_SRC 8 - u_char len; - union { - struct MADT_local_apic local_apic; - struct MADT_io_apic io_apic; - struct MADT_int_override int_override; - struct MADT_nmi nmi; - struct MADT_local_nmi local_nmi; - struct MADT_local_apic_override local_apic_override; - struct MADT_io_sapic io_sapic; - struct MADT_local_sapic local_sapic; - struct MADT_int_src int_src; - } body; -} __packed; - -struct MADTbody { - u_int32_t lapic_addr; - u_int32_t flags; -#define ACPI_APIC_FLAG_PCAT_COMPAT 1 /* System has dual-8259 setup. */ - u_char body[1]; -} __packed; - -struct HPETbody { - u_int32_t block_hwrev:8, - block_comparitors:5, - block_counter_size:1, - :1, - block_legacy_capable:1, - block_pcivendor:16; - u_int32_t base_addr; - u_int64_t reserved1; - u_int8_t hpet_number; - u_int16_t clock_tick __packed; -} __packed; - -/* Embedded Controller Description Table */ -struct ECDTbody { - struct ACPIgas ec_control; /* Control register */ - struct ACPIgas ec_data; /* Data register */ - uint32_t uid; /* Same value as _UID in namespace */ - uint8_t gpe_bit; /* GPE bit for the EC */ - u_char ec_id[1]; /* Variable length name string */ -} __packed; - -/* Memory Mapped PCI config space base allocation structure */ -struct MCFGbody { - uint8_t rsvd[8]; - struct { - uint64_t baseaddr; /* Base Address */ - uint16_t seg_grp; /* Segment group number */ - uint8_t start; /* Starting bus number */ - uint8_t end; /* Ending bus number */ - uint8_t rsvd[4]; /* Reserved */ - } s[1] __packed; -} __packed; - -/* SRAT - System Resource Affinity Table */ - -struct SRAT_cpu_affinity { - uint8_t proximity_domain_lo; - uint8_t apic_id; - uint32_t flags; - uint8_t local_sapic_eid; - uint8_t proximity_domain_hi[3]; - uint32_t reserved; /* must be zero */ -}; - -#define ACPI_SRAT_FLAG_CPU_ENABLED 1 - -struct SRAT_mem_affinity -{ - uint32_t proximity_domain; - uint16_t reserved; /* must be zero */ - uint64_t base_address; - uint64_t length; - uint32_t reserved1; -#define ACPI_SRAT_FLAG_MEM_ENABLED 1 -#define ACPI_SRAT_FLAG_MEM_HOT_PLUGGABLE 2 -#define ACPI_SRAT_FLAG_MEM_NON_VOLATILE 4 - uint32_t flags; - uint64_t reserved2; /* must be zero */ - -}; - -struct SRAT_x2apic_cpu_affinity -{ - uint16_t reserved; /* must be zero */ - uint32_t proximity_domain; - uint32_t apic_id; - uint32_t flags; - uint32_t clock_domain; - uint32_t reserved2; -}; - -struct SRAT_APIC { - u_char type; -#define ACPI_SRAT_APIC_TYPE_CPU_AFFINITY 0 -#define ACPI_SRAT_APIC_TYPE_MEMORY_AFFINITY 1 -#define ACPI_SRAT_APIC_TYPE_X2APIC_CPU_AFFINITY 2 -#define ACPI_SRAT_APIC_TYPE_RESERVED 3 - u_char len; - union { - struct SRAT_cpu_affinity cpu_affinity; - struct SRAT_mem_affinity mem_affinity; - struct SRAT_x2apic_cpu_affinity x2apic_cpu_affinity; - } body; -} __packed; - -struct SRATbody { - u_int32_t revision; - u_int64_t reserved; - u_char body[1]; -} __packed; - -/* - * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2 - * of the ACPI spec, we only consider two regions for the base address: - * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E) - * 2. High memory (0xE0000 - 0xFFFFF) - */ -#define RSDP_EBDA_PTR 0x40E -#define RSDP_EBDA_SIZE 0x400 -#define RSDP_HI_START 0xE0000 -#define RSDP_HI_SIZE 0x20000 - -/* Find and map the RSD PTR structure and return it for parsing */ -struct ACPIsdt *sdt_load_devmem(void); - -/* - * Load the DSDT from a previous save file. Note that other tables are - * not saved (i.e. FADT) - */ -struct ACPIsdt *dsdt_load_file(char *); - -/* Save the DSDT to a file */ -void dsdt_save_file(char *, struct ACPIsdt *, struct ACPIsdt *); - -/* Print out as many fixed tables as possible, given the RSD PTR */ -void sdt_print_all(struct ACPIsdt *); - -/* Disassemble the AML in the DSDT */ -void aml_disassemble(struct ACPIsdt *, struct ACPIsdt *); - -/* Routines for accessing tables in physical memory */ -struct ACPIrsdp *acpi_find_rsd_ptr(void); -void *acpi_map_physical(vm_offset_t, size_t); -struct ACPIsdt *sdt_from_rsdt(struct ACPIsdt *, const char *, - struct ACPIsdt *); -struct ACPIsdt *dsdt_from_fadt(struct FADTbody *); -int acpi_checksum(void *, size_t); - -/* Command line flags */ -extern int dflag; -extern int tflag; -extern int vflag; - -#endif /* !_ACPIDUMP_H_ */ diff --git a/usr.sbin/acpi/acpidump/osdragonflytbl.c b/usr.sbin/acpi/acpidump/osdragonflytbl.c new file mode 100644 index 0000000000..103077cffd --- /dev/null +++ b/usr.sbin/acpi/acpidump/osdragonflytbl.c @@ -0,0 +1,904 @@ +/****************************************************************************** + * + * Module Name: osdragonflytbl - DragonFly OSL for obtaining ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpidump.h" + +#if 0 /* see XXX below */ +#include +#endif +#include +#include +#include + + +#define _COMPONENT ACPI_OS_SERVICES + ACPI_MODULE_NAME ("osdragonflytbl") + + +/* Local prototypes */ + +static ACPI_STATUS +OslTableInitialize ( + void); + +static ACPI_STATUS +OslMapTable ( + ACPI_SIZE Address, + char *Signature, + ACPI_TABLE_HEADER **Table); + +static ACPI_STATUS +OslAddTablesToList ( + void); + +static ACPI_STATUS +OslGetTableViaRoot ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address); + + +/* Hints for RSDP */ + +#define SYSTEM_KENV "hint.acpi.0.rsdp" +#define SYSTEM_SYSCTL "machdep.acpi_root" + +/* Initialization flags */ + +UINT8 Gbl_TableListInitialized = FALSE; +UINT8 Gbl_MainTableObtained = FALSE; + +/* Local copies of main ACPI tables */ + +ACPI_TABLE_RSDP Gbl_Rsdp; +ACPI_TABLE_FADT *Gbl_Fadt; +ACPI_TABLE_RSDT *Gbl_Rsdt; +ACPI_TABLE_XSDT *Gbl_Xsdt; + +/* Fadt address */ + +ACPI_PHYSICAL_ADDRESS Gbl_FadtAddress; + +/* Revision of RSD PTR */ + +UINT8 Gbl_Revision; + +/* List of information about obtained ACPI tables */ + +typedef struct table_info +{ + struct table_info *Next; + char Signature[4]; + UINT32 Instance; + ACPI_PHYSICAL_ADDRESS Address; + +} OSL_TABLE_INFO; + +OSL_TABLE_INFO *Gbl_TableListHead = NULL; + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByAddress + * + * PARAMETERS: Address - Physical address of the ACPI table + * Table - Where a pointer to the table is returned + * + * RETURN: Status; Table buffer is returned if AE_OK. + * AE_NOT_FOUND: A valid table was not found at the address + * + * DESCRIPTION: Get an ACPI table via a physical memory address. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByAddress ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER **Table) +{ + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *LocalTable; + ACPI_STATUS Status; + + + /* Validate the input physical address to avoid program crash */ + + if (Address < ACPI_HI_RSDP_WINDOW_BASE) + { + fprintf (stderr, "Invalid table address: 0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Address)); + return (AE_BAD_ADDRESS); + } + + /* Map the table and validate it */ + + Status = OslMapTable (Address, NULL, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Copy table to local buffer and return it */ + + LocalTable = calloc (1, MappedTable->Length); + if (!LocalTable) + { + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (LocalTable, MappedTable, MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + + *Table = LocalTable; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByName + * + * PARAMETERS: Signature - ACPI Signature for desired table. Must be + * a null terminated 4-character string. + * Instance - Multiple table support for SSDT/UEFI (0...n) + * Must be 0 for other tables. + * Table - Where a pointer to the table is returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Instance is beyond valid limit + * AE_NOT_FOUND: A table with the signature was not found + * + * NOTE: Assumes the input signature is uppercase. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByName ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) +{ + ACPI_STATUS Status; + + + /* Instance is only valid for SSDT/UEFI tables */ + + if (Instance && + !ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) && + !ACPI_COMPARE_NAME (Signature, ACPI_SIG_UEFI)) + { + return (AE_LIMIT); + } + + /* Initialize main tables */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * If one of the main ACPI tables was requested (RSDT/XSDT/FADT), + * simply return it immediately. + */ + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_XSDT)) + { + if (!Gbl_Revision) + { + return (AE_NOT_FOUND); + } + + *Address = Gbl_Rsdp.XsdtPhysicalAddress; + *Table = (ACPI_TABLE_HEADER *) Gbl_Xsdt; + return (AE_OK); + } + + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDT)) + { + if (!Gbl_Rsdp.RsdtPhysicalAddress) + { + return (AE_NOT_FOUND); + } + + *Address = Gbl_Rsdp.RsdtPhysicalAddress; + *Table = (ACPI_TABLE_HEADER *) Gbl_Rsdt; + return (AE_OK); + } + + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FADT)) + { + *Address = Gbl_FadtAddress; + *Table = (ACPI_TABLE_HEADER *) Gbl_Fadt; + return (AE_OK); + } + + /* Not a main ACPI table, attempt to extract it from the RSDT/XSDT */ + + Status = OslGetTableViaRoot (Signature, Instance, Table, Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByIndex + * + * PARAMETERS: Index - Which table to get + * Table - Where a pointer to the table is returned + * Instance - Where a pointer to the table instance no. is + * returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Index is beyond valid limit + * + * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns + * AE_LIMIT when an invalid index is reached. Index is not + * necessarily an index into the RSDT/XSDT. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByIndex ( + UINT32 Index, + ACPI_TABLE_HEADER **Table, + UINT32 *Instance, + ACPI_PHYSICAL_ADDRESS *Address) +{ + OSL_TABLE_INFO *Info; + ACPI_STATUS Status; + UINT32 i; + + + /* Initialize main tables */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Add all tables to list */ + + Status = OslAddTablesToList (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Validate Index */ + + if (Index >= Gbl_TableListHead->Instance) + { + return (AE_LIMIT); + } + + /* Point to the table list entry specified by the Index argument */ + + Info = Gbl_TableListHead; + for (i = 0; i <= Index; i++) + { + Info = Info->Next; + } + + /* Now we can just get the table via the address or name */ + + if (Info->Address) + { + Status = AcpiOsGetTableByAddress (Info->Address, Table); + if (ACPI_SUCCESS (Status)) + { + *Address = Info->Address; + } + } + else + { + Status = AcpiOsGetTableByName (Info->Signature, Info->Instance, + Table, Address); + } + + if (ACPI_SUCCESS (Status)) + { + *Instance = Info->Instance; + } + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: OslTableInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize ACPI table data. Get and store main ACPI tables to + * local variables. Main ACPI tables include RSDP, FADT, RSDT, + * and/or XSDT. + * + *****************************************************************************/ + +static ACPI_STATUS +OslTableInitialize ( + void) +{ +#if 0 /* see XXX below */ + char Buffer[32]; +#endif + ACPI_TABLE_HEADER *MappedTable; + UINT8 *TableAddress; + UINT8 *RsdpAddress; + ACPI_PHYSICAL_ADDRESS RsdpBase; + ACPI_SIZE RsdpSize; + ACPI_STATUS Status; + u_long Address = 0; + size_t Length = sizeof (Address); + + + /* Get main ACPI tables from memory on first invocation of this function */ + + if (Gbl_MainTableObtained) + { + return (AE_OK); + } + + /* Attempt to use kenv or sysctl to find RSD PTR record. */ + + if (Gbl_RsdpBase) + { + Address = Gbl_RsdpBase; + } +#if 0 /* XXX: Either import kenv(2) or scan the list a la kenv(1) */ + else if (kenv (KENV_GET, SYSTEM_KENV, Buffer, sizeof (Buffer)) > 0) + { + Address = ACPI_STRTOUL (Buffer, NULL, 0); + } +#endif + if (!Address) + { + if (sysctlbyname (SYSTEM_SYSCTL, &Address, &Length, NULL, 0) != 0) + { + Address = 0; + } + } + if (Address) + { + RsdpBase = Address; + RsdpSize = sizeof (Gbl_Rsdp); + } + else + { + RsdpBase = ACPI_HI_RSDP_WINDOW_BASE; + RsdpSize = ACPI_HI_RSDP_WINDOW_SIZE; + } + + /* Get RSDP from memory */ + + RsdpAddress = AcpiOsMapMemory (RsdpBase, RsdpSize); + if (!RsdpAddress) + { + return (AE_BAD_ADDRESS); + } + + /* Search low memory for the RSDP */ + + TableAddress = AcpiTbScanMemoryForRsdp (RsdpAddress, RsdpSize); + if (!TableAddress) + { + AcpiOsUnmapMemory (RsdpAddress, RsdpSize); + return (AE_ERROR); + } + + ACPI_MEMCPY (&Gbl_Rsdp, TableAddress, sizeof (Gbl_Rsdp)); + AcpiOsUnmapMemory (RsdpAddress, RsdpSize); + + /* Get XSDT from memory */ + + if (Gbl_Rsdp.Revision) + { + Status = OslMapTable (Gbl_Rsdp.XsdtPhysicalAddress, + ACPI_SIG_XSDT, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Gbl_Revision = 2; + Gbl_Xsdt = calloc (1, MappedTable->Length); + if (!Gbl_Xsdt) + { + fprintf (stderr, + "XSDT: Could not allocate buffer for table of length %X\n", + MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Gbl_Xsdt, MappedTable, MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + } + + /* Get RSDT from memory */ + + if (Gbl_Rsdp.RsdtPhysicalAddress) + { + Status = OslMapTable (Gbl_Rsdp.RsdtPhysicalAddress, + ACPI_SIG_RSDT, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Gbl_Rsdt = calloc (1, MappedTable->Length); + if (!Gbl_Rsdt) + { + fprintf (stderr, + "RSDT: Could not allocate buffer for table of length %X\n", + MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Gbl_Rsdt, MappedTable, MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + } + + /* Get FADT from memory */ + + if (Gbl_Revision) + { + Gbl_FadtAddress = Gbl_Xsdt->TableOffsetEntry[0]; + } + else + { + Gbl_FadtAddress = Gbl_Rsdt->TableOffsetEntry[0]; + } + + if (!Gbl_FadtAddress) + { + fprintf(stderr, "FADT: Table could not be found\n"); + return (AE_ERROR); + } + + Status = OslMapTable (Gbl_FadtAddress, ACPI_SIG_FADT, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Gbl_Fadt = calloc (1, MappedTable->Length); + if (!Gbl_Fadt) + { + fprintf (stderr, + "FADT: Could not allocate buffer for table of length %X\n", + MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Gbl_Fadt, MappedTable, MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + Gbl_MainTableObtained = TRUE; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslGetTableViaRoot + * + * PARAMETERS: Signature - ACPI Signature for common table. Must be + * a null terminated 4-character string. + * Instance - Multiple table support for SSDT/UEFI (0...n) + * Must be 0 for other tables. + * Table - Where a pointer to the table is returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Instance is beyond valid limit + * AE_NOT_FOUND: A table with the signature was not found + * + * DESCRIPTION: Get an ACPI table via the root table (RSDT/XSDT) + * + * NOTE: Assumes the input signature is uppercase. + * + *****************************************************************************/ + +static ACPI_STATUS +OslGetTableViaRoot ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) +{ + ACPI_TABLE_HEADER *LocalTable = NULL; + ACPI_TABLE_HEADER *MappedTable = NULL; + UINT8 NumberOfTables; + UINT32 CurrentInstance = 0; + ACPI_PHYSICAL_ADDRESS TableAddress = 0; + ACPI_STATUS Status; + UINT32 i; + + + /* DSDT and FACS address must be extracted from the FADT */ + + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) + { + /* + * Get the appropriate address, either 32-bit or 64-bit. Be very + * careful about the FADT length and validate table addresses. + * Note: The 64-bit addresses have priority. + */ + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) + { + if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XDSDT) && + Gbl_Fadt->XDsdt) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XDsdt; + } + else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_DSDT) && + Gbl_Fadt->Dsdt) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Dsdt; + } + } + else /* FACS */ + { + if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XFACS) && + Gbl_Fadt->XFacs) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XFacs; + } + else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_FACS) && + Gbl_Fadt->Facs) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Facs; + } + } + } + else /* Case for a normal ACPI table */ + { + if (Gbl_Revision) + { + NumberOfTables = + (Gbl_Xsdt->Header.Length - sizeof (Gbl_Xsdt->Header)) + / sizeof (Gbl_Xsdt->TableOffsetEntry[0]); + } + else /* Use RSDT if XSDT is not available */ + { + NumberOfTables = + (Gbl_Rsdt->Header.Length - sizeof (Gbl_Rsdt->Header)) + / sizeof (Gbl_Rsdt->TableOffsetEntry[0]); + } + + /* Search RSDT/XSDT for the requested table */ + + for (i = 0; i < NumberOfTables; i++) + { + if (Gbl_Revision) + { + TableAddress = Gbl_Xsdt->TableOffsetEntry[i]; + } + else + { + TableAddress = Gbl_Rsdt->TableOffsetEntry[i]; + } + + MappedTable = AcpiOsMapMemory (TableAddress, sizeof (*MappedTable)); + if (!MappedTable) + { + return (AE_BAD_ADDRESS); + } + + /* Does this table match the requested signature? */ + + if (ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) + { + + /* Match table instance (for SSDT/UEFI tables) */ + + if (CurrentInstance == Instance) + { + AcpiOsUnmapMemory (MappedTable, sizeof (*MappedTable)); + break; + } + + CurrentInstance++; + } + + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + TableAddress = 0; + } + } + + if (!TableAddress) + { + if (CurrentInstance) + { + return (AE_LIMIT); + } + return (AE_NOT_FOUND); + } + + /* Now we can get the requested table */ + + Status = OslMapTable (TableAddress, Signature, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Copy table to local buffer and return it */ + + LocalTable = calloc (1, MappedTable->Length); + if (!LocalTable) + { + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (LocalTable, MappedTable, MappedTable->Length); + AcpiOsUnmapMemory (MappedTable, MappedTable->Length); + *Table = LocalTable; + *Address = TableAddress; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslAddTablesToList + * + * PARAMETERS: None + * + * RETURN: Status; Table list is initialized if AE_OK. + * + * DESCRIPTION: Add ACPI tables to the table list. + * + *****************************************************************************/ + +static ACPI_STATUS +OslAddTablesToList( + void) +{ + ACPI_PHYSICAL_ADDRESS TableAddress; + OSL_TABLE_INFO *Info = NULL; + OSL_TABLE_INFO *NewInfo; + ACPI_TABLE_HEADER *Table; + UINT8 Instance; + UINT8 NumberOfTables; + int i; + + + /* Initialize the table list on first invocation */ + + if (Gbl_TableListInitialized) + { + return (AE_OK); + } + + /* Add mandatory tables to global table list first */ + + for (i = 0; i < 4; i++) + { + NewInfo = calloc (1, sizeof (*NewInfo)); + if (!NewInfo) + { + return (AE_NO_MEMORY); + } + + switch (i) { + case 0: + + Gbl_TableListHead = Info = NewInfo; + continue; + + case 1: + + ACPI_MOVE_NAME (NewInfo->Signature, + Gbl_Revision ? ACPI_SIG_XSDT : ACPI_SIG_RSDT); + break; + + case 2: + + ACPI_MOVE_NAME (NewInfo->Signature, ACPI_SIG_FACS); + break; + + default: + + ACPI_MOVE_NAME (NewInfo->Signature, ACPI_SIG_DSDT); + + } + + Info->Next = NewInfo; + Info = NewInfo; + Gbl_TableListHead->Instance++; + } + + /* Add normal tables from RSDT/XSDT to global list */ + + if (Gbl_Revision) + { + NumberOfTables = + (Gbl_Xsdt->Header.Length - sizeof (Gbl_Xsdt->Header)) + / sizeof (Gbl_Xsdt->TableOffsetEntry[0]); + } + else + { + NumberOfTables = + (Gbl_Rsdt->Header.Length - sizeof (Gbl_Rsdt->Header)) + / sizeof (Gbl_Rsdt->TableOffsetEntry[0]); + } + + for (i = 0; i < NumberOfTables; i++) + { + if (Gbl_Revision) + { + TableAddress = Gbl_Xsdt->TableOffsetEntry[i]; + } + else + { + TableAddress = Gbl_Rsdt->TableOffsetEntry[i]; + } + + Table = AcpiOsMapMemory (TableAddress, sizeof (*Table)); + if (!Table) + { + return (AE_BAD_ADDRESS); + } + + Instance = 0; + NewInfo = Gbl_TableListHead; + while (NewInfo->Next != NULL) + { + NewInfo = NewInfo->Next; + if (ACPI_COMPARE_NAME (Table->Signature, NewInfo->Signature)) + { + Instance++; + } + } + + NewInfo = calloc (1, sizeof (*NewInfo)); + if (!NewInfo) + { + AcpiOsUnmapMemory (Table, sizeof (*Table)); + return (AE_NO_MEMORY); + } + + ACPI_MOVE_NAME (NewInfo->Signature, Table->Signature); + + AcpiOsUnmapMemory (Table, sizeof (*Table)); + + NewInfo->Instance = Instance; + NewInfo->Address = TableAddress; + Info->Next = NewInfo; + Info = NewInfo; + Gbl_TableListHead->Instance++; + } + + Gbl_TableListInitialized = TRUE; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslMapTable + * + * PARAMETERS: Address - Address of the table in memory + * Signature - Optional ACPI Signature for desired table. + * Null terminated 4-character string. + * Table - Where a pointer to the mapped table is + * returned + * + * RETURN: Status; Mapped table is returned if AE_OK. + * + * DESCRIPTION: Map entire ACPI table into caller's address space. Also + * validates the table and checksum. + * + *****************************************************************************/ + +static ACPI_STATUS +OslMapTable ( + ACPI_SIZE Address, + char *Signature, + ACPI_TABLE_HEADER **Table) +{ + ACPI_TABLE_HEADER *MappedTable; + UINT32 Length; + + + /* Map the header so we can get the table length */ + + MappedTable = AcpiOsMapMemory (Address, sizeof (*MappedTable)); + if (!MappedTable) + { + return (AE_BAD_ADDRESS); + } + + /* Check if table is valid */ + + if (!ApIsValidHeader (MappedTable)) + { + AcpiOsUnmapMemory (MappedTable, sizeof (*MappedTable)); + return (AE_BAD_HEADER); + } + + /* If specified, signature must match */ + + if (Signature && + !ACPI_COMPARE_NAME (Signature, MappedTable->Signature)) + { + AcpiOsUnmapMemory (MappedTable, sizeof (*MappedTable)); + return (AE_NOT_EXIST); + } + + /* Map the entire table */ + + Length = MappedTable->Length; + AcpiOsUnmapMemory (MappedTable, sizeof (*MappedTable)); + + MappedTable = AcpiOsMapMemory (Address, Length); + if (!MappedTable) + { + return (AE_BAD_ADDRESS); + } + + (void) ApIsValidChecksum (MappedTable); + + *Table = MappedTable; + + return (AE_OK); +} diff --git a/usr.sbin/acpi/acpiexec/Makefile b/usr.sbin/acpi/acpiexec/Makefile new file mode 100644 index 0000000000..fec21c759c --- /dev/null +++ b/usr.sbin/acpi/acpiexec/Makefile @@ -0,0 +1,207 @@ +# +# acpiexec: ACPI execution simulator. Runs ACPICA code in user +# space. Loads ACPI tables, displays the namespace, and allows +# execution of control methods. +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpiexec + +.PATH: ${UTILDIR} + +PROG= acpiexec +NOMAN= + +SRCS= \ + aeexec.c \ + aehandlers.c \ + aemain.c \ + aetables.c + +SRCS+= \ + acgetline.c \ + dbcmds.c \ + dbconvert.c \ + dbdisply.c \ + dbexec.c \ + dbfileio.c \ + dbhistry.c \ + dbinput.c \ + dbmethod.c \ + dbnames.c \ + dbstats.c \ + dbutils.c \ + dbxface.c \ + dmbuffer.c \ + dmdeferred.c \ + dmnames.c \ + dmobject.c \ + dmopcode.c \ + dmresrc.c \ + dmresrcl.c \ + dmresrcl2.c \ + dmresrcs.c \ + dmutils.c \ + dmwalk.c \ + dsargs.c \ + dscontrol.c \ + dsfield.c \ + dsinit.c \ + dsmethod.c \ + dsmthdat.c \ + dsobject.c \ + dsopcode.c \ + dsutils.c \ + dswexec.c \ + dswload.c \ + dswload2.c \ + dswscope.c \ + dswstate.c \ + evevent.c \ + evglock.c \ + evgpe.c \ + evgpeblk.c \ + evgpeinit.c \ + evgpeutil.c \ + evhandler.c \ + evmisc.c \ + evregion.c \ + evrgnini.c \ + evsci.c \ + evxface.c \ + evxfevnt.c \ + evxfgpe.c \ + evxfregn.c \ + exconfig.c \ + exconvrt.c \ + excreate.c \ + exdebug.c \ + exdump.c \ + exfield.c \ + exfldio.c \ + exmisc.c \ + exmutex.c \ + exnames.c \ + exoparg1.c \ + exoparg2.c \ + exoparg3.c \ + exoparg6.c \ + exprep.c \ + exregion.c \ + exresnte.c \ + exresolv.c \ + exresop.c \ + exstore.c \ + exstoren.c \ + exstorob.c \ + exsystem.c \ + exutils.c \ + getopt.c \ + hwacpi.c \ + hwesleep.c \ + hwgpe.c \ + hwpci.c \ + hwregs.c \ + hwsleep.c \ + hwvalid.c \ + hwxface.c \ + hwxfsleep.c \ + nsaccess.c \ + nsalloc.c \ + nsarguments.c \ + nsconvert.c \ + nsdump.c \ + nsdumpdv.c \ + nseval.c \ + nsinit.c \ + nsload.c \ + nsnames.c \ + nsobject.c \ + nsparse.c \ + nspredef.c \ + nsprepkg.c \ + nsrepair.c \ + nsrepair2.c \ + nssearch.c \ + nsutils.c \ + nswalk.c \ + nsxfeval.c \ + nsxfname.c \ + nsxfobj.c \ + osunixxf.c \ + psargs.c \ + psloop.c \ + psobject.c \ + psopcode.c \ + psopinfo.c \ + psparse.c \ + psscope.c \ + pstree.c \ + psutils.c \ + pswalk.c \ + psxface.c \ + rsaddr.c \ + rscalc.c \ + rscreate.c \ + rsdump.c \ + rsdumpinfo.c \ + rsinfo.c \ + rsio.c \ + rsirq.c \ + rslist.c \ + rsmemory.c \ + rsmisc.c \ + rsserial.c \ + rsutils.c \ + rsxface.c \ + tbfadt.c \ + tbfind.c \ + tbinstal.c \ + tbprint.c \ + tbutils.c \ + tbxface.c \ + tbxfload.c \ + tbxfroot.c \ + utaddress.c \ + utalloc.c \ + utbuffer.c \ + utcache.c \ + utcopy.c \ + utdebug.c \ + utdecode.c \ + utdelete.c \ + uterror.c \ + uteval.c \ + utexcep.c \ + utglobal.c \ + utids.c \ + utinit.c \ + utlock.c \ + utmath.c \ + utmisc.c \ + utmutex.c \ + utobject.c \ + utosi.c \ + utownerid.c \ + utpredef.c \ + utresrc.c \ + utstate.c \ + utstring.c \ + uttrack.c \ + utxface.c \ + utxferror.c \ + utxfinit.c \ + utxfmutex.c + +CFLAGS+= \ + -DACPI_EXEC_APP \ + -I${UTILDIR} + +#ifeq ($(ASLTS),TRUE) +#CFLAGS += \ +# -DACPI_CHECKSUM_ABORT=TRUE +#endif + +LDADD+= -lpthread +DPADD+= ${LIBPTHREAD} + +.include diff --git a/usr.sbin/acpi/acpihelp/Makefile b/usr.sbin/acpi/acpihelp/Makefile new file mode 100644 index 0000000000..a826952674 --- /dev/null +++ b/usr.sbin/acpi/acpihelp/Makefile @@ -0,0 +1,30 @@ +# +# acpihelp - ACPI Help utility. Displays ASL operator syntax and +# information about ACPI predefined names. +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpihelp + +.PATH: ${UTILDIR} + +PROG= acpihelp +NOMAN= + +SRCS= \ + ahamlops.c \ + ahaslkey.c \ + ahaslops.c \ + ahdecode.c \ + ahpredef.c \ + ahmain.c + +SRCS+= \ + getopt.c \ + utexcep.c \ + utpredef.c + +CFLAGS+= \ + -DACPI_HELP_APP \ + -I${UTILDIR} + +.include diff --git a/usr.sbin/acpi/acpinames/Makefile b/usr.sbin/acpi/acpinames/Makefile new file mode 100644 index 0000000000..dccb5ae817 --- /dev/null +++ b/usr.sbin/acpi/acpinames/Makefile @@ -0,0 +1,95 @@ +# +# acpinames - Load ACPI table and dump namespace. This is a subset +# of the AcpiExec functionality, it is intended to demonstrate +# the configurability of ACPICA. +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpinames + +.PATH: ${UTILDIR} + +PROG= acpinames +NOMAN= + +SRCS= \ + anmain.c \ + anstubs.c \ + antables.c + +SRCS+= \ + dbfileio.c \ + dsfield.c \ + dsmthdat.c \ + dsobject.c \ + dsutils.c \ + dswload.c \ + dswload2.c \ + dswscope.c \ + dswstate.c \ + excreate.c \ + exnames.c \ + exresnte.c \ + exresolv.c \ + exutils.c \ + getopt.c \ + nsaccess.c \ + nsalloc.c \ + nsdump.c \ + nsinit.c \ + nsload.c \ + nsnames.c \ + nsobject.c \ + nsparse.c \ + nssearch.c \ + nsutils.c \ + nswalk.c \ + nsxfeval.c \ + nsxfname.c \ + nsxfobj.c \ + osunixxf.c \ + psargs.c \ + psloop.c \ + psobject.c \ + psopcode.c \ + psopinfo.c \ + psparse.c \ + psscope.c \ + pstree.c \ + psutils.c \ + pswalk.c \ + psxface.c \ + tbfadt.c \ + tbfind.c \ + tbinstal.c \ + tbprint.c \ + tbutils.c \ + tbxface.c \ + tbxfload.c \ + tbxfroot.c \ + utaddress.c \ + utalloc.c \ + utcache.c \ + utdebug.c \ + utdecode.c \ + utdelete.c \ + uterror.c \ + utexcep.c \ + utglobal.c \ + utlock.c \ + utmath.c \ + utmisc.c \ + utmutex.c \ + utobject.c \ + utosi.c \ + utownerid.c \ + utstate.c \ + utstring.c \ + utxface.c \ + utxferror.c \ + utxfinit.c + +CFLAGS+= \ + -DACPI_NAMES_APP \ + -I${UTILDIR} + +.include diff --git a/usr.sbin/acpi/acpisrc/Makefile b/usr.sbin/acpi/acpisrc/Makefile new file mode 100644 index 0000000000..769261ea3a --- /dev/null +++ b/usr.sbin/acpi/acpisrc/Makefile @@ -0,0 +1,29 @@ +# +# acpisrc - ACPICA source code conversion utility +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpisrc + +.PATH: ${UTILDIR} + +PROG= acpisrc +NOMAN= + +SRCS= \ + ascase.c \ + asconvrt.c \ + asfile.c \ + asmain.c \ + asremove.c \ + astable.c \ + asutils.c + +SRCS+= \ + osunixdir.c \ + getopt.c + +CFLAGS+= \ + -DACPI_SRC_APP \ + -I${UTILDIR} + +.include diff --git a/usr.sbin/acpi/acpixtract/Makefile b/usr.sbin/acpi/acpixtract/Makefile new file mode 100644 index 0000000000..5e30a79888 --- /dev/null +++ b/usr.sbin/acpi/acpixtract/Makefile @@ -0,0 +1,23 @@ +# +# acpixtract - extract binary ACPI tables from acpidump text output +# + +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/tools/acpixtract + +.PATH: ${UTILDIR} + +PROG= acpixtract +NOMAN= + +SRCS= \ + acpixtract.c \ + axmain.c + +SRCS+= \ + getopt.c + +CFLAGS+= \ + -DACPI_XTRACT_APP \ + -I${UTILDIR} + +.include diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile index c7323a9799..9c00601bb1 100644 --- a/usr.sbin/acpi/iasl/Makefile +++ b/usr.sbin/acpi/iasl/Makefile @@ -1,53 +1,189 @@ -# $FreeBSD: src/usr.sbin/acpi/iasl/Makefile,v 1.5 2004/01/13 20:53:56 ru Exp $ -# $DragonFly: src/usr.sbin/acpi/iasl/Makefile,v 1.2 2007/01/17 17:31:20 y0netan1 Exp $ +# +# iASL compiler/disassembler +# -PROG= iasl -SRCS= aslcompiler.y.h aslcompilerlex.c aslcompilerparse.c \ - aslanalyze.c aslbtypes.c aslwalks.c aslcodegen.c \ - aslcompile.c aslerror.c aslfiles.c asllength.c \ - asllisting.c aslload.c asllookup.c aslmain.c \ - aslmap.c aslopcodes.c asloperands.c aslstartup.c aslresource.c \ - aslrestype1.c aslrestype2.c asltree.c aslutils.c \ - asltransform.c aslfold.c aslstubs.c aslopt.c \ - aslpredef.c asluuid.c aslrestype1i.c aslrestype2d.c aslrestype2e.c \ - aslrestype2q.c aslrestype2w.c - -SRCS+= adisasm.c getopt.c osunixxf.c -SRCS+= dbfileio.c dmbuffer.c dmnames.c dmopcode.c dmobject.c \ - dmresrc.c dmresrcl.c dmresrcs.c dmutils.c dmwalk.c dmextern.c \ - dsopcode.c dsargs.c dscontrol.c dsutils.c dswexec.c dswload.c \ - dswscope.c dswstate.c dsfield.c dsobject.c dswload2.c \ - exconvrt.c excreate.c exdump.c exmisc.c \ - exmutex.c exnames.c exoparg1.c exoparg2.c \ - exoparg3.c exoparg6.c exprep.c exregion.c \ - exresnte.c exresolv.c exresop.c exstore.c \ - exstoren.c exstorob.c exsystem.c exutils.c \ - nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \ - nsparse.c nssearch.c nsutils.c nswalk.c nsxfobj.c \ - psargs.c psopcode.c psparse.c psscope.c \ - pstree.c psutils.c pswalk.c \ - tbfadt.c tbinstal.c tbutils.c tbxface.c \ - utalloc.c utcopy.c utdebug.c utdelete.c utinit.c \ - utglobal.c utobject.c utlock.c utmisc.c utmath.c utdecode.c \ - utxface.c utxferror.c \ - dttemplate.c dtcompile.c dtsubtable.c dtutils.c dtfield.c dtio.c dttable.c dtexpress.c \ - dtparser.y.h dtparserlex.c dtparserparse.c - -SRCS+= adfile.c adwalk.c dmrestag.c dmtbdump.c dmtbinfo.c dmtable.c psloop.c utcache.c utmutex.c utresrc.c utstate.c +UTILDIR=${.CURDIR}/../../../sys/contrib/dev/acpica/source/compiler + +.PATH: ${UTILDIR} +PROG= iasl MAN= iasl.8 -CFLAGS+= -DACPI_ASL_COMPILER -I. -LFLAGS= -i -s -YFLAGS= -d +SRCS= \ + aslcompiler.y.h \ + aslcompilerlex.c \ + aslcompilerparse.c \ + dtparser.y.h \ + dtparserlex.c \ + dtparserparse.c \ + prparser.y.h \ + prparserlex.c \ + prparserparse.c \ + adfile.c \ + adisasm.c \ + adwalk.c \ + ahpredef.c \ + aslanalyze.c \ + aslbtypes.c \ + aslcodegen.c \ + aslcompile.c \ + aslerror.c \ + aslfiles.c \ + aslfileio.c \ + aslfold.c \ + aslhex.c \ + asllength.c \ + asllisting.c \ + asllistsup.c \ + aslload.c \ + asllookup.c \ + aslmain.c \ + aslmap.c \ + aslmethod.c \ + aslnamesp.c \ + asloffset.c \ + aslopcodes.c \ + asloperands.c \ + aslopt.c \ + asloptions.c \ + aslpredef.c \ + aslprepkg.c \ + aslresource.c \ + aslrestype1.c \ + aslrestype1i.c \ + aslrestype2.c \ + aslrestype2d.c \ + aslrestype2e.c \ + aslrestype2q.c \ + aslrestype2s.c \ + aslrestype2w.c \ + aslstartup.c \ + aslstubs.c \ + asltransform.c \ + asltree.c \ + aslutils.c \ + asluuid.c \ + aslwalks.c \ + aslxref.c \ + dtcompile.c \ + dtexpress.c \ + dtfield.c \ + dtio.c \ + dtsubtable.c \ + dttable.c \ + dttemplate.c \ + dtutils.c \ + dbfileio.c \ + dmbuffer.c \ + dmdeferred.c \ + dmextern.c \ + dmnames.c \ + dmobject.c \ + dmopcode.c \ + dmresrc.c \ + dmresrcl.c \ + dmresrcl2.c \ + dmresrcs.c \ + dmrestag.c \ + dmtable.c \ + dmtbdump.c \ + dmtbinfo.c \ + dmutils.c \ + dmwalk.c \ + dsargs.c \ + dscontrol.c \ + dsfield.c \ + dsobject.c \ + dsopcode.c \ + dsutils.c \ + dswexec.c \ + dswload.c \ + dswload2.c \ + dswscope.c \ + dswstate.c \ + exconvrt.c \ + excreate.c \ + exdump.c \ + exmisc.c \ + exmutex.c \ + exnames.c \ + exoparg1.c \ + exoparg2.c \ + exoparg3.c \ + exoparg6.c \ + exprep.c \ + exregion.c \ + exresnte.c \ + exresolv.c \ + exresop.c \ + exstore.c \ + exstoren.c \ + exstorob.c \ + exsystem.c \ + exutils.c \ + getopt.c \ + nsaccess.c \ + nsalloc.c \ + nsdump.c \ + nsnames.c \ + nsobject.c \ + nsparse.c \ + nssearch.c \ + nsutils.c \ + nswalk.c \ + nsxfobj.c \ + osunixxf.c \ + prexpress.c \ + prmacros.c \ + prscan.c \ + prutils.c \ + psargs.c \ + psloop.c \ + psobject.c \ + psopcode.c \ + psopinfo.c \ + psparse.c \ + psscope.c \ + pstree.c \ + psutils.c \ + pswalk.c \ + tbfadt.c \ + tbinstal.c \ + tbprint.c \ + tbutils.c \ + tbxface.c \ + utaddress.c \ + utalloc.c \ + utbuffer.c \ + utcache.c \ + utcopy.c \ + utdebug.c \ + utdecode.c \ + utdelete.c \ + uterror.c \ + utexcep.c \ + utglobal.c \ + utinit.c \ + utlock.c \ + utmath.c \ + utmisc.c \ + utmutex.c \ + utobject.c \ + utownerid.c \ + utpredef.c \ + utresrc.c \ + utstate.c \ + utstring.c \ + utxface.c \ + utxferror.c -CFLAGS+= -D_USE_BERKELEY_YACC -LDADD= -lpthread -DPADD= ${LIBPTHREAD} +CFLAGS+= \ + -DACPI_ASL_COMPILER \ + -I${UTILDIR} \ + -I${.CURDIR} -CLEANFILES= aslcompiler.y.h aslcompilerlex.c aslcompilerparse.c \ - aslcompilerparse.h dtparser.y.h dtparserlex.c \ - dtparserparse.c dtparserparse.h +LFLAGS= -i -s +YFLAGS= -d aslcompilerlex.c: aslcompiler.l ${LEX} ${LFLAGS} -PAslCompiler -o${.TARGET} ${.ALLSRC} @@ -67,4 +203,24 @@ dtparserparse.c: dtparser.y dtparser.y.h: dtparserparse.c mv -f dtparserparse.h ${.TARGET} +prparserlex.c: prparser.l + ${LEX} ${LFLAGS} -PPrParser -o${.TARGET} ${.ALLSRC} + +prparserparse.c: prparser.y + ${YACC} ${YFLAGS} -pPrParser -o${.TARGET} ${.ALLSRC} + +prparser.y.h: prparserparse.c + mv -f prparserparse.h ${.TARGET} + +CLEANFILES+= \ + aslcompilerlex.c \ + aslcompilerparse.c \ + aslcompiler.y.h \ + dtparserlex.c \ + dtparserparse.c \ + dtparser.y.h \ + prparserlex.c \ + prparserparse.c \ + prparser.y.h + .include -- 2.41.0