diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2011-06-23 17:28:46 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2011-06-23 17:28:46 +0000 |
commit | f885636060ce6a22f621a4765c5ea055fbf0cea8 (patch) | |
tree | 0bda5163cdee2902d4a3848aa7106c226116c56c | |
parent | eb16cf140e9ac2743140a477895264ce7dd69ec0 (diff) |
Notes
49 files changed, 4665 insertions, 2066 deletions
@@ -1,79 +1,137 @@ -acpica-unix ------------ +Makefiles for tool generation from the unix tarball +--------------------------------------------------- -This source release includes: +These makefiles are intended to generate the ACPICA utilities in +a Linux or Unix-like environment, from the ACPICA source code +as released in the unix tarball. +Windows binary versions of these tools are available at: -1) a cross-OS AML interpreter +http://www.acpica.org/downloads/binary_tools.php -This is intended to allow commercial and open source operating systems -to be enabled for ACPI. OS specific code is still needed, but the -AML interpreter should greatly improve the development speed of ACPI -support. +Documentation is available at acpica.org: -The AML interpreter source should be integrated into the kernel's -build process. We recommend establishing an automated method for -this, so later versions can also be incorporated easily. Please see -the documentation on the website for API and other implementation -information. +http://www.acpica.org/documentation/ +The acpica/source/tools directory contains the following utilities. +Note: These utilities are tested and supported as 32-bit versions +only. -2) iasl, an ASL compiler/decompiler +acpibin +acpiexec +acpihelp +acpinames +acpisrc +acpixtract +iasl -iasl compiles ASL (ACPI Source Language) into AML (ACPI Machine -Language). This AML is suitable for inclusion as a DSDT in system -firmware. It also can disassemble AML, for debugging purposes. + +Requirements +------------ + +make +gcc compiler (4+) +bison or yacc +flex or lex + + +Configuration +------------- + +The Makefiles contain this configuration information: + +HOST = _LINUX /* Host system, must appear in acenv.h */ +CC = gcc /* C compiler */ + + +1) acpibin, an AML file tool + +acpibin compares AML files, dumps AML binary files to text files, +extracts binary AML from text files, and other AML file +manipulation. To compile: -cd compiler +cd acpica/source/tools/acpibin make +make install /* install the binary to /usr/bin */ -It has been compiled on Linux, but should easily port to other Unix -environments. -Run 'iasl -h' for more information, or download the binary version for -documentation in PDF format. +2) acpiexec, a user-space AML interpreter +acpiexec allows the loading of ACPI tables and execution of control +methods from user space. Useful for debugging AML code and testing +the AML interpreter. Hardware access is simulated. -3) acpisrc, a source code conversion tool +To compile: + +cd acpica/source/tools/acpiexec +make +make install /* install the binary to /usr/bin */ -acpisrc converts the standard form of the acpica source release (included -here) into a version that meets Linux coding guidelines. This consists -mainly of performing a series of string replacements and transformations -to the code. + +3) acpihelp, syntax help for ASL operators and reserved names + +acpihelp displays the syntax for all of the ASL operators, as well +as information about the ASL/ACPI reserved names (4-char names that +start with underscore.) To compile: -cd tools/acpisrc +cd acpica/source/tools/acpihelp make +make install /* install the binary to /usr/bin */ -It has been compiled on Linux, but should easily port to other Unix -environments. +4) acpinames, load and dump acpi namespace -4) acpibin, an AML file tool +acpinames loads an ACPI namespace from a binary ACPI table file. +This is a smaller version of acpiexec that loads an acpi table and +dumps the resulting namespace. It is primarily intended to demonstrate +the configurability of ACPICA. -acpibin compares AML files, dumps AML binary files to text files, -extracts binary AML from text files, and other AML file -manipulation. +To compile: + +cd acpica/source/tools/acpinames +make +make install /* install the binary to /usr/bin */ + + +5) acpisrc, a source code conversion tool + +acpisrc converts the standard form of the acpica source release (included +here) into a version that meets Linux coding guidelines. This consists +mainly of performing a series of string replacements and transformations +to the code. It can also be used to clean the acpica source and generate +statistics. To compile: -cd tools/acpibin +cd acpica/source/tools/acpisrc make +make install /* install the binary to /usr/bin */ -5) acpiexec, a user-space AML interpreter +6) acpixtract, extract binary ACPI tables from an acpidump -acpiexec allows the loading of ACPI tables and execution of control -methods from user space. Useful for debugging AML code and testing -the AML interpreter. +acpixtract is used to extract binary ACPI tables from the ASCII text +output of an acpidump utility (available on several different hosts.) To compile: -cd tools/acpiexec +cd acpica/source/tools/acpixtract make +make install /* install the binary to /usr/bin */ -Thanks -- The ACPI CA Team +7) iasl, an optimizing ASL compiler/disassembler + +iasl compiles ASL (ACPI Source Language) into AML (ACPI Machine +Language). This AML is suitable for inclusion as a DSDT in system +firmware. It also can disassemble AML, for debugging purposes. + +To compile: + +cd acpica/source/compiler +make +make install /* install the binary to /usr/bin */ diff --git a/changes.txt b/changes.txt index f53fd426da4a..b6ddcd9690ad 100644 --- a/changes.txt +++ b/changes.txt @@ -1,7 +1,72 @@ ---------------------------------------- -27 May 2011. Summary of changes for version 20110527: +23 June 2011. Summary of changes for version 20110623: + +1) ACPI CA Core Subsystem: + +Updated the predefined name repair mechanism to not attempt repair of a _TSS +return object if a _PSS object is present. We can only sort the _TSS return +package if there is no _PSS within the same scope. This is because if _PSS is +present, the ACPI specification dictates that the _TSS Power Dissipation field +is to be ignored, and therefore some BIOSs leave garbage values in the _TSS +Power field(s). In this case, it is best to just return the _TSS package as- +is. Reported by, and fixed with assistance from Fenghua Yu. + +Added an option to globally disable the control method return value validation +and repair. This runtime option can be used to disable return value repair if +this is causing a problem on a particular machine. Also added an option to +AcpiExec (-dr) to set this disable flag. + +All makefiles and project files: Major changes to improve generation of ACPICA +tools. ACPICA BZ 912: + Reduce default optimization levels to improve compatibility + For Linux, add strict-aliasing=0 for gcc 4 + Cleanup and simplify use of command line defines + Cleanup multithread library support + Improve usage messages + +Linux-specific header: update handling of THREAD_ID and pthread. For the 32- +bit case, improve casting to eliminate possible warnings, especially with the +acpica tools. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug +version of the code includes the debug output trace mechanism and has a much +larger code and data size. + + Previous Release (VC 9.0): + Non-Debug Version: 90.1K Code, 23.9K Data, 114.0K Total + Debug Version: 165.6K Code, 68.4K Data, 234.0K Total + Current Release (VC 9.0): + Non-Debug Version: 90.2K Code, 23.9K Data, 114.1K Total + Debug Version: 165.6K Code, 68.4K Data, 234.0K Total + +2) iASL Compiler/Disassembler and Tools: -This release is available at www.acpica.org/downloads +With this release, a new utility named "acpihelp" has been added to the ACPICA +package. This utility summarizes the ACPI specification chapters for the ASL +and AML languages. It generates under Linux/Unix as well as Windows, and +provides the following functionality: + Find/display ASL operator(s) -- with description and syntax. + Find/display ASL keyword(s) -- with exact spelling and descriptions. + Find/display ACPI predefined name(s) -- with description, number + of arguments, and the return value data type. + Find/display AML opcode name(s) -- with opcode, arguments, and grammar. + Decode/display AML opcode -- with opcode name, arguments, and grammar. + +Service Layers: Make multi-thread support configurable. Conditionally compile +the multi-thread support so that threading libraries will not be linked if not +necessary. The only tool that requires multi-thread support is AcpiExec. + +iASL: Update yyerrror/AslCompilerError for "const" errors. Newer versions of +Bison appear to want the interface to yyerror to be a const char * (or at +least this is a problem when generating iASL on some systems.) ACPICA BZ 923 +Pierre Lejeune. + +Tools: Fix for systems where O_BINARY is not defined. Only used for Windows +versions of the tools. + +---------------------------------------- +27 May 2011. Summary of changes for version 20110527: 1) ACPI CA Core Subsystem: diff --git a/compiler/Makefile b/compiler/Makefile index 4c54b22b84e7..1807635a2a40 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -1,18 +1,57 @@ # # iASL compiler/disassembler # +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# + +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROG = iasl -PROG= iasl +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? +ACPICA_COMPONENTS = ACPICA_SRC = .. -ASL_COMPILER = $(ACPICA_SRC)/compiler ACPICA_COMMON = $(ACPICA_SRC)/common -ACPICA_CORE = $(ACPICA_SRC) +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) ACPICA_TOOLS = $(ACPICA_SRC)/tools ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers - -NOMAN= YES -CFLAGS+= -Wall -O2 -Wstrict-prototypes -D_LINUX -DACPI_ASL_COMPILER -I../include -I../compiler +ASL_COMPILER = $(ACPICA_SRC)/compiler +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) + +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_ASL_COMPILER \ + -I$(ACPICA_SRC)/include \ + -I$(ASL_COMPILER) + +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef # # Bison/Flex configuration @@ -23,11 +62,6 @@ YFLAGS+= -v -d -y LEX= flex LFLAGS+= -i -s - -COMPILE = $(CC) -c $(CFLAGS) -o$@ $? -LDFLAGS += -lpthread -lrt - - OBJS = \ adfile.o \ adisasm.o \ @@ -182,7 +216,6 @@ MISC = \ # $(PROG) : $(INTERMEDIATES) $(OBJS) $(CC) $(OBJS) $(LDFLAGS) -o $(PROG) - $(COPYPROG) # @@ -210,16 +243,16 @@ dtparserparse.c : $(ASL_COMPILER)/dtparser.y # by the utilities above and they are not necessarily ANSI C, etc. # aslcompilerlex.o : aslcompilerlex.c - $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $? + $(CC) -c $(CFLAGS) -Wall -Werror -Wstrict-aliasing=0 -o$@ $? aslcompilerparse.o : aslcompilerparse.c - $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $? + $(CC) -c $(CFLAGS) -Wall -Werror -Wstrict-aliasing=0 -o$@ $? dtparserlex.o : dtparserlex.c - $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $? + $(CC) -c $(CFLAGS) -Wall -Werror -Wstrict-aliasing=0 -o$@ $? dtparserparse.o : dtparserparse.c - $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $? + $(CC) -c $(CFLAGS) -Wall -Werror -Wstrict-aliasing=0 -o$@ $? # @@ -632,5 +665,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) $(INTERMEDIATES) $(MISC) + +install : + $(INSTALLPROG) diff --git a/compiler/aslcompiler.h b/compiler/aslcompiler.h index 8ce206926a1b..2a397b3fe1e3 100644 --- a/compiler/aslcompiler.h +++ b/compiler/aslcompiler.h @@ -289,7 +289,7 @@ AslCoreSubsystemError ( int AslCompilererror( - char *s); + const char *s); void AslCommonError ( diff --git a/compiler/aslerror.c b/compiler/aslerror.c index ab85c6f6089e..12f108a268b6 100644 --- a/compiler/aslerror.c +++ b/compiler/aslerror.c @@ -620,13 +620,13 @@ AslCoreSubsystemError ( int AslCompilererror ( - char *CompilerMessage) + const char *CompilerMessage) { AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber, - Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, - Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename, - CompilerMessage); + Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, + Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename, + ACPI_CAST_PTR (char, CompilerMessage)); return 0; } diff --git a/compiler/aslstubs.c b/compiler/aslstubs.c index 30100dafc649..0ca2b5bf46e1 100644 --- a/compiler/aslstubs.c +++ b/compiler/aslstubs.c @@ -232,3 +232,20 @@ AcpiTbFindTable ( return (AE_SUPPORT); } +/* OSL interfaces */ + +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (0xFFFF); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_SUPPORT); +} diff --git a/generate/unix/Makefile b/generate/unix/Makefile index f1ca17f2632c..e75523c26bb7 100644 --- a/generate/unix/Makefile +++ b/generate/unix/Makefile @@ -1,28 +1,37 @@ # # Common make for acpica tools and utilities # + +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# include Makefile.config -all: ${DIRS} -${DIRS}: FORCE +all: ${PROGS} +${PROGS}: FORCE @cd $@; make; ls -al $@ clean: FORCE - @for d in ${DIRS}; do \ + @for d in ${PROGS}; do \ (cd $$d; \ if [ $$? -ne 0 ]; then \ - echo "Bad element of DIRS: <$$d>"; \ + echo "Bad element of PROGS: <$$d>"; \ else \ pwd; make clean; \ fi); \ done install: FORCE - @for d in ${DIRS}; do \ + @for d in ${PROGS}; do \ (cd $$d; \ if [ $$? -ne 0 ]; then \ - echo "Bad element of DIRS: <$$d>"; \ + echo "Bad element of PROGS: <$$d>"; \ else \ pwd; make install; \ fi); \ diff --git a/generate/unix/Makefile.config b/generate/unix/Makefile.config index c9bf6873a214..2eb5be23faa8 100644 --- a/generate/unix/Makefile.config +++ b/generate/unix/Makefile.config @@ -2,76 +2,94 @@ # Makefile.config # # Common configuration and setup file to generate the ACPICA tools and -# utilities: acpiexec, acpisrc, acpixtract, and the iASL compiler. +# utilities: the iASL compiler, acpiexec, acpihelp, acpinames, acpisrc, +# acpixtract, acpibin. # # This file is included by the individual makefiles for each tool. # # -# Configuration -# Note: gcc should be version 4 or greater, otherwise some of the -# options used won't be recognized (see below) +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# + # +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROGS = acpibin acpiexec acpihelp acpinames acpisrc acpixtract iasl + HOST = _CYGWIN CC = gcc -ACPICA_SRC = ../../../source -DIRS = acpiexec acpinames acpisrc acpixtract iasl -INSTALLDIR = /usr/bin +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? # # Common defines # -ASL_COMPILER = $(ACPICA_SRC)/compiler +ACPICA_SRC = ../../../source ACPICA_COMMON = $(ACPICA_SRC)/common ACPICA_CORE = $(ACPICA_SRC)/components ACPICA_TOOLS = $(ACPICA_SRC)/tools ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers -COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? +ASL_COMPILER = $(ACPICA_SRC)/compiler COPYPROG = @mkdir -p ../bin; rm -f ../bin/$(PROG); cp --remove-destination $(PROG) ../bin +INSTALLDIR = /usr/bin INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) - # # Common compiler flags. The warning flags in addition to -Wall are not # automatically included in -Wall. # -CFLAGS+= -Os -D$(HOST) -I$(ACPICA_SRC)/include -D_GNU_SOURCE +CFLAGS += \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -I$(ACPICA_SRC)/include + CWARNINGFLAGS = \ - -ansi \ - -Wall \ - -Wbad-function-cast \ - -Wdeclaration-after-statement \ - -Werror \ - -Wformat=2 \ - -Wmissing-declarations \ - -Wmissing-prototypes \ - -Wstrict-aliasing=0 \ - -Wstrict-prototypes \ - -Wswitch-default \ - -Wpointer-arith \ - -Wundef + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef # # gcc 4+ flags # -CWARNINGFLAGS+= \ - -Waddress \ - -Waggregate-return \ - -Wchar-subscripts \ - -Wempty-body \ - -Wlogical-op \ - -Wmissing-declarations \ - -Wmissing-field-initializers \ - -Wmissing-parameter-type \ - -Wnested-externs \ - -Wold-style-declaration \ - -Wold-style-definition \ - -Wredundant-decls \ - -Wtype-limits +CWARNINGFLAGS += \ + -Waddress \ + -Waggregate-return \ + -Wchar-subscripts \ + -Wempty-body \ + -Wlogical-op \ + -Wmissing-declarations \ + -Wmissing-field-initializers \ + -Wmissing-parameter-type \ + -Wnested-externs \ + -Wold-style-declaration \ + -Wold-style-definition \ + -Wredundant-decls \ + -Wtype-limits # # Extra warning flags (possible future use) # -#CWARNINGFLAGS+= \ +#CWARNINGFLAGS += \ # -Wcast-qual \ # -Wconversion # -Wshadow \ @@ -88,12 +106,11 @@ CWARNINGFLAGS+= \ # # Berkeley yacc configuration # -#YACC= byacc -#YFLAGS+= -v -d +#YACC= byacc +#YFLAGS += -v -d # -YACC= bison -YFLAGS+= -v -d -y - -LEX= flex -LFLAGS+= -i -s +YACC= bison +YFLAGS += -v -d -y +LEX= flex +LFLAGS += -i -s diff --git a/generate/unix/acpibin/Makefile b/generate/unix/acpibin/Makefile new file mode 100644 index 000000000000..4779cb8fe27b --- /dev/null +++ b/generate/unix/acpibin/Makefile @@ -0,0 +1,109 @@ +# +# acpibin - Binary ACPI table utility +# + +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config +PROG = acpibin + +# +# Flags specific to acpibin +# +CFLAGS+= \ + -DACPI_BIN_APP \ + -I$(ACPICA_TOOLS)/acpibin + +OBJS = \ + abcompare.o \ + abmain.o \ + utalloc.o \ + utcache.o \ + utdebug.o \ + utdecode.o \ + utglobal.o \ + utlock.o \ + utmath.o \ + utmisc.o \ + utmutex.o \ + utstate.o \ + utxferror.o \ + osunixxf.o \ + getopt.o + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + $(COPYPROG) + +# +# acpibin source +# +abcompare.o : $(ACPICA_TOOLS)/acpibin/abcompare.c + $(COMPILE) + +abmain.o : $(ACPICA_TOOLS)/acpibin/abmain.c + $(COMPILE) + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + +# +# ACPICA core source +# +utalloc.o : $(ACPICA_CORE)/utilities/utalloc.c + $(COMPILE) + +utcache.o : $(ACPICA_CORE)/utilities/utcache.c + $(COMPILE) + +utdebug.o : $(ACPICA_CORE)/utilities/utdebug.c + $(COMPILE) + +utdecode.o : $(ACPICA_CORE)/utilities/utdecode.c + $(COMPILE) + +utglobal.o : $(ACPICA_CORE)/utilities/utglobal.c + $(COMPILE) + +utlock.o : $(ACPICA_CORE)/utilities/utlock.c + $(COMPILE) + +utmath.o : $(ACPICA_CORE)/utilities/utmath.c + $(COMPILE) + +utmisc.o : $(ACPICA_CORE)/utilities/utmisc.c + $(COMPILE) + +utmutex.o : $(ACPICA_CORE)/utilities/utmutex.c + $(COMPILE) + +utstate.o : $(ACPICA_CORE)/utilities/utstate.c + $(COMPILE) + +utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c + $(COMPILE) + +# +# Unix OS services layer (OSL) +# +osunixxf.o : $(ACPICA_OSL)/osunixxf.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 04f709def602..331218e4f3a2 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -1,15 +1,27 @@ # -# AcpiExec utility +# acpiexec: ACPI execution simulator. Runs ACPICA code in user +# space. Loads ACPI tables, displays the namespace, and allows +# execution of control methods. # -include ../Makefile.config +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config PROG = acpiexec - # # Flags specific to acpiexec utility # -CFLAGS+= -DACPI_EXEC_APP -I$(ACPICA_TOOLS)/acpiexec +CFLAGS+= \ + -DACPI_EXEC_APP \ + -I$(ACPICA_TOOLS)/acpiexec +LDFLAGS += -lpthread -lrt OBJS = \ aeexec.o \ @@ -165,15 +177,13 @@ OBJS = \ utxferror.o \ utxface.o - # # Root rule # $(PROG) : $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -lpthread -o $(PROG) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) $(COPYPROG) - # # acpiexec source # @@ -189,14 +199,12 @@ aemain.o : $(ACPICA_TOOLS)/acpiexec/aemain.c aetables.o : $(ACPICA_TOOLS)/acpiexec/aetables.c $(COMPILE) - # # ACPICA core source - common # getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # ACPICA core source # @@ -638,7 +646,6 @@ utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c utxface.o : $(ACPICA_CORE)/utilities/utxface.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -646,8 +653,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) -install : +install : $(INSTALLPROG) diff --git a/generate/unix/acpihelp/Makefile b/generate/unix/acpihelp/Makefile new file mode 100644 index 000000000000..f6907141b386 --- /dev/null +++ b/generate/unix/acpihelp/Makefile @@ -0,0 +1,72 @@ +# +# acpihelp - ACPI Help utility. Displays ASL operator syntax and +# information about ACPI predefined names. +# + +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config +PROG = acpihelp + +# +# Flags specific to acpihelp +# +CFLAGS+= \ + -DACPI_HELP_APP \ + -I$(ACPICA_TOOLS)/acpihelp + +OBJS = \ + ahamlops.o \ + ahaslkey.o \ + ahaslops.o \ + ahdecode.o \ + ahpredef.o \ + ahmain.o \ + getopt.o + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + $(COPYPROG) + +# +# acpihelp source +# +ahamlops.o : $(ACPICA_TOOLS)/acpihelp/ahamlops.c + $(COMPILE) + +ahaslkey.o : $(ACPICA_TOOLS)/acpihelp/ahaslkey.c + $(COMPILE) + +ahaslops.o : $(ACPICA_TOOLS)/acpihelp/ahaslops.c + $(COMPILE) + +ahdecode.o : $(ACPICA_TOOLS)/acpihelp/ahdecode.c + $(COMPILE) + +ahpredef.o : $(ACPICA_TOOLS)/acpihelp/ahpredef.c + $(COMPILE) + +ahmain.o : $(ACPICA_TOOLS)/acpihelp/ahmain.c + $(COMPILE) + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/generate/unix/acpinames/Makefile b/generate/unix/acpinames/Makefile index abf916b94dd8..698afd25d6da 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -1,15 +1,26 @@ # -# AcpiNames utility +# acpinames - Load ACPI table and dump namespace. This is a subset +# of the AcpiExec functionality, it is intended to demonstrate +# the configurability of ACPICA. # -include ../Makefile.config +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config PROG = acpinames - # # Flags specific to acpinames utility # -CFLAGS+= -DACPI_APPLICATION -DACPI_SINGLE_THREADED -DACPI_DEBUGGER -I$(ACPICA_TOOLS)/acpinames +CFLAGS+= \ + -DACPI_NAMES_APP \ + -I$(ACPICA_TOOLS)/acpinames OBJS = \ anmain.o \ @@ -76,15 +87,13 @@ OBJS = \ utxferror.o \ utxface.o - # # Root rule # $(PROG) : $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -lpthread -o $(PROG) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) $(COPYPROG) - # # acpinames source # @@ -97,14 +106,12 @@ anstubs.o : $(ACPICA_TOOLS)/acpinames/anstubs.c antables.o : $(ACPICA_TOOLS)/acpinames/antables.c $(COMPILE) - # # ACPICA core source - common # getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # ACPICA core source # @@ -282,7 +289,6 @@ utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c utxface.o : $(ACPICA_CORE)/utilities/utxface.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -290,8 +296,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) -install : +install : $(INSTALLPROG) diff --git a/generate/unix/acpisrc/Makefile b/generate/unix/acpisrc/Makefile index 9cc93fc54bd7..92325b050417 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -1,15 +1,24 @@ # -# acpisrc utility +# acpisrc - ACPICA source code conversion utility # -include ../Makefile.config +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config PROG = acpisrc - # # Flags specific to acpisrc # -CFLAGS+= -DACPI_APPLICATION -I$(ACPICA_TOOLS)/acpisrc +CFLAGS+= \ + -DACPI_SRC_APP \ + -I$(ACPICA_TOOLS)/acpisrc OBJS = \ ascase.o \ @@ -20,8 +29,7 @@ OBJS = \ astable.o \ asutils.o \ getopt.o \ - osunixdir.o - + osunixdir.o # # Root rule @@ -30,7 +38,6 @@ $(PROG) : $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) $(COPYPROG) - # # acpisrc source # @@ -55,14 +62,12 @@ astable.o : $(ACPICA_TOOLS)/acpisrc/astable.c asutils.o : $(ACPICA_TOOLS)/acpisrc/asutils.c $(COMPILE) - # # ACPICA core source - common # getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -70,8 +75,8 @@ osunixdir.o : $(ACPICA_OSL)/osunixdir.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) -install : +install : $(INSTALLPROG) diff --git a/generate/unix/acpixtract/Makefile b/generate/unix/acpixtract/Makefile index f6be17117557..f63b45ee293e 100644 --- a/generate/unix/acpixtract/Makefile +++ b/generate/unix/acpixtract/Makefile @@ -1,17 +1,36 @@ # -# acpixtract utility +# acpixtract - extract binary ACPI tables from acpidump text output # -include ../Makefile.config +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config PROG = acpixtract +OBJS = \ + acpixtract.o + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + +# +# acpixtract source +# +acpixtract.o : $(ACPICA_TOOLS)/acpixtract/acpixtract.c + $(COMPILE) -$(PROG) : $(ACPICA_TOOLS)/acpixtract/acpixtract.c - $(CC) $(CFLAGS) $(CWARNINGFLAGS) $(LDFLAGS) -o$(PROG) $? - $(COPYPROG) -clean : +clean : rm -f $(PROG) $(PROG).exe -install : +install : $(INSTALLPROG) diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index b8bdb76de565..4d20dbcae1df 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -1,15 +1,25 @@ # -# iASL compiler +# iASL compiler/disassembler # -include ../Makefile.config +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config PROG = iasl # # Flags specific to iASL compiler # -CFLAGS+= -DACPI_ASL_COMPILER -I$(ASL_COMPILER) -I. -LDFLAGS+= -lpthread +CFLAGS+= \ + -DACPI_ASL_COMPILER \ + -I$(ASL_COMPILER) \ + -I. OBJS = \ adfile.o \ @@ -159,7 +169,6 @@ MISC = \ dtparser.y.h \ dtparserparse.output - # # Root rule # @@ -167,7 +176,6 @@ $(PROG) : $(INTERMEDIATES) $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) $(COPYPROG) - # # Parser and Lexer - intermediate C files # @@ -185,7 +193,6 @@ dtparserparse.c : $(ASL_COMPILER)/dtparser.y ${YACC} ${YFLAGS} -pDtParser -o$@ $? @mv -f dtparserparse.h dtparser.y.h - # # Parsers and Lexers - final object files # @@ -204,7 +211,6 @@ dtparserlex.o : dtparserlex.c dtparserparse.o : dtparserparse.c $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $? - # # Compiler source # @@ -304,7 +310,6 @@ asluuid.o : $(ASL_COMPILER)/asluuid.c aslwalks.o : $(ASL_COMPILER)/aslwalks.c $(COMPILE) - # # Data Table Compiler # @@ -332,7 +337,6 @@ dttemplate.o : $(ASL_COMPILER)/dttemplate.c dtutils.o : $(ASL_COMPILER)/dtutils.c $(COMPILE) - # # ACPICA core source - common # @@ -363,7 +367,6 @@ dmtbinfo.o : $(ACPICA_COMMON)/dmtbinfo.c getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # ACPICA core source # @@ -607,7 +610,6 @@ utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c utxface.o : $(ACPICA_CORE)/utilities/utxface.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -615,8 +617,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) $(INTERMEDIATES) $(MISC) -install : +install : $(INSTALLPROG) diff --git a/generate/unix/readme.txt b/generate/unix/readme.txt index 6e20a437b5de..c68b936bb6f2 100644 --- a/generate/unix/readme.txt +++ b/generate/unix/readme.txt @@ -1,26 +1,44 @@ -Unix ACPICA makefiles ---------------------- +Generic Unix ACPICA makefiles +----------------------------- -These makefiles are intended for generating the ACPICA utilities in +These makefiles are intended to generate the ACPICA utilities in a Unix-like environment, with the original ACPICA code (not linuxized), and in the original (git tree) ACPICA directory structure. +Windows binary versions of these tools are available at: + +http://www.acpica.org/downloads/binary_tools.php + +Documentation is available at acpica.org: + +http://www.acpica.org/documentation/ + The top level makefile will generate the following utilities: +Note: These utilities are tested and supported as 32-bit versions +only. +acpibin acpiexec +acpihelp acpinames acpisrc acpixtract iasl +To generate all utilities: + +cd acpica/generate/unix +make +make install /* install all binaries to /usr/bin */ + Requirements ------------ make -gcc compiler (3+ or 4+) -bison -flex +gcc compiler (4+) +bison or yacc +flex or lex Configuration @@ -29,7 +47,7 @@ Configuration The Makefile.config file contains the configuration information: HOST = _CYGWIN /* Host system, must appear in acenv.h */ -CC = gcc-4 /* C compiler */ +CC = gcc /* C compiler */ ACPICA_SRC = ../../../source /* Location of acpica source tree */ @@ -49,3 +67,54 @@ The executable utilities are copied to the local bin directory. "make install" will install the binaries to /usr/bin + + +1) acpibin, an AML file tool + +acpibin compares AML files, dumps AML binary files to text files, +extracts binary AML from text files, and other AML file +manipulation. + + +2) acpiexec, a user-space AML interpreter + +acpiexec allows the loading of ACPI tables and execution of control +methods from user space. Useful for debugging AML code and testing +the AML interpreter. Hardware access is simulated. + + +3) acpihelp, syntax help for ASL operators and reserved names + +acpihelp displays the syntax for all of the ASL operators, as well +as information about the ASL/ACPI reserved names (4-char names that +start with underscore.) + + +4) acpinames, load and dump acpi namespace + +acpinames loads an ACPI namespace from a binary ACPI table file. +This is a smaller version of acpiexec that loads an acpi table and +dumps the resulting namespace. It is primarily intended to demonstrate +the configurability of ACPICA. + + +5) acpisrc, a source code conversion tool + +acpisrc converts the standard form of the acpica source release (included +here) into a version that meets Linux coding guidelines. This consists +mainly of performing a series of string replacements and transformations +to the code. It can also be used to clean the acpica source and generate +statistics. + + +6) acpixtract, extract binary ACPI tables from an acpidump + +acpixtract is used to extract binary ACPI tables from the ASCII text +output of an acpidump utility (available on several different hosts.) + + +7) iasl, an optimizing ASL compiler/disassembler + +iasl compiles ASL (ACPI Source Language) into AML (ACPI Machine +Language). This AML is suitable for inclusion as a DSDT in system +firmware. It also can disassemble AML, for debugging purposes. diff --git a/include/acglobal.h b/include/acglobal.h index ebbae0f59597..ceb26b0b150c 100644 --- a/include/acglobal.h +++ b/include/acglobal.h @@ -128,6 +128,12 @@ UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CopyDsdtLocally, FALSE); */ UINT8 ACPI_INIT_GLOBAL (AcpiGbl_TruncateIoAddresses, FALSE); +/* + * Disable runtime checking and repair of values returned by control methods. + * Use only if the repair is causing a problem on a particular machine. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_DisableAutoRepair, FALSE); + /* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ diff --git a/include/aclocal.h b/include/aclocal.h index 2eb6fc21d465..385a88ff4ec5 100644 --- a/include/aclocal.h +++ b/include/aclocal.h @@ -411,6 +411,7 @@ typedef struct acpi_predefined_data char *Pathname; const ACPI_PREDEFINED_INFO *Predefined; union acpi_operand_object *ParentPackage; + ACPI_NAMESPACE_NODE *Node; UINT32 Flags; UINT8 NodeFlags; diff --git a/include/acpixf.h b/include/acpixf.h index 82b677e615cc..8cb1753b5338 100644 --- a/include/acpixf.h +++ b/include/acpixf.h @@ -48,7 +48,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20110527 +#define ACPI_CA_VERSION 0x20110623 #include "actypes.h" #include "actbl.h" @@ -76,6 +76,7 @@ extern UINT32 AcpiGbl_TraceFlags; extern UINT8 AcpiGbl_EnableAmlDebugObject; extern UINT8 AcpiGbl_CopyDsdtLocally; extern UINT8 AcpiGbl_TruncateIoAddresses; +extern UINT8 AcpiGbl_DisableAutoRepair; /* diff --git a/include/platform/acenv.h b/include/platform/acenv.h index 7f893c13ff23..e59d5846195b 100644 --- a/include/platform/acenv.h +++ b/include/platform/acenv.h @@ -79,7 +79,7 @@ #define ACPI_SINGLE_THREADED #endif -/* AcpiExec and AcpiBin configuration */ +/* AcpiExec configuration. Multithreaded with full AML debugger */ #ifdef ACPI_EXEC_APP #define ACPI_APPLICATION @@ -88,7 +88,26 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -#ifdef ACPI_BIN_APP +/* AcpiNames configuration. Single threaded with debugger output enabled. */ + +#ifdef ACPI_NAMES_APP +#define ACPI_DEBUGGER +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + +/* + * AcpiBin/AcpiHelp/AcpiSrc configuration. All single threaded, with + * no debug output. + */ +#if (defined ACPI_BIN_APP) || \ + (defined ACPI_SRC_APP) +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + +#ifdef ACPI_HELP_APP +#define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED #endif diff --git a/include/platform/aclinux.h b/include/platform/aclinux.h index 3fc3d97cb81c..21132a96f076 100644 --- a/include/platform/aclinux.h +++ b/include/platform/aclinux.h @@ -87,17 +87,18 @@ /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE() -#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (pthread)) #if defined(__ia64__) || defined(__x86_64__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long #define COMPILER_DEPENDENT_UINT64 unsigned long +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (pthread)) #else #define ACPI_MACHINE_WIDTH 32 #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long #define ACPI_USE_NATIVE_DIVIDE +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (UINT32) (void *) (pthread)) #endif #ifndef __cdecl diff --git a/include/platform/acmsvc.h b/include/platform/acmsvc.h index 8590d95fd023..64b14c698cd4 100644 --- a/include/platform/acmsvc.h +++ b/include/platform/acmsvc.h @@ -44,6 +44,28 @@ #ifndef __ACMSVC_H__ #define __ACMSVC_H__ + +/* + * Map low I/O functions for MS. This allows us to disable MS language + * extensions for maximum portability. + */ +#define open _open +#define read _read +#define write _write +#define close _close +#define stat _stat +#define fstat _fstat +#define mkdir _mkdir +#define strlwr _strlwr +#define O_RDONLY _O_RDONLY +#define O_BINARY _O_BINARY +#define O_CREAT _O_CREAT +#define O_WRONLY _O_WRONLY +#define O_TRUNC _O_TRUNC +#define S_IREAD _S_IREAD +#define S_IWRITE _S_IWRITE +#define S_IFDIR _S_IFDIR + /* Eliminate warnings for "old" (non-secure) versions of clib functions */ #ifndef _CRT_SECURE_NO_WARNINGS diff --git a/namespace/nspredef.c b/namespace/nspredef.c index 95c3edf04d26..358c63a85dc6 100644 --- a/namespace/nspredef.c +++ b/namespace/nspredef.c @@ -216,14 +216,20 @@ AcpiNsCheckPredefinedNames ( } /* - * 1) We have a return value, but if one wasn't expected, just exit, this is - * not a problem. For example, if the "Implicit Return" feature is - * enabled, methods will always return a value. + * Return value validation and possible repair. * - * 2) If the return value can be of any type, then we cannot perform any - * validation, exit. + * 1) Don't perform return value validation/repair if this feature + * has been disabled via a global option. + * + * 2) We have a return value, but if one wasn't expected, just exit, + * this is not a problem. For example, if the "Implicit Return" + * feature is enabled, methods will always return a value. + * + * 3) If the return value can be of any type, then we cannot perform + * any validation, just exit. */ - if ((!Predefined->Info.ExpectedBtypes) || + if (AcpiGbl_DisableAutoRepair || + (!Predefined->Info.ExpectedBtypes) || (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) { goto Cleanup; @@ -237,6 +243,7 @@ AcpiNsCheckPredefinedNames ( goto Cleanup; } Data->Predefined = Predefined; + Data->Node = Node; Data->NodeFlags = Node->Flags; Data->Pathname = Pathname; diff --git a/namespace/nsrepair2.c b/namespace/nsrepair2.c index 4c9c6d78259a..d8a0420cf94c 100644 --- a/namespace/nsrepair2.c +++ b/namespace/nsrepair2.c @@ -555,8 +555,23 @@ AcpiNsRepair_TSS ( { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + /* + * We can only sort the _TSS return package if there is no _PSS in the + * same scope. This is because if _PSS is present, the ACPI specification + * dictates that the _TSS Power Dissipation field is to be ignored, and + * therefore some BIOSs leave garbage values in the _TSS Power field(s). + * In this case, it is best to just return the _TSS package as-is. + * (May, 2011) + */ + Status = AcpiNsGetNode (Data->Node, "^_PSS", ACPI_NS_NO_UPSEARCH, &Node); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); + } + Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1, ACPI_SORT_DESCENDING, "PowerDissipation"); diff --git a/os_specific/service_layers/osunixxf.c b/os_specific/service_layers/osunixxf.c index 434e5fe1a41e..2ad9780ef42c 100644 --- a/os_specific/service_layers/osunixxf.c +++ b/os_specific/service_layers/osunixxf.c @@ -48,6 +48,12 @@ * * Note: Use #define __APPLE__ for OS X generation. */ +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdebug.h" + #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -57,12 +63,6 @@ #include <pthread.h> #include <errno.h> -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acparser.h" -#include "acdebug.h" - #define _COMPONENT ACPI_OS_SERVICES ACPI_MODULE_NAME ("osunixxf") @@ -815,39 +815,6 @@ AcpiOsRemoveInterruptHandler ( /****************************************************************************** * - * FUNCTION: AcpiOsExecute - * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function - * - * RETURN: Status. - * - * DESCRIPTION: Execute a new thread - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - pthread_t thread; - int ret; - - - ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context); - if (ret) - { - AcpiOsPrintf("Create thread failed"); - } - return (0); -} - - -/****************************************************************************** - * * FUNCTION: AcpiOsStall * * PARAMETERS: microseconds - Time to sleep @@ -1154,6 +1121,43 @@ AcpiOsWritable ( /****************************************************************************** * + * FUNCTION: AcpiOsSignal + * + * PARAMETERS: Function - ACPI CA signal function code + * Info - Pointer to function-dependent structure + * + * RETURN: Status + * + * DESCRIPTION: Miscellaneous functions. Example implementation only. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + break; + + case ACPI_SIGNAL_BREAKPOINT: + break; + + default: + break; + } + + return (AE_OK); +} + +/* Optional multi-thread support */ + +#ifndef ACPI_SINGLE_THREADED +/****************************************************************************** + * * FUNCTION: AcpiOsGetThreadId * * PARAMETERS: None @@ -1175,34 +1179,34 @@ AcpiOsGetThreadId ( /****************************************************************************** * - * FUNCTION: AcpiOsSignal + * FUNCTION: AcpiOsExecute * - * PARAMETERS: Function - ACPI CA signal function code - * Info - Pointer to function-dependent structure + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function * - * RETURN: Status + * RETURN: Status. * - * DESCRIPTION: Miscellaneous functions. Example implementation only. + * DESCRIPTION: Execute a new thread * *****************************************************************************/ ACPI_STATUS -AcpiOsSignal ( - UINT32 Function, - void *Info) +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) { + pthread_t thread; + int ret; - switch (Function) - { - case ACPI_SIGNAL_FATAL: - break; - - case ACPI_SIGNAL_BREAKPOINT: - break; - default: - break; + ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context); + if (ret) + { + AcpiOsPrintf("Create thread failed"); } - - return (AE_OK); + return (0); } + +#endif /* ACPI_SINGLE_THREADED */ diff --git a/os_specific/service_layers/oswinxf.c b/os_specific/service_layers/oswinxf.c index e8a49190ecf9..a931c7f22069 100644 --- a/os_specific/service_layers/oswinxf.c +++ b/os_specific/service_layers/oswinxf.c @@ -1044,60 +1044,6 @@ AcpiOsRemoveInterruptHandler ( /****************************************************************************** * - * FUNCTION: AcpiOsGetThreadId - * - * PARAMETERS: None - * - * RETURN: Id of the running thread - * - * DESCRIPTION: Get the Id of the current (running) thread - * - *****************************************************************************/ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - DWORD ThreadId; - - /* Ensure ID is never 0 */ - - ThreadId = GetCurrentThreadId (); - return ((ACPI_THREAD_ID) (ThreadId + 1)); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsExecute - * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function - * - * RETURN: Status - * - * DESCRIPTION: Execute a new thread - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - -#ifndef ACPI_SINGLE_THREADED - _beginthread (Function, (unsigned) 0, Context); -#endif - - return (0); -} - - -/****************************************************************************** - * * FUNCTION: AcpiOsStall * * PARAMETERS: Microseconds - Time to stall @@ -1436,4 +1382,61 @@ AcpiOsReleaseObject ( return (AE_OK); } -#endif +#endif /* ACPI_USE_LOCAL_CACHE */ + + +/* Optional multi-thread support */ + +#ifndef ACPI_SINGLE_THREADED +/****************************************************************************** + * + * FUNCTION: AcpiOsGetThreadId + * + * PARAMETERS: None + * + * RETURN: Id of the running thread + * + * DESCRIPTION: Get the Id of the current (running) thread + * + *****************************************************************************/ + +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + DWORD ThreadId; + + /* Ensure ID is never 0 */ + + ThreadId = GetCurrentThreadId (); + return ((ACPI_THREAD_ID) (ThreadId + 1)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsExecute + * + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function + * + * RETURN: Status + * + * DESCRIPTION: Execute a new thread + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + + _beginthread (Function, (unsigned) 0, Context); + return (0); +} + +#endif /* ACPI_SINGLE_THREADED */ + diff --git a/osunixxf.c b/osunixxf.c deleted file mode 100644 index 434e5fe1a41e..000000000000 --- a/osunixxf.c +++ /dev/null @@ -1,1208 +0,0 @@ -/****************************************************************************** - * - * Module Name: osunixxf - UNIX OSL interfaces - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2011, 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. - */ - - -/* - * These interfaces are required in order to compile the ASL compiler and the - * various ACPICA tools under Linux or other Unix-like system. - * - * Note: Use #define __APPLE__ for OS X generation. - */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> -#include <sys/time.h> -#include <semaphore.h> -#include <pthread.h> -#include <errno.h> - -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acparser.h" -#include "acdebug.h" - -#define _COMPONENT ACPI_OS_SERVICES - ACPI_MODULE_NAME ("osunixxf") - - -extern FILE *AcpiGbl_DebugFile; -FILE *AcpiGbl_OutputFile; - - -/* Upcalls to AcpiExec */ - -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - -void -AeTableOverride ( - ACPI_TABLE_HEADER *ExistingTable, - ACPI_TABLE_HEADER **NewTable); - -typedef void* (*PTHREAD_CALLBACK) (void *); - -/* Apple-specific */ - -#ifdef __APPLE__ -#define sem_destroy sem_close -#endif - - -/****************************************************************************** - * - * FUNCTION: AcpiOsInitialize, AcpiOsTerminate - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Init and terminate. Nothing to do. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsInitialize ( - void) -{ - - AcpiGbl_OutputFile = stdout; - return (AE_OK); -} - - -ACPI_STATUS -AcpiOsTerminate ( - void) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsGetRootPointer - * - * PARAMETERS: None - * - * RETURN: RSDP physical address - * - * DESCRIPTION: Gets the ACPI root pointer (RSDP) - * - *****************************************************************************/ - -ACPI_PHYSICAL_ADDRESS -AcpiOsGetRootPointer ( - void) -{ - - return (AeLocalGetRootPointer ()); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsPredefinedOverride - * - * PARAMETERS: InitVal - Initial value of the predefined object - * NewVal - The new value for the object - * - * RETURN: Status, pointer to value. Null pointer returned if not - * overriding. - * - * DESCRIPTION: Allow the OS to override predefined names - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsPredefinedOverride ( - const ACPI_PREDEFINED_NAMES *InitVal, - ACPI_STRING *NewVal) -{ - - if (!InitVal || !NewVal) - { - return (AE_BAD_PARAMETER); - } - - *NewVal = NULL; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsTableOverride - * - * PARAMETERS: ExistingTable - Header of current table (probably - * firmware) - * NewTable - Where an entire new table is returned. - * - * RETURN: Status, pointer to new table. Null pointer returned if no - * table is available to override - * - * DESCRIPTION: Return a different version of a table if one is available - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsTableOverride ( - ACPI_TABLE_HEADER *ExistingTable, - ACPI_TABLE_HEADER **NewTable) -{ - - if (!ExistingTable || !NewTable) - { - return (AE_BAD_PARAMETER); - } - - *NewTable = NULL; - -#ifdef ACPI_EXEC_APP - - AeTableOverride (ExistingTable, NewTable); - return (AE_OK); -#else - - return (AE_NO_ACPI_TABLES); -#endif -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsRedirectOutput - * - * PARAMETERS: Destination - An open file handle/pointer - * - * RETURN: None - * - * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf - * - *****************************************************************************/ - -void -AcpiOsRedirectOutput ( - void *Destination) -{ - - AcpiGbl_OutputFile = Destination; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsPrintf - * - * PARAMETERS: fmt, ... - Standard printf format - * - * RETURN: None - * - * DESCRIPTION: Formatted output - * - *****************************************************************************/ - -void ACPI_INTERNAL_VAR_XFACE -AcpiOsPrintf ( - const char *Fmt, - ...) -{ - va_list Args; - - - va_start (Args, Fmt); - AcpiOsVprintf (Fmt, Args); - va_end (Args); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsVprintf - * - * PARAMETERS: fmt - Standard printf format - * args - Argument list - * - * RETURN: None - * - * DESCRIPTION: Formatted output with argument list pointer - * - *****************************************************************************/ - -void -AcpiOsVprintf ( - const char *Fmt, - va_list Args) -{ - INT32 Count = 0; - UINT8 Flags; - - - Flags = AcpiGbl_DbOutputFlags; - if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) - { - /* Output is directable to either a file (if open) or the console */ - - if (AcpiGbl_DebugFile) - { - /* Output file is open, send the output there */ - - Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args); - } - else - { - /* No redirection, send output to console (once only!) */ - - Flags |= ACPI_DB_CONSOLE_OUTPUT; - } - } - - if (Flags & ACPI_DB_CONSOLE_OUTPUT) - { - Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args); - } -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsGetLine - * - * PARAMETERS: Buffer - Where to return the command line - * BufferLength - Maximum length of Buffer - * BytesRead - Where the actual byte count is returned - * - * RETURN: Status and actual bytes read - * - * DESCRIPTION: Formatted input with argument list pointer - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsGetLine ( - char *Buffer, - UINT32 BufferLength, - UINT32 *BytesRead) -{ - UINT8 Temp; - UINT32 i; - - - for (i = 0; ; i++) - { - if (i >= BufferLength) - { - return (AE_BUFFER_OVERFLOW); - } - - scanf ("%1c", &Temp); - if (!Temp || Temp == '\n') - { - break; - } - - Buffer [i] = Temp; - } - - /* Null terminate the buffer */ - - Buffer [i] = 0; - - /* Return the number of bytes in the string */ - - if (BytesRead) - { - *BytesRead = i; - } - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsMapMemory - * - * PARAMETERS: where - Physical address of memory to be mapped - * length - How much memory to map - * - * RETURN: Pointer to mapped memory. Null on error. - * - * DESCRIPTION: Map physical memory into caller's address space - * - *****************************************************************************/ - -void * -AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS where, - ACPI_SIZE length) -{ - - return (ACPI_TO_POINTER ((ACPI_SIZE) where)); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsUnmapMemory - * - * PARAMETERS: where - Logical address of memory to be unmapped - * length - How much memory to unmap - * - * RETURN: None. - * - * DESCRIPTION: Delete a previously created mapping. Where and Length must - * correspond to a previous mapping exactly. - * - *****************************************************************************/ - -void -AcpiOsUnmapMemory ( - void *where, - ACPI_SIZE length) -{ - - return; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsAllocate - * - * PARAMETERS: Size - Amount to allocate, in bytes - * - * RETURN: Pointer to the new allocation. Null on error. - * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. - * - *****************************************************************************/ - -void * -AcpiOsAllocate ( - ACPI_SIZE size) -{ - void *Mem; - - - Mem = (void *) malloc ((size_t) size); - return (Mem); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsFree - * - * PARAMETERS: mem - Pointer to previously allocated memory - * - * RETURN: None. - * - * DESCRIPTION: Free memory allocated via AcpiOsAllocate - * - *****************************************************************************/ - -void -AcpiOsFree ( - void *mem) -{ - - free (mem); -} - - -#ifdef ACPI_SINGLE_THREADED -/****************************************************************************** - * - * FUNCTION: Semaphore stub functions - * - * DESCRIPTION: Stub functions used for single-thread applications that do - * not require semaphore synchronization. Full implementations - * of these functions appear after the stubs. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsCreateSemaphore ( - UINT32 MaxUnits, - UINT32 InitialUnits, - ACPI_HANDLE *OutHandle) -{ - *OutHandle = (ACPI_HANDLE) 1; - return (AE_OK); -} - -ACPI_STATUS -AcpiOsDeleteSemaphore ( - ACPI_HANDLE Handle) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiOsWaitSemaphore ( - ACPI_HANDLE Handle, - UINT32 Units, - UINT16 Timeout) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiOsSignalSemaphore ( - ACPI_HANDLE Handle, - UINT32 Units) -{ - return (AE_OK); -} - -#else -/****************************************************************************** - * - * FUNCTION: AcpiOsCreateSemaphore - * - * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore - * OutHandle - Where a handle will be returned - * - * RETURN: Status - * - * DESCRIPTION: Create an OS semaphore - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsCreateSemaphore ( - UINT32 MaxUnits, - UINT32 InitialUnits, - ACPI_HANDLE *OutHandle) -{ - sem_t *Sem; - - - if (!OutHandle) - { - return (AE_BAD_PARAMETER); - } - -#ifdef __APPLE__ - { - char *SemaphoreName = tmpnam (NULL); - - Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); - if (!Sem) - { - return (AE_NO_MEMORY); - } - sem_unlink (SemaphoreName); /* This just deletes the name */ - } - -#else - Sem = AcpiOsAllocate (sizeof (sem_t)); - if (!Sem) - { - return (AE_NO_MEMORY); - } - - if (sem_init (Sem, 0, InitialUnits) == -1) - { - AcpiOsFree (Sem); - return (AE_BAD_PARAMETER); - } -#endif - - *OutHandle = (ACPI_HANDLE) Sem; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsDeleteSemaphore - * - * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore - * - * RETURN: Status - * - * DESCRIPTION: Delete an OS semaphore - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsDeleteSemaphore ( - ACPI_HANDLE Handle) -{ - sem_t *Sem = (sem_t *) Handle; - - - if (!Sem) - { - return (AE_BAD_PARAMETER); - } - - if (sem_destroy (Sem) == -1) - { - return (AE_BAD_PARAMETER); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsWaitSemaphore - * - * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore - * Units - How many units to wait for - * Timeout - How long to wait - * - * RETURN: Status - * - * DESCRIPTION: Wait for units - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsWaitSemaphore ( - ACPI_HANDLE Handle, - UINT32 Units, - UINT16 Timeout) -{ - ACPI_STATUS Status = AE_OK; - sem_t *Sem = (sem_t *) Handle; - struct timespec T; - - - if (!Sem) - { - return (AE_BAD_PARAMETER); - } - - switch (Timeout) - { - /* - * No Wait: - * -------- - * A zero timeout value indicates that we shouldn't wait - just - * acquire the semaphore if available otherwise return AE_TIME - * (a.k.a. 'would block'). - */ - case 0: - - if (sem_trywait(Sem) == -1) - { - Status = (AE_TIME); - } - break; - - /* Wait Indefinitely */ - - case ACPI_WAIT_FOREVER: - - if (sem_wait (Sem)) - { - Status = (AE_TIME); - } - break; - - /* Wait with Timeout */ - - default: - - T.tv_sec = Timeout / 1000; - T.tv_nsec = (Timeout - (T.tv_sec * 1000)) * 1000000; - -#ifdef ACPI_USE_ALTERNATE_TIMEOUT - /* - * Alternate timeout mechanism for environments where - * sem_timedwait is not available or does not work properly. - */ - while (Timeout) - { - if (sem_trywait (Sem) == 0) - { - /* Got the semaphore */ - return (AE_OK); - } - usleep (1000); /* one millisecond */ - Timeout--; - } - Status = (AE_TIME); -#else - - if (sem_timedwait (Sem, &T)) - { - Status = (AE_TIME); - } -#endif - - break; - } - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsSignalSemaphore - * - * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore - * Units - Number of units to send - * - * RETURN: Status - * - * DESCRIPTION: Send units - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsSignalSemaphore ( - ACPI_HANDLE Handle, - UINT32 Units) -{ - sem_t *Sem = (sem_t *)Handle; - - - if (!Sem) - { - return (AE_BAD_PARAMETER); - } - - if (sem_post (Sem) == -1) - { - return (AE_LIMIT); - } - - return (AE_OK); -} - -#endif /* ACPI_SINGLE_THREADED */ - - -/****************************************************************************** - * - * FUNCTION: Spinlock interfaces - * - * DESCRIPTION: Map these interfaces to semaphore interfaces - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsCreateLock ( - ACPI_SPINLOCK *OutHandle) -{ - - return (AcpiOsCreateSemaphore (1, 1, OutHandle)); -} - - -void -AcpiOsDeleteLock ( - ACPI_SPINLOCK Handle) -{ - AcpiOsDeleteSemaphore (Handle); -} - - -ACPI_CPU_FLAGS -AcpiOsAcquireLock ( - ACPI_HANDLE Handle) -{ - AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); - return (0); -} - - -void -AcpiOsReleaseLock ( - ACPI_SPINLOCK Handle, - ACPI_CPU_FLAGS Flags) -{ - AcpiOsSignalSemaphore (Handle, 1); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsInstallInterruptHandler - * - * PARAMETERS: InterruptNumber - Level handler should respond to. - * Isr - Address of the ACPI interrupt handler - * ExceptPtr - Where status is returned - * - * RETURN: Handle to the newly installed handler. - * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI - * OS-independent handler. - * - *****************************************************************************/ - -UINT32 -AcpiOsInstallInterruptHandler ( - UINT32 InterruptNumber, - ACPI_OSD_HANDLER ServiceRoutine, - void *Context) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsRemoveInterruptHandler - * - * PARAMETERS: Handle - Returned when handler was installed - * - * RETURN: Status - * - * DESCRIPTION: Uninstalls an interrupt handler. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsRemoveInterruptHandler ( - UINT32 InterruptNumber, - ACPI_OSD_HANDLER ServiceRoutine) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsExecute - * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function - * - * RETURN: Status. - * - * DESCRIPTION: Execute a new thread - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - pthread_t thread; - int ret; - - - ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context); - if (ret) - { - AcpiOsPrintf("Create thread failed"); - } - return (0); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsStall - * - * PARAMETERS: microseconds - Time to sleep - * - * RETURN: Blocks until sleep is completed. - * - * DESCRIPTION: Sleep at microsecond granularity - * - *****************************************************************************/ - -void -AcpiOsStall ( - UINT32 microseconds) -{ - - if (microseconds) - { - usleep (microseconds); - } -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsSleep - * - * PARAMETERS: milliseconds - Time to sleep - * - * RETURN: Blocks until sleep is completed. - * - * DESCRIPTION: Sleep at millisecond granularity - * - *****************************************************************************/ - -void -AcpiOsSleep ( - UINT64 milliseconds) -{ - - sleep (milliseconds / 1000); /* Sleep for whole seconds */ - - /* - * Arg to usleep() must be less than 1,000,000 (1 second) - */ - usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */ -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsGetTimer - * - * PARAMETERS: None - * - * RETURN: Current time in 100 nanosecond units - * - * DESCRIPTION: Get the current system time - * - *****************************************************************************/ - -UINT64 -AcpiOsGetTimer ( - void) -{ - struct timeval time; - - - gettimeofday (&time, NULL); - - /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */ - - return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10)); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsReadPciConfiguration - * - * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register - * Value - Buffer where value is placed - * Width - Number of bits - * - * RETURN: Status - * - * DESCRIPTION: Read data from PCI configuration space - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsReadPciConfiguration ( - ACPI_PCI_ID *PciId, - UINT32 Register, - UINT64 *Value, - UINT32 Width) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsWritePciConfiguration - * - * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register - * Value - Value to be written - * Width - Number of bits - * - * RETURN: Status. - * - * DESCRIPTION: Write data to PCI configuration space - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsWritePciConfiguration ( - ACPI_PCI_ID *PciId, - UINT32 Register, - UINT64 Value, - UINT32 Width) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsReadPort - * - * PARAMETERS: Address - Address of I/O port/register to read - * Value - Where value is placed - * Width - Number of bits - * - * RETURN: Value read from port - * - * DESCRIPTION: Read data from an I/O port or register - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsReadPort ( - ACPI_IO_ADDRESS Address, - UINT32 *Value, - UINT32 Width) -{ - - switch (Width) - { - case 8: - *Value = 0xFF; - break; - - case 16: - *Value = 0xFFFF; - break; - - case 32: - *Value = 0xFFFFFFFF; - break; - - default: - return (AE_BAD_PARAMETER); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsWritePort - * - * PARAMETERS: Address - Address of I/O port/register to write - * Value - Value to write - * Width - Number of bits - * - * RETURN: None - * - * DESCRIPTION: Write data to an I/O port or register - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsWritePort ( - ACPI_IO_ADDRESS Address, - UINT32 Value, - UINT32 Width) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsReadMemory - * - * PARAMETERS: Address - Physical Memory Address to read - * Value - Where value is placed - * Width - Number of bits - * - * RETURN: Value read from physical memory address - * - * DESCRIPTION: Read data from a physical memory address - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsReadMemory ( - ACPI_PHYSICAL_ADDRESS Address, - UINT32 *Value, - UINT32 Width) -{ - - switch (Width) - { - case 8: - case 16: - case 32: - *Value = 0; - break; - - default: - return (AE_BAD_PARAMETER); - } - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsWriteMemory - * - * PARAMETERS: Address - Physical Memory Address to write - * Value - Value to write - * Width - Number of bits - * - * RETURN: None - * - * DESCRIPTION: Write data to a physical memory address - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsWriteMemory ( - ACPI_PHYSICAL_ADDRESS Address, - UINT32 Value, - UINT32 Width) -{ - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsReadable - * - * PARAMETERS: Pointer - Area to be verified - * Length - Size of area - * - * RETURN: TRUE if readable for entire length - * - * DESCRIPTION: Verify that a pointer is valid for reading - * - *****************************************************************************/ - -BOOLEAN -AcpiOsReadable ( - void *Pointer, - ACPI_SIZE Length) -{ - - return (TRUE); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsWritable - * - * PARAMETERS: Pointer - Area to be verified - * Length - Size of area - * - * RETURN: TRUE if writable for entire length - * - * DESCRIPTION: Verify that a pointer is valid for writing - * - *****************************************************************************/ - -BOOLEAN -AcpiOsWritable ( - void *Pointer, - ACPI_SIZE Length) -{ - - return (TRUE); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsGetThreadId - * - * PARAMETERS: None - * - * RETURN: Id of the running thread - * - * DESCRIPTION: Get the ID of the current (running) thread - * - *****************************************************************************/ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - - return (ACPI_CAST_PTHREAD_T (pthread_self())); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiOsSignal - * - * PARAMETERS: Function - ACPI CA signal function code - * Info - Pointer to function-dependent structure - * - * RETURN: Status - * - * DESCRIPTION: Miscellaneous functions. Example implementation only. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsSignal ( - UINT32 Function, - void *Info) -{ - - switch (Function) - { - case ACPI_SIGNAL_FATAL: - break; - - case ACPI_SIGNAL_BREAKPOINT: - break; - - default: - break; - } - - return (AE_OK); -} diff --git a/tools/acpibin/Makefile b/tools/acpibin/Makefile new file mode 100644 index 000000000000..d1aa7d38715c --- /dev/null +++ b/tools/acpibin/Makefile @@ -0,0 +1,139 @@ +# +# acpibin - Binary ACPI table utility +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# + +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROG = acpibin + +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? + +ACPICA_COMPONENTS = +ACPICA_SRC = ../.. +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) + +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_BIN_APP \ + -I$(ACPICA_SRC)/include + +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef + +OBJS = \ + abcompare.o \ + abmain.o \ + utalloc.o \ + utcache.o \ + utdebug.o \ + utdecode.o \ + utglobal.o \ + utlock.o \ + utmath.o \ + utmisc.o \ + utmutex.o \ + utstate.o \ + utxferror.o \ + osunixxf.o \ + getopt.o + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + +# +# acpibin source +# +abcompare.o : $(ACPICA_TOOLS)/acpibin/abcompare.c + $(COMPILE) + +abmain.o : $(ACPICA_TOOLS)/acpibin/abmain.c + $(COMPILE) + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + +# +# ACPICA core source +# +utalloc.o : $(ACPICA_CORE)/utilities/utalloc.c + $(COMPILE) + +utcache.o : $(ACPICA_CORE)/utilities/utcache.c + $(COMPILE) + +utdebug.o : $(ACPICA_CORE)/utilities/utdebug.c + $(COMPILE) + +utdecode.o : $(ACPICA_CORE)/utilities/utdecode.c + $(COMPILE) + +utglobal.o : $(ACPICA_CORE)/utilities/utglobal.c + $(COMPILE) + +utlock.o : $(ACPICA_CORE)/utilities/utlock.c + $(COMPILE) + +utmath.o : $(ACPICA_CORE)/utilities/utmath.c + $(COMPILE) + +utmisc.o : $(ACPICA_CORE)/utilities/utmisc.c + $(COMPILE) + +utmutex.o : $(ACPICA_CORE)/utilities/utmutex.c + $(COMPILE) + +utstate.o : $(ACPICA_CORE)/utilities/utstate.c + $(COMPILE) + +utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c + $(COMPILE) + +# +# Unix OS services layer (OSL) +# +osunixxf.o : $(ACPICA_OSL)/osunixxf.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG) $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/acpibin/abcompare.c b/tools/acpibin/abcompare.c new file mode 100644 index 000000000000..1c703fd8933b --- /dev/null +++ b/tools/acpibin/abcompare.c @@ -0,0 +1,767 @@ + +/****************************************************************************** + * + * Module Name: abcompare - compare AML files + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpibin.h" + + +FILE *File1; +FILE *File2; +ACPI_TABLE_HEADER Header1; +ACPI_TABLE_HEADER Header2; +struct stat Gbl_StatBuf; + +#define BUFFER_SIZE 256 +char Buffer[BUFFER_SIZE]; + + +/* Local prototypes */ + +static BOOLEAN +AbValidateHeader ( + ACPI_TABLE_HEADER *Header); + +static UINT8 +AcpiTbSumTable ( + void *Buffer, + UINT32 Length); + +static char * +AbGetFile ( + char *Filename, + UINT32 *FileSize); + +static void +AbPrintHeaderInfo ( + ACPI_TABLE_HEADER *Header); + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( + void); + + +/******************************************************************************* + * + * FUNCTION: UtHexCharToValue + * + * PARAMETERS: HexChar - Hex character in Ascii + * + * RETURN: The binary value of the hex character + * + * DESCRIPTION: Perform ascii-to-hex translation + * + ******************************************************************************/ + +static UINT8 +UtHexCharToValue ( + int HexChar, + UINT8 *OutBinary) +{ + + if (HexChar >= 0x30 && HexChar <= 0x39) + { + *OutBinary = (UINT8) (HexChar - 0x30); + return (1); + } + + else if (HexChar >= 0x41 && HexChar <= 0x46) + { + *OutBinary = (UINT8) (HexChar - 0x37); + return (1); + } + + else if (HexChar >= 0x61 && HexChar <= 0x66) + { + *OutBinary = (UINT8) (HexChar - 0x57); + return (1); + } + return (0); +} + +static UINT8 +AbHexByteToBinary ( + char *HexString, + char *OutBinary) +{ + UINT8 Local1; + UINT8 Local2; + + + if (!UtHexCharToValue (HexString[0], &Local1)) + { + return (0); + } + if (!UtHexCharToValue (HexString[1], &Local2)) + { + return (0); + } + + *OutBinary = (UINT8) ((Local1 << 4) | Local2); + return (2); + +} + + +/****************************************************************************** + * + * FUNCTION: AbValidateHeader + * + * DESCRIPTION: Check for valid ACPI table header + * + ******************************************************************************/ + +static BOOLEAN +AbValidateHeader ( + ACPI_TABLE_HEADER *Header) +{ + + if (!AcpiUtValidAcpiName (* (UINT32 *) &Header->Signature)) + { + printf ("Header signature is invalid\n"); + return FALSE; + } + + return TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSumTable + * + * PARAMETERS: Buffer - Buffer to checksum + * Length - Size of the buffer + * + * RETURNS 8 bit checksum of buffer + * + * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. + * + ******************************************************************************/ + +static UINT8 +AcpiTbSumTable ( + void *Buffer, + UINT32 Length) +{ + const UINT8 *limit; + const UINT8 *rover; + UINT8 sum = 0; + + + if (Buffer && Length) + { + /* Buffer and Length are valid */ + + limit = (UINT8 *) Buffer + Length; + + for (rover = Buffer; rover < limit; rover++) + { + sum = (UINT8) (sum + *rover); + } + } + return (sum); +} + + +/******************************************************************************* + * + * FUNCTION: AbPrintHeaderInfo + * + * PARAMETERS: Header - An ACPI table header + * + * RETURNS None. + * + * DESCRIPTION: Format and display header contents. + * + ******************************************************************************/ + +static void +AbPrintHeaderInfo ( + ACPI_TABLE_HEADER *Header) +{ + + /* Display header information */ + + printf ("Signature : %4.4s\n", Header->Signature); + printf ("Length : %8.8X\n", Header->Length); + printf ("Revision : %2.2X\n", Header->Revision); + printf ("Checksum : %2.2X\n", Header->Checksum); + printf ("OEM ID : %6.6s\n", Header->OemId); + printf ("OEM Table ID : %8.8s\n", Header->OemTableId); + printf ("OEM Revision : %8.8X\n", Header->OemRevision); + printf ("ASL Compiler ID : %4.4s\n", Header->AslCompilerId); + printf ("Compiler Revision : %8.8X\n", Header->AslCompilerRevision); + printf ("\n"); +} + + +/****************************************************************************** + * + * FUNCTION: AbDisplayHeader + * + * DESCRIPTION: Display an ACPI table header + * + ******************************************************************************/ + +void +AbDisplayHeader ( + char *File1Path) +{ + UINT32 Actual1; + + + File1 = fopen (File1Path, "rb"); + if (!File1) + { + printf ("Could not open file %s\n", File1Path); + return; + } + + Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + if (Actual1 < sizeof (ACPI_TABLE_HEADER)) + { + printf ("File %s does not contain an ACPI table header\n", File1Path); + return; + } + + if (!AbValidateHeader (&Header1)) + { + return; + } + + AbPrintHeaderInfo (&Header1); +} + + +/****************************************************************************** + * + * FUNCTION: AbComputeChecksum + * + * DESCRIPTION: Compute proper checksum for an ACPI table + * + ******************************************************************************/ + +void +AbComputeChecksum ( + char *File1Path) +{ + UINT32 Actual1; + ACPI_TABLE_HEADER *Table; + UINT8 Checksum; + + + File1 = fopen (File1Path, "rb"); + if (!File1) + { + printf ("Could not open file %s\n", File1Path); + return; + } + + Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + if (Actual1 < sizeof (ACPI_TABLE_HEADER)) + { + printf ("File %s does not contain an ACPI table header\n", File1Path); + return; + } + + if (!AbValidateHeader (&Header1)) + { + return; + } + + if (!Gbl_TerseMode) + { + AbPrintHeaderInfo (&Header1); + } + + /* Allocate a buffer to hold the entire table */ + + Table = AcpiOsAllocate (Header1.Length); + if (!Table) + { + printf ("could not allocate\n"); + return; + } + + /* Read the entire table, including header */ + + fseek (File1, 0, SEEK_SET); + Actual1 = fread (Table, 1, Header1.Length, File1); + if (Actual1 < Header1.Length) + { + printf ("could not read table\n"); + return; + } + + /* Compute the checksum for the table */ + + Table->Checksum = 0; + + Checksum = (UINT8) (0 - AcpiTbSumTable (Table, Table->Length)); + printf ("Computed checksum: 0x%X\n\n", Checksum); + + if (Header1.Checksum == Checksum) + { + printf ("Checksum ok in AML file, not updating\n"); + return; + } + + /* Open the target file for writing, to update checksum */ + + fclose (File1); + File1 = fopen (File1Path, "r+b"); + if (!File1) + { + printf ("Could not open file %s for writing\n", File1Path); + return; + } + + /* Set the checksum, write the new header */ + + Header1.Checksum = Checksum; + + Actual1 = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + if (Actual1 < sizeof (ACPI_TABLE_HEADER)) + { + printf ("Could not write updated table header\n"); + return; + } + + printf ("Wrote new checksum\n"); + return; +} + + +/****************************************************************************** + * + * FUNCTION: AbCompareAmlFiles + * + * DESCRIPTION: Compare two AML files + * + ******************************************************************************/ + +int +AbCompareAmlFiles ( + char *File1Path, + char *File2Path) +{ + UINT32 Actual1; + UINT32 Actual2; + UINT32 Offset; + UINT8 Char1; + UINT8 Char2; + UINT8 Mismatches = 0; + BOOLEAN HeaderMismatch = FALSE; + + + File1 = fopen (File1Path, "rb"); + if (!File1) + { + printf ("Could not open file %s\n", File1Path); + return -1; + } + + File2 = fopen (File2Path, "rb"); + if (!File2) + { + printf ("Could not open file %s\n", File2Path); + return -1; + } + + /* Read the ACPI header from each file */ + + Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + if (Actual1 < sizeof (ACPI_TABLE_HEADER)) + { + printf ("File %s does not contain an ACPI table header\n", File1Path); + return -1; + } + + Actual2 = fread (&Header2, 1, sizeof (ACPI_TABLE_HEADER), File2); + if (Actual2 < sizeof (ACPI_TABLE_HEADER)) + { + printf ("File %s does not contain an ACPI table header\n", File2Path); + return -1; + } + + if ((!AbValidateHeader (&Header1)) || + (!AbValidateHeader (&Header2))) + { + return -1; + } + + /* Table signatures must match */ + + if (*((UINT32 *) Header1.Signature) != *((UINT32 *) Header2.Signature)) + { + printf ("Table signatures do not match\n"); + return -1; + } + + if (!Gbl_TerseMode) + { + /* Display header information */ + + AbPrintHeaderInfo (&Header1); + AbPrintHeaderInfo (&Header2); + } + + if (memcmp (Header1.Signature, Header2.Signature, sizeof (ACPI_TABLE_HEADER))) + { + printf ("Headers do not match exactly\n"); + HeaderMismatch = TRUE; + } + + /* Do the byte-by-byte compare */ + + Actual1 = fread (&Char1, 1, 1, File1); + Actual2 = fread (&Char2, 1, 1, File2); + Offset = sizeof (ACPI_TABLE_HEADER); + + while (Actual1 && Actual2) + { + if (Char1 != Char2) + { + printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n", + Offset, Char1, Char2); + Mismatches++; + if (Mismatches > 100) + { + printf ("100 Mismatches: Too many mismatches\n"); + return -1; + } + } + + Offset++; + Actual1 = fread (&Char1, 1, 1, File1); + Actual2 = fread (&Char2, 1, 1, File2); + } + + if (Actual1) + { + printf ("Error - file %s is longer than file %s\n", File1Path, File2Path); + Mismatches++; + } + else if (Actual2) + { + printf ("Error - file %s is shorter than file %s\n", File1Path, File2Path); + Mismatches++; + } + else if (!Mismatches) + { + if (HeaderMismatch) + { + printf ("Files compare exactly after header\n"); + } + else + { + printf ("Files compare exactly\n"); + } + } + + printf ("%u Mismatches found\n", Mismatches); + return 0; +} + + +/****************************************************************************** + * + * FUNCTION: AsGetFile + * + * DESCRIPTION: Open a file and read it entirely into a new buffer + * + ******************************************************************************/ + +static char * +AbGetFile ( + char *Filename, + UINT32 *FileSize) +{ + int FileHandle; + UINT32 Size; + char *Buffer = NULL; + + + /* Binary mode does not alter CR/LF pairs */ + + FileHandle = open (Filename, O_BINARY | O_RDONLY); + if (!FileHandle) + { + printf ("Could not open %s\n", Filename); + return NULL; + } + + /* Need file size to allocate a buffer */ + + if (fstat (FileHandle, &Gbl_StatBuf)) + { + printf ("Could not get file status for %s\n", Filename); + goto ErrorExit; + } + + /* Allocate a buffer for the entire file */ + + Size = Gbl_StatBuf.st_size; + Buffer = calloc (Size, 1); + if (!Buffer) + { + printf ("Could not allocate buffer of size %u\n", Size); + goto ErrorExit; + } + + /* Read the entire file */ + + Size = read (FileHandle, Buffer, Size); + if (Size == -1) + { + printf ("Could not read the input file %s\n", Filename); + free (Buffer); + Buffer = NULL; + goto ErrorExit; + } + + *FileSize = Size; + +ErrorExit: + close (FileHandle); + + return (Buffer); +} + + +/****************************************************************************** + * + * FUNCTION: AbDumpAmlFile + * + * DESCRIPTION: Dump a binary AML file to a text file + * + ******************************************************************************/ + +int +AbDumpAmlFile ( + char *File1Path, + char *File2Path) +{ + char *FileBuffer; + UINT32 FileSize = 0; + FILE *FileOutHandle; + + + /* Get the entire AML file, validate header */ + + FileBuffer = AbGetFile (File1Path, &FileSize); + printf ("File %s contains 0x%X bytes\n\n", File1Path, FileSize); + + FileOutHandle = fopen (File2Path, "wb"); + if (!FileOutHandle) + { + printf ("Could not open %s\n", File2Path); + return -1; + } + + if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer)) + { + return -1; + } + + /* Convert binary AML to text, using common dump buffer routine */ + + AcpiGbl_DebugFile = FileOutHandle; + AcpiGbl_DbOutputFlags = ACPI_DB_REDIRECTABLE_OUTPUT; + + AcpiOsPrintf ("%4.4s\n", ((ACPI_TABLE_HEADER *) FileBuffer)->Signature); + AcpiDbgLevel = ACPI_UINT32_MAX; + AcpiUtDumpBuffer ((UINT8 *) FileBuffer, FileSize, + DB_BYTE_DISPLAY, ACPI_UINT32_MAX); + + return 0; +} + + +/****************************************************************************** + * + * FUNCTION: AbExtractAmlFile + * + * DESCRIPTION: Extract a binary AML file from a text file (as produced by the + * DumpAmlFile procedure or the "acpidmp" table utility. + * + ******************************************************************************/ + +int +AbExtractAmlFile ( + char *TableSig, + char *File1Path, + char *File2Path) +{ + char *Table; + char Value; + UINT32 i; + FILE *FileHandle; + FILE *FileOutHandle; + UINT32 Count = 0; + int Scanned; + + + /* Open in/out files. input is in text mode, output is in binary mode */ + + FileHandle = fopen (File1Path, "rt"); + if (!FileHandle) + { + printf ("Could not open %s\n", File1Path); + return -1; + } + + FileOutHandle = fopen (File2Path, "w+b"); + if (!FileOutHandle) + { + printf ("Could not open %s\n", File2Path); + return -1; + } + + /* Force input table sig to uppercase */ + + AcpiUtStrupr (TableSig); + + + /* TBD: examine input for ASCII */ + + + /* We have an ascii file, grab one line at a time */ + + while (fgets (Buffer, BUFFER_SIZE, FileHandle)) + { + /* The 4-char ACPI signature appears at the beginning of a line */ + + if (!strncmp (Buffer, TableSig, 4)) + { + printf ("Found table [%4.4s]\n", TableSig); + + /* + * Eat all lines in the table, of the form: + * <offset>: <16 bytes of hex data, separated by spaces> <ASCII representation> <newline> + * + * Example: + * + * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........ + * + */ + while (fgets (Buffer, BUFFER_SIZE, FileHandle)) + { + /* Get past the offset, terminated by a colon */ + + Table = strchr (Buffer, ':'); + if (!Table) + { + /* No colon, all done */ + goto Exit; + } + + Table += 2; /* Eat the colon + space */ + + for (i = 0; i < 16; i++) + { + Scanned = AbHexByteToBinary (Table, &Value); + if (!Scanned) + { + goto Exit; + } + + Table += 3; /* Go past this hex byte and space */ + + /* Write the converted (binary) byte */ + + fwrite (&Value, 1, 1, FileOutHandle); + Count++; + } + } + + /* No more lines, EOF, all done */ + + goto Exit; + } + } + + /* Searched entire file, no match to table signature */ + + printf ("Could not match table signature\n"); + fclose (FileHandle); + return -1; + +Exit: + printf ("%u (0x%X) bytes written to %s\n", Count, Count, File2Path); + fclose (FileHandle); + fclose (FileOutHandle); + return 0; +} + + +/****************************************************************************** + * + * FUNCTION: Stubs + * + * DESCRIPTION: For linkage + * + ******************************************************************************/ + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( + void) +{ + return AE_OK; +} + +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (0xFFFF); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_SUPPORT); +} diff --git a/tools/acpibin/abmain.c b/tools/acpibin/abmain.c new file mode 100644 index 000000000000..3d84cc7c7681 --- /dev/null +++ b/tools/acpibin/abmain.c @@ -0,0 +1,190 @@ + +/****************************************************************************** + * + * Module Name: abmain - Main module for the acpi binary utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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. + */ + + +#define _DECLARE_GLOBALS +#include "acpibin.h" +#include "acapps.h" + +/* Local prototypes */ + +static void +AbDisplayUsage ( + UINT8 OptionCount); + + +/****************************************************************************** + * + * FUNCTION: AbDisplayUsage + * + * DESCRIPTION: Usage message + * + ******************************************************************************/ + +static void +AbDisplayUsage ( + UINT8 OptionCount) +{ + + if (OptionCount) + { + printf ("Option requires %u arguments\n\n", OptionCount); + } + + printf ("Usage: acpibin [options]\n\n"); + printf ("Options:\n\n"); + printf (" -c <File1> <File2> Compare two AML files\n"); + printf (" -d <InFile> <OutFile> Dump AML binary to text file\n"); + printf (" -e <Sig> <InFile> <OutFile> Extract binary AML table from AcpiDmp file\n\n"); + + printf (" -h <File> Display table header for binary AML file\n"); + printf (" -s <File> Update checksum for binary AML file\n"); + printf (" -t Terse mode\n"); + + printf ("\n"); + return; +} + + +/****************************************************************************** + * + * FUNCTION: main + * + * DESCRIPTION: C main function + * + ******************************************************************************/ + +int ACPI_SYSTEM_XFACE +main ( + int argc, + char *argv[]) +{ + int j; + int Status = AE_OK; + + + AcpiGbl_DebugFile = NULL; + AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT ; + + AcpiOsInitialize (); + printf (ACPI_COMMON_SIGNON ("ACPI Binary AML File Utility")); + + if (argc < 2) + { + AbDisplayUsage (0); + return 0; + } + + /* Command line options */ + + while ((j = AcpiGetopt (argc, argv, "c:d:e:h:s:t")) != EOF) switch(j) + { + case 'c': /* Compare Files */ + + if (argc < 4) + { + AbDisplayUsage (2); + return -1; + } + + Status = AbCompareAmlFiles (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); + break; + + case 'd': /* Dump AML file */ + + if (argc < 4) + { + AbDisplayUsage (2); + return -1; + } + + Status = AbDumpAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); + break; + + case 'e': /* Extract AML text file */ + + if (argc < 5) + { + AbDisplayUsage (3); + return -1; + } + + Status = AbExtractAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind], + argv[AcpiGbl_Optind+1]); + break; + + case 'h': /* Display ACPI table header */ + + if (argc < 3) + { + AbDisplayUsage (1); + return -1; + } + + AbDisplayHeader (AcpiGbl_Optarg); + return (0); + + case 's': /* Compute/update checksum */ + + if (argc < 3) + { + AbDisplayUsage (1); + return -1; + } + + AbComputeChecksum (AcpiGbl_Optarg); + return (0); + + case 't': /* Enable terse mode */ + + Gbl_TerseMode = TRUE; + break; + + default: + AbDisplayUsage (0); + return -1; + } + + return Status; +} diff --git a/tools/acpibin/acpibin.h b/tools/acpibin/acpibin.h new file mode 100644 index 000000000000..4da7617b3d1d --- /dev/null +++ b/tools/acpibin/acpibin.h @@ -0,0 +1,113 @@ + +/****************************************************************************** + * + * Module Name: acpibinh - Include file for AcpiBin utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpi.h" +#include "accommon.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include <ctype.h> +#include <errno.h> + +#ifdef WIN32 +#include <stdlib.h> +#include <io.h> +#include <direct.h> +#endif + +/* O_BINARY is not always defined */ +#ifndef O_BINARY +#define O_BINARY 0x0 +#endif + +#define DB_CONSOLE_OUTPUT 0x02 +#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 + +/* + * Global variables. Defined in main.c only, externed in all other files + */ + +#ifdef _DECLARE_GLOBALS +#define EXTERN +#define INIT_GLOBAL(a,b) a=b +#else +#define EXTERN extern +#define INIT_GLOBAL(a,b) a +#endif + + +/* Globals */ + +EXTERN BOOLEAN INIT_GLOBAL (Gbl_TerseMode, FALSE); +EXTERN FILE INIT_GLOBAL (*AcpiGbl_DebugFile, NULL); + + +/* Prototypes */ + +int +AbCompareAmlFiles ( + char *File1Path, + char *File2Path); + +int +AbExtractAmlFile ( + char *TableSig, + char *File1Path, + char *File2Path); + +int +AbDumpAmlFile ( + char *File1Path, + char *File2Path); + +void +AbComputeChecksum ( + char *File1Path); + +void +AbDisplayHeader ( + char *File1Path); + diff --git a/tools/acpiexec/Makefile b/tools/acpiexec/Makefile index ec7b093376ae..897a1928fb91 100644 --- a/tools/acpiexec/Makefile +++ b/tools/acpiexec/Makefile @@ -1,20 +1,58 @@ # -# AcpiExec utility +# acpiexec: ACPI execution simulator. Runs ACPICA code in user +# space. Loads ACPI tables, displays the namespace, and allows +# execution of control methods. +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. # +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# PROG = acpiexec +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? +LDFLAGS += -lpthread -lrt + +ACPICA_COMPONENTS = ACPICA_SRC = ../.. ACPICA_COMMON = $(ACPICA_SRC)/common -ACPICA_CORE = $(ACPICA_SRC) +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) ACPICA_TOOLS = $(ACPICA_SRC)/tools ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers - -NOMAN= YES -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -Wstrict-prototypes -I$(ACPICA_SRC)/include - -COMPILE = $(CC) -c $(CFLAGS) -o$@ $? -LDFLAGS += -lpthread -lrt +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) + +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_EXEC_APP \ + -I$(ACPICA_SRC)/include + +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef OBJS = \ aeexec.o \ @@ -170,14 +208,11 @@ OBJS = \ utxferror.o \ utxface.o - # # Root rule # $(PROG) : $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -lpthread -o $(PROG) - $(COPYPROG) - + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) # # acpiexec source @@ -194,14 +229,12 @@ aemain.o : $(ACPICA_TOOLS)/acpiexec/aemain.c aetables.o : $(ACPICA_TOOLS)/acpiexec/aetables.c $(COMPILE) - # # ACPICA core source - common # getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # ACPICA core source # @@ -643,7 +676,6 @@ utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c utxface.o : $(ACPICA_CORE)/utilities/utxface.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -651,5 +683,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/acpiexec/aemain.c b/tools/acpiexec/aemain.c index ec1801c6d0d8..626cfdd00939 100644 --- a/tools/acpiexec/aemain.c +++ b/tools/acpiexec/aemain.c @@ -93,6 +93,7 @@ usage (void) printf (" -da Disable method abort on error\n"); printf (" -di Disable execution of STA/INI methods during init\n"); printf (" -do Disable Operation Region address simulation\n"); + printf (" -dr Disable repair of method return values\n"); printf (" -dt Disable allocation tracking (performance)\n"); printf ("\n"); @@ -433,6 +434,10 @@ main ( AcpiGbl_DbOpt_NoRegionSupport = TRUE; break; + case 'r': + AcpiGbl_DisableAutoRepair = TRUE; + break; + case 't': #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisableMemTracking = TRUE; diff --git a/tools/acpiexec/osunixdir.c b/tools/acpiexec/osunixdir.c deleted file mode 100644 index 54543bb2bcc4..000000000000 --- a/tools/acpiexec/osunixdir.c +++ /dev/null @@ -1,251 +0,0 @@ - -/****************************************************************************** - * - * Module Name: osunixdir - Unix directory access interfaces - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2011, 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 <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <dirent.h> -#include <fnmatch.h> -#include <ctype.h> -#include <sys/stat.h> - -#include "acpisrc.h" - -/* - * Allocated structure returned from OsOpenDirectory - */ -typedef struct ExternalFindInfo -{ - char *DirPathname; - DIR *DirPtr; - char temp_buffer[128]; - char *WildcardSpec; - char RequestedFileType; - -} EXTERNAL_FIND_INFO; - - -/******************************************************************************* - * - * FUNCTION: AcpiOsOpenDirectory - * - * PARAMETERS: DirPathname - Full pathname to the directory - * WildcardSpec - string of the form "*.c", etc. - * - * RETURN: A directory "handle" to be used in subsequent search operations. - * NULL returned on failure. - * - * DESCRIPTION: Open a directory in preparation for a wildcard search - * - ******************************************************************************/ - -void * -AcpiOsOpenDirectory ( - char *DirPathname, - char *WildcardSpec, - char RequestedFileType) -{ - EXTERNAL_FIND_INFO *ExternalInfo; - DIR *dir; - - - /* Allocate the info struct that will be returned to the caller */ - - ExternalInfo = calloc (sizeof (EXTERNAL_FIND_INFO), 1); - if (!ExternalInfo) - { - return (NULL); - } - - /* Get the directory stream */ - - dir = opendir (DirPathname); - if (!dir) - { - free (ExternalInfo); - return (NULL); - } - - /* Save the info in the return structure */ - - ExternalInfo->WildcardSpec = WildcardSpec; - ExternalInfo->RequestedFileType = RequestedFileType; - ExternalInfo->DirPathname = DirPathname; - ExternalInfo->DirPtr = dir; - return (ExternalInfo); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsGetNextFilename - * - * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory - * - * RETURN: Next filename matched. NULL if no more matches. - * - * DESCRIPTION: Get the next file in the directory that matches the wildcard - * specification. - * - ******************************************************************************/ - -char * -AcpiOsGetNextFilename ( - void *DirHandle) -{ - EXTERNAL_FIND_INFO *ExternalInfo = DirHandle; - struct dirent *dir_entry; - char *temp_str; - int str_len; - struct stat temp_stat; - int err; - - - while ((dir_entry = readdir (ExternalInfo->DirPtr))) - { - if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0)) - { - if (dir_entry->d_name[0] == '.') - { - continue; - } - - str_len = strlen (dir_entry->d_name) + - strlen (ExternalInfo->DirPathname) + 2; - - temp_str = calloc (str_len, 1); - if (!temp_str) - { - printf ("Could not allocate buffer for temporary string\n"); - return (NULL); - } - - strcpy (temp_str, ExternalInfo->DirPathname); - strcat (temp_str, "/"); - strcat (temp_str, dir_entry->d_name); - - err = stat (temp_str, &temp_stat); - free (temp_str); - if (err == -1) - { - printf ("stat() error - should not happen\n"); - return (NULL); - } - - if ((S_ISDIR (temp_stat.st_mode) - && (ExternalInfo->RequestedFileType == REQUEST_DIR_ONLY)) - || - ((!S_ISDIR (temp_stat.st_mode) - && ExternalInfo->RequestedFileType == REQUEST_FILE_ONLY))) - { - /* copy to a temp buffer because dir_entry struct is on the stack */ - - strcpy (ExternalInfo->temp_buffer, dir_entry->d_name); - return (ExternalInfo->temp_buffer); - } - } - } - - return (NULL); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsCloseDirectory - * - * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory - * - * RETURN: None. - * - * DESCRIPTION: Close the open directory and cleanup. - * - ******************************************************************************/ - -void -AcpiOsCloseDirectory ( - void *DirHandle) -{ - EXTERNAL_FIND_INFO *ExternalInfo = DirHandle; - - - /* Close the directory and free allocations */ - - closedir (ExternalInfo->DirPtr); - free (DirHandle); -} - - -/* Other functions acpisrc uses but that aren't standard on Unix */ - -/******************************************************************************* - * - * FUNCTION: strlwr - * - * PARAMETERS: str - String to be lowercased. - * - * RETURN: str. - * - * DESCRIPTION: Lowercase a string in-place. - * - ******************************************************************************/ - -char * -strlwr ( - char *str) -{ - int length; - int i; - - - length = strlen (str); - - for (i = 0; i < length; i++) - { - str[i] = tolower ((int) str[i]); - } - - return (str); -} diff --git a/tools/acpihelp/Makefile b/tools/acpihelp/Makefile new file mode 100644 index 000000000000..6cf56996840a --- /dev/null +++ b/tools/acpihelp/Makefile @@ -0,0 +1,101 @@ +# +# acpihelp - ACPI Help utility. Displays ASL operator syntax and +# information about ACPI predefined names. +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# + +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROG = acpihelp + +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? + +ACPICA_COMPONENTS = +ACPICA_SRC = ../.. +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) + +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_HELP_APP \ + -I$(ACPICA_SRC)/include + +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef + +OBJS = \ + ahamlops.o \ + ahaslkey.o \ + ahaslops.o \ + ahdecode.o \ + ahpredef.o \ + ahmain.o \ + getopt.o + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + +# +# acpihelp source +# +ahamlops.o : $(ACPICA_TOOLS)/acpihelp/ahamlops.c + $(COMPILE) + +ahaslkey.o : $(ACPICA_TOOLS)/acpihelp/ahaslkey.c + $(COMPILE) + +ahaslops.o : $(ACPICA_TOOLS)/acpihelp/ahaslops.c + $(COMPILE) + +ahdecode.o : $(ACPICA_TOOLS)/acpihelp/ahdecode.c + $(COMPILE) + +ahpredef.o : $(ACPICA_TOOLS)/acpihelp/ahpredef.c + $(COMPILE) + +ahmain.o : $(ACPICA_TOOLS)/acpihelp/ahmain.c + $(COMPILE) + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + +clean : + rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/acpihelp/acpihelp.h b/tools/acpihelp/acpihelp.h new file mode 100644 index 000000000000..928187348a9e --- /dev/null +++ b/tools/acpihelp/acpihelp.h @@ -0,0 +1,143 @@ +/****************************************************************************** + * + * Module Name: acpihelp.h - Include file for AcpiHelp utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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. + */ + +#ifndef __ACPIHELP_H +#define __ACPIHELP_H + + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include <ctype.h> +#ifdef WIN32 +#include <io.h> +#include <direct.h> +#endif +#include <errno.h> + + +#define AH_DECODE_DEFAULT 0 +#define AH_DECODE_ASL 1 +#define AH_DECODE_ASL_KEYWORD 2 +#define AH_DECODE_PREDEFINED_NAME 3 +#define AH_DECODE_AML 4 +#define AH_DECODE_AML_OPCODE 5 + +#define AH_MAX_ASL_LINE_LENGTH 70 +#define AH_MAX_AML_LINE_LENGTH 100 + + +typedef struct ah_aml_opcode +{ + UINT16 OpcodeRangeStart; + UINT16 OpcodeRangeEnd; + char *OpcodeString; + char *OpcodeName; + char *Type; + char *FixedArguments; + char *VariableArguments; + char *Grammar; + +} AH_AML_OPCODE; + +typedef struct ah_asl_operator +{ + char *Name; + char *Syntax; + char *Description; + +} AH_ASL_OPERATOR; + +typedef struct ah_asl_keyword +{ + char *Name; + char *Description; + char *KeywordList; + +} AH_ASL_KEYWORD; + +typedef struct ah_predefined_name +{ + char *Name; + char *Description; + char *Action; + +} AH_PREDEFINED_NAME; + + +extern const AH_AML_OPCODE AmlOpcodeInfo[]; +extern const AH_ASL_OPERATOR AslOperatorInfo[]; +extern const AH_ASL_KEYWORD AslKeywordInfo[]; +extern const AH_PREDEFINED_NAME AslPredefinedInfo[]; +extern BOOLEAN AhDisplayAll; + +void +AhStrupr ( + char *SrcString); + +void +AhFindAmlOpcode ( + char *Name); + +void +AhDecodeAmlOpcode ( + char *Name); + +void +AhFindPredefinedNames ( + char *Name); + +void +AhFindAslOperators ( + char *Name); + +void +AhFindAslKeywords ( + char *Name); + +#endif /* __ACPIHELP_H */ diff --git a/tools/acpihelp/ahamlops.c b/tools/acpihelp/ahamlops.c new file mode 100644 index 000000000000..de8c73e14756 --- /dev/null +++ b/tools/acpihelp/ahamlops.c @@ -0,0 +1,325 @@ +/****************************************************************************** + * + * Module Name: ahamlops - Table of all known AML opcodes + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + +/* + * AML opcodes with related syntax and grammar information. + * This table was extracted from the ACPI specification. + */ +const AH_AML_OPCODE AmlOpcodeInfo[] = +{ + {0x00, 0x00, "0x00", "ZeroOp", "DataObject", NULL, NULL, + NULL}, + {0x01, 0x01, "0x01", "OneOp", "DataObject", NULL, NULL, + NULL}, + {0x02, 0x05, "0x02-0x05", NULL, NULL, NULL, NULL, + NULL}, + {0x06, 0x06, "0x06", "AliasOp", "TermObject", "NameString NameString", NULL, + "DefAlias := AliasOp NameString NameString"}, + {0x07, 0x07, "0x07", NULL, NULL, NULL, NULL, + NULL}, + {0x08, 0x08, "0x08", "NameOp", "TermObject", "NameString DataRefObject", NULL, + "DefName := NameOp NameString DataRefObject"}, + {0x09, 0x09, "0x09", NULL, NULL, NULL, NULL, + NULL}, + {0x0A, 0x0A, "0x0A", "BytePrefix", "DataObject", "ByteData", NULL, + "ByteConst := BytePrefix ByteData"}, + {0x0B, 0x0B, "0x0B", "WordPrefix", "DataObject", "WordData", NULL, + "WordConst := WordPrefix WordData"}, + {0x0C, 0x0C, "0x0C", "DWordPrefix", "DataObject", "DWordData", NULL, + "DWordConst := DWordPrefix DWordData"}, + {0x0D, 0x0D, "0x0D", "StringPrefix", "DataObject", "AsciiCharList NullChar", NULL, + "String := StringPrefix AsciiCharList NullChar"}, + {0x0E, 0x0E, "0x0E", "QWordPrefix", "DataObject", "QWordData", NULL, + "QWordConst := QWordPrefix QWordData"}, + {0x0F, 0x0F, "0x0F", NULL, NULL, NULL, NULL, + NULL}, + {0x10, 0x10, "0x10", "ScopeOp", "TermObject", "NameString", "TermList", + "DefScope := ScopeOp PkgLength NameString TermList"}, + {0x11, 0x11, "0x11", "BufferOp", "TermObject", "TermArg", "ByteList", + "DefBuffer := BufferOp PkgLength BufferSize ByteList"}, + {0x12, 0x12, "0x12", "PackageOp", "TermObject", "ByteData", "Package TermList", + "DefPackage := PackageOp PkgLength NumElements PackageElementList"}, + {0x13, 0x13, "0x13", "VarPackageOp", "TermObject", "TermArg", "Package TermList", + "DefVarPackage := VarPackageOp PkgLength VarNumElements PackageElementList"}, + {0x14, 0x14, "0x14", "MethodOp", "TermObject", "NameString ByteData", "TermList", + "DefMethod := MethodOp PkgLength NameString MethodFlags TermList"}, + {0x15, 0x2D, "0x15-0x2D", NULL, NULL, NULL, NULL, + NULL}, + {0x2E, 0x2E, "0x2E", "DualNamePrefix", "NameObject", "NameSeg NameSeg", NULL, + "DualNamePath := DualNamePrefix NameSeg NameSeg"}, + {0x2F, 0x2F, "0x2F", "MultiNamePrefix", "NameObject", "ByteData NameSeg", NULL, + "MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount)"}, + {0x30, 0x39, "0x30-0x39", "DigitChar", "NameObject", NULL, NULL, + NULL}, + {0x3A, 0x40, "0x3A-0x40", NULL, NULL, NULL, NULL, + NULL}, + {0x41, 0x5A, "0x41-0x5A", "NameChar", "NameObject", NULL, NULL, + NULL}, + {0x5B, 0x5B, "0x5B", "ExtOpPrefix", "DataObject", "ByteData", NULL, + NULL}, + {0x5B00, 0x5B00, "0x5B00", NULL, NULL, NULL, NULL, + NULL}, + {0x5B01, 0x5B01, "0x5B01", "MutexOp", "TermObject", "NameString ByteData", NULL, + "DefMutex := MutexOp NameString SyncFlags"}, + {0x5B02, 0x5B02, "0x5B02", "EventOp", "TermObject", "NameString", NULL, + "DefEvent := EventOp NameString"}, + {0x5B12, 0x5B12, "0x5B12", "CondRefOfOp", "TermObject", "SuperName SuperName", NULL, + "DefCondRefOf := CondRefOfOp SuperName Target"}, + {0x5B13, 0x5B13, "0x5B13", "CreateFieldOp", "TermObject", "TermArg TermArg TermArg NameString", NULL, + "DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString"}, + {0x5B1F, 0x5B1F, "0x5B1F", "LoadTableOp", "TermObject", "TermArg TermArg TermArg TermArg TermArg TermArg", NULL, + "DefLoadTable := LoadTableOp TermArg TermArg TermArg TermArg TermArg TermArg"}, + {0x5B20, 0x5B20, "0x5B20", "LoadOp", "TermObject", "NameString SuperName", NULL, + "DefLoad := LoadOp NameString DDBHandleObject"}, + {0x5B21, 0x5B21, "0x5B21", "StallOp", "TermObject", "TermArg", NULL, + "DefStall := StallOp UsecTime"}, + {0x5B22, 0x5B22, "0x5B22", "SleepOp", "TermObject", "TermArg", NULL, + "DefSleep := SleepOp MsecTime"}, + {0x5B23, 0x5B23, "0x5B23", "AcquireOp", "TermObject", "SuperName WordData", NULL, + "DefAcquire := AcquireOp MutexObject Timeout"}, + {0x5B24, 0x5B24, "0x5B24", "SignalOp", "TermObject", "SuperName", NULL, + "DefSignal := SignalOp EventObject"}, + {0x5B25, 0x5B25, "0x5B25", "WaitOp", "TermObject", "SuperName TermArg", NULL, + "DefWait := WaitOp EventObject Operand"}, + {0x5B26, 0x5B26, "0x5B26", "ResetOp", "TermObject", "SuperName", NULL, + "DefReset := ResetOp EventObject"}, + {0x5B27, 0x5B27, "0x5B27", "ReleaseOp", "TermObject", "SuperName", NULL, + "DefRelease := ReleaseOp MutexObject"}, + {0x5B28, 0x5B28, "0x5B28", "FromBCDOp", "TermObject", "TermArg Target", NULL, + "DefFromBCD := FromBCDOp BCDValue Target"}, + {0x5B29, 0x5B29, "0x5B29", "ToBCD", "TermObject", "TermArg Target", NULL, + "DefToBCD := ToBCDOp Operand Target"}, + {0x5B2A, 0x5B2A, "0x5B2A", "UnloadOp", "TermObject", "SuperName", NULL, + "DefUnload := UnloadOp DDBHandleObject"}, + {0x5B30, 0x5B30, "0x5B30", "RevisionOp", "DataObject", NULL, NULL, + NULL}, + {0x5B31, 0x5B31, "0x5B31", "DebugOp", "DebugObject", NULL, NULL, + NULL}, + {0x5B32, 0x5B32, "0x5B32", "FatalOp", "TermObject", "ByteData DWordData TermArg", NULL, + "DefFatal := FatalOp FatalType FatalCode FatalArg"}, + {0x5B33, 0x5B33, "0x5B33", "TimerOp", "TermObject", NULL, NULL, + "DefTimer := TimerOp"}, + {0x5B80, 0x5B80, "0x5B80", "OpRegionOp", "TermObject", "NameString ByteData TermArg TermArg", NULL, + "DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen"}, + {0x5B81, 0x5B81, "0x5B81", "FieldOp", "TermObject", "NameString ByteData", "FieldList", + "DefField := FieldOp PkgLength NameString FieldFlags FieldList"}, + {0x5B82, 0x5B82, "0x5B82", "DeviceOp", "TermObject", "NameString", "ObjectList", + "DefDevice := DeviceOp PkgLength NameString ObjectList"}, + {0x5B83, 0x5B83, "0x5B83", "ProcessorOp", "TermObject", "NameString ByteData DWordData ByteData", "ObjectList", + "DefProcessor := ProcessorOp PkgLength NameString ProcID PblkAddr PblkLen ObjectList"}, + {0x5B84, 0x5B84, "0x5B84", "PowerResOp", "TermObject", "NameString ByteData WordData", "ObjectList", + "DefPowerRes := PowerResOp PkgLength NameString SystemLevel ResourceOrder ObjectList"}, + {0x5B85, 0x5B85, "0x5B85", "ThermalZoneOp", "TermObject", "NameString", "ObjectList", + "DefThermalZone := ThermalZoneOp PkgLength NameString ObjectList"}, + {0x5B86, 0x5B86, "0x5B86", "IndexFieldOp", "TermObject", "NameString NameString ByteData", "FieldList", + "DefIndexField := IndexFieldOp PkgLength NameString NameString FieldFlags FieldList"}, + {0x5B87, 0x5B87, "0x5B87", "BankFieldOp", "TermObject", "NameString NameString TermArg ByteData", "FieldList", + "DefBankField := BankFieldOp PkgLength NameString NameString BankValue FieldFlags FieldList"}, + {0x5B88, 0x5B88, "0x5B88", "DataRegionOp", "TermObject", "NameString TermArg TermArg TermArg", NULL, + "DefDataRegion := DataRegionOp NameString TermArg TermArg TermArg"}, + {0x5B89, 0x5BFF, "0x5B89-0x5BFF", NULL, NULL, NULL, NULL, + NULL}, + {0x5C, 0x5C, "0x5C", "RootChar", "NameObject", NULL, NULL, + NULL}, + {0x5D, 0x5D, "0x5D", NULL, NULL, NULL, NULL, + NULL}, + {0x5E, 0x5E, "0x5E", "ParentPrefixChar", "NameObject", NULL, NULL, + NULL}, + {0x5F, 0x5F, "0x5F", "NameChar", "NameObject", NULL, NULL, + NULL}, + {0x60, 0x60, "0x60", "Local0Op", "LocalObject", NULL, NULL, + NULL}, + {0x61, 0x61, "0x61", "Local1Op", "LocalObject", NULL, NULL, + NULL}, + {0x62, 0x62, "0x62", "Local2Op", "LocalObject", NULL, NULL, + NULL}, + {0x63, 0x63, "0x63", "Local3Op", "LocalObject", NULL, NULL, + NULL}, + {0x64, 0x64, "0x64", "Local4Op", "LocalObject", NULL, NULL, + NULL}, + {0x65, 0x65, "0x65", "Local5Op", "LocalObject", NULL, NULL, + NULL}, + {0x66, 0x66, "0x66", "Local6Op", "LocalObject", NULL, NULL, + NULL}, + {0x67, 0x67, "0x67", "Local7Op", "LocalObject", NULL, NULL, + NULL}, + {0x68, 0x68, "0x68", "Arg0Op", "ArgObject", NULL, NULL, + NULL}, + {0x69, 0x69, "0x69", "Arg1Op", "ArgObject", NULL, NULL, + NULL}, + {0x6A, 0x6A, "0x6A", "Arg2Op", "ArgObject", NULL, NULL, + NULL}, + {0x6B, 0x6B, "0x6B", "Arg3Op", "ArgObject", NULL, NULL, + NULL}, + {0x6C, 0x6C, "0x6C", "Arg4Op", "ArgObject", NULL, NULL, + NULL}, + {0x6D, 0x6D, "0x6D", "Arg5Op", "ArgObject", NULL, NULL, + NULL}, + {0x6E, 0x6E, "0x6E", "Arg6Op", "ArgObject", NULL, NULL, + NULL}, + {0x6F, 0x6F, "0x6F", NULL, NULL, NULL, NULL, + NULL}, + {0x70, 0x70, "0x70", "StoreOp", "TermObject", "TermArg SuperName", NULL, + "DefStore := StoreOp TermArg SuperName"}, + {0x71, 0x71, "0x71", "RefOfOp", "TermObject", "SuperName ", NULL, + "DefRefOf := RefOfOp SuperName"}, + {0x72, 0x72, "0x72", "AddOp", "TermObject", "TermArg TermArg Target", NULL, + "DefAdd := AddOp Operand Operand Target"}, + {0x73, 0x73, "0x73", "ConcatOp", "TermObject", "TermArg TermArg Target", NULL, + "DefConcat := ConcatOp Data Data Target"}, + {0x74, 0x74, "0x74", "SubtractOp", "TermObject", "TermArg TermArg Target", NULL, + "DefSubtract := SubtractOp Operand Operand Target"}, + {0x75, 0x75, "0x75", "IncrementOp", "TermObject", "SuperName", NULL, + "DefIncrement := IncrementOp SuperName"}, + {0x76, 0x76, "0x76", "DecrementOp", "TermObject", "SuperName", NULL, + "DefDecrement := DecrementOp SuperName"}, + {0x77, 0x77, "0x77", "MultiplyOp", "TermObject", "TermArg TermArg Target", NULL, + "DefMultiply := MultiplyOp Operand Operand Target"}, + {0x78, 0x78, "0x78", "DivideOp", "TermObject", "TermArg TermArg Target Target", NULL, + "DefDivide := DivideOp Dividend Divisor Remainder Quotient"}, + {0x79, 0x79, "0x79", "ShiftLeftOp", "TermObject", "TermArg TermArg Target", NULL, + "DefShiftLeft := ShiftLeftOp Operand ShiftCount Target"}, + {0x7A, 0x7A, "0x7A", "ShiftRightOp", "TermObject", "TermArg TermArg Target", NULL, + "DefShiftRight := ShiftRightOp Operand ShiftCount Target"}, + {0x7B, 0x7B, "0x7B", "AndOp", "TermObject", "TermArg TermArg Target", NULL, + "DefAnd := AndOp Operand Operand Target"}, + {0x7C, 0x7C, "0x7C", "NandOp", "TermObject", "TermArg TermArg Target", NULL, + "DefNAnd := NandOp Operand Operand Target"}, + {0x7D, 0x7D, "0x7D", "OrOp", "TermObject", "TermArg TermArg Target", NULL, + "DefOr := OrOp Operand Operand Target"}, + {0x7E, 0x7E, "0x7E", "NorOp", "TermObject", "TermArg TermArg Target", NULL, + "DefNOr := NorOp Operand Operand Target"}, + {0x7F, 0x7F, "0x7F", "XorOp", "TermObject", "TermArg TermArg Target", NULL, + "DefXOr := XorOp Operand Operand Target"}, + {0x80, 0x80, "0x80", "NotOp", "TermObject", "TermArg Target", NULL, + "DefNot := NotOp Operand Target"}, + {0x81, 0x81, "0x81", "FindSetLeftBitOp", "TermObject", "TermArg Target", NULL, + "DefFindSetLeftBit := FindSetLeftBitOp Operand Target"}, + {0x82, 0x82, "0x82", "FindSetRightBitOp", "TermObject", "TermArg Target", NULL, + "DefFindSetRightBit := FindSetRightBitOp Operand Target"}, + {0x83, 0x83, "0x83", "DerefOfOp", "TermObject", "TermArg", NULL, + "DefDerefOf := DerefOfOp ObjReference"}, + {0x84, 0x84, "0x84", "ConcatResOp", "TermObject", "TermArg TermArg Target", NULL, + "DefConcatRes := ConcatResOp BufData BufData Target"}, + {0x85, 0x85, "0x85", "ModOp", "TermObject", "TermArg TermArg Target", NULL, + "DefMod := ModOp Dividend Divisor Target"}, + {0x86, 0x86, "0x86", "NotifyOp", "TermObject", "SuperName TermArg", NULL, + "DefNotify := NotifyOp NotifyObject NotifyValue"}, + {0x87, 0x87, "0x87", "SizeOfOp", "TermObject", "SuperName", NULL, + "DefSizeOf := SizeOfOp SuperName"}, + {0x88, 0x88, "0x88", "IndexOp", "TermObject", "TermArg TermArg Target", NULL, + "DefIndex := IndexOp BuffPkgStrObj IndexValue Target"}, + {0x89, 0x89, "0x89", "MatchOp", "TermObject", "TermArg ByteData TermArg ByteData TermArg TermArg", NULL, + "DefMatch := MatchOp SearchPkg MatchOpcode Operand MatchOpcode Operand StartIndex"}, + {0x8A, 0x8A, "0x8A", "CreateDWordFieldOp", "TermObject", "TermArg TermArg NameString", NULL, + "DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString"}, + {0x8B, 0x8B, "0x8B", "CreateWordFieldOp", "TermObject", "TermArg TermArg NameString", NULL, + "DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString"}, + {0x8C, 0x8C, "0x8C", "CreateByteFieldOp", "TermObject", "TermArg TermArg NameString", NULL, + "DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString"}, + {0x8D, 0x8D, "0x8D", "CreateBitFieldOp", "TermObject", "TermArg TermArg NameString", NULL, + "DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString"}, + {0x8E, 0x8E, "0x8E", "ObjectTypeOp", "TermObject", "SuperName", NULL, + "DefObjectType := ObjectTypeOp SuperName"}, + {0x8F, 0x8F, "0x8F", "CreateQWordFieldOp", "TermObject", "TermArg TermArg NameString", NULL, + "DefCreateQWordField := CreateQWordFieldOp SourceBuff ByteIndex NameString"}, + {0x90, 0x90, "0x90", "LAndOp", "TermObject", "TermArg TermArg", NULL, + "DefLAnd := LandOp Operand Operand"}, + {0x91, 0x91, "0x91", "LOrOp", "TermObject", "TermArg TermArg", NULL, + "DefLOr := LorOp Operand Operand"}, + {0x92, 0x92, "0x92", "LNotOp", "TermObject", "TermArg", NULL, + "DefLNot := LnotOp Operand"}, + {0x9293, 0x9293, "0x9293", "LNotEqualOp", "TermObject", "TermArg TermArg", NULL, + "DefLNotEqual := LnotEqualOp Operand Operand"}, + {0x9294, 0x9294, "0x9294", "LLessEqualOp", "TermObject", "TermArg TermArg", NULL, + "DefLLessEqual := LlessEqualOp Operand Operand"}, + {0x9295, 0x9295, "0x9295", "LGreaterEqualOp", "TermObject", "TermArg TermArg", NULL, + "DefLGreaterEqual := LgreaterEqualOp Operand Operand"}, + {0x93, 0x93, "0x93", "LEqualOp", "TermObject", "TermArg TermArg", NULL, + "DefLEqual := LequalOp Operand Operand"}, + {0x94, 0x94, "0x94", "LGreaterOp", "TermObject", "TermArg TermArg", NULL, + "DefLGreater := LgreaterOp Operand Operand"}, + {0x95, 0x95, "0x95", "LLessOp", "TermObject", "TermArg TermArg", NULL, + "DefLLess := LlessOp Operand Operand"}, + {0x96, 0x96, "0x96", "ToBufferOp", "TermObject", "TermArg Target", NULL, + "DefToBuffer := ToBufferOp Operand Target"}, + {0x97, 0x97, "0x97", "ToDecimalStringOp", "TermObject", "TermArg Target", NULL, + "DefToDecimalString := ToDecimalStringOp Operand Target"}, + {0x98, 0x98, "0x98", "ToHexStringOp", "TermObject", "TermArg Target", NULL, + "DefToHexString := ToHexStringOp Operand Target"}, + {0x99, 0x99, "0x99", "ToIntegerOp", "TermObject", "TermArg Target", NULL, + "DefToInteger := ToIntegerOp Operand Target"}, + {0x9A, 0x9B, "0x9A-0x9B", NULL, NULL, NULL, NULL, + NULL}, + {0x9C, 0x9C, "0x9C", "ToStringOp", "TermObject", "TermArg TermArg Target", NULL, + "DefToString := ToStringOp TermArg LengthArg Target"}, + {0x9D, 0x9D, "0x9D", "CopyObjectOp", "TermObject", "TermArg SimpleName", NULL, + "DefCopyObject := CopyObjectOp TermArg SimpleName"}, + {0x9E, 0x9E, "0x9E", "MidOp", "TermObject", "TermArg TermArg TermArg Target", NULL, + "DefMid := MidOp MidObj TermArg TermArg Target"}, + {0x9F, 0x9F, "0x9F", "ContinueOp", "TermObject", NULL, NULL, + "DefContinue := ContinueOp"}, + {0xA0, 0xA0, "0xA0", "IfOp", "TermObject", "TermArg", "TermList", + "DefIfElse := IfOp PkgLength Predicate TermList DefElse"}, + {0xA1, 0xA1, "0xA1", "ElseOp", "TermObject", NULL, "TermList", + "DefElse := Nothing | <ElseOp PkgLength TermList>"}, + {0xA2, 0xA2, "0xA2", "WhileOp", "TermObject", "TermArg", "TermList", + "DefWhile := WhileOp PkgLength Predicate TermList"}, + {0xA3, 0xA3, "0xA3", "NoopOp", "TermObject", NULL, NULL, + "DefNoop := NoopOp"}, + {0xA4, 0xA4, "0xA4", "ReturnOp", "TermObject", "TermArg", NULL, + "DefReturn := ReturnOp ArgObject"}, + {0xA5, 0xA5, "0xA5", "BreakOp", "TermObject", NULL, NULL, + "DefBreak := BreakOp"}, + {0xA6, 0xCB, "0xA6-0xCB", NULL, NULL, NULL, NULL, + NULL}, + {0xCC, 0xCC, "0xCC", "BreakPointOp", "TermObject", NULL, NULL, + "DefBreakPoint := BreakPointOp"}, + {0xCD, 0xFE, "0xCD-0xFE", NULL, NULL, NULL, NULL, + NULL}, + {0xFF, 0xFF, "0xFF", "OnesOp", "DataObject", NULL, NULL, + NULL}, + {0, 0, NULL, NULL, NULL, NULL, NULL, NULL} +}; diff --git a/tools/acpihelp/ahaslkey.c b/tools/acpihelp/ahaslkey.c new file mode 100644 index 000000000000..48d2110e9c49 --- /dev/null +++ b/tools/acpihelp/ahaslkey.c @@ -0,0 +1,112 @@ +/****************************************************************************** + * + * Module Name: ahaslkey - Table of all known ASL non-operator keywords + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + +/* + * ASL Keyword types and associated actual keywords. + * This table was extracted from the ACPI specification. + */ +const AH_ASL_KEYWORD AslKeywordInfo[] = +{ + {"AccessAttribKeyword", "SMBus Attributes", + ":= SMBQuick | SMBSendReceive | SMBByte | SMBWord | " + "SMBBlock | SMBProcessCall | SMBBlockProcessCall"}, + {"AccessTypeKeyword", "Field Access Types", + ":= AnyAcc | ByteAcc | WordAcc | DWordAcc | QWordAcc | BufferAcc"}, + {"AddressKeyword", "ACPI memory range types", + ":= AddressRangeMemory | AddressRangeReserved | " + "AddressRangeNVS | AddressRangeACPI"}, + {"AddressSpaceKeyword", "Operation Region Address Space Types", + ":= RegionSpaceKeyword | FFixedHW"}, + {"BusMasterKeyword", "DMA Bus Mastering", + ":= BusMaster | NotBusMaster"}, + {"DecodeKeyword", "Type of Memory Decoding - Resource Descriptors", + ":= SubDecode | PosDecode"}, + {"DMATypeKeyword", "DMA Types - DMA Resource Descriptor", + ":= Compatibility | TypeA | TypeB | TypeF"}, + {"InterruptTypeKeyword", "Interrupt Types", + ":= Edge | Level"}, + {"InterruptLevel", "Interrupt Active Types", + ":= ActiveHigh | ActiveLow"}, + {"IODecodeKeyword", "I/O Decoding - IO Resource Descriptor", + ":= Decode16 | Decode10"}, + {"LockRuleKeyword", "Global Lock use for Field Operator", + ":= Lock | NoLock"}, + {"MatchOpKeyword", "Types for Match Operator", + ":= MTR | MEQ | MLE | MLT | MGE | MGT"}, + {"MaxKeyword", "Max Range Type - Resource Descriptors", + ":= MaxFixed | MaxNotFixed"}, + {"MemTypeKeyword", "Memory Types - Resource Descriptors", + ":= Cacheable | WriteCombining | Prefetchable | NonCacheable"}, + {"MinKeyword", "Min Range Type - Resource Descriptors", + ":= MinFixed | MinNotFixed"}, + {"ObjectTypeKeyword", "ACPI Object Types", + ":= UnknownObj | IntObj | StrObj | BuffObj | PkgObj | FieldUnitObj | " + "DeviceObj | EventObj | MethodObj | MutexObj | OpRegionObj | PowerResObj | " + "ProcessorObj | ThermalZoneObj | BuffFieldObj | DDBHandleObj"}, + {"RangeTypeKeyword", "I/O Range Types - Resource Descriptors", + ":= ISAOnlyRanges | NonISAOnlyRanges | EntireRange"}, + {"ReadWriteKeyword", "Memory Access Types - Resource Descriptors", + ":= ReadWrite | ReadOnly"}, + {"RegionSpaceKeyword", "Operation Region Address Space Types", + ":= UserDefRegionSpace | SystemIO | SystemMemory | PCI_Config | " + "EmbeddedControl | SMBus | SystemCMOS | PciBarTarget | IPMI"}, + {"ResourceTypeKeyword", "Resource Usage - Resource Descriptors", + ":= ResourceConsumer | ResourceProducer"}, + {"SerializeRuleKeyword", "Control Method Serialization", + ":= Serialized | NotSerialized"}, + {"ShareTypeKeyword", "Interrupt Sharing - Resource Descriptors", + ":= Shared | Exclusive"}, + {"TranslationKeyword", "Translation Density Types - Resource Descriptors", + ":= SparseTranslation | DenseTranslation"}, + {"TypeKeyword", "Translation Types - Resource Descriptors", + ":= TypeTranslation | TypeStatic"}, + {"UpdateRuleKeyword", "Field Update Rules", + ":= Preserve | WriteAsOnes | WriteAsZeros"}, + {"UserDefRegionSpace", "User defined address spaces", + ":= IntegerData => 0x80 - 0xFF"}, + {"XferTypeKeyword", "DMA Transfer Types", + ":= Transfer8 | Transfer16 | Transfer8_16"}, + {NULL, NULL, NULL} +}; diff --git a/tools/acpihelp/ahaslops.c b/tools/acpihelp/ahaslops.c new file mode 100644 index 000000000000..44a1e80c31aa --- /dev/null +++ b/tools/acpihelp/ahaslops.c @@ -0,0 +1,358 @@ +/****************************************************************************** + * + * Module Name: ahaslops - Table of all known ASL operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + +/* + * ASL operators with syntax (directly from ACPI specification). + * Note: All tokens require a space separator. + * Long lines are automatically split during output. + */ +const AH_ASL_OPERATOR AslOperatorInfo[] = +{ + {"Acquire", "(SyncObject, TimeoutValue) => Boolean", + "Acquire a mutex"}, + {"Add", "(Addend1, Addend2, Result) => Integer", + "Integer Add"}, + {"Alias", "(SourceObject, AliasObject)", + "Define a name alias"}, + {"And", "(Source1, Source2, Result) => Integer", + "Integer Bitwise And"}, + {"Arg", "Arg0 - Arg6", + "Method argument data objects"}, + {"BankField", "(RegionName, BankName, BankValue, AccessType, LockRule, UpdateRule) {FieldUnitList}", + "Declare fields in a banked configuration object"}, + {"Break", NULL, + "Continue following the innermost enclosing While"}, + {"BreakPoint", NULL, + "Used for debugging, stops execution in the debugger"}, + {"Buffer", "(BufferSize) {String or ByteList} => Buffer", + "Declare Buffer object"}, + {"Case", "(Value) {TermList}", + "Expression for conditional execution"}, + {"Concatenate", "(Source1, Source2, Result) => ComputationalData", + "Concatenate two strings}, integers or buffers"}, + {"ConcatenateResTemplate", "(Source1, Source2, Result) => Buffer", + "Concatenate two resource templates"}, + {"CondRefOf", "(Source, Result) => Boolean", + "Conditional reference to an object"}, + {"Continue", NULL, + "Continue innermost enclosing While loop"}, + {"CopyObject", "(Source, Destination) => DataRefObject", + "Copy and existing object"}, + {"CreateBitField", "(SourceBuffer, BitIndex, BitFieldName)", + "Declare a bit field object of a buffer object"}, + {"CreateByteField", "(SourceBuffer, ByteIndex, ByteFieldName)", + "Declare a byte field object of a buffer object"}, + {"CreateDWordField", "(SourceBuffer, ByteIndex, DWordFieldName)", + "Declare a DWord field object of a buffer object"}, + {"CreateField", "(SourceBuffer, BitIndex, NumBits, FieldName)", + "Declare an arbitrary length bit field of a buffer object"}, + {"CreateQWordField", "(SourceBuffer, ByteIndex, QWordFieldName)", + "Declare a QWord field object of a buffer object"}, + {"CreateWordField", "(SourceBuffer, ByteIndex, WordFieldName)", + "Declare a Word field object of a buffer object"}, + {"DataTableRegion", "(RegionName, SignatureString, OemIDString, OemTableIDString)", + "Declare a Data Table Region"}, + {"Debug", NULL, + "Debugger output"}, + {"Decrement", "(Minuend) => Integer", + "Decrement an Integer"}, + {"Default", "{TermList}", + "Default execution path in Switch()"}, + {"DefinitionBlock", "(AMLFileName, TableSignature, ComplianceRevision, OEMID, TableID, OEMRevision) {TermList}", + "Declare a Definition Block"}, + {"DerefOf", "(Source) => Object", + "Dereference an object reference"}, + {"Device", "(DeviceName) {ObjectList}", + "Declare a bus/device object"}, + {"Divide", "(Dividend, Divisor, Remainder, Result) => Integer", + "Integer Divide"}, + {"DMA", "(DmaType, IsBusMaster, DmaTransferSize, DescriptorName) {DmaChannelList} => Buffer", + "DMA Resource Descriptor macro"}, + {"DWordIO", "(ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges, AddressGranularity, " + "AddressMinimum, AddressMaximum, AddressTranslation, RangeLength, ResourceSourceIndex, " + "ResourceSource, DescriptorName, TranslationType, TranslationDensity)", + "DWord IO Resource Descriptor macro"}, + {"DWordMemory", "(ResourceUsage, Decode, IsMinFixed, IsMaxFixed, Cacheable, ReadAndWrite, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, ResourceSourceIndex, ResourceSource, DescriptorName, MemoryType, " + "TranslationType)", + "DWord Memory Resource Descriptor macro"}, + {"DWordSpace", "(ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed, TypeSpecificFlags, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, RangeLength, " + "ResourceSourceIndex, ResourceSource, DescriptorName)", + "DWord Space Resource Descriptor macro"}, + {"EISAID", "(EisaIdString) => DWordConst", + "EISA ID String to Integer conversion macro"}, + {"Else", "{TermList}", + "Alternate conditional execution"}, + {"ElseIf", "(Predicate)", + "Conditional execution"}, + {"EndDependentFn", "() => Buffer", + "End Dependent Function Resource Descriptor macro"}, + {"Event", "(EventName)", + "Declare an event synchronization object"}, + {"ExtendedIO", "(ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges, AddressGranularity, " + "AddressMinimum, AddressMaximum, AddressTranslation, RangeLength, " + "TypeSpecificAttributes, DescriptorName, TranslationType, TranslationDensity)", + "Extended IO Resource Descriptor macro"}, + {"ExtendedMemory", "(ResourceUsage, Decode, IsMinFixed, IsMaxFixed, Cacheable, ReadAndWrite, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, TypeSpecificAttributes, DescriptorName, MemoryType, TranslationType)", + "Extended Memory Resource Descriptor macro"}, + {"ExtendedSpace", "(ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed, TypeSpecificFlags, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, TypeSpecificAttributes, DescriptorName)", + "Extended Space Resource Descriptor macro"}, + {"External", "(ObjectName, ObjectType, ReturnType, ParameterTypes)", + "Declare external objects"}, + {"Fatal", "(Type, Code, Arg)", + "Fatal error check"}, + {"Field", "(RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}", + "Declare fields of an operation region object"}, + {"FindSetLeftBit", "(Source, Result) => Integer", + "Index of first least significant bit set"}, + {"FindSetRightBit", "(Source, Result) => Integer", + "Index of first most significant bit set"}, + {"FixedIO", "(AddressBase, RangeLength, DescriptorName) => Buffer", + "Fixed I/O Resource Descriptor macro"}, + {"FromBCD", "(BCDValue, Result) => Integer", + "Convert from BCD to numeric"}, + {"Function", "(FunctionName, ReturnType, ParameterTypes) {TermList}", + "Declare control method"}, + {"If", "(Predicate) {TermList}", + "Conditional execution"}, + {"Include", "(FilePathName)", + "Include another ASL file"}, + {"Increment", "(Addend) => Integer", + "Increment a Integer"}, + {"Index", "(Source, Index, Destination) => ObjectReference", + "Indexed Reference to member object"}, + {"IndexField", "(IndexName, DataName, AccessType, LockRule, UpdateRule) {FieldUnitList}", + "Declare Index/Data Fields"}, + {"Interrupt", "(ResourceUsage, EdgeLevel, ActiveLevel, Shared, ResourceSourceIndex, " + "ResourceSource, DescriptorName) {InterruptList} => Buffer", + "Interrupt Resource Descriptor macro"}, + {"IO", "(Decode, AddressMin, AddressMax, AddressAlignment, RangeLength, DescriptorName) => Buffer", + "IO Resource Descriptor macro"}, + {"IRQ", "(EdgeLevel, ActiveLevel, Shared, DescriptorName) {InterruptList} => Buffer", + "Interrupt Resource Descriptor macro"}, + {"IRQNoFlags", "(DescriptorName) {InterruptList} => Buffer", + "Short Interrupt Resource Descriptor macro"}, + {"LAnd", "(Source1, Source2) => Boolean", + "Logical And"}, + {"LEqual", "(Source1, Source2) => Boolean", + "Logical Equal"}, + {"LGreater", "(Source1, Source2) => Boolean", + "Logical Greater"}, + {"LGreaterEqual", "(Source1, Source2) => Boolean", + "Logical Not less"}, + {"LLess", "(Source1, Source2) => Boolean", + "Logical Less"}, + {"LLessEqual", "(Source1, Source2) => Boolean", + "Logical Not greater"}, + {"LNot", "(Source) => Boolean", + "Logical Not"}, + {"LNotEqual", "(Source1, Source2) => Boolean", + "Logical Not equal"}, + {"Load", "(Object, DDBHandle)", + "Load differentiating definition block"}, + {"LoadTable", "(SignatureString, OEMIDString, OEMTableIDString, RootPathString, " + "ParameterPathString, ParameterData) => DDBHandle", + "Load Table from RSDT/XSDT"}, + {"Local", "Local0 - Local 7", + "Method local data objects"}, + {"LOr", "(Source1, Source2) => Boolean", + "Logical Or"}, + {"Match", "(SearchPackage, Op1, MatchObject1, Op2, MatchObject2, StartIndex) => Ones | Integer", + "Search for match in package array"}, + {"Memory24", "(ReadAndWrite, AddressMinimum, AddressMaximum, AddressAlignment, " + "RangeLength, DescriptorName)", + "Memory Resource Descriptor macro"}, + {"Memory32", "(ReadAndWrite, AddressMinimum, AddressMaximum, AddressAlignment, " + "RangeLength, DescriptorName)", + "Memory Resource Descriptor macro"}, + {"Memory32Fixed", "(ReadAndWrite, AddressBase, RangeLength, DescriptorName)", + "Memory Resource Descriptor macro"}, + {"Method", "(MethodName, NumArgs, SerializeRule, SyncLevel, ReturnType, ParameterTypes) " + "{TermList}", + "Declare a control method"}, + {"Mid", "(Source, Index, Length, Result) => Buffer or String", + "Return a portion of buffer or string"}, + {"Mod", "(Dividend, Divisor, Result) => Integer", + "Integer Modulo"}, + {"Multiply", "(Multiplicand, Multiplier, Result) => Integer", + "Integer Multiply"}, + {"Mutex", "(MutexName, SyncLevel)", + "Declare a mutex synchronization object"}, + {"Name", "(ObjectName, Object)", + "Declare a Named object"}, + {"NAnd", "(Source1, Source2, Result) => Integer", + "Integer Bitwise Nand"}, + {"NoOp", NULL, + "No operation"}, + {"NOr", "(Source1, Source2, Result) => Integer", + "Integer Bitwise Nor"}, + {"Not", "(Source, Result) => Integer", + "Integer Bitwise Not"}, + {"Notify", "(Object, NotificationValue)", + "Notify Object of event"}, + {"ObjectType", "(Object) => Integer", + "Type of object"}, + {"One", "=> Integer", + "Constant One Object (1)"}, + {"Ones", "=> Integer", + "Constant Ones Object (-1)"}, + {"OperationRegion", "(RegionName, RegionSpace, Offset, Length)", + "Declare an operational region"}, + {"Or", "(Source1, Source2, Result) => Integer", + "Integer Bitwise Or"}, + {"Package", "(NumElements) {PackageList} => Package", + "Declare a package object"}, + {"PowerResource", "(ResourceName, SystemLevel, ResourceOrder) {ObjectList}", + "Declare a power resource object"}, + {"Processor", "(ProcessorName, ProcessorID, PBlockAddress, PblockLength) {ObjectList}", + "Declare a processor package"}, + {"QWordIO", "(ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges, AddressGranularity, " + "AddressMinimum, AddressMaximum, AddressTranslation, RangeLength, " + "ResourceSourceIndex, ResourceSource, DescriptorName, TranslationType, " + "TranslationDensity)", + "QWord IO Resource Descriptor macro"}, + {"QWordMemory", "(ResourceUsage, Decode, IsMinFixed, IsMaxFixed, Cacheable, ReadAndWrite, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, ResourceSourceIndex, ResourceSource, DescriptorName, MemoryType, " + "TranslationType)", + "QWord Memory Resource Descriptor macro"}, + {"QWordSpace", "(ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed, TypeSpecificFlags, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, ResourceSourceIndex, ResourceSource, DescriptorName)", + "Qword Space Resource Descriptor macro"}, + {"RefOf", "(Object) => ObjectReference", + "Create Reference to an object"}, + {"Register", "(AddressSpaceKeyword, RegisterBitWidth, RegisterBitOffset, RegisterAddress, " + "AccessSize, DescriptorName)", + "Generic register Resource Descriptor macro"}, + {"Release", "(SyncObject)", + "Release a synchronization object"}, + {"Reset", "(SyncObject)", + "Reset a synchronization object"}, + {"ResourceTemplate", "() {ResourceMacroList} => Buffer", + "Resource to buffer conversion macro"}, + {"Return", "None | () | (ReturnArg)", + "Return from method execution"}, + {"Revision", "=> Integer", + "Constant revision object"}, + {"Scope", "(Location) {ObjectList}", + "Open named scope "}, + {"ShiftLeft", "(Source, ShiftCount, Result) => Integer", + "Integer shift value left"}, + {"ShiftRight", "(Source, ShiftCount, Result) => Integer", + "Integer shift value right"}, + {"Signal", "(SyncObject)", + "Signal a synchronization object"}, + {"SizeOf", "(ObjectName) => Integer", + "Get the size of a buffer}, string}, or package"}, + {"Sleep", "(MilliSeconds)", + "Sleep n milliseconds (yields the processor)"}, + {"Stall", "(MicroSeconds)", + "Delay n microseconds (does not yield the processor)"}, + {"StartDependentFn", "(CompatibilityPriority, PerformancePriority) {ResourceList}", + "Start Dependent Function Resource Descriptor macro"}, + {"StartDependentFnNoPri", "() {ResourceList}", + "Start Dependent Function Resource Descriptor macro"}, + {"Store", "(Source, Destination) => DataRefObject", + "Store object"}, + {"Subtract", "(Minuend, Subtrahend, Result) => Integer", + "Integer Subtract"}, + {"Switch", "(Expression) {CaseTermList}", + "Select code to execute based on expression value"}, + {"ThermalZone", "(ThermalZoneName) {ObjectList}", + "Declare a thermal zone package"}, + {"Timer", "=> Integer", + "Get 64-bit timer value"}, + {"ToBCD", "(Value, Result) => Integer", + "Convert Integer to BCD"}, + {"ToBuffer", "(Data, Result) => Buffer", + "Convert data type to buffer"}, + {"ToDecimalString", "(Data, Result) => String", + "Convert data type to decimal string"}, + {"ToHexString", "(Data, Result) => String", + "Convert data type to hexadecimal string"}, + {"ToInteger", "(Data, Result) => Integer", + "Convert data type to integer"}, + {"ToString", "(Source, Length, Result) => String", + "Copy ASCII string from buffer"}, + {"ToUUID", "(AsciiString) => Buffer", + "Convert Ascii string to UUID"}, + {"Unicode", "(String) => Buffer", + "String to Unicode conversion macro"}, + {"Unload", "(Handle)", + "Unload definition block"}, + {"VendorLong", "(DescriptorName) {VendorByteList}", + "Vendor Resource Descriptor"}, + {"VendorShort", "(DescriptorName) {VendorByteList}", + "Vendor Resource Descriptor"}, + {"Wait", "(SyncObject, TimeoutValue) => Boolean", + "Wait on an Event"}, + {"While", "(Predicate) {TermList}", + "Conditional loop"}, + {"WordBusNumber", "(ResourceUsage, IsMinFixed, IsMaxFixed, Decode, AddressGranularity, AddressMinimum, " + "AddressMaximum, AddressTranslation, RangeLength, ResourceSourceIndex, " + "ResourceSource, DescriptorName)", + "Word Bus number Resource Descriptor macro"}, + {"WordIO", "(ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges, AddressGranularity, " + "AddressMinimum, AddressMaximum, AddressTranslation, RangeLength, " + "ResourceSourceIndex, ResourceSource, DescriptorName, TranslationType, " + "TranslationDensity)", + "Word IO Resource Descriptor macro"}, + {"WordSpace", "(ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed, TypeSpecificFlags, " + "AddressGranularity, AddressMinimum, AddressMaximum, AddressTranslation, " + "RangeLength, ResourceSourceIndex, ResourceSource, DescriptorName)", + "Word Space Resource Descriptor macro"}, + {"XOr", "(Source1, Source2, Result) => Integer", + "Integer Bitwise Xor"}, + {"Zero", "=> Integer", + "Constant Zero object (0)"}, + {NULL, NULL, NULL} +}; diff --git a/tools/acpihelp/ahdecode.c b/tools/acpihelp/ahdecode.c new file mode 100644 index 000000000000..aaeae4a03160 --- /dev/null +++ b/tools/acpihelp/ahdecode.c @@ -0,0 +1,732 @@ +/****************************************************************************** + * + * Module Name: ahdecode - Operator/Opcode decoding for acpihelp utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + +#define ACPI_CREATE_PREDEFINED_TABLE +#include "acpredef.h" + +static char Gbl_Buffer[64]; +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/* Local prototypes */ + +static BOOLEAN +AhDisplayPredefinedName ( + char *Name, + UINT32 Length); + +static void +AhDisplayPredefinedInfo ( + char *Name); + +static void +AhGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + +static void +AhDisplayAmlOpcode ( + const AH_AML_OPCODE *Op); + +static void +AhDisplayAslOperator ( + const AH_ASL_OPERATOR *Op); + +static void +AhDisplayAslKeyword ( + const AH_ASL_KEYWORD *Op); + +static void +AhPrintOneField ( + UINT32 Indent, + UINT32 CurrentPosition, + UINT32 MaxPosition, + const char *Field); + + +/******************************************************************************* + * + * FUNCTION: AhFindPredefinedNames (entry point for predefined name search) + * + * PARAMETERS: NamePrefix - Name or prefix to find. Must start with + * an underscore. NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find and display all ACPI predefined names that match the + * input name or prefix. Includes the required number of arguments + * and the expected return type, if any. + * + ******************************************************************************/ + +void +AhFindPredefinedNames ( + char *NamePrefix) +{ + UINT32 Length; + BOOLEAN Found; + char Name[9]; + + + if (!NamePrefix) + { + Found = AhDisplayPredefinedName (Name, 0); + return; + } + + /* Contruct a local name or name prefix */ + + AhStrupr (NamePrefix); + if (*NamePrefix == '_') + { + NamePrefix++; + } + + Name[0] = '_'; + strncpy (&Name[1], NamePrefix, 7); + + Length = strlen (Name); + if (Length > 4) + { + printf ("%.8s: Predefined name must be 4 characters maximum\n", Name); + return; + } + + Found = AhDisplayPredefinedName (Name, Length); + if (!Found) + { + printf ("%s, no matching predefined names\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayPredefinedName + * + * PARAMETERS: Name - Name or name prefix + * + * RETURN: TRUE if any names matched, FALSE otherwise + * + * DESCRIPTION: Display information about ACPI predefined names that match + * the input name or name prefix. + * + ******************************************************************************/ + +static BOOLEAN +AhDisplayPredefinedName ( + char *Name, + UINT32 Length) +{ + const AH_PREDEFINED_NAME *Info; + BOOLEAN Found = FALSE; + BOOLEAN Matched; + UINT32 i; + + + /* Find/display all names that match the input name prefix */ + + for (Info = AslPredefinedInfo; Info->Name; Info++) + { + if (!Name) + { + Found = TRUE; + printf ("%s: <%s>\n", Info->Name, Info->Description); + printf ("%*s%s\n", 6, " ", Info->Action); + + AhDisplayPredefinedInfo (Info->Name); + continue; + } + + Matched = TRUE; + for (i = 0; i < Length; i++) + { + if (Info->Name[i] != Name[i]) + { + Matched = FALSE; + break; + } + } + + if (Matched) + { + Found = TRUE; + printf ("%s: <%s>\n", Info->Name, Info->Description); + printf ("%*s%s\n", 6, " ", Info->Action); + + AhDisplayPredefinedInfo (Info->Name); + } + } + + return (Found); +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayPredefinedInfo + * + * PARAMETERS: Name - Exact 4-character ACPI name. + * + * RETURN: None + * + * DESCRIPTION: Find the name in the main ACPICA predefined info table and + * display the # of arguments and the return value type. + * + * Note: Resource Descriptor field names do not appear in this + * table -- thus, nothing will be displayed for them. + * + ******************************************************************************/ + +static void +AhDisplayPredefinedInfo ( + char *Name) +{ + const ACPI_PREDEFINED_INFO *ThisName; + BOOLEAN Matched; + UINT32 i; + + + /* Find/display only the exact input name */ + + for (ThisName = PredefinedNames; ThisName->Info.Name[0]; ThisName++) + { + Matched = TRUE; + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (ThisName->Info.Name[i] != Name[i]) + { + Matched = FALSE; + break; + } + } + + if (Matched) + { + AhGetExpectedTypes (Gbl_Buffer, ThisName->Info.ExpectedBtypes); + + printf ("%*s%4.4s has %u arguments, returns: %s\n", + 6, " ", ThisName->Info.Name, ThisName->Info.ParamCount, + ThisName->Info.ExpectedBtypes ? Gbl_Buffer : "-Nothing-"); + return; + } + + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AhGetExpectedTypes + * + * PARAMETERS: Buffer - Where the formatted string is returned + * ExpectedBTypes - Bitfield of expected data types + * + * RETURN: Formatted string in Buffer. + * + * DESCRIPTION: Format the expected object types into a printable string. + * + ******************************************************************************/ + +static void +AhGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + strcat (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAmlOpcode (entry point for AML opcode name search) + * + * PARAMETERS: Name - Name or prefix for an AML opcode. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all AML opcodes that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAmlOpcode ( + char *Name) +{ + const AH_AML_OPCODE *Op; + BOOLEAN Found = FALSE; + + + AhStrupr (Name); + + /* Find/display all opcode names that match the input name prefix */ + + for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) + { + if (!Op->OpcodeName) /* Unused opcodes */ + { + continue; + } + + if (!Name) + { + AhDisplayAmlOpcode (Op); + Found = TRUE; + continue; + } + + /* Upper case the opcode name before substring compare */ + + strcpy (Gbl_Buffer, Op->OpcodeName); + AhStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAmlOpcode (Op); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching AML operators\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDecodeAmlOpcode (entry point for AML opcode search) + * + * PARAMETERS: OpcodeString - String version of AML opcode + * + * RETURN: None + * + * DESCRIPTION: Display information about the input AML opcode + * + ******************************************************************************/ + +void +AhDecodeAmlOpcode ( + char *OpcodeString) +{ + const AH_AML_OPCODE *Op; + UINT32 Opcode; + BOOLEAN Found = FALSE; + UINT8 Prefix; + + + if (!OpcodeString) + { + AhFindAmlOpcode (NULL); + return; + } + + Opcode = ACPI_STRTOUL (OpcodeString, NULL, 16); + if (Opcode > ACPI_UINT16_MAX) + { + printf ("Invalid opcode (more than 16 bits)\n"); + return; + } + + /* Only valid opcode extension is 0x5B */ + + Prefix = (Opcode & 0x0000FF00) >> 8; + if (Prefix && (Prefix != 0x5B)) + { + printf ("Invalid opcode (invalid extension prefix 0x%X)\n", + Prefix); + return; + } + + /* Find/Display the opcode. May fall within an opcode range */ + + for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) + { + if ((Opcode >= Op->OpcodeRangeStart) && + (Opcode <= Op->OpcodeRangeEnd)) + { + AhDisplayAmlOpcode (Op); + Found = TRUE; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAmlOpcode + * + * PARAMETERS: Op - An opcode info struct + * + * RETURN: None + * + * DESCRIPTION: Display the contents of an AML opcode information struct + * + ******************************************************************************/ + +static void +AhDisplayAmlOpcode ( + const AH_AML_OPCODE *Op) +{ + + if (!Op->OpcodeName) + { + printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString); + return; + } + + /* Opcode name and value(s) */ + + printf ("%18s: Opcode=%-9s Type (%s)", + Op->OpcodeName, Op->OpcodeString, Op->Type); + + /* Optional fixed/static arguments */ + + if (Op->FixedArguments) + { + printf (" FixedArgs ("); + AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12, + AH_MAX_AML_LINE_LENGTH, Op->FixedArguments); + printf (")"); + } + + /* Optional variable-length argument list */ + + if (Op->VariableArguments) + { + if (Op->FixedArguments) + { + printf ("\n%*s", 36, " "); + } + printf (" VariableArgs ("); + AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments); + printf (")"); + } + printf ("\n"); + + /* Grammar specification */ + + if (Op->Grammar) + { + AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar); + printf ("\n"); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAslKeywords (entry point for ASL keyword search) + * + * PARAMETERS: Name - Name or prefix for an ASL keyword. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all ASL keywords that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAslKeywords ( + char *Name) +{ + const AH_ASL_KEYWORD *Keyword; + BOOLEAN Found = FALSE; + + + AhStrupr (Name); + + for (Keyword = AslKeywordInfo; Keyword->Name; Keyword++) + { + if (!Name) + { + AhDisplayAslKeyword (Keyword); + Found = TRUE; + continue; + } + + /* Upper case the operator name before substring compare */ + + strcpy (Gbl_Buffer, Keyword->Name); + AhStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAslKeyword (Keyword); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching ASL keywords\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAslKeyword + * + * PARAMETERS: Op - Pointer to ASL keyword with syntax info + * + * RETURN: None + * + * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits + * long lines appropriately for reading. + * + ******************************************************************************/ + +static void +AhDisplayAslKeyword ( + const AH_ASL_KEYWORD *Op) +{ + + /* ASL keyword name and description */ + + printf ("%20s: %s\n", Op->Name, Op->Description); + if (!Op->KeywordList) + { + return; + } + + /* List of actual keywords */ + + AhPrintOneField (22, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList); + printf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAslOperators (entry point for ASL operator search) + * + * PARAMETERS: Name - Name or prefix for an ASL operator. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all ASL operators that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAslOperators ( + char *Name) +{ + const AH_ASL_OPERATOR *Operator; + BOOLEAN Found = FALSE; + + + AhStrupr (Name); + + /* Find/display all names that match the input name prefix */ + + for (Operator = AslOperatorInfo; Operator->Name; Operator++) + { + if (!Name) + { + AhDisplayAslOperator (Operator); + Found = TRUE; + continue; + } + + /* Upper case the operator name before substring compare */ + + strcpy (Gbl_Buffer, Operator->Name); + AhStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAslOperator (Operator); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching ASL operators\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAslOperator + * + * PARAMETERS: Op - Pointer to ASL operator with syntax info + * + * RETURN: None + * + * DESCRIPTION: Format and display syntax info for an ASL operator. Splits + * long lines appropriately for reading. + * + ******************************************************************************/ + +static void +AhDisplayAslOperator ( + const AH_ASL_OPERATOR *Op) +{ + + /* ASL operator name and description */ + + printf ("%16s: %s\n", Op->Name, Op->Description); + if (!Op->Syntax) + { + return; + } + + /* Syntax for the operator */ + + AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax); + printf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AhPrintOneField + * + * PARAMETERS: Indent - Indent length for new line(s) + * CurrentPosition - Position on current line + * MaxPosition - Max allowed line length + * Field - Data to output + * + * RETURN: Line position after field is written + * + * DESCRIPTION: Split long lines appropriately for ease of reading. + * + ******************************************************************************/ + +static void +AhPrintOneField ( + UINT32 Indent, + UINT32 CurrentPosition, + UINT32 MaxPosition, + const char *Field) +{ + UINT32 Position; + UINT32 TokenLength; + const char *This; + const char *Next; + const char *Last; + + + This = Field; + Position = CurrentPosition; + + if (Position == 0) + { + printf ("%*s", (int) Indent, " "); + Position = Indent; + } + + Last = This + strlen (This); + while ((Next = strpbrk (This, " "))) + { + TokenLength = Next - This; + Position += TokenLength; + + /* Split long lines */ + + if (Position > MaxPosition) + { + printf ("\n%*s", (int) Indent, " "); + Position = TokenLength; + } + + printf ("%.*s ", (int) TokenLength, This); + This = Next + 1; + } + + /* Handle last token on the input line */ + + TokenLength = Last - This; + if (TokenLength > 0) + { + Position += TokenLength; + if (Position > MaxPosition) + { + printf ("\n%*s", (int) Indent, " "); + } + printf ("%s", This); + } +} diff --git a/tools/acpihelp/ahmain.c b/tools/acpihelp/ahmain.c new file mode 100644 index 000000000000..b8b9ed33a491 --- /dev/null +++ b/tools/acpihelp/ahmain.c @@ -0,0 +1,221 @@ +/****************************************************************************** + * + * Module Name: ahmain - Main module for the acpi help utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + + +/* Local prototypes */ + +static void +AhDisplayUsage ( + void); + + +/****************************************************************************** + * + * FUNCTION: AhDisplayUsage + * + * DESCRIPTION: Usage message + * + ******************************************************************************/ + +static void +AhDisplayUsage ( + void) +{ + + printf ("\n"); + printf ("Usage: acpihelp <options> [NamePrefix | HexValue]\n\n"); + printf ("Where: -k [NamePrefix] Find/Display ASL non-operator keyword(s)\n"); + printf (" -m [NamePrefix] Find/Display AML opcode name(s)\n"); + printf (" -o [HexValue] Decode hex AML opcode\n"); + printf (" -p [NamePrefix] Find/Display ASL predefined method name(s)\n"); + printf (" -s [NamePrefix] Find/Display ASL operator name(s)\n"); + printf ("\nNamePrefix/HexValue not specified means \"Display All\"\n"); + printf ("\nDefault search with NamePrefix and no options:\n"); + printf (" Find ASL operator names - if NamePrefix does not start with underscore\n"); + printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n"); + printf ("\n"); +} + + +/****************************************************************************** + * + * FUNCTION: main + * + * DESCRIPTION: C main function for AcpiHelp utility. + * + ******************************************************************************/ + +int ACPI_SYSTEM_XFACE +main ( + int argc, + char *argv[]) +{ + char *Name; + UINT32 DecodeType; + int j; + + + printf (ACPI_COMMON_SIGNON ("ACPI Help Utility")); + DecodeType = AH_DECODE_DEFAULT; + + if (argc < 2) + { + AhDisplayUsage (); + return (0); + } + + /* Command line options */ + + while ((j = AcpiGetopt (argc, argv, "hkmops")) != EOF) switch (j) + { + case 'k': + DecodeType = AH_DECODE_ASL_KEYWORD; + break; + + case 'm': + DecodeType = AH_DECODE_AML; + break; + + case 'o': + DecodeType = AH_DECODE_AML_OPCODE; + break; + + case 'p': + DecodeType = AH_DECODE_PREDEFINED_NAME; + break; + + case 's': + DecodeType = AH_DECODE_ASL; + break; + + case 'h': + default: + AhDisplayUsage (); + return (-1); + } + + /* Missing (null) name means "display all" */ + + Name = argv[AcpiGbl_Optind]; + + switch (DecodeType) + { + case AH_DECODE_AML: + AhFindAmlOpcode (Name); + break; + + case AH_DECODE_AML_OPCODE: + AhDecodeAmlOpcode (Name); + break; + + case AH_DECODE_PREDEFINED_NAME: + AhFindPredefinedNames (Name); + break; + + case AH_DECODE_ASL: + AhFindAslOperators (Name); + break; + + case AH_DECODE_ASL_KEYWORD: + AhFindAslKeywords (Name); + break; + + default: + if (!Name) + { + AhFindAslOperators (Name); + break; + } + + if (*Name == '_') + { + AhFindPredefinedNames (Name); + } + else + { + AhFindAslOperators (Name); + } + break; + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AhStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AhStrupr ( + char *SrcString) +{ + char *String; + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) toupper ((int) *String); + } + + return; +} diff --git a/tools/acpihelp/ahpredef.c b/tools/acpihelp/ahpredef.c new file mode 100644 index 000000000000..49d524f930bb --- /dev/null +++ b/tools/acpihelp/ahpredef.c @@ -0,0 +1,277 @@ +/****************************************************************************** + * + * Module Name: ahpredef - Table of all known ACPI predefined names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2011, 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 "acpihelp.h" + +/* + * Predefined ACPI names, with short description and return value. + * This table was extracted directly from the ACPI specification. + */ +const AH_PREDEFINED_NAME AslPredefinedInfo[] = +{ + {"_ACx", "Active Cooling", "Returns the active cooling policy threshold values"}, + {"_ADR", "Address", "Returns the address of a device on its parent bus"}, + {"_ALC", "Ambient Light Chromaticity", "Returns the ambient light color chromaticity"}, + {"_ALI", "Ambient Light Illuminance", "Returns the ambient light brightness"}, + {"_ALN", "Alignment", "Base alignment, Resource Descriptor field"}, + {"_ALP", "Ambient Light Polling", "Returns the ambient light sensor polling frequency"}, + {"_ALR", "Ambient Light Response", "Returns the ambient light brightness to display brightness mappings"}, + {"_ALT", "Ambient Light Temperature", "Returns the ambient light color temperature"}, + {"_ALx", "Active List", "Returns a list of active cooling device objects"}, + {"_ART", "Active cooling Relationship Table", "Returns thermal relationship information between platform devices and fan devices"}, + {"_ASI", "Address Space Id", "Resource Descriptor field"}, + {"_ASZ", "Access Size", "Resource Descriptor field"}, + {"_ATT", "Type-Specific Attribute", "Resource Descriptor field"}, + {"_BAS", "Base Address", "Range base address, Resource Descriptor field"}, + {"_BBN", "Bios Bus Number", "Returns the PCI bus number returned by the BIOS"}, + {"_BCL", "Brightness Control Levels", "Returns a list of supported brightness control levels"}, + {"_BCM", "Brightness Control Method", "Sets the brightness level of the display device"}, + {"_BCT", "Battery Charge Time", "Returns time remaining to complete charging battery"}, + {"_BDN", "Bios Dock Name", "Returns the Dock ID returned by the BIOS"}, + {"_BFS", "Back From Sleep", "Inform AML of a wake event"}, + {"_BIF", "Battery Information", "Returns a Control Method Battery information block"}, + {"_BIX", "Battery Information Extended", "Returns a Control Method Battery extended information block"}, + {"_BLT", "Battery Level Threshold", "Set battery level threshold preferences"}, + {"_BM_", "Bus Master", "Resource Descriptor field"}, + {"_BMA", "Battery Measurement Averaging Interval", "Sets battery measurement averaging interval"}, + {"_BMC", "Battery Maintenance Control", "Sets battery maintenance and control features"}, + {"_BMD", "Battery Maintenance Data", "Returns battery maintenance, control, and state data"}, + {"_BMS", "Battery Measurement Sampling Time", "Sets the battery measurement sampling time"}, + {"_BQC", "Brightness Query Current", "Returns the current display brightness level"}, + {"_BST", "Battery Status", "Returns a Control Method Battery status block"}, + {"_BTM", "Battery Time", "Returns the battery runtime"}, + {"_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"}, + {"_CBA", "Configuration Base Address", "Sets the CBA for a PCI Express host bridge"}, + {"_CDM", "Clock Domain", "Returns a logical processor's clock domain identifier"}, + {"_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"}, + {"_CRS", "Current Resource Settings", "Returns the current resource settings for a device"}, + {"_CRT", "Critical Temperature", "Returns the shutdown critical temperature"}, + {"_CSD", "C State Dependencies", "Returns a list of C-state dependencies"}, + {"_CST", "C States", "Returns a list of supported C-states"}, + {"_DCK", "Dock", "Sets docking isolation. Presence indicates device is a docking station"}, + {"_DCS", "Display Current Status", "Returns status of the display output device"}, + {"_DDC", "Display Data Current", "Returns the EDID for the display output device"}, + {"_DDN", "Dos Device Name", "Returns a device logical name"}, + {"_DEC", "Decode", "Device decoding type, Resource Descriptor field"}, + {"_DGS", "Display Graphics State", "Return the current state of the output device"}, + {"_DIS", "Disable", "Disables a device"}, + {"_DMA", "Direct Memory Access", "Returns a device's current resources for DMA transactions"}, + {"_DOD", "Display Output Devices", "Enumerate all devices attached to the display adapter"}, + {"_DOS", "Disable Output Switching", "Sets the display output switching mode"}, + {"_DSM", "Device Specific Method", "Executes device-specific functions"}, + {"_DSS", "Device Set State", "Sets the display device state"}, + {"_DSW", "Device Sleep Wake", "Sets the sleep and wake transition states for a device"}, + {"_DTI", "Device Temperature Indication", "Conveys native device temperature to the platform"}, + {"_Exx", "Edge GPE", "Method executed as a result of a general-purpose event"}, + {"_EC_", "Embedded Controller", "returns EC offset and query information"}, + {"_EDL", "Eject Device List", "Returns a list of devices that are dependent on a device (docking)"}, + {"_EJD", "Ejection Dependent Device", "Returns the name of dependent (parent) device (docking)"}, + {"_EJx", "Eject", "Begin or cancel a device ejection request (docking)"}, + {"_FDE", "Floppy Disk Enumerate", "Returns floppy disk configuration information"}, + {"_FDI", "Floppy Drive Information", "Returns a floppy drive information block"}, + {"_FDM", "Floppy Drive Mode", "Sets a floppy drive speed"}, + {"_FIF", "Fan Information", "Returns fan device information"}, + {"_FIX", "Fixed Register Resource Provider", "Returns a list of devices that implement FADT register blocks"}, + {"_FPS", "Fan Performance States", "Returns a list of supported fan performance states"}, + {"_FSL", "Fan Set Level", "Control method that sets the fan device's speed level (performance state)"}, + {"_FST", "Fan Status", "Returns current status information for a fan device"}, + {"_GAI", "Get Averaging Interval", "Returns the power meter averaging interval"}, + {"_GHL", "Get Hardware Limit", "Returns the hardware limit enforced by the power meter"}, + {"_GL_", "Global Lock", "OS-defined Global Lock mutex object"}, + {"_GLK", "Global Lock", "Returns a device's Global Lock requirement for device access"}, + {"_GPD", "Get Post Data", "Returns the value of the VGA device that will be posted at boot"}, + {"_GPE", "General Purpose Events", "(1) predefined Scope (\\_GPE.)"}, + {"_GRA", "Granularity", "Address space granularity, Resource Descriptor field"}, + {"_GSB", "Global System Interrupt Base", "Returns the GSB for a I/O APIC device"}, + {"_GTF", "Get Task File", "Returns a list of ATA commands to restore a drive to default state"}, + {"_GTM", "Get Timing Mode", "Returns a list of IDE controller timing information"}, + {"_GTS", "Going To Sleep", "Inform AML of pending sleep"}, + {"_HE_", "High-Edge", "Interrupt triggering, Resource Descriptor field"}, + {"_HID", "Hardware ID", "Returns a device's Plug and Play Hardware ID"}, + {"_HOT", "Hot Temperature", "Returns the critical temperature for sleep (entry to S4)"}, + {"_HPP", "Hot Plug Parameters", "Returns a list of hot-plug information for a PCI device"}, + {"_HPX", "Hot Plug Parameter Extensions", "Returns a list of hot-plug information for a PCI device. Supersedes _HPP"}, + {"_IFT", "IPMI Interface Type", "See the Intelligent Platform Management Interface Specification"}, + {"_INI", "Initialize", "Performs device specific initialization"}, + {"_INT", "Interrupts", "Interrupt mask bits, Resource Descriptor field"}, + {"_IRC", "Inrush Current", "Presence indicates that a device has a significant inrush current draw"}, + {"_Lxx", "Level GPE", "Control method executed as a result of a general-purpose event"}, + {"_LCK", "Lock", "Locks or unlocks a device (docking)"}, + {"_LEN", "Length", "Range length, Resource Descriptor field"}, + {"_LID", "Lid", "Returns the open/closed status of the lid on a mobile system"}, + {"_LL_", "Low Level", "Interrupt polarity, Resource Descriptor field"}, + {"_MAF", "Maximum Address Fixed", "Resource Descriptor field"}, + {"_MAT", "Multiple Apic Table Entry", "Returns a list of MADT APIC structure entries"}, + {"_MAX", "Maximum Base Address", "Resource Descriptor field"}, + {"_MBM", "Memory Bandwidth Monitoring Data", "Returns bandwidth monitoring data for a memory device"}, + {"_MEM", "Memory Attributes", "Resource Descriptor field"}, + {"_MIF", "Minimum Address Fixed", "Resource Descriptor field"}, + {"_MIN", "Minimum Base Address", "Resource Descriptor field"}, + {"_MLS", "Multiple Language String", "Returns a device description in multiple languages"}, + {"_MSG", "Message", "Sets the system message waiting status indicator"}, + {"_MSM", "Memory Set Monitoring", "Sets bandwidth monitoring parameters for a memory device"}, + {"_MTP", "Memory Type", "Resource Descriptor field"}, + {"_NTT", "Notification Temperature Threshold", "Returns a threshold for device temperature change that requires platform notification"}, + {"_OFF", "Off", "Sets a power resource to the off state"}, + {"_ON_", "On", "Sets a power resource to the on state"}, + {"_OS_", "Operating System", "Returns a string that identifies the operating system"}, + {"_OSC", "Operating System Capabilities", "Inform AML of host features and capabilities"}, + {"_OSI", "Operating System Interfaces", "Returns supported interfaces, behaviors, and features"}, + {"_OST", "Ospm Status Indication", "Inform AML of event processing status"}, + {"_PAI", "Power Averaging Interval", "Sets the averaging interval for a power meter"}, + {"_PCL", "Power Consumer List", "Returns a list of devices powered by a power source"}, + {"_PCT", "Performance Control", "Returns processor performance control and status registers"}, + {"_PDC", "Processor Driver Capabilities", "Inform AML of processor driver capabilities"}, + {"_PDL", "P-state Depth Limit", "Returns the lowest available performance P-state"}, + {"_PIC", "PIC", "Inform AML of the interrupt model in use"}, + {"_PIF", "Power Source Information", "Returns a Power Source information block"}, + {"_PLD", "Physical Device Location", "Returns a device's physical location information"}, + {"_PMC", "Power Meter Capabilities", "Returns a list of Power Meter capabilities info"}, + {"_PMD", "Power Metered Devices", "Returns a list of devices that are measured by the power meter device"}, + {"_PMM", "Power Meter Measurement", "Returns the current value of the Power Meter"}, + {"_PPC", "Performance Present Capabilites", "Returns a list of the performance states currently supported by the platform"}, + {"_PPE", "Polling for Platform Error", "Returns the polling interval to retrieve Corrected Platform Error information"}, + {"_PR", "Processor", "Predefined scope for processor objects"}, + {"_PR0", "Power Resources for D0", "Returns a list of dependent power resources to enter state D0 (fully on)"}, + {"_PR1", "Power Resources for D1", "Returns a list of dependent power resources to enter state D1"}, + {"_PR2", "Power Resources for D2", "Returns a list of dependent power resources to enter state D2"}, + {"_PR3", "Power Resources for D3hot", "Returns a list of dependent power resources to enter state D3hot"}, + {"_PRL", "Power Source Redundancy List", "Returns a list of power source devices in the same redundancy grouping"}, + {"_PRS", "Possible Resource Settings", "Returns a list of a device's possible resource settings"}, + {"_PRT", "Pci Routing Table", "Returns a list of PCI interrupt mappings"}, + {"_PRW", "Power Resources for Wake", "Returns a list of dependent power resources for waking"}, + {"_PS0", "Power State 0", "Sets a device's power state to D0 (device fully on)"}, + {"_PS1", "Power State 1", "Sets a device's power state to D1"}, + {"_PS2", "Power State 2", "Sets a device's power state to D2"}, + {"_PS3", "Power State 3", "Sets a device's power state to D3 (device off)"}, + {"_PSC", "Power State Current", "Returns a device's current power state"}, + {"_PSD", "Processor State Dependencies", "Returns processor P-State dependencies"}, + {"_PSL", "Passive List", "Returns a list of passive cooling device objects"}, + {"_PSR", "Power Source", "Returns the power source device currently in use"}, + {"_PSS", "Performance Supported States", "Returns a list of supported processor performance states"}, + {"_PSV", "Passive", "Returns the passive trip point temperature"}, + {"_PSW", "Power State Wake", "Sets a device's wake function"}, + {"_PTC", "Processor Throttling Control", "Returns throttling control and status registers"}, + {"_PTP", "Power Trip Points", "Sets trip points for the Power Meter device"}, + {"_PTS", "Prepare To Sleep", "Inform the platform of an impending sleep transition"}, + {"_PUR", "Processor Utilization Request", "Returns the number of processors that the platform would like to idle"}, + {"_PXM", "Proximity", "Returns a device's proximity domain identifier"}, + {"_Qxx", "Query", "Embedded Controller query and SMBus Alarm control method"}, + {"_RBO", "Register Bit Offset", "Resource Descriptor field"}, + {"_RBW", "Register Bit Width", "Resource Descriptor field"}, + {"_REG", "Region", "Inform AML code of an operation region availability change"}, + {"_REV", "Revision", "Returns the revision of the ACPI specification that is implemented"}, + {"_RMV", "Remove", "Returns a device's removal ability status (docking)"}, + {"_RNG", "Range", "Memory range type, Resource Descriptor field"}, + {"_ROM", "Read-Only Memory", "Returns a copy of the ROM data for a display device"}, + {"_RT_", "Resource Type", "Resource Descriptor field"}, + {"_RTV", "Relative Temperature Values", "Returns temperature value information"}, + {"_RW_", "Read-Write Status", "Resource Descriptor field"}, + {"_S0_", "S0 System State", "Returns values to enter the system into the S0 state"}, + {"_S1_", "S1 System State", "Returns values to enter the system into the S1 state"}, + {"_S2_", "S2 System State", "Returns values to enter the system into the S2 state"}, + {"_S3_", "S3 System State", "Returns values to enter the system into the S3 state"}, + {"_S4_", "S4 System State", "Returns values to enter the system into the S4 state"}, + {"_S5_", "S5 System State", "Returns values to enter the system into the S5 state"}, + {"_S1D", "S1 Device State", "Returns the highest D-state supported by a device when in the S1 state"}, + {"_S2D", "S2 Device State", "Returns the highest D-state supported by a device when in the S2 state"}, + {"_S3D", "S3 Device State", "Returns the highest D-state supported by a device when in the S3 state"}, + {"_S4D", "S4 Device State", "Returns the highest D-state supported by a device when in the S4 state"}, + {"_S0W", "S0 Device Wake State", "Returns the lowest D-state that the device can wake itself from S0"}, + {"_S1W", "S1 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S1"}, + {"_S2W", "S2 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S2"}, + {"_S3W", "S3 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S3"}, + {"_S4W", "S4 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S4"}, + {"_SB_", "System Bus", "Scope for device and bus objects"}, + {"_SBS", "Smart Battery Subsystem", "Returns the subsystem configuration"}, + {"_SCP", "Set Cooling Policy", "Sets the cooling policy (active or passive)"}, + {"_SDD", "Set Device Data", "Sets data for a SATA device"}, + {"_SEG", "Segment", "Returns a device's PCI Segment Group number"}, + {"_SHL", "Set Hardware Limit", "Sets the hardware limit enforced by the Power Meter"}, + {"_SHR", "Sharable", "Interrupt share status, Resource Descriptor field"}, + {"_SI_", "System Indicators", "Predefined scope"}, + {"_SIZ", "Size", "DMA transfer size, Resource Descriptor field"}, + {"_SLI", "System Locality Information", "Returns a list of NUMA system localities"}, + {"_SPD", "Set Post Device", "Sets which video device will be posted at boot"}, + {"_SRS", "Set Resource Settings", "Sets a device's resource allocation"}, + {"_SRV", "IPMI Spec Revision", "See the Intelligent Platform Management Interface Specification"}, + {"_SST", "System Status", "Sets the system status indicator"}, + {"_STA", "Status", " (1) returns the current status of a device"}, + {"_STM", "Set Timing Mode", "Sets an IDE controller transfer timings"}, + {"_STP", "Set Expired Timer Wake Policy", "Sets expired timer policies of the wake alarm device"}, + {"_STR", "String", "Returns a device's description string"}, + {"_STV", "Set Timer Value", "Set timer values of the wake alarm device"}, + {"_SUN", "Slot User Number", "Returns the slot unique ID number"}, + {"_SWS", "System Wake Source", "Returns the source event that caused the system to wake"}, + {"_T_x", "Temporary", "Reserved for use by ASL compilers"}, + {"_TC1", "Thermal Constant 1", "Returns TC1 for the passive cooling formula"}, + {"_TC2", "Thermal Constant 2", "Returns TC2 for the passive cooling formula"}, + {"_TDL", "T-State Depth Limit", "Returns the _TSS entry number of the lowest power throttling state"}, + {"_TIP", "Expired Timer Wake Policy", "Returns timer policies of the wake alarm device"}, + {"_TIV", "Timer Values", "Returns remaining time of the wake alarm device"}, + {"_TMP", "Temperature", "Returns a thermal zone's current temperature"}, + {"_TPC", "Throttling Present Capabilities", "Returns the current number of supported throttling states"}, + {"_TPT", "Trip Point Temperature", "Inform AML that a device's embedded temperature sensor has crossed a temperature trip point"}, + {"_TRA", "Translation", "Address translation offset, Resource Descriptor field"}, + {"_TRS", "Translation Sparse", "Sparse/dense flag, Resource Descriptor field"}, + {"_TRT", "Thermal Relationship Table", "Returns thermal relationships between platform devices"}, + {"_TSD", "Throttling State Dependencies", "Returns a list of T-state dependencies"}, + {"_TSF", "Type-Specific Flags", "Resource Descriptor field"}, + {"_TSP", "Thermal Sampling Period", "Returns the thermal sampling period for passive cooling"}, + {"_TSS", "Throttling Supported States", "Returns supported throttling state information"}, + {"_TST", "Temperature Sensor Threshold", "Returns the minimum separation for a device's temperature trip points"}, + {"_TTP", "Translation Type", "Translation/static flag, Resource Descriptor field"}, + {"_TTS", "Transition To State", "Inform AML of an S-state transition"}, + {"_TYP", "Type", "DMA channel type (speed), Resource Descriptor field"}, + {"_TZ_", "Thermal Zone", "Predefined scope: ACPI 1.0"}, + {"_TZD", "Thermal Zone Devices", "Returns a list of device names associated with a Thermal Zone"}, + {"_TZM", "Thermal Zone Member", "Returns a reference to the thermal zone of which a device is a member"}, + {"_TZP", "Thermal Zone Polling", "Returns a Thermal zone's polling frequency"}, + {"_UID", "Unique ID", "Return a device's unique persistent ID"}, + {"_UPC", "USB Port Capabilities", "Returns a list of USB port capabilities"}, + {"_UPD", "User Presence Detect", "Returns user detection information"}, + {"_UPP", "User Presence Polling", "Returns the recommended user presence polling interval"}, + {"_VPO", "Video Post Options", "Returns the implemented video post options"}, + {"_WAK", "Wake", "Inform AML that the system has just awakened"}, + {"_Wxx", "Wake Event", "Method executed as a result of a wake event"} +}; diff --git a/tools/acpinames/Makefile b/tools/acpinames/Makefile index 9e20e4e795ad..d88d6c5ef9fb 100644 --- a/tools/acpinames/Makefile +++ b/tools/acpinames/Makefile @@ -1,19 +1,58 @@ # -# AcpiNames utility +# acpinames - Load ACPI table and dump namespace. This is a subset +# of the AcpiExec functionality, it is intended to demonstrate +# the configurability of ACPICA. +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# + +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. # PROG = acpinames +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? + +ACPICA_COMPONENTS = ACPICA_SRC = ../.. ACPICA_COMMON = $(ACPICA_SRC)/common -ACPICA_CORE = $(ACPICA_SRC) +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) ACPICA_TOOLS = $(ACPICA_SRC)/tools ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers - -NOMAN= YES -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_APPLICATION -DACPI_SINGLE_THREADED -DACPI_DEBUGGER -Wstrict-prototypes -I$(ACPICA_SRC)/include -I$(ACPICA_TOOLS)/acpinames - -COMPILE = $(CC) -c $(CFLAGS) -o$@ $? -LDFLAGS += -lpthread -lrt +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) + +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_NAMES_APP \ + -I$(ACPICA_SRC)/include \ + -I$(ACPICA_TOOLS)/acpinames + +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef OBJS = \ anmain.o \ @@ -80,14 +119,11 @@ OBJS = \ utxferror.o \ utxface.o - # # Root rule # $(PROG) : $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -lpthread -o $(PROG) - $(COPYPROG) - + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) # # acpinames source @@ -101,14 +137,12 @@ anstubs.o : $(ACPICA_TOOLS)/acpinames/anstubs.c antables.o : $(ACPICA_TOOLS)/acpinames/antables.c $(COMPILE) - # # ACPICA core source - common # getopt.o : $(ACPICA_COMMON)/getopt.c $(COMPILE) - # # ACPICA core source # @@ -286,7 +320,6 @@ utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c utxface.o : $(ACPICA_CORE)/utilities/utxface.c $(COMPILE) - # # Unix OS services layer (OSL) # @@ -294,5 +327,8 @@ osunixxf.o : $(ACPICA_OSL)/osunixxf.c $(COMPILE) -clean : +clean : rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/acpinames/anstubs.c b/tools/acpinames/anstubs.c index a5225e4cb828..dba4134a4598 100644 --- a/tools/acpinames/anstubs.c +++ b/tools/acpinames/anstubs.c @@ -420,4 +420,20 @@ AcpiDbTerminate ( { } +/* OSL interfaces */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (0xFFFF); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_SUPPORT); +} diff --git a/tools/acpisrc/Makefile b/tools/acpisrc/Makefile index 216c51a68615..bd55d024db6a 100644 --- a/tools/acpisrc/Makefile +++ b/tools/acpisrc/Makefile @@ -1,17 +1,113 @@ - +# +# acpisrc - ACPICA source code conversion utility +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# -PROG= acpisrc -SRCS= ascase.c asconvrt.c asfile.c asmain.c asremove.c astable.c \ - asutils.c osunixdir.c ../../common/getopt.c +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROG = acpisrc -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? +ACPICA_COMPONENTS = +ACPICA_SRC = ../.. +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) -aslmain : $(patsubst %.c,%.o, $(SRCS)) - $(CC) $(LDFLAGS) $(CFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -DACPI_SRC_APP \ + -I$(ACPICA_SRC)/include \ + -I. -CLEANFILES= $(PROG) +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef -clean : - rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) +OBJS = \ + ascase.o \ + asconvrt.o \ + asfile.o \ + asmain.o \ + asremove.o \ + astable.o \ + asutils.o \ + osunixdir.o \ + getopt.o +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + +# +# acpisrc source +# +ascase.o : $(ACPICA_TOOLS)/acpisrc/ascase.c + $(COMPILE) + +asconvrt.o : $(ACPICA_TOOLS)/acpisrc/asconvrt.c + $(COMPILE) + +asfile.o : $(ACPICA_TOOLS)/acpisrc/asfile.c + $(COMPILE) + +asmain.o : $(ACPICA_TOOLS)/acpisrc/asmain.c + $(COMPILE) + +asremove.o : $(ACPICA_TOOLS)/acpisrc/asremove.c + $(COMPILE) + +astable.o : $(ACPICA_TOOLS)/acpisrc/astable.c + $(COMPILE) + +asutils.o : $(ACPICA_TOOLS)/acpisrc/asutils.c + $(COMPILE) + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + +# +# Unix OS services layer (OSL) +# +osunixdir.o : $(ACPICA_OSL)/osunixdir.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG) $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/acpisrc/acpisrc.h b/tools/acpisrc/acpisrc.h index b879e57de91b..857dbaa3de9d 100644 --- a/tools/acpisrc/acpisrc.h +++ b/tools/acpisrc/acpisrc.h @@ -64,12 +64,13 @@ #include <errno.h> -/* Fixups for non-Win32 compilation */ -#ifndef WIN32 +/* O_BINARY is not always defined */ #ifndef O_BINARY #define O_BINARY 0x0 #endif +/* Fixups for non-Win32 compilation */ +#ifndef WIN32 #define mkdir(x) mkdir(x, 0770) char * strlwr(char* str); #endif diff --git a/tools/acpisrc/osunixdir.c b/tools/acpisrc/osunixdir.c deleted file mode 100644 index 54543bb2bcc4..000000000000 --- a/tools/acpisrc/osunixdir.c +++ /dev/null @@ -1,251 +0,0 @@ - -/****************************************************************************** - * - * Module Name: osunixdir - Unix directory access interfaces - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2011, 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 <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <dirent.h> -#include <fnmatch.h> -#include <ctype.h> -#include <sys/stat.h> - -#include "acpisrc.h" - -/* - * Allocated structure returned from OsOpenDirectory - */ -typedef struct ExternalFindInfo -{ - char *DirPathname; - DIR *DirPtr; - char temp_buffer[128]; - char *WildcardSpec; - char RequestedFileType; - -} EXTERNAL_FIND_INFO; - - -/******************************************************************************* - * - * FUNCTION: AcpiOsOpenDirectory - * - * PARAMETERS: DirPathname - Full pathname to the directory - * WildcardSpec - string of the form "*.c", etc. - * - * RETURN: A directory "handle" to be used in subsequent search operations. - * NULL returned on failure. - * - * DESCRIPTION: Open a directory in preparation for a wildcard search - * - ******************************************************************************/ - -void * -AcpiOsOpenDirectory ( - char *DirPathname, - char *WildcardSpec, - char RequestedFileType) -{ - EXTERNAL_FIND_INFO *ExternalInfo; - DIR *dir; - - - /* Allocate the info struct that will be returned to the caller */ - - ExternalInfo = calloc (sizeof (EXTERNAL_FIND_INFO), 1); - if (!ExternalInfo) - { - return (NULL); - } - - /* Get the directory stream */ - - dir = opendir (DirPathname); - if (!dir) - { - free (ExternalInfo); - return (NULL); - } - - /* Save the info in the return structure */ - - ExternalInfo->WildcardSpec = WildcardSpec; - ExternalInfo->RequestedFileType = RequestedFileType; - ExternalInfo->DirPathname = DirPathname; - ExternalInfo->DirPtr = dir; - return (ExternalInfo); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsGetNextFilename - * - * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory - * - * RETURN: Next filename matched. NULL if no more matches. - * - * DESCRIPTION: Get the next file in the directory that matches the wildcard - * specification. - * - ******************************************************************************/ - -char * -AcpiOsGetNextFilename ( - void *DirHandle) -{ - EXTERNAL_FIND_INFO *ExternalInfo = DirHandle; - struct dirent *dir_entry; - char *temp_str; - int str_len; - struct stat temp_stat; - int err; - - - while ((dir_entry = readdir (ExternalInfo->DirPtr))) - { - if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0)) - { - if (dir_entry->d_name[0] == '.') - { - continue; - } - - str_len = strlen (dir_entry->d_name) + - strlen (ExternalInfo->DirPathname) + 2; - - temp_str = calloc (str_len, 1); - if (!temp_str) - { - printf ("Could not allocate buffer for temporary string\n"); - return (NULL); - } - - strcpy (temp_str, ExternalInfo->DirPathname); - strcat (temp_str, "/"); - strcat (temp_str, dir_entry->d_name); - - err = stat (temp_str, &temp_stat); - free (temp_str); - if (err == -1) - { - printf ("stat() error - should not happen\n"); - return (NULL); - } - - if ((S_ISDIR (temp_stat.st_mode) - && (ExternalInfo->RequestedFileType == REQUEST_DIR_ONLY)) - || - ((!S_ISDIR (temp_stat.st_mode) - && ExternalInfo->RequestedFileType == REQUEST_FILE_ONLY))) - { - /* copy to a temp buffer because dir_entry struct is on the stack */ - - strcpy (ExternalInfo->temp_buffer, dir_entry->d_name); - return (ExternalInfo->temp_buffer); - } - } - } - - return (NULL); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsCloseDirectory - * - * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory - * - * RETURN: None. - * - * DESCRIPTION: Close the open directory and cleanup. - * - ******************************************************************************/ - -void -AcpiOsCloseDirectory ( - void *DirHandle) -{ - EXTERNAL_FIND_INFO *ExternalInfo = DirHandle; - - - /* Close the directory and free allocations */ - - closedir (ExternalInfo->DirPtr); - free (DirHandle); -} - - -/* Other functions acpisrc uses but that aren't standard on Unix */ - -/******************************************************************************* - * - * FUNCTION: strlwr - * - * PARAMETERS: str - String to be lowercased. - * - * RETURN: str. - * - * DESCRIPTION: Lowercase a string in-place. - * - ******************************************************************************/ - -char * -strlwr ( - char *str) -{ - int length; - int i; - - - length = strlen (str); - - for (i = 0; i < length; i++) - { - str[i] = tolower ((int) str[i]); - } - - return (str); -} diff --git a/tools/acpixtract/Makefile b/tools/acpixtract/Makefile index 3dd15233f107..8b7bcf9d6cee 100644 --- a/tools/acpixtract/Makefile +++ b/tools/acpixtract/Makefile @@ -1,16 +1,73 @@ - +# +# acpixtract - extract binary ACPI tables from acpidump text output +# +# NOTE: This makefile is intended to be used in the Linux environment, +# with the Linux directory structure. It will not work directly +# on the native ACPICA source tree. +# -PROG= acpixtract -SRCS= acpixtract.c +# +# Configuration +# Notes: +# gcc should be version 4 or greater, otherwise some of the options +# used will not be recognized. +# Global optimization flags (such as -O2, -Os) are not used, since +# they cause issues on some compilers. +# The _GNU_SOURCE symbol is required for many hosts. +# +PROG = acpixtract -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +HOST = _LINUX +NOMAN = YES +COMPILE = $(CC) -c $(CFLAGS) $(CWARNINGFLAGS) -o$@ $? +ACPICA_COMPONENTS = +ACPICA_SRC = ../.. +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_CORE = $(ACPICA_SRC)$(ACPICA_COMPONENTS) +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers +INSTALLDIR = /usr/bin +INSTALLPROG = cp --remove-destination $(PROG) $(INSTALLDIR) -acpixtract : $(patsubst %.c,%.o, $(SRCS)) - $(CC) $(LDFLAGS) $(CFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) +CFLAGS+= \ + -D$(HOST) \ + -D_GNU_SOURCE \ + -I$(ACPICA_SRC)/include -CLEANFILES= $(PROG) +CWARNINGFLAGS = \ + -ansi \ + -Wall \ + -Wbad-function-cast \ + -Wdeclaration-after-statement \ + -Werror \ + -Wformat=2 \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wstrict-aliasing=0 \ + -Wstrict-prototypes \ + -Wswitch-default \ + -Wpointer-arith \ + -Wundef -clean : - rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) +OBJS = \ + acpixtract.o +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(PROG) + +# +# acpixtract source +# +acpixtract.o : $(ACPICA_TOOLS)/acpixtract/acpixtract.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG).exe $(OBJS) + +install : + $(INSTALLPROG) diff --git a/tools/examples/examples.c b/tools/examples/examples.c index a3142417e920..29975c913724 100644 --- a/tools/examples/examples.c +++ b/tools/examples/examples.c @@ -432,3 +432,18 @@ AeLocalGetRootPointer ( return (0); } +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (0xFFFF); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_SUPPORT); +} |