From 754171ae60abbbd707ed8d449f07ef38f596bd22 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Thu, 11 Sep 2014 21:38:09 +0000 Subject: Import ACPICA 20140828. --- changes.txt | 155 ++ generate/unix/Makefile.config | 5 + generate/unix/acpiexamples/Makefile | 1 + generate/unix/acpiexec/Makefile | 3 + generate/unix/acpihelp/Makefile | 5 +- generate/unix/acpinames/Makefile | 1 + generate/unix/iasl/Makefile | 28 +- source/common/adfile.c | 8 +- source/common/adisasm.c | 26 +- source/common/adwalk.c | 1 - source/common/ahids.c | 6 +- source/common/ahpredef.c | 2 + source/common/ahuuids.c | 132 + source/common/dmextern.c | 31 +- source/common/dmrestag.c | 1 - source/common/dmtable.c | 81 +- source/common/dmtbdump.c | 176 +- source/common/dmtbinfo.c | 194 +- source/compiler/aslanalyze.c | 49 +- source/compiler/aslascii.c | 349 +++ source/compiler/aslbtypes.c | 1 - source/compiler/aslcodegen.c | 1 - source/compiler/aslcompile.c | 743 ++---- source/compiler/aslcompiler.h | 34 +- source/compiler/aslcompiler.l | 16 +- source/compiler/aslcompiler.y | 3587 -------------------------- source/compiler/asldefine.h | 7 +- source/compiler/aslerror.c | 8 +- source/compiler/aslfileio.c | 2 + source/compiler/aslfiles.c | 9 +- source/compiler/aslfold.c | 1 - source/compiler/aslglobal.h | 35 +- source/compiler/aslhex.c | 1 - source/compiler/asllength.c | 1 - source/compiler/aslload.c | 1 + source/compiler/asllookup.c | 1 - source/compiler/aslmain.c | 13 +- source/compiler/aslmessages.c | 3 + source/compiler/aslmessages.h | 3 + source/compiler/aslmethod.c | 47 +- source/compiler/aslnamesp.c | 1 - source/compiler/aslopcodes.c | 13 +- source/compiler/asloperands.c | 7 +- source/compiler/aslopt.c | 3 +- source/compiler/aslparser.y | 129 + source/compiler/aslprepkg.c | 35 + source/compiler/aslresource.c | 34 +- source/compiler/aslrestype1.c | 1 - source/compiler/aslrestype1i.c | 1 - source/compiler/aslrestype2.c | 1 - source/compiler/aslrestype2d.c | 1 - source/compiler/aslrestype2e.c | 1 - source/compiler/aslrestype2q.c | 1 - source/compiler/aslrestype2s.c | 1 - source/compiler/aslrestype2w.c | 1 - source/compiler/aslrules.y | 2763 ++++++++++++++++++++ source/compiler/aslstartup.c | 16 +- source/compiler/aslsupport.l | 18 +- source/compiler/aslsupport.y | 119 + source/compiler/asltokens.y | 386 +++ source/compiler/asltransform.c | 2 - source/compiler/asltree.c | 25 +- source/compiler/asltypes.h | 11 +- source/compiler/asltypes.y | 381 +++ source/compiler/aslutils.c | 105 +- source/compiler/asluuid.c | 74 +- source/compiler/aslwalks.c | 1 - source/compiler/aslxref.c | 193 +- source/compiler/dtcompile.c | 12 +- source/compiler/dtcompiler.h | 30 +- source/compiler/dtfield.c | 2 +- source/compiler/dtio.c | 14 +- source/compiler/dtsubtable.c | 4 +- source/compiler/dttable.c | 162 +- source/compiler/dttemplate.c | 7 +- source/compiler/dttemplate.h | 140 +- source/compiler/dtutils.c | 148 +- source/compiler/prutils.c | 9 +- source/components/debugger/dbcmds.c | 1 - source/components/debugger/dbconvert.c | 1 - source/components/debugger/dbdisply.c | 1 - source/components/debugger/dbexec.c | 1 - source/components/debugger/dbfileio.c | 1 - source/components/debugger/dbhistry.c | 1 - source/components/debugger/dbinput.c | 1 - source/components/debugger/dbmethod.c | 1 - source/components/debugger/dbnames.c | 1 - source/components/debugger/dbstats.c | 1 - source/components/debugger/dbutils.c | 1 - source/components/debugger/dbxface.c | 1 - source/components/disassembler/dmbuffer.c | 143 +- source/components/disassembler/dmdeferred.c | 1 - source/components/disassembler/dmnames.c | 1 - source/components/disassembler/dmobject.c | 1 - source/components/disassembler/dmopcode.c | 7 +- source/components/disassembler/dmresrc.c | 1 - source/components/disassembler/dmresrcl.c | 1 - source/components/disassembler/dmresrcl2.c | 3 +- source/components/disassembler/dmresrcs.c | 1 - source/components/disassembler/dmutils.c | 1 - source/components/disassembler/dmwalk.c | 4 +- source/components/dispatcher/dswstate.c | 1 - source/components/events/evgpe.c | 34 +- source/components/events/evgpeinit.c | 1 - source/components/events/evhandler.c | 1 - source/components/events/evregion.c | 1 - source/components/events/evrgnini.c | 1 - source/components/events/evxface.c | 1 - source/components/events/evxfevnt.c | 1 - source/components/events/evxfgpe.c | 72 +- source/components/executer/exconvrt.c | 1 - source/components/executer/exdebug.c | 11 +- source/components/executer/exdump.c | 6 +- source/components/executer/exfield.c | 31 +- source/components/executer/exfldio.c | 1 - source/components/executer/exoparg2.c | 1 - source/components/executer/exregion.c | 1 - source/components/namespace/nsalloc.c | 1 - source/components/namespace/nsinit.c | 1 - source/components/namespace/nsobject.c | 20 +- source/components/namespace/nsprepkg.c | 40 + source/components/namespace/nswalk.c | 1 - source/components/namespace/nsxfeval.c | 1 - source/components/namespace/nsxfobj.c | 1 - source/components/parser/psloop.c | 1 - source/components/parser/psobject.c | 1 - source/components/parser/psopcode.c | 1 - source/components/parser/psopinfo.c | 1 - source/components/parser/psparse.c | 1 - source/components/parser/psscope.c | 1 - source/components/parser/pstree.c | 1 - source/components/parser/psutils.c | 1 - source/components/parser/pswalk.c | 1 - source/components/resources/rsdump.c | 1 - source/components/resources/rsdumpinfo.c | 1 - source/components/resources/rsutils.c | 1 - source/components/resources/rsxface.c | 1 - source/components/utilities/utclib.c | 1 - source/components/utilities/utdecode.c | 37 +- source/components/utilities/utexcep.c | 1 - source/components/utilities/utfileio.c | 4 +- source/components/utilities/uthex.c | 113 + source/components/utilities/utinit.c | 1 - source/components/utilities/utmath.c | 1 - source/components/utilities/utmisc.c | 1 - source/components/utilities/utmutex.c | 1 - source/components/utilities/utownerid.c | 1 - source/components/utilities/utprint.c | 65 +- source/components/utilities/utresrc.c | 5 +- source/components/utilities/utstate.c | 1 - source/components/utilities/utstring.c | 1 - source/components/utilities/utuuid.c | 103 + source/components/utilities/utxface.c | 1 - source/components/utilities/utxfinit.c | 1 - source/include/acconfig.h | 19 + source/include/acdisasm.h | 19 + source/include/acdispat.h | 1 - source/include/aclocal.h | 20 +- source/include/acnames.h | 5 + source/include/acparser.h | 1 - source/include/acpixf.h | 8 +- source/include/acpredef.h | 15 +- source/include/actbl.h | 12 +- source/include/actbl1.h | 97 +- source/include/actbl2.h | 26 +- source/include/actbl3.h | 138 +- source/include/actypes.h | 5 +- source/include/acutils.h | 16 + source/include/platform/achaiku.h | 3 +- source/include/platform/aclinux.h | 18 +- source/include/platform/aclinuxex.h | 32 +- source/include/platform/acmsvc.h | 27 +- source/os_specific/service_layers/osefixf.c | 218 -- source/os_specific/service_layers/oslibcfs.c | 34 +- source/os_specific/service_layers/osunixxf.c | 9 +- source/os_specific/service_layers/oswintbl.c | 4 +- source/os_specific/service_layers/oswinxf.c | 2 - source/tools/acpibin/abmain.c | 1 - source/tools/acpidump/acpidump.h | 1 - source/tools/acpiexec/aehandlers.c | 6 +- source/tools/acpiexec/aemain.c | 2 + source/tools/acpihelp/acpihelp.h | 6 + source/tools/acpihelp/ahdecode.c | 28 + source/tools/acpihelp/ahmain.c | 13 +- source/tools/acpisrc/acpisrc.h | 13 + source/tools/acpisrc/asconvrt.c | 618 +++-- source/tools/acpisrc/asmain.c | 5 +- source/tools/acpisrc/astable.c | 20 +- source/tools/acpisrc/asutils.c | 4 +- 189 files changed, 7623 insertions(+), 5200 deletions(-) create mode 100644 source/common/ahuuids.c create mode 100644 source/compiler/aslascii.c delete mode 100644 source/compiler/aslcompiler.y create mode 100644 source/compiler/aslparser.y create mode 100644 source/compiler/aslrules.y create mode 100644 source/compiler/aslsupport.y create mode 100644 source/compiler/asltokens.y create mode 100644 source/compiler/asltypes.y create mode 100644 source/components/utilities/uthex.c create mode 100644 source/components/utilities/utuuid.c diff --git a/changes.txt b/changes.txt index 3acf4fd281ac..89d262821bcb 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,158 @@ +---------------------------------------- +28 August 2014. Summary of changes for version 20140828: + +1) ACPICA kernel-resident subsystem: + +Fixed a problem related to the internal use of the Timer() operator where +a 64-bit divide could cause an attempted link to a double-precision math +library. This divide is not actually necessary, so the code was +restructured to eliminate it. Lv Zheng. + +ACPI 5.1: Added support for the runtime validation of the _DSD package +(similar to the iASL support). + +ACPI 5.1/Headers: Added support for the GICC affinity subtable to the +SRAT table. Hanjun Guo . + +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. + + Current Release: + Non-Debug Version: 98.8K Code, 27.3K Data, 126.1K Total + Debug Version: 192.1K Code, 79.8K Data, 271.9K Total + Previous Release: + Non-Debug Version: 98.7K Code, 27.3K Data, 126.0K Total1 + Debug Version: 192.0K Code, 79.7K Data, 271.7K Total + +2) iASL Compiler/Disassembler and Tools: + +AcpiExec: Fixed a problem on unix systems where the original terminal +state was not always properly restored upon exit. Seen when using the -v +option. ACPICA BZ 1104. + +iASL: Fixed a problem with the validation of the ranges/length within the +Memory24 resource descriptor. There was a boundary condition when the +range was equal to the (length -1) caused by the fact that these values +are defined in 256-byte blocks, not bytes. ACPICA BZ 1098 + +Disassembler: Fixed a problem with the GpioInt descriptor interrupt polarity +flags. The flags are actually 2 bits, not 1, and the "ActiveBoth" keyword is +now supported properly. + +ACPI 5.1: Added the GICC affinity subtable to the SRAT table. Supported +in the disassembler, data table compiler, and table template generator. + +iASL: Added a requirement for Device() objects that one of either a _HID +or _ADR must exist within the scope of a Device, as per the ACPI +specification. Remove a similar requirement that was incorrectly in place +for the _DSD object. + +iASL: Added error detection for illegal named references within control +methods that would cause runtime failures. Now trapped as errors are: 1) +References to objects within a non-parent control method. 2) Forward +references (within a method) -- for control methods, AML interpreters use +a one-pass parse of control methods. ACPICA BZ 1008. + +iASL: Added error checking for dependencies related to the _PSx power +methods. ACPICA BZ 1029. +1) For _PS0, one of these must exist within the same scope: _PS1, _PS2, +_PS3. +2) For _PS1, _PS2, and PS3: A _PS0 object must exist within the same +scope. + +iASL and table compiler: Cleanup miscellaneous memory leaks by fully +deploying the existing object and string caches and adding new caches for +the table compiler. + +iASL: Split the huge parser source file into multiple subfiles to improve +manageability. Generation now requires the M4 macro preprocessor, which +is part of the Bison distribution on both unix and windows platforms. + +AcpiSrc: Fixed and removed all extraneous warnings generated during +entire ACPICA source code scan and/or conversion. + + +---------------------------------------- + +24 July 2014. Summary of changes for version 20140724: + +The ACPI 5.1 specification has been released and is available at: +http://uefi.org/specs/access + + +0) ACPI 5.1 support in ACPICA: + +ACPI 5.1 is fully supported in ACPICA as of this release. + +New predefined names. Support includes iASL and runtime ACPICA +validation. + _CCA (Cache Coherency Attribute). + _DSD (Device-Specific Data). David Box. + +Modifications to existing ACPI tables. Support includes headers, iASL +Data Table compiler, disassembler, and the template generator. + FADT - New fields and flags. Graeme Gregory. + GTDT - One new subtable and new fields. Tomasz Nowicki. + MADT - Two new subtables. Tomasz Nowicki. + PCCT - One new subtable. + +Miscellaneous. + New notification type for System Resource Affinity change events. + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression introduced in 20140627 where a fault can happen during +the deletion of Alias AML namespace objects. The problem affected both +the core ACPICA and the ACPICA tools including iASL and AcpiExec. + +Implemented a new GPE public interface, AcpiMarkGpeForWake. Provides a +simple mechanism to enable wake GPEs that have no associated handler or +control method. Rafael Wysocki. + +Updated the AcpiEnableGpe interface to disallow the enable if there is no +handler or control method associated with the particular GPE. This will +help avoid meaningless GPEs and even GPE floods. Rafael Wysocki. + +Updated GPE handling and dispatch by disabling the GPE before clearing +the status bit for edge-triggered GPEs. Lv Zheng. + +Added Timer() support to the AML Debug object. The current timer value is +now displayed with each invocation of (Store to) the debug object to +enable simple generation of execution times for AML code (method +execution for example.) ACPICA BZ 1093. + +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. + + Current Release: + Non-Debug Version: 98.7K Code, 27.3K Data, 126.0K Total + Debug Version: 192.0K Code, 79.7K Data, 271.7K Total + Previous Release: + Non-Debug Version: 98.7K Code, 27.2K Data, 125.9K Total + Debug Version: 191.7K Code, 79.6K Data, 271.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed an issue with the recently added local printf implementation, +concerning width/precision specifiers that could cause incorrect output. +Lv Zheng. ACPICA BZ 1094. + +Disassembler: Added support to detect buffers that contain UUIDs and +disassemble them to an invocation of the ToUUID operator. Also emit +commented descriptions of known ACPI-related UUIDs. + +AcpiHelp: Added support to display known ACPI-related UUIDs. New option, +-u. Adds three new files. + +iASL: Update table compiler and disassembler for DMAR table changes that +were introduced in September 2013. With assistance by David Woodhouse. + ---------------------------------------- 27 June 2014. Summary of changes for version 20140627: diff --git a/generate/unix/Makefile.config b/generate/unix/Makefile.config index 8d41399cdfb0..dd7fd756149e 100644 --- a/generate/unix/Makefile.config +++ b/generate/unix/Makefile.config @@ -206,6 +206,8 @@ endif # -Wconversion\ # -Wshadow\ +# +# M4 macro processor is used to build the final parser file # # Bison/Flex configuration # @@ -226,6 +228,9 @@ endif YACC= bison YFLAGS += -y +MACROPROC= m4 +MFLAGS= -P -I$(ASL_COMPILER) + LEX= flex LFLAGS += -i -s diff --git a/generate/unix/acpiexamples/Makefile b/generate/unix/acpiexamples/Makefile index 8bcdb9ba0a98..458314371003 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -138,6 +138,7 @@ OBJECTS = \ $(OBJDIR)/uteval.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utids.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 6c5c63222bf7..8d7facf70167 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -45,6 +45,7 @@ OBJECTS = \ $(OBJDIR)/aemain.o\ $(OBJDIR)/aetables.o\ $(OBJDIR)/ahids.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/dbcmds.o\ $(OBJDIR)/dbconvert.o\ @@ -204,6 +205,7 @@ OBJECTS = \ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utids.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ @@ -219,6 +221,7 @@ OBJECTS = \ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/uttrack.o\ + $(OBJDIR)/utuuid.o\ $(OBJDIR)/utxface.o\ $(OBJDIR)/utxferror.o\ $(OBJDIR)/utxfinit.o\ diff --git a/generate/unix/acpihelp/Makefile b/generate/unix/acpihelp/Makefile index 25c8c0a3c404..ed4ee8a816c8 100644 --- a/generate/unix/acpihelp/Makefile +++ b/generate/unix/acpihelp/Makefile @@ -35,15 +35,18 @@ OBJECTS = \ $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ $(OBJDIR)/ahmain.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/getopt.o\ $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utpredef.o\ - $(OBJDIR)/utprint.o + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utuuid.o # # Flags specific to acpihelp diff --git a/generate/unix/acpinames/Makefile b/generate/unix/acpinames/Makefile index 27c7b9579ff0..743c6c5da4ac 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -103,6 +103,7 @@ OBJECTS = \ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utids.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index 7fd7bbe2a267..f4b6ef39d1bd 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -48,7 +48,9 @@ OBJECTS = \ $(OBJDIR)/adwalk.o\ $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/aslanalyze.o\ + $(OBJDIR)/aslascii.o\ $(OBJDIR)/aslbtypes.o\ $(OBJDIR)/aslcodegen.o\ $(OBJDIR)/aslcompile.o\ @@ -193,6 +195,7 @@ OBJECTS = \ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ $(OBJDIR)/utmath.o\ @@ -205,10 +208,12 @@ OBJECTS = \ $(OBJDIR)/utresrc.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ + $(OBJDIR)/utuuid.o\ $(OBJDIR)/utxface.o\ $(OBJDIR)/utxferror.o INTERMEDIATES = \ + $(OBJDIR)/aslcompiler.y\ $(OBJDIR)/aslcompilerlex.c\ $(OBJDIR)/aslcompilerparse.c\ $(OBJDIR)/dtparserlex.c\ @@ -221,6 +226,18 @@ MISC = \ $(OBJDIR)/dtparser.y.h\ $(OBJDIR)/prparser.y.h +ASL_PARSER = \ + $(ASL_COMPILER)/aslparser.y\ + $(ASL_COMPILER)/asltokens.y\ + $(ASL_COMPILER)/asltypes.y\ + $(ASL_COMPILER)/aslrules.y + +ASL_LEXER = \ + $(ASL_COMPILER)/aslcompiler.l\ + $(ASL_COMPILER)/aslsupport.l\ + $(OBJDIR)/aslcompiler.y.h + + # # Flags specific to iASL compiler # @@ -234,17 +251,22 @@ CFLAGS += \ # include ../Makefile.rules +# +# Macro processing for iASL .y files +# +$(OBJDIR)/aslcompiler.y : $(ASL_PARSER) + $(MACROPROC) $(MFLAGS) $(ASL_COMPILER)/aslparser.y > $(OBJDIR)/aslcompiler.y # # Parser and Lexer - intermediate C files # -$(OBJDIR)/aslcompilerlex.c : $(ASL_COMPILER)/aslcompiler.l $(ASL_COMPILER)/aslsupport.l $(OBJDIR)/aslcompiler.y.h +$(OBJDIR)/aslcompilerlex.c : $(ASL_LEXER) $(LEX) $(LFLAGS) -PAslCompiler -o$@ $(ASL_COMPILER)/aslcompiler.l -$(OBJDIR)/aslcompiler.y.h : $(ASL_COMPILER)/aslcompiler.y +$(OBJDIR)/aslcompiler.y.h : $(OBJDIR)/aslcompiler.y $(YACC) $(YFLAGS) -pAslCompiler -o/dev/null --defines=$@ $< -$(OBJDIR)/aslcompilerparse.c : $(ASL_COMPILER)/aslcompiler.y +$(OBJDIR)/aslcompilerparse.c : $(OBJDIR)/aslcompiler.y $(YACC) $(YFLAGS) -pAslCompiler -o$@ --defines=/dev/null $< $(OBJDIR)/dtparserlex.c : $(ASL_COMPILER)/dtparser.l $(OBJDIR)/dtparser.y.h diff --git a/source/common/adfile.c b/source/common/adfile.c index 0b70d69e226c..41c27eebbbf3 100644 --- a/source/common/adfile.c +++ b/source/common/adfile.c @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ - +#include "aslcompiler.h" #include "acpi.h" #include "accommon.h" #include "acapps.h" @@ -206,7 +206,7 @@ FlGenerateFilename ( * Copy the original filename to a new buffer. Leave room for the worst * case where we append the suffix, an added dot and the null terminator. */ - NewFilename = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + NewFilename = UtStringCacheCalloc ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); if (!NewFilename) { @@ -255,7 +255,7 @@ FlStrdup ( char *NewString; - NewString = ACPI_ALLOCATE ((ACPI_SIZE) strlen (String) + 1); + NewString = UtStringCacheCalloc ((ACPI_SIZE) strlen (String) + 1); if (!NewString) { return (NULL); @@ -337,7 +337,6 @@ FlSplitInputPathname ( if (!Filename) { - ACPI_FREE (DirectoryPath); return (AE_NO_MEMORY); } @@ -349,6 +348,5 @@ FlSplitInputPathname ( return (AE_OK); } - ACPI_FREE (Filename); return (AE_OK); } diff --git a/source/common/adisasm.c b/source/common/adisasm.c index 292b4720da98..8deaee7e0717 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -41,12 +41,9 @@ * POSSIBILITY OF SUCH DAMAGES. */ - -#include "acpi.h" -#include "accommon.h" +#include "aslcompiler.h" #include "acparser.h" #include "amlcode.h" -#include "acdebug.h" #include "acdisasm.h" #include "acdispat.h" #include "acnamesp.h" @@ -60,23 +57,6 @@ #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("adisasm") -/* - * Older versions of Bison won't emit this external in the generated header. - * Newer versions do emit the external, so we don't need to do it. - */ -#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H -extern int AslCompilerdebug; -#endif - -ACPI_STATUS -NsDisplayNamespace ( - void); - -void -NsSetupNamespaceListing ( - void *Handle); - - /* Local prototypes */ static void @@ -654,7 +634,7 @@ AdCreateTableHeader ( } else { - NewFilename = ACPI_ALLOCATE_ZEROED (9); + NewFilename = UtStringCacheCalloc (9); if (NewFilename) { strncat (NewFilename, Table->Signature, 4); @@ -674,8 +654,6 @@ AdCreateTableHeader ( "DefinitionBlock (\"%s\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", NewFilename, Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); - - ACPI_FREE (NewFilename); } diff --git a/source/common/adwalk.c b/source/common/adwalk.c index d150f4dd31e6..81b5f4acc8f7 100644 --- a/source/common/adwalk.c +++ b/source/common/adwalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/common/ahids.c b/source/common/ahids.c index 851393b1c903..13cd1000ef1d 100644 --- a/source/common/ahids.c +++ b/source/common/ahids.c @@ -174,7 +174,11 @@ const AH_DEVICE_ID AslDeviceIds[] = {"PNP0C60", "Display Sensor Device"}, {"PNP0C70", "Dock Sensor Device"}, {"PNP0C80", "Memory Device"}, - {"PNP0D40", "Standard Compliant SD Host Controller"}, + {"PNP0D10", "XHCI USB Controller with debug"}, + {"PNP0D15", "XHCI USB Controller without debug"}, + {"PNP0D20", "EHCI USB Controller without debug"}, + {"PNP0D25", "EHCI USB Controller with debug"}, + {"PNP0D40", "SDA Standard Compliant SD Host Controller"}, {"PNP0D80", "Windows-compatible System Power Management Controller"}, {"PNP0F03", "Microsoft PS/2-style Mouse"}, {"SMO91D0", "Sensor Hub"}, diff --git a/source/common/ahpredef.c b/source/common/ahpredef.c index 33c8eab43021..893ea1cdd56c 100644 --- a/source/common/ahpredef.c +++ b/source/common/ahpredef.c @@ -97,6 +97,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_BTM", "Battery Time", "Returns the battery runtime"), AH_PREDEF ("_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"), AH_PREDEF ("_CBA", "Configuration Base Address", "Sets the base address for a PCI Express host bridge"), + AH_PREDEF ("_CCA", "Cache Coherency Attribute", "Returns a device's support level for cache coherency"), AH_PREDEF ("_CDM", "Clock Domain", "Returns a logical processor's clock domain identifier"), AH_PREDEF ("_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"), AH_PREDEF ("_CLS", "Class Code", "Returns PCI class code and subclass"), @@ -121,6 +122,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_DOS", "Disable Output Switching", "Sets the display output switching mode"), AH_PREDEF ("_DPL", "Device Selection Polarity", "Polarity of Device Selection signal, Resource Descriptor field"), AH_PREDEF ("_DRS", "Drive Strength", "Drive Strength setting for GPIO connection, Resource Descriptor field"), + AH_PREDEF ("_DSD", "Device-Specific Data", "Returns a list of device property information"), AH_PREDEF ("_DSM", "Device-Specific Method", "Executes device-specific functions"), AH_PREDEF ("_DSS", "Device Set State", "Sets the display device state"), AH_PREDEF ("_DSW", "Device Sleep Wake", "Sets the sleep and wake transition states for a device"), diff --git a/source/common/ahuuids.c b/source/common/ahuuids.c new file mode 100644 index 000000000000..e0b05faef07d --- /dev/null +++ b/source/common/ahuuids.c @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Module Name: ahuuids - Table of known ACPI-related UUIDs + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahuuids") + +/* + * Table of "known" (ACPI-related) UUIDs + */ +const AH_UUID AcpiUuids[] = +{ + {"PCI Host Bridge Device", + "33db4d5b-1ff7-401c-9657-7441c03dd766"}, + + {"Platform-wide Capabilities", + "0811b06e-4a27-44f9-8d60-3cbbc22e7b48"}, + + {"Dynamic Enumeration", + "d8c1a3a6-be9b-4c9b-91bf-c3cb81fc5daf"}, + + {"GPIO Controller", + "4f248f40-d5e2-499f-834c-27758ea1cd3f"}, + + {"Battery Thermal Limit", + "4c2067e3-887d-475c-9720-4af1d3ed602e"}, + + {"Thermal Extensions", + "14d399cd-7a27-4b18-8fb4-7cb7b9f4e500"}, + + {"USB Controller", + "ce2ee385-00e6-48cb-9f05-2edb927c4899"}, + + {"HID I2C Device", + "3cdff6f7-4267-4555-ad05-b30a3d8938de"}, + + {"Power Button Device", + "dfbcf3c5-e7a5-44e6-9c1f-29c76f6e059c"}, + + {"Device Labeling Interface", + "e5c937d0-3553-4d7a-9117-ea4d19c3434d"}, + + {"SATA Controller", + "e4db149b-fcfe-425b-a6d8-92357d78fc7f"}, + + {"Physical Presence Interface", + "3dddfaa6-361b-4eb4-a424-8d10089d1653"}, + + {"Device Properties for _DSD", + "daffd814-6eba-4d8c-8a91-bc9bbf4aa301"}, + + {NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchUuid + * + * PARAMETERS: Data - Data buffer containing a UUID + * + * RETURN: ASCII description string for the UUID if it is found. + * + * DESCRIPTION: Returns a description string for "known" UUIDs, which are + * are UUIDs that are related to ACPI in some way. + * + ******************************************************************************/ + +const char * +AcpiAhMatchUuid ( + UINT8 *Data) +{ + const AH_UUID *Info; + UINT8 UuidBuffer[UUID_BUFFER_LENGTH]; + + + /* Walk the table of known ACPI-related UUIDs */ + + for (Info = AcpiUuids; Info->Description; Info++) + { + AcpiUtConvertStringToUuid (Info->String, UuidBuffer); + + if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH)) + { + return (Info->Description); + } + } + + return (NULL); +} diff --git a/source/common/dmextern.c b/source/common/dmextern.c index 728207cef330..37c3a656a25e 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -406,18 +406,37 @@ AcpiDmGetExternalsFromFile ( while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ExternalRefFile)) { Token = strtok (StringBuffer, METHOD_SEPARATORS); /* "External" */ - if (!Token) continue; - if (strcmp (Token, "External")) continue; + if (!Token) + { + continue; + } + if (strcmp (Token, "External")) + { + continue; + } MethodName = strtok (NULL, METHOD_SEPARATORS); /* Method namepath */ - if (!MethodName) continue; + if (!MethodName) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* "MethodObj" */ - if (!Token) continue; - if (strcmp (Token, "MethodObj")) continue; + if (!Token) + { + continue; + } + + if (strcmp (Token, "MethodObj")) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* Arg count */ - if (!Token) continue; + if (!Token) + { + continue; + } /* Convert arg count string to an integer */ diff --git a/source/common/dmrestag.c b/source/common/dmrestag.c index 398691b39f2a..5589d1f4a8e6 100644 --- a/source/common/dmrestag.c +++ b/source/common/dmrestag.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/common/dmtable.c b/source/common/dmtable.c index 384f7955e867..fc8cbc29f6bc 100644 --- a/source/common/dmtable.c +++ b/source/common/dmtable.c @@ -87,9 +87,21 @@ static const char *AcpiDmDmarSubnames[] = "Reserved Memory Region", "Root Port ATS Capability", "Remapping Hardware Static Affinity", + "ACPI Namespace Device Declaration", "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmDmarScope[] = +{ + "Reserved value", + "PCI Endpoint Device", + "PCI Bridge Device", + "IOAPIC Device", + "Message-capable HPET Device", + "Namespace Device", + "Unknown Scope Type" /* Reserved */ +}; + static const char *AcpiDmEinjActions[] = { "Begin Operation", @@ -160,6 +172,13 @@ static const char *AcpiDmErstInstructions[] = "Unknown Instruction" }; +static const char *AcpiDmGtdtSubnames[] = +{ + "Generic Timer Block", + "Generic Watchdog Timer", + "Unknown SubTable Type" /* Reserved */ +}; + static const char *AcpiDmHestSubnames[] = { "IA-32 Machine Check Exception", @@ -189,25 +208,28 @@ static const char *AcpiDmHestNotifySubnames[] = static const char *AcpiDmMadtSubnames[] = { - "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ - "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ - "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ - "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ - "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ - "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ - "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ - "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ - "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ - "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ - "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ - "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ - "Generic Interrupt Distributor",/* ACPI_MADT_GENERIC_DISTRIBUTOR */ - "Unknown SubTable Type" /* Reserved */ + "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ + "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ + "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ + "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ + "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ + "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ + "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ + "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ + "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ + "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ + "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ + "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ + "Generic Interrupt Distributor", /* ACPI_MADT_GENERIC_DISTRIBUTOR */ + "Generic MSI Frame", /* ACPI_MADT_GENERIC_MSI_FRAME */ + "Generic Interrupt Redistributor", /* ACPI_MADT_GENERIC_REDISTRIBUTOR */ + "Unknown SubTable Type" /* Reserved */ }; static const char *AcpiDmPcctSubnames[] = { "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */ + "HW-Reduced Communications Subspace", "Unknown SubTable Type" /* Reserved */ }; @@ -231,6 +253,7 @@ static const char *AcpiDmSratSubnames[] = "Processor Local APIC/SAPIC Affinity", "Memory Affinity", "Processor Local x2APIC Affinity", + "GICC Affinity", "Unknown SubTable Type" /* Reserved */ }; @@ -306,7 +329,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"}, {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table (FADT)"}, {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt, "Firmware Performance Data Table"}, - {ACPI_SIG_GTDT, AcpiDmTableInfoGtdt, NULL, NULL, TemplateGtdt, "Generic Timer Description Table"}, + {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt, "Generic Timer Description Table"}, {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"}, {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"}, {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"}, @@ -705,6 +728,7 @@ AcpiDmDumpTable ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: @@ -716,6 +740,7 @@ AcpiDmDumpTable ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -1047,6 +1072,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); break; + case ACPI_DMT_DMAR_SCOPE: + + /* DMAR device scope types */ + + Temp8 = *Target; + if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED) + { + Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmDmarScope[Temp8]); + break; + case ACPI_DMT_EINJACT: /* EINJ Action types */ @@ -1099,6 +1137,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmErstInstructions[Temp8]); break; + case ACPI_DMT_GTDT: + + /* GTDT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_GTDT_TYPE_RESERVED) + { + Temp8 = ACPI_GTDT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGtdtSubnames[Temp8]); + break; + case ACPI_DMT_HEST: /* HEST subtable types */ diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index 8d52ce36e8de..ac4600147335 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -891,18 +891,24 @@ AcpiDmDumpDmar ( ScopeOffset = sizeof (ACPI_DMAR_RESERVED_MEMORY); break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; ScopeOffset = sizeof (ACPI_DMAR_ATSR); break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; ScopeOffset = sizeof (ACPI_DMAR_RHSA); break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + ScopeOffset = sizeof (ACPI_DMAR_ANDD); + break; + default: AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", SubTable->Type); @@ -916,7 +922,16 @@ AcpiDmDumpDmar ( return; } - /* Dump the device scope entries (if any) */ + /* + * Dump the optional device scope entries + */ + if ((SubTable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (SubTable->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + goto NextSubtable; + } ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, SubTable, ScopeOffset); while (ScopeOffset < SubTable->Length) @@ -956,6 +971,7 @@ AcpiDmDumpDmar ( ScopeTable, ScopeTable->Length); } +NextSubtable: /* Point to next subtable */ Offset += SubTable->Length; @@ -1153,6 +1169,123 @@ NextSubTable: } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpGtdt + * + * PARAMETERS: Table - A GTDT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a GTDT. This table type consists + * of an open-ended number of subtables. + * + ******************************************************************************/ + +void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_GTDT_HEADER *SubTable; + UINT32 Length = Table->Length; + UINT32 Offset = sizeof (ACPI_TABLE_GTDT); + ACPI_DMTABLE_INFO *InfoTable; + UINT32 SubTableLength; + UINT32 GtCount; + ACPI_GTDT_TIMER_ENTRY *GtxTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Subtables */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common subtable header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoGtdtHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + GtCount = 0; + switch (SubTable->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + SubTableLength = sizeof (ACPI_GTDT_TIMER_BLOCK); + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + SubTable))->TimerCount; + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + SubTableLength = sizeof (ACPI_GTDT_WATCHDOG); + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + /* Cannot continue on unknown type - no length */ + + AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n", SubTable->Type); + return; + } + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to end of current subtable (each subtable above is of fixed length) */ + + Offset += SubTableLength; + + /* If there are any Gt Timer Blocks from above, dump them now */ + + if (GtCount) + { + GtxTable = ACPI_ADD_PTR (ACPI_GTDT_TIMER_ENTRY, SubTable, SubTableLength); + SubTableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY); + + while (GtCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, GtxTable, + sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a); + if (ACPI_FAILURE (Status)) + { + return; + } + Offset += sizeof (ACPI_GTDT_TIMER_ENTRY); + GtxTable++; + GtCount--; + } + } + + /* Point to next subtable */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, SubTable, SubTableLength); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpHest @@ -1662,6 +1795,16 @@ AcpiDmDumpMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", SubTable->Type); @@ -2017,6 +2160,7 @@ AcpiDmDumpPcct ( { ACPI_STATUS Status; ACPI_PCCT_SUBSPACE *SubTable; + ACPI_DMTABLE_INFO *InfoTable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_PCCT); @@ -2044,10 +2188,20 @@ AcpiDmDumpPcct ( return; } - /* ACPI 5.0: Only one type of PCCT subtable is supported */ - - if (SubTable->Header.Type != ACPI_PCCT_TYPE_GENERIC_SUBSPACE) + switch (SubTable->Header.Type) { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + default: + AcpiOsPrintf ( "\n**** Unexpected or unknown PCCT subtable type 0x%X\n\n", SubTable->Header.Type); @@ -2056,7 +2210,7 @@ AcpiDmDumpPcct ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoPcct0); + SubTable->Header.Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -2210,8 +2364,7 @@ AcpiDmDumpPmtt ( if (DomainCount) { AcpiOsPrintf ( - "\n**** DomainCount exceeds subtable length\n\n", - MemSubTable->Type); + "\n**** DomainCount exceeds subtable length\n\n"); } /* Walk the physical component (DIMM) subtables */ @@ -2586,6 +2739,11 @@ AcpiDmDumpSrat ( InfoTable = AcpiDmTableInfoSrat2; break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + default: AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n", SubTable->Type); diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index 577dca731c68..c7a247ecaa82 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -137,11 +137,16 @@ #define ACPI_DMAR1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RESERVED_MEMORY,f) #define ACPI_DMAR2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ATSR,f) #define ACPI_DMAR3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RHSA,f) +#define ACPI_DMAR4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ANDD,f) #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) #define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT,f) #define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_PTR,f) +#define ACPI_GTDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_BLOCK,f) +#define ACPI_GTDT0a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_ENTRY,f) +#define ACPI_GTDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_WATCHDOG,f) +#define ACPI_GTDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_HEADER,f) #define ACPI_HEST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f) #define ACPI_HEST1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_CORRECTED,f) #define ACPI_HEST2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_NMI,f) @@ -174,6 +179,8 @@ #define ACPI_MADT10_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f) #define ACPI_MADT11_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f) #define ACPI_MADT12_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_DISTRIBUTOR,f) +#define ACPI_MADT13_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f) +#define ACPI_MADT14_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_REDISTRIBUTOR,f) #define ACPI_MADTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_MCFG0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f) #define ACPI_MPST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MPST_POWER_NODE,f) @@ -184,6 +191,7 @@ #define ACPI_MSCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f) #define ACPI_MTMR0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MTMR_ENTRY,f) #define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f) +#define ACPI_PCCT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f) #define ACPI_PMTT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_SOCKET,f) #define ACPI_PMTT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_CONTROLLER,f) #define ACPI_PMTT1A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_DOMAIN,f) @@ -199,6 +207,7 @@ #define ACPI_SRAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_CPU_AFFINITY,f) #define ACPI_SRAT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_MEM_AFFINITY,f) #define ACPI_SRAT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f) +#define ACPI_SRAT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_GICC_AFFINITY,f) #define ACPI_VRTC0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_VRTC_ENTRY,f) #define ACPI_WDAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WDAT_ENTRY,f) @@ -215,7 +224,10 @@ #define ACPI_SRAT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_CPU_AFFINITY,f,o) #define ACPI_SRAT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_MEM_AFFINITY,f,o) #define ACPI_SRAT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f,o) +#define ACPI_SRAT3_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_GICC_AFFINITY,f,o) #define ACPI_GTDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_GTDT,f,o) +#define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o) +#define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o) #define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o) #define ACPI_MADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_MADT,f,o) #define ACPI_MADT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC,f,o) @@ -227,9 +239,11 @@ #define ACPI_MADT9_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC,f,o) #define ACPI_MADT10_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f,o) #define ACPI_MADT11_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f,o) +#define ACPI_MADT13_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f,o) #define ACPI_MPST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_NODE,f,o) #define ACPI_MPST2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_DATA,f,o) #define ACPI_PCCT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o) +#define ACPI_PCCT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o) #define ACPI_PMTTH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PMTT_HEADER,f,o) #define ACPI_WDDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_WDDT,f,o) #define ACPI_EINJ0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) @@ -440,17 +454,22 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0}, ACPI_DMT_TERMINATOR }; -/* ACPI 2.0+ Extensions (FADT version 3 and 4) */ +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "ARM Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "PSCI Compliant", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "Must use HVC for PSCI", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "FADT Minor Revision", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address", 0}, {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block", 0}, @@ -807,7 +826,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[] = { - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EntryType), "Device Scope Entry Type", 0}, + {ACPI_DMT_DMAR_SCOPE, ACPI_DMARS_OFFSET (EntryType), "Device Scope Type", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Length), "Entry Length", DT_LENGTH}, {ACPI_DMT_UINT16, ACPI_DMARS_OFFSET (Reserved), "Reserved", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EnumerationId), "Enumeration ID", 0}, @@ -859,6 +878,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[] = ACPI_DMT_TERMINATOR }; +/* 4: ACPI Namespace Device Declaration Structure */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[] = +{ + {ACPI_DMT_UINT24, ACPI_DMAR4_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR4_OFFSET (DeviceNumber), "Device Number", 0}, + {ACPI_DMT_STRING, ACPI_DMAR4_OFFSET (DeviceName[0]), "Device Name", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -998,29 +1027,89 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[] = ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[] = { - {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (Address), "Timer Address", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (Flags,0), "Memory Present", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterBlockAddresss), "Counter Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Interrupt), "Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Flags), "SPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Interrupt), "Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Flags), "EL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Always On", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Interrupt), "Non-Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Flags), "NSPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Interrupt), "Non-Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Flags), "NEL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Always On", 0}, ACPI_DMT_NEW_LINE, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerFlags), "VT Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Trigger Mode", 0}, {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Always On", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Interrupt), "Non-Secure PL2 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Flags), "NSPL2 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Interrupt), "Non-Secure EL2 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Flags), "NEL2 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Always On", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterReadBlockAddress), "Counter Read Block Address", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerCount), "Platform Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerOffset), "Platform Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[] = +{ + {ACPI_DMT_GTDT, ACPI_GTDTH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT16, ACPI_GTDTH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtables */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0_OFFSET (BlockAddress), "Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerCount), "Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerOffset), "Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[] = +{ + {ACPI_DMT_UINT8 , ACPI_GTDT0a_OFFSET (FrameNumber), "Frame Number", 0}, + {ACPI_DMT_UINT24, ACPI_GTDT0a_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (El0BaseAddress), "EL0 Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerFlags), "Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerFlags), "Virtual Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (CommonFlags), "Common Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Secure", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Always On", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (RefreshFrameAddress), "Refresh Frame Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (ControlFrameAddress), "Control Frame Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerFlags), "Timer Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Security", 0}, ACPI_DMT_TERMINATOR }; @@ -1527,14 +1616,21 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[] = { {ACPI_DMT_UINT16, ACPI_MADT11_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (GicId), "Local GIC Hardware ID", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (CpuInterfaceNumber), "CPU Interface Number", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Uid), "Processor UID", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Processor Enabled", 0}, + {ACPI_DMT_FLAG1, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Performance Interrupt Trigger Mode", 0}, + {ACPI_DMT_FLAG2, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Virtual GIC Interrupt Trigger Mode", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (ParkingVersion), "Parking Protocol Version", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (PerformanceInterrupt), "Performance Interrupt", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ParkedAddress), "Parked Address", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicvBaseAddress), "Virtual GIC Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GichBaseAddress), "Hypervisor GIC Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (VgicInterrupt), "Virtual GIC Interrupt", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicrBaseAddress), "Redistributor Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ArmMpidr), "ARM MPIDR", 0}, ACPI_DMT_TERMINATOR }; @@ -1550,6 +1646,30 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[] = ACPI_DMT_TERMINATOR }; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (MsiFrameId), "MSI Frame ID", 0}, + {ACPI_DMT_UINT64, ACPI_MADT13_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT13_FLAG_OFFSET (Flags,0), "Select SPI", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiCount), "SPI Count", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiBase), "SPI Base", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 14: Generic Redistributor (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT14_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_MADT14_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT14_OFFSET (Length), "Length", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -1769,6 +1889,26 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[] = ACPI_DMT_TERMINATOR }; +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[] = +{ + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (DoorbellInterrupt), "Doorbell Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Flags), "Flags (Decoded Below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG1, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Mode", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (Length), "Address Length", 0}, + {ACPI_DMT_GAS, ACPI_PCCT1_OFFSET (DoorbellRegister), "Doorbell Register", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (PreserveMask), "Preserve Mask", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT1_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -2048,7 +2188,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] = {ACPI_DMT_FLAG0, ACPI_SRAT0_FLAG_OFFSET (Flags,0), "Enabled", 0}, {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (LocalSapicEid), "Local Sapic EID", 0}, {ACPI_DMT_UINT24, ACPI_SRAT0_OFFSET (ProximityDomainHi[0]), "Proximity Domain High(24)", 0}, - {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (ClockDomain), "Clock Domain", 0}, ACPI_DMT_TERMINATOR }; @@ -2083,6 +2223,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] = ACPI_DMT_TERMINATOR }; +/* : GICC Affinity (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[] = +{ + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ProximityDomain), "Proximity Domain", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (AcpiProcessorUid), "Acpi Processor UID", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_SRAT3_FLAG_OFFSET (Flags,0), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ClockDomain), "Clock Domain", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index 112c1213986d..94282a081338 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include @@ -569,3 +568,51 @@ ApCheckRegMethod ( AslError (ASL_WARNING, ASL_MSG_NO_REGION, Op, NULL); } + + +/******************************************************************************* + * + * FUNCTION: ApFindNameInScope + * + * PARAMETERS: Name - Name to search for + * Op - Current parse op + * + * RETURN: TRUE if name found in the same scope as Op. + * + * DESCRIPTION: Determine if a name appears in the same scope as Op, as either + * a Method() or a Name(). + * + ******************************************************************************/ + +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + + + /* Get the start of the current scope */ + + Parent = Op->Asl.Parent; + Next = Parent->Asl.Child; + + /* Search entire scope for a match to the name */ + + while (Next) + { + if ((Next->Asl.ParseOpcode == PARSEOP_METHOD) || + (Next->Asl.ParseOpcode == PARSEOP_NAME)) + { + if (ACPI_COMPARE_NAME (Name, Next->Asl.NameSeg)) + { + return (TRUE); + } + } + + Next = Next->Asl.Next; + } + + return (FALSE); +} diff --git a/source/compiler/aslascii.c b/source/compiler/aslascii.c new file mode 100644 index 000000000000..3fdf1ac0e22e --- /dev/null +++ b/source/compiler/aslascii.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Module Name: aslascii - ASCII detection and support routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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 "aslcompiler.h" +#include + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslascii") + + +/* Local prototypes */ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAcpiTable + * + * PARAMETERS: Handle - Open input file + * + * RETURN: Status + * + * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the + * following checks on what would be the table header: + * 0) File must be at least as long as an ACPI_TABLE_HEADER + * 1) The header length field must match the file size + * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAcpiTable ( + FILE *Handle) +{ + ACPI_TABLE_HEADER Table; + UINT32 FileSize; + size_t Actual; + UINT32 i; + + + /* Read a potential table header */ + + Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); + fseek (Handle, 0, SEEK_SET); + + if (Actual < sizeof (ACPI_TABLE_HEADER)) + { + return (AE_ERROR); + } + + /* Header length field must match the file size */ + + FileSize = CmGetFileSize (Handle); + if (Table.Length != FileSize) + { + return (AE_ERROR); + } + + /* + * These fields must be ASCII: + * Signature, OemId, OemTableId, AslCompilerId. + * We allow a NULL terminator in OemId and OemTableId. + */ + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) + { + return (AE_ERROR); + } + + if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) + { + return (AE_ERROR); + } + } + + printf ("Binary file appears to be a valid ACPI table, disassembling\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAscii + * + * PARAMETERS: Handle - Open input file + * Filename - Input filename + * DisplayErrors - TRUE if error messages desired + * + * RETURN: Status + * + * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters + * within comments. Note: does not handle nested comments and does + * not handle comment delimiters within string literals. However, + * on the rare chance this happens and an invalid character is + * missed, the parser will catch the error by failing in some + * spectactular manner. + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAscii ( + FILE *Handle, + char *Filename, + BOOLEAN DisplayErrors) +{ + UINT8 Byte; + ACPI_SIZE BadBytes = 0; + BOOLEAN OpeningComment = FALSE; + ASL_FILE_STATUS Status; + + + Status.Line = 1; + Status.Offset = 0; + + /* Read the entire file */ + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Ignore comment fields (allow non-ascii within) */ + + if (OpeningComment) + { + /* Check for second comment open delimiter */ + + if (Byte == '*') + { + FlConsumeAnsiComment (Handle, &Status); + } + + if (Byte == '/') + { + FlConsumeNewComment (Handle, &Status); + } + + /* Reset */ + + OpeningComment = FALSE; + } + else if (Byte == '/') + { + OpeningComment = TRUE; + } + + /* Check for an ASCII character */ + + if (!ACPI_IS_ASCII (Byte)) + { + if ((BadBytes < 10) && (DisplayErrors)) + { + AcpiOsPrintf ( + "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", + Byte, Status.Line, Status.Offset); + } + + BadBytes++; + } + + /* Update line counter */ + + else if (Byte == 0x0A) + { + Status.Line++; + } + + Status.Offset++; + } + + /* Seek back to the beginning of the source file */ + + fseek (Handle, 0, SEEK_SET); + + /* Were there any non-ASCII characters in the file? */ + + if (BadBytes) + { + if (DisplayErrors) + { + AcpiOsPrintf ( + "%u non-ASCII characters found in input source text, could be a binary file\n", + BadBytes); + AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); + } + + return (AE_BAD_CHARACTER); + } + + /* File is OK (100% ASCII) */ + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeAnsiComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a normal slash-star type comment + * + ******************************************************************************/ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + BOOLEAN ClosingComment = FALSE; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Scan until comment close is found */ + + if (ClosingComment) + { + if (Byte == '/') + { + return; + } + + if (Byte != '*') + { + /* Reset */ + + ClosingComment = FALSE; + } + } + else if (Byte == '*') + { + ClosingComment = TRUE; + } + + /* Maintain line count */ + + if (Byte == 0x0A) + { + Status->Line++; + } + + Status->Offset++; + } +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeNewComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a slash-slash type of comment + * + ******************************************************************************/ + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + Status->Offset++; + + /* Comment ends at newline */ + + if (Byte == 0x0A) + { + Status->Line++; + return; + } + } +} diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index fc61c0e3abfd..025a416705eb 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 1d10cd7903cd..8cef7555b134 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index cc1a0eb6d08e..060380a4341b 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -43,6 +43,7 @@ #include "aslcompiler.h" #include "dtcompiler.h" +#include "acnamesp.h" #include #include @@ -67,484 +68,8 @@ CmFlushSourceCode ( void); static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - -static void -CmDumpAllEvents ( - void); - - -/******************************************************************************* - * - * FUNCTION: AslCompilerSignon - * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None - * - * DESCRIPTION: Display compiler signon - * - ******************************************************************************/ - -void -AslCompilerSignon ( - UINT32 FileId) -{ - char *Prefix = ""; - char *UtilityName; - - - /* Set line prefix depending on the destination file type */ - - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: - case ASL_FILE_ASM_INCLUDE_OUTPUT: - - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || - (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) - { - FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - Prefix = " * "; - break; - - default: - - /* No other output types supported */ - - break; - } - - /* Running compiler or disassembler? */ - - if (Gbl_DisasmFlag) - { - UtilityName = AML_DISASSEMBLER_NAME; - } - else - { - UtilityName = ASL_COMPILER_NAME; - } - - /* Compiler signon with copyright */ - - FlPrintFile (FileId, "%s\n", Prefix); - FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); -} - - -/******************************************************************************* - * - * FUNCTION: AslCompilerFileHeader - * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None - * - * DESCRIPTION: Header used at the beginning of output files - * - ******************************************************************************/ - -void -AslCompilerFileHeader ( - UINT32 FileId) -{ - struct tm *NewTime; - time_t Aclock; - char *Prefix = ""; - - - /* Set line prefix depending on the destination file type */ - - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: - case ASL_FILE_ASM_INCLUDE_OUTPUT: - - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || - (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) - { - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - Prefix = " * "; - break; - - default: - - /* No other output types supported */ - - break; - } - - /* Compilation header with timestamp */ - - (void) time (&Aclock); - NewTime = localtime (&Aclock); - - FlPrintFile (FileId, - "%sCompilation of \"%s\" - %s%s\n", - Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), - Prefix); - - switch (FileId) - { - case ASL_FILE_C_SOURCE_OUTPUT: - case ASL_FILE_C_OFFSET_OUTPUT: - case ASL_FILE_C_INCLUDE_OUTPUT: - - FlPrintFile (FileId, " */\n"); - break; - - default: - - /* Nothing to do for other output types */ - - break; - } -} - - -/******************************************************************************* - * - * FUNCTION: CmFlushSourceCode - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Read in any remaining source code after the parse tree - * has been constructed. - * - ******************************************************************************/ - -static void -CmFlushSourceCode ( - void) -{ - char Buffer; - - - while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) - { - AslInsertLineBuffer ((int) Buffer); - } - - AslResetCurrentLineBuffer (); -} - - -/******************************************************************************* - * - * FUNCTION: FlConsume* - * - * PARAMETERS: Handle - Open input file - * Status - File current status struct - * - * RETURN: Number of lines consumed - * - * DESCRIPTION: Step over both types of comment during check for ascii chars - * - ******************************************************************************/ - -static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - BOOLEAN ClosingComment = FALSE; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Scan until comment close is found */ - - if (ClosingComment) - { - if (Byte == '/') - { - return; - } - - if (Byte != '*') - { - /* Reset */ - - ClosingComment = FALSE; - } - } - else if (Byte == '*') - { - ClosingComment = TRUE; - } - - /* Maintain line count */ - - if (Byte == 0x0A) - { - Status->Line++; - } - - Status->Offset++; - } -} - - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - Status->Offset++; - - /* Comment ends at newline */ - - if (Byte == 0x0A) - { - Status->Line++; - return; - } - } -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAcpiTable - * - * PARAMETERS: Handle - Open input file - * - * RETURN: Status - * - * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the - * following checks on what would be the table header: - * 0) File must be at least as long as an ACPI_TABLE_HEADER - * 1) The header length field must match the file size - * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle) -{ - ACPI_TABLE_HEADER Table; - UINT32 FileSize; - size_t Actual; - UINT32 i; - - - /* Read a potential table header */ - - Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); - fseek (Handle, 0, SEEK_SET); - - if (Actual < sizeof (ACPI_TABLE_HEADER)) - { - return (AE_ERROR); - } - - /* Header length field must match the file size */ - - FileSize = CmGetFileSize (Handle); - if (Table.Length != FileSize) - { - return (AE_ERROR); - } - - /* - * These fields must be ASCII: - * Signature, OemId, OemTableId, AslCompilerId. - * We allow a NULL terminator in OemId and OemTableId. - */ - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) - { - return (AE_ERROR); - } - - if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) - { - return (AE_ERROR); - } - } - - printf ("Binary file appears to be a valid ACPI table, disassembling\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAscii - * - * PARAMETERS: Handle - Open input file - * Filename - Input filename - * DisplayErrors - TRUE if error messages desired - * - * RETURN: Status - * - * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters - * within comments. Note: does not handle nested comments and does - * not handle comment delimiters within string literals. However, - * on the rare chance this happens and an invalid character is - * missed, the parser will catch the error by failing in some - * spectactular manner. - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAscii ( - FILE *Handle, - char *Filename, - BOOLEAN DisplayErrors) -{ - UINT8 Byte; - ACPI_SIZE BadBytes = 0; - BOOLEAN OpeningComment = FALSE; - ASL_FILE_STATUS Status; - - - Status.Line = 1; - Status.Offset = 0; - - /* Read the entire file */ - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Ignore comment fields (allow non-ascii within) */ - - if (OpeningComment) - { - /* Check for second comment open delimiter */ - - if (Byte == '*') - { - FlConsumeAnsiComment (Handle, &Status); - } - - if (Byte == '/') - { - FlConsumeNewComment (Handle, &Status); - } - - /* Reset */ - - OpeningComment = FALSE; - } - else if (Byte == '/') - { - OpeningComment = TRUE; - } - - /* Check for an ASCII character */ - - if (!ACPI_IS_ASCII (Byte)) - { - if ((BadBytes < 10) && (DisplayErrors)) - { - AcpiOsPrintf ( - "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", - Byte, Status.Line, Status.Offset); - } - - BadBytes++; - } - - /* Update line counter */ - - else if (Byte == 0x0A) - { - Status.Line++; - } - - Status.Offset++; - } - - /* Seek back to the beginning of the source file */ - - fseek (Handle, 0, SEEK_SET); - - /* Were there any non-ASCII characters in the file? */ - - if (BadBytes) - { - if (DisplayErrors) - { - AcpiOsPrintf ( - "%u non-ASCII characters found in input source text, could be a binary file\n", - BadBytes); - AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); - } - - return (AE_BAD_CHARACTER); - } - - /* File is OK (100% ASCII) */ - - return (AE_OK); -} +CmDumpAllEvents ( + void); /******************************************************************************* @@ -617,7 +142,6 @@ CmDoCompile ( goto ErrorExit; } - /* Flush out any remaining source after parse tree is complete */ Event = UtBeginEvent ("Flush source input"); @@ -800,6 +324,197 @@ ErrorExit: } +/******************************************************************************* + * + * FUNCTION: AslCompilerSignon + * + * PARAMETERS: FileId - ID of the output file + * + * RETURN: None + * + * DESCRIPTION: Display compiler signon + * + ******************************************************************************/ + +void +AslCompilerSignon ( + UINT32 FileId) +{ + char *Prefix = ""; + char *UtilityName; + + + /* Set line prefix depending on the destination file type */ + + switch (FileId) + { + case ASL_FILE_ASM_SOURCE_OUTPUT: + case ASL_FILE_ASM_INCLUDE_OUTPUT: + + Prefix = "; "; + break; + + case ASL_FILE_HEX_OUTPUT: + + if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) + { + Prefix = "; "; + } + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); + Prefix = " * "; + } + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + Prefix = " * "; + break; + + default: + + /* No other output types supported */ + + break; + } + + /* Running compiler or disassembler? */ + + if (Gbl_DisasmFlag) + { + UtilityName = AML_DISASSEMBLER_NAME; + } + else + { + UtilityName = ASL_COMPILER_NAME; + } + + /* Compiler signon with copyright */ + + FlPrintFile (FileId, "%s\n", Prefix); + FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); +} + + +/******************************************************************************* + * + * FUNCTION: AslCompilerFileHeader + * + * PARAMETERS: FileId - ID of the output file + * + * RETURN: None + * + * DESCRIPTION: Header used at the beginning of output files + * + ******************************************************************************/ + +void +AslCompilerFileHeader ( + UINT32 FileId) +{ + struct tm *NewTime; + time_t Aclock; + char *Prefix = ""; + + + /* Set line prefix depending on the destination file type */ + + switch (FileId) + { + case ASL_FILE_ASM_SOURCE_OUTPUT: + case ASL_FILE_ASM_INCLUDE_OUTPUT: + + Prefix = "; "; + break; + + case ASL_FILE_HEX_OUTPUT: + + if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) + { + Prefix = "; "; + } + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) + { + Prefix = " * "; + } + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + Prefix = " * "; + break; + + default: + + /* No other output types supported */ + + break; + } + + /* Compilation header with timestamp */ + + (void) time (&Aclock); + NewTime = localtime (&Aclock); + + FlPrintFile (FileId, + "%sCompilation of \"%s\" - %s%s\n", + Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), + Prefix); + + switch (FileId) + { + case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: + case ASL_FILE_C_INCLUDE_OUTPUT: + + FlPrintFile (FileId, " */\n"); + break; + + default: + + /* Nothing to do for other output types */ + + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: CmFlushSourceCode + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Read in any remaining source code after the parse tree + * has been constructed. + * + ******************************************************************************/ + +static void +CmFlushSourceCode ( + void) +{ + char Buffer; + + + while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) + { + AslInsertLineBuffer ((int) Buffer); + } + + AslResetCurrentLineBuffer (); +} + + /******************************************************************************* * * FUNCTION: CmDoOutputFiles @@ -965,7 +680,8 @@ CmCleanupAndExit ( * We will delete the AML file if there are errors and the * force AML output option has not been used. */ - if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && + if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && + (!Gbl_IgnoreErrors) && Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) { DeleteAmlFile = TRUE; @@ -1025,4 +741,71 @@ CmCleanupAndExit ( { FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); } + + /* Final cleanup after compiling one file */ + + CmDeleteCaches (); +} + + +/******************************************************************************* + * + * FUNCTION: CmDeleteCaches + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all local cache buffer blocks + * + ******************************************************************************/ + +void +CmDeleteCaches ( + void) +{ + UINT32 BufferCount; + ASL_CACHE_INFO *Next; + + + /* Parse Op cache */ + + BufferCount = 0; + while (Gbl_ParseOpCacheList) + { + Next = Gbl_ParseOpCacheList->Next; + ACPI_FREE (Gbl_ParseOpCacheList); + Gbl_ParseOpCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n", + Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE, + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount); + + Gbl_ParseOpCount = 0; + Gbl_ParseOpCacheNext = NULL; + Gbl_ParseOpCacheLast = NULL; + RootNode = NULL; + + /* Generic string cache */ + + BufferCount = 0; + while (Gbl_StringCacheList) + { + Next = Gbl_StringCacheList->Next; + ACPI_FREE (Gbl_StringCacheList); + Gbl_StringCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n", + Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount); + + Gbl_StringSize = 0; + Gbl_StringCount = 0; + Gbl_StringCacheNext = NULL; + Gbl_StringCacheLast = NULL; } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 40dcd692784c..1001f68966ec 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLCOMPILER_H #define __ASLCOMPILER_H @@ -111,6 +110,11 @@ AslPushInputFileStack ( FILE *InputFile, char *Filename); +void +AslParserCleanup ( + void); + + /* * aslstartup - entered from main() */ @@ -154,6 +158,14 @@ void CmCleanupAndExit ( void); +void +CmDeleteCaches ( + void); + + +/* + * aslascii - ascii support + */ ACPI_STATUS FlCheckForAcpiTable ( FILE *Handle); @@ -275,6 +287,11 @@ void ApCheckRegMethod ( ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op); + /* * aslerror - error handling/reporting @@ -890,10 +907,6 @@ void UtDisplaySummary ( UINT32 FileId); -UINT8 -UtHexCharToValue ( - int HexChar); - void UtConvertByteToHex ( UINT8 RawByte, @@ -913,13 +926,17 @@ UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length); void UtExpandLineBuffers ( void); +void +UtFreeLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, @@ -954,11 +971,6 @@ ACPI_STATUS AuValidateUuid ( char *InString); -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuIdBuffer); - ACPI_STATUS AuConvertUuidToString ( char *UuIdBuffer, diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 286e62815535..523241a5a557 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -110,10 +110,11 @@ NamePathTail [.]{NameSeg} [ \t] { count (0); } -"/*" { if (!AslDoComment ()) yyterminate (); } -"//" { if (!AslDoCommentType2 ()) yyterminate (); } +"/*" { if (!AslDoComment ()) {yyterminate ();} } +"//" { if (!AslDoCommentType2 ()) {yyterminate ();} } -"\"" { if (AslDoStringLiteral ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } +"\"" { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);} + else {yyterminate ();} } ";" { count (0); return(';'); } @@ -607,7 +608,7 @@ NamePathTail [.]{NameSeg} {NameSeg} { char *s; count (0); - s=malloc (ACPI_NAME_SIZE + 1); + s=UtStringCacheCalloc (ACPI_NAME_SIZE + 1); if (strcmp (AslCompilertext, "\\")) { strcpy (s, "____"); @@ -620,10 +621,9 @@ NamePathTail [.]{NameSeg} {NameString} { char *s; count (0); - s=malloc (strlen (AslCompilertext)+1); + s=UtStringCacheCalloc (strlen (AslCompilertext)+1); AcpiUtStrupr (AslCompilertext); strcpy (s, AslCompilertext); - s[strlen (AslCompilertext)] = 0; AslCompilerlval.s = s; DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); return (PARSEOP_NAMESTRING); } @@ -639,9 +639,9 @@ NamePathTail [.]{NameSeg} AslCompilererror (MsgBuffer);} <> { if (AslPopInputFileStack ()) - yyterminate(); + {yyterminate();} else - return (PARSEOP_INCLUDE_END);}; + {return (PARSEOP_INCLUDE_END);} }; %% diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslcompiler.y deleted file mode 100644 index 6860e726d57a..000000000000 --- a/source/compiler/aslcompiler.y +++ /dev/null @@ -1,3587 +0,0 @@ -%{ -/****************************************************************************** - * - * Module Name: aslcompiler.y - Bison/Yacc input file (ASL grammar and actions) - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2014, 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 "aslcompiler.h" -#include -#include -#include -#include "acpi.h" -#include "accommon.h" - -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslparse") - -/* - * Global Notes: - * - * October 2005: The following list terms have been optimized (from the - * original ASL grammar in the ACPI specification) to force the immediate - * reduction of each list item so that the parse stack use doesn't increase on - * each list element and possibly overflow on very large lists (>4000 items). - * This dramatically reduces use of the parse stack overall. - * - * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, - * ResourceMacroList, and FieldUnitList - */ - -void * AslLocalAllocate (unsigned int Size); - -/* Bison/yacc configuration */ - -#define static -#undef alloca -#define alloca AslLocalAllocate -#define yytname AslCompilername - -#define YYINITDEPTH 600 /* State stack depth */ -#define YYDEBUG 1 /* Enable debug output */ -#define YYERROR_VERBOSE 1 /* Verbose error messages */ - -/* Define YYMALLOC/YYFREE to prevent redefinition errors */ - -#define YYMALLOC malloc -#define YYFREE free - -/* - * The windows version of bison defines this incorrectly as "32768" (Not negative). - * We use a custom (edited binary) version of bison that defines YYFLAG as YYFBAD - * instead (#define YYFBAD 32768), so we can define it correctly here. - * - * The problem is that if YYFLAG is positive, the extended syntax error messages - * are disabled. - */ -#define YYFLAG -32768 - -%} - -/* - * Declare the type of values in the grammar - */ -%union { - UINT64 i; - char *s; - ACPI_PARSE_OBJECT *n; -} - -/*! [Begin] no source code translation */ - -/* - * These shift/reduce conflicts are expected. There should be zero - * reduce/reduce conflicts. - */ -%expect 86 - -/****************************************************************************** - * - * Token types: These are returned by the lexer - * - * NOTE: This list MUST match the AslKeywordMapping table found - * in aslmap.c EXACTLY! Double check any changes! - * - *****************************************************************************/ - -%token PARSEOP_ACCESSAS -%token PARSEOP_ACCESSATTRIB_BLOCK -%token PARSEOP_ACCESSATTRIB_BLOCK_CALL -%token PARSEOP_ACCESSATTRIB_BYTE -%token PARSEOP_ACCESSATTRIB_MULTIBYTE -%token PARSEOP_ACCESSATTRIB_QUICK -%token PARSEOP_ACCESSATTRIB_RAW_BYTES -%token PARSEOP_ACCESSATTRIB_RAW_PROCESS -%token PARSEOP_ACCESSATTRIB_SND_RCV -%token PARSEOP_ACCESSATTRIB_WORD -%token PARSEOP_ACCESSATTRIB_WORD_CALL -%token PARSEOP_ACCESSTYPE_ANY -%token PARSEOP_ACCESSTYPE_BUF -%token PARSEOP_ACCESSTYPE_BYTE -%token PARSEOP_ACCESSTYPE_DWORD -%token PARSEOP_ACCESSTYPE_QWORD -%token PARSEOP_ACCESSTYPE_WORD -%token PARSEOP_ACQUIRE -%token PARSEOP_ADD -%token PARSEOP_ADDRESSINGMODE_7BIT -%token PARSEOP_ADDRESSINGMODE_10BIT -%token PARSEOP_ADDRESSTYPE_ACPI -%token PARSEOP_ADDRESSTYPE_MEMORY -%token PARSEOP_ADDRESSTYPE_NVS -%token PARSEOP_ADDRESSTYPE_RESERVED -%token PARSEOP_ALIAS -%token PARSEOP_AND -%token PARSEOP_ARG0 -%token PARSEOP_ARG1 -%token PARSEOP_ARG2 -%token PARSEOP_ARG3 -%token PARSEOP_ARG4 -%token PARSEOP_ARG5 -%token PARSEOP_ARG6 -%token PARSEOP_BANKFIELD -%token PARSEOP_BITSPERBYTE_EIGHT -%token PARSEOP_BITSPERBYTE_FIVE -%token PARSEOP_BITSPERBYTE_NINE -%token PARSEOP_BITSPERBYTE_SEVEN -%token PARSEOP_BITSPERBYTE_SIX -%token PARSEOP_BREAK -%token PARSEOP_BREAKPOINT -%token PARSEOP_BUFFER -%token PARSEOP_BUSMASTERTYPE_MASTER -%token PARSEOP_BUSMASTERTYPE_NOTMASTER -%token PARSEOP_BYTECONST -%token PARSEOP_CASE -%token PARSEOP_CLOCKPHASE_FIRST -%token PARSEOP_CLOCKPHASE_SECOND -%token PARSEOP_CLOCKPOLARITY_HIGH -%token PARSEOP_CLOCKPOLARITY_LOW -%token PARSEOP_CONCATENATE -%token PARSEOP_CONCATENATERESTEMPLATE -%token PARSEOP_CONDREFOF -%token PARSEOP_CONNECTION -%token PARSEOP_CONTINUE -%token PARSEOP_COPYOBJECT -%token PARSEOP_CREATEBITFIELD -%token PARSEOP_CREATEBYTEFIELD -%token PARSEOP_CREATEDWORDFIELD -%token PARSEOP_CREATEFIELD -%token PARSEOP_CREATEQWORDFIELD -%token PARSEOP_CREATEWORDFIELD -%token PARSEOP_DATABUFFER -%token PARSEOP_DATATABLEREGION -%token PARSEOP_DEBUG -%token PARSEOP_DECODETYPE_POS -%token PARSEOP_DECODETYPE_SUB -%token PARSEOP_DECREMENT -%token PARSEOP_DEFAULT -%token PARSEOP_DEFAULT_ARG -%token PARSEOP_DEFINITIONBLOCK -%token PARSEOP_DEREFOF -%token PARSEOP_DEVICE -%token PARSEOP_DEVICEPOLARITY_HIGH -%token PARSEOP_DEVICEPOLARITY_LOW -%token PARSEOP_DIVIDE -%token PARSEOP_DMA -%token PARSEOP_DMATYPE_A -%token PARSEOP_DMATYPE_COMPATIBILITY -%token PARSEOP_DMATYPE_B -%token PARSEOP_DMATYPE_F -%token PARSEOP_DWORDCONST -%token PARSEOP_DWORDIO -%token PARSEOP_DWORDMEMORY -%token PARSEOP_DWORDSPACE -%token PARSEOP_EISAID -%token PARSEOP_ELSE -%token PARSEOP_ELSEIF -%token PARSEOP_ENDDEPENDENTFN -%token PARSEOP_ENDIAN_BIG -%token PARSEOP_ENDIAN_LITTLE -%token PARSEOP_ENDTAG -%token PARSEOP_ERRORNODE -%token PARSEOP_EVENT -%token PARSEOP_EXTENDEDIO -%token PARSEOP_EXTENDEDMEMORY -%token PARSEOP_EXTENDEDSPACE -%token PARSEOP_EXTERNAL -%token PARSEOP_FATAL -%token PARSEOP_FIELD -%token PARSEOP_FINDSETLEFTBIT -%token PARSEOP_FINDSETRIGHTBIT -%token PARSEOP_FIXEDDMA -%token PARSEOP_FIXEDIO -%token PARSEOP_FLOWCONTROL_HW -%token PARSEOP_FLOWCONTROL_NONE -%token PARSEOP_FLOWCONTROL_SW -%token PARSEOP_FROMBCD -%token PARSEOP_FUNCTION -%token PARSEOP_GPIO_INT -%token PARSEOP_GPIO_IO -%token PARSEOP_I2C_SERIALBUS -%token PARSEOP_IF -%token PARSEOP_INCLUDE -%token PARSEOP_INCLUDE_END -%token PARSEOP_INCREMENT -%token PARSEOP_INDEX -%token PARSEOP_INDEXFIELD -%token PARSEOP_INTEGER -%token PARSEOP_INTERRUPT -%token PARSEOP_INTLEVEL_ACTIVEBOTH -%token PARSEOP_INTLEVEL_ACTIVEHIGH -%token PARSEOP_INTLEVEL_ACTIVELOW -%token PARSEOP_INTTYPE_EDGE -%token PARSEOP_INTTYPE_LEVEL -%token PARSEOP_IO -%token PARSEOP_IODECODETYPE_10 -%token PARSEOP_IODECODETYPE_16 -%token PARSEOP_IORESTRICT_IN -%token PARSEOP_IORESTRICT_NONE -%token PARSEOP_IORESTRICT_OUT -%token PARSEOP_IORESTRICT_PRESERVE -%token PARSEOP_IRQ -%token PARSEOP_IRQNOFLAGS -%token PARSEOP_LAND -%token PARSEOP_LEQUAL -%token PARSEOP_LGREATER -%token PARSEOP_LGREATEREQUAL -%token PARSEOP_LLESS -%token PARSEOP_LLESSEQUAL -%token PARSEOP_LNOT -%token PARSEOP_LNOTEQUAL -%token PARSEOP_LOAD -%token PARSEOP_LOADTABLE -%token PARSEOP_LOCAL0 -%token PARSEOP_LOCAL1 -%token PARSEOP_LOCAL2 -%token PARSEOP_LOCAL3 -%token PARSEOP_LOCAL4 -%token PARSEOP_LOCAL5 -%token PARSEOP_LOCAL6 -%token PARSEOP_LOCAL7 -%token PARSEOP_LOCKRULE_LOCK -%token PARSEOP_LOCKRULE_NOLOCK -%token PARSEOP_LOR -%token PARSEOP_MATCH -%token PARSEOP_MATCHTYPE_MEQ -%token PARSEOP_MATCHTYPE_MGE -%token PARSEOP_MATCHTYPE_MGT -%token PARSEOP_MATCHTYPE_MLE -%token PARSEOP_MATCHTYPE_MLT -%token PARSEOP_MATCHTYPE_MTR -%token PARSEOP_MAXTYPE_FIXED -%token PARSEOP_MAXTYPE_NOTFIXED -%token PARSEOP_MEMORY24 -%token PARSEOP_MEMORY32 -%token PARSEOP_MEMORY32FIXED -%token PARSEOP_MEMTYPE_CACHEABLE -%token PARSEOP_MEMTYPE_NONCACHEABLE -%token PARSEOP_MEMTYPE_PREFETCHABLE -%token PARSEOP_MEMTYPE_WRITECOMBINING -%token PARSEOP_METHOD -%token PARSEOP_METHODCALL -%token PARSEOP_MID -%token PARSEOP_MINTYPE_FIXED -%token PARSEOP_MINTYPE_NOTFIXED -%token PARSEOP_MOD -%token PARSEOP_MULTIPLY -%token PARSEOP_MUTEX -%token PARSEOP_NAME -%token PARSEOP_NAMESEG -%token PARSEOP_NAMESTRING -%token PARSEOP_NAND -%token PARSEOP_NOOP -%token PARSEOP_NOR -%token PARSEOP_NOT -%token PARSEOP_NOTIFY -%token PARSEOP_OBJECTTYPE -%token PARSEOP_OBJECTTYPE_BFF -%token PARSEOP_OBJECTTYPE_BUF -%token PARSEOP_OBJECTTYPE_DDB -%token PARSEOP_OBJECTTYPE_DEV -%token PARSEOP_OBJECTTYPE_EVT -%token PARSEOP_OBJECTTYPE_FLD -%token PARSEOP_OBJECTTYPE_INT -%token PARSEOP_OBJECTTYPE_MTH -%token PARSEOP_OBJECTTYPE_MTX -%token PARSEOP_OBJECTTYPE_OPR -%token PARSEOP_OBJECTTYPE_PKG -%token PARSEOP_OBJECTTYPE_POW -%token PARSEOP_OBJECTTYPE_PRO -%token PARSEOP_OBJECTTYPE_STR -%token PARSEOP_OBJECTTYPE_THZ -%token PARSEOP_OBJECTTYPE_UNK -%token PARSEOP_OFFSET -%token PARSEOP_ONE -%token PARSEOP_ONES -%token PARSEOP_OPERATIONREGION -%token PARSEOP_OR -%token PARSEOP_PACKAGE -%token PARSEOP_PACKAGE_LENGTH -%token PARSEOP_PARITYTYPE_EVEN -%token PARSEOP_PARITYTYPE_MARK -%token PARSEOP_PARITYTYPE_NONE -%token PARSEOP_PARITYTYPE_ODD -%token PARSEOP_PARITYTYPE_SPACE -%token PARSEOP_PIN_NOPULL -%token PARSEOP_PIN_PULLDEFAULT -%token PARSEOP_PIN_PULLDOWN -%token PARSEOP_PIN_PULLUP -%token PARSEOP_POWERRESOURCE -%token PARSEOP_PROCESSOR -%token PARSEOP_QWORDCONST -%token PARSEOP_QWORDIO -%token PARSEOP_QWORDMEMORY -%token PARSEOP_QWORDSPACE -%token PARSEOP_RANGETYPE_ENTIRE -%token PARSEOP_RANGETYPE_ISAONLY -%token PARSEOP_RANGETYPE_NONISAONLY -%token PARSEOP_RAW_DATA -%token PARSEOP_READWRITETYPE_BOTH -%token PARSEOP_READWRITETYPE_READONLY -%token PARSEOP_REFOF -%token PARSEOP_REGIONSPACE_CMOS -%token PARSEOP_REGIONSPACE_EC -%token PARSEOP_REGIONSPACE_FFIXEDHW -%token PARSEOP_REGIONSPACE_GPIO -%token PARSEOP_REGIONSPACE_GSBUS -%token PARSEOP_REGIONSPACE_IO -%token PARSEOP_REGIONSPACE_IPMI -%token PARSEOP_REGIONSPACE_MEM -%token PARSEOP_REGIONSPACE_PCC -%token PARSEOP_REGIONSPACE_PCI -%token PARSEOP_REGIONSPACE_PCIBAR -%token PARSEOP_REGIONSPACE_SMBUS -%token PARSEOP_REGISTER -%token PARSEOP_RELEASE -%token PARSEOP_RESERVED_BYTES -%token PARSEOP_RESET -%token PARSEOP_RESOURCETEMPLATE -%token PARSEOP_RESOURCETYPE_CONSUMER -%token PARSEOP_RESOURCETYPE_PRODUCER -%token PARSEOP_RETURN -%token PARSEOP_REVISION -%token PARSEOP_SCOPE -%token PARSEOP_SERIALIZERULE_NOTSERIAL -%token PARSEOP_SERIALIZERULE_SERIAL -%token PARSEOP_SHARETYPE_EXCLUSIVE -%token PARSEOP_SHARETYPE_EXCLUSIVEWAKE -%token PARSEOP_SHARETYPE_SHARED -%token PARSEOP_SHARETYPE_SHAREDWAKE -%token PARSEOP_SHIFTLEFT -%token PARSEOP_SHIFTRIGHT -%token PARSEOP_SIGNAL -%token PARSEOP_SIZEOF -%token PARSEOP_SLAVEMODE_CONTROLLERINIT -%token PARSEOP_SLAVEMODE_DEVICEINIT -%token PARSEOP_SLEEP -%token PARSEOP_SPI_SERIALBUS -%token PARSEOP_STALL -%token PARSEOP_STARTDEPENDENTFN -%token PARSEOP_STARTDEPENDENTFN_NOPRI -%token PARSEOP_STOPBITS_ONE -%token PARSEOP_STOPBITS_ONEPLUSHALF -%token PARSEOP_STOPBITS_TWO -%token PARSEOP_STOPBITS_ZERO -%token PARSEOP_STORE -%token PARSEOP_STRING_LITERAL -%token PARSEOP_SUBTRACT -%token PARSEOP_SWITCH -%token PARSEOP_THERMALZONE -%token PARSEOP_TIMER -%token PARSEOP_TOBCD -%token PARSEOP_TOBUFFER -%token PARSEOP_TODECIMALSTRING -%token PARSEOP_TOHEXSTRING -%token PARSEOP_TOINTEGER -%token PARSEOP_TOSTRING -%token PARSEOP_TOUUID -%token PARSEOP_TRANSLATIONTYPE_DENSE -%token PARSEOP_TRANSLATIONTYPE_SPARSE -%token PARSEOP_TYPE_STATIC -%token PARSEOP_TYPE_TRANSLATION -%token PARSEOP_UART_SERIALBUS -%token PARSEOP_UNICODE -%token PARSEOP_UNLOAD -%token PARSEOP_UPDATERULE_ONES -%token PARSEOP_UPDATERULE_PRESERVE -%token PARSEOP_UPDATERULE_ZEROS -%token PARSEOP_VAR_PACKAGE -%token PARSEOP_VENDORLONG -%token PARSEOP_VENDORSHORT -%token PARSEOP_WAIT -%token PARSEOP_WHILE -%token PARSEOP_WIREMODE_FOUR -%token PARSEOP_WIREMODE_THREE -%token PARSEOP_WORDBUSNUMBER -%token PARSEOP_WORDCONST -%token PARSEOP_WORDIO -%token PARSEOP_WORDSPACE -%token PARSEOP_XFERSIZE_8 -%token PARSEOP_XFERSIZE_16 -%token PARSEOP_XFERSIZE_32 -%token PARSEOP_XFERSIZE_64 -%token PARSEOP_XFERSIZE_128 -%token PARSEOP_XFERSIZE_256 -%token PARSEOP_XFERTYPE_8 -%token PARSEOP_XFERTYPE_8_16 -%token PARSEOP_XFERTYPE_16 -%token PARSEOP_XOR -%token PARSEOP_ZERO - -/* - * Special functions. These should probably stay at the end of this - * table. - */ -%token PARSEOP___DATE__ -%token PARSEOP___FILE__ -%token PARSEOP___LINE__ -%token PARSEOP___PATH__ - - -/****************************************************************************** - * - * Production names - * - *****************************************************************************/ - -%type ArgList -%type ASLCode -%type BufferData -%type BufferTermData -%type CompilerDirective -%type DataObject -%type DefinitionBlockTerm -%type IntegerData -%type NamedObject -%type NameSpaceModifier -%type Object -%type ObjectList -%type PackageData -%type ParameterTypePackage -%type ParameterTypePackageList -%type ParameterTypesPackage -%type ParameterTypesPackageList -%type RequiredTarget -%type SimpleTarget -%type StringData -%type Target -%type Term -%type TermArg -%type TermList -%type UserTerm - -/* Type4Opcode is obsolete */ - -%type Type1Opcode -%type Type2BufferOpcode -%type Type2BufferOrStringOpcode -%type Type2IntegerOpcode -%type Type2Opcode -%type Type2StringOpcode -%type Type3Opcode -%type Type5Opcode -%type Type6Opcode - -%type AccessAsTerm -%type ExternalTerm -%type FieldUnit -%type FieldUnitEntry -%type FieldUnitList -%type IncludeTerm -%type OffsetTerm -%type OptionalAccessAttribTerm - -/* Named Objects */ - -%type BankFieldTerm -%type CreateBitFieldTerm -%type CreateByteFieldTerm -%type CreateDWordFieldTerm -%type CreateFieldTerm -%type CreateQWordFieldTerm -%type CreateWordFieldTerm -%type DataRegionTerm -%type DeviceTerm -%type EventTerm -%type FieldTerm -%type FunctionTerm -%type IndexFieldTerm -%type MethodTerm -%type MutexTerm -%type OpRegionTerm -%type OpRegionSpaceIdTerm -%type PowerResTerm -%type ProcessorTerm -%type ThermalZoneTerm - -/* Namespace modifiers */ - -%type AliasTerm -%type NameTerm -%type ScopeTerm - -/* Type 1 opcodes */ - -%type BreakPointTerm -%type BreakTerm -%type CaseDefaultTermList -%type CaseTerm -%type ContinueTerm -%type DefaultTerm -%type ElseTerm -%type FatalTerm -%type IfElseTerm -%type IfTerm -%type LoadTerm -%type NoOpTerm -%type NotifyTerm -%type ReleaseTerm -%type ResetTerm -%type ReturnTerm -%type SignalTerm -%type SleepTerm -%type StallTerm -%type SwitchTerm -%type UnloadTerm -%type WhileTerm -/* %type CaseTermList */ - -/* Type 2 opcodes */ - -%type AcquireTerm -%type AddTerm -%type AndTerm -%type ConcatResTerm -%type ConcatTerm -%type CondRefOfTerm -%type CopyObjectTerm -%type DecTerm -%type DerefOfTerm -%type DivideTerm -%type FindSetLeftBitTerm -%type FindSetRightBitTerm -%type FromBCDTerm -%type IncTerm -%type IndexTerm -%type LAndTerm -%type LEqualTerm -%type LGreaterEqualTerm -%type LGreaterTerm -%type LLessEqualTerm -%type LLessTerm -%type LNotEqualTerm -%type LNotTerm -%type LoadTableTerm -%type LOrTerm -%type MatchTerm -%type MidTerm -%type ModTerm -%type MultiplyTerm -%type NAndTerm -%type NOrTerm -%type NotTerm -%type ObjectTypeTerm -%type OrTerm -%type RefOfTerm -%type ShiftLeftTerm -%type ShiftRightTerm -%type SizeOfTerm -%type StoreTerm -%type SubtractTerm -%type TimerTerm -%type ToBCDTerm -%type ToBufferTerm -%type ToDecimalStringTerm -%type ToHexStringTerm -%type ToIntegerTerm -%type ToStringTerm -%type WaitTerm -%type XOrTerm - -/* Keywords */ - -%type AccessAttribKeyword -%type AccessTypeKeyword -%type AddressingModeKeyword -%type AddressKeyword -%type AddressSpaceKeyword -%type BitsPerByteKeyword -%type ClockPhaseKeyword -%type ClockPolarityKeyword -%type DecodeKeyword -%type DevicePolarityKeyword -%type DMATypeKeyword -%type EndianKeyword -%type FlowControlKeyword -%type InterruptLevel -%type InterruptTypeKeyword -%type IODecodeKeyword -%type IoRestrictionKeyword -%type LockRuleKeyword -%type MatchOpKeyword -%type MaxKeyword -%type MemTypeKeyword -%type MinKeyword -%type ObjectTypeKeyword -%type OptionalBusMasterKeyword -%type OptionalReadWriteKeyword -%type ParityTypeKeyword -%type PinConfigByte -%type PinConfigKeyword -%type RangeTypeKeyword -%type RegionSpaceKeyword -%type ResourceTypeKeyword -%type SerializeRuleKeyword -%type ShareTypeKeyword -%type SlaveModeKeyword -%type StopBitsKeyword -%type TranslationKeyword -%type TypeKeyword -%type UpdateRuleKeyword -%type WireModeKeyword -%type XferSizeKeyword -%type XferTypeKeyword - -/* Types */ - -%type SuperName -%type ObjectTypeName -%type ArgTerm -%type LocalTerm -%type DebugTerm - -%type Integer -%type ByteConst -%type WordConst -%type DWordConst -%type QWordConst -%type String - -%type ConstTerm -%type ConstExprTerm -%type ByteConstExpr -%type WordConstExpr -%type DWordConstExpr -%type QWordConstExpr - -%type DWordList -%type BufferTerm -%type ByteList - -%type PackageElement -%type PackageList -%type PackageTerm -%type VarPackageLengthTerm - -/* Macros */ - -%type EISAIDTerm -%type ResourceMacroList -%type ResourceMacroTerm -%type ResourceTemplateTerm -%type ToUUIDTerm -%type UnicodeTerm - -/* Resource Descriptors */ - -%type ConnectionTerm -%type DataBufferTerm -%type DMATerm -%type DWordIOTerm -%type DWordMemoryTerm -%type DWordSpaceTerm -%type EndDependentFnTerm -%type ExtendedIOTerm -%type ExtendedMemoryTerm -%type ExtendedSpaceTerm -%type FixedDmaTerm -%type FixedIOTerm -%type GpioIntTerm -%type GpioIoTerm -%type I2cSerialBusTerm -%type InterruptTerm -%type IOTerm -%type IRQNoFlagsTerm -%type IRQTerm -%type Memory24Term -%type Memory32FixedTerm -%type Memory32Term -%type NameSeg -%type NameString -%type QWordIOTerm -%type QWordMemoryTerm -%type QWordSpaceTerm -%type RegisterTerm -%type SpiSerialBusTerm -%type StartDependentFnNoPriTerm -%type StartDependentFnTerm -%type UartSerialBusTerm -%type VendorLongTerm -%type VendorShortTerm -%type WordBusNumberTerm -%type WordIOTerm -%type WordSpaceTerm - -/* Local types that help construct the AML, not in ACPI spec */ - -%type AmlPackageLengthTerm -%type IncludeEndTerm -%type NameStringItem -%type TermArgItem - -%type OptionalAccessSize -%type OptionalAddressingMode -%type OptionalAddressRange -%type OptionalBitsPerByte -%type OptionalBuffer_Last -%type OptionalByteConstExpr -%type OptionalCount -%type OptionalDecodeType -%type OptionalDevicePolarity -%type OptionalDWordConstExpr -%type OptionalEndian -%type OptionalFlowControl -%type OptionalIoRestriction -%type OptionalListString -%type OptionalMaxType -%type OptionalMemType -%type OptionalMinType -%type OptionalNameString -%type OptionalNameString_First -%type OptionalNameString_Last -%type OptionalObjectTypeKeyword -%type OptionalParameterTypePackage -%type OptionalParameterTypesPackage -%type OptionalParityType -%type OptionalQWordConstExpr -%type OptionalRangeType -%type OptionalReference -%type OptionalResourceType -%type OptionalResourceType_First -%type OptionalReturnArg -%type OptionalSerializeRuleKeyword -%type OptionalShareType -%type OptionalShareType_First -%type OptionalSlaveMode -%type OptionalStopBits -%type OptionalStringData -%type OptionalTermArg -%type OptionalTranslationType_Last -%type OptionalType -%type OptionalType_Last -%type OptionalWireMode -%type OptionalWordConst -%type OptionalWordConstExpr -%type OptionalXferSize - -%% -/******************************************************************************* - * - * Production rules start here - * - ******************************************************************************/ - -/* - * ASL Names - */ - - -/* - * Root rule. Allow multiple #line directives before the definition block - * to handle output from preprocessors - */ -ASLCode - : DefinitionBlockTerm - | error {YYABORT; $$ = NULL;} - ; - -/* - * Blocks, Data, and Opcodes - */ - -/* - * Note concerning support for "module-level code". - * - * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control - * methods (the so-called module-level code.) This support was explicitly - * removed in ACPI 2.0, but this type of code continues to be created by - * BIOS vendors. In order to support the disassembly and recompilation of - * such code (and the porting of ASL code to iASL), iASL supports this - * code in violation of the current ACPI specification. - * - * The grammar change to support module-level code is to revert the - * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the - * original use of {TermList} instead (see below.) This allows the use - * of Type1 and Type2 opcodes at module level. - */ -DefinitionBlockTerm - : PARSEOP_DEFINITIONBLOCK '(' {$$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);} - String ',' - String ',' - ByteConst ',' - String ',' - String ',' - DWordConst - ')' {TrSetEndLineNumber ($3);} - '{' TermList '}' {$$ = TrLinkChildren ($3,7,$4,$6,$8,$10,$12,$14,$18);} - ; - -/* ACPI 3.0 -- allow semicolons between terms */ - -TermList - : {$$ = NULL;} - | TermList Term {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} - | TermList Term ';' {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} - | TermList ';' Term {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} - | TermList ';' Term ';' {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} - ; - -Term - : Object {} - | Type1Opcode {} - | Type2Opcode {} - | Type2IntegerOpcode {} - | Type2StringOpcode {} - | Type2BufferOpcode {} - | Type2BufferOrStringOpcode {} - | error {$$ = AslDoError(); yyclearin;} - ; - -CompilerDirective - : IncludeTerm {} - | ExternalTerm {} - ; - -ObjectList - : {$$ = NULL;} - | ObjectList Object {$$ = TrLinkPeerNode ($1,$2);} - | error {$$ = AslDoError(); yyclearin;} - ; - -Object - : CompilerDirective {} - | NamedObject {} - | NameSpaceModifier {} - ; - -DataObject - : BufferData {} - | PackageData {} - | IntegerData {} - | StringData {} - ; - -BufferData - : Type5Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | BufferTerm {} - ; - -PackageData - : PackageTerm {} - ; - -IntegerData - : Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | Integer {} - | ConstTerm {} - ; - -StringData - : Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} - | String {} - ; - -NamedObject - : BankFieldTerm {} - | CreateBitFieldTerm {} - | CreateByteFieldTerm {} - | CreateDWordFieldTerm {} - | CreateFieldTerm {} - | CreateQWordFieldTerm {} - | CreateWordFieldTerm {} - | DataRegionTerm {} - | DeviceTerm {} - | EventTerm {} - | FieldTerm {} - | FunctionTerm {} - | IndexFieldTerm {} - | MethodTerm {} - | MutexTerm {} - | OpRegionTerm {} - | PowerResTerm {} - | ProcessorTerm {} - | ThermalZoneTerm {} - ; - -NameSpaceModifier - : AliasTerm {} - | NameTerm {} - | ScopeTerm {} - ; - -UserTerm - : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} - ArgList ')' {$$ = TrLinkChildNode ($1,$4);} - ; - -ArgList - : {$$ = NULL;} - | TermArg - | ArgList ',' /* Allows a trailing comma at list end */ - | ArgList ',' - TermArg {$$ = TrLinkPeerNode ($1,$3);} - ; - -/* -Removed from TermArg due to reduce/reduce conflicts - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - -*/ - -TermArg - : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - ; - -Target - : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ - | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} - ; - -RequiredTarget - : ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} - ; - -SimpleTarget - : NameString {} - | LocalTerm {} - | ArgTerm {} - ; - -/* Rules for specifying the type of one method argument or return value */ - -ParameterTypePackage - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | ParameterTypePackage ',' - ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypePackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypePackage '}' {$$ = $2;} - ; - -OptionalParameterTypePackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - -/* Rules for specifying the types for method arguments */ - -ParameterTypesPackage - : ParameterTypePackageList {$$ = $1;} - | ParameterTypesPackage ',' - ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypesPackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypesPackage '}' {$$ = $2;} - ; - -OptionalParameterTypesPackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - - -/* Opcode types */ - -Type1Opcode - : BreakTerm {} - | BreakPointTerm {} - | ContinueTerm {} - | FatalTerm {} - | IfElseTerm {} - | LoadTerm {} - | NoOpTerm {} - | NotifyTerm {} - | ReleaseTerm {} - | ResetTerm {} - | ReturnTerm {} - | SignalTerm {} - | SleepTerm {} - | StallTerm {} - | SwitchTerm {} - | UnloadTerm {} - | WhileTerm {} - ; - -Type2Opcode - : AcquireTerm {} - | CondRefOfTerm {} - | CopyObjectTerm {} - | DerefOfTerm {} - | ObjectTypeTerm {} - | RefOfTerm {} - | SizeOfTerm {} - | StoreTerm {} - | TimerTerm {} - | WaitTerm {} - | UserTerm {} - ; - -/* - * Type 3/4/5 opcodes - */ - -Type2IntegerOpcode /* "Type3" opcodes */ - : AddTerm {} - | AndTerm {} - | DecTerm {} - | DivideTerm {} - | FindSetLeftBitTerm {} - | FindSetRightBitTerm {} - | FromBCDTerm {} - | IncTerm {} - | IndexTerm {} - | LAndTerm {} - | LEqualTerm {} - | LGreaterTerm {} - | LGreaterEqualTerm {} - | LLessTerm {} - | LLessEqualTerm {} - | LNotTerm {} - | LNotEqualTerm {} - | LoadTableTerm {} - | LOrTerm {} - | MatchTerm {} - | ModTerm {} - | MultiplyTerm {} - | NAndTerm {} - | NOrTerm {} - | NotTerm {} - | OrTerm {} - | ShiftLeftTerm {} - | ShiftRightTerm {} - | SubtractTerm {} - | ToBCDTerm {} - | ToIntegerTerm {} - | XOrTerm {} - ; - -Type2StringOpcode /* "Type4" Opcodes */ - : ToDecimalStringTerm {} - | ToHexStringTerm {} - | ToStringTerm {} - ; - -Type2BufferOpcode /* "Type5" Opcodes */ - : ToBufferTerm {} - | ConcatResTerm {} - ; - -Type2BufferOrStringOpcode - : ConcatTerm {} - | MidTerm {} - ; - -/* - * A type 3 opcode evaluates to an Integer and cannot have a destination operand - */ - -Type3Opcode - : EISAIDTerm {} - ; - -/* Obsolete -Type4Opcode - : ConcatTerm {} - | ToDecimalStringTerm {} - | ToHexStringTerm {} - | MidTerm {} - | ToStringTerm {} - ; -*/ - - -Type5Opcode - : ResourceTemplateTerm {} - | UnicodeTerm {} - | ToUUIDTerm {} - ; - -Type6Opcode - : RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - | UserTerm {} - ; - -IncludeTerm - : PARSEOP_INCLUDE '(' {$$ = TrCreateLeafNode (PARSEOP_INCLUDE);} - String ')' {TrLinkChildren ($3,1,$4);FlOpenIncludeFile ($4);} - TermList - IncludeEndTerm {$$ = TrLinkPeerNodes (3,$3,$7,$8);} - ; - -IncludeEndTerm - : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);} - ; - -ExternalTerm - : PARSEOP_EXTERNAL '(' - NameString - OptionalObjectTypeKeyword - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} - | PARSEOP_EXTERNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Named Objects *******************************************************/ - - -BankFieldTerm - : PARSEOP_BANKFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} - NameString - NameStringItem - TermArgItem - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($3,7,$4,$5,$6,$8,$10,$12,$15);} - | PARSEOP_BANKFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -FieldUnitList - : {$$ = NULL;} - | FieldUnit - | FieldUnitList ',' /* Allows a trailing comma at list end */ - | FieldUnitList ',' - FieldUnit {$$ = TrLinkPeerNode ($1,$3);} - ; - -FieldUnit - : FieldUnitEntry {} - | OffsetTerm {} - | AccessAsTerm {} - | ConnectionTerm {} - ; - -FieldUnitEntry - : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} - | NameSeg ',' - AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} - ; - -OffsetTerm - : PARSEOP_OFFSET '(' - AmlPackageLengthTerm - ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} - | PARSEOP_OFFSET '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -AccessAsTerm - : PARSEOP_ACCESSAS '(' - AccessTypeKeyword - OptionalAccessAttribTerm - ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} - | PARSEOP_ACCESSAS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ConnectionTerm - : PARSEOP_CONNECTION '(' - NameString - ')' {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);} - | PARSEOP_CONNECTION '(' {$$ = TrCreateLeafNode (PARSEOP_CONNECTION);} - ResourceMacroTerm - ')' {$$ = TrLinkChildren ($3, 1, - TrLinkChildren (TrCreateLeafNode (PARSEOP_RESOURCETEMPLATE), 3, - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - $4));} - | PARSEOP_CONNECTION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateBitFieldTerm - : PARSEOP_CREATEBITFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} - TermArg - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBITFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateByteFieldTerm - : PARSEOP_CREATEBYTEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);} - TermArg - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBYTEFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateDWordFieldTerm - : PARSEOP_CREATEDWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);} - TermArg - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEDWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateFieldTerm - : PARSEOP_CREATEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);} - TermArg - TermArgItem - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateQWordFieldTerm - : PARSEOP_CREATEQWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);} - TermArg - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEQWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CreateWordFieldTerm - : PARSEOP_CREATEWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);} - TermArg - TermArgItem - NameStringItem - ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} - | PARSEOP_CREATEWORDFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DataRegionTerm - : PARSEOP_DATATABLEREGION '(' {$$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);} - NameString - TermArgItem - TermArgItem - TermArgItem - ')' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);} - | PARSEOP_DATATABLEREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DeviceTerm - : PARSEOP_DEVICE '(' {$$ = TrCreateLeafNode (PARSEOP_DEVICE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_DEVICE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -EventTerm - : PARSEOP_EVENT '(' {$$ = TrCreateLeafNode (PARSEOP_EVENT);} - NameString - ')' {$$ = TrLinkChildren ($3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} - | PARSEOP_EVENT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FieldTerm - : PARSEOP_FIELD '(' {$$ = TrCreateLeafNode (PARSEOP_FIELD);} - NameString - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$8,$10,$13);} - | PARSEOP_FIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -FunctionTerm - : PARSEOP_FUNCTION '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} - NameString - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' '{' - TermList '}' {$$ = TrLinkChildren ($3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), - TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} - | PARSEOP_FUNCTION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IndexFieldTerm - : PARSEOP_INDEXFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} - NameString - NameStringItem - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($3,6,$4,$5,$7,$9,$11,$14);} - | PARSEOP_INDEXFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -MethodTerm - : PARSEOP_METHOD '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} - NameString - OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} - OptionalSerializeRuleKeyword - OptionalByteConstExpr - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' '{' - TermList '}' {$$ = TrLinkChildren ($3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} - | PARSEOP_METHOD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MutexTerm - : PARSEOP_MUTEX '(' {$$ = TrCreateLeafNode (PARSEOP_MUTEX);} - NameString - ',' ByteConstExpr - ')' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_MUTEX '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -OpRegionTerm - : PARSEOP_OPERATIONREGION '(' {$$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} - NameString - ',' OpRegionSpaceIdTerm - TermArgItem - TermArgItem - ')' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} - | PARSEOP_OPERATIONREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -OpRegionSpaceIdTerm - : RegionSpaceKeyword {} - | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PowerResTerm - : PARSEOP_POWERRESOURCE '(' {$$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} - NameString - ',' ByteConstExpr - ',' WordConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} - | PARSEOP_POWERRESOURCE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ProcessorTerm - : PARSEOP_PROCESSOR '(' {$$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} - NameString - ',' ByteConstExpr - OptionalDWordConstExpr - OptionalByteConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} - | PARSEOP_PROCESSOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ThermalZoneTerm - : PARSEOP_THERMALZONE '(' {$$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_THERMALZONE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Namespace modifiers *************************************************/ - - -AliasTerm - : PARSEOP_ALIAS '(' {$$ = TrCreateLeafNode (PARSEOP_ALIAS);} - NameString - NameStringItem - ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} - | PARSEOP_ALIAS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NameTerm - : PARSEOP_NAME '(' {$$ = TrCreateLeafNode (PARSEOP_NAME);} - NameString - ',' DataObject - ')' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_NAME '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ScopeTerm - : PARSEOP_SCOPE '(' {$$ = TrCreateLeafNode (PARSEOP_SCOPE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_SCOPE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Type 1 opcodes *******************************************************/ - - -BreakTerm - : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} - ; - -BreakPointTerm - : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} - ; - -ContinueTerm - : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} - ; - -FatalTerm - : PARSEOP_FATAL '(' {$$ = TrCreateLeafNode (PARSEOP_FATAL);} - ByteConstExpr - ',' DWordConstExpr - TermArgItem - ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} - | PARSEOP_FATAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IfElseTerm - : IfTerm ElseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -IfTerm - : PARSEOP_IF '(' {$$ = TrCreateLeafNode (PARSEOP_IF);} - TermArg - ')' '{' - TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - - | PARSEOP_IF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ElseTerm - : {$$ = NULL;} - | PARSEOP_ELSE '{' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} - TermList '}' {$$ = TrLinkChildren ($3,1,$4);} - - | PARSEOP_ELSE '{' - error '}' {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSE - error {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} - TermArg {$$ = TrCreateLeafNode (PARSEOP_IF);} - ')' '{' - TermList '}' {TrLinkChildren ($5,2,$4,$8);} - ElseTerm {TrLinkPeerNode ($5,$11);} - {$$ = TrLinkChildren ($3,1,$5);} - - | PARSEOP_ELSEIF '(' - error ')' {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSEIF - error {$$ = AslDoError(); yyclearin;} - ; - -LoadTerm - : PARSEOP_LOAD '(' {$$ = TrCreateLeafNode (PARSEOP_LOAD);} - NameString - RequiredTarget - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NoOpTerm - : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} - ; - -NotifyTerm - : PARSEOP_NOTIFY '(' {$$ = TrCreateLeafNode (PARSEOP_NOTIFY);} - SuperName - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_NOTIFY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReleaseTerm - : PARSEOP_RELEASE '(' {$$ = TrCreateLeafNode (PARSEOP_RELEASE);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_RELEASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ResetTerm - : PARSEOP_RESET '(' {$$ = TrCreateLeafNode (PARSEOP_RESET);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_RESET '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReturnTerm - : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);} - OptionalReturnArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} - | PARSEOP_RETURN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SignalTerm - : PARSEOP_SIGNAL '(' {$$ = TrCreateLeafNode (PARSEOP_SIGNAL);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SIGNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SleepTerm - : PARSEOP_SLEEP '(' {$$ = TrCreateLeafNode (PARSEOP_SLEEP);} - TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SLEEP '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StallTerm - : PARSEOP_STALL '(' {$$ = TrCreateLeafNode (PARSEOP_STALL);} - TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_STALL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SwitchTerm - : PARSEOP_SWITCH '(' {$$ = TrCreateLeafNode (PARSEOP_SWITCH);} - TermArg - ')' '{' - CaseDefaultTermList '}' - {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_SWITCH '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -/* - * Case-Default list; allow only one Default term and unlimited Case terms - */ - -CaseDefaultTermList - : {$$ = NULL;} - | CaseTerm {} - | DefaultTerm {} - | CaseDefaultTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - | CaseDefaultTermList - DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} - -/* Original - attempts to force zero or one default term within the switch */ - -/* -CaseDefaultTermList - : {$$ = NULL;} - | CaseTermList - DefaultTerm - CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -CaseTermList - : {$$ = NULL;} - | CaseTerm {} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; -*/ - -CaseTerm - : PARSEOP_CASE '(' {$$ = TrCreateLeafNode (PARSEOP_CASE);} - DataObject - ')' '{' - TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_CASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DefaultTerm - : PARSEOP_DEFAULT '{' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT);} - TermList '}' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_DEFAULT '{' - error '}' {$$ = AslDoError(); yyclearin;} - ; - -UnloadTerm - : PARSEOP_UNLOAD '(' {$$ = TrCreateLeafNode (PARSEOP_UNLOAD);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_UNLOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WhileTerm - : PARSEOP_WHILE '(' {$$ = TrCreateLeafNode (PARSEOP_WHILE);} - TermArg - ')' '{' TermList '}' - {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_WHILE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Type 2 opcodes *******************************************************/ - -AcquireTerm - : PARSEOP_ACQUIRE '(' {$$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} - SuperName - ',' WordConstExpr - ')' {$$ = TrLinkChildren ($3,2,$4,$6);} - | PARSEOP_ACQUIRE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -AddTerm - : PARSEOP_ADD '(' {$$ = TrCreateLeafNode (PARSEOP_ADD);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_ADD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -AndTerm - : PARSEOP_AND '(' {$$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_AND '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ConcatTerm - : PARSEOP_CONCATENATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ConcatResTerm - : PARSEOP_CONCATENATERESTEMPLATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATERESTEMPLATE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CondRefOfTerm - : PARSEOP_CONDREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} - SuperName - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_CONDREFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -CopyObjectTerm - : PARSEOP_COPYOBJECT '(' {$$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} - TermArg - ',' SimpleTarget - ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_COPYOBJECT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DecTerm - : PARSEOP_DECREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_DECREMENT);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_DECREMENT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DerefOfTerm - : PARSEOP_DEREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_DEREFOF);} - TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_DEREFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DivideTerm - : PARSEOP_DIVIDE '(' {$$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg - TermArgItem - Target - Target - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_DIVIDE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FindSetLeftBitTerm - : PARSEOP_FINDSETLEFTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETLEFTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FindSetRightBitTerm - : PARSEOP_FINDSETRIGHTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETRIGHTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FromBCDTerm - : PARSEOP_FROMBCD '(' {$$ = TrCreateLeafNode (PARSEOP_FROMBCD);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_FROMBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IncTerm - : PARSEOP_INCREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_INCREMENT);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_INCREMENT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IndexTerm - : PARSEOP_INDEX '(' {$$ = TrCreateLeafNode (PARSEOP_INDEX);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_INDEX '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LAndTerm - : PARSEOP_LAND '(' {$$ = TrCreateLeafNode (PARSEOP_LAND);} - TermArg - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LAND '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LEqualTerm - : PARSEOP_LEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} - TermArg - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LGreaterTerm - : PARSEOP_LGREATER '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} - TermArg - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LGREATER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LGreaterEqualTerm - : PARSEOP_LGREATEREQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} - TermArg - TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LGREATEREQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LLessTerm - : PARSEOP_LLESS '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} - TermArg - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LLESS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LLessEqualTerm - : PARSEOP_LLESSEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} - TermArg - TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LLESSEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LNotTerm - : PARSEOP_LNOT '(' {$$ = TrCreateLeafNode (PARSEOP_LNOT);} - TermArg - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_LNOT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LNotEqualTerm - : PARSEOP_LNOTEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} - TermArg - TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} - | PARSEOP_LNOTEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LoadTableTerm - : PARSEOP_LOADTABLE '(' {$$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} - TermArg - TermArgItem - TermArgItem - OptionalListString - OptionalListString - OptionalReference - ')' {$$ = TrLinkChildren ($3,6,$4,$5,$6,$7,$8,$9);} - | PARSEOP_LOADTABLE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -LOrTerm - : PARSEOP_LOR '(' {$$ = TrCreateLeafNode (PARSEOP_LOR);} - TermArg - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_LOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MatchTerm - : PARSEOP_MATCH '(' {$$ = TrCreateLeafNode (PARSEOP_MATCH);} - TermArg - ',' MatchOpKeyword - TermArgItem - ',' MatchOpKeyword - TermArgItem - TermArgItem - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$7,$9,$10,$11);} - | PARSEOP_MATCH '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MidTerm - : PARSEOP_MID '(' {$$ = TrCreateLeafNode (PARSEOP_MID);} - TermArg - TermArgItem - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_MID '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ModTerm - : PARSEOP_MOD '(' {$$ = TrCreateLeafNode (PARSEOP_MOD);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_MOD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MultiplyTerm - : PARSEOP_MULTIPLY '(' {$$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_MULTIPLY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NAndTerm - : PARSEOP_NAND '(' {$$ = TrCreateLeafNode (PARSEOP_NAND);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_NAND '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NOrTerm - : PARSEOP_NOR '(' {$$ = TrCreateLeafNode (PARSEOP_NOR);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_NOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NotTerm - : PARSEOP_NOT '(' {$$ = TrCreateLeafNode (PARSEOP_NOT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_NOT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ObjectTypeTerm - : PARSEOP_OBJECTTYPE '(' {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);} - ObjectTypeName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_OBJECTTYPE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -OrTerm - : PARSEOP_OR '(' {$$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_OR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -/* - * In RefOf, the node isn't really a target, but we can't keep track of it after - * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) - */ -RefOfTerm - : PARSEOP_REFOF '(' {$$ = TrCreateLeafNode (PARSEOP_REFOF);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,TrSetNodeFlags ($4, NODE_IS_TARGET));} - | PARSEOP_REFOF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ShiftLeftTerm - : PARSEOP_SHIFTLEFT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTLEFT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ShiftRightTerm - : PARSEOP_SHIFTRIGHT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTRIGHT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SizeOfTerm - : PARSEOP_SIZEOF '(' {$$ = TrCreateLeafNode (PARSEOP_SIZEOF);} - SuperName - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_SIZEOF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StoreTerm - : PARSEOP_STORE '(' {$$ = TrCreateLeafNode (PARSEOP_STORE);} - TermArg - ',' SuperName - ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_STORE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SubtractTerm - : PARSEOP_SUBTRACT '(' {$$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_SUBTRACT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -TimerTerm - : PARSEOP_TIMER '(' {$$ = TrCreateLeafNode (PARSEOP_TIMER);} - ')' {$$ = TrLinkChildren ($3,0);} - | PARSEOP_TIMER {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_TIMER),0);} - | PARSEOP_TIMER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToBCDTerm - : PARSEOP_TOBCD '(' {$$ = TrCreateLeafNode (PARSEOP_TOBCD);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToBufferTerm - : PARSEOP_TOBUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_TOBUFFER);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOBUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToDecimalStringTerm - : PARSEOP_TODECIMALSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TODECIMALSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToHexStringTerm - : PARSEOP_TOHEXSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOHEXSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToIntegerTerm - : PARSEOP_TOINTEGER '(' {$$ = TrCreateLeafNode (PARSEOP_TOINTEGER);} - TermArg - Target - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_TOINTEGER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToStringTerm - : PARSEOP_TOSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOSTRING);} - TermArg - OptionalCount - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_TOSTRING '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ToUUIDTerm - : PARSEOP_TOUUID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);} - | PARSEOP_TOUUID '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WaitTerm - : PARSEOP_WAIT '(' {$$ = TrCreateLeafNode (PARSEOP_WAIT);} - SuperName - TermArgItem - ')' {$$ = TrLinkChildren ($3,2,$4,$5);} - | PARSEOP_WAIT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -XOrTerm - : PARSEOP_XOR '(' {$$ = TrCreateLeafNode (PARSEOP_XOR);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} - | PARSEOP_XOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Keywords *************************************************************/ - - -AccessAttribKeyword - : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} - | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} - | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} - | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} - | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} - | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} - | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} - | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} - ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} - ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} - ByteConst - ')' {$$ = TrLinkChildren ($3,1,$4);} - ; - -AccessTypeKeyword - : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} - | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} - | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} - | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} - | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} - | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} - ; - -AddressingModeKeyword - : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} - | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} - ; - -AddressKeyword - : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} - | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} - | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} - | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} - ; - -AddressSpaceKeyword - : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} - | RegionSpaceKeyword {} - ; - -BitsPerByteKeyword - : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} - | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} - | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} - | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} - | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} - ; - -ClockPhaseKeyword - : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} - | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} - ; - -ClockPolarityKeyword - : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} - | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} - ; - -DecodeKeyword - : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} - | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} - ; - -DevicePolarityKeyword - : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} - | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} - ; - -DMATypeKeyword - : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} - | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} - | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} - | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} - ; - -EndianKeyword - : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} - | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} - ; - -FlowControlKeyword - : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} - | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} - | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} - ; - -InterruptLevel - : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} - | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} - | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} - ; - -InterruptTypeKeyword - : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} - | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} - ; - -IODecodeKeyword - : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} - | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} - ; - -IoRestrictionKeyword - : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} - | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} - | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} - | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} - ; - -LockRuleKeyword - : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} - | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} - ; - -MatchOpKeyword - : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} - | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} - | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} - | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} - | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} - | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} - ; - -MaxKeyword - : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} - | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} - ; - -MemTypeKeyword - : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} - | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} - | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} - | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} - ; - -MinKeyword - : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} - | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} - ; - -ObjectTypeKeyword - : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} - | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} - | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} - | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} - | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} - | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} - | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} - | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} - | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} - | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} - | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} - | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} - | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} - | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} - | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} - ; - -ParityTypeKeyword - : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} - | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} - | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} - | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} - | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} - ; - -PinConfigByte - : PinConfigKeyword {$$ = $1;} - | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PinConfigKeyword - : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} - | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} - | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} - | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} - ; - -RangeTypeKeyword - : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} - | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} - | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} - ; - -RegionSpaceKeyword - : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} - | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} - | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} - | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} - | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} - | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} - | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} - | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} - | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} - | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} - | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} - | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} - ; - -ResourceTypeKeyword - : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} - ; - -SerializeRuleKeyword - : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} - | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} - ; - -ShareTypeKeyword - : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} - | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} - | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} - | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} - ; - -SlaveModeKeyword - : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} - | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} - ; - -StopBitsKeyword - : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} - | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} - | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} - | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} - ; - -TranslationKeyword - : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} - | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} - ; - -TypeKeyword - : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} - | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} - ; - -UpdateRuleKeyword - : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} - | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} - | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} - ; - -WireModeKeyword - : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} - | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} - ; - -XferSizeKeyword - : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} - | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} - | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} - | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} - | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} - ; - -XferTypeKeyword - : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} - | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} - | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} - ; - - -/******* Miscellaneous Types **************************************************/ - - -SuperName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | Type6Opcode {} - -/* For ObjectType: SuperName except for UserTerm (method invocation) */ - -ObjectTypeName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - -/* | UserTerm {} */ /* Caused reduce/reduce with Type6Opcode->UserTerm */ - ; - -ArgTerm - : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} - | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} - | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} - | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} - | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} - | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} - | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} - ; - -LocalTerm - : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} - | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} - | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} - | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} - | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} - | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} - | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} - | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} - ; - -DebugTerm - : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} - ; - - -ByteConst - : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - ; - -WordConst - : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - ; - -DWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - ; - -QWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - ; - -Integer - : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} - ; - -String - : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - -ConstTerm - : ConstExprTerm {} - | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} - ; - -ConstExprTerm - : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} - | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} - | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} - | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} - | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} - | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} - | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} - ; - -/* - * The NODE_COMPILE_TIME_CONST flag in the following constant expressions - * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes - * to simple integers. It is an error if these types of expressions cannot be - * reduced, since the AML grammar for ****ConstExpr requires a simple constant. - * Note: The required byte length of the constant is passed through to the - * constant folding code in the node AmlLength field. - */ -ByteConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - | ByteConst {} - ; - -WordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - | WordConst {} - ; - -DWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - | DWordConst {} - ; - -QWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - | QWordConst {} - ; - -/* OptionalCount must appear before ByteList or an incorrect reduction will result */ - -OptionalCount - : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' TermArg {$$ = $2;} - ; - -BufferTerm - : PARSEOP_BUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_BUFFER);} - OptionalTermArg - ')' '{' - BufferTermData '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_BUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -BufferTermData - : ByteList {} - | StringData {} - ; - -ByteList - : {$$ = NULL;} - | ByteConstExpr - | ByteList ',' /* Allows a trailing comma at list end */ - | ByteList ',' - ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -DataBufferTerm - : PARSEOP_DATABUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} - OptionalWordConst - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_DATABUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordList - : {$$ = NULL;} - | DWordConstExpr - | DWordList ',' /* Allows a trailing comma at list end */ - | DWordList ',' - DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageTerm - : PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} - VarPackageLengthTerm - ')' '{' - PackageList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_PACKAGE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -PackageList - : {$$ = NULL;} - | PackageElement - | PackageList ',' /* Allows a trailing comma at list end */ - | PackageList ',' - PackageElement {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageElement - : DataObject {} - | NameString {} - ; - -VarPackageLengthTerm - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | TermArg {$$ = $1;} - ; - - -/******* Macros ***********************************************/ - - -EISAIDTerm - : PARSEOP_EISAID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} - | PARSEOP_EISAID '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UnicodeTerm - : PARSEOP_UNICODE '(' {$$ = TrCreateLeafNode (PARSEOP_UNICODE);} - StringData - ')' {$$ = TrLinkChildren ($3,2,0,$4);} - | PARSEOP_UNICODE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Resources and Memory ***********************************************/ - - -/* - * Note: Create two default nodes to allow conversion to a Buffer AML opcode - * Also, insert the EndTag at the end of the template. - */ -ResourceTemplateTerm - : PARSEOP_RESOURCETEMPLATE '(' ')' - '{' - ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - $5, - TrCreateLeafNode (PARSEOP_ENDTAG));} - ; - -ResourceMacroList - : {$$ = NULL;} - | ResourceMacroList - ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -ResourceMacroTerm - : DMATerm {} - | DWordIOTerm {} - | DWordMemoryTerm {} - | DWordSpaceTerm {} - | EndDependentFnTerm {} - | ExtendedIOTerm {} - | ExtendedMemoryTerm {} - | ExtendedSpaceTerm {} - | FixedDmaTerm {} - | FixedIOTerm {} - | GpioIntTerm {} - | GpioIoTerm {} - | I2cSerialBusTerm {} - | InterruptTerm {} - | IOTerm {} - | IRQNoFlagsTerm {} - | IRQTerm {} - | Memory24Term {} - | Memory32FixedTerm {} - | Memory32Term {} - | QWordIOTerm {} - | QWordMemoryTerm {} - | QWordSpaceTerm {} - | RegisterTerm {} - | SpiSerialBusTerm {} - | StartDependentFnNoPriTerm {} - | StartDependentFnTerm {} - | UartSerialBusTerm {} - | VendorLongTerm {} - | VendorShortTerm {} - | WordBusNumberTerm {} - | WordIOTerm {} - | WordSpaceTerm {} - ; - -DMATerm - : PARSEOP_DMA '(' {$$ = TrCreateLeafNode (PARSEOP_DMA);} - DMATypeKeyword - OptionalBusMasterKeyword - ',' XferTypeKeyword - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$5,$7,$8,$11);} - | PARSEOP_DMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordIOTerm - : PARSEOP_DWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_DWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordMemoryTerm - : PARSEOP_DWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_DWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordSpaceTerm - : PARSEOP_DWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_DWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -EndDependentFnTerm - : PARSEOP_ENDDEPENDENTFN '(' - ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} - | PARSEOP_ENDDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedIOTerm - : PARSEOP_EXTENDEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} - | PARSEOP_EXTENDEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedMemoryTerm - : PARSEOP_EXTENDEDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} - | PARSEOP_EXTENDEDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedSpaceTerm - : PARSEOP_EXTENDEDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} - | PARSEOP_EXTENDEDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedDmaTerm - : PARSEOP_FIXEDDMA '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} - WordConstExpr /* 04: DMA RequestLines */ - ',' WordConstExpr /* 06: DMA Channels */ - OptionalXferSize /* 07: DMA TransferSize */ - OptionalNameString /* 08: DescriptorName */ - ')' {$$ = TrLinkChildren ($3,4,$4,$6,$7,$8);} - | PARSEOP_FIXEDDMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedIOTerm - : PARSEOP_FIXEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} - WordConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} - | PARSEOP_FIXEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIntTerm - : PARSEOP_GPIO_INT '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} - InterruptTypeKeyword /* 04: InterruptType */ - ',' InterruptLevel /* 06: InterruptLevel */ - OptionalShareType /* 07: SharedType */ - ',' PinConfigByte /* 09: PinConfig */ - OptionalWordConstExpr /* 10: DebounceTimeout */ - ',' StringData /* 12: ResourceSource */ - OptionalByteConstExpr /* 13: ResourceSourceIndex */ - OptionalResourceType /* 14: ResourceType */ - OptionalNameString /* 15: DescriptorName */ - OptionalBuffer_Last /* 16: VendorData */ - ')' '{' - DWordConstExpr '}' {$$ = TrLinkChildren ($3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} - | PARSEOP_GPIO_INT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIoTerm - : PARSEOP_GPIO_IO '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} - OptionalShareType_First /* 04: SharedType */ - ',' PinConfigByte /* 06: PinConfig */ - OptionalWordConstExpr /* 07: DebounceTimeout */ - OptionalWordConstExpr /* 08: DriveStrength */ - OptionalIoRestriction /* 09: IoRestriction */ - ',' StringData /* 11: ResourceSource */ - OptionalByteConstExpr /* 12: ResourceSourceIndex */ - OptionalResourceType /* 13: ResourceType */ - OptionalNameString /* 14: DescriptorName */ - OptionalBuffer_Last /* 15: VendorData */ - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} - | PARSEOP_GPIO_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -I2cSerialBusTerm - : PARSEOP_I2C_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} - WordConstExpr /* 04: SlaveAddress */ - OptionalSlaveMode /* 05: SlaveMode */ - ',' DWordConstExpr /* 07: ConnectionSpeed */ - OptionalAddressingMode /* 08: AddressingMode */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - ')' {$$ = TrLinkChildren ($3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);} - | PARSEOP_I2C_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -InterruptTerm - : PARSEOP_INTERRUPT '(' {$$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} - OptionalResourceType_First - ',' InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($3,8,$4,$6,$8,$9,$10,$11,$12,$15);} - | PARSEOP_INTERRUPT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IOTerm - : PARSEOP_IO '(' {$$ = TrCreateLeafNode (PARSEOP_IO);} - IODecodeKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' ByteConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQNoFlagsTerm - : PARSEOP_IRQNOFLAGS '(' {$$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_IRQNOFLAGS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQTerm - : PARSEOP_IRQ '(' {$$ = TrCreateLeafNode (PARSEOP_IRQ);} - InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$7,$8,$11);} - | PARSEOP_IRQ '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory24Term - : PARSEOP_MEMORY24 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);} - OptionalReadWriteKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY24 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32FixedTerm - : PARSEOP_MEMORY32FIXED '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,4,$4,$6,$8,$9);} - | PARSEOP_MEMORY32FIXED '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32Term - : PARSEOP_MEMORY32 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY32 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordIOTerm - : PARSEOP_QWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_QWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordMemoryTerm - : PARSEOP_QWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_QWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordSpaceTerm - : PARSEOP_QWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_QWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -RegisterTerm - : PARSEOP_REGISTER '(' {$$ = TrCreateLeafNode (PARSEOP_REGISTER);} - AddressSpaceKeyword - ',' ByteConstExpr - ',' ByteConstExpr - ',' QWordConstExpr - OptionalAccessSize - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$11,$12);} - | PARSEOP_REGISTER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SpiSerialBusTerm - : PARSEOP_SPI_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} - WordConstExpr /* 04: DeviceSelection */ - OptionalDevicePolarity /* 05: DevicePolarity */ - OptionalWireMode /* 06: WireMode */ - ',' ByteConstExpr /* 08: DataBitLength */ - OptionalSlaveMode /* 09: SlaveMode */ - ',' DWordConstExpr /* 11: ConnectionSpeed */ - ',' ClockPolarityKeyword /* 13: ClockPolarity */ - ',' ClockPhaseKeyword /* 15: ClockPhase */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_SPI_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnNoPriTerm - : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($3,1,$6);} - | PARSEOP_STARTDEPENDENTFN_NOPRI '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnTerm - : PARSEOP_STARTDEPENDENTFN '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} - ByteConstExpr - ',' ByteConstExpr - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($3,3,$4,$6,$9);} - | PARSEOP_STARTDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UartSerialBusTerm - : PARSEOP_UART_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} - DWordConstExpr /* 04: ConnectionSpeed */ - OptionalBitsPerByte /* 05: BitsPerByte */ - OptionalStopBits /* 06: StopBits */ - ',' ByteConstExpr /* 08: LinesInUse */ - OptionalEndian /* 09: Endianess */ - OptionalParityType /* 10: Parity */ - OptionalFlowControl /* 11: FlowControl */ - ',' WordConstExpr /* 13: Rx BufferSize */ - ',' WordConstExpr /* 15: Tx BufferSize */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_UART_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorLongTerm - : PARSEOP_VENDORLONG '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_VENDORLONG '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorShortTerm - : PARSEOP_VENDORSHORT '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} - | PARSEOP_VENDORSHORT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordBusNumberTerm - : PARSEOP_WORDBUSNUMBER '(' {$$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} - | PARSEOP_WORDBUSNUMBER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordIOTerm - : PARSEOP_WORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_WORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_WORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordSpaceTerm - : PARSEOP_WORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_WORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Object References ***********************************************/ - -/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ - -NameString - : NameSeg {} - | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} - | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} - | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} - | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} - ; - -NameSeg - : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - - -/******* Helper rules ****************************************************/ - - -AmlPackageLengthTerm - : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);} - ; - -NameStringItem - : ',' NameString {$$ = $2;} - | ',' error {$$ = AslDoError (); yyclearin;} - ; - -TermArgItem - : ',' TermArg {$$ = $2;} - | ',' error {$$ = AslDoError (); yyclearin;} - ; - -OptionalBusMasterKeyword - : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} - ; - -OptionalAccessAttribTerm - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - | ',' AccessAttribKeyword {$$ = $2;} - ; - -OptionalAccessSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalAddressingMode - : ',' {$$ = NULL;} - | ',' AddressingModeKeyword {$$ = $2;} - ; - -OptionalAddressRange - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' AddressKeyword {$$ = $2;} - ; - -OptionalBitsPerByte - : ',' {$$ = NULL;} - | ',' BitsPerByteKeyword {$$ = $2;} - ; - -OptionalBuffer_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DataBufferTerm {$$ = $2;} - ; - -OptionalByteConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalDecodeType - : ',' {$$ = NULL;} - | ',' DecodeKeyword {$$ = $2;} - ; - -OptionalDevicePolarity - : ',' {$$ = NULL;} - | ',' DevicePolarityKeyword {$$ = $2;} - ; - -OptionalDWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DWordConstExpr {$$ = $2;} - ; - -OptionalEndian - : ',' {$$ = NULL;} - | ',' EndianKeyword {$$ = $2;} - ; - -OptionalFlowControl - : ',' {$$ = NULL;} - | ',' FlowControlKeyword {$$ = $2;} - ; - -OptionalIoRestriction - : ',' {$$ = NULL;} - | ',' IoRestrictionKeyword {$$ = $2;} - ; - -OptionalListString - : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' TermArg {$$ = $2;} - ; - -OptionalMaxType - : ',' {$$ = NULL;} - | ',' MaxKeyword {$$ = $2;} - ; - -OptionalMemType - : ',' {$$ = NULL;} - | ',' MemTypeKeyword {$$ = $2;} - ; - -OptionalMinType - : ',' {$$ = NULL;} - | ',' MinKeyword {$$ = $2;} - ; - -OptionalNameString - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_First - : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} - | NameString {$$ = $1;} - ; - -OptionalObjectTypeKeyword - : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | ',' ObjectTypeKeyword {$$ = $2;} - ; - -OptionalParityType - : ',' {$$ = NULL;} - | ',' ParityTypeKeyword {$$ = $2;} - ; - -OptionalQWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' QWordConstExpr {$$ = $2;} - ; - -OptionalRangeType - : ',' {$$ = NULL;} - | ',' RangeTypeKeyword {$$ = $2;} - ; - -OptionalReadWriteKeyword - : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} - ; - -OptionalReference - : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ - | ',' TermArg {$$ = $2;} - ; - -OptionalResourceType_First - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ResourceTypeKeyword {$$ = $1;} - ; - -OptionalResourceType - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' ResourceTypeKeyword {$$ = $2;} - ; - -OptionalReturnArg - : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ - | TermArg {$$ = $1;} - ; - -OptionalSerializeRuleKeyword - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' SerializeRuleKeyword {$$ = $2;} - ; - -OptionalSlaveMode - : ',' {$$ = NULL;} - | ',' SlaveModeKeyword {$$ = $2;} - ; - -OptionalShareType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ShareTypeKeyword {$$ = $2;} - ; - -OptionalShareType_First - : {$$ = NULL;} - | ShareTypeKeyword {$$ = $1;} - ; - -OptionalStopBits - : ',' {$$ = NULL;} - | ',' StopBitsKeyword {$$ = $2;} - ; - -OptionalStringData - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' StringData {$$ = $2;} - ; - -OptionalTermArg - : {$$ = NULL;} - | TermArg {$$ = $1;} - ; - -OptionalType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalTranslationType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TranslationKeyword {$$ = $2;} - ; - -OptionalWireMode - : ',' {$$ = NULL;} - | ',' WireModeKeyword {$$ = $2;} - ; - -OptionalWordConst - : {$$ = NULL;} - | WordConst {$$ = $1;} - ; - -OptionalWordConstExpr - : ',' {$$ = NULL;} - | ',' WordConstExpr {$$ = $2;} - ; - -OptionalXferSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' XferSizeKeyword {$$ = $2;} - ; - -%% -/****************************************************************************** - * - * Local support functions - * - *****************************************************************************/ - -int -AslCompilerwrap(void) -{ - return (1); -} - -/*! [End] no source code translation !*/ - -void * -AslLocalAllocate (unsigned int Size) -{ - void *Mem; - - - DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); - - Mem = ACPI_ALLOCATE_ZEROED (Size); - if (!Mem) - { - AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_InputByteCount, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); - exit (1); - } - - return (Mem); -} - -ACPI_PARSE_OBJECT * -AslDoError (void) -{ - - - return (TrCreateLeafNode (PARSEOP_ERRORNODE)); - -} - - -/******************************************************************************* - * - * FUNCTION: UtGetOpName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * - * RETURN: Pointer to the opcode name - * - * DESCRIPTION: Get the ascii name of the parse opcode - * - ******************************************************************************/ - -char * -UtGetOpName ( - UINT32 ParseOpcode) -{ -#ifdef ASL_YYTNAME_START - /* - * First entries (ASL_YYTNAME_START) in yytname are special reserved names. - * Ignore first 8 characters of the name - */ - return ((char *) yytname - [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); -#else - return ("[Unknown parser generator]"); -#endif -} diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 9e42a302563f..c76b4a070b27 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLDEFINE_H #define __ASLDEFINE_H @@ -55,14 +54,14 @@ #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0A" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.1" /* Configuration constants */ #define ASL_MAX_ERROR_COUNT 200 -#define ASL_NODE_CACHE_SIZE 1024 -#define ASL_STRING_CACHE_SIZE 32768 +#define ASL_PARSEOP_CACHE_SIZE (1024 * 16) +#define ASL_STRING_CACHE_SIZE (1024 * 64) #define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS #define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */ diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 14ca99d02ba1..fee96ec0ae26 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -557,7 +557,7 @@ AslCommonError2 ( { /* Allocate a buffer for the message and a new error node */ - MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -571,7 +571,7 @@ AslCommonError2 ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -643,7 +643,7 @@ AslCommonError ( { /* Allocate a buffer for the message and a new error node */ - MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -654,7 +654,7 @@ AslCommonError ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 56d006b5ad7b..6bde7080f8c6 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -319,6 +319,8 @@ FlCloseFile ( AslAbort (); } + /* Do not clear/free the filename string */ + Gbl_Files[FileId].Handle = NULL; return; } diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 514c119d6b49..722e0ee9b620 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -107,6 +107,8 @@ FlSetFilename ( DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n", Filename, Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free any existing filename */ + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; } @@ -216,14 +218,14 @@ FlMergePathnames ( (*FilePathname == '/') || (FilePathname[1] == ':')) { - Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1); + Pathname = UtStringCacheCalloc (strlen (FilePathname) + 1); strcpy (Pathname, FilePathname); goto ConvertBackslashes; } /* Need a local copy of the prefix directory path */ - CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1); + CommonPath = UtStringCacheCalloc (strlen (PrefixDir) + 1); strcpy (CommonPath, PrefixDir); /* @@ -259,14 +261,13 @@ FlMergePathnames ( /* Build the final merged pathname */ ConcatenatePaths: - Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2); + Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2); if (LastElement && *CommonPath) { strcpy (Pathname, CommonPath); strcat (Pathname, "/"); } strcat (Pathname, FilePathname); - ACPI_FREE (CommonPath); /* Convert all backslashes to normal slashes */ diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index 5035c25a34ae..579997516ad1 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 2707f4da8d42..e347e694f86c 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLGLOBAL_H #define __ASLGLOBAL_H @@ -63,11 +62,6 @@ #ifdef _DECLARE_GLOBALS UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; -char AslHexLookup[] = -{ - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -}; - /* Table below must match ASL_FILE_TYPES in asltypes.h */ @@ -92,7 +86,6 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = #else extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern char AslHexLookup[]; extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; #endif @@ -102,12 +95,20 @@ extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; */ extern int yydebug; extern FILE *AslCompilerin; -extern int AslCompilerdebug; extern int DtParserdebug; extern int PrParserdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; extern char *AslCompilertext; +/* + * Older versions of Bison won't emit this external in the generated header. + * Newer versions do emit the external, so we don't need to do it. + */ +#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H +extern int AslCompilerdebug; +#endif + + #define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */ #define ASL_MSG_BUFFER_SIZE 4096 #define ASL_MAX_DISABLED_MESSAGES 32 @@ -207,6 +208,20 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocated, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0); +/* Local caches */ + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ParseOpCount, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_ParseOpCacheList, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheNext, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheLast, NULL); + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringCount, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringSize, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_StringCacheList, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); + + /* Misc */ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); @@ -215,10 +230,6 @@ ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0); ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c index 6405fada9e5b..38766a4db964 100644 --- a/source/compiler/aslhex.c +++ b/source/compiler/aslhex.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index c6938bd6d08d..13af96a00d37 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index 9b1b2afdf924..ff02d5362f05 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -129,6 +129,7 @@ LdLoadNamespace ( /* Dump the namespace if debug is enabled */ AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); + ACPI_FREE (WalkState); return (AE_OK); } diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index f0c79f7e8a6a..67c037e1eca8 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 3034281b3dcf..25dca949054a 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -327,6 +327,7 @@ main ( ACPI_STATUS Status; int Index1; int Index2; + int ReturnStatus = 0; /* @@ -392,16 +393,24 @@ main ( Status = AslDoOneFile (argv[Index2]); if (ACPI_FAILURE (Status)) { - return (-1); + ReturnStatus = -1; + goto CleanupAndExit; } Index2++; } + +CleanupAndExit: + + UtFreeLineBuffers (); + + AslParserCleanup (); + if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalFileList(); } - return (0); + return (ReturnStatus); } diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 926bc465cb68..30b479e1b749 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -233,6 +233,9 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_WRITE */ "Could not write file", /* ASL_MSG_RANGE */ "Constant out of range", /* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", +/* ASL_MSG_MISSING_DEPENDENCY */ "Missing dependency", +/* ASL_MSG_ILLEGAL_FORWARD_REF */ "Illegal forward reference within a method", +/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods" }; /* Table compiler */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 851d46c59ca1..ba0c22b1d297 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -235,6 +235,9 @@ typedef enum ASL_MSG_WRITE, ASL_MSG_RANGE, ASL_MSG_BUFFER_ALLOCATION, + ASL_MSG_MISSING_DEPENDENCY, + ASL_MSG_ILLEGAL_FORWARD_REF, + ASL_MSG_ILLEGAL_METHOD_REF, /* These messages are used by the Data Table compiler only */ diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index a9b064082757..0a5cee2835db 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" @@ -108,6 +107,41 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; + /* + * Special handling for _PSx methods. Dependency rules (same scope): + * + * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3 + * 2) _PS1/_PS2/_PS3: A _PS0 must exist + */ + if (ACPI_COMPARE_NAME (METHOD_NAME__PS0, Op->Asl.NameSeg)) + { + /* For _PS0, one of _PS1/_PS2/_PS3 must exist */ + + if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS2, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS3, Op))) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "_PS0 requires one of _PS1/_PS2/_PS3 in same scope"); + } + } + else if ( + ACPI_COMPARE_NAME (METHOD_NAME__PS1, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS2, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS3, Op->Asl.NameSeg)) + { + /* For _PS1/_PS2/_PS3, a _PS0 must exist */ + + if (!ApFindNameInScope (METHOD_NAME__PS0, Op)) + { + sprintf (MsgBuffer, + "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg); + + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + MsgBuffer); + } + } + /* Get the name node */ Next = Op->Asl.Child; @@ -359,6 +393,17 @@ MtMethodAnalysisWalkBegin ( break; case PARSEOP_DEVICE: + + Next = Op->Asl.Child; + + if (!ApFindNameInScope (METHOD_NAME__HID, Next) && + !ApFindNameInScope (METHOD_NAME__ADR, Next)) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "Device object requires a _HID or _ADR in same scope"); + } + break; + case PARSEOP_EVENT: case PARSEOP_MUTEX: case PARSEOP_OPERATIONREGION: diff --git a/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c index 140e0d4362b7..ede0ff9400d0 100644 --- a/source/compiler/aslnamesp.c +++ b/source/compiler/aslnamesp.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acnamesp.h" diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index 7c1cd5b98970..1ad47532bc3b 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -623,10 +622,10 @@ OpcDoEisaId ( (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 | (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 | - (UtHexCharToValue (InString[3])) << 12 | - (UtHexCharToValue (InString[4])) << 8 | - (UtHexCharToValue (InString[5])) << 4 | - UtHexCharToValue (InString[6]); + (AcpiUtAsciiCharToHex (InString[3])) << 12 | + (AcpiUtAsciiCharToHex (InString[4])) << 8 | + (AcpiUtAsciiCharToHex (InString[5])) << 4 | + AcpiUtAsciiCharToHex (InString[6]); /* Swap to little-endian to get final ID (see function header) */ @@ -666,7 +665,7 @@ OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { char *InString; - char *Buffer; + UINT8 *Buffer; ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *NewOp; @@ -681,7 +680,7 @@ OpcDoUuId ( } else { - (void) AuConvertStringToUuid (InString, Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 4a0f294a330e..b6cf4a4564b2 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -913,8 +912,8 @@ OpnDoDefinitionBlock ( * We will use the AML filename that is embedded in the source file * for the output filename. */ - Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) + - strlen ((char *) Child->Asl.Value.Buffer) + 1); + Filename = UtStringCacheCalloc (strlen (Gbl_DirectoryPath) + + strlen ((char *) Child->Asl.Value.Buffer) + 1); /* Prepend the current directory path */ @@ -969,7 +968,7 @@ OpnDoDefinitionBlock ( if (Child->Asl.Value.String) { Length = ACPI_STRLEN (Child->Asl.Value.String); - Gbl_TableId = AcpiOsAllocate (Length + 1); + Gbl_TableId = UtStringCacheCalloc (Length + 1); ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); /* diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index 05dd27bf5d6e..1e9b55b93ad0 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" @@ -168,7 +167,7 @@ OptSearchToRoot ( /* We must allocate a new string for the name (TargetPath gets deleted) */ - *NewPath = ACPI_ALLOCATE_ZEROED (ACPI_NAME_SIZE + 1); + *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1); ACPI_STRCPY (*NewPath, Path); if (ACPI_STRNCMP (*NewPath, "_T_", 3)) diff --git a/source/compiler/aslparser.y b/source/compiler/aslparser.y new file mode 100644 index 000000000000..bf4a8a74991c --- /dev/null +++ b/source/compiler/aslparser.y @@ -0,0 +1,129 @@ +%{ +/****************************************************************************** + * + * Module Name: aslparser.y - Master Bison/Yacc input file for iASL + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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 "aslcompiler.h" +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslparse") + +/* + * Global Notes: + * + * October 2005: The following list terms have been optimized (from the + * original ASL grammar in the ACPI specification) to force the immediate + * reduction of each list item so that the parse stack use doesn't increase on + * each list element and possibly overflow on very large lists (>4000 items). + * This dramatically reduces use of the parse stack overall. + * + * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, + * ResourceMacroList, and FieldUnitList + */ + +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#define static +#undef malloc +#define malloc AslLocalAllocate +#undef alloca +#define alloca AslLocalAllocate +#define yytname AslCompilername + +#define YYINITDEPTH 600 /* State stack depth */ +#define YYDEBUG 1 /* Enable debug output */ +#define YYERROR_VERBOSE 1 /* Verbose error messages */ +#define YYFLAG -32768 + +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ + +#define YYMALLOC malloc +#define YYFREE free +%} + +/* + * Declare the type of values in the grammar + */ +%union { + UINT64 i; + char *s; + ACPI_PARSE_OBJECT *n; +} + +/* + * These shift/reduce conflicts are expected. There should be zero + * reduce/reduce conflicts. + */ +%expect 86 + +/*! [Begin] no source code translation */ + +/* + * The M4 macro processor is used to bring in the parser items, + * in order to keep this master file smaller, and to break up + * the various parser items. + */ +m4_define(NoEcho) + +/* Token types */ + +m4_include(asltokens.y) + +/* Production types/names */ + +m4_include(asltypes.y) +%% + +/* Production rules */ + +m4_include(aslrules.y) +%% + +/*! [End] no source code translation !*/ + +/* Local support functions in C */ + +m4_include(aslsupport.y) diff --git a/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index b4f96955def5..f6fed5366a70 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -289,6 +289,41 @@ ApCheckPackage ( Package, 1, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package contains a variable list of UUID Buffer/Package pairs */ + + /* The length of the package must be even */ + + if (Count & 1) + { + sprintf (MsgBuffer, "%4.4s: Package length, %d, must be even.", + Predefined->Info.Name, Count); + + AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, + ParentOp->Asl.Child, MsgBuffer); + } + + /* Validate the alternating types */ + + for (i = 0; i < Count; ++i) + { + if (i & 1) + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType2, i); + } + else + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType1, i); + } + + Op = Op->Asl.Next; + } + + break; + case ACPI_PTYPE2: case ACPI_PTYPE2_FIXED: case ACPI_PTYPE2_MIN: diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index ce2c4b5c8804..f123990cc233 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" @@ -123,22 +122,10 @@ RsSmallAddressCheck ( return; } - /* Special case for Memory24, values are compressed */ - - if (Type == ACPI_RESOURCE_NAME_MEMORY24) - { - if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */ - { - Alignment = ACPI_UINT16_MAX + 1; - } - - Minimum <<= 8; - Maximum <<= 8; - Length *= 256; - } - - /* IO descriptor has different definition of min/max, don't check */ - + /* + * Range checks for Memory24 and Memory32. + * IO descriptor has different definition of min/max, don't check. + */ if (Type != ACPI_RESOURCE_NAME_IO) { /* Basic checks on Min/Max/Length */ @@ -151,6 +138,19 @@ RsSmallAddressCheck ( { AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); } + + /* Special case for Memory24, min/max values are compressed */ + + if (Type == ACPI_RESOURCE_NAME_MEMORY24) + { + if (!Alignment) /* Alignment==0 means 64K alignment */ + { + Alignment = ACPI_UINT16_MAX + 1; + } + + Minimum <<= 8; + Maximum <<= 8; + } } /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ diff --git a/source/compiler/aslrestype1.c b/source/compiler/aslrestype1.c index 602e0091cb7b..73f3efe6cabf 100644 --- a/source/compiler/aslrestype1.c +++ b/source/compiler/aslrestype1.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype1i.c b/source/compiler/aslrestype1i.c index 5a68500fc825..bc16d728200c 100644 --- a/source/compiler/aslrestype1i.c +++ b/source/compiler/aslrestype1i.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2.c b/source/compiler/aslrestype2.c index a1e2fbb63e56..9579fe4423ce 100644 --- a/source/compiler/aslrestype2.c +++ b/source/compiler/aslrestype2.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslrestype2d.c b/source/compiler/aslrestype2d.c index d9a560c2f5f7..297f99a2cb3b 100644 --- a/source/compiler/aslrestype2d.c +++ b/source/compiler/aslrestype2d.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2e.c b/source/compiler/aslrestype2e.c index fa2c611dfc66..08590cc57317 100644 --- a/source/compiler/aslrestype2e.c +++ b/source/compiler/aslrestype2e.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/source/compiler/aslrestype2q.c b/source/compiler/aslrestype2q.c index 6ee163973e64..0bd32e79b3bc 100644 --- a/source/compiler/aslrestype2q.c +++ b/source/compiler/aslrestype2q.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrestype2s.c b/source/compiler/aslrestype2s.c index dc42eb79aff1..c607899b5fbe 100644 --- a/source/compiler/aslrestype2s.c +++ b/source/compiler/aslrestype2s.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/source/compiler/aslrestype2w.c b/source/compiler/aslrestype2w.c index efdf2e7118ac..7f58babf2108 100644 --- a/source/compiler/aslrestype2w.c +++ b/source/compiler/aslrestype2w.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y new file mode 100644 index 000000000000..2bc48db11f6a --- /dev/null +++ b/source/compiler/aslrules.y @@ -0,0 +1,2763 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslrules.y - Bison/Yacc production rules + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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. + */ + +') + +/******************************************************************************* + * + * Production rules start here + * + ******************************************************************************/ + +/* + * ASL Names + * + * Root rule. Allow multiple #line directives before the definition block + * to handle output from preprocessors + */ +ASLCode + : DefinitionBlockTerm + | error {YYABORT; $$ = NULL;} + ; + +/* + * Blocks, Data, and Opcodes + */ + +/* + * Note concerning support for "module-level code". + * + * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control + * methods (the so-called module-level code.) This support was explicitly + * removed in ACPI 2.0, but this type of code continues to be created by + * BIOS vendors. In order to support the disassembly and recompilation of + * such code (and the porting of ASL code to iASL), iASL supports this + * code in violation of the current ACPI specification. + * + * The grammar change to support module-level code is to revert the + * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the + * original use of {TermList} instead (see below.) This allows the use + * of Type1 and Type2 opcodes at module level. + */ +DefinitionBlockTerm + : PARSEOP_DEFINITIONBLOCK '(' {$$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);} + String ',' + String ',' + ByteConst ',' + String ',' + String ',' + DWordConst + ')' {TrSetEndLineNumber ($3);} + '{' TermList '}' {$$ = TrLinkChildren ($3,7,$4,$6,$8,$10,$12,$14,$18);} + ; + +/* ACPI 3.0 -- allow semicolons between terms */ + +TermList + : {$$ = NULL;} + | TermList Term {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} + | TermList Term ';' {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} + | TermList ';' Term {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} + | TermList ';' Term ';' {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} + ; + +Term + : Object {} + | Type1Opcode {} + | Type2Opcode {} + | Type2IntegerOpcode {} + | Type2StringOpcode {} + | Type2BufferOpcode {} + | Type2BufferOrStringOpcode {} + | error {$$ = AslDoError(); yyclearin;} + ; + +CompilerDirective + : IncludeTerm {} + | ExternalTerm {} + ; + +ObjectList + : {$$ = NULL;} + | ObjectList Object {$$ = TrLinkPeerNode ($1,$2);} + | error {$$ = AslDoError(); yyclearin;} + ; + +Object + : CompilerDirective {} + | NamedObject {} + | NameSpaceModifier {} + ; + +DataObject + : BufferData {} + | PackageData {} + | IntegerData {} + | StringData {} + ; + +BufferData + : Type5Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | BufferTerm {} + ; + +PackageData + : PackageTerm {} + ; + +IntegerData + : Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Integer {} + | ConstTerm {} + ; + +StringData + : Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | String {} + ; + +NamedObject + : BankFieldTerm {} + | CreateBitFieldTerm {} + | CreateByteFieldTerm {} + | CreateDWordFieldTerm {} + | CreateFieldTerm {} + | CreateQWordFieldTerm {} + | CreateWordFieldTerm {} + | DataRegionTerm {} + | DeviceTerm {} + | EventTerm {} + | FieldTerm {} + | FunctionTerm {} + | IndexFieldTerm {} + | MethodTerm {} + | MutexTerm {} + | OpRegionTerm {} + | PowerResTerm {} + | ProcessorTerm {} + | ThermalZoneTerm {} + ; + +NameSpaceModifier + : AliasTerm {} + | NameTerm {} + | ScopeTerm {} + ; + +UserTerm + : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} + ArgList ')' {$$ = TrLinkChildNode ($1,$4);} + ; + +ArgList + : {$$ = NULL;} + | TermArg + | ArgList ',' /* Allows a trailing comma at list end */ + | ArgList ',' + TermArg {$$ = TrLinkPeerNode ($1,$3);} + ; + +/* +Removed from TermArg due to reduce/reduce conflicts + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + +*/ + +TermArg + : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + ; + +Target + : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ + | ',' {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ + | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} + ; + +RequiredTarget + : ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} + ; + +SimpleTarget + : NameString {} + | LocalTerm {} + | ArgTerm {} + ; + +/* Rules for specifying the type of one method argument or return value */ + +ParameterTypePackage + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | ParameterTypePackage ',' + ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypePackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypePackage '}' {$$ = $2;} + ; + +OptionalParameterTypePackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + +/* Rules for specifying the types for method arguments */ + +ParameterTypesPackage + : ParameterTypePackageList {$$ = $1;} + | ParameterTypesPackage ',' + ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypesPackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypesPackage '}' {$$ = $2;} + ; + +OptionalParameterTypesPackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + + +/* Opcode types */ + +Type1Opcode + : BreakTerm {} + | BreakPointTerm {} + | ContinueTerm {} + | FatalTerm {} + | IfElseTerm {} + | LoadTerm {} + | NoOpTerm {} + | NotifyTerm {} + | ReleaseTerm {} + | ResetTerm {} + | ReturnTerm {} + | SignalTerm {} + | SleepTerm {} + | StallTerm {} + | SwitchTerm {} + | UnloadTerm {} + | WhileTerm {} + ; + +Type2Opcode + : AcquireTerm {} + | CondRefOfTerm {} + | CopyObjectTerm {} + | DerefOfTerm {} + | ObjectTypeTerm {} + | RefOfTerm {} + | SizeOfTerm {} + | StoreTerm {} + | TimerTerm {} + | WaitTerm {} + | UserTerm {} + ; + +/* + * Type 3/4/5 opcodes + */ + +Type2IntegerOpcode /* "Type3" opcodes */ + : AddTerm {} + | AndTerm {} + | DecTerm {} + | DivideTerm {} + | FindSetLeftBitTerm {} + | FindSetRightBitTerm {} + | FromBCDTerm {} + | IncTerm {} + | IndexTerm {} + | LAndTerm {} + | LEqualTerm {} + | LGreaterTerm {} + | LGreaterEqualTerm {} + | LLessTerm {} + | LLessEqualTerm {} + | LNotTerm {} + | LNotEqualTerm {} + | LoadTableTerm {} + | LOrTerm {} + | MatchTerm {} + | ModTerm {} + | MultiplyTerm {} + | NAndTerm {} + | NOrTerm {} + | NotTerm {} + | OrTerm {} + | ShiftLeftTerm {} + | ShiftRightTerm {} + | SubtractTerm {} + | ToBCDTerm {} + | ToIntegerTerm {} + | XOrTerm {} + ; + +Type2StringOpcode /* "Type4" Opcodes */ + : ToDecimalStringTerm {} + | ToHexStringTerm {} + | ToStringTerm {} + ; + +Type2BufferOpcode /* "Type5" Opcodes */ + : ToBufferTerm {} + | ConcatResTerm {} + ; + +Type2BufferOrStringOpcode + : ConcatTerm {} + | MidTerm {} + ; + +/* + * A type 3 opcode evaluates to an Integer and cannot have a destination operand + */ + +Type3Opcode + : EISAIDTerm {} + ; + +/* Obsolete +Type4Opcode + : ConcatTerm {} + | ToDecimalStringTerm {} + | ToHexStringTerm {} + | MidTerm {} + | ToStringTerm {} + ; +*/ + + +Type5Opcode + : ResourceTemplateTerm {} + | UnicodeTerm {} + | ToUUIDTerm {} + ; + +Type6Opcode + : RefOfTerm {} + | DerefOfTerm {} + | IndexTerm {} + | UserTerm {} + ; + +IncludeTerm + : PARSEOP_INCLUDE '(' {$$ = TrCreateLeafNode (PARSEOP_INCLUDE);} + String ')' {TrLinkChildren ($3,1,$4);FlOpenIncludeFile ($4);} + TermList + IncludeEndTerm {$$ = TrLinkPeerNodes (3,$3,$7,$8);} + ; + +IncludeEndTerm + : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);} + ; + +ExternalTerm + : PARSEOP_EXTERNAL '(' + NameString + OptionalObjectTypeKeyword + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} + | PARSEOP_EXTERNAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Named Objects *******************************************************/ + + +BankFieldTerm + : PARSEOP_BANKFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} + NameString + NameStringItem + TermArgItem + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword + ')' '{' + FieldUnitList '}' {$$ = TrLinkChildren ($3,7,$4,$5,$6,$8,$10,$12,$15);} + | PARSEOP_BANKFIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + ; + +FieldUnitList + : {$$ = NULL;} + | FieldUnit + | FieldUnitList ',' /* Allows a trailing comma at list end */ + | FieldUnitList ',' + FieldUnit {$$ = TrLinkPeerNode ($1,$3);} + ; + +FieldUnit + : FieldUnitEntry {} + | OffsetTerm {} + | AccessAsTerm {} + | ConnectionTerm {} + ; + +FieldUnitEntry + : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} + | NameSeg ',' + AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} + ; + +OffsetTerm + : PARSEOP_OFFSET '(' + AmlPackageLengthTerm + ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} + | PARSEOP_OFFSET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +AccessAsTerm + : PARSEOP_ACCESSAS '(' + AccessTypeKeyword + OptionalAccessAttribTerm + ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} + | PARSEOP_ACCESSAS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ConnectionTerm + : PARSEOP_CONNECTION '(' + NameString + ')' {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);} + | PARSEOP_CONNECTION '(' {$$ = TrCreateLeafNode (PARSEOP_CONNECTION);} + ResourceMacroTerm + ')' {$$ = TrLinkChildren ($3, 1, + TrLinkChildren (TrCreateLeafNode (PARSEOP_RESOURCETEMPLATE), 3, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + $4));} + | PARSEOP_CONNECTION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateBitFieldTerm + : PARSEOP_CREATEBITFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} + TermArg + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEBITFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateByteFieldTerm + : PARSEOP_CREATEBYTEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);} + TermArg + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEBYTEFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateDWordFieldTerm + : PARSEOP_CREATEDWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);} + TermArg + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEDWORDFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateFieldTerm + : PARSEOP_CREATEFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);} + TermArg + TermArgItem + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateQWordFieldTerm + : PARSEOP_CREATEQWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);} + TermArg + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEQWORDFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CreateWordFieldTerm + : PARSEOP_CREATEWORDFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);} + TermArg + TermArgItem + NameStringItem + ')' {$$ = TrLinkChildren ($3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));} + | PARSEOP_CREATEWORDFIELD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DataRegionTerm + : PARSEOP_DATATABLEREGION '(' {$$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);} + NameString + TermArgItem + TermArgItem + TermArgItem + ')' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);} + | PARSEOP_DATATABLEREGION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DeviceTerm + : PARSEOP_DEVICE '(' {$$ = TrCreateLeafNode (PARSEOP_DEVICE);} + NameString + ')' '{' + ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_DEVICE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +EventTerm + : PARSEOP_EVENT '(' {$$ = TrCreateLeafNode (PARSEOP_EVENT);} + NameString + ')' {$$ = TrLinkChildren ($3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} + | PARSEOP_EVENT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FieldTerm + : PARSEOP_FIELD '(' {$$ = TrCreateLeafNode (PARSEOP_FIELD);} + NameString + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword + ')' '{' + FieldUnitList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$8,$10,$13);} + | PARSEOP_FIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + ; + +FunctionTerm + : PARSEOP_FUNCTION '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), + TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} + | PARSEOP_FUNCTION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IndexFieldTerm + : PARSEOP_INDEXFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} + NameString + NameStringItem + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword + ')' '{' + FieldUnitList '}' {$$ = TrLinkChildren ($3,6,$4,$5,$7,$9,$11,$14);} + | PARSEOP_INDEXFIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + ; + +MethodTerm + : PARSEOP_METHOD '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} + OptionalSerializeRuleKeyword + OptionalByteConstExpr + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} + | PARSEOP_METHOD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +MutexTerm + : PARSEOP_MUTEX '(' {$$ = TrCreateLeafNode (PARSEOP_MUTEX);} + NameString + ',' ByteConstExpr + ')' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_MUTEX '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionTerm + : PARSEOP_OPERATIONREGION '(' {$$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} + NameString + ',' OpRegionSpaceIdTerm + TermArgItem + TermArgItem + ')' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} + | PARSEOP_OPERATIONREGION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionSpaceIdTerm + : RegionSpaceKeyword {} + | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + +PowerResTerm + : PARSEOP_POWERRESOURCE '(' {$$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} + NameString + ',' ByteConstExpr + ',' WordConstExpr + ')' '{' + ObjectList '}' {$$ = TrLinkChildren ($3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} + | PARSEOP_POWERRESOURCE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ProcessorTerm + : PARSEOP_PROCESSOR '(' {$$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} + NameString + ',' ByteConstExpr + OptionalDWordConstExpr + OptionalByteConstExpr + ')' '{' + ObjectList '}' {$$ = TrLinkChildren ($3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} + | PARSEOP_PROCESSOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ThermalZoneTerm + : PARSEOP_THERMALZONE '(' {$$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} + NameString + ')' '{' + ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_THERMALZONE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Namespace modifiers *************************************************/ + + +AliasTerm + : PARSEOP_ALIAS '(' {$$ = TrCreateLeafNode (PARSEOP_ALIAS);} + NameString + NameStringItem + ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} + | PARSEOP_ALIAS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NameTerm + : PARSEOP_NAME '(' {$$ = TrCreateLeafNode (PARSEOP_NAME);} + NameString + ',' DataObject + ')' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_NAME '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ScopeTerm + : PARSEOP_SCOPE '(' {$$ = TrCreateLeafNode (PARSEOP_SCOPE);} + NameString + ')' '{' + ObjectList '}' {$$ = TrLinkChildren ($3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_SCOPE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Type 1 opcodes *******************************************************/ + + +BreakTerm + : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} + ; + +BreakPointTerm + : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} + ; + +ContinueTerm + : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} + ; + +FatalTerm + : PARSEOP_FATAL '(' {$$ = TrCreateLeafNode (PARSEOP_FATAL);} + ByteConstExpr + ',' DWordConstExpr + TermArgItem + ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} + | PARSEOP_FATAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IfElseTerm + : IfTerm ElseTerm {$$ = TrLinkPeerNode ($1,$2);} + ; + +IfTerm + : PARSEOP_IF '(' {$$ = TrCreateLeafNode (PARSEOP_IF);} + TermArg + ')' '{' + TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + + | PARSEOP_IF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ElseTerm + : {$$ = NULL;} + | PARSEOP_ELSE '{' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} + TermList '}' {$$ = TrLinkChildren ($3,1,$4);} + + | PARSEOP_ELSE '{' + error '}' {$$ = AslDoError(); yyclearin;} + + | PARSEOP_ELSE + error {$$ = AslDoError(); yyclearin;} + + | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} + TermArg {$$ = TrCreateLeafNode (PARSEOP_IF);} + ')' '{' + TermList '}' {TrLinkChildren ($5,2,$4,$8);} + ElseTerm {TrLinkPeerNode ($5,$11);} + {$$ = TrLinkChildren ($3,1,$5);} + + | PARSEOP_ELSEIF '(' + error ')' {$$ = AslDoError(); yyclearin;} + + | PARSEOP_ELSEIF + error {$$ = AslDoError(); yyclearin;} + ; + +LoadTerm + : PARSEOP_LOAD '(' {$$ = TrCreateLeafNode (PARSEOP_LOAD);} + NameString + RequiredTarget + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NoOpTerm + : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} + ; + +NotifyTerm + : PARSEOP_NOTIFY '(' {$$ = TrCreateLeafNode (PARSEOP_NOTIFY);} + SuperName + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_NOTIFY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ReleaseTerm + : PARSEOP_RELEASE '(' {$$ = TrCreateLeafNode (PARSEOP_RELEASE);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_RELEASE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ResetTerm + : PARSEOP_RESET '(' {$$ = TrCreateLeafNode (PARSEOP_RESET);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_RESET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ReturnTerm + : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);} + OptionalReturnArg + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} + | PARSEOP_RETURN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SignalTerm + : PARSEOP_SIGNAL '(' {$$ = TrCreateLeafNode (PARSEOP_SIGNAL);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SIGNAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SleepTerm + : PARSEOP_SLEEP '(' {$$ = TrCreateLeafNode (PARSEOP_SLEEP);} + TermArg + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SLEEP '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StallTerm + : PARSEOP_STALL '(' {$$ = TrCreateLeafNode (PARSEOP_STALL);} + TermArg + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_STALL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SwitchTerm + : PARSEOP_SWITCH '(' {$$ = TrCreateLeafNode (PARSEOP_SWITCH);} + TermArg + ')' '{' + CaseDefaultTermList '}' + {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_SWITCH '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +/* + * Case-Default list; allow only one Default term and unlimited Case terms + */ + +CaseDefaultTermList + : {$$ = NULL;} + | CaseTerm {} + | DefaultTerm {} + | CaseDefaultTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} + | CaseDefaultTermList + DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} + +/* Original - attempts to force zero or one default term within the switch */ + +/* +CaseDefaultTermList + : {$$ = NULL;} + | CaseTermList + DefaultTerm + CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} + ; + +CaseTermList + : {$$ = NULL;} + | CaseTerm {} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} + ; +*/ + +CaseTerm + : PARSEOP_CASE '(' {$$ = TrCreateLeafNode (PARSEOP_CASE);} + DataObject + ')' '{' + TermList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_CASE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DefaultTerm + : PARSEOP_DEFAULT '{' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT);} + TermList '}' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_DEFAULT '{' + error '}' {$$ = AslDoError(); yyclearin;} + ; + +UnloadTerm + : PARSEOP_UNLOAD '(' {$$ = TrCreateLeafNode (PARSEOP_UNLOAD);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_UNLOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WhileTerm + : PARSEOP_WHILE '(' {$$ = TrCreateLeafNode (PARSEOP_WHILE);} + TermArg + ')' '{' TermList '}' + {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_WHILE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Type 2 opcodes *******************************************************/ + +AcquireTerm + : PARSEOP_ACQUIRE '(' {$$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} + SuperName + ',' WordConstExpr + ')' {$$ = TrLinkChildren ($3,2,$4,$6);} + | PARSEOP_ACQUIRE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +AddTerm + : PARSEOP_ADD '(' {$$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_ADD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +AndTerm + : PARSEOP_AND '(' {$$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_AND '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ConcatTerm + : PARSEOP_CONCATENATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_CONCATENATE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ConcatResTerm + : PARSEOP_CONCATENATERESTEMPLATE '(' {$$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_CONCATENATERESTEMPLATE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CondRefOfTerm + : PARSEOP_CONDREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} + SuperName + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_CONDREFOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +CopyObjectTerm + : PARSEOP_COPYOBJECT '(' {$$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} + TermArg + ',' SimpleTarget + ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} + | PARSEOP_COPYOBJECT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DecTerm + : PARSEOP_DECREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_DECREMENT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DerefOfTerm + : PARSEOP_DEREFOF '(' {$$ = TrCreateLeafNode (PARSEOP_DEREFOF);} + TermArg + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_DEREFOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DivideTerm + : PARSEOP_DIVIDE '(' {$$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg + TermArgItem + Target + Target + ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} + | PARSEOP_DIVIDE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FindSetLeftBitTerm + : PARSEOP_FINDSETLEFTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FINDSETLEFTBIT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FindSetRightBitTerm + : PARSEOP_FINDSETRIGHTBIT '(' {$$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FINDSETRIGHTBIT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FromBCDTerm + : PARSEOP_FROMBCD '(' {$$ = TrCreateLeafNode (PARSEOP_FROMBCD);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_FROMBCD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IncTerm + : PARSEOP_INCREMENT '(' {$$ = TrCreateLeafNode (PARSEOP_INCREMENT);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_INCREMENT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IndexTerm + : PARSEOP_INDEX '(' {$$ = TrCreateLeafNode (PARSEOP_INDEX);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_INDEX '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LAndTerm + : PARSEOP_LAND '(' {$$ = TrCreateLeafNode (PARSEOP_LAND);} + TermArg + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LAND '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LEqualTerm + : PARSEOP_LEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + TermArg + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LEQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LGreaterTerm + : PARSEOP_LGREATER '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} + TermArg + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LGREATER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LGreaterEqualTerm + : PARSEOP_LGREATEREQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg + TermArgItem + ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} + | PARSEOP_LGREATEREQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LLessTerm + : PARSEOP_LLESS '(' {$$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LLESS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LLessEqualTerm + : PARSEOP_LLESSEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LGREATER);} + TermArg + TermArgItem + ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} + | PARSEOP_LLESSEQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LNotTerm + : PARSEOP_LNOT '(' {$$ = TrCreateLeafNode (PARSEOP_LNOT);} + TermArg + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_LNOT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LNotEqualTerm + : PARSEOP_LNOTEQUAL '(' {$$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + TermArg + TermArgItem + ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($3,2,$4,$5));} + | PARSEOP_LNOTEQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LoadTableTerm + : PARSEOP_LOADTABLE '(' {$$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} + TermArg + TermArgItem + TermArgItem + OptionalListString + OptionalListString + OptionalReference + ')' {$$ = TrLinkChildren ($3,6,$4,$5,$6,$7,$8,$9);} + | PARSEOP_LOADTABLE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LOrTerm + : PARSEOP_LOR '(' {$$ = TrCreateLeafNode (PARSEOP_LOR);} + TermArg + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_LOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +MatchTerm + : PARSEOP_MATCH '(' {$$ = TrCreateLeafNode (PARSEOP_MATCH);} + TermArg + ',' MatchOpKeyword + TermArgItem + ',' MatchOpKeyword + TermArgItem + TermArgItem + ')' {$$ = TrLinkChildren ($3,6,$4,$6,$7,$9,$10,$11);} + | PARSEOP_MATCH '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +MidTerm + : PARSEOP_MID '(' {$$ = TrCreateLeafNode (PARSEOP_MID);} + TermArg + TermArgItem + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,4,$4,$5,$6,$7);} + | PARSEOP_MID '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ModTerm + : PARSEOP_MOD '(' {$$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_MOD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +MultiplyTerm + : PARSEOP_MULTIPLY '(' {$$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_MULTIPLY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NAndTerm + : PARSEOP_NAND '(' {$$ = TrCreateLeafNode (PARSEOP_NAND);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_NAND '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NOrTerm + : PARSEOP_NOR '(' {$$ = TrCreateLeafNode (PARSEOP_NOR);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_NOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NotTerm + : PARSEOP_NOT '(' {$$ = TrCreateLeafNode (PARSEOP_NOT);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_NOT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ObjectTypeTerm + : PARSEOP_OBJECTTYPE '(' {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);} + ObjectTypeName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_OBJECTTYPE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OrTerm + : PARSEOP_OR '(' {$$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_OR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +/* + * In RefOf, the node isn't really a target, but we can't keep track of it after + * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) + */ +RefOfTerm + : PARSEOP_REFOF '(' {$$ = TrCreateLeafNode (PARSEOP_REFOF);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,TrSetNodeFlags ($4, NODE_IS_TARGET));} + | PARSEOP_REFOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ShiftLeftTerm + : PARSEOP_SHIFTLEFT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SHIFTLEFT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ShiftRightTerm + : PARSEOP_SHIFTRIGHT '(' {$$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SHIFTRIGHT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SizeOfTerm + : PARSEOP_SIZEOF '(' {$$ = TrCreateLeafNode (PARSEOP_SIZEOF);} + SuperName + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_SIZEOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StoreTerm + : PARSEOP_STORE '(' {$$ = TrCreateLeafNode (PARSEOP_STORE);} + TermArg + ',' SuperName + ')' {$$ = TrLinkChildren ($3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} + | PARSEOP_STORE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SubtractTerm + : PARSEOP_SUBTRACT '(' {$$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_SUBTRACT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +TimerTerm + : PARSEOP_TIMER '(' {$$ = TrCreateLeafNode (PARSEOP_TIMER);} + ')' {$$ = TrLinkChildren ($3,0);} + | PARSEOP_TIMER {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_TIMER),0);} + | PARSEOP_TIMER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToBCDTerm + : PARSEOP_TOBCD '(' {$$ = TrCreateLeafNode (PARSEOP_TOBCD);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOBCD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToBufferTerm + : PARSEOP_TOBUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_TOBUFFER);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOBUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToDecimalStringTerm + : PARSEOP_TODECIMALSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TODECIMALSTRING '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToHexStringTerm + : PARSEOP_TOHEXSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOHEXSTRING '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToIntegerTerm + : PARSEOP_TOINTEGER '(' {$$ = TrCreateLeafNode (PARSEOP_TOINTEGER);} + TermArg + Target + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_TOINTEGER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToStringTerm + : PARSEOP_TOSTRING '(' {$$ = TrCreateLeafNode (PARSEOP_TOSTRING);} + TermArg + OptionalCount + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_TOSTRING '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ToUUIDTerm + : PARSEOP_TOUUID '(' + StringData ')' {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);} + | PARSEOP_TOUUID '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WaitTerm + : PARSEOP_WAIT '(' {$$ = TrCreateLeafNode (PARSEOP_WAIT);} + SuperName + TermArgItem + ')' {$$ = TrLinkChildren ($3,2,$4,$5);} + | PARSEOP_WAIT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +XOrTerm + : PARSEOP_XOR '(' {$$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($3,3,$4,$5,$6);} + | PARSEOP_XOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Keywords *************************************************************/ + + +AccessAttribKeyword + : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} + | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} + | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} + | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} + | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} + | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} + | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} + | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} + ByteConst + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} + ByteConst + ')' {$$ = TrLinkChildren ($3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} + ByteConst + ')' {$$ = TrLinkChildren ($3,1,$4);} + ; + +AccessTypeKeyword + : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} + | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} + | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} + | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} + | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} + | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} + ; + +AddressingModeKeyword + : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} + | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} + ; + +AddressKeyword + : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} + | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} + | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} + | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} + ; + +AddressSpaceKeyword + : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} + | RegionSpaceKeyword {} + ; + +BitsPerByteKeyword + : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} + | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} + | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} + | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} + | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} + ; + +ClockPhaseKeyword + : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} + | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} + ; + +ClockPolarityKeyword + : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} + | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} + ; + +DecodeKeyword + : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} + | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} + ; + +DevicePolarityKeyword + : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} + | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} + ; + +DMATypeKeyword + : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} + | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} + | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} + | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} + ; + +EndianKeyword + : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} + | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} + ; + +FlowControlKeyword + : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} + | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} + | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} + ; + +InterruptLevel + : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} + | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} + | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} + ; + +InterruptTypeKeyword + : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} + | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} + ; + +IODecodeKeyword + : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} + | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} + ; + +IoRestrictionKeyword + : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} + | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} + | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} + | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} + ; + +LockRuleKeyword + : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} + | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} + ; + +MatchOpKeyword + : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} + | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} + | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} + | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} + | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} + | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} + ; + +MaxKeyword + : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} + | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} + ; + +MemTypeKeyword + : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} + | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} + | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} + | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} + ; + +MinKeyword + : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} + | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} + ; + +ObjectTypeKeyword + : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} + | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} + | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} + | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} + | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} + | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} + | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} + | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} + | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} + | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} + | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} + | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} + | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} + | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} + | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} + ; + +ParityTypeKeyword + : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} + | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} + | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} + | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} + | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} + ; + +PinConfigByte + : PinConfigKeyword {$$ = $1;} + | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + +PinConfigKeyword + : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} + | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} + | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} + | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} + ; + +RangeTypeKeyword + : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} + | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} + | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} + ; + +RegionSpaceKeyword + : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} + | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} + | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} + | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} + | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} + | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} + | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} + | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} + | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} + | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} + | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} + | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} + ; + +ResourceTypeKeyword + : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} + ; + +SerializeRuleKeyword + : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} + | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} + ; + +ShareTypeKeyword + : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} + | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} + | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} + | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} + ; + +SlaveModeKeyword + : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} + | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} + ; + +StopBitsKeyword + : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} + | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} + | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} + | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} + ; + +TranslationKeyword + : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} + | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} + ; + +TypeKeyword + : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} + | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} + ; + +UpdateRuleKeyword + : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} + | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} + | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} + ; + +WireModeKeyword + : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} + | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} + ; + +XferSizeKeyword + : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} + | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} + | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} + | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} + | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} + ; + +XferTypeKeyword + : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} + | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} + | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} + ; + + +/******* Miscellaneous Types **************************************************/ + + +SuperName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | Type6Opcode {} + +/* For ObjectType: SuperName except for UserTerm (method invocation) */ + +ObjectTypeName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | RefOfTerm {} + | DerefOfTerm {} + | IndexTerm {} + +/* | UserTerm {} */ /* Caused reduce/reduce with Type6Opcode->UserTerm */ + ; + +ArgTerm + : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} + | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} + | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} + | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} + | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} + | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} + | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} + ; + +LocalTerm + : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} + | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} + | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} + | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} + | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} + | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} + | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} + | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} + ; + +DebugTerm + : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} + ; + + +ByteConst + : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + ; + +WordConst + : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + ; + +DWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + ; + +QWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + ; + +Integer + : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} + ; + +String + : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + +ConstTerm + : ConstExprTerm {} + | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} + ; + +ConstExprTerm + : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} + | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} + | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} + | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} + | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} + | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} + | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} + ; + +/* + * The NODE_COMPILE_TIME_CONST flag in the following constant expressions + * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes + * to simple integers. It is an error if these types of expressions cannot be + * reduced, since the AML grammar for ****ConstExpr requires a simple constant. + * Note: The required byte length of the constant is passed through to the + * constant folding code in the node AmlLength field. + */ +ByteConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + | ByteConst {} + ; + +WordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + | WordConst {} + ; + +DWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + | DWordConst {} + ; + +QWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + | QWordConst {} + ; + +/* OptionalCount must appear before ByteList or an incorrect reduction will result */ + +OptionalCount + : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' TermArg {$$ = $2;} + ; + +BufferTerm + : PARSEOP_BUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_BUFFER);} + OptionalTermArg + ')' '{' + BufferTermData '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_BUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +BufferTermData + : ByteList {} + | StringData {} + ; + +ByteList + : {$$ = NULL;} + | ByteConstExpr + | ByteList ',' /* Allows a trailing comma at list end */ + | ByteList ',' + ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +DataBufferTerm + : PARSEOP_DATABUFFER '(' {$$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} + OptionalWordConst + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_DATABUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordList + : {$$ = NULL;} + | DWordConstExpr + | DWordList ',' /* Allows a trailing comma at list end */ + | DWordList ',' + DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +PackageTerm + : PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} + VarPackageLengthTerm + ')' '{' + PackageList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_PACKAGE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PackageList + : {$$ = NULL;} + | PackageElement + | PackageList ',' /* Allows a trailing comma at list end */ + | PackageList ',' + PackageElement {$$ = TrLinkPeerNode ($1,$3);} + ; + +PackageElement + : DataObject {} + | NameString {} + ; + +VarPackageLengthTerm + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | TermArg {$$ = $1;} + ; + + +/******* Macros ***********************************************/ + + +EISAIDTerm + : PARSEOP_EISAID '(' + StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} + | PARSEOP_EISAID '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UnicodeTerm + : PARSEOP_UNICODE '(' {$$ = TrCreateLeafNode (PARSEOP_UNICODE);} + StringData + ')' {$$ = TrLinkChildren ($3,2,0,$4);} + | PARSEOP_UNICODE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Resources and Memory ***********************************************/ + + +/* + * Note: Create two default nodes to allow conversion to a Buffer AML opcode + * Also, insert the EndTag at the end of the template. + */ +ResourceTemplateTerm + : PARSEOP_RESOURCETEMPLATE '(' ')' + '{' + ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + $5, + TrCreateLeafNode (PARSEOP_ENDTAG));} + ; + +ResourceMacroList + : {$$ = NULL;} + | ResourceMacroList + ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} + ; + +ResourceMacroTerm + : DMATerm {} + | DWordIOTerm {} + | DWordMemoryTerm {} + | DWordSpaceTerm {} + | EndDependentFnTerm {} + | ExtendedIOTerm {} + | ExtendedMemoryTerm {} + | ExtendedSpaceTerm {} + | FixedDmaTerm {} + | FixedIOTerm {} + | GpioIntTerm {} + | GpioIoTerm {} + | I2cSerialBusTerm {} + | InterruptTerm {} + | IOTerm {} + | IRQNoFlagsTerm {} + | IRQTerm {} + | Memory24Term {} + | Memory32FixedTerm {} + | Memory32Term {} + | QWordIOTerm {} + | QWordMemoryTerm {} + | QWordSpaceTerm {} + | RegisterTerm {} + | SpiSerialBusTerm {} + | StartDependentFnNoPriTerm {} + | StartDependentFnTerm {} + | UartSerialBusTerm {} + | VendorLongTerm {} + | VendorShortTerm {} + | WordBusNumberTerm {} + | WordIOTerm {} + | WordSpaceTerm {} + ; + +DMATerm + : PARSEOP_DMA '(' {$$ = TrCreateLeafNode (PARSEOP_DMA);} + DMATypeKeyword + OptionalBusMasterKeyword + ',' XferTypeKeyword + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$5,$7,$8,$11);} + | PARSEOP_DMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordIOTerm + : PARSEOP_DWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_DWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordMemoryTerm + : PARSEOP_DWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_DWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordSpaceTerm + : PARSEOP_DWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_DWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +EndDependentFnTerm + : PARSEOP_ENDDEPENDENTFN '(' + ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} + | PARSEOP_ENDDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedIOTerm + : PARSEOP_EXTENDEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} + | PARSEOP_EXTENDEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedMemoryTerm + : PARSEOP_EXTENDEDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} + | PARSEOP_EXTENDEDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedSpaceTerm + : PARSEOP_EXTENDEDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} + | PARSEOP_EXTENDEDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedDmaTerm + : PARSEOP_FIXEDDMA '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} + WordConstExpr /* 04: DMA RequestLines */ + ',' WordConstExpr /* 06: DMA Channels */ + OptionalXferSize /* 07: DMA TransferSize */ + OptionalNameString /* 08: DescriptorName */ + ')' {$$ = TrLinkChildren ($3,4,$4,$6,$7,$8);} + | PARSEOP_FIXEDDMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedIOTerm + : PARSEOP_FIXEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} + WordConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,3,$4,$6,$7);} + | PARSEOP_FIXEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIntTerm + : PARSEOP_GPIO_INT '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} + InterruptTypeKeyword /* 04: InterruptType */ + ',' InterruptLevel /* 06: InterruptLevel */ + OptionalShareType /* 07: SharedType */ + ',' PinConfigByte /* 09: PinConfig */ + OptionalWordConstExpr /* 10: DebounceTimeout */ + ',' StringData /* 12: ResourceSource */ + OptionalByteConstExpr /* 13: ResourceSourceIndex */ + OptionalResourceType /* 14: ResourceType */ + OptionalNameString /* 15: DescriptorName */ + OptionalBuffer_Last /* 16: VendorData */ + ')' '{' + DWordConstExpr '}' {$$ = TrLinkChildren ($3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} + | PARSEOP_GPIO_INT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIoTerm + : PARSEOP_GPIO_IO '(' {$$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} + OptionalShareType_First /* 04: SharedType */ + ',' PinConfigByte /* 06: PinConfig */ + OptionalWordConstExpr /* 07: DebounceTimeout */ + OptionalWordConstExpr /* 08: DriveStrength */ + OptionalIoRestriction /* 09: IoRestriction */ + ',' StringData /* 11: ResourceSource */ + OptionalByteConstExpr /* 12: ResourceSourceIndex */ + OptionalResourceType /* 13: ResourceType */ + OptionalNameString /* 14: DescriptorName */ + OptionalBuffer_Last /* 15: VendorData */ + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} + | PARSEOP_GPIO_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +I2cSerialBusTerm + : PARSEOP_I2C_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} + WordConstExpr /* 04: SlaveAddress */ + OptionalSlaveMode /* 05: SlaveMode */ + ',' DWordConstExpr /* 07: ConnectionSpeed */ + OptionalAddressingMode /* 08: AddressingMode */ + ',' StringData /* 10: ResourceSource */ + OptionalByteConstExpr /* 11: ResourceSourceIndex */ + OptionalResourceType /* 12: ResourceType */ + OptionalNameString /* 13: DescriptorName */ + OptionalBuffer_Last /* 14: VendorData */ + ')' {$$ = TrLinkChildren ($3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);} + | PARSEOP_I2C_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +InterruptTerm + : PARSEOP_INTERRUPT '(' {$$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} + OptionalResourceType_First + ',' InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($3,8,$4,$6,$8,$9,$10,$11,$12,$15);} + | PARSEOP_INTERRUPT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IOTerm + : PARSEOP_IO '(' {$$ = TrCreateLeafNode (PARSEOP_IO);} + IODecodeKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' ByteConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQNoFlagsTerm + : PARSEOP_IRQNOFLAGS '(' {$$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_IRQNOFLAGS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQTerm + : PARSEOP_IRQ '(' {$$ = TrCreateLeafNode (PARSEOP_IRQ);} + InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,5,$4,$6,$7,$8,$11);} + | PARSEOP_IRQ '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory24Term + : PARSEOP_MEMORY24 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);} + OptionalReadWriteKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY24 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32FixedTerm + : PARSEOP_MEMORY32FIXED '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,4,$4,$6,$8,$9);} + | PARSEOP_MEMORY32FIXED '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32Term + : PARSEOP_MEMORY32 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY32 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordIOTerm + : PARSEOP_QWORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_QWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordMemoryTerm + : PARSEOP_QWORDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_QWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordSpaceTerm + : PARSEOP_QWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_QWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +RegisterTerm + : PARSEOP_REGISTER '(' {$$ = TrCreateLeafNode (PARSEOP_REGISTER);} + AddressSpaceKeyword + ',' ByteConstExpr + ',' ByteConstExpr + ',' QWordConstExpr + OptionalAccessSize + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,6,$4,$6,$8,$10,$11,$12);} + | PARSEOP_REGISTER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SpiSerialBusTerm + : PARSEOP_SPI_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} + WordConstExpr /* 04: DeviceSelection */ + OptionalDevicePolarity /* 05: DevicePolarity */ + OptionalWireMode /* 06: WireMode */ + ',' ByteConstExpr /* 08: DataBitLength */ + OptionalSlaveMode /* 09: SlaveMode */ + ',' DWordConstExpr /* 11: ConnectionSpeed */ + ',' ClockPolarityKeyword /* 13: ClockPolarity */ + ',' ClockPhaseKeyword /* 15: ClockPhase */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);} + | PARSEOP_SPI_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnNoPriTerm + : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($3,1,$6);} + | PARSEOP_STARTDEPENDENTFN_NOPRI '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnTerm + : PARSEOP_STARTDEPENDENTFN '(' {$$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} + ByteConstExpr + ',' ByteConstExpr + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($3,3,$4,$6,$9);} + | PARSEOP_STARTDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UartSerialBusTerm + : PARSEOP_UART_SERIALBUS '(' {$$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} + DWordConstExpr /* 04: ConnectionSpeed */ + OptionalBitsPerByte /* 05: BitsPerByte */ + OptionalStopBits /* 06: StopBits */ + ',' ByteConstExpr /* 08: LinesInUse */ + OptionalEndian /* 09: Endianess */ + OptionalParityType /* 10: Parity */ + OptionalFlowControl /* 11: FlowControl */ + ',' WordConstExpr /* 13: Rx BufferSize */ + ',' WordConstExpr /* 15: Tx BufferSize */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);} + | PARSEOP_UART_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorLongTerm + : PARSEOP_VENDORLONG '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_VENDORLONG '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorShortTerm + : PARSEOP_VENDORSHORT '(' {$$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($3,2,$4,$7);} + | PARSEOP_VENDORSHORT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordBusNumberTerm + : PARSEOP_WORDBUSNUMBER '(' {$$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} + | PARSEOP_WORDBUSNUMBER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordIOTerm + : PARSEOP_WORDIO '(' {$$ = TrCreateLeafNode (PARSEOP_WORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_WORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordSpaceTerm + : PARSEOP_WORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_WORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Object References ***********************************************/ + +/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ + +NameString + : NameSeg {} + | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} + | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} + | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} + | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} + ; + +NameSeg + : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + + +/******* Helper rules ****************************************************/ + + +AmlPackageLengthTerm + : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);} + ; + +NameStringItem + : ',' NameString {$$ = $2;} + | ',' error {$$ = AslDoError (); yyclearin;} + ; + +TermArgItem + : ',' TermArg {$$ = $2;} + | ',' error {$$ = AslDoError (); yyclearin;} + ; + +OptionalBusMasterKeyword + : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} + ; + +OptionalAccessAttribTerm + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + | ',' AccessAttribKeyword {$$ = $2;} + ; + +OptionalAccessSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalAddressingMode + : ',' {$$ = NULL;} + | ',' AddressingModeKeyword {$$ = $2;} + ; + +OptionalAddressRange + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' AddressKeyword {$$ = $2;} + ; + +OptionalBitsPerByte + : ',' {$$ = NULL;} + | ',' BitsPerByteKeyword {$$ = $2;} + ; + +OptionalBuffer_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' DataBufferTerm {$$ = $2;} + ; + +OptionalByteConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalDecodeType + : ',' {$$ = NULL;} + | ',' DecodeKeyword {$$ = $2;} + ; + +OptionalDevicePolarity + : ',' {$$ = NULL;} + | ',' DevicePolarityKeyword {$$ = $2;} + ; + +OptionalDWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' DWordConstExpr {$$ = $2;} + ; + +OptionalEndian + : ',' {$$ = NULL;} + | ',' EndianKeyword {$$ = $2;} + ; + +OptionalFlowControl + : ',' {$$ = NULL;} + | ',' FlowControlKeyword {$$ = $2;} + ; + +OptionalIoRestriction + : ',' {$$ = NULL;} + | ',' IoRestrictionKeyword {$$ = $2;} + ; + +OptionalListString + : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' TermArg {$$ = $2;} + ; + +OptionalMaxType + : ',' {$$ = NULL;} + | ',' MaxKeyword {$$ = $2;} + ; + +OptionalMemType + : ',' {$$ = NULL;} + | ',' MemTypeKeyword {$$ = $2;} + ; + +OptionalMinType + : ',' {$$ = NULL;} + | ',' MinKeyword {$$ = $2;} + ; + +OptionalNameString + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_First + : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} + | NameString {$$ = $1;} + ; + +OptionalObjectTypeKeyword + : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | ',' ObjectTypeKeyword {$$ = $2;} + ; + +OptionalParityType + : ',' {$$ = NULL;} + | ',' ParityTypeKeyword {$$ = $2;} + ; + +OptionalQWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' QWordConstExpr {$$ = $2;} + ; + +OptionalRangeType + : ',' {$$ = NULL;} + | ',' RangeTypeKeyword {$$ = $2;} + ; + +OptionalReadWriteKeyword + : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} + ; + +OptionalReference + : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ + | ',' {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ + | ',' TermArg {$$ = $2;} + ; + +OptionalResourceType_First + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ResourceTypeKeyword {$$ = $1;} + ; + +OptionalResourceType + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' ResourceTypeKeyword {$$ = $2;} + ; + +OptionalReturnArg + : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ + | TermArg {$$ = $1;} + ; + +OptionalSerializeRuleKeyword + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' SerializeRuleKeyword {$$ = $2;} + ; + +OptionalSlaveMode + : ',' {$$ = NULL;} + | ',' SlaveModeKeyword {$$ = $2;} + ; + +OptionalShareType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ShareTypeKeyword {$$ = $2;} + ; + +OptionalShareType_First + : {$$ = NULL;} + | ShareTypeKeyword {$$ = $1;} + ; + +OptionalStopBits + : ',' {$$ = NULL;} + | ',' StopBitsKeyword {$$ = $2;} + ; + +OptionalStringData + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' StringData {$$ = $2;} + ; + +OptionalTermArg + : {$$ = NULL;} + | TermArg {$$ = $1;} + ; + +OptionalType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalTranslationType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TranslationKeyword {$$ = $2;} + ; + +OptionalWireMode + : ',' {$$ = NULL;} + | ',' WireModeKeyword {$$ = $2;} + ; + +OptionalWordConst + : {$$ = NULL;} + | WordConst {$$ = $1;} + ; + +OptionalWordConstExpr + : ',' {$$ = NULL;} + | ',' WordConstExpr {$$ = $2;} + ; + +OptionalXferSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' XferSizeKeyword {$$ = $2;} + ; diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index 1ed69724d2b0..84a23dbeb463 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "actables.h" #include "acdisasm.h" @@ -284,8 +283,11 @@ AslDoDisassembly ( return (AE_CTRL_CONTINUE); } - ACPI_FREE (Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free the filename string */ + Gbl_Files[ASL_FILE_INPUT].Filename = NULL; + + CmDeleteCaches (); return (AE_OK); } @@ -325,8 +327,13 @@ AslDoOneFile ( return (Status); } - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; - UtConvertBackslashes (Filename); + /* Take a copy of the input filename, convert any backslashes */ + + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + UtConvertBackslashes (Gbl_Files[ASL_FILE_INPUT].Filename); /* * AML Disassembly (Optional) @@ -396,7 +403,6 @@ AslDoOneFile ( if (Gbl_Signature) { - ACPI_FREE (Gbl_Signature); Gbl_Signature = NULL; } diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 0317041b4e98..7ea43a07dba7 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* Configuration */ #define ASL_SPACES_PER_TAB 4 @@ -70,6 +69,15 @@ typedef struct asl_file_node ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; +void +AslParserCleanup ( + void) +{ + + yy_delete_buffer (YY_CURRENT_BUFFER); +} + + /******************************************************************************* * * FUNCTION: AslDoLineDirective @@ -259,7 +267,11 @@ AslPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_CurrentLineNumber = 1; yyin = InputFile; } @@ -797,7 +809,7 @@ CompletedString: */ *StringBuffer = 0; - CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); + CleanString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); if (!CleanString) { AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, diff --git a/source/compiler/aslsupport.y b/source/compiler/aslsupport.y new file mode 100644 index 000000000000..a1fdec3437d2 --- /dev/null +++ b/source/compiler/aslsupport.y @@ -0,0 +1,119 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslsupport.y - Bison/Yacc C support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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. + */ + +') + +/****************************************************************************** + * + * Local support functions + * + *****************************************************************************/ + +/*! [Begin] no source code translation */ +int +AslCompilerwrap(void) +{ + return (1); +} +/*! [End] no source code translation !*/ + + +void * +AslLocalAllocate (unsigned int Size) +{ + void *Mem; + + + DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); + + Mem = UtStringCacheCalloc (Size); + if (!Mem) + { + AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_InputByteCount, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + exit (1); + } + + return (Mem); +} + +ACPI_PARSE_OBJECT * +AslDoError (void) +{ + + + return (TrCreateLeafNode (PARSEOP_ERRORNODE)); + +} + + +/******************************************************************************* + * + * FUNCTION: UtGetOpName + * + * PARAMETERS: ParseOpcode - Parser keyword ID + * + * RETURN: Pointer to the opcode name + * + * DESCRIPTION: Get the ascii name of the parse opcode + * + ******************************************************************************/ + +char * +UtGetOpName ( + UINT32 ParseOpcode) +{ +#ifdef ASL_YYTNAME_START + /* + * First entries (ASL_YYTNAME_START) in yytname are special reserved names. + * Ignore first 8 characters of the name + */ + return ((char *) yytname + [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); +#else + return ("[Unknown parser generator]"); +#endif +} diff --git a/source/compiler/asltokens.y b/source/compiler/asltokens.y new file mode 100644 index 000000000000..c296fea30bec --- /dev/null +++ b/source/compiler/asltokens.y @@ -0,0 +1,386 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltokens.y - Bison/Yacc token types + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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. + */ + +') + +/****************************************************************************** + * + * Token types: These are returned by the lexer + * + * NOTE: This list MUST match the AslKeywordMapping table found + * in aslmap.c EXACTLY! Double check any changes! + * + *****************************************************************************/ + +%token PARSEOP_ACCESSAS +%token PARSEOP_ACCESSATTRIB_BLOCK +%token PARSEOP_ACCESSATTRIB_BLOCK_CALL +%token PARSEOP_ACCESSATTRIB_BYTE +%token PARSEOP_ACCESSATTRIB_MULTIBYTE +%token PARSEOP_ACCESSATTRIB_QUICK +%token PARSEOP_ACCESSATTRIB_RAW_BYTES +%token PARSEOP_ACCESSATTRIB_RAW_PROCESS +%token PARSEOP_ACCESSATTRIB_SND_RCV +%token PARSEOP_ACCESSATTRIB_WORD +%token PARSEOP_ACCESSATTRIB_WORD_CALL +%token PARSEOP_ACCESSTYPE_ANY +%token PARSEOP_ACCESSTYPE_BUF +%token PARSEOP_ACCESSTYPE_BYTE +%token PARSEOP_ACCESSTYPE_DWORD +%token PARSEOP_ACCESSTYPE_QWORD +%token PARSEOP_ACCESSTYPE_WORD +%token PARSEOP_ACQUIRE +%token PARSEOP_ADD +%token PARSEOP_ADDRESSINGMODE_7BIT +%token PARSEOP_ADDRESSINGMODE_10BIT +%token PARSEOP_ADDRESSTYPE_ACPI +%token PARSEOP_ADDRESSTYPE_MEMORY +%token PARSEOP_ADDRESSTYPE_NVS +%token PARSEOP_ADDRESSTYPE_RESERVED +%token PARSEOP_ALIAS +%token PARSEOP_AND +%token PARSEOP_ARG0 +%token PARSEOP_ARG1 +%token PARSEOP_ARG2 +%token PARSEOP_ARG3 +%token PARSEOP_ARG4 +%token PARSEOP_ARG5 +%token PARSEOP_ARG6 +%token PARSEOP_BANKFIELD +%token PARSEOP_BITSPERBYTE_EIGHT +%token PARSEOP_BITSPERBYTE_FIVE +%token PARSEOP_BITSPERBYTE_NINE +%token PARSEOP_BITSPERBYTE_SEVEN +%token PARSEOP_BITSPERBYTE_SIX +%token PARSEOP_BREAK +%token PARSEOP_BREAKPOINT +%token PARSEOP_BUFFER +%token PARSEOP_BUSMASTERTYPE_MASTER +%token PARSEOP_BUSMASTERTYPE_NOTMASTER +%token PARSEOP_BYTECONST +%token PARSEOP_CASE +%token PARSEOP_CLOCKPHASE_FIRST +%token PARSEOP_CLOCKPHASE_SECOND +%token PARSEOP_CLOCKPOLARITY_HIGH +%token PARSEOP_CLOCKPOLARITY_LOW +%token PARSEOP_CONCATENATE +%token PARSEOP_CONCATENATERESTEMPLATE +%token PARSEOP_CONDREFOF +%token PARSEOP_CONNECTION +%token PARSEOP_CONTINUE +%token PARSEOP_COPYOBJECT +%token PARSEOP_CREATEBITFIELD +%token PARSEOP_CREATEBYTEFIELD +%token PARSEOP_CREATEDWORDFIELD +%token PARSEOP_CREATEFIELD +%token PARSEOP_CREATEQWORDFIELD +%token PARSEOP_CREATEWORDFIELD +%token PARSEOP_DATABUFFER +%token PARSEOP_DATATABLEREGION +%token PARSEOP_DEBUG +%token PARSEOP_DECODETYPE_POS +%token PARSEOP_DECODETYPE_SUB +%token PARSEOP_DECREMENT +%token PARSEOP_DEFAULT +%token PARSEOP_DEFAULT_ARG +%token PARSEOP_DEFINITIONBLOCK +%token PARSEOP_DEREFOF +%token PARSEOP_DEVICE +%token PARSEOP_DEVICEPOLARITY_HIGH +%token PARSEOP_DEVICEPOLARITY_LOW +%token PARSEOP_DIVIDE +%token PARSEOP_DMA +%token PARSEOP_DMATYPE_A +%token PARSEOP_DMATYPE_COMPATIBILITY +%token PARSEOP_DMATYPE_B +%token PARSEOP_DMATYPE_F +%token PARSEOP_DWORDCONST +%token PARSEOP_DWORDIO +%token PARSEOP_DWORDMEMORY +%token PARSEOP_DWORDSPACE +%token PARSEOP_EISAID +%token PARSEOP_ELSE +%token PARSEOP_ELSEIF +%token PARSEOP_ENDDEPENDENTFN +%token PARSEOP_ENDIAN_BIG +%token PARSEOP_ENDIAN_LITTLE +%token PARSEOP_ENDTAG +%token PARSEOP_ERRORNODE +%token PARSEOP_EVENT +%token PARSEOP_EXTENDEDIO +%token PARSEOP_EXTENDEDMEMORY +%token PARSEOP_EXTENDEDSPACE +%token PARSEOP_EXTERNAL +%token PARSEOP_FATAL +%token PARSEOP_FIELD +%token PARSEOP_FINDSETLEFTBIT +%token PARSEOP_FINDSETRIGHTBIT +%token PARSEOP_FIXEDDMA +%token PARSEOP_FIXEDIO +%token PARSEOP_FLOWCONTROL_HW +%token PARSEOP_FLOWCONTROL_NONE +%token PARSEOP_FLOWCONTROL_SW +%token PARSEOP_FROMBCD +%token PARSEOP_FUNCTION +%token PARSEOP_GPIO_INT +%token PARSEOP_GPIO_IO +%token PARSEOP_I2C_SERIALBUS +%token PARSEOP_IF +%token PARSEOP_INCLUDE +%token PARSEOP_INCLUDE_END +%token PARSEOP_INCREMENT +%token PARSEOP_INDEX +%token PARSEOP_INDEXFIELD +%token PARSEOP_INTEGER +%token PARSEOP_INTERRUPT +%token PARSEOP_INTLEVEL_ACTIVEBOTH +%token PARSEOP_INTLEVEL_ACTIVEHIGH +%token PARSEOP_INTLEVEL_ACTIVELOW +%token PARSEOP_INTTYPE_EDGE +%token PARSEOP_INTTYPE_LEVEL +%token PARSEOP_IO +%token PARSEOP_IODECODETYPE_10 +%token PARSEOP_IODECODETYPE_16 +%token PARSEOP_IORESTRICT_IN +%token PARSEOP_IORESTRICT_NONE +%token PARSEOP_IORESTRICT_OUT +%token PARSEOP_IORESTRICT_PRESERVE +%token PARSEOP_IRQ +%token PARSEOP_IRQNOFLAGS +%token PARSEOP_LAND +%token PARSEOP_LEQUAL +%token PARSEOP_LGREATER +%token PARSEOP_LGREATEREQUAL +%token PARSEOP_LLESS +%token PARSEOP_LLESSEQUAL +%token PARSEOP_LNOT +%token PARSEOP_LNOTEQUAL +%token PARSEOP_LOAD +%token PARSEOP_LOADTABLE +%token PARSEOP_LOCAL0 +%token PARSEOP_LOCAL1 +%token PARSEOP_LOCAL2 +%token PARSEOP_LOCAL3 +%token PARSEOP_LOCAL4 +%token PARSEOP_LOCAL5 +%token PARSEOP_LOCAL6 +%token PARSEOP_LOCAL7 +%token PARSEOP_LOCKRULE_LOCK +%token PARSEOP_LOCKRULE_NOLOCK +%token PARSEOP_LOR +%token PARSEOP_MATCH +%token PARSEOP_MATCHTYPE_MEQ +%token PARSEOP_MATCHTYPE_MGE +%token PARSEOP_MATCHTYPE_MGT +%token PARSEOP_MATCHTYPE_MLE +%token PARSEOP_MATCHTYPE_MLT +%token PARSEOP_MATCHTYPE_MTR +%token PARSEOP_MAXTYPE_FIXED +%token PARSEOP_MAXTYPE_NOTFIXED +%token PARSEOP_MEMORY24 +%token PARSEOP_MEMORY32 +%token PARSEOP_MEMORY32FIXED +%token PARSEOP_MEMTYPE_CACHEABLE +%token PARSEOP_MEMTYPE_NONCACHEABLE +%token PARSEOP_MEMTYPE_PREFETCHABLE +%token PARSEOP_MEMTYPE_WRITECOMBINING +%token PARSEOP_METHOD +%token PARSEOP_METHODCALL +%token PARSEOP_MID +%token PARSEOP_MINTYPE_FIXED +%token PARSEOP_MINTYPE_NOTFIXED +%token PARSEOP_MOD +%token PARSEOP_MULTIPLY +%token PARSEOP_MUTEX +%token PARSEOP_NAME +%token PARSEOP_NAMESEG +%token PARSEOP_NAMESTRING +%token PARSEOP_NAND +%token PARSEOP_NOOP +%token PARSEOP_NOR +%token PARSEOP_NOT +%token PARSEOP_NOTIFY +%token PARSEOP_OBJECTTYPE +%token PARSEOP_OBJECTTYPE_BFF +%token PARSEOP_OBJECTTYPE_BUF +%token PARSEOP_OBJECTTYPE_DDB +%token PARSEOP_OBJECTTYPE_DEV +%token PARSEOP_OBJECTTYPE_EVT +%token PARSEOP_OBJECTTYPE_FLD +%token PARSEOP_OBJECTTYPE_INT +%token PARSEOP_OBJECTTYPE_MTH +%token PARSEOP_OBJECTTYPE_MTX +%token PARSEOP_OBJECTTYPE_OPR +%token PARSEOP_OBJECTTYPE_PKG +%token PARSEOP_OBJECTTYPE_POW +%token PARSEOP_OBJECTTYPE_PRO +%token PARSEOP_OBJECTTYPE_STR +%token PARSEOP_OBJECTTYPE_THZ +%token PARSEOP_OBJECTTYPE_UNK +%token PARSEOP_OFFSET +%token PARSEOP_ONE +%token PARSEOP_ONES +%token PARSEOP_OPERATIONREGION +%token PARSEOP_OR +%token PARSEOP_PACKAGE +%token PARSEOP_PACKAGE_LENGTH +%token PARSEOP_PARITYTYPE_EVEN +%token PARSEOP_PARITYTYPE_MARK +%token PARSEOP_PARITYTYPE_NONE +%token PARSEOP_PARITYTYPE_ODD +%token PARSEOP_PARITYTYPE_SPACE +%token PARSEOP_PIN_NOPULL +%token PARSEOP_PIN_PULLDEFAULT +%token PARSEOP_PIN_PULLDOWN +%token PARSEOP_PIN_PULLUP +%token PARSEOP_POWERRESOURCE +%token PARSEOP_PROCESSOR +%token PARSEOP_QWORDCONST +%token PARSEOP_QWORDIO +%token PARSEOP_QWORDMEMORY +%token PARSEOP_QWORDSPACE +%token PARSEOP_RANGETYPE_ENTIRE +%token PARSEOP_RANGETYPE_ISAONLY +%token PARSEOP_RANGETYPE_NONISAONLY +%token PARSEOP_RAW_DATA +%token PARSEOP_READWRITETYPE_BOTH +%token PARSEOP_READWRITETYPE_READONLY +%token PARSEOP_REFOF +%token PARSEOP_REGIONSPACE_CMOS +%token PARSEOP_REGIONSPACE_EC +%token PARSEOP_REGIONSPACE_FFIXEDHW +%token PARSEOP_REGIONSPACE_GPIO +%token PARSEOP_REGIONSPACE_GSBUS +%token PARSEOP_REGIONSPACE_IO +%token PARSEOP_REGIONSPACE_IPMI +%token PARSEOP_REGIONSPACE_MEM +%token PARSEOP_REGIONSPACE_PCC +%token PARSEOP_REGIONSPACE_PCI +%token PARSEOP_REGIONSPACE_PCIBAR +%token PARSEOP_REGIONSPACE_SMBUS +%token PARSEOP_REGISTER +%token PARSEOP_RELEASE +%token PARSEOP_RESERVED_BYTES +%token PARSEOP_RESET +%token PARSEOP_RESOURCETEMPLATE +%token PARSEOP_RESOURCETYPE_CONSUMER +%token PARSEOP_RESOURCETYPE_PRODUCER +%token PARSEOP_RETURN +%token PARSEOP_REVISION +%token PARSEOP_SCOPE +%token PARSEOP_SERIALIZERULE_NOTSERIAL +%token PARSEOP_SERIALIZERULE_SERIAL +%token PARSEOP_SHARETYPE_EXCLUSIVE +%token PARSEOP_SHARETYPE_EXCLUSIVEWAKE +%token PARSEOP_SHARETYPE_SHARED +%token PARSEOP_SHARETYPE_SHAREDWAKE +%token PARSEOP_SHIFTLEFT +%token PARSEOP_SHIFTRIGHT +%token PARSEOP_SIGNAL +%token PARSEOP_SIZEOF +%token PARSEOP_SLAVEMODE_CONTROLLERINIT +%token PARSEOP_SLAVEMODE_DEVICEINIT +%token PARSEOP_SLEEP +%token PARSEOP_SPI_SERIALBUS +%token PARSEOP_STALL +%token PARSEOP_STARTDEPENDENTFN +%token PARSEOP_STARTDEPENDENTFN_NOPRI +%token PARSEOP_STOPBITS_ONE +%token PARSEOP_STOPBITS_ONEPLUSHALF +%token PARSEOP_STOPBITS_TWO +%token PARSEOP_STOPBITS_ZERO +%token PARSEOP_STORE +%token PARSEOP_STRING_LITERAL +%token PARSEOP_SUBTRACT +%token PARSEOP_SWITCH +%token PARSEOP_THERMALZONE +%token PARSEOP_TIMER +%token PARSEOP_TOBCD +%token PARSEOP_TOBUFFER +%token PARSEOP_TODECIMALSTRING +%token PARSEOP_TOHEXSTRING +%token PARSEOP_TOINTEGER +%token PARSEOP_TOSTRING +%token PARSEOP_TOUUID +%token PARSEOP_TRANSLATIONTYPE_DENSE +%token PARSEOP_TRANSLATIONTYPE_SPARSE +%token PARSEOP_TYPE_STATIC +%token PARSEOP_TYPE_TRANSLATION +%token PARSEOP_UART_SERIALBUS +%token PARSEOP_UNICODE +%token PARSEOP_UNLOAD +%token PARSEOP_UPDATERULE_ONES +%token PARSEOP_UPDATERULE_PRESERVE +%token PARSEOP_UPDATERULE_ZEROS +%token PARSEOP_VAR_PACKAGE +%token PARSEOP_VENDORLONG +%token PARSEOP_VENDORSHORT +%token PARSEOP_WAIT +%token PARSEOP_WHILE +%token PARSEOP_WIREMODE_FOUR +%token PARSEOP_WIREMODE_THREE +%token PARSEOP_WORDBUSNUMBER +%token PARSEOP_WORDCONST +%token PARSEOP_WORDIO +%token PARSEOP_WORDSPACE +%token PARSEOP_XFERSIZE_8 +%token PARSEOP_XFERSIZE_16 +%token PARSEOP_XFERSIZE_32 +%token PARSEOP_XFERSIZE_64 +%token PARSEOP_XFERSIZE_128 +%token PARSEOP_XFERSIZE_256 +%token PARSEOP_XFERTYPE_8 +%token PARSEOP_XFERTYPE_8_16 +%token PARSEOP_XFERTYPE_16 +%token PARSEOP_XOR +%token PARSEOP_ZERO + +/* + * Special functions. These should probably stay at the end of this + * table. + */ +%token PARSEOP___DATE__ +%token PARSEOP___FILE__ +%token PARSEOP___LINE__ +%token PARSEOP___PATH__ diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 9615fe6c6e47..34c6ae717583 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" @@ -377,7 +376,6 @@ TrDoDefinitionBlock ( * * RETURN: None * - * * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is * no actual AML opcode for SWITCH -- it must be simulated. * diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 0ea4528baf66..cd84d8bf5667 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acapps.h" @@ -79,15 +78,29 @@ static ACPI_PARSE_OBJECT * TrGetNextNode ( void) { + ASL_CACHE_INFO *Cache; + - if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast) + if (Gbl_ParseOpCacheNext >= Gbl_ParseOpCacheLast) { - Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * - ASL_NODE_CACHE_SIZE); - Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_ParseOpCacheList; + Gbl_ParseOpCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_ParseOpCacheNext = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Cache->Buffer); + Gbl_ParseOpCacheLast = Gbl_ParseOpCacheNext + ASL_PARSEOP_CACHE_SIZE; } - return (Gbl_NodeCacheNext++); + Gbl_ParseOpCount++; + return (Gbl_ParseOpCacheNext++); } diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 7e297d3b6721..44c937f2f63e 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLTYPES_H #define __ASLTYPES_H @@ -175,6 +174,16 @@ typedef enum #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +/* Cache block structure for ParseOps and Strings */ + +typedef struct asl_cache_info +{ + void *Next; + char Buffer[1]; + +} ASL_CACHE_INFO; + + typedef struct asl_include_dir { char *Dir; diff --git a/source/compiler/asltypes.y b/source/compiler/asltypes.y new file mode 100644 index 000000000000..b9914531b4e3 --- /dev/null +++ b/source/compiler/asltypes.y @@ -0,0 +1,381 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltypes.y - Bison/Yacc production types/names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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. + */ + +') + +/****************************************************************************** + * + * Production names + * + *****************************************************************************/ + +%type ArgList +%type ASLCode +%type BufferData +%type BufferTermData +%type CompilerDirective +%type DataObject +%type DefinitionBlockTerm +%type IntegerData +%type NamedObject +%type NameSpaceModifier +%type Object +%type ObjectList +%type PackageData +%type ParameterTypePackage +%type ParameterTypePackageList +%type ParameterTypesPackage +%type ParameterTypesPackageList +%type RequiredTarget +%type SimpleTarget +%type StringData +%type Target +%type Term +%type TermArg +%type TermList +%type UserTerm + +/* Type4Opcode is obsolete */ + +%type Type1Opcode +%type Type2BufferOpcode +%type Type2BufferOrStringOpcode +%type Type2IntegerOpcode +%type Type2Opcode +%type Type2StringOpcode +%type Type3Opcode +%type Type5Opcode +%type Type6Opcode + +%type AccessAsTerm +%type ExternalTerm +%type FieldUnit +%type FieldUnitEntry +%type FieldUnitList +%type IncludeTerm +%type OffsetTerm +%type OptionalAccessAttribTerm + +/* Named Objects */ + +%type BankFieldTerm +%type CreateBitFieldTerm +%type CreateByteFieldTerm +%type CreateDWordFieldTerm +%type CreateFieldTerm +%type CreateQWordFieldTerm +%type CreateWordFieldTerm +%type DataRegionTerm +%type DeviceTerm +%type EventTerm +%type FieldTerm +%type FunctionTerm +%type IndexFieldTerm +%type MethodTerm +%type MutexTerm +%type OpRegionTerm +%type OpRegionSpaceIdTerm +%type PowerResTerm +%type ProcessorTerm +%type ThermalZoneTerm + +/* Namespace modifiers */ + +%type AliasTerm +%type NameTerm +%type ScopeTerm + +/* Type 1 opcodes */ + +%type BreakPointTerm +%type BreakTerm +%type CaseDefaultTermList +%type CaseTerm +%type ContinueTerm +%type DefaultTerm +%type ElseTerm +%type FatalTerm +%type IfElseTerm +%type IfTerm +%type LoadTerm +%type NoOpTerm +%type NotifyTerm +%type ReleaseTerm +%type ResetTerm +%type ReturnTerm +%type SignalTerm +%type SleepTerm +%type StallTerm +%type SwitchTerm +%type UnloadTerm +%type WhileTerm +/* %type CaseTermList */ + +/* Type 2 opcodes */ + +%type AcquireTerm +%type AddTerm +%type AndTerm +%type ConcatResTerm +%type ConcatTerm +%type CondRefOfTerm +%type CopyObjectTerm +%type DecTerm +%type DerefOfTerm +%type DivideTerm +%type FindSetLeftBitTerm +%type FindSetRightBitTerm +%type FromBCDTerm +%type IncTerm +%type IndexTerm +%type LAndTerm +%type LEqualTerm +%type LGreaterEqualTerm +%type LGreaterTerm +%type LLessEqualTerm +%type LLessTerm +%type LNotEqualTerm +%type LNotTerm +%type LoadTableTerm +%type LOrTerm +%type MatchTerm +%type MidTerm +%type ModTerm +%type MultiplyTerm +%type NAndTerm +%type NOrTerm +%type NotTerm +%type ObjectTypeTerm +%type OrTerm +%type RefOfTerm +%type ShiftLeftTerm +%type ShiftRightTerm +%type SizeOfTerm +%type StoreTerm +%type SubtractTerm +%type TimerTerm +%type ToBCDTerm +%type ToBufferTerm +%type ToDecimalStringTerm +%type ToHexStringTerm +%type ToIntegerTerm +%type ToStringTerm +%type WaitTerm +%type XOrTerm + +/* Keywords */ + +%type AccessAttribKeyword +%type AccessTypeKeyword +%type AddressingModeKeyword +%type AddressKeyword +%type AddressSpaceKeyword +%type BitsPerByteKeyword +%type ClockPhaseKeyword +%type ClockPolarityKeyword +%type DecodeKeyword +%type DevicePolarityKeyword +%type DMATypeKeyword +%type EndianKeyword +%type FlowControlKeyword +%type InterruptLevel +%type InterruptTypeKeyword +%type IODecodeKeyword +%type IoRestrictionKeyword +%type LockRuleKeyword +%type MatchOpKeyword +%type MaxKeyword +%type MemTypeKeyword +%type MinKeyword +%type ObjectTypeKeyword +%type OptionalBusMasterKeyword +%type OptionalReadWriteKeyword +%type ParityTypeKeyword +%type PinConfigByte +%type PinConfigKeyword +%type RangeTypeKeyword +%type RegionSpaceKeyword +%type ResourceTypeKeyword +%type SerializeRuleKeyword +%type ShareTypeKeyword +%type SlaveModeKeyword +%type StopBitsKeyword +%type TranslationKeyword +%type TypeKeyword +%type UpdateRuleKeyword +%type WireModeKeyword +%type XferSizeKeyword +%type XferTypeKeyword + +/* Types */ + +%type SuperName +%type ObjectTypeName +%type ArgTerm +%type LocalTerm +%type DebugTerm + +%type Integer +%type ByteConst +%type WordConst +%type DWordConst +%type QWordConst +%type String + +%type ConstTerm +%type ConstExprTerm +%type ByteConstExpr +%type WordConstExpr +%type DWordConstExpr +%type QWordConstExpr + +%type DWordList +%type BufferTerm +%type ByteList + +%type PackageElement +%type PackageList +%type PackageTerm +%type VarPackageLengthTerm + +/* Macros */ + +%type EISAIDTerm +%type ResourceMacroList +%type ResourceMacroTerm +%type ResourceTemplateTerm +%type ToUUIDTerm +%type UnicodeTerm + +/* Resource Descriptors */ + +%type ConnectionTerm +%type DataBufferTerm +%type DMATerm +%type DWordIOTerm +%type DWordMemoryTerm +%type DWordSpaceTerm +%type EndDependentFnTerm +%type ExtendedIOTerm +%type ExtendedMemoryTerm +%type ExtendedSpaceTerm +%type FixedDmaTerm +%type FixedIOTerm +%type GpioIntTerm +%type GpioIoTerm +%type I2cSerialBusTerm +%type InterruptTerm +%type IOTerm +%type IRQNoFlagsTerm +%type IRQTerm +%type Memory24Term +%type Memory32FixedTerm +%type Memory32Term +%type NameSeg +%type NameString +%type QWordIOTerm +%type QWordMemoryTerm +%type QWordSpaceTerm +%type RegisterTerm +%type SpiSerialBusTerm +%type StartDependentFnNoPriTerm +%type StartDependentFnTerm +%type UartSerialBusTerm +%type VendorLongTerm +%type VendorShortTerm +%type WordBusNumberTerm +%type WordIOTerm +%type WordSpaceTerm + +/* Local types that help construct the AML, not in ACPI spec */ + +%type AmlPackageLengthTerm +%type IncludeEndTerm +%type NameStringItem +%type TermArgItem + +%type OptionalAccessSize +%type OptionalAddressingMode +%type OptionalAddressRange +%type OptionalBitsPerByte +%type OptionalBuffer_Last +%type OptionalByteConstExpr +%type OptionalCount +%type OptionalDecodeType +%type OptionalDevicePolarity +%type OptionalDWordConstExpr +%type OptionalEndian +%type OptionalFlowControl +%type OptionalIoRestriction +%type OptionalListString +%type OptionalMaxType +%type OptionalMemType +%type OptionalMinType +%type OptionalNameString +%type OptionalNameString_First +%type OptionalNameString_Last +%type OptionalObjectTypeKeyword +%type OptionalParameterTypePackage +%type OptionalParameterTypesPackage +%type OptionalParityType +%type OptionalQWordConstExpr +%type OptionalRangeType +%type OptionalReference +%type OptionalResourceType +%type OptionalResourceType_First +%type OptionalReturnArg +%type OptionalSerializeRuleKeyword +%type OptionalShareType +%type OptionalShareType_First +%type OptionalSlaveMode +%type OptionalStopBits +%type OptionalStringData +%type OptionalTermArg +%type OptionalTranslationType_Last +%type OptionalType +%type OptionalType_Last +%type OptionalWireMode +%type OptionalWordConst +%type OptionalWordConstExpr +%type OptionalXferSize diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 7dc0697236b8..c9a9fac6d75d 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acdisasm.h" @@ -241,37 +240,6 @@ UtEndEvent ( } -/******************************************************************************* - * - * FUNCTION: UtHexCharToValue - * - * PARAMETERS: HexChar - Hex character in Ascii - * - * RETURN: The binary value of the hex character - * - * DESCRIPTION: Perform ascii-to-hex translation - * - ******************************************************************************/ - -UINT8 -UtHexCharToValue ( - int HexChar) -{ - - if (HexChar <= 0x39) - { - return ((UINT8) (HexChar - 0x30)); - } - - if (HexChar <= 0x46) - { - return ((UINT8) (HexChar - 0x37)); - } - - return ((UINT8) (HexChar - 0x57)); -} - - /******************************************************************************* * * FUNCTION: UtConvertByteToHex @@ -296,8 +264,8 @@ UtConvertByteToHex ( Buffer[0] = '0'; Buffer[1] = 'x'; - Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); } @@ -312,7 +280,7 @@ UtConvertByteToHex ( * RETURN: Ascii hex byte is stored in Buffer. * * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" + * with '0', and a trailing 'h' is added. * ******************************************************************************/ @@ -323,8 +291,8 @@ UtConvertByteToAsmHex ( { Buffer[0] = '0'; - Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); Buffer[3] = 'h'; } @@ -585,7 +553,7 @@ UtCheckIntegerRange ( /******************************************************************************* * - * FUNCTION: UtGetStringBuffer + * FUNCTION: UtStringCacheCalloc * * PARAMETERS: Length - Size of buffer requested * @@ -598,22 +566,42 @@ UtCheckIntegerRange ( ******************************************************************************/ char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length) { char *Buffer; + ASL_CACHE_INFO *Cache; + if (Length > ASL_STRING_CACHE_SIZE) + { + Buffer = UtLocalCalloc (Length); + return (Buffer); + } + if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast) { - Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); - Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + - Length; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + ASL_STRING_CACHE_SIZE); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_StringCacheList; + Gbl_StringCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_StringCacheNext = Cache->Buffer; + Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE; } + Gbl_StringCount++; + Gbl_StringSize += Length; + Buffer = Gbl_StringCacheNext; Gbl_StringCacheNext += Length; - return (Buffer); } @@ -646,7 +634,8 @@ UtExpandLineBuffers ( NewSize = Gbl_LineBufferSize * 2; if (Gbl_CurrentLineBuffer) { - DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to %u\n", + DbgPrint (ASL_DEBUG_OUTPUT, + "Increasing line buffer size from %u to %u\n", Gbl_LineBufferSize, NewSize); } @@ -691,6 +680,30 @@ ErrorExit: } +/****************************************************************************** + * + * FUNCTION: UtFreeLineBuffers + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all line buffers + * + *****************************************************************************/ + +void +UtFreeLineBuffers ( + void) +{ + + free (Gbl_CurrentLineBuffer); + free (Gbl_MainTokenBuffer); + free (Gbl_MacroTokenBuffer); + free (Gbl_ExpressionTokenBuffer); +} + + /******************************************************************************* * * FUNCTION: UtInternalizeName @@ -723,9 +736,9 @@ UtInternalizeName ( Info.ExternalName = ExternalName; AcpiNsGetInternalNameLength (&Info); - /* We need a segment to store the internal name */ + /* We need a segment to store the internal name */ - Info.InternalName = UtGetStringBuffer (Info.Length); + Info.InternalName = UtStringCacheCalloc (Info.Length); if (!Info.InternalName) { return (AE_NO_MEMORY); diff --git a/source/compiler/asluuid.c b/source/compiler/asluuid.c index f7b1f0c5890f..f79a33b7f879 100644 --- a/source/compiler/asluuid.c +++ b/source/compiler/asluuid.c @@ -41,42 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asluuid") -/* - * UUID support functions. - * - * This table is used to convert an input UUID ascii string to a 16 byte - * buffer and the reverse. The table maps a UUID buffer index 0-15 to - * the index within the 36-byte UUID string where the associated 2-byte - * hex value can be found. - * - * 36-byte UUID strings are of the form: - * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp - * Where aa-pp are one byte hex numbers, made up of two hex digits - * - * Note: This table is basically the inverse of the string-to-offset table - * found in the ACPI spec in the description of the ToUUID macro. - */ -static UINT8 Gbl_MapToUuidOffset[16] = -{ - 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 -}; - -#define UUID_BUFFER_LENGTH 16 -#define UUID_STRING_LENGTH 36 - -/* Positions for required hyphens (dashes) in UUID strings */ - -#define UUID_HYPHEN1_OFFSET 8 -#define UUID_HYPHEN2_OFFSET 13 -#define UUID_HYPHEN3_OFFSET 18 -#define UUID_HYPHEN4_OFFSET 23 +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -135,42 +106,6 @@ AuValidateUuid ( } -/******************************************************************************* - * - * FUNCTION: AuConvertStringToUuid - * - * PARAMETERS: InString - 36-byte formatted UUID string - * UuidBuffer - 16-byte UUID buffer - * - * RETURN: Status - * - * DESCRIPTION: Convert 36-byte formatted UUID string to 16-byte UUID buffer - * - ******************************************************************************/ - -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuidBuffer) -{ - UINT32 i; - - - if (!InString || !UuidBuffer) - { - return (AE_BAD_PARAMETER); - } - - for (i = 0; i < UUID_BUFFER_LENGTH; i++) - { - UuidBuffer[i] = (char) (UtHexCharToValue (InString[Gbl_MapToUuidOffset[i]]) << 4); - UuidBuffer[i] |= (char) UtHexCharToValue (InString[Gbl_MapToUuidOffset[i] + 1]); - } - - return (AE_OK); -} - - /******************************************************************************* * * FUNCTION: AuConvertUuidToString @@ -200,8 +135,11 @@ AuConvertUuidToString ( for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - OutString[Gbl_MapToUuidOffset[i]] = (UINT8) AslHexLookup[(UuidBuffer[i] >> 4) & 0xF]; - OutString[Gbl_MapToUuidOffset[i] + 1] = (UINT8) AslHexLookup[UuidBuffer[i] & 0xF]; + OutString[AcpiGbl_MapToUuidOffset[i]] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 4); + + OutString[AcpiGbl_MapToUuidOffset[i] + 1] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 0); } /* Insert required hyphens (dashes) */ diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 960bebcdd3b2..da4e9e31e9e0 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index ee3a0f8828e4..1cbd6e092c70 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" @@ -86,6 +85,20 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *MethodOp1, + ACPI_PARSE_OBJECT *MethodOp2); + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *Node); + /******************************************************************************* * @@ -130,6 +143,8 @@ XfCrossReferenceNamespace ( TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); + + ACPI_FREE (WalkState); return (AE_OK); } @@ -262,6 +277,178 @@ XfCheckFieldRange ( } } + +/******************************************************************************* + * + * FUNCTION: XfIsObjectParental + * + * PARAMETERS: ChildOp - Op to be checked + * PossibleParentOp - Determine if this op is in the family + * + * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp + * + * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to + * detect if a method is declared within another method. + * + ******************************************************************************/ + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *ChildOp, + ACPI_PARSE_OBJECT *PossibleParentOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + /* Search upwards through the tree for possible parent */ + + ParentOp = ChildOp; + while (ParentOp) + { + if (ParentOp == PossibleParentOp) + { + return (TRUE); + } + + ParentOp = ParentOp->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfGetParentMethod + * + * PARAMETERS: Op - Op to be checked + * + * RETURN: Op for parent method. NULL if object is not within a method. + * + * DESCRIPTION: Determine if an object is within a control method. Used to + * implement special rules for named references from within a + * control method. + * + * NOTE: It would be better to have the parser set a flag in the Op if possible. + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + if (!Op) + { + return (NULL); + } + + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (NULL); + } + + /* Walk upwards through the parse tree, up to the root if necessary */ + + ParentOp = Op; + while (ParentOp) + { + if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (ParentOp); + } + + ParentOp = ParentOp->Asl.Parent; + } + + /* Object is not within a method */ + + return (NULL); +} + +/******************************************************************************* + * + * FUNCTION: XfCheckIllegalReference + * + * PARAMETERS: Op - Op referring to the target + * TargetNode - Target of the reference + * + * RETURN: None. Emits error message for an illegal reference + * + * DESCRIPTION: Determine if a named reference is legal. A "named" reference + * is something like: Store(ABCD, ...), where ABCD is an AML + * Nameseg or Namepath. + * + * NOTE: Caller must ensure that the name Op is in fact a reference, and not + * an actual name declaration (creation of a named object). + * + ******************************************************************************/ + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *TargetNode) +{ + ACPI_PARSE_OBJECT *MethodOp1; + ACPI_PARSE_OBJECT *MethodOp2; + ACPI_PARSE_OBJECT *TargetOp; + + + /* + * Check for an illegal reference to a named object: + * + * 1) References from one control method to another, non-parent + * method are not allowed, they will fail at runtime. + * + * 2) Forward references within a control method are not allowed. + * AML interpreters use a one-pass parse of control methods + * so these forward references will fail at runtime. + */ + TargetOp = TargetNode->Op; + + MethodOp1 = XfGetParentMethod (Op); + MethodOp2 = XfGetParentMethod (TargetOp); + + /* Are both objects within control method(s)? */ + + if (!MethodOp1 || !MethodOp2) + { + return; + } + + /* Objects not in the same method? */ + + if (MethodOp1 != MethodOp2) + { + /* + * 1) Cross-method named reference + * + * This is OK if and only if the target reference is within in a + * method that is a parent of current method + */ + if (!XfIsObjectParental (MethodOp1, MethodOp2)) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, + Op->Asl.ExternalName); + } + } + + /* + * 2) Both reference and target are in the same method. Check if this is + * an (illegal) forward reference by examining the exact source code + * location of each (the referenced object and the object declaration). + * This is a bit nasty, yet effective. + */ + else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op, + Op->Asl.ExternalName); + } +} + + /******************************************************************************* * * FUNCTION: XfNamespaceLocateBegin @@ -471,6 +658,10 @@ XfNamespaceLocateBegin ( /* This node has been referenced, mark it for reference check */ Node->Flags |= ANOBJ_IS_REFERENCED; + + /* Check for an illegal reference */ + + XfCheckIllegalReference (Op, Node); } /* Attempt to optimize the NamePath */ diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index aa1f9d1e5d27..5c8fea3092a1 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -141,8 +141,6 @@ DtDoCompile ( Status = DtCompileDataTable (&FieldList); UtEndEvent (Event); - DtFreeFieldList (); - if (ACPI_FAILURE (Status)) { /* TBD: temporary error message. Msgs should come from function above */ @@ -170,6 +168,8 @@ DtDoCompile ( CleanupAndExit: + AcpiUtDeleteCaches (); + DtDeleteCaches (); CmCleanupAndExit (); return (Status); } @@ -298,7 +298,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -461,11 +461,11 @@ DtCompileTable ( return (AE_ERROR); } - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); if (Length > 0) { - Subtable->Buffer = UtLocalCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, UtStringCacheCalloc (Length)); } Subtable->Length = Length; Subtable->TotalLength = Length; @@ -567,8 +567,6 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); - ACPI_FREE (InlineSubtable->Buffer); - ACPI_FREE (InlineSubtable); LocalField = *Field; break; diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index db5d306d2110..553f5e6d1991 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -50,6 +50,10 @@ #include "acdisasm.h" +#define ASL_FIELD_CACHE_SIZE 512 +#define ASL_SUBTABLE_CACHE_SIZE 128 + + #undef DT_EXTERN #ifdef _DECLARE_DT_GLOBALS @@ -143,6 +147,18 @@ DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL); DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0); +/* Local caches */ + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_SubtableCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_SubtableCacheList, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheNext, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheLast, NULL); + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_FieldCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_FieldCacheList, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheNext, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheLast, NULL); + /* dtcompiler - main module */ @@ -368,8 +384,16 @@ void DtSetTableLength( void); +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void); + +DT_FIELD * +UtFieldCacheCalloc ( + void); + void -DtFreeFieldList ( +DtDeleteCaches ( void); @@ -419,6 +443,10 @@ ACPI_STATUS DtCompileFpdt ( void **PFieldList); +ACPI_STATUS +DtCompileGtdt ( + void **PFieldList); + ACPI_STATUS DtCompileHest ( void **PFieldList); diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index ff77242127c5..98c87798c543 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -259,7 +259,7 @@ DtCompileUuid ( } else { - Status = AuConvertStringToUuid (InString, (char *) Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } return (Status); diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 25d84ab059cc..f8e35fdd8a3b 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -133,7 +133,7 @@ DtTrim ( if (!ACPI_STRCMP (String, " ")) { - ReturnString = UtLocalCalloc (1); + ReturnString = UtStringCacheCalloc (1); return (ReturnString); } @@ -181,7 +181,7 @@ DtTrim ( /* Create the trimmed return string */ Length = ACPI_PTR_DIFF (End, Start) + 1; - ReturnString = UtLocalCalloc (Length + 1); + ReturnString = UtStringCacheCalloc (Length + 1); if (ACPI_STRLEN (Start)) { ACPI_STRNCPY (ReturnString, Start, Length); @@ -370,7 +370,7 @@ DtParseLine ( if ((Value && *Value) || IsNullString) { - Field = UtLocalCalloc (sizeof (DT_FIELD)); + Field = UtFieldCacheCalloc (); Field->Name = Name; Field->Value = Value; Field->Line = Line; @@ -380,11 +380,7 @@ DtParseLine ( DtLinkField (Field); } - else /* Ignore this field, it has no valid data */ - { - ACPI_FREE (Name); - ACPI_FREE (Value); - } + /* Else -- Ignore this field, it has no valid data */ return (AE_OK); } @@ -1035,6 +1031,8 @@ DtDumpSubtableList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nSubtable Tree: (Depth, Subtable, Length, TotalLength)\n\n"); DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL); + + DbgPrint (ASL_DEBUG_OUTPUT, "\n"); } diff --git a/source/compiler/dtsubtable.c b/source/compiler/dtsubtable.c index 90cb067bd0ee..a87198d39a65 100644 --- a/source/compiler/dtsubtable.c +++ b/source/compiler/dtsubtable.c @@ -75,11 +75,11 @@ DtCreateSubtable ( DT_SUBTABLE *Subtable; - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); /* Create a new buffer for the subtable data */ - Subtable->Buffer = UtLocalCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, UtStringCacheCalloc (Length)); ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index c341bf20e449..a0dee31e6896 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -736,16 +736,21 @@ DtCompileDmar ( InfoTable = AcpiDmTableInfoDmar1; break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); @@ -762,10 +767,20 @@ DtCompileDmar ( ParentTable = DtPeekSubtable (); DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - /* Optional Device Scope subtables */ + /* + * Optional Device Scope subtables + */ + if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + DtPopSubtable (); + continue; + } + DtPushSubtable (Subtable); DeviceScopeLength = DmarHeader->Length - Subtable->Length - ParentTable->Length; while (DeviceScopeLength) @@ -938,6 +953,125 @@ DtCompileFadt ( return (AE_OK); } +/****************************************************************************** + * + * FUNCTION: DtCompileGtdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile GTDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGtdt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *GtdtHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 GtCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional GT block subtable data + */ + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; + while (GtCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + + DtInsertSubtable (ParentTable, Subtable); + GtCount--; + } + DtPopSubtable (); + break; + + default: + + break; + } + + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -1501,6 +1635,16 @@ DtCompileMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); @@ -1792,6 +1936,11 @@ DtCompilePcct ( InfoTable = AcpiDmTableInfoPcct0; break; + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); @@ -2271,6 +2420,11 @@ DtCompileSrat ( InfoTable = AcpiDmTableInfoSrat2; break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); diff --git a/source/compiler/dttemplate.c b/source/compiler/dttemplate.c index 8cafbf959f80..4fb6be0d389d 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -187,6 +187,12 @@ GetTemplate: } Status = DtCreateOneTemplate (Signature, TableData); + + + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); return (Status); } @@ -397,6 +403,5 @@ DtCreateOneTemplate ( Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); - ACPI_FREE (DisasmFilename); return (Status); } diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 4c8ba08490e2..4011f087287b 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -395,7 +395,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000080 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ @@ -434,16 +434,34 @@ const unsigned char TemplateFpdt[] = const unsigned char TemplateGtdt[] = { - 0x47,0x54,0x44,0x54,0x50,0x00,0x00,0x00, /* 00000000 "GTDTP..." */ - 0x01,0xF1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000048 "........" */ + 0x47,0x54,0x44,0x54,0xe0,0x00,0x00,0x00, /* 00000000 "GTDT...." */ + 0x02,0xb0,0x4c,0x49,0x4e,0x41,0x52,0x4f, /* 00000008 "..LINARO" */ + 0x52,0x54,0x53,0x4d,0x56,0x45,0x56,0x38, /* 00000010 "RTSMVEV8" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x1d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */ + 0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000058 "....`..." */ + 0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".d......" */ + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 00000068 "........" */ + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x1c,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000d8 "........" */ }; const unsigned char TemplateHest[] = @@ -575,41 +593,48 @@ const unsigned char TemplateLpit[] = 0x00,0x00,0x00,0x00 /* 000000B0 "...." */ }; -/* MADT with ACPI 5.0 subtables */ +/* MADT with ACPI 5.1 subtables */ const unsigned char TemplateMadt[] = { - 0x41,0x50,0x49,0x43,0xF6,0x00,0x00,0x00, /* 00000000 "APIC...." */ - 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x41,0x50,0x49,0x43,0x2a,0x01,0x00,0x00, /* 00000000 "APIC*..." */ + 0x04,0x34,0x49,0x4e,0x54,0x45,0x4c,0x20, /* 00000008 ".4INTEL " */ + 0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ - 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x0c,0x01,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */ + 0x02,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x03,0x08,0x0d,0x00,0x01,0x00, /* 00000048 "........" */ 0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */ - 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x05,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ 0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */ + 0x00,0x00,0x00,0x00,0x5c,0x43,0x50,0x55, /* 00000080 "....\CPU" */ 0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */ 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ 0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ - 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x28, /* 000000B0 ".......(" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18, /* 000000D8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00 /* 000000F0 "......" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x0a,0x0c,0x05,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x4c, /* 000000b0 ".......L" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f8 "........" */ + 0x00,0x00,0x0e,0x10,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */ + 0x00,0x00,0x0c,0x18,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00 /* 00000128 ".. " */ }; const unsigned char TemplateMcfg[] = @@ -703,27 +728,27 @@ const unsigned char TemplateMtmr[] = const unsigned char TemplatePcct[] = { 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ - 0x01,0x97,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0xCF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ - 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ - 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ - 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ - 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ - 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ - 0x77,0x77,0x77,0x77,0x88,0x88,0x00,0x3E, /* 00000068 "wwww...>" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, /* 00000070 "........" */ - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xEE, /* 00000078 "........" */ - 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0x01,0x32, /* 00000080 ".......2" */ - 0x00,0x03,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD, /* 00000088 "........" */ - 0xDD,0xDD,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* 00000090 "........" */ - 0xCC,0xCC,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB, /* 00000098 "........" */ - 0xBB,0xBB,0xAA,0xAA,0xAA,0xAA,0x99,0x99, /* 000000A0 "........" */ - 0x99,0x99,0x88,0x88 /* 000000A8 "...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x32,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ".2......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000058 "........" */ + 0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00, /* 00000060 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x3E, /* 00000068 ".......>" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x32, /* 00000080 ".......2" */ + 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000098 "........" */ + 0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x01,0x00 /* 000000A8 "...." */ }; const unsigned char TemplatePmtt[] = @@ -936,11 +961,11 @@ const unsigned char TemplateSpmi[] = const unsigned char TemplateSrat[] = { - 0x53,0x52,0x41,0x54,0x80,0x00,0x00,0x00, /* 00000000 "SRAT...." */ - 0x03,0x5A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".ZINTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x53,0x52,0x41,0x54,0x92,0x00,0x00,0x00, /* 00000000 "SRAT...." */ + 0x03,0x50,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".PINTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x24,0x07,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -951,7 +976,10 @@ const unsigned char TemplateSrat[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ 0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00 /* 00000090 ".." */ }; const unsigned char TemplateTcpa[] = diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 281bfb3725a2..6927c56697f4 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -501,6 +501,7 @@ DtGetFieldLength ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: @@ -512,6 +513,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -843,39 +845,151 @@ DtWalkTableTree ( } -/****************************************************************************** +/******************************************************************************* + * + * FUNCTION: UtSubtableCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure + * + * DESCRIPTION: Allocate a subtable object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_SubtableCacheNext >= Gbl_SubtableCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_SubtableCacheList; + Gbl_SubtableCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_SubtableCacheNext = ACPI_CAST_PTR (DT_SUBTABLE, Cache->Buffer); + Gbl_SubtableCacheLast = Gbl_SubtableCacheNext + ASL_SUBTABLE_CACHE_SIZE; + } + + Gbl_SubtableCount++; + return (Gbl_SubtableCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: UtFieldCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure * - * FUNCTION: DtFreeFieldList + * DESCRIPTION: Allocate a field object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_FIELD * +UtFieldCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_FieldCacheNext >= Gbl_FieldCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_FieldCacheList; + Gbl_FieldCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_FieldCacheNext = ACPI_CAST_PTR (DT_FIELD, Cache->Buffer); + Gbl_FieldCacheLast = Gbl_FieldCacheNext + ASL_FIELD_CACHE_SIZE; + } + + Gbl_FieldCount++; + return (Gbl_FieldCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: DtDeleteCaches * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Free the field list + * DESCRIPTION: Delete all local cache buffer blocks * - *****************************************************************************/ + ******************************************************************************/ void -DtFreeFieldList ( +DtDeleteCaches ( void) { - DT_FIELD *Field = Gbl_FieldList; - DT_FIELD *NextField; + UINT32 BufferCount; + ASL_CACHE_INFO *Next; - /* Walk and free entire field list */ + /* Field cache */ - while (Field) + BufferCount = 0; + while (Gbl_FieldCacheList) { - NextField = Field->Next; /* Save link */ + Next = Gbl_FieldCacheList->Next; + ACPI_FREE (Gbl_FieldCacheList); + Gbl_FieldCacheList = Next; + BufferCount++; + } - if (!(Field->Flags & DT_FIELD_NOT_ALLOCATED)) - { - ACPI_FREE (Field->Name); - ACPI_FREE (Field->Value); - } + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Fields, Buffer size: %u fields (%u bytes), %u Buffers\n", + Gbl_FieldCount, ASL_FIELD_CACHE_SIZE, + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE), BufferCount); + + Gbl_FieldCount = 0; + Gbl_FieldCacheNext = NULL; + Gbl_FieldCacheLast = NULL; + + /* Subtable cache */ - ACPI_FREE (Field); - Field = NextField; + BufferCount = 0; + while (Gbl_SubtableCacheList) + { + Next = Gbl_SubtableCacheList->Next; + ACPI_FREE (Gbl_SubtableCacheList); + Gbl_SubtableCacheList = Next; + BufferCount++; } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Subtables, Buffer size: %u subtables (%u bytes), %u Buffers\n", + Gbl_SubtableCount, ASL_SUBTABLE_CACHE_SIZE, + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE), BufferCount); + + Gbl_SubtableCount = 0; + Gbl_SubtableCacheNext = NULL; + Gbl_SubtableCacheLast = NULL; } diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c index d8b7d45c5d39..a93a14e85e97 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -340,7 +340,6 @@ PrOpenIncludeWithPrefix ( if (!IncludeFile) { fprintf (stderr, "Could not open include file %s\n", Pathname); - ACPI_FREE (Pathname); return (NULL); } @@ -393,15 +392,17 @@ PrPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; Gbl_PreviousLineNumber = 0; Gbl_CurrentLineNumber = 0; /* Emit a new #line directive for the include file */ - FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", - 1, Filename); + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", 1, Filename); } diff --git a/source/components/debugger/dbcmds.c b/source/components/debugger/dbcmds.c index d9aa2e7aa1c3..44aafbf0caa0 100644 --- a/source/components/debugger/dbcmds.c +++ b/source/components/debugger/dbcmds.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acevents.h" diff --git a/source/components/debugger/dbconvert.c b/source/components/debugger/dbconvert.c index ab809f8112f1..ad8b13967cce 100644 --- a/source/components/debugger/dbconvert.c +++ b/source/components/debugger/dbconvert.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbdisply.c b/source/components/debugger/dbdisply.c index fb47c7ba6376..9d0a216af4e8 100644 --- a/source/components/debugger/dbdisply.c +++ b/source/components/debugger/dbdisply.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "amlcode.h" diff --git a/source/components/debugger/dbexec.c b/source/components/debugger/dbexec.c index 806b80fb3e1f..71db787c4d30 100644 --- a/source/components/debugger/dbexec.c +++ b/source/components/debugger/dbexec.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index ee4ba15f0f13..abdc454b398a 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbhistry.c b/source/components/debugger/dbhistry.c index b56d4ef82d5d..6680306ae9ae 100644 --- a/source/components/debugger/dbhistry.c +++ b/source/components/debugger/dbhistry.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 88fbb9475246..abf9688c2932 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbmethod.c b/source/components/debugger/dbmethod.c index 90d131408c36..05fd2affb0d8 100644 --- a/source/components/debugger/dbmethod.c +++ b/source/components/debugger/dbmethod.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdispat.h" diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c index de02fb635ed7..29fe1ec1d477 100644 --- a/source/components/debugger/dbnames.c +++ b/source/components/debugger/dbnames.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acnamesp.h" diff --git a/source/components/debugger/dbstats.c b/source/components/debugger/dbstats.c index 450afcb73b15..db29db5584e7 100644 --- a/source/components/debugger/dbstats.c +++ b/source/components/debugger/dbstats.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdebug.h" diff --git a/source/components/debugger/dbutils.c b/source/components/debugger/dbutils.c index fcc33ed6848c..1d4963d4d46e 100644 --- a/source/components/debugger/dbutils.c +++ b/source/components/debugger/dbutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acnamesp.h" diff --git a/source/components/debugger/dbxface.c b/source/components/debugger/dbxface.c index 671a8f31e465..9a304ad4c0b8 100644 --- a/source/components/debugger/dbxface.c +++ b/source/components/debugger/dbxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "amlcode.h" diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index 739fb44a1890..2231ce1efdd1 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -41,9 +41,9 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" +#include "acutils.h" #include "acdisasm.h" #include "acparser.h" #include "amlcode.h" @@ -57,6 +57,10 @@ /* Local prototypes */ +static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op); + static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); @@ -71,6 +75,7 @@ AcpiDmPldBuffer ( UINT8 *ByteData, UINT32 ByteCount); + #define ACPI_BUFFER_BYTES_PER_LINE 8 @@ -216,6 +221,11 @@ AcpiDmByteList ( AcpiOsPrintf ("\n"); break; + case ACPI_DASM_UUID: + + AcpiDmUuid (Op); + break; + case ACPI_DASM_UNICODE: AcpiDmUnicode (Op); @@ -239,6 +249,137 @@ AcpiDmByteList ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmIsUuidBuffer + * + * PARAMETERS: Op - Buffer Object to be examined + * + * RETURN: TRUE if buffer contains a UUID + * + * DESCRIPTION: Determine if a buffer Op contains a UUID + * + * To help determine whether the buffer is a UUID versus a raw data buffer, + * there a are a couple bytes we can look at: + * + * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx + * + * The variant covered by the UUID specification is indicated by the two most + * significant bits of N being 1 0 (i.e., the hexadecimal N will always be + * 8, 9, A, or B). + * + * The variant covered by the UUID specification has five versions. For this + * variant, the four bits of M indicates the UUID version (i.e., the + * hexadecimal M will be either 1, 2, 3, 4, or 5). + * + ******************************************************************************/ + +BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + ACPI_PARSE_OBJECT *SizeOp; + ACPI_PARSE_OBJECT *NextOp; + + + /* Buffer size is the buffer argument */ + + SizeOp = Op->Common.Value.Arg; + + /* Next, the initializer byte list to examine */ + + NextOp = SizeOp->Common.Next; + if (!NextOp) + { + return (FALSE); + } + + /* Extract the byte list info */ + + ByteData = NextOp->Named.Data; + ByteCount = (UINT32) NextOp->Common.Value.Integer; + + /* Byte count must be exactly 16 */ + + if (ByteCount != UUID_BUFFER_LENGTH) + { + return (FALSE); + } + + /* Check for valid "M" and "N" values (see function header above) */ + + if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */ + ((ByteData[7] & 0xF0) > 0x50) || + ((ByteData[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */ + ((ByteData[8] & 0xF0) > 0xB0)) + { + return (FALSE); + } + + /* Ignore the Size argument in the disassembly of this buffer op */ + + SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmUuid + * + * PARAMETERS: Op - Byte List op containing a UUID + * + * RETURN: None + * + * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string. + * + * Output Format: + * In its canonical form, the UUID is represented by a string containing 32 + * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens. + * The complete form is 8-4-4-4-12 for a total of 36 characters (32 + * alphanumeric characters representing hex digits and 4 hyphens). In bytes, + * 4-2-2-2-6. Example: + * + * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644") + * + ******************************************************************************/ + +static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *Data; + const char *Description; + + + Data = ACPI_CAST_PTR (UINT8, Op->Named.Data); + + /* Emit the 36-byte UUID string in the proper format/order */ + + AcpiOsPrintf ( + "\"%2.2x%2.2x%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")", + Data[3], Data[2], Data[1], Data[0], + Data[5], Data[4], + Data[7], Data[6], + Data[8], Data[9], + Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]); + + /* Dump the UUID description string if available */ + + Description = AcpiAhMatchUuid (Data); + if (Description) + { + AcpiOsPrintf (" /* %s */", Description); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmIsUnicodeBuffer diff --git a/source/components/disassembler/dmdeferred.c b/source/components/disassembler/dmdeferred.c index dd0be81a4e86..56c6b3899ebb 100644 --- a/source/components/disassembler/dmdeferred.c +++ b/source/components/disassembler/dmdeferred.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdispat.h" diff --git a/source/components/disassembler/dmnames.c b/source/components/disassembler/dmnames.c index 66d50a44335b..4b48a348fe7e 100644 --- a/source/components/disassembler/dmnames.c +++ b/source/components/disassembler/dmnames.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "amlcode.h" diff --git a/source/components/disassembler/dmobject.c b/source/components/disassembler/dmobject.c index c938bdefd067..00fc680d7b98 100644 --- a/source/components/disassembler/dmobject.c +++ b/source/components/disassembler/dmobject.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acnamesp.h" diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 30f985c524c1..52e01a9cb074 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -827,7 +827,12 @@ AcpiDmDisassembleOneOp ( } } - if (AcpiDmIsUnicodeBuffer (Op)) + if (AcpiDmIsUuidBuffer (Op)) + { + Op->Common.DisasmOpcode = ACPI_DASM_UUID; + AcpiOsPrintf ("ToUUID ("); + } + else if (AcpiDmIsUnicodeBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_UNICODE; AcpiOsPrintf ("Unicode ("); diff --git a/source/components/disassembler/dmresrc.c b/source/components/disassembler/dmresrc.c index 9bd47db6ffd2..ff6278b2e77e 100644 --- a/source/components/disassembler/dmresrc.c +++ b/source/components/disassembler/dmresrc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "amlcode.h" diff --git a/source/components/disassembler/dmresrcl.c b/source/components/disassembler/dmresrcl.c index 41cbc01817fc..d6707d39b813 100644 --- a/source/components/disassembler/dmresrcl.c +++ b/source/components/disassembler/dmresrcl.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdisasm.h" diff --git a/source/components/disassembler/dmresrcl2.c b/source/components/disassembler/dmresrcl2.c index 3e48afca745a..dd9039ea095f 100644 --- a/source/components/disassembler/dmresrcl2.c +++ b/source/components/disassembler/dmresrcl2.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdisasm.h" @@ -274,7 +273,7 @@ AcpiDmGpioIntDescriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("GpioInt (%s, %s, %s, ", AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)], - AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->Gpio.IntFlags, 1)], + AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)], AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]); /* PinConfig, DebounceTimeout */ diff --git a/source/components/disassembler/dmresrcs.c b/source/components/disassembler/dmresrcs.c index 104189098258..cbbdc7114d72 100644 --- a/source/components/disassembler/dmresrcs.c +++ b/source/components/disassembler/dmresrcs.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acdisasm.h" diff --git a/source/components/disassembler/dmutils.c b/source/components/disassembler/dmutils.c index 2771d44abdd3..700cfecc3092 100644 --- a/source/components/disassembler/dmutils.c +++ b/source/components/disassembler/dmutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "amlcode.h" diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c index 0aa305282a04..92f27e506224 100644 --- a/source/components/disassembler/dmwalk.c +++ b/source/components/disassembler/dmwalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" @@ -285,7 +284,8 @@ AcpiDmBlockType ( case AML_BUFFER_OP: - if (Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) + if ((Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) || + (Op->Common.DisasmOpcode == ACPI_DASM_UUID)) { return (BLOCK_NONE); } diff --git a/source/components/dispatcher/dswstate.c b/source/components/dispatcher/dswstate.c index 18208f393049..389a7d068996 100644 --- a/source/components/dispatcher/dswstate.c +++ b/source/components/dispatcher/dswstate.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __DSWSTATE_C__ #include "acpi.h" diff --git a/source/components/events/evgpe.c b/source/components/events/evgpe.c index c31f0b385197..939402559e0b 100644 --- a/source/components/events/evgpe.c +++ b/source/components/events/evgpe.c @@ -760,22 +760,6 @@ AcpiEvGpeDispatch ( GpeNumber, AcpiGbl_GlobalEventHandlerContext); } - /* - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_EDGE_TRIGGERED) - { - Status = AcpiHwClearGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to clear GPE %02X", GpeNumber)); - return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); - } - } - /* * Always disable the GPE so that it does not keep firing before * any asynchronous activity completes (either from the execution @@ -793,6 +777,24 @@ AcpiEvGpeDispatch ( return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } + /* + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE %02X", GpeNumber)); + (void) AcpiHwLowSetGpe (GpeEventInfo, + ACPI_GPE_CONDITIONAL_ENABLE); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + /* * Dispatch the GPE to either an installed handler or the control * method associated with this GPE (_Lxx or _Exx). If a handler diff --git a/source/components/events/evgpeinit.c b/source/components/events/evgpeinit.c index 6251b36f4d7a..a8aea022f858 100644 --- a/source/components/events/evgpeinit.c +++ b/source/components/events/evgpeinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acevents.h" diff --git a/source/components/events/evhandler.c b/source/components/events/evhandler.c index 150f73f77169..0fd1cba30de3 100644 --- a/source/components/events/evhandler.c +++ b/source/components/events/evhandler.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVHANDLER_C__ #include "acpi.h" diff --git a/source/components/events/evregion.c b/source/components/events/evregion.c index 4b5cb9b1ddb0..8531b5ae2a6e 100644 --- a/source/components/events/evregion.c +++ b/source/components/events/evregion.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVREGION_C__ #include "acpi.h" diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c index 1c3dbbc49df4..cd0ca2eea5f0 100644 --- a/source/components/events/evrgnini.c +++ b/source/components/events/evrgnini.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVRGNINI_C__ #include "acpi.h" diff --git a/source/components/events/evxface.c b/source/components/events/evxface.c index 51437a915b39..bbd88dc370ff 100644 --- a/source/components/events/evxface.c +++ b/source/components/events/evxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/events/evxfevnt.c b/source/components/events/evxfevnt.c index f854145a4915..683c73b56876 100644 --- a/source/components/events/evxfevnt.c +++ b/source/components/events/evxfevnt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFEVNT_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/events/evxfgpe.c b/source/components/events/evxfgpe.c index 73164e1d04b1..79e888ff8053 100644 --- a/source/components/events/evxfgpe.c +++ b/source/components/events/evxfgpe.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFGPE_C__ #define EXPORT_ACPI_INTERFACES @@ -141,12 +140,23 @@ AcpiEnableGpe ( Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - /* Ensure that we have a valid GPE number */ - + /* + * Ensure that we have a valid GPE number and that there is some way + * of handling the GPE (handler or a GPE method). In other words, we + * won't allow a valid GPE to be enabled if there is no way to handle it. + */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); if (GpeEventInfo) { - Status = AcpiEvAddGpeReference (GpeEventInfo); + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_NONE) + { + Status = AcpiEvAddGpeReference (GpeEventInfo); + } + else + { + Status = AE_NO_HANDLER; + } } AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); @@ -274,6 +284,60 @@ UnlockAndExit: ACPI_EXPORT_SYMBOL (AcpiSetGpe) +/******************************************************************************* + * + * FUNCTION: AcpiMarkGpeForWake + * + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * + * RETURN: Status + * + * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply + * sets the ACPI_GPE_CAN_WAKE flag. + * + * Some potential callers of AcpiSetupGpeForWake may know in advance that + * there won't be any notify handlers installed for device wake notifications + * from the given GPE (one example is a button GPE in Linux). For these cases, + * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake. + * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to + * setup implicit wake notification for it (since there's no handler method). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiMarkGpeForWake); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) + { + /* Mark the GPE as a possible wake event */ + + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; + Status = AE_OK; + } + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiMarkGpeForWake) + + /******************************************************************************* * * FUNCTION: AcpiSetupGpeForWake diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c index fbfd137deb9f..9803cb6a0528 100644 --- a/source/components/executer/exconvrt.c +++ b/source/components/executer/exconvrt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXCONVRT_C__ #include "acpi.h" diff --git a/source/components/executer/exdebug.c b/source/components/executer/exdebug.c index df61b7988da1..5b13d19dca4f 100644 --- a/source/components/executer/exdebug.c +++ b/source/components/executer/exdebug.c @@ -82,6 +82,7 @@ AcpiExDoDebugObject ( UINT32 Index) { UINT32 i; + UINT32 Timer; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); @@ -95,13 +96,21 @@ AcpiExDoDebugObject ( return_VOID; } + /* + * We will emit the current timer value (in microseconds) with each + * debug output. Only need the lower 26 bits. This allows for 67 + * million microseconds or 67 seconds before rollover. + */ + Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ + Timer &= 0x03FFFFFF; + /* * Print line header as long as we are not in the middle of an * object display */ if (!((Level > 0) && Index == 0)) { - AcpiOsPrintf ("[ACPI Debug] %*s", Level, " "); + AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); } /* Display the index for package output only */ diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 815e337be5b2..6e7de67bf880 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -508,7 +508,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_HDLR_LIST: @@ -542,7 +542,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_RGN_LIST: @@ -576,7 +576,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_NODE: diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c index a1de0ca237c7..49d3b667b78e 100644 --- a/source/components/executer/exfield.c +++ b/source/components/executer/exfield.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFIELD_C__ #include "acpi.h" @@ -203,14 +202,13 @@ AcpiExReadDataFromField ( Length = AcpiExGetSerialAccessLength (AccessorType, ObjDesc->Field.AccessLength); - /* - * Add additional 2 bytes for modeled GenericSerialBus data buffer: - * typedef struct { - * BYTEStatus; // Byte 0 of the data buffer - * BYTELength; // Byte 1 of the data buffer - * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, - * } - */ + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ Length += 2; Function = ACPI_READ | (AccessorType << 16); } @@ -397,14 +395,13 @@ AcpiExWriteDataToField ( Length = AcpiExGetSerialAccessLength (AccessorType, ObjDesc->Field.AccessLength); - /* - * Add additional 2 bytes for modeled GenericSerialBus data buffer: - * typedef struct { - * BYTEStatus; // Byte 0 of the data buffer - * BYTELength; // Byte 1 of the data buffer - * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, - * } - */ + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ Length += 2; Function = ACPI_WRITE | (AccessorType << 16); } diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c index 448d455d55bd..e35559fffa5e 100644 --- a/source/components/executer/exfldio.c +++ b/source/components/executer/exfldio.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFLDIO_C__ #include "acpi.h" diff --git a/source/components/executer/exoparg2.c b/source/components/executer/exoparg2.c index 8f25f7b16d59..f3e976ce536f 100644 --- a/source/components/executer/exoparg2.c +++ b/source/components/executer/exoparg2.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXOPARG2_C__ #include "acpi.h" diff --git a/source/components/executer/exregion.c b/source/components/executer/exregion.c index 1fa07e3490bc..7532630a232a 100644 --- a/source/components/executer/exregion.c +++ b/source/components/executer/exregion.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXREGION_C__ #include "acpi.h" diff --git a/source/components/namespace/nsalloc.c b/source/components/namespace/nsalloc.c index 0f29a8491622..d465a37e5b8b 100644 --- a/source/components/namespace/nsalloc.c +++ b/source/components/namespace/nsalloc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSALLOC_C__ #include "acpi.h" diff --git a/source/components/namespace/nsinit.c b/source/components/namespace/nsinit.c index 27ff7a13244c..53155977f39f 100644 --- a/source/components/namespace/nsinit.c +++ b/source/components/namespace/nsinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFINIT_C__ #include "acpi.h" diff --git a/source/components/namespace/nsobject.c b/source/components/namespace/nsobject.c index 9221ac00aa2e..5247ca61b41b 100644 --- a/source/components/namespace/nsobject.c +++ b/source/components/namespace/nsobject.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSOBJECT_C__ #include "acpi.h" @@ -263,17 +262,16 @@ AcpiNsDetachObject ( { Node->Object = Node->Object->Common.NextObject; } - } - - /* - * Detach the object from any data objects (which are still held by - * the namespace node) - */ - if (ObjDesc->Common.NextObject && - ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - ObjDesc->Common.NextObject = NULL; + /* + * Detach the object from any data objects (which are still held by + * the namespace node) + */ + if (ObjDesc->Common.NextObject && + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + ObjDesc->Common.NextObject = NULL; + } } /* Reset the node type to untyped */ diff --git a/source/components/namespace/nsprepkg.c b/source/components/namespace/nsprepkg.c index 1e66b5aee2da..6cc3c700f29b 100644 --- a/source/components/namespace/nsprepkg.c +++ b/source/components/namespace/nsprepkg.c @@ -321,6 +321,46 @@ AcpiNsCheckPackage ( Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package must contain pairs of (UUID + type) */ + + if (Count & 1) + { + ExpectedCount = Count + 1; + goto PackageTooSmall; + } + + while (Count > 0) + { + Status = AcpiNsCheckObjectType(Info, Elements, + Package->RetInfo.ObjectType1, 0); + if (ACPI_FAILURE(Status)) + { + return (Status); + } + + /* Validate length of the UUID buffer */ + + if ((*Elements)->Buffer.Length != 16) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, + Info->NodeFlags, "Invalid length for UUID Buffer")); + return (AE_AML_OPERAND_VALUE); + } + + Status = AcpiNsCheckObjectType(Info, Elements + 1, + Package->RetInfo.ObjectType2, 0); + if (ACPI_FAILURE(Status)) + { + return (Status); + } + + Elements += 2; + Count -= 2; + } + break; + default: /* Should not get here if predefined info table is correct */ diff --git a/source/components/namespace/nswalk.c b/source/components/namespace/nswalk.c index 48b5a27f0f53..147e4ce816c7 100644 --- a/source/components/namespace/nswalk.c +++ b/source/components/namespace/nswalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSWALK_C__ #include "acpi.h" diff --git a/source/components/namespace/nsxfeval.c b/source/components/namespace/nsxfeval.c index 1423da30349a..2b2663cabb56 100644 --- a/source/components/namespace/nsxfeval.c +++ b/source/components/namespace/nsxfeval.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFEVAL_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/namespace/nsxfobj.c b/source/components/namespace/nsxfobj.c index 86e109778524..69b656e12620 100644 --- a/source/components/namespace/nsxfobj.c +++ b/source/components/namespace/nsxfobj.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFOBJ_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/parser/psloop.c b/source/components/parser/psloop.c index ace1d6b2bbbf..5d5dab496759 100644 --- a/source/components/parser/psloop.c +++ b/source/components/parser/psloop.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, (such as * Perl) do. Parsing is done by hand rather than with a YACC generated parser diff --git a/source/components/parser/psobject.c b/source/components/parser/psobject.c index 661817178d8e..2f69a1489728 100644 --- a/source/components/parser/psobject.c +++ b/source/components/parser/psobject.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/components/parser/psopcode.c b/source/components/parser/psopcode.c index bcfb57dd4a4b..60758e4eb043 100644 --- a/source/components/parser/psopcode.c +++ b/source/components/parser/psopcode.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acopcode.h" diff --git a/source/components/parser/psopinfo.c b/source/components/parser/psopinfo.c index af15d303bad1..d419aa0fa1fb 100644 --- a/source/components/parser/psopinfo.c +++ b/source/components/parser/psopinfo.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/components/parser/psparse.c b/source/components/parser/psparse.c index 7b8e1b986361..31899bd55a9e 100644 --- a/source/components/parser/psparse.c +++ b/source/components/parser/psparse.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, * like Perl, do. Parsing is done by hand rather than with a YACC diff --git a/source/components/parser/psscope.c b/source/components/parser/psscope.c index 1a512410d841..d0068b7913e0 100644 --- a/source/components/parser/psscope.c +++ b/source/components/parser/psscope.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/components/parser/pstree.c b/source/components/parser/pstree.c index 1d57826e4c88..746d5759f53b 100644 --- a/source/components/parser/pstree.c +++ b/source/components/parser/pstree.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __PSTREE_C__ #include "acpi.h" diff --git a/source/components/parser/psutils.c b/source/components/parser/psutils.c index 6c37839c91f7..f6d8c5977ecc 100644 --- a/source/components/parser/psutils.c +++ b/source/components/parser/psutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/components/parser/pswalk.c b/source/components/parser/pswalk.c index 4e41d4bc7174..026205d21e11 100644 --- a/source/components/parser/pswalk.c +++ b/source/components/parser/pswalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/source/components/resources/rsdump.c b/source/components/resources/rsdump.c index 91675ed08d90..b83d05849afc 100644 --- a/source/components/resources/rsdump.c +++ b/source/components/resources/rsdump.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMP_C__ #include "acpi.h" diff --git a/source/components/resources/rsdumpinfo.c b/source/components/resources/rsdumpinfo.c index 665a76a1cf3c..906544ad86b8 100644 --- a/source/components/resources/rsdumpinfo.c +++ b/source/components/resources/rsdumpinfo.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMPINFO_C__ #include "acpi.h" diff --git a/source/components/resources/rsutils.c b/source/components/resources/rsutils.c index e1fb7777ec7a..b010ea031f0c 100644 --- a/source/components/resources/rsutils.c +++ b/source/components/resources/rsutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSUTILS_C__ #include "acpi.h" diff --git a/source/components/resources/rsxface.c b/source/components/resources/rsxface.c index 49b087812e89..1e15f8dd848b 100644 --- a/source/components/resources/rsxface.c +++ b/source/components/resources/rsxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index d7faee926529..7fbcaee9351f 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __CMCLIB_C__ #include "acpi.h" diff --git a/source/components/utilities/utdecode.c b/source/components/utilities/utdecode.c index 28617dd8bf47..1666a36b254f 100644 --- a/source/components/utilities/utdecode.c +++ b/source/components/utilities/utdecode.c @@ -91,38 +91,6 @@ const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = }; -/******************************************************************************* - * - * FUNCTION: AcpiUtHexToAsciiChar - * - * PARAMETERS: Integer - Contains the hex digit - * Position - bit position of the digit within the - * integer (multiple of 4) - * - * RETURN: The converted Ascii character - * - * DESCRIPTION: Convert a hex digit to an Ascii character - * - ******************************************************************************/ - -/* Hex to ASCII conversion table */ - -static const char AcpiGbl_HexToAscii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' -}; - -char -AcpiUtHexToAsciiChar ( - UINT64 Integer, - UINT32 Position) -{ - - return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); -} - - /******************************************************************************* * * FUNCTION: AcpiUtGetRegionName @@ -541,7 +509,8 @@ static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = /* 09 */ "Device PLD Check", /* 0A */ "Reserved", /* 0B */ "System Locality Update", - /* 0C */ "Shutdown Request" + /* 0C */ "Shutdown Request", + /* 0D */ "System Resource Affinity Update" }; static const char *AcpiGbl_DeviceNotify[4] = @@ -575,7 +544,7 @@ AcpiUtGetNotifyName ( ACPI_OBJECT_TYPE Type) { - /* 00 - 0C are common to all object types */ + /* 00 - 0D are common to all object types */ if (NotifyValue <= ACPI_NOTIFY_MAX) { diff --git a/source/components/utilities/utexcep.c b/source/components/utilities/utexcep.c index c941c5615271..550719cfe145 100644 --- a/source/components/utilities/utexcep.c +++ b/source/components/utilities/utexcep.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTEXCEP_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/utilities/utfileio.c b/source/components/utilities/utfileio.c index 1d9adbbb5552..c6ee29cfabb4 100644 --- a/source/components/utilities/utfileio.c +++ b/source/components/utilities/utfileio.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "actables.h" @@ -232,8 +231,7 @@ AcpiUtReadTable ( Status = FlCheckForAscii (fp, NULL, FALSE); if (ACPI_SUCCESS (Status)) { - AcpiOsPrintf ("File appears to be ASCII only, must be binary\n", - TableHeader.Length, FileSize); + AcpiOsPrintf ("File appears to be ASCII only, must be binary\n"); } #endif return (AE_BAD_HEADER); diff --git a/source/components/utilities/uthex.c b/source/components/utilities/uthex.c new file mode 100644 index 000000000000..e71cacdbc96c --- /dev/null +++ b/source/components/utilities/uthex.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Module Name: uthex -- Hex/ASCII support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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 __UTHEX_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("uthex") + + +/* Hex to ASCII conversion table */ + +static char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexToAsciiChar + * + * PARAMETERS: Integer - Contains the hex digit + * Position - bit position of the digit within the + * integer (multiple of 4) + * + * RETURN: The converted Ascii character + * + * DESCRIPTION: Convert a hex digit to an Ascii character + * + ******************************************************************************/ + +char +AcpiUtHexToAsciiChar ( + UINT64 Integer, + UINT32 Position) +{ + + return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexCharToValue + * + * PARAMETERS: AsciiChar - Hex character in Ascii + * + * RETURN: The binary value of the ascii/hex character + * + * DESCRIPTION: Perform ascii-to-hex translation + * + ******************************************************************************/ + +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar) +{ + + if (HexChar <= 0x39) + { + return ((UINT8) (HexChar - 0x30)); + } + + if (HexChar <= 0x46) + { + return ((UINT8) (HexChar - 0x37)); + } + + return ((UINT8) (HexChar - 0x57)); +} diff --git a/source/components/utilities/utinit.c b/source/components/utilities/utinit.c index 17030be64043..8e11c516751a 100644 --- a/source/components/utilities/utinit.c +++ b/source/components/utilities/utinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTINIT_C__ #include "acpi.h" diff --git a/source/components/utilities/utmath.c b/source/components/utilities/utmath.c index 871a3e6c93b2..51393353b173 100644 --- a/source/components/utilities/utmath.c +++ b/source/components/utilities/utmath.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMATH_C__ #include "acpi.h" diff --git a/source/components/utilities/utmisc.c b/source/components/utilities/utmisc.c index 93cb288a5bfd..de2673c6c7d3 100644 --- a/source/components/utilities/utmisc.c +++ b/source/components/utilities/utmisc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMISC_C__ #include "acpi.h" diff --git a/source/components/utilities/utmutex.c b/source/components/utilities/utmutex.c index e787cd0a7d24..8fc977a63f50 100644 --- a/source/components/utilities/utmutex.c +++ b/source/components/utilities/utmutex.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMUTEX_C__ #include "acpi.h" diff --git a/source/components/utilities/utownerid.c b/source/components/utilities/utownerid.c index 55756e457301..91943501241d 100644 --- a/source/components/utilities/utownerid.c +++ b/source/components/utilities/utownerid.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTOWNERID_C__ #include "acpi.h" diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c index 0194d561157c..21f70347bc5c 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -88,6 +88,12 @@ AcpiUtPutNumber ( BOOLEAN Upper); +/* Module globals */ + +static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + /******************************************************************************* * * FUNCTION: AcpiUtBoundStringLength @@ -95,7 +101,7 @@ AcpiUtPutNumber ( * PARAMETERS: String - String with boundary * Count - Boundary of the string * - * RETURN: Length of the string. + * RETURN: Length of the string. Less than or equal to Count. * * DESCRIPTION: Calculate the length of a string with boundary. * @@ -145,8 +151,8 @@ AcpiUtBoundStringOutput ( { *String = c; } - ++String; + ++String; return (String); } @@ -174,15 +180,13 @@ AcpiUtPutNumber ( UINT8 Base, BOOLEAN Upper) { - const char LowerDigits[] = "0123456789abcdef"; - const char UpperDigits[] = "0123456789ABCDEF"; const char *Digits; UINT64 DigitIndex; char *Pos; Pos = String; - Digits = Upper ? UpperDigits : LowerDigits; + Digits = Upper ? AcpiGbl_UpperHexDigits : AcpiGbl_LowerHexDigits; if (Number == 0) { @@ -196,8 +200,8 @@ AcpiUtPutNumber ( *(Pos++) = Digits[DigitIndex]; } } - /* *(Pos++) = '0'; */ + /* *(Pos++) = '0'; */ return (Pos); } @@ -228,8 +232,8 @@ AcpiUtScanNumber ( Number *= 10; Number += *(String++) - '0'; } - *NumberPtr = Number; + *NumberPtr = Number; return (String); } @@ -264,8 +268,8 @@ AcpiUtPrintNumber ( { *(Pos2++) = *(--Pos1); } - *Pos2 = 0; + *Pos2 = 0; return (String); } @@ -298,6 +302,7 @@ AcpiUtFormatNumber ( INT32 Precision, UINT8 Type) { + char *Pos; char Sign; char Zero; BOOLEAN NeedPrefix; @@ -306,12 +311,13 @@ AcpiUtFormatNumber ( char ReversedString[66]; - /* Perform sanity checks */ + /* Parameter validation */ if (Base < 2 || Base > 16) { - return NULL; + return (NULL); } + if (Type & ACPI_FORMAT_LEFT) { Type &= ~ACPI_FORMAT_ZERO; @@ -354,9 +360,8 @@ AcpiUtFormatNumber ( /* Generate full string in reverse order */ - i = ACPI_PTR_DIFF ( - AcpiUtPutNumber (ReversedString, Number, Base, Upper), - ReversedString); + Pos = AcpiUtPutNumber (ReversedString, Number, Base, Upper); + i = ACPI_PTR_DIFF (Pos, ReversedString); /* Printing 100 using %2d gives "100", not "00" */ @@ -364,6 +369,7 @@ AcpiUtFormatNumber ( { Precision = i; } + Width -= Precision; /* Output the string */ @@ -386,7 +392,7 @@ AcpiUtFormatNumber ( { String = AcpiUtBoundStringOutput (String, End, Upper ? 'X' : 'x'); - } + } } if (!(Type & ACPI_FORMAT_LEFT)) { @@ -395,6 +401,7 @@ AcpiUtFormatNumber ( String = AcpiUtBoundStringOutput (String, End, Zero); } } + while (i <= --Precision) { String = AcpiUtBoundStringOutput (String, End, '0'); @@ -422,7 +429,7 @@ AcpiUtFormatNumber ( * Format - Standard printf format * Args - Argument list * - * RETURN: Size of successfully output bytes + * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a string using argument list pointer. * @@ -453,7 +460,7 @@ AcpiUtVsnprintf ( Pos = String; End = String + Size; - for (; *Format ; ++Format) + for (; *Format; ++Format) { if (*Format != '%') { @@ -494,6 +501,7 @@ AcpiUtVsnprintf ( /* Process width */ + Width = -1; if (ACPI_IS_DIGIT (*Format)) { Format = AcpiUtScanNumber (Format, &Number); @@ -502,7 +510,7 @@ AcpiUtVsnprintf ( else if (*Format == '*') { ++Format; - Width = va_arg(Args, int); + Width = va_arg (Args, int); if (Width < 0) { Width = -Width; @@ -512,6 +520,7 @@ AcpiUtVsnprintf ( /* Process precision */ + Precision = -1; if (*Format == '.') { ++Format; @@ -523,7 +532,7 @@ AcpiUtVsnprintf ( else if (*Format == '*') { ++Format; - Precision = va_arg(Args, int); + Precision = va_arg (Args, int); } if (Precision < 0) { @@ -533,10 +542,12 @@ AcpiUtVsnprintf ( /* Process qualifier */ + Qualifier = -1; if (*Format == 'h' || *Format == 'l' || *Format == 'L') { Qualifier = *Format; ++Format; + if (Qualifier == 'l' && *Format == 'l') { Qualifier = 'L'; @@ -560,8 +571,10 @@ AcpiUtVsnprintf ( Pos = AcpiUtBoundStringOutput (Pos, End, ' '); } } + c = (char) va_arg (Args, int); Pos = AcpiUtBoundStringOutput (Pos, End, c); + while (--Width > 0) { Pos = AcpiUtBoundStringOutput (Pos, End, ' '); @@ -624,10 +637,10 @@ AcpiUtVsnprintf ( Width = 2 * sizeof (void *); Type |= ACPI_FORMAT_ZERO; } + p = va_arg (Args, void *); Pos = AcpiUtFormatNumber (Pos, End, - ACPI_TO_INTEGER (p), - 16, Width, Precision, Type); + ACPI_TO_INTEGER (p), 16, Width, Precision, Type); continue; default: @@ -676,7 +689,8 @@ AcpiUtVsnprintf ( Number = (signed int) Number; } } - Pos = AcpiUtFormatNumber(Pos, End, Number, Base, + + Pos = AcpiUtFormatNumber (Pos, End, Number, Base, Width, Precision, Type); } @@ -704,7 +718,7 @@ AcpiUtVsnprintf ( * Size - Boundary of the string * Format, ... - Standard printf format * - * RETURN: Size of successfully output bytes + * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a string. * @@ -738,7 +752,7 @@ AcpiUtSnprintf ( * Format - Standard printf format * Args - Argument list * - * RETURN: Size of successfully output bytes + * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a file using argument list pointer. * @@ -755,8 +769,9 @@ AcpiUtFileVprintf ( Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); - Length = AcpiUtVsnprintf(AcpiGbl_PrintBuffer, + Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, sizeof (AcpiGbl_PrintBuffer), Format, Args); + (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); @@ -771,7 +786,7 @@ AcpiUtFileVprintf ( * PARAMETERS: File - File descriptor * Format, ... - Standard printf format * - * RETURN: Size of successfully output bytes + * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a file. * diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c index 53ad155a69b0..af077aec8215 100644 --- a/source/components/utilities/utresrc.c +++ b/source/components/utilities/utresrc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTRESRC_C__ #include "acpi.h" @@ -100,7 +99,9 @@ const char *AcpiGbl_IoDecode[] = const char *AcpiGbl_LlDecode[] = { "ActiveHigh", - "ActiveLow" + "ActiveLow", + "ActiveBoth", + "Reserved" }; const char *AcpiGbl_MaxDecode[] = diff --git a/source/components/utilities/utstate.c b/source/components/utilities/utstate.c index 5dae9328c589..12de2731932f 100644 --- a/source/components/utilities/utstate.c +++ b/source/components/utilities/utstate.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTATE_C__ #include "acpi.h" diff --git a/source/components/utilities/utstring.c b/source/components/utilities/utstring.c index 435f6988892d..2fa7710725dc 100644 --- a/source/components/utilities/utstring.c +++ b/source/components/utilities/utstring.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTRING_C__ #include "acpi.h" diff --git a/source/components/utilities/utuuid.c b/source/components/utilities/utuuid.c new file mode 100644 index 000000000000..ebf03231e4f8 --- /dev/null +++ b/source/components/utilities/utuuid.c @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Module Name: utuuid -- UUID support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, 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 __UTUUID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("utuuid") + + +/* + * UUID support functions. + * + * This table is used to convert an input UUID ascii string to a 16 byte + * buffer and the reverse. The table maps a UUID buffer index 0-15 to + * the index within the 36-byte UUID string where the associated 2-byte + * hex value can be found. + * + * 36-byte UUID strings are of the form: + * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * Where aa-pp are one byte hex numbers, made up of two hex digits + * + * Note: This table is basically the inverse of the string-to-offset table + * found in the ACPI spec in the description of the ToUUID macro. + */ +const UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH] = +{ + 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertStringToUuid + * + * PARAMETERS: InString - 36-byte formatted UUID string + * UuidBuffer - Where the 16-byte UUID buffer is returned + * + * RETURN: None. Output data is returned in the UuidBuffer + * + * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer + * + ******************************************************************************/ + +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer) +{ + UINT32 i; + + + for (i = 0; i < UUID_BUFFER_LENGTH; i++) + { + UuidBuffer[i] = + (AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i]]) << 4); + + UuidBuffer[i] |= + AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i] + 1]); + } +} diff --git a/source/components/utilities/utxface.c b/source/components/utilities/utxface.c index 6e5628ef7d5f..dedeab39b418 100644 --- a/source/components/utilities/utxface.c +++ b/source/components/utilities/utxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index 7c4b66d748b6..0f1a6c3a9a87 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFINIT_C__ #define EXPORT_ACPI_INTERFACES diff --git a/source/include/acconfig.h b/source/include/acconfig.h index 4cad6f4b7edc..69242ee61c12 100644 --- a/source/include/acconfig.h +++ b/source/include/acconfig.h @@ -221,6 +221,25 @@ #define ACPI_NUM_SxW_METHODS 5 +/****************************************************************************** + * + * Miscellaneous constants + * + *****************************************************************************/ + +/* UUID constants */ + +#define UUID_BUFFER_LENGTH 16 /* Length of UUID in memory */ +#define UUID_STRING_LENGTH 36 /* Total length of a UUID string */ + +/* Positions for required hyphens (dashes) in UUID strings */ + +#define UUID_HYPHEN1_OFFSET 8 +#define UUID_HYPHEN2_OFFSET 13 +#define UUID_HYPHEN3_OFFSET 18 +#define UUID_HYPHEN4_OFFSET 23 + + /****************************************************************************** * * ACPI AML Debugger diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index 7de84acc1a49..a732d1726f05 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -137,11 +137,13 @@ typedef enum ACPI_DMT_ASF, ACPI_DMT_DMAR, + ACPI_DMT_DMAR_SCOPE, ACPI_DMT_EINJACT, ACPI_DMT_EINJINST, ACPI_DMT_ERSTACT, ACPI_DMT_ERSTINST, ACPI_DMT_FADTPM, + ACPI_DMT_GTDT, ACPI_DMT_HEST, ACPI_DMT_HESTNTFY, ACPI_DMT_HESTNTYP, @@ -255,6 +257,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; @@ -272,6 +275,10 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; @@ -309,6 +316,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; @@ -332,6 +341,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmttHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[]; @@ -350,6 +360,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; @@ -444,6 +455,10 @@ void AcpiDmDumpFpdt ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpHest ( ACPI_TABLE_HEADER *Table); @@ -654,6 +669,10 @@ void AcpiDmDecompressEisaId ( UINT32 EncodedId); +BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op); + BOOLEAN AcpiDmIsUnicodeBuffer ( ACPI_PARSE_OBJECT *Op); diff --git a/source/include/acdispat.h b/source/include/acdispat.h index 5715ab3b7c7b..c4abebb55e8c 100644 --- a/source/include/acdispat.h +++ b/source/include/acdispat.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef _ACDISPAT_H_ #define _ACDISPAT_H_ diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 3fcfe1fcb509..7b9e83d238a1 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -878,12 +878,13 @@ typedef union acpi_parse_value #define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */ #define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */ #define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */ -#define ACPI_DASM_EISAID 0x05 /* Integer is an EISAID */ -#define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */ -#define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a LNotEqual (etc.) pair of opcodes */ -#define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a LNotEqual (etc.) pair of opcodes */ -#define ACPI_DASM_HID_STRING 0x09 /* String is a _HID or _CID */ -#define ACPI_DASM_IGNORE 0x0A /* Not used at this time */ +#define ACPI_DASM_UUID 0x05 /* Buffer is a UUID/GUID */ +#define ACPI_DASM_EISAID 0x06 /* Integer is an EISAID */ +#define ACPI_DASM_MATCHOP 0x07 /* Parent opcode is a Match() operator */ +#define ACPI_DASM_LNOT_PREFIX 0x08 /* Start of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */ +#define ACPI_DASM_IGNORE 0x0B /* Not used at this time */ /* * Generic operation (for example: If, While, Store) @@ -1358,4 +1359,11 @@ typedef struct ah_device_id } AH_DEVICE_ID; +typedef struct ah_uuid +{ + char *Description; + char *String; + +} AH_UUID; + #endif /* __ACLOCAL_H__ */ diff --git a/source/include/acnames.h b/source/include/acnames.h index f5daaceb2f81..bd2a168217fc 100644 --- a/source/include/acnames.h +++ b/source/include/acnames.h @@ -55,9 +55,14 @@ #define METHOD_NAME__HID "_HID" #define METHOD_NAME__INI "_INI" #define METHOD_NAME__PLD "_PLD" +#define METHOD_NAME__DSD "_DSD" #define METHOD_NAME__PRS "_PRS" #define METHOD_NAME__PRT "_PRT" #define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__PS0 "_PS0" +#define METHOD_NAME__PS1 "_PS1" +#define METHOD_NAME__PS2 "_PS2" +#define METHOD_NAME__PS3 "_PS3" #define METHOD_NAME__REG "_REG" #define METHOD_NAME__SB_ "_SB_" #define METHOD_NAME__SEG "_SEG" diff --git a/source/include/acparser.h b/source/include/acparser.h index bddd3c114296..8d8adba1fcfd 100644 --- a/source/include/acparser.h +++ b/source/include/acparser.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACPARSER_H__ #define __ACPARSER_H__ diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 31adb7026afd..40037b108567 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20140627 +#define ACPI_CA_VERSION 0x20140828 #include "acconfig.h" #include "actypes.h" @@ -849,6 +849,12 @@ AcpiFinishGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber)) +ACPI_HW_DEPENDENT_RETURN_STATUS ( +ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber)) + ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiSetupGpeForWake ( diff --git a/source/include/acpredef.h b/source/include/acpredef.h index 3ab4ae0a229f..c41ab03b5440 100644 --- a/source/include/acpredef.h +++ b/source/include/acpredef.h @@ -106,6 +106,11 @@ * count = 0 (optional) * (Used for _DLM) * + * ACPI_PTYPE2_UUID_PAIR: Each subpackage is preceded by a UUID Buffer. The UUID + * defines the format of the package. Zero-length parent package is + * allowed. + * (Used for _DSD) + * *****************************************************************************/ enum AcpiReturnPackageTypes @@ -119,7 +124,8 @@ enum AcpiReturnPackageTypes ACPI_PTYPE2_FIXED = 7, ACPI_PTYPE2_MIN = 8, ACPI_PTYPE2_REV_FIXED = 9, - ACPI_PTYPE2_FIX_VAR = 10 + ACPI_PTYPE2_FIX_VAR = 10, + ACPI_PTYPE2_UUID_PAIR = 11 }; @@ -366,6 +372,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_CBA", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */ + {{"_CCA", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* ACPI 5.1 */ + {{"_CDM", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, @@ -434,6 +443,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_DOS", METHOD_1ARGS (ACPI_TYPE_INTEGER), METHOD_NO_RETURN_VALUE}}, + {{"_DSD", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */ + PACKAGE_INFO (ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_PACKAGE, 1,0), + {{"_DSM", METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_PACKAGE), METHOD_RETURNS (ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */ diff --git a/source/include/actbl.h b/source/include/actbl.h index a41919504266..6ef64e1de8b2 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -296,7 +296,8 @@ typedef struct acpi_table_fadt UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ - UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ UINT64 XFacs; /* 64-bit physical address of FACS */ UINT64 XDsdt; /* 64-bit physical address of DSDT */ ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ @@ -313,7 +314,7 @@ typedef struct acpi_table_fadt } ACPI_TABLE_FADT; -/* Masks for FADT Boot Architecture Flags (BootFlags) [Vx]=Introduced in this FADT revision */ +/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) [Vx]=Introduced in this FADT revision */ #define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ #define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ @@ -322,6 +323,11 @@ typedef struct acpi_table_fadt #define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ #define ACPI_FADT_NO_CMOS_RTC (1<<5) /* 05: [V5] No CMOS real-time clock present */ +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ + +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ + /* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1) /* 00: [V1] The WBINVD instruction works properly */ @@ -435,7 +441,7 @@ typedef struct acpi_table_desc * FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) -#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (Reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) #define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) #define ACPI_FADT_V5_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) diff --git a/source/include/actbl1.h b/source/include/actbl1.h index fe47a73c9943..a781056e1d54 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -762,20 +762,22 @@ typedef struct acpi_table_madt enum AcpiMadtType { - ACPI_MADT_TYPE_LOCAL_APIC = 0, - ACPI_MADT_TYPE_IO_APIC = 1, - ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, - ACPI_MADT_TYPE_NMI_SOURCE = 3, - ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, - ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, - ACPI_MADT_TYPE_IO_SAPIC = 6, - ACPI_MADT_TYPE_LOCAL_SAPIC = 7, - ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, - ACPI_MADT_TYPE_LOCAL_X2APIC = 9, - ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, - ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, - ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, - ACPI_MADT_TYPE_RESERVED = 13 /* 13 and greater are reserved */ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, + ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13, + ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14, + ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */ }; @@ -936,16 +938,27 @@ typedef struct acpi_madt_generic_interrupt { ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; /* Reserved - must be zero */ - UINT32 GicId; + UINT32 CpuInterfaceNumber; UINT32 Uid; UINT32 Flags; UINT32 ParkingVersion; UINT32 PerformanceInterrupt; UINT64 ParkedAddress; UINT64 BaseAddress; + UINT64 GicvBaseAddress; + UINT64 GichBaseAddress; + UINT32 VgicInterrupt; + UINT64 GicrBaseAddress; + UINT64 ArmMpidr; } ACPI_MADT_GENERIC_INTERRUPT; +/* Masks for Flags field above */ + +/* ACPI_MADT_ENABLED (1) Processor is usable if set */ +#define ACPI_MADT_PERFORMANCE_IRQ_MODE (1<<1) /* 01: Performance Interrupt Mode */ +#define ACPI_MADT_VGIC_IRQ_MODE (1<<2) /* 02: VGIC Maintenance Interrupt mode */ + /* 12: Generic Distributor (ACPI 5.0) */ @@ -961,11 +974,42 @@ typedef struct acpi_madt_generic_distributor } ACPI_MADT_GENERIC_DISTRIBUTOR; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +typedef struct acpi_madt_generic_msi_frame +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 MsiFrameId; + UINT64 BaseAddress; + UINT32 Flags; + UINT16 SpiCount; + UINT16 SpiBase; + +} ACPI_MADT_GENERIC_MSI_FRAME; + +/* Masks for Flags field above */ + +#define ACPI_MADT_OVERRIDE_SPI_VALUES (1) + + +/* 14: Generic Redistributor (ACPI 5.1) */ + +typedef struct acpi_madt_generic_redistributor +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* reserved - must be zero */ + UINT64 BaseAddress; + UINT32 Length; + +} ACPI_MADT_GENERIC_REDISTRIBUTOR; + + /* * Common flags fields for MADT subtables */ -/* MADT Local APIC flags (LapicFlags) and GIC flags */ +/* MADT Local APIC flags */ #define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ @@ -1074,7 +1118,8 @@ enum AcpiSratType ACPI_SRAT_TYPE_CPU_AFFINITY = 0, ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, - ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ + ACPI_SRAT_TYPE_GICC_AFFINITY = 3, + ACPI_SRAT_TYPE_RESERVED = 4 /* 4 and greater are reserved */ }; /* @@ -1091,7 +1136,7 @@ typedef struct acpi_srat_cpu_affinity UINT32 Flags; UINT8 LocalSapicEid; UINT8 ProximityDomainHi[3]; - UINT32 Reserved; /* Reserved, must be zero */ + UINT32 ClockDomain; } ACPI_SRAT_CPU_AFFINITY; @@ -1141,6 +1186,22 @@ typedef struct acpi_srat_x2apic_cpu_affinity #define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ +/* 3: GICC Affinity (ACPI 5.1) */ + +typedef struct acpi_srat_gicc_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT32 AcpiProcessorUid; + UINT32 Flags; + UINT32 ClockDomain; + +} ACPI_SRAT_GICC_AFFINITY; + +/* Flags for ACPI_SRAT_GICC_AFFINITY */ + +#define ACPI_SRAT_GICC_ENABLED (1) /* 00: Use affinity structure */ + /* Reset to default packing */ #pragma pack() diff --git a/source/include/actbl2.h b/source/include/actbl2.h index df6692f4054f..a6f2f2081f64 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -450,7 +450,7 @@ typedef struct acpi_table_dbgp * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 1.2, Sept. 2008 + * Version 2.2, Sept. 2013 * ******************************************************************************/ @@ -483,9 +483,10 @@ enum AcpiDmarType { ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, - ACPI_DMAR_TYPE_ATSR = 2, - ACPI_DMAR_HARDWARE_AFFINITY = 3, - ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ + ACPI_DMAR_TYPE_ROOT_ATS = 2, + ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_NAMESPACE = 4, + ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ }; @@ -501,7 +502,7 @@ typedef struct acpi_dmar_device_scope } ACPI_DMAR_DEVICE_SCOPE; -/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE - device types */ enum AcpiDmarScopeType { @@ -510,7 +511,8 @@ enum AcpiDmarScopeType ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, ACPI_DMAR_SCOPE_TYPE_HPET = 4, - ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ + ACPI_DMAR_SCOPE_TYPE_NAMESPACE = 5, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 6 /* 6 and greater are reserved */ }; typedef struct acpi_dmar_pci_path @@ -587,6 +589,18 @@ typedef struct acpi_dmar_rhsa } ACPI_DMAR_RHSA; +/* 4: ACPI Namespace Device Declaration Structure */ + +typedef struct acpi_dmar_andd +{ + ACPI_DMAR_HEADER Header; + UINT8 Reserved[3]; + UINT8 DeviceNumber; + char DeviceName[1]; + +} ACPI_DMAR_ANDD; + + /******************************************************************************* * * HPET - High Precision Event Timer table diff --git a/source/include/actbl3.h b/source/include/actbl3.h index ce69acd4549c..2f98b37203a9 100644 --- a/source/include/actbl3.h +++ b/source/include/actbl3.h @@ -280,35 +280,115 @@ typedef struct acpi_s3pt_suspend /******************************************************************************* * - * GTDT - Generic Timer Description Table (ACPI 5.0) - * Version 1 + * GTDT - Generic Timer Description Table (ACPI 5.1) + * Version 2 * ******************************************************************************/ typedef struct acpi_table_gtdt { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT64 Address; - UINT32 Flags; - UINT32 SecurePl1Interrupt; - UINT32 SecurePl1Flags; - UINT32 NonSecurePl1Interrupt; - UINT32 NonSecurePl1Flags; + UINT64 CounterBlockAddresss; + UINT32 Reserved; + UINT32 SecureEl1Interrupt; + UINT32 SecureEl1Flags; + UINT32 NonSecureEl1Interrupt; + UINT32 NonSecureEl1Flags; UINT32 VirtualTimerInterrupt; UINT32 VirtualTimerFlags; - UINT32 NonSecurePl2Interrupt; - UINT32 NonSecurePl2Flags; + UINT32 NonSecureEl2Interrupt; + UINT32 NonSecureEl2Flags; + UINT64 CounterReadBlockAddress; + UINT32 PlatformTimerCount; + UINT32 PlatformTimerOffset; } ACPI_TABLE_GTDT; -/* Values for Flags field above */ +/* Flag Definitions: Timer Block Physical Timers and Virtual timers */ + +#define ACPI_GTDT_INTERRUPT_MODE (1) +#define ACPI_GTDT_INTERRUPT_POLARITY (1<<1) +#define ACPI_GTDT_ALWAYS_ON (1<<2) + + +/* Common GTDT subtable header */ + +typedef struct acpi_gtdt_header +{ + UINT8 Type; + UINT16 Length; + +} ACPI_GTDT_HEADER; + +/* Values for GTDT subtable type above */ -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 +enum AcpiGtdtType +{ + ACPI_GTDT_TYPE_TIMER_BLOCK = 0, + ACPI_GTDT_TYPE_WATCHDOG = 1, + ACPI_GTDT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + + +/* GTDT Subtables, correspond to Type in acpi_gtdt_header */ + +/* 0: Generic Timer Block */ + +typedef struct acpi_gtdt_timer_block +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 BlockAddress; + UINT32 TimerCount; + UINT32 TimerOffset; + +} ACPI_GTDT_TIMER_BLOCK; + +/* Timer Sub-Structure, one per timer */ + +typedef struct acpi_gtdt_timer_entry +{ + UINT8 FrameNumber; + UINT8 Reserved[3]; + UINT64 BaseAddress; + UINT64 El0BaseAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + UINT32 VirtualTimerInterrupt; + UINT32 VirtualTimerFlags; + UINT32 CommonFlags; -/* Values for all "TimerFlags" fields above */ +} ACPI_GTDT_TIMER_ENTRY; -#define ACPI_GTDT_INTERRUPT_MODE 1 -#define ACPI_GTDT_INTERRUPT_POLARITY 2 +/* Flag Definitions: TimerFlags and VirtualTimerFlags above */ + +#define ACPI_GTDT_GT_IRQ_MODE (1) +#define ACPI_GTDT_GT_IRQ_POLARITY (1<<1) + +/* Flag Definitions: CommonFlags above */ + +#define ACPI_GTDT_GT_IS_SECURE_TIMER (1) +#define ACPI_GTDT_GT_ALWAYS_ON (1<<1) + + +/* 1: SBSA Generic Watchdog Structure */ + +typedef struct acpi_gtdt_watchdog +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 RefreshFrameAddress; + UINT64 ControlFrameAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + +} ACPI_GTDT_WATCHDOG; + +/* Flag Definitions: TimerFlags above */ + +#define ACPI_GTDT_WATCHDOG_IRQ_MODE (1) +#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY (1<<1) +#define ACPI_GTDT_WATCHDOG_SECURE (1<<2) /******************************************************************************* @@ -453,7 +533,8 @@ typedef struct acpi_table_pcct enum AcpiPcctType { ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, - ACPI_PCCT_TYPE_RESERVED = 1 /* 1 and greater are reserved */ + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, + ACPI_PCCT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ }; /* @@ -478,6 +559,31 @@ typedef struct acpi_pcct_subspace } ACPI_PCCT_SUBSPACE; +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +typedef struct acpi_pcct_hw_reduced +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 DoorbellInterrupt; + UINT8 Flags; + UINT8 Reserved; + UINT64 BaseAddress; + UINT64 Length; + ACPI_GENERIC_ADDRESS DoorbellRegister; + UINT64 PreserveMask; + UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; + +} ACPI_PCCT_HW_REDUCED; + +/* Values for doorbell flags above */ + +#define ACPI_PCCT_INTERRUPT_POLARITY (1) +#define ACPI_PCCT_INTERRUPT_MODE (1<<1) + + /* * PCC memory structures (not part of the ACPI table) */ diff --git a/source/include/actypes.h b/source/include/actypes.h index 5e1c307f46ce..817192309504 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -524,7 +524,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) -#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) NULL) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) @@ -618,8 +618,9 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_RESERVED (UINT8) 0x0A #define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B #define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C +#define ACPI_NOTIFY_AFFINITY_UPDATE (UINT8) 0x0D -#define ACPI_NOTIFY_MAX 0x0C +#define ACPI_NOTIFY_MAX 0x0D /* * Types associated with ACPI names and objects. The first group of diff --git a/source/include/acutils.h b/source/include/acutils.h index b0062340632c..e5656c48a709 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -225,6 +225,10 @@ AcpiUtHexToAsciiChar ( UINT64 Integer, UINT32 Position); +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar); + BOOLEAN AcpiUtValidObjectType ( ACPI_OBJECT_TYPE Type); @@ -1135,6 +1139,10 @@ const AH_DEVICE_ID * AcpiAhMatchHardwareId ( char *Hid); +const char * +AcpiAhMatchUuid ( + UINT8 *Data); + /* * utprint - printf/vprintf output functions */ @@ -1176,4 +1184,12 @@ AcpiUtFilePrintf ( ...); #endif +/* + * utuuid -- UUID support functions + */ +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer); + #endif /* _ACUTILS_H */ diff --git a/source/include/platform/achaiku.h b/source/include/platform/achaiku.h index ab8bf0d15275..931ebf9615d0 100644 --- a/source/include/platform/achaiku.h +++ b/source/include/platform/achaiku.h @@ -60,7 +60,8 @@ struct mutex; #define ACPI_USE_NATIVE_DIVIDE -// #define ACPI_THREAD_ID thread_id +/* #define ACPI_THREAD_ID thread_id */ + #define ACPI_SEMAPHORE sem_id #define ACPI_SPINLOCK spinlock * #define ACPI_CPU_FLAGS cpu_status diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index a51f28872bc9..a56a51314026 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -44,6 +44,16 @@ #ifndef __ACLINUX_H__ #define __ACLINUX_H__ +#ifdef __KERNEL__ + +/* ACPICA external files should not include ACPICA headers directly. */ + +#if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H) +#error "Please don't include directly, include instead." +#endif + +#endif + /* Common (in-kernel/user-space) ACPICA configuration */ #define ACPI_USE_SYSTEM_CLIBRARY @@ -71,7 +81,9 @@ #ifdef EXPORT_ACPI_INTERFACES #include #endif +#ifdef CONFIG_ACPI #include +#endif #ifndef CONFIG_ACPI @@ -129,8 +141,6 @@ #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory /* * OSL interfaces used by debugger/disassembler @@ -164,10 +174,6 @@ #define __init #endif -#ifndef __iomem -#define __iomem -#endif - /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE() diff --git a/source/include/platform/aclinuxex.h b/source/include/platform/aclinuxex.h index 87d43910b226..cc6d2cecb9f5 100644 --- a/source/include/platform/aclinuxex.h +++ b/source/include/platform/aclinuxex.h @@ -46,6 +46,28 @@ #ifdef __KERNEL__ +#ifndef ACPI_USE_NATIVE_DIVIDE + +#ifndef ACPI_DIV_64_BY_32 +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ + do { \ + UINT64 (__n) = ((UINT64) n_hi) << 32 | (n_lo); \ + (r32) = do_div ((__n), (d32)); \ + (q32) = (UINT32) (__n); \ + } while (0) +#endif + +#ifndef ACPI_SHIFT_RIGHT_64 +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ + do { \ + (n_lo) >>= 1; \ + (n_lo) |= (((n_hi) & 1) << 31); \ + (n_hi) >>= 1; \ + } while (0) +#endif + +#endif + /* * Overrides for in-kernel ACPICA */ @@ -114,16 +136,6 @@ AcpiOsGetThreadId ( Lock ? AE_OK : AE_NO_MEMORY; \ }) -void __iomem * -AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS Where, - ACPI_SIZE Length); - -void -AcpiOsUnmapMemory ( - void __iomem *LogicalAddress, - ACPI_SIZE Size); - /* * OSL interfaces added by Linux */ diff --git a/source/include/platform/acmsvc.h b/source/include/platform/acmsvc.h index ec664b00da1a..845a319907cb 100644 --- a/source/include/platform/acmsvc.h +++ b/source/include/platform/acmsvc.h @@ -150,6 +150,10 @@ /* Debug support. Must be last in this file, do not move. */ #ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC /* Enables specific file/lineno for leaks */ + +#include +#include #include /* @@ -159,9 +163,26 @@ * This can quickly localize the memory corruption. */ #define ACPI_DEBUG_INITIALIZE() \ - _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | \ - _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | \ - _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + _CrtSetDbgFlag (\ + _CRTDBG_CHECK_ALWAYS_DF | \ + _CRTDBG_ALLOC_MEM_DF | \ + _CRTDBG_DELAY_FREE_MEM_DF | \ + _CRTDBG_LEAK_CHECK_DF | \ + _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); + +#if 0 +/* + * _CrtSetBreakAlloc can be used to set a breakpoint at a particular + * memory leak, add to the macro above. + */ +Detected memory leaks! +Dumping objects -> +..\..\source\os_specific\service_layers\oswinxf.c(701) : {937} normal block at 0x002E9190, 40 bytes long. + Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +_CrtSetBreakAlloc (937); +#endif + #endif #endif /* __ACMSVC_H__ */ diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 3f6c5da3353e..4efbd5b26da2 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acapps.h" @@ -52,23 +51,8 @@ #define ACPI_EFI_PRINT_LENGTH 256 -/* Local definitions */ - -typedef struct acpi_efi_memory_descriptor { - EFI_MEMORY_DESCRIPTOR *Descriptor; - UINTN EntryCount; - UINTN EntrySize; - UINTN Cookie; - UINT32 Version; -} ACPI_EFI_MEMORY_DESCRIPTOR; - - /* Local prototypes */ -static void * -AcpiEfiAllocatePool ( - ACPI_SIZE Size); - static ACPI_STATUS AcpiEfiArgify ( char *String, @@ -100,25 +84,10 @@ AcpiEfiFlushFile ( CHAR16 *Pos, BOOLEAN FlushAll); -static void -AcpiEfiFreePool ( - void *Mem); - -static ACPI_STATUS -AcpiEfiInitializeMemoryMap ( - void); - -static void -AcpiEfiTerminateMemoryMap ( - void); - /* Local variables */ static EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; -static ACPI_EFI_MEMORY_DESCRIPTOR AcpiGbl_EfiMemoryMap; -static BOOLEAN AcpiGbl_EfiMemoryInitialized = FALSE; -static UINTN AcpiGbl_EfiPoolAllocation = EfiBootServicesData; /****************************************************************************** @@ -156,107 +125,6 @@ AcpiEfiCompareGuid ( } -/****************************************************************************** - * - * FUNCTION: AcpiEfiInitializeMemoryMap - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize EFI memory map. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiEfiInitializeMemoryMap ( - void) -{ - EFI_STATUS Status; - ACPI_EFI_MEMORY_DESCRIPTOR *Map; - UINT32 Length; - - - if (AcpiGbl_EfiMemoryInitialized) - { - return (AE_OK); - } - - /* Initialize */ - - Map = &AcpiGbl_EfiMemoryMap; - Length = sizeof (EFI_MEMORY_DESCRIPTOR); - Map->Descriptor = NULL; - Status = EFI_BUFFER_TOO_SMALL; - - /* Allocation and GetMemoryMap() loop */ - - while (!AcpiGbl_EfiMemoryInitialized && - Status == EFI_BUFFER_TOO_SMALL) - { - Map->Descriptor = AcpiEfiAllocatePool (Length); - if (!Map->Descriptor) - { - return (AE_NO_MEMORY); - } - Status = uefi_call_wrapper (BS->GetMemoryMap, 5, - &Length, Map->Descriptor, - &Map->Cookie, &Map->EntrySize, &Map->Version); - if (!EFI_ERROR (Status)) - { - AcpiGbl_EfiMemoryInitialized = TRUE; - } - else if (Status == EFI_BUFFER_TOO_SMALL) - { - AcpiEfiFreePool (Map->Descriptor); - } - } - - /* Finalize */ - - if (!AcpiGbl_EfiMemoryInitialized) - { - if (Map->Descriptor) - { - AcpiEfiFreePool (Map->Descriptor); - Map->Descriptor = NULL; - } - return (AE_ERROR); - } - else - { - Map->EntryCount = Length / sizeof (EFI_MEMORY_DESCRIPTOR); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEfiTerminateMemoryMap - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Terminate EFI memory map. - * - *****************************************************************************/ - -static void -AcpiEfiTerminateMemoryMap ( - void) -{ - - if (AcpiGbl_EfiMemoryInitialized) - { - AcpiEfiFreePool (AcpiGbl_EfiMemoryMap.Descriptor); - AcpiGbl_EfiMemoryInitialized = FALSE; - } -} - - /****************************************************************************** * * FUNCTION: AcpiEfiGetRsdpViaGuid @@ -291,58 +159,6 @@ AcpiEfiGetRsdpViaGuid ( } -/****************************************************************************** - * - * FUNCTION: AcpiEfiAllocatePool - * - * PARAMETERS: Size - Amount to allocate, in bytes - * - * RETURN: Pointer to the new allocation. Null on error. - * - * DESCRIPTION: Allocate pool memory. - * - *****************************************************************************/ - -static void * -AcpiEfiAllocatePool ( - ACPI_SIZE Size) -{ - EFI_STATUS EfiStatus; - void *Mem; - - - EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3, - AcpiGbl_EfiPoolAllocation, Size, &Mem); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); - return (NULL); - } - - return (Mem); -} - -/****************************************************************************** - * - * FUNCTION: AcpiEfiFreePool - * - * PARAMETERS: Mem - Pointer to previously allocated memory - * - * RETURN: None - * - * DESCRIPTION: Free memory allocated via AcpiEfiAllocatePool - * - *****************************************************************************/ - -static void -AcpiEfiFreePool ( - void *Mem) -{ - - uefi_call_wrapper (BS->FreePool, 1, Mem); -} - - /****************************************************************************** * * FUNCTION: AcpiOsGetRootPointer @@ -392,32 +208,6 @@ AcpiOsMapMemory ( ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length) { - UINTN i; - EFI_MEMORY_DESCRIPTOR *p; - UINT64 Size; - EFI_PHYSICAL_ADDRESS End; - - - for (i = 0, p = AcpiGbl_EfiMemoryMap.Descriptor; - i < AcpiGbl_EfiMemoryMap.EntryCount; - i++, p = ACPI_ADD_PTR (EFI_MEMORY_DESCRIPTOR, p, AcpiGbl_EfiMemoryMap.EntrySize)) - { - Size = p->NumberOfPages << EFI_PAGE_SHIFT; - End = p->PhysicalStart + Size; - - if (!(p->Attribute & EFI_MEMORY_RUNTIME) || !p->VirtualStart) - { - continue; - } - - if (where >= p->PhysicalStart && where < End) - { - where += p->VirtualStart - p->PhysicalStart; - break; - } - } - - /* Default to use the physical address */ return (ACPI_TO_POINTER ((ACPI_SIZE) where)); } @@ -1252,7 +1042,6 @@ efi_main ( AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n"); return (EfiStatus); } - AcpiGbl_EfiPoolAllocation = Info->ImageDataType; EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, Info->DeviceHandle, &FileSystemProtocol, (void **) &Volume); if (EFI_ERROR (EfiStatus)) @@ -1267,12 +1056,6 @@ efi_main ( AcpiLogError ("EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n"); return (EfiStatus); } - Status = AcpiEfiInitializeMemoryMap (); - if (ACPI_FAILURE (Status)) - { - EfiStatus = EFI_DEVICE_ERROR; - goto ErrorAlloc; - } Status = AcpiEfiConvertArgcv (Info->LoadOptions, Info->LoadOptionsSize, &argc, &argv, &OptBuffer); @@ -1294,7 +1077,6 @@ ErrorAlloc: { ACPI_FREE (OptBuffer); } - AcpiEfiTerminateMemoryMap (); return (EfiStatus); } diff --git a/source/os_specific/service_layers/oslibcfs.c b/source/os_specific/service_layers/oslibcfs.c index 3bb55bb94cc0..606e3a910296 100644 --- a/source/os_specific/service_layers/oslibcfs.c +++ b/source/os_specific/service_layers/oslibcfs.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: oslibcfs - C library OSL for file IO + * Module Name: oslibcfs - C library OSL for file I/O * *****************************************************************************/ @@ -69,8 +69,9 @@ AcpiOsOpenFile ( UINT8 Modes) { ACPI_FILE File; - char ModesStr[4]; UINT32 i = 0; + char ModesStr[4]; + if (Modes & ACPI_FILE_READING) { @@ -84,6 +85,7 @@ AcpiOsOpenFile ( { ModesStr[i++] = 'b'; } + ModesStr[i++] = '\0'; File = fopen (Path, ModesStr); @@ -100,11 +102,11 @@ AcpiOsOpenFile ( * * FUNCTION: AcpiOsCloseFile * - * PARAMETERS: File - File descriptor + * PARAMETERS: File - An open file descriptor * * RETURN: None. * - * DESCRIPTION: Close a file. + * DESCRIPTION: Close a file opened via AcpiOsOpenFile. * ******************************************************************************/ @@ -120,14 +122,14 @@ AcpiOsCloseFile ( * * FUNCTION: AcpiOsReadFile * - * PARAMETERS: File - File descriptor + * PARAMETERS: File - An open file descriptor * Buffer - Data buffer * Size - Data block size * Count - Number of data blocks * - * RETURN: Size of successfully read buffer. + * RETURN: Number of bytes actually read. * - * DESCRIPTION: Read a file. + * DESCRIPTION: Read from a file. * ******************************************************************************/ @@ -140,6 +142,7 @@ AcpiOsReadFile ( { int Length; + Length = fread (Buffer, Size, Count, File); if (Length < 0) { @@ -154,14 +157,14 @@ AcpiOsReadFile ( * * FUNCTION: AcpiOsWriteFile * - * PARAMETERS: File - File descriptor + * PARAMETERS: File - An open file descriptor * Buffer - Data buffer * Size - Data block size * Count - Number of data blocks * - * RETURN: Size of successfully written buffer. + * RETURN: Number of bytes actually written. * - * DESCRIPTION: Write a file. + * DESCRIPTION: Write to a file. * ******************************************************************************/ @@ -174,6 +177,7 @@ AcpiOsWriteFile ( { int Length; + Length = fwrite (Buffer, Size, Count, File); if (Length < 0) { @@ -188,9 +192,9 @@ AcpiOsWriteFile ( * * FUNCTION: AcpiOsGetFileOffset * - * PARAMETERS: File - File descriptor + * PARAMETERS: File - An open file descriptor * - * RETURN: Size of current position. + * RETURN: Current file pointer position. * * DESCRIPTION: Get current file offset. * @@ -202,8 +206,8 @@ AcpiOsGetFileOffset ( { long Offset; - Offset = ftell (File); + Offset = ftell (File); return (Offset); } @@ -212,8 +216,8 @@ AcpiOsGetFileOffset ( * * FUNCTION: AcpiOsSetFileOffset * - * PARAMETERS: File - File descriptor - * Offset - File offset + * PARAMETERS: File - An open file descriptor + * Offset - New file offset * From - From begin/end of file * * RETURN: Status diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index eb088b9dd128..b656de96fe6f 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -41,7 +41,6 @@ * 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. @@ -1159,7 +1158,7 @@ AcpiOsGetTimer ( * FUNCTION: AcpiOsReadPciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Buffer where value is placed * Width - Number of bits * @@ -1172,7 +1171,7 @@ AcpiOsGetTimer ( ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 *Value, UINT32 Width) { @@ -1187,7 +1186,7 @@ AcpiOsReadPciConfiguration ( * FUNCTION: AcpiOsWritePciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Value to be written * Width - Number of bits * @@ -1200,7 +1199,7 @@ AcpiOsReadPciConfiguration ( ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 Value, UINT32 Width) { diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c index 0afde6874f6a..7c8ec2b294dd 100644 --- a/source/os_specific/service_layers/oswintbl.c +++ b/source/os_specific/service_layers/oswintbl.c @@ -329,7 +329,7 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize); - if (WinStatus = ERROR_SUCCESS) + if (WinStatus != ERROR_SUCCESS) { fprintf (stderr, "Could not read the %s table size: %s\n", Signature, WindowsFormatException (WinStatus)); @@ -350,7 +350,7 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, (UCHAR *) ReturnTable, &DataSize); - if (WinStatus = ERROR_SUCCESS) + if (WinStatus != ERROR_SUCCESS) { fprintf (stderr, "Could not read %s data: %s\n", Signature, WindowsFormatException (WinStatus)); diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index 140bfdbb880e..59528077fbd4 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -627,7 +627,6 @@ AcpiOsAllocate ( Mem = (void *) malloc ((size_t) Size); - return (Mem); } @@ -653,7 +652,6 @@ AcpiOsAllocateZeroed ( Mem = (void *) calloc (1, (size_t) Size); - return (Mem); } #endif diff --git a/source/tools/acpibin/abmain.c b/source/tools/acpibin/abmain.c index d6b1acd7e92c..9cfeb32b4a7a 100644 --- a/source/tools/acpibin/abmain.c +++ b/source/tools/acpibin/abmain.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define _DECLARE_GLOBALS #include "acpibin.h" #include "acapps.h" diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index f5c021a49909..8ac08b3e7717 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Global variables. Defined in main.c only, externed in all other files */ diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index 1280ff6e646e..9f32ae7473fc 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -1341,8 +1341,7 @@ AeRegionHandler ( case AML_FIELD_ATTRIB_RAW_BYTES: case AML_FIELD_ATTRIB_RAW_PROCESS: - /* (-2) for status/length */ - Length = MyContext->AccessLength - 2; + Length = MyContext->AccessLength; break; default: @@ -1376,8 +1375,7 @@ AeRegionHandler ( case AML_FIELD_ATTRIB_RAW_BYTES: case AML_FIELD_ATTRIB_RAW_PROCESS: - /* (-2) for status/length */ - Length = MyContext->AccessLength - 2; + Length = MyContext->AccessLength; break; default: diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 99dd1a27d390..c7715098a232 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -314,6 +314,7 @@ AeDoOptions ( { case '^': /* -v: (Version): signon already emitted, just exit */ + (void) AcpiOsTerminate (); exit (0); case 'i': @@ -395,6 +396,7 @@ main ( if (argc < 2) { usage (); + (void) AcpiOsTerminate (); return (0); } diff --git a/source/tools/acpihelp/acpihelp.h b/source/tools/acpihelp/acpihelp.h index da15e4ef89f8..5e7a40fc0f82 100644 --- a/source/tools/acpihelp/acpihelp.h +++ b/source/tools/acpihelp/acpihelp.h @@ -71,6 +71,7 @@ #define AH_DISPLAY_DEVICE_IDS 6 #define AH_DECODE_EXCEPTION 7 #define AH_DECODE_ASL_AML 8 +#define AH_DISPLAY_UUIDS 9 #define AH_MAX_ASL_LINE_LENGTH 70 #define AH_MAX_AML_LINE_LENGTH 100 @@ -109,6 +110,7 @@ typedef struct ah_asl_keyword extern const AH_AML_OPCODE AmlOpcodeInfo[]; extern const AH_ASL_OPERATOR AslOperatorInfo[]; extern const AH_ASL_KEYWORD AslKeywordInfo[]; +extern const AH_UUID AcpiUuids[]; extern BOOLEAN AhDisplayAll; void @@ -147,4 +149,8 @@ void AhDisplayDeviceIds ( char *Name); +void +AhDisplayUuids ( + void); + #endif /* __ACPIHELP_H */ diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c index 60e38081253b..385707186230 100644 --- a/source/tools/acpihelp/ahdecode.c +++ b/source/tools/acpihelp/ahdecode.c @@ -871,6 +871,34 @@ AhDisplayDeviceIds ( } +/******************************************************************************* + * + * FUNCTION: AhDisplayUuids + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all known UUIDs. + * + ******************************************************************************/ + +void +AhDisplayUuids ( + void) +{ + const AH_UUID *Info; + + + printf ("ACPI-related UUIDs:\n\n"); + + for (Info = AcpiUuids; Info->Description; Info++) + { + printf ("%32s : %s\n", Info->Description, Info->String); + } +} + + /******************************************************************************* * * FUNCTION: AhDecodeException diff --git a/source/tools/acpihelp/ahmain.c b/source/tools/acpihelp/ahmain.c index 9be1f3b830b9..4749e5b55357 100644 --- a/source/tools/acpihelp/ahmain.c +++ b/source/tools/acpihelp/ahmain.c @@ -51,7 +51,7 @@ AhDisplayUsage ( void); #define AH_UTILITY_NAME "ACPI Help Utility" -#define AH_SUPPORTED_OPTIONS "aehikmopsv" +#define AH_SUPPORTED_OPTIONS "aehikmopsuv" /****************************************************************************** @@ -82,6 +82,7 @@ AhDisplayUsage ( ACPI_USAGE_TEXT ("\nOther ACPI Names:\n"); ACPI_OPTION ("-i [Name/Prefix]", "Find/Display ACPI/PNP Hardware ID(s)"); + ACPI_OPTION ("-u", "Display ACPI-related UUIDs"); ACPI_USAGE_TEXT ("\nACPI Values:\n"); ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code"); @@ -167,6 +168,11 @@ main ( DecodeType = AH_DECODE_ASL; break; + case 'u': + + DecodeType = AH_DISPLAY_UUIDS; + break; + case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); @@ -224,6 +230,11 @@ main ( AhDecodeException (Name); break; + case AH_DISPLAY_UUIDS: + + AhDisplayUuids (); + break; + default: if (!Name) diff --git a/source/tools/acpisrc/acpisrc.h b/source/tools/acpisrc/acpisrc.h index cdf7f0d99b33..355657fe49d4 100644 --- a/source/tools/acpisrc/acpisrc.h +++ b/source/tools/acpisrc/acpisrc.h @@ -210,6 +210,19 @@ extern ACPI_CONVERSION_TABLE CustomConversionTable; extern ACPI_CONVERSION_TABLE LicenseConversionTable; extern ACPI_CONVERSION_TABLE IndentConversionTable; +typedef +char * (*AS_SCAN_CALLBACK) ( + char *Buffer, + char *Filename, + UINT32 LineNumber); + +typedef struct as_brace_info +{ + char *Operator; + UINT32 Length; + +} AS_BRACE_INFO; + /* Prototypes */ diff --git a/source/tools/acpisrc/asconvrt.c b/source/tools/acpisrc/asconvrt.c index 53c0c5454059..086f24ee14c3 100644 --- a/source/tools/acpisrc/asconvrt.c +++ b/source/tools/acpisrc/asconvrt.c @@ -43,22 +43,309 @@ #include "acpisrc.h" +AS_BRACE_INFO Gbl_BraceInfo[] = +{ + {" if", 3}, + {" else if", 8}, + {" else while", 11}, + {" else", 5}, + {" do ", 4}, + {NULL, 0} +}; + + /* Local prototypes */ -char * -AsCheckAndSkipLiterals ( +static char * +AsMatchValidToken ( char *Buffer, - UINT32 *TotalLines); + char *Filename, + char TargetChar, + AS_SCAN_CALLBACK Callback); + +static char * +AsCheckBracesCallback ( + char *Buffer, + char *Filename, + UINT32 LineNumber); -UINT32 +static UINT32 AsCountLines ( char *Buffer, char *Filename); + /* Opening signature of the Intel legal header */ char *HeaderBegin = "/******************************************************************************\n *\n * 1. Copyright Notice"; +UINT32 NonAnsiCommentCount; + + +/****************************************************************************** + * + * FUNCTION: AsCountNonAnsiComments + * + * DESCRIPTION: Count the number of "//" comments. This type of comment is + * non-ANSI C. + * + * NOTE: July 2014: Allows // within quoted strings and within normal + * comments. Eliminates extraneous warnings from this utility. + * + ******************************************************************************/ + +void +AsCountNonAnsiComments ( + char *Buffer, + char *Filename) +{ + + AsMatchValidToken (Buffer, Filename, 0, NULL); + + /* Error if any slash-slash comments found */ + + if (NonAnsiCommentCount) + { + AsPrint ("Non-ANSI // Comments Found", NonAnsiCommentCount, Filename); + Gbl_NonAnsiComments += NonAnsiCommentCount; + } +} + + +/****************************************************************************** + * + * FUNCTION: AsCheckForBraces + * + * DESCRIPTION: Check for an open brace after each if/else/do (etc.) + * statement + * + ******************************************************************************/ + +void +AsCheckForBraces ( + char *Buffer, + char *Filename) +{ + + AsMatchValidToken (Buffer, Filename, 0, AsCheckBracesCallback); +} + + +/****************************************************************************** + * + * FUNCTION: AsCheckBracesCallback + * + * DESCRIPTION: Check if/else/do statements. Ensure that braces + * are always used. + * + * TBD: Currently, don't check while() statements. The problem is that there + * are two forms: do {} while (); and while () {}. + * + ******************************************************************************/ + +static char * +AsCheckBracesCallback ( + char *Buffer, + char *Filename, + UINT32 LineNumber) +{ + char *SubBuffer = Buffer; + char *NextBrace; + char *NextSemicolon; + AS_BRACE_INFO *BraceInfo; + + + for (BraceInfo = Gbl_BraceInfo; BraceInfo->Operator; BraceInfo++) + { + if (!(strncmp (BraceInfo->Operator, SubBuffer, BraceInfo->Length))) + { + SubBuffer += (BraceInfo->Length - 1); + + /* Find next brace and the next semicolon */ + + NextBrace = AsMatchValidToken (SubBuffer, Filename, '{', NULL); + NextSemicolon = AsMatchValidToken (SubBuffer, Filename, ';', NULL); + + /* Next brace should appear before next semicolon */ + + if ((!NextBrace) || + (NextSemicolon && (NextBrace > NextSemicolon))) + { + Gbl_MissingBraces++; + + if (!Gbl_QuietMode) + { + printf ("Missing braces for <%s>, line %u: %s\n", + BraceInfo->Operator + 1, LineNumber, Filename); + } + } + + return (SubBuffer); + } + } + + /* No match, just return original buffer */ + + return (Buffer); +} + + +/****************************************************************************** + * + * FUNCTION: AsMatchValidToken + * + * DESCRIPTION: Find the next matching token in the input buffer. + * + ******************************************************************************/ + +static char * +AsMatchValidToken ( + char *Buffer, + char *Filename, + char TargetChar, + AS_SCAN_CALLBACK Callback) +{ + char *SubBuffer = Buffer; + char *StringStart; + UINT32 TotalLines; + + + TotalLines = 1; + NonAnsiCommentCount = 0; + + /* Scan from current position up to the end if necessary */ + + while (*SubBuffer) + { + /* Skip normal comments */ + + if ((*SubBuffer == '/') && + (*(SubBuffer + 1) == '*')) + { + /* Must maintain line count */ + + SubBuffer += 2; + while (strncmp ("*/", SubBuffer, 2)) + { + if (*SubBuffer == '\n') + { + TotalLines++; + } + SubBuffer++; + } + + SubBuffer += 2; + continue; + } + + /* Skip single quoted chars */ + + if (*SubBuffer == '\'') + { + SubBuffer++; + if (!(*SubBuffer)) + { + break; + } + + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + continue; + } + + /* Skip quoted strings */ + + if (*SubBuffer == '"') + { + StringStart = SubBuffer; + SubBuffer++; + if (!(*SubBuffer)) + { + break; + } + + while (*SubBuffer != '"') + { + if ((*SubBuffer == '\n') || + (!(*SubBuffer))) + { + AsPrint ("Unbalanced quoted string", 1, Filename); + printf (" %.32s\n", StringStart); + break; + } + + /* Handle escapes within the string */ + + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + } + + SubBuffer++; + continue; + } + + /* Now we can check for a slash-slash comment */ + + if ((*SubBuffer == '/') && + (*(SubBuffer + 1) == '/')) + { + NonAnsiCommentCount++; + + /* Skip to end-of-line */ + + while ((*SubBuffer != '\n') && + (*SubBuffer)) + { + SubBuffer++; + } + + if (!(*SubBuffer)) + { + break; + } + + if (*SubBuffer == '\n') + { + TotalLines++; + } + + SubBuffer++; + continue; + } + + /* Finally, check for a newline */ + + if (*SubBuffer == '\n') + { + TotalLines++; + SubBuffer++; + continue; + } + + /* Normal character, do the user actions */ + + if (Callback) + { + SubBuffer = Callback (SubBuffer, Filename, TotalLines); + } + + if (TargetChar && (*SubBuffer == TargetChar)) + { + return (SubBuffer); + } + + SubBuffer++; + } + + return (NULL); +} + /****************************************************************************** * @@ -199,163 +486,6 @@ AsPrint ( } -/****************************************************************************** - * - * FUNCTION: AsCheckAndSkipLiterals - * - * DESCRIPTION: Generic routine to skip comments and quoted string literals. - * Keeps a line count. - * - ******************************************************************************/ - -char * -AsCheckAndSkipLiterals ( - char *Buffer, - UINT32 *TotalLines) -{ - UINT32 NewLines = 0; - char *SubBuffer = Buffer; - char *LiteralEnd; - - - /* Ignore comments */ - - if ((SubBuffer[0] == '/') && - (SubBuffer[1] == '*')) - { - LiteralEnd = strstr (SubBuffer, "*/"); - SubBuffer += 2; /* Get past comment opening */ - - if (!LiteralEnd) - { - return (SubBuffer); - } - - while (SubBuffer < LiteralEnd) - { - if (*SubBuffer == '\n') - { - NewLines++; - } - - SubBuffer++; - } - - SubBuffer += 2; /* Get past comment close */ - } - - /* Ignore quoted strings */ - - else if (*SubBuffer == '\"') - { - SubBuffer++; - LiteralEnd = AsSkipPastChar (SubBuffer, '\"'); - if (!LiteralEnd) - { - return (SubBuffer); - } - } - - if (TotalLines) - { - (*TotalLines) += NewLines; - } - return (SubBuffer); -} - - -/****************************************************************************** - * - * FUNCTION: AsAsCheckForBraces - * - * DESCRIPTION: Check for an open brace after each if statement - * - ******************************************************************************/ - -void -AsCheckForBraces ( - char *Buffer, - char *Filename) -{ - char *SubBuffer = Buffer; - char *NextBrace; - char *NextSemicolon; - char *NextIf; - UINT32 TotalLines = 1; - - - while (*SubBuffer) - { - - SubBuffer = AsCheckAndSkipLiterals (SubBuffer, &TotalLines); - - if (*SubBuffer == '\n') - { - TotalLines++; - } - else if (!(strncmp (" if", SubBuffer, 3))) - { - SubBuffer += 2; - NextBrace = strstr (SubBuffer, "{"); - NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); - - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) - { - Gbl_MissingBraces++; - - if (!Gbl_QuietMode) - { - printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); - } - } - } - else if (!(strncmp (" else if", SubBuffer, 8))) - { - SubBuffer += 7; - NextBrace = strstr (SubBuffer, "{"); - NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); - - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) - { - Gbl_MissingBraces++; - - if (!Gbl_QuietMode) - { - printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); - } - } - } - else if (!(strncmp (" else", SubBuffer, 5))) - { - SubBuffer += 4; - NextBrace = strstr (SubBuffer, "{"); - NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); - - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) - { - Gbl_MissingBraces++; - - if (!Gbl_QuietMode) - { - printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); - } - } - } - - SubBuffer++; - } -} - - /****************************************************************************** * * FUNCTION: AsTrimLines @@ -435,12 +565,47 @@ void AsTrimWhitespace ( char *Buffer) { + char *SubBuffer; int ReplaceCount = 1; while (ReplaceCount) { - ReplaceCount = AsReplaceString ("\n\n\n\n", "\n\n\n", REPLACE_SUBSTRINGS, Buffer); + ReplaceCount = AsReplaceString ("\n\n\n\n", "\n\n\n", + REPLACE_SUBSTRINGS, Buffer); + } + + /* + * Check for exactly one blank line after the copyright header + */ + + /* Find the header */ + + SubBuffer = strstr (Buffer, HeaderBegin); + if (!SubBuffer) + { + return; + } + + /* Find the end of the header */ + + SubBuffer = strstr (SubBuffer, "*/"); + SubBuffer = AsSkipPastChar (SubBuffer, '\n'); + + /* Replace a double blank line with a single */ + + if (!strncmp (SubBuffer, "\n\n", 2)) + { + SubBuffer = AsReplaceData (SubBuffer, 2, "\n", 1); + AcpiOsPrintf ("Found multiple blank lines after copyright\n"); + } + + /* If no blank line after header, insert one */ + + else if (*SubBuffer != '\n') + { + AsInsertData (SubBuffer, "\n", 1); + AcpiOsPrintf ("Inserted blank line after copyright\n"); } } @@ -477,7 +642,8 @@ AsReplaceHeader ( /* Delete old header, insert new one */ - AsReplaceData (SubBuffer, TokenEnd - SubBuffer, NewHeader, strlen (NewHeader)); + AsReplaceData (SubBuffer, TokenEnd - SubBuffer, + NewHeader, strlen (NewHeader)); } @@ -565,7 +731,8 @@ AsReplaceString ( } } - SubBuffer = AsReplaceData (SubString1, TargetLength, Replacement, ReplacementLength); + SubBuffer = AsReplaceData (SubString1, TargetLength, + Replacement, ReplacementLength); if ((Type & EXTRA_INDENT_C) && (!Gbl_StructDefs)) @@ -585,7 +752,7 @@ AsReplaceString ( * * FUNCTION: AsConvertToLineFeeds * - * DESCRIPTION: + * DESCRIPTION: Convert all CR/LF pairs to LF only. * ******************************************************************************/ @@ -612,7 +779,6 @@ AsConvertToLineFeeds ( SubBuffer = AsReplaceData (SubString, 1, NULL, 0); } - return; } @@ -620,7 +786,7 @@ AsConvertToLineFeeds ( * * FUNCTION: AsInsertCarriageReturns * - * DESCRIPTION: + * DESCRIPTION: Convert lone LFs to CR/LF pairs. * ******************************************************************************/ @@ -648,7 +814,6 @@ AsInsertCarriageReturns ( SubBuffer = AsInsertData (SubString, "\r", 1); SubBuffer += 1; } - return; } @@ -1109,7 +1274,7 @@ AsTabify8 ( * ******************************************************************************/ -UINT32 +static UINT32 AsCountLines ( char *Buffer, char *Filename) @@ -1141,7 +1306,9 @@ AsCountLines ( if (LongLineCount) { - VERBOSE_PRINT (("%u Lines longer than 80 found in %s\n", LongLineCount, Filename)); + VERBOSE_PRINT (("%u Lines longer than 80 found in %s\n", + LongLineCount, Filename)); + Gbl_LongLines += LongLineCount; } @@ -1185,42 +1352,6 @@ AsCountTabs ( } -/****************************************************************************** - * - * FUNCTION: AsCountNonAnsiComments - * - * DESCRIPTION: Count the number of "//" comments. This type of comment is - * non-ANSI C. - * - ******************************************************************************/ - -void -AsCountNonAnsiComments ( - char *Buffer, - char *Filename) -{ - char *SubBuffer = Buffer; - UINT32 CommentCount = 0; - - - while (SubBuffer) - { - SubBuffer = strstr (SubBuffer, "//"); - if (SubBuffer) - { - CommentCount++; - SubBuffer += 2; - } - } - - if (CommentCount) - { - AsPrint ("Non-ANSI Comments found", CommentCount, Filename); - Gbl_NonAnsiComments += CommentCount; - } -} - - /****************************************************************************** * * FUNCTION: AsCountSourceLines @@ -1309,7 +1440,8 @@ AsCountSourceLines ( Gbl_CommentLines += CommentCount; VERBOSE_PRINT (("%u Comment %u White %u Code %u Lines in %s\n", - CommentCount, WhiteCount, LineCount, LineCount+WhiteCount+CommentCount, Filename)); + CommentCount, WhiteCount, LineCount, + LineCount + WhiteCount + CommentCount, Filename)); } @@ -1536,3 +1668,75 @@ Exit: } } #endif + +#ifdef ACPI_UNUSED_FUNCTIONS +/****************************************************************************** + * + * FUNCTION: AsCheckAndSkipLiterals + * + * DESCRIPTION: Generic routine to skip comments and quoted string literals. + * Keeps a line count. + * + ******************************************************************************/ + +static char * +AsCheckAndSkipLiterals ( + char *Buffer, + UINT32 *TotalLines); + + +static char * +AsCheckAndSkipLiterals ( + char *Buffer, + UINT32 *TotalLines) +{ + UINT32 NewLines = 0; + char *SubBuffer = Buffer; + char *LiteralEnd; + + + /* Ignore comments */ + + if ((SubBuffer[0] == '/') && + (SubBuffer[1] == '*')) + { + LiteralEnd = strstr (SubBuffer, "*/"); + SubBuffer += 2; /* Get past comment opening */ + + if (!LiteralEnd) + { + return (SubBuffer); + } + + while (SubBuffer < LiteralEnd) + { + if (*SubBuffer == '\n') + { + NewLines++; + } + + SubBuffer++; + } + + SubBuffer += 2; /* Get past comment close */ + } + + /* Ignore quoted strings */ + + else if (*SubBuffer == '\"') + { + SubBuffer++; + LiteralEnd = AsSkipPastChar (SubBuffer, '\"'); + if (!LiteralEnd) + { + return (SubBuffer); + } + } + + if (TotalLines) + { + (*TotalLines) += NewLines; + } + return (SubBuffer); +} +#endif diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 8b26ebcfcf39..7c893e6a0359 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpisrc.h" #include "acapps.h" @@ -242,8 +241,8 @@ AsDisplayStats ( printf ("%8u Total bytes (%.1fK/file)\n", Gbl_TotalSize, ((double) Gbl_TotalSize/Gbl_Files)/1024); printf ("%8u Tabs found\n", Gbl_Tabs); - printf ("%8u Missing if/else braces\n", Gbl_MissingBraces); - printf ("%8u Non-ANSI comments found\n", Gbl_NonAnsiComments); + printf ("%8u Missing if/else/while braces\n", Gbl_MissingBraces); + printf ("%8u Non-ANSI // comments found\n", Gbl_NonAnsiComments); printf ("%8u Total Lines\n", Gbl_TotalLines); printf ("%8u Lines of code\n", Gbl_SourceLines); printf ("%8u Lines of non-comment whitespace\n", Gbl_WhiteLines); diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 7f25988b10ae..818bba6864d1 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpisrc.h" #include "acapps.h" @@ -467,6 +466,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AML_RESOURCE_UART_SERIALBUS", SRC_TYPE_STRUCT}, {"AML_RESOURCE_VENDOR_LARGE", SRC_TYPE_STRUCT}, {"AML_RESOURCE_VENDOR_SMALL", SRC_TYPE_STRUCT}, + {"AS_BRACE_INFO", SRC_TYPE_STRUCT}, + {"AS_SCAN_CALLBACK", SRC_TYPE_SIMPLE}, {"APIC_HEADER", SRC_TYPE_STRUCT}, {"AE_DEBUG_REGIONS", SRC_TYPE_STRUCT}, @@ -474,6 +475,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AE_TABLE_DESC", SRC_TYPE_STRUCT}, {"ASL_ANALYSIS_WALK_INFO", SRC_TYPE_STRUCT}, {"ASL_ERROR_MSG", SRC_TYPE_STRUCT}, + {"ASL_ERROR_MSG", SRC_TYPE_STRUCT}, {"ASL_EVENT_INFO", SRC_TYPE_STRUCT}, {"ASL_FILE_INFO", SRC_TYPE_STRUCT}, {"ASL_FILE_STATUS", SRC_TYPE_STRUCT}, @@ -506,6 +508,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_TABLE_FACS", SRC_TYPE_STRUCT}, {"ACPI_TABLE_FADT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_FPDT", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_GTDT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_HEST", SRC_TYPE_STRUCT}, {"ACPI_TABLE_HPET", SRC_TYPE_STRUCT}, {"ACPI_TABLE_IBFT", SRC_TYPE_STRUCT}, @@ -551,17 +554,22 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_DBG2_DEVICE", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HEADER", SRC_TYPE_STRUCT}, {"ACPI_DMAR_DEVICE_SCOPE", SRC_TYPE_STRUCT}, + {"ACPI_DMAR_ANDD", SRC_TYPE_STRUCT}, {"ACPI_DMAR_ATSR", SRC_TYPE_STRUCT}, {"ACPI_DMAR_RHSA", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HARDWARE_UNIT", SRC_TYPE_STRUCT}, {"ACPI_DMAR_RESERVED_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_EINJ_ENTRY", SRC_TYPE_STRUCT}, {"ACPI_EINJ_TRIGGER", SRC_TYPE_STRUCT}, + {"ACPI_ERST_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, {"ACPI_FPDT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_FPDT_BOOT", SRC_TYPE_STRUCT}, {"ACPI_FPDT_S3PT_PTR", SRC_TYPE_STRUCT}, - {"ACPI_ERST_ENTRY", SRC_TYPE_STRUCT}, - {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_HEADER", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_TIMER_BLOCK", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_TIMER_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_WATCHDOG", SRC_TYPE_STRUCT}, {"ACPI_HEST_AER_COMMON", SRC_TYPE_STRUCT}, {"ACPI_HEST_HEADER", SRC_TYPE_STRUCT}, {"ACPI_HEST_NOTIFY", SRC_TYPE_STRUCT}, @@ -589,6 +597,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_IVRS_DEVICE8C", SRC_TYPE_STRUCT}, {"ACPI_IVRS_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_MADT_ADDRESS_OVERRIDE", SRC_TYPE_STRUCT}, + {"ACPI_MADT_GENERIC_MSI_FRAME", SRC_TYPE_STRUCT}, + {"ACPI_MADT_GENERIC_REDISTRIBUTOR", SRC_TYPE_STRUCT}, {"ACPI_MADT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_APIC", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_SAPIC", SRC_TYPE_STRUCT}, @@ -611,6 +621,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_MPST_POWER_STATE", SRC_TYPE_STRUCT}, {"ACPI_MCFG_ALLOCATION", SRC_TYPE_STRUCT}, {"ACPI_MSCT_PROXIMITY", SRC_TYPE_STRUCT}, + {"ACPI_PCCT_HW_REDUCED", SRC_TYPE_STRUCT}, + {"ACPI_PCCT_SHARED_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_PCCT_SUBSPACE", SRC_TYPE_STRUCT}, {"ACPI_RSDP_COMMON", SRC_TYPE_STRUCT}, {"ACPI_RSDP_EXTENSION", SRC_TYPE_STRUCT}, @@ -623,6 +635,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_SRAT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_SRAT_MEM_AFFINITY", SRC_TYPE_STRUCT}, {"ACPI_SRAT_X2APIC_CPU_AFFINITY", SRC_TYPE_STRUCT}, + {"ACPI_SRAT_GICC_AFFINITY", SRC_TYPE_STRUCT}, {"ACPI_TPM2_CONTROL", SRC_TYPE_STRUCT}, {"ACPI_WDAT_ENTRY", SRC_TYPE_STRUCT}, @@ -652,6 +665,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AH_ASL_KEYWORD", SRC_TYPE_STRUCT}, {"AH_DEVICE_ID", SRC_TYPE_STRUCT}, {"AH_PREDEFINED_NAME", SRC_TYPE_STRUCT}, + {"AH_UUID", SRC_TYPE_STRUCT}, /* AcpiXtract utility */ diff --git a/source/tools/acpisrc/asutils.c b/source/tools/acpisrc/asutils.c index 050d343388ba..8dbf59fa282c 100644 --- a/source/tools/acpisrc/asutils.c +++ b/source/tools/acpisrc/asutils.c @@ -132,7 +132,6 @@ AsSkipPastChar ( } Buffer++; - return (Buffer); } @@ -173,7 +172,8 @@ AsReplaceData ( if (LengthToRemove > 0) { Gbl_MadeChanges = TRUE; - memmove ((Buffer + LengthToAdd), (Buffer + LengthToRemove), (BufferLength - LengthToRemove)); + memmove ((Buffer + LengthToAdd), (Buffer + LengthToRemove), + (BufferLength - LengthToRemove)); } } -- cgit v1.2.3