From 79eafdd799bd34e8b1ec1dc221be9389c7f2b162 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 30 Aug 2014 11:50:38 +0200 Subject: [PATCH] Sync ACPICA with Intel's version 20140828. * Add support for runtime validation of the _DSD package. * Add the GICC affinity subtable to the SRAT table. * Add error detection for illegally named references within control methods that would cause runtime failures. * Add error checking for dependencies related to the _PSx power methods. * Various improvements, bug fixes and cleanups. For a more detailed list, please see sys/contrib/dev/acpica/changes.txt. --- sys/contrib/dev/acpica/changes.txt | 78 +- .../dev/acpica/generate/unix/Makefile.config | 5 + .../dev/acpica/generate/unix/iasl/Makefile | 25 +- sys/contrib/dev/acpica/source/common/adfile.c | 8 +- .../dev/acpica/source/common/adisasm.c | 26 +- sys/contrib/dev/acpica/source/common/adwalk.c | 1 - .../dev/acpica/source/common/ahuuids.c | 3 + .../dev/acpica/source/common/dmrestag.c | 1 - .../dev/acpica/source/common/dmtable.c | 1 + .../dev/acpica/source/common/dmtbdump.c | 5 + .../dev/acpica/source/common/dmtbinfo.c | 16 +- .../dev/acpica/source/compiler/aslanalyze.c | 1 - .../dev/acpica/source/compiler/aslascii.c | 349 ++++++++ .../dev/acpica/source/compiler/aslbtypes.c | 1 - .../dev/acpica/source/compiler/aslcodegen.c | 1 - .../dev/acpica/source/compiler/aslcompile.c | 743 ++++++---------- .../dev/acpica/source/compiler/aslcompiler.h | 20 +- .../dev/acpica/source/compiler/aslcompiler.l | 8 +- .../dev/acpica/source/compiler/asldefine.h | 5 +- .../dev/acpica/source/compiler/aslerror.c | 8 +- .../dev/acpica/source/compiler/aslfileio.c | 2 + .../dev/acpica/source/compiler/aslfiles.c | 9 +- .../dev/acpica/source/compiler/aslfold.c | 1 - .../dev/acpica/source/compiler/aslglobal.h | 29 +- .../dev/acpica/source/compiler/aslhex.c | 1 - .../dev/acpica/source/compiler/asllength.c | 1 - .../dev/acpica/source/compiler/aslload.c | 1 + .../dev/acpica/source/compiler/asllookup.c | 1 - .../dev/acpica/source/compiler/aslmain.c | 13 +- .../dev/acpica/source/compiler/aslmessages.c | 4 +- .../dev/acpica/source/compiler/aslmessages.h | 2 + .../dev/acpica/source/compiler/aslmethod.c | 53 +- .../dev/acpica/source/compiler/aslnamesp.c | 1 - .../dev/acpica/source/compiler/aslopcodes.c | 1 - .../dev/acpica/source/compiler/asloperands.c | 7 +- .../dev/acpica/source/compiler/aslopt.c | 3 +- .../parser/pswalk.c => compiler/aslparser.y} | 124 +-- .../dev/acpica/source/compiler/aslresource.c | 34 +- .../dev/acpica/source/compiler/aslrestype1.c | 1 - .../dev/acpica/source/compiler/aslrestype1i.c | 1 - .../dev/acpica/source/compiler/aslrestype2.c | 1 - .../dev/acpica/source/compiler/aslrestype2d.c | 1 - .../dev/acpica/source/compiler/aslrestype2e.c | 1 - .../dev/acpica/source/compiler/aslrestype2q.c | 1 - .../dev/acpica/source/compiler/aslrestype2s.c | 1 - .../dev/acpica/source/compiler/aslrestype2w.c | 1 - .../compiler/{aslcompiler.y => aslrules.y} | 832 +----------------- .../dev/acpica/source/compiler/aslstartup.c | 16 +- .../dev/acpica/source/compiler/aslsupport.l | 18 +- .../parser/pswalk.c => compiler/aslsupport.y} | 128 ++- .../dev/acpica/source/compiler/asltokens.y | 386 ++++++++ .../dev/acpica/source/compiler/asltransform.c | 2 - .../dev/acpica/source/compiler/asltree.c | 25 +- .../dev/acpica/source/compiler/asltypes.h | 11 +- .../dev/acpica/source/compiler/asltypes.y | 381 ++++++++ .../dev/acpica/source/compiler/aslutils.c | 64 +- .../dev/acpica/source/compiler/aslwalks.c | 1 - .../dev/acpica/source/compiler/aslxref.c | 193 +++- .../dev/acpica/source/compiler/dtcompile.c | 12 +- .../dev/acpica/source/compiler/dtcompiler.h | 26 +- sys/contrib/dev/acpica/source/compiler/dtio.c | 14 +- .../dev/acpica/source/compiler/dtsubtable.c | 4 +- .../dev/acpica/source/compiler/dttable.c | 5 + .../dev/acpica/source/compiler/dttemplate.c | 7 +- .../dev/acpica/source/compiler/dttemplate.h | 13 +- .../dev/acpica/source/compiler/dtutils.c | 146 ++- .../dev/acpica/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 - .../components/disassembler/dmdeferred.c | 1 - .../source/components/disassembler/dmnames.c | 1 - .../source/components/disassembler/dmobject.c | 1 - .../source/components/disassembler/dmresrc.c | 1 - .../source/components/disassembler/dmresrcl.c | 1 - .../components/disassembler/dmresrcl2.c | 3 +- .../source/components/disassembler/dmresrcs.c | 1 - .../source/components/disassembler/dmutils.c | 1 - .../source/components/disassembler/dmwalk.c | 1 - .../source/components/dispatcher/dswstate.c | 1 - .../source/components/events/evgpeinit.c | 1 - .../source/components/events/evhandler.c | 1 - .../source/components/events/evregion.c | 1 - .../source/components/events/evrgnini.c | 1 - .../acpica/source/components/events/evxface.c | 1 - .../source/components/events/evxfevnt.c | 1 - .../acpica/source/components/events/evxfgpe.c | 1 - .../source/components/executer/exconvrt.c | 1 - .../source/components/executer/exdebug.c | 2 +- .../source/components/executer/exfield.c | 1 - .../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 | 1 - .../source/components/namespace/nsprepkg.c | 40 + .../source/components/namespace/nswalk.c | 1 - .../source/components/namespace/nsxfeval.c | 1 - .../source/components/namespace/nsxfobj.c | 1 - .../acpica/source/components/parser/psloop.c | 1 - .../source/components/parser/psobject.c | 1 - .../source/components/parser/psopcode.c | 1 - .../source/components/parser/psopinfo.c | 1 - .../acpica/source/components/parser/psparse.c | 1 - .../acpica/source/components/parser/psscope.c | 1 - .../acpica/source/components/parser/pstree.c | 1 - .../acpica/source/components/parser/psutils.c | 1 - .../acpica/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/utexcep.c | 1 - .../source/components/utilities/utfileio.c | 1 - .../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/utresrc.c | 5 +- .../source/components/utilities/utstate.c | 1 - .../source/components/utilities/utstring.c | 1 - .../source/components/utilities/utxface.c | 1 - .../source/components/utilities/utxfinit.c | 1 - .../dev/acpica/source/include/acdisasm.h | 1 + .../dev/acpica/source/include/acdispat.h | 1 - .../dev/acpica/source/include/acnames.h | 4 + .../dev/acpica/source/include/acparser.h | 1 - .../dev/acpica/source/include/acpixf.h | 2 +- .../dev/acpica/source/include/actbl1.h | 21 +- .../dev/acpica/source/include/actbl3.h | 8 +- .../acpica/source/include/platform/aclinux.h | 12 + .../source/include/platform/aclinuxex.h | 22 + .../acpica/source/include/platform/acmsvc.h | 27 +- .../os_specific/service_layers/osefixf.c | 1 - .../os_specific/service_layers/osunixxf.c | 1 - .../os_specific/service_layers/oswinxf.c | 2 - .../dev/acpica/source/tools/acpibin/abmain.c | 1 - .../acpica/source/tools/acpidump/acpidump.h | 1 - .../dev/acpica/source/tools/acpiexec/aemain.c | 2 + .../dev/acpica/source/tools/acpisrc/acpisrc.h | 13 + .../acpica/source/tools/acpisrc/asconvrt.c | 740 +++++++++------- .../dev/acpica/source/tools/acpisrc/asmain.c | 5 +- .../dev/acpica/source/tools/acpisrc/astable.c | 5 +- .../dev/acpica/source/tools/acpisrc/asutils.c | 4 +- sys/contrib/dev/acpica/tests/misc/grammar.asl | 2 +- usr.sbin/acpi/iasl/Makefile | 5 + 158 files changed, 2849 insertions(+), 2039 deletions(-) create mode 100644 sys/contrib/dev/acpica/source/compiler/aslascii.c copy sys/contrib/dev/acpica/source/{components/parser/pswalk.c => compiler/aslparser.y} (50%) rename sys/contrib/dev/acpica/source/compiler/{aslcompiler.y => aslrules.y} (82%) copy sys/contrib/dev/acpica/source/{components/parser/pswalk.c => compiler/aslsupport.y} (58%) create mode 100644 sys/contrib/dev/acpica/source/compiler/asltokens.y create mode 100644 sys/contrib/dev/acpica/source/compiler/asltypes.y diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index eae9f819c3..89d262821b 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,8 +1,82 @@ ---------------------------------------- +28 August 2014. Summary of changes for version 20140828: -24 July 2014. Summary of changes for version 20140724: +1) ACPICA kernel-resident subsystem: -This release is available at https://acpica.org/downloads +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 diff --git a/sys/contrib/dev/acpica/generate/unix/Makefile.config b/sys/contrib/dev/acpica/generate/unix/Makefile.config index 8d41399cdf..dd7fd75614 100644 --- a/sys/contrib/dev/acpica/generate/unix/Makefile.config +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/generate/unix/iasl/Makefile b/sys/contrib/dev/acpica/generate/unix/iasl/Makefile index 051450c8a5..f4b6ef39d1 100644 --- a/sys/contrib/dev/acpica/generate/unix/iasl/Makefile +++ b/sys/contrib/dev/acpica/generate/unix/iasl/Makefile @@ -50,6 +50,7 @@ OBJECTS = \ $(OBJDIR)/ahpredef.o\ $(OBJDIR)/ahuuids.o\ $(OBJDIR)/aslanalyze.o\ + $(OBJDIR)/aslascii.o\ $(OBJDIR)/aslbtypes.o\ $(OBJDIR)/aslcodegen.o\ $(OBJDIR)/aslcompile.o\ @@ -212,6 +213,7 @@ OBJECTS = \ $(OBJDIR)/utxferror.o INTERMEDIATES = \ + $(OBJDIR)/aslcompiler.y\ $(OBJDIR)/aslcompilerlex.c\ $(OBJDIR)/aslcompilerparse.c\ $(OBJDIR)/dtparserlex.c\ @@ -224,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 # @@ -237,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/sys/contrib/dev/acpica/source/common/adfile.c b/sys/contrib/dev/acpica/source/common/adfile.c index 0b70d69e22..41c27eebbb 100644 --- a/sys/contrib/dev/acpica/source/common/adfile.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/common/adisasm.c b/sys/contrib/dev/acpica/source/common/adisasm.c index 292b4720da..8deaee7e07 100644 --- a/sys/contrib/dev/acpica/source/common/adisasm.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/common/adwalk.c b/sys/contrib/dev/acpica/source/common/adwalk.c index d150f4dd31..81b5f4acc8 100644 --- a/sys/contrib/dev/acpica/source/common/adwalk.c +++ b/sys/contrib/dev/acpica/source/common/adwalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/sys/contrib/dev/acpica/source/common/ahuuids.c b/sys/contrib/dev/acpica/source/common/ahuuids.c index 8d0b080753..e0b05faef0 100644 --- a/sys/contrib/dev/acpica/source/common/ahuuids.c +++ b/sys/contrib/dev/acpica/source/common/ahuuids.c @@ -88,6 +88,9 @@ const AH_UUID AcpiUuids[] = {"Physical Presence Interface", "3dddfaa6-361b-4eb4-a424-8d10089d1653"}, + {"Device Properties for _DSD", + "daffd814-6eba-4d8c-8a91-bc9bbf4aa301"}, + {NULL, NULL} }; diff --git a/sys/contrib/dev/acpica/source/common/dmrestag.c b/sys/contrib/dev/acpica/source/common/dmrestag.c index 398691b39f..5589d1f4a8 100644 --- a/sys/contrib/dev/acpica/source/common/dmrestag.c +++ b/sys/contrib/dev/acpica/source/common/dmrestag.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/sys/contrib/dev/acpica/source/common/dmtable.c b/sys/contrib/dev/acpica/source/common/dmtable.c index e5627d732e..fc8cbc29f6 100644 --- a/sys/contrib/dev/acpica/source/common/dmtable.c +++ b/sys/contrib/dev/acpica/source/common/dmtable.c @@ -253,6 +253,7 @@ static const char *AcpiDmSratSubnames[] = "Processor Local APIC/SAPIC Affinity", "Memory Affinity", "Processor Local x2APIC Affinity", + "GICC Affinity", "Unknown SubTable Type" /* Reserved */ }; diff --git a/sys/contrib/dev/acpica/source/common/dmtbdump.c b/sys/contrib/dev/acpica/source/common/dmtbdump.c index 72ec095ff5..ac46001473 100644 --- a/sys/contrib/dev/acpica/source/common/dmtbdump.c +++ b/sys/contrib/dev/acpica/source/common/dmtbdump.c @@ -2739,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/sys/contrib/dev/acpica/source/common/dmtbinfo.c b/sys/contrib/dev/acpica/source/common/dmtbinfo.c index 0bfd9e6527..c7a247ecaa 100644 --- a/sys/contrib/dev/acpica/source/common/dmtbinfo.c +++ b/sys/contrib/dev/acpica/source/common/dmtbinfo.c @@ -207,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) @@ -223,6 +224,7 @@ #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) @@ -2186,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 }; @@ -2221,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/sys/contrib/dev/acpica/source/compiler/aslanalyze.c b/sys/contrib/dev/acpica/source/compiler/aslanalyze.c index 940f220b94..94282a0813 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/source/compiler/aslanalyze.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include diff --git a/sys/contrib/dev/acpica/source/compiler/aslascii.c b/sys/contrib/dev/acpica/source/compiler/aslascii.c new file mode 100644 index 0000000000..3fdf1ac0e2 --- /dev/null +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslbtypes.c b/sys/contrib/dev/acpica/source/compiler/aslbtypes.c index fc61c0e3ab..025a416705 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslcodegen.c b/sys/contrib/dev/acpica/source/compiler/aslcodegen.c index 1d10cd7903..8cef7555b1 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslcompile.c b/sys/contrib/dev/acpica/source/compiler/aslcompile.c index cc1a0eb6d0..060380a434 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslcompiler.h b/sys/contrib/dev/acpica/source/compiler/aslcompiler.h index 10251a8c21..1001f68966 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/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); @@ -914,13 +926,17 @@ UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length); void UtExpandLineBuffers ( void); +void +UtFreeLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, diff --git a/sys/contrib/dev/acpica/source/compiler/aslcompiler.l b/sys/contrib/dev/acpica/source/compiler/aslcompiler.l index 60caa49dad..523241a5a5 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/source/compiler/aslcompiler.l @@ -113,7 +113,8 @@ NamePathTail [.]{NameSeg} "/*" { 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); } diff --git a/sys/contrib/dev/acpica/source/compiler/asldefine.h b/sys/contrib/dev/acpica/source/compiler/asldefine.h index 636a02c3a8..c76b4a070b 100644 --- a/sys/contrib/dev/acpica/source/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/source/compiler/asldefine.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLDEFINE_H #define __ASLDEFINE_H @@ -61,8 +60,8 @@ /* 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/sys/contrib/dev/acpica/source/compiler/aslerror.c b/sys/contrib/dev/acpica/source/compiler/aslerror.c index 14ca99d02b..fee96ec0ae 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslfileio.c b/sys/contrib/dev/acpica/source/compiler/aslfileio.c index 56d006b5ad..6bde7080f8 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslfiles.c b/sys/contrib/dev/acpica/source/compiler/aslfiles.c index 514c119d6b..722e0ee9b6 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslfold.c b/sys/contrib/dev/acpica/source/compiler/aslfold.c index 5035c25a34..579997516a 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslglobal.h b/sys/contrib/dev/acpica/source/compiler/aslglobal.h index 4896d70ee6..e347e694f8 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/source/compiler/aslglobal.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLGLOBAL_H #define __ASLGLOBAL_H @@ -96,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 @@ -201,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); @@ -209,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/sys/contrib/dev/acpica/source/compiler/aslhex.c b/sys/contrib/dev/acpica/source/compiler/aslhex.c index 6405fada9e..38766a4db9 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/source/compiler/aslhex.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/sys/contrib/dev/acpica/source/compiler/asllength.c b/sys/contrib/dev/acpica/source/compiler/asllength.c index c6938bd6d0..13af96a00d 100644 --- a/sys/contrib/dev/acpica/source/compiler/asllength.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslload.c b/sys/contrib/dev/acpica/source/compiler/aslload.c index 9b1b2afdf9..ff02d5362f 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslload.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/asllookup.c b/sys/contrib/dev/acpica/source/compiler/asllookup.c index f0c79f7e8a..67c037e1ec 100644 --- a/sys/contrib/dev/acpica/source/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslmain.c b/sys/contrib/dev/acpica/source/compiler/aslmain.c index 3034281b3d..25dca94905 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslmessages.c b/sys/contrib/dev/acpica/source/compiler/aslmessages.c index c9d196f170..30b479e1b7 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslmessages.c +++ b/sys/contrib/dev/acpica/source/compiler/aslmessages.c @@ -233,7 +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_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/sys/contrib/dev/acpica/source/compiler/aslmessages.h b/sys/contrib/dev/acpica/source/compiler/aslmessages.h index 48ebcbfc32..ba0c22b1d2 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/source/compiler/aslmessages.h @@ -236,6 +236,8 @@ typedef enum 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/sys/contrib/dev/acpica/source/compiler/aslmethod.c b/sys/contrib/dev/acpica/source/compiler/aslmethod.c index a040d9217c..0a5cee2835 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/source/compiler/aslmethod.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acparser.h" @@ -108,14 +107,38 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; - /* Special handling for _DSD, must have a _HID also */ + /* + * 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 (!ACPI_STRCMP (METHOD_NAME__DSD, Op->Asl.NameSeg)) + 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)) { - if (!ApFindNameInScope (METHOD_NAME__HID, Op)) + /* 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, - "_DSD requires _HID in same scope"); + MsgBuffer); } } @@ -370,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: @@ -424,15 +458,6 @@ MtMethodAnalysisWalkBegin ( } } - else if (!ACPI_STRCMP (METHOD_NAME__DSD, Op->Asl.NameSeg)) - { - if (!ApFindNameInScope (METHOD_NAME__HID, Op)) - { - AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, - "_DSD requires _HID in same scope"); - } - } - break; default: diff --git a/sys/contrib/dev/acpica/source/compiler/aslnamesp.c b/sys/contrib/dev/acpica/source/compiler/aslnamesp.c index 140e0d4362..ede0ff9400 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslopcodes.c b/sys/contrib/dev/acpica/source/compiler/aslopcodes.c index d6f32d2c22..1ad47532bc 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/source/compiler/aslopcodes.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" diff --git a/sys/contrib/dev/acpica/source/compiler/asloperands.c b/sys/contrib/dev/acpica/source/compiler/asloperands.c index 4a0f294a33..b6cf4a4564 100644 --- a/sys/contrib/dev/acpica/source/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslopt.c b/sys/contrib/dev/acpica/source/compiler/aslopt.c index 05dd27bf5d..1e9b55b93a 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/pswalk.c b/sys/contrib/dev/acpica/source/compiler/aslparser.y similarity index 50% copy from sys/contrib/dev/acpica/source/components/parser/pswalk.c copy to sys/contrib/dev/acpica/source/compiler/aslparser.y index 4e41d4bc71..bf4a8a7499 100644 --- a/sys/contrib/dev/acpica/source/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/source/compiler/aslparser.y @@ -1,6 +1,7 @@ +%{ /****************************************************************************** * - * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * Module Name: aslparser.y - Master Bison/Yacc input file for iASL * *****************************************************************************/ @@ -41,81 +42,88 @@ * POSSIBILITY OF SUCH DAMAGES. */ - +#include "aslcompiler.h" #include "acpi.h" #include "accommon.h" -#include "acparser.h" - -#define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("pswalk") +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslparse") -/******************************************************************************* - * - * FUNCTION: AcpiPsDeleteParseTree - * - * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete - * - * RETURN: None +/* + * Global Notes: * - * DESCRIPTION: Delete a portion of or an entire parse tree. + * 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 -AcpiPsDeleteParseTree ( - ACPI_PARSE_OBJECT *SubtreeRoot) -{ - ACPI_PARSE_OBJECT *Op = SubtreeRoot; - ACPI_PARSE_OBJECT *Next = NULL; - ACPI_PARSE_OBJECT *Parent = NULL; +void * AslLocalAllocate (unsigned int Size); +/* Bison/yacc configuration */ - ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); +#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 - /* Visit all nodes in the subtree */ +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ - while (Op) - { - /* Check if we are not ascending */ +#define YYMALLOC malloc +#define YYFREE free +%} - if (Op != Parent) - { - /* Look for an argument or child of the current op */ +/* + * Declare the type of values in the grammar + */ +%union { + UINT64 i; + char *s; + ACPI_PARSE_OBJECT *n; +} - Next = AcpiPsGetArg (Op, 0); - if (Next) - { - /* Still going downward in tree (Op is not completed yet) */ +/* + * These shift/reduce conflicts are expected. There should be zero + * reduce/reduce conflicts. + */ +%expect 86 - Op = Next; - continue; - } - } +/*! [Begin] no source code translation */ - /* No more children, this Op is complete. */ +/* + * 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) - Next = Op->Common.Next; - Parent = Op->Common.Parent; +/* Token types */ - AcpiPsFreeOp (Op); +m4_include(asltokens.y) - /* If we are back to the starting point, the walk is complete. */ +/* Production types/names */ - if (Op == SubtreeRoot) - { - return_VOID; - } - if (Next) - { - Op = Next; - } - else - { - Op = Parent; - } - } +m4_include(asltypes.y) +%% - return_VOID; -} +/* Production rules */ + +m4_include(aslrules.y) +%% + +/*! [End] no source code translation !*/ + +/* Local support functions in C */ + +m4_include(aslsupport.y) diff --git a/sys/contrib/dev/acpica/source/compiler/aslresource.c b/sys/contrib/dev/acpica/source/compiler/aslresource.c index ce2c4b5c88..f123990cc2 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslrestype1.c b/sys/contrib/dev/acpica/source/compiler/aslrestype1.c index 602e0091cb..73f3efe6ca 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype1.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/sys/contrib/dev/acpica/source/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/source/compiler/aslrestype1i.c index 5a68500fc8..bc16d72820 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype1i.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/sys/contrib/dev/acpica/source/compiler/aslrestype2.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2.c index a1e2fbb63e..9579fe4423 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2d.c index d9a560c2f5..297f99a2cb 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype2d.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/sys/contrib/dev/acpica/source/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2e.c index fa2c611dfc..08590cc573 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype2e.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER diff --git a/sys/contrib/dev/acpica/source/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2q.c index 6ee163973e..0bd32e79b3 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype2q.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/sys/contrib/dev/acpica/source/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2s.c index dc42eb79af..c607899b5f 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/source/compiler/aslrestype2w.c index efdf2e7118..7f58babf21 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/source/compiler/aslrestype2w.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" diff --git a/sys/contrib/dev/acpica/source/compiler/aslcompiler.y b/sys/contrib/dev/acpica/source/compiler/aslrules.y similarity index 82% rename from sys/contrib/dev/acpica/source/compiler/aslcompiler.y rename to sys/contrib/dev/acpica/source/compiler/aslrules.y index 6860e726d5..2bc48db11f 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica/source/compiler/aslrules.y @@ -1,7 +1,7 @@ -%{ +NoEcho(' /****************************************************************************** * - * Module Name: aslcompiler.y - Bison/Yacc input file (ASL grammar and actions) + * Module Name: aslrules.y - Bison/Yacc production rules * *****************************************************************************/ @@ -42,755 +42,8 @@ * 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 @@ -799,10 +52,7 @@ void * AslLocalAllocate (unsigned int Size); /* * ASL Names - */ - - -/* + * * Root rule. Allow multiple #line directives before the definition block * to handle output from preprocessors */ @@ -3511,77 +2761,3 @@ OptionalXferSize | ',' {$$ = 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/sys/contrib/dev/acpica/source/compiler/aslstartup.c b/sys/contrib/dev/acpica/source/compiler/aslstartup.c index 1ed69724d2..84a23dbeb4 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslsupport.l b/sys/contrib/dev/acpica/source/compiler/aslsupport.l index 0317041b4e..7ea43a07db 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/pswalk.c b/sys/contrib/dev/acpica/source/compiler/aslsupport.y similarity index 58% copy from sys/contrib/dev/acpica/source/components/parser/pswalk.c copy to sys/contrib/dev/acpica/source/compiler/aslsupport.y index 4e41d4bc71..a1fdec3437 100644 --- a/sys/contrib/dev/acpica/source/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/source/compiler/aslsupport.y @@ -1,6 +1,7 @@ +NoEcho(' /****************************************************************************** * - * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * Module Name: aslsupport.y - Bison/Yacc C support functions * *****************************************************************************/ @@ -41,81 +42,78 @@ * POSSIBILITY OF SUCH DAMAGES. */ +') -#include "acpi.h" -#include "accommon.h" -#include "acparser.h" - -#define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("pswalk") - - -/******************************************************************************* - * - * FUNCTION: AcpiPsDeleteParseTree - * - * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete - * - * RETURN: None +/****************************************************************************** * - * DESCRIPTION: Delete a portion of or an entire parse tree. + * Local support functions * - ******************************************************************************/ + *****************************************************************************/ -void -AcpiPsDeleteParseTree ( - ACPI_PARSE_OBJECT *SubtreeRoot) +/*! [Begin] no source code translation */ +int +AslCompilerwrap(void) { - ACPI_PARSE_OBJECT *Op = SubtreeRoot; - ACPI_PARSE_OBJECT *Next = NULL; - ACPI_PARSE_OBJECT *Parent = NULL; + return (1); +} +/*! [End] no source code translation !*/ - ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); +void * +AslLocalAllocate (unsigned int Size) +{ + void *Mem; - /* Visit all nodes in the subtree */ + DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); - while (Op) + Mem = UtStringCacheCalloc (Size); + if (!Mem) { - /* Check if we are not ascending */ - - if (Op != Parent) - { - /* Look for an argument or child of the current op */ - - Next = AcpiPsGetArg (Op, 0); - if (Next) - { - /* Still going downward in tree (Op is not completed yet) */ - - Op = Next; - continue; - } - } - - /* No more children, this Op is complete. */ - - Next = Op->Common.Next; - Parent = Op->Common.Parent; - - AcpiPsFreeOp (Op); - - /* If we are back to the starting point, the walk is complete. */ - - if (Op == SubtreeRoot) - { - return_VOID; - } - if (Next) - { - Op = Next; - } - else - { - Op = Parent; - } + 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_VOID; + 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/sys/contrib/dev/acpica/source/compiler/asltokens.y b/sys/contrib/dev/acpica/source/compiler/asltokens.y new file mode 100644 index 0000000000..c296fea30b --- /dev/null +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/asltransform.c b/sys/contrib/dev/acpica/source/compiler/asltransform.c index 9615fe6c6e..34c6ae7175 100644 --- a/sys/contrib/dev/acpica/source/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/asltree.c b/sys/contrib/dev/acpica/source/compiler/asltree.c index 0ea4528baf..cd84d8bf56 100644 --- a/sys/contrib/dev/acpica/source/compiler/asltree.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/asltypes.h b/sys/contrib/dev/acpica/source/compiler/asltypes.h index 7e297d3b67..44c937f2f6 100644 --- a/sys/contrib/dev/acpica/source/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/asltypes.y b/sys/contrib/dev/acpica/source/compiler/asltypes.y new file mode 100644 index 0000000000..b9914531b4 --- /dev/null +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslutils.c b/sys/contrib/dev/acpica/source/compiler/aslutils.c index b6e6087e88..c9a9fac6d7 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/source/compiler/aslutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acdisasm.h" @@ -554,7 +553,7 @@ UtCheckIntegerRange ( /******************************************************************************* * - * FUNCTION: UtGetStringBuffer + * FUNCTION: UtStringCacheCalloc * * PARAMETERS: Length - Size of buffer requested * @@ -567,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); } @@ -615,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); } @@ -660,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 @@ -692,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/sys/contrib/dev/acpica/source/compiler/aslwalks.c b/sys/contrib/dev/acpica/source/compiler/aslwalks.c index 960bebcdd3..da4e9e31e9 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/aslxref.c b/sys/contrib/dev/acpica/source/compiler/aslxref.c index ee3a0f8828..1cbd6e092c 100644 --- a/sys/contrib/dev/acpica/source/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/dtcompile.c b/sys/contrib/dev/acpica/source/compiler/dtcompile.c index aa1f9d1e5d..5c8fea3092 100644 --- a/sys/contrib/dev/acpica/source/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/dtcompiler.h b/sys/contrib/dev/acpica/source/compiler/dtcompiler.h index cec699c5f7..553f5e6d19 100644 --- a/sys/contrib/dev/acpica/source/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/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); diff --git a/sys/contrib/dev/acpica/source/compiler/dtio.c b/sys/contrib/dev/acpica/source/compiler/dtio.c index 25d84ab059..f8e35fdd8a 100644 --- a/sys/contrib/dev/acpica/source/compiler/dtio.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/dtsubtable.c b/sys/contrib/dev/acpica/source/compiler/dtsubtable.c index 90cb067bd0..a87198d39a 100644 --- a/sys/contrib/dev/acpica/source/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/dttable.c b/sys/contrib/dev/acpica/source/compiler/dttable.c index 78a459f8bd..a0dee31e68 100644 --- a/sys/contrib/dev/acpica/source/compiler/dttable.c +++ b/sys/contrib/dev/acpica/source/compiler/dttable.c @@ -2420,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/sys/contrib/dev/acpica/source/compiler/dttemplate.c b/sys/contrib/dev/acpica/source/compiler/dttemplate.c index 8cafbf959f..4fb6be0d38 100644 --- a/sys/contrib/dev/acpica/source/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/compiler/dttemplate.h b/sys/contrib/dev/acpica/source/compiler/dttemplate.h index 67515ea48a..4011f08728 100644 --- a/sys/contrib/dev/acpica/source/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/source/compiler/dttemplate.h @@ -961,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 "........" */ @@ -976,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/sys/contrib/dev/acpica/source/compiler/dtutils.c b/sys/contrib/dev/acpica/source/compiler/dtutils.c index 9cfd314aa5..6927c56697 100644 --- a/sys/contrib/dev/acpica/source/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/source/compiler/dtutils.c @@ -845,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/sys/contrib/dev/acpica/source/compiler/prutils.c b/sys/contrib/dev/acpica/source/compiler/prutils.c index d8b7d45c5d..a93a14e85e 100644 --- a/sys/contrib/dev/acpica/source/compiler/prutils.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/source/components/debugger/dbcmds.c index d9aa2e7aa1..44aafbf0ca 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/source/components/debugger/dbconvert.c index ab809f8112..ad8b13967c 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbconvert.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/source/components/debugger/dbdisply.c index fb47c7ba63..9d0a216af4 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbexec.c b/sys/contrib/dev/acpica/source/components/debugger/dbexec.c index 806b80fb3e..71db787c4d 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/source/components/debugger/dbfileio.c index ee4ba15f0f..abdc454b39 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/source/components/debugger/dbhistry.c index b56d4ef82d..6680306ae9 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbinput.c b/sys/contrib/dev/acpica/source/components/debugger/dbinput.c index 88fbb94752..abf9688c29 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/source/components/debugger/dbmethod.c index 90d131408c..05fd2affb0 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbmethod.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbnames.c b/sys/contrib/dev/acpica/source/components/debugger/dbnames.c index de02fb635e..29fe1ec1d4 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbnames.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbstats.c b/sys/contrib/dev/acpica/source/components/debugger/dbstats.c index 450afcb73b..db29db5584 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbstats.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbutils.c b/sys/contrib/dev/acpica/source/components/debugger/dbutils.c index fcc33ed684..1d4963d4d4 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/debugger/dbxface.c b/sys/contrib/dev/acpica/source/components/debugger/dbxface.c index 671a8f31e4..9a304ad4c0 100644 --- a/sys/contrib/dev/acpica/source/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmdeferred.c b/sys/contrib/dev/acpica/source/components/disassembler/dmdeferred.c index dd0be81a4e..56c6b3899e 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmdeferred.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmnames.c b/sys/contrib/dev/acpica/source/components/disassembler/dmnames.c index 66d50a4433..4b48a348fe 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmnames.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmobject.c b/sys/contrib/dev/acpica/source/components/disassembler/dmobject.c index c938bdefd0..00fc680d7b 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmobject.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmresrc.c b/sys/contrib/dev/acpica/source/components/disassembler/dmresrc.c index 9bd47db6ff..ff6278b2e7 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmresrc.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl.c b/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl.c index 41cbc01817..d6707d39b8 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl2.c b/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl2.c index 3e48afca74..dd9039ea09 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmresrcl2.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmresrcs.c b/sys/contrib/dev/acpica/source/components/disassembler/dmresrcs.c index 1041890982..cbbdc7114d 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmresrcs.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmutils.c b/sys/contrib/dev/acpica/source/components/disassembler/dmutils.c index 2771d44abd..700cfecc30 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmutils.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c index 2da52ea98e..92f27e5062 100644 --- a/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c +++ b/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acparser.h" diff --git a/sys/contrib/dev/acpica/source/components/dispatcher/dswstate.c b/sys/contrib/dev/acpica/source/components/dispatcher/dswstate.c index 18208f3930..389a7d0689 100644 --- a/sys/contrib/dev/acpica/source/components/dispatcher/dswstate.c +++ b/sys/contrib/dev/acpica/source/components/dispatcher/dswstate.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __DSWSTATE_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/events/evgpeinit.c b/sys/contrib/dev/acpica/source/components/events/evgpeinit.c index 6251b36f4d..a8aea022f8 100644 --- a/sys/contrib/dev/acpica/source/components/events/evgpeinit.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/events/evhandler.c b/sys/contrib/dev/acpica/source/components/events/evhandler.c index 150f73f771..0fd1cba30d 100644 --- a/sys/contrib/dev/acpica/source/components/events/evhandler.c +++ b/sys/contrib/dev/acpica/source/components/events/evhandler.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVHANDLER_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/events/evregion.c b/sys/contrib/dev/acpica/source/components/events/evregion.c index 4b5cb9b1dd..8531b5ae2a 100644 --- a/sys/contrib/dev/acpica/source/components/events/evregion.c +++ b/sys/contrib/dev/acpica/source/components/events/evregion.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVREGION_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/events/evrgnini.c b/sys/contrib/dev/acpica/source/components/events/evrgnini.c index 1c3dbbc49d..cd0ca2eea5 100644 --- a/sys/contrib/dev/acpica/source/components/events/evrgnini.c +++ b/sys/contrib/dev/acpica/source/components/events/evrgnini.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVRGNINI_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/events/evxface.c b/sys/contrib/dev/acpica/source/components/events/evxface.c index 51437a915b..bbd88dc370 100644 --- a/sys/contrib/dev/acpica/source/components/events/evxface.c +++ b/sys/contrib/dev/acpica/source/components/events/evxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/events/evxfevnt.c b/sys/contrib/dev/acpica/source/components/events/evxfevnt.c index f854145a49..683c73b568 100644 --- a/sys/contrib/dev/acpica/source/components/events/evxfevnt.c +++ b/sys/contrib/dev/acpica/source/components/events/evxfevnt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFEVNT_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/events/evxfgpe.c b/sys/contrib/dev/acpica/source/components/events/evxfgpe.c index 9e7436a418..79e888ff80 100644 --- a/sys/contrib/dev/acpica/source/components/events/evxfgpe.c +++ b/sys/contrib/dev/acpica/source/components/events/evxfgpe.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFGPE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/executer/exconvrt.c b/sys/contrib/dev/acpica/source/components/executer/exconvrt.c index fbfd137deb..9803cb6a05 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exconvrt.c +++ b/sys/contrib/dev/acpica/source/components/executer/exconvrt.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXCONVRT_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/executer/exdebug.c b/sys/contrib/dev/acpica/source/components/executer/exdebug.c index 9223e4b08f..5b13d19dca 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exdebug.c +++ b/sys/contrib/dev/acpica/source/components/executer/exdebug.c @@ -101,7 +101,7 @@ AcpiExDoDebugObject ( * 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 = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ Timer &= 0x03FFFFFF; /* diff --git a/sys/contrib/dev/acpica/source/components/executer/exfield.c b/sys/contrib/dev/acpica/source/components/executer/exfield.c index 479eee739d..49d3b667b7 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exfield.c +++ b/sys/contrib/dev/acpica/source/components/executer/exfield.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFIELD_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/executer/exfldio.c b/sys/contrib/dev/acpica/source/components/executer/exfldio.c index 448d455d55..e35559fffa 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exfldio.c +++ b/sys/contrib/dev/acpica/source/components/executer/exfldio.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFLDIO_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/executer/exoparg2.c b/sys/contrib/dev/acpica/source/components/executer/exoparg2.c index 8f25f7b16d..f3e976ce53 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exoparg2.c +++ b/sys/contrib/dev/acpica/source/components/executer/exoparg2.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXOPARG2_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/executer/exregion.c b/sys/contrib/dev/acpica/source/components/executer/exregion.c index 1fa07e3490..7532630a23 100644 --- a/sys/contrib/dev/acpica/source/components/executer/exregion.c +++ b/sys/contrib/dev/acpica/source/components/executer/exregion.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXREGION_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsalloc.c b/sys/contrib/dev/acpica/source/components/namespace/nsalloc.c index 0f29a84916..d465a37e5b 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nsalloc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSALLOC_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsinit.c b/sys/contrib/dev/acpica/source/components/namespace/nsinit.c index 27ff7a1324..53155977f3 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsinit.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nsinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFINIT_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsobject.c b/sys/contrib/dev/acpica/source/components/namespace/nsobject.c index 7550fed8d7..5247ca61b4 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsobject.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nsobject.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSOBJECT_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/source/components/namespace/nsprepkg.c index 1e66b5aee2..6cc3c700f2 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsprepkg.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/namespace/nswalk.c b/sys/contrib/dev/acpica/source/components/namespace/nswalk.c index 48b5a27f0f..147e4ce816 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nswalk.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nswalk.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSWALK_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/source/components/namespace/nsxfeval.c index 1423da3034..2b2663cabb 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nsxfeval.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFEVAL_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/namespace/nsxfobj.c b/sys/contrib/dev/acpica/source/components/namespace/nsxfobj.c index 86e1097785..69b656e126 100644 --- a/sys/contrib/dev/acpica/source/components/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/source/components/namespace/nsxfobj.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFOBJ_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/parser/psloop.c b/sys/contrib/dev/acpica/source/components/parser/psloop.c index ace1d6b2bb..5d5dab4967 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psloop.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/psobject.c b/sys/contrib/dev/acpica/source/components/parser/psobject.c index 661817178d..2f69a14897 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psobject.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/psopcode.c b/sys/contrib/dev/acpica/source/components/parser/psopcode.c index bcfb57dd4a..60758e4eb0 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psopcode.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/psopinfo.c b/sys/contrib/dev/acpica/source/components/parser/psopinfo.c index af15d303ba..d419aa0fa1 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psopinfo.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/psparse.c b/sys/contrib/dev/acpica/source/components/parser/psparse.c index 7b8e1b9863..31899bd55a 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psparse.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/psscope.c b/sys/contrib/dev/acpica/source/components/parser/psscope.c index 1a512410d8..d0068b7913 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psscope.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/pstree.c b/sys/contrib/dev/acpica/source/components/parser/pstree.c index 1d57826e4c..746d5759f5 100644 --- a/sys/contrib/dev/acpica/source/components/parser/pstree.c +++ b/sys/contrib/dev/acpica/source/components/parser/pstree.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __PSTREE_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/parser/psutils.c b/sys/contrib/dev/acpica/source/components/parser/psutils.c index 6c37839c91..f6d8c5977e 100644 --- a/sys/contrib/dev/acpica/source/components/parser/psutils.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/parser/pswalk.c b/sys/contrib/dev/acpica/source/components/parser/pswalk.c index 4e41d4bc71..026205d21e 100644 --- a/sys/contrib/dev/acpica/source/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/resources/rsdump.c b/sys/contrib/dev/acpica/source/components/resources/rsdump.c index 91675ed08d..b83d05849a 100644 --- a/sys/contrib/dev/acpica/source/components/resources/rsdump.c +++ b/sys/contrib/dev/acpica/source/components/resources/rsdump.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMP_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/resources/rsdumpinfo.c b/sys/contrib/dev/acpica/source/components/resources/rsdumpinfo.c index 665a76a1cf..906544ad86 100644 --- a/sys/contrib/dev/acpica/source/components/resources/rsdumpinfo.c +++ b/sys/contrib/dev/acpica/source/components/resources/rsdumpinfo.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMPINFO_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/resources/rsutils.c b/sys/contrib/dev/acpica/source/components/resources/rsutils.c index e1fb7777ec..b010ea031f 100644 --- a/sys/contrib/dev/acpica/source/components/resources/rsutils.c +++ b/sys/contrib/dev/acpica/source/components/resources/rsutils.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSUTILS_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/resources/rsxface.c b/sys/contrib/dev/acpica/source/components/resources/rsxface.c index 49b087812e..1e15f8dd84 100644 --- a/sys/contrib/dev/acpica/source/components/resources/rsxface.c +++ b/sys/contrib/dev/acpica/source/components/resources/rsxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/utilities/utclib.c b/sys/contrib/dev/acpica/source/components/utilities/utclib.c index 7892df4c55..c23cc7b4d3 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utclib.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utclib.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __CMCLIB_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utexcep.c b/sys/contrib/dev/acpica/source/components/utilities/utexcep.c index c941c56152..550719cfe1 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utexcep.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utexcep.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTEXCEP_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/utilities/utfileio.c b/sys/contrib/dev/acpica/source/components/utilities/utfileio.c index c6b66ae620..c6ee29cfab 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utfileio.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utfileio.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "actables.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utinit.c b/sys/contrib/dev/acpica/source/components/utilities/utinit.c index 17030be640..8e11c51675 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utinit.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTINIT_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utmath.c b/sys/contrib/dev/acpica/source/components/utilities/utmath.c index 871a3e6c93..51393353b1 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utmath.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utmath.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMATH_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utmisc.c b/sys/contrib/dev/acpica/source/components/utilities/utmisc.c index 93cb288a5b..de2673c6c7 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utmisc.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utmisc.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMISC_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utmutex.c b/sys/contrib/dev/acpica/source/components/utilities/utmutex.c index e787cd0a7d..8fc977a63f 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utmutex.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utmutex.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMUTEX_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utownerid.c b/sys/contrib/dev/acpica/source/components/utilities/utownerid.c index 55756e4573..9194350124 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utownerid.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utownerid.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTOWNERID_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utresrc.c b/sys/contrib/dev/acpica/source/components/utilities/utresrc.c index 53ad155a69..af077aec82 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utresrc.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/components/utilities/utstate.c b/sys/contrib/dev/acpica/source/components/utilities/utstate.c index 5dae9328c5..12de273193 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utstate.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utstate.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTATE_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utstring.c b/sys/contrib/dev/acpica/source/components/utilities/utstring.c index 435f698889..2fa7710725 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utstring.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utstring.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTRING_C__ #include "acpi.h" diff --git a/sys/contrib/dev/acpica/source/components/utilities/utxface.c b/sys/contrib/dev/acpica/source/components/utilities/utxface.c index 6e5628ef7d..dedeab39b4 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utxface.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utxface.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFACE_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/components/utilities/utxfinit.c b/sys/contrib/dev/acpica/source/components/utilities/utxfinit.c index 7c4b66d748..0f1a6c3a9a 100644 --- a/sys/contrib/dev/acpica/source/components/utilities/utxfinit.c +++ b/sys/contrib/dev/acpica/source/components/utilities/utxfinit.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFINIT_C__ #define EXPORT_ACPI_INTERFACES diff --git a/sys/contrib/dev/acpica/source/include/acdisasm.h b/sys/contrib/dev/acpica/source/include/acdisasm.h index 094356ab6d..a732d1726f 100644 --- a/sys/contrib/dev/acpica/source/include/acdisasm.h +++ b/sys/contrib/dev/acpica/source/include/acdisasm.h @@ -360,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[]; diff --git a/sys/contrib/dev/acpica/source/include/acdispat.h b/sys/contrib/dev/acpica/source/include/acdispat.h index 5715ab3b7c..c4abebb55e 100644 --- a/sys/contrib/dev/acpica/source/include/acdispat.h +++ b/sys/contrib/dev/acpica/source/include/acdispat.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef _ACDISPAT_H_ #define _ACDISPAT_H_ diff --git a/sys/contrib/dev/acpica/source/include/acnames.h b/sys/contrib/dev/acpica/source/include/acnames.h index b8322e6afa..bd2a168217 100644 --- a/sys/contrib/dev/acpica/source/include/acnames.h +++ b/sys/contrib/dev/acpica/source/include/acnames.h @@ -59,6 +59,10 @@ #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/sys/contrib/dev/acpica/source/include/acparser.h b/sys/contrib/dev/acpica/source/include/acparser.h index bddd3c1142..8d8adba1fc 100644 --- a/sys/contrib/dev/acpica/source/include/acparser.h +++ b/sys/contrib/dev/acpica/source/include/acparser.h @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACPARSER_H__ #define __ACPARSER_H__ diff --git a/sys/contrib/dev/acpica/source/include/acpixf.h b/sys/contrib/dev/acpica/source/include/acpixf.h index 71741010f3..40037b1085 100644 --- a/sys/contrib/dev/acpica/source/include/acpixf.h +++ b/sys/contrib/dev/acpica/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20140724 +#define ACPI_CA_VERSION 0x20140828 #include "acconfig.h" #include "actypes.h" diff --git a/sys/contrib/dev/acpica/source/include/actbl1.h b/sys/contrib/dev/acpica/source/include/actbl1.h index f9aa1e0e0d..a781056e1d 100644 --- a/sys/contrib/dev/acpica/source/include/actbl1.h +++ b/sys/contrib/dev/acpica/source/include/actbl1.h @@ -1118,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 */ }; /* @@ -1135,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; @@ -1185,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/sys/contrib/dev/acpica/source/include/actbl3.h b/sys/contrib/dev/acpica/source/include/actbl3.h index 37bbd3e6bf..2f98b37203 100644 --- a/sys/contrib/dev/acpica/source/include/actbl3.h +++ b/sys/contrib/dev/acpica/source/include/actbl3.h @@ -360,11 +360,15 @@ typedef struct acpi_gtdt_timer_entry } ACPI_GTDT_TIMER_ENTRY; +/* 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) +#define ACPI_GTDT_GT_IS_SECURE_TIMER (1) +#define ACPI_GTDT_GT_ALWAYS_ON (1<<1) /* 1: SBSA Generic Watchdog Structure */ diff --git a/sys/contrib/dev/acpica/source/include/platform/aclinux.h b/sys/contrib/dev/acpica/source/include/platform/aclinux.h index 30f53e9a11..a56a513140 100644 --- a/sys/contrib/dev/acpica/source/include/platform/aclinux.h +++ b/sys/contrib/dev/acpica/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 diff --git a/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h b/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h index c51f90c82f..cc6d2cecb9 100644 --- a/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h +++ b/sys/contrib/dev/acpica/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 */ diff --git a/sys/contrib/dev/acpica/source/include/platform/acmsvc.h b/sys/contrib/dev/acpica/source/include/platform/acmsvc.h index ec664b00da..845a319907 100644 --- a/sys/contrib/dev/acpica/source/include/platform/acmsvc.h +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/os_specific/service_layers/osefixf.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/osefixf.c index bbb68d8d74..4efbd5b26d 100644 --- a/sys/contrib/dev/acpica/source/os_specific/service_layers/osefixf.c +++ b/sys/contrib/dev/acpica/source/os_specific/service_layers/osefixf.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" #include "acapps.h" diff --git a/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c index b2df84227a..b656de96fe 100644 --- a/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c +++ b/sys/contrib/dev/acpica/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. diff --git a/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c index 140bfdbb88..59528077fb 100644 --- a/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpibin/abmain.c b/sys/contrib/dev/acpica/source/tools/acpibin/abmain.c index d6b1acd7e9..9cfeb32b4a 100644 --- a/sys/contrib/dev/acpica/source/tools/acpibin/abmain.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpidump/acpidump.h b/sys/contrib/dev/acpica/source/tools/acpidump/acpidump.h index f5c021a499..8ac08b3e77 100644 --- a/sys/contrib/dev/acpica/source/tools/acpidump/acpidump.h +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c b/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c index 99dd1a27d3..c7715098a2 100644 --- a/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpisrc/acpisrc.h b/sys/contrib/dev/acpica/source/tools/acpisrc/acpisrc.h index cdf7f0d99b..355657fe49 100644 --- a/sys/contrib/dev/acpica/source/tools/acpisrc/acpisrc.h +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpisrc/asconvrt.c b/sys/contrib/dev/acpica/source/tools/acpisrc/asconvrt.c index 5184b8b3a3..086f24ee14 100644 --- a/sys/contrib/dev/acpica/source/tools/acpisrc/asconvrt.c +++ b/sys/contrib/dev/acpica/source/tools/acpisrc/asconvrt.c @@ -43,254 +43,180 @@ #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); -UINT32 +static char * +AsCheckBracesCallback ( + char *Buffer, + char *Filename, + UINT32 LineNumber); + +static UINT32 AsCountLines ( char *Buffer, char *Filename); + /* Opening signature of the Intel legal header */ char *HeaderBegin = "/******************************************************************************\n *\n * 1. Copyright Notice"; - -/****************************************************************************** - * - * FUNCTION: AsRemoveExtraLines - * - * DESCRIPTION: Remove all extra lines at the start and end of the file. - * - ******************************************************************************/ - -void -AsRemoveExtraLines ( - char *FileBuffer, - char *Filename) -{ - char *FileEnd; - int Length; - - - /* Remove any extra lines at the start of the file */ - - while (*FileBuffer == '\n') - { - printf ("Removing extra line at start of file: %s\n", Filename); - AsRemoveData (FileBuffer, FileBuffer + 1); - } - - /* Remove any extra lines at the end of the file */ - - Length = strlen (FileBuffer); - FileEnd = FileBuffer + (Length - 2); - - while (*FileEnd == '\n') - { - printf ("Removing extra line at end of file: %s\n", Filename); - AsRemoveData (FileEnd, FileEnd + 1); - FileEnd--; - } -} +UINT32 NonAnsiCommentCount; /****************************************************************************** * - * FUNCTION: AsRemoveSpacesAfterPeriod + * FUNCTION: AsCountNonAnsiComments * - * DESCRIPTION: Remove an extra space after a period. + * 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 -AsRemoveSpacesAfterPeriod ( - char *FileBuffer, +AsCountNonAnsiComments ( + char *Buffer, char *Filename) { - int ReplaceCount = 0; - char *Possible; - - - Possible = FileBuffer; - while (Possible) - { - Possible = strstr (Possible, ". "); - if (Possible) - { - if ((*(Possible -1) == '.') || - (*(Possible -1) == '\"') || - (*(Possible -1) == '\n')) - { - Possible += 3; - continue; - } - - Possible = AsReplaceData (Possible, 3, ". ", 2); - ReplaceCount++; - } - } - - if (ReplaceCount) - { - printf ("Removed %d extra blanks after a period: %s\n", - ReplaceCount, Filename); - } -} - - -/****************************************************************************** - * - * FUNCTION: AsMatchExactWord - * - * DESCRIPTION: Check previous and next characters for whitespace - * - ******************************************************************************/ - -BOOLEAN -AsMatchExactWord ( - char *Word, - UINT32 WordLength) -{ - char NextChar; - char PrevChar; + AsMatchValidToken (Buffer, Filename, 0, NULL); - NextChar = Word[WordLength]; - PrevChar = * (Word -1); + /* Error if any slash-slash comments found */ - if (isalnum ((int) NextChar) || - (NextChar == '_') || - isalnum ((int) PrevChar) || - (PrevChar == '_')) + if (NonAnsiCommentCount) { - return (FALSE); + AsPrint ("Non-ANSI // Comments Found", NonAnsiCommentCount, Filename); + Gbl_NonAnsiComments += NonAnsiCommentCount; } - - return (TRUE); } /****************************************************************************** * - * FUNCTION: AsPrint + * FUNCTION: AsCheckForBraces * - * DESCRIPTION: Common formatted print + * DESCRIPTION: Check for an open brace after each if/else/do (etc.) + * statement * ******************************************************************************/ void -AsPrint ( - char *Message, - UINT32 Count, +AsCheckForBraces ( + char *Buffer, char *Filename) { - if (Gbl_QuietMode) - { - return; - } - - printf ("-- %4u %28.28s : %s\n", Count, Message, Filename); + AsMatchValidToken (Buffer, Filename, 0, AsCheckBracesCallback); } /****************************************************************************** * - * FUNCTION: AsCheckAndSkipLiterals + * FUNCTION: AsCheckBracesCallback * - * DESCRIPTION: Generic routine to skip comments and quoted string literals. - * Keeps a line count. + * 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 () {}. * ******************************************************************************/ -char * -AsCheckAndSkipLiterals ( +static char * +AsCheckBracesCallback ( char *Buffer, - UINT32 *TotalLines) + char *Filename, + UINT32 LineNumber) { - UINT32 NewLines = 0; char *SubBuffer = Buffer; - char *LiteralEnd; - + char *NextBrace; + char *NextSemicolon; + AS_BRACE_INFO *BraceInfo; - /* Ignore comments */ - if ((SubBuffer[0] == '/') && - (SubBuffer[1] == '*')) + for (BraceInfo = Gbl_BraceInfo; BraceInfo->Operator; BraceInfo++) { - LiteralEnd = strstr (SubBuffer, "*/"); - SubBuffer += 2; /* Get past comment opening */ - - if (!LiteralEnd) + if (!(strncmp (BraceInfo->Operator, SubBuffer, BraceInfo->Length))) { - return (SubBuffer); - } + SubBuffer += (BraceInfo->Length - 1); - while (SubBuffer < LiteralEnd) - { - if (*SubBuffer == '\n') - { - NewLines++; - } + /* Find next brace and the next semicolon */ - SubBuffer++; - } + NextBrace = AsMatchValidToken (SubBuffer, Filename, '{', NULL); + NextSemicolon = AsMatchValidToken (SubBuffer, Filename, ';', NULL); - SubBuffer += 2; /* Get past comment close */ - } + /* Next brace should appear before next semicolon */ - /* Ignore quoted strings */ + if ((!NextBrace) || + (NextSemicolon && (NextBrace > NextSemicolon))) + { + Gbl_MissingBraces++; + + if (!Gbl_QuietMode) + { + printf ("Missing braces for <%s>, line %u: %s\n", + BraceInfo->Operator + 1, LineNumber, Filename); + } + } - else if (*SubBuffer == '\"') - { - SubBuffer++; - LiteralEnd = AsSkipPastChar (SubBuffer, '\"'); - if (!LiteralEnd) - { return (SubBuffer); } } - if (TotalLines) - { - (*TotalLines) += NewLines; - } - return (SubBuffer); + /* No match, just return original buffer */ + + return (Buffer); } /****************************************************************************** * - * FUNCTION: AsAsCheckForBraces + * FUNCTION: AsMatchValidToken * - * DESCRIPTION: Check for an open brace after each if/else statement + * DESCRIPTION: Find the next matching token in the input buffer. * ******************************************************************************/ -void -AsCheckForBraces ( +static char * +AsMatchValidToken ( char *Buffer, - char *Filename) + char *Filename, + char TargetChar, + AS_SCAN_CALLBACK Callback) { char *SubBuffer = Buffer; - char *NextBrace; - char *NextSemicolon; - UINT32 TotalLines = 1; - char *EndBuffer; + char *StringStart; + UINT32 TotalLines; - EndBuffer = SubBuffer + strlen (SubBuffer); + TotalLines = 1; + NonAnsiCommentCount = 0; - while (SubBuffer <= EndBuffer) - { - /* TBD: Update this function to work properly, as per code below */ - /* SubBuffer = AsCheckAndSkipLiterals (SubBuffer, &TotalLines); */ + /* Scan from current position up to the end if necessary */ + while (*SubBuffer) + { /* Skip normal comments */ if ((*SubBuffer == '/') && @@ -307,6 +233,7 @@ AsCheckForBraces ( } SubBuffer++; } + SubBuffer += 2; continue; } @@ -316,6 +243,11 @@ AsCheckForBraces ( if (*SubBuffer == '\'') { SubBuffer++; + if (!(*SubBuffer)) + { + break; + } + if (*SubBuffer == '\\') { SubBuffer++; @@ -328,9 +260,23 @@ AsCheckForBraces ( 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 == '\\') @@ -344,66 +290,199 @@ AsCheckForBraces ( continue; } - if (*SubBuffer == '\n') - { - TotalLines++; - } - else if (!(strncmp (" if", SubBuffer, 3))) - { - SubBuffer += 2; + /* 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); +} + + +/****************************************************************************** + * + * FUNCTION: AsRemoveExtraLines + * + * DESCRIPTION: Remove all extra lines at the start and end of the file. + * + ******************************************************************************/ + +void +AsRemoveExtraLines ( + char *FileBuffer, + char *Filename) +{ + char *FileEnd; + int Length; + + + /* Remove any extra lines at the start of the file */ + + while (*FileBuffer == '\n') + { + printf ("Removing extra line at start of file: %s\n", Filename); + AsRemoveData (FileBuffer, FileBuffer + 1); + } + + /* Remove any extra lines at the end of the file */ + + Length = strlen (FileBuffer); + FileEnd = FileBuffer + (Length - 2); + + while (*FileEnd == '\n') + { + printf ("Removing extra line at end of file: %s\n", Filename); + AsRemoveData (FileEnd, FileEnd + 1); + FileEnd--; + } +} + + +/****************************************************************************** + * + * FUNCTION: AsRemoveSpacesAfterPeriod + * + * DESCRIPTION: Remove an extra space after a period. + * + ******************************************************************************/ + +void +AsRemoveSpacesAfterPeriod ( + char *FileBuffer, + char *Filename) +{ + int ReplaceCount = 0; + char *Possible; + + + Possible = FileBuffer; + while (Possible) + { + Possible = strstr (Possible, ". "); + if (Possible) + { + if ((*(Possible -1) == '.') || + (*(Possible -1) == '\"') || + (*(Possible -1) == '\n')) + { + Possible += 3; + continue; + } + + Possible = AsReplaceData (Possible, 3, ". ", 2); + ReplaceCount++; + } + } + + if (ReplaceCount) + { + printf ("Removed %d extra blanks after a period: %s\n", + ReplaceCount, Filename); + } +} + - NextBrace = strstr (SubBuffer, "{"); - NextSemicolon = strstr (SubBuffer, ";"); +/****************************************************************************** + * + * FUNCTION: AsMatchExactWord + * + * DESCRIPTION: Check previous and next characters for whitespace + * + ******************************************************************************/ - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon))) - { - Gbl_MissingBraces++; +BOOLEAN +AsMatchExactWord ( + char *Word, + UINT32 WordLength) +{ + char NextChar; + char PrevChar; - 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, ";"); + NextChar = Word[WordLength]; + PrevChar = * (Word -1); - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon))) - { - Gbl_MissingBraces++; + if (isalnum ((int) NextChar) || + (NextChar == '_') || + isalnum ((int) PrevChar) || + (PrevChar == '_')) + { + return (FALSE); + } - 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, ";"); + return (TRUE); +} - if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon))) - { - Gbl_MissingBraces++; - if (!Gbl_QuietMode) - { - printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); - } - } - } +/****************************************************************************** + * + * FUNCTION: AsPrint + * + * DESCRIPTION: Common formatted print + * + ******************************************************************************/ - SubBuffer++; +void +AsPrint ( + char *Message, + UINT32 Count, + char *Filename) +{ + + if (Gbl_QuietMode) + { + return; } + + printf ("-- %4u %28.28s : %s\n", Count, Message, Filename); } @@ -486,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"); } } @@ -528,7 +642,8 @@ AsReplaceHeader ( /* Delete old header, insert new one */ - AsReplaceData (SubBuffer, TokenEnd - SubBuffer, NewHeader, strlen (NewHeader)); + AsReplaceData (SubBuffer, TokenEnd - SubBuffer, + NewHeader, strlen (NewHeader)); } @@ -616,7 +731,8 @@ AsReplaceString ( } } - SubBuffer = AsReplaceData (SubString1, TargetLength, Replacement, ReplacementLength); + SubBuffer = AsReplaceData (SubString1, TargetLength, + Replacement, ReplacementLength); if ((Type & EXTRA_INDENT_C) && (!Gbl_StructDefs)) @@ -636,7 +752,7 @@ AsReplaceString ( * * FUNCTION: AsConvertToLineFeeds * - * DESCRIPTION: + * DESCRIPTION: Convert all CR/LF pairs to LF only. * ******************************************************************************/ @@ -663,7 +779,6 @@ AsConvertToLineFeeds ( SubBuffer = AsReplaceData (SubString, 1, NULL, 0); } - return; } @@ -671,7 +786,7 @@ AsConvertToLineFeeds ( * * FUNCTION: AsInsertCarriageReturns * - * DESCRIPTION: + * DESCRIPTION: Convert lone LFs to CR/LF pairs. * ******************************************************************************/ @@ -699,7 +814,6 @@ AsInsertCarriageReturns ( SubBuffer = AsInsertData (SubString, "\r", 1); SubBuffer += 1; } - return; } @@ -1160,7 +1274,7 @@ AsTabify8 ( * ******************************************************************************/ -UINT32 +static UINT32 AsCountLines ( char *Buffer, char *Filename) @@ -1192,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; } @@ -1236,105 +1352,6 @@ AsCountTabs ( } -/****************************************************************************** - * - * 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) -{ - char *SubBuffer = Buffer; - char *EndBuffer; - UINT32 CommentCount = 0; - char *StartBuffer; - - - EndBuffer = SubBuffer + strlen (SubBuffer); - - while (SubBuffer <= EndBuffer) - { - /* Skip normal comments */ - - if ((*SubBuffer == '/') && - (*(SubBuffer + 1) == '*')) - { - SubBuffer = strstr (SubBuffer + 2, "*/"); - if (!SubBuffer) - { - break; - } - - SubBuffer += 2; - continue; - } - - /* Skip single quoted chars */ - - if (*SubBuffer == '\'') - { - SubBuffer++; - if (*SubBuffer == '\\') - { - SubBuffer++; - } - SubBuffer++; - continue; - } - - /* Skip quoted strings */ - - if (*SubBuffer == '"') - { - StartBuffer = SubBuffer; -AcpiOsPrintf ("START STRING: %.64s\n", StartBuffer); - SubBuffer++; - while (*SubBuffer != '"') - { - /* Handle escapes within the string */ - - if (*SubBuffer == '\\') - { - SubBuffer++; - } - SubBuffer++; - } - - SubBuffer++; - continue; - } - - /* Finally: check for slash-slash comment */ - - if ((*SubBuffer == '/') && - (*(SubBuffer + 1) == '/')) - { - CommentCount++; - SubBuffer++; - } - - SubBuffer++; - } - - /* Error if any slash-slash comments found */ - - if (CommentCount) - { - AsPrint ("Non-ANSI // Comments Found", CommentCount, Filename); - Gbl_NonAnsiComments += CommentCount; - } -} - - /****************************************************************************** * * FUNCTION: AsCountSourceLines @@ -1423,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)); } @@ -1650,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/sys/contrib/dev/acpica/source/tools/acpisrc/asmain.c b/sys/contrib/dev/acpica/source/tools/acpisrc/asmain.c index 8b26ebcfcf..7c893e6a03 100644 --- a/sys/contrib/dev/acpica/source/tools/acpisrc/asmain.c +++ b/sys/contrib/dev/acpica/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/sys/contrib/dev/acpica/source/tools/acpisrc/astable.c b/sys/contrib/dev/acpica/source/tools/acpisrc/astable.c index 1f6f09d6a1..818bba6864 100644 --- a/sys/contrib/dev/acpica/source/tools/acpisrc/astable.c +++ b/sys/contrib/dev/acpica/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}, @@ -633,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}, diff --git a/sys/contrib/dev/acpica/source/tools/acpisrc/asutils.c b/sys/contrib/dev/acpica/source/tools/acpisrc/asutils.c index 050d343388..8dbf59fa28 100644 --- a/sys/contrib/dev/acpica/source/tools/acpisrc/asutils.c +++ b/sys/contrib/dev/acpica/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)); } } diff --git a/sys/contrib/dev/acpica/tests/misc/grammar.asl b/sys/contrib/dev/acpica/tests/misc/grammar.asl index c5f6434ee6..d8b201ab01 100644 --- a/sys/contrib/dev/acpica/tests/misc/grammar.asl +++ b/sys/contrib/dev/acpica/tests/misc/grammar.asl @@ -8402,7 +8402,7 @@ DefinitionBlock ( Return (0x71) } - Store (DerefOf (Index (DEST, 3)), Local0) // DEST = "Destination buffer that..." + Store (DerefOf (Index (DEST, 3)), Local0) // DEST = "Destination buffer that... If (LNotEqual (Local0, 0x74)) // 't' { diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile index c505260860..b477289b38 100644 --- a/usr.sbin/acpi/iasl/Makefile +++ b/usr.sbin/acpi/iasl/Makefile @@ -27,6 +27,7 @@ SRCS= \ ahpredef.c \ ahuuids.c \ aslanalyze.c \ + aslascii.c \ aslbtypes.c \ aslcodegen.c \ aslcompile.c \ @@ -195,6 +196,9 @@ CFLAGS+= \ LFLAGS= -i -s YFLAGS= -d +aslcompiler.y: aslparser.y + m4 -P -I${UTILDIR} ${.ALLSRC} >${.TARGET} + aslcompilerlex.c: aslcompiler.l ${LEX} ${LFLAGS} -PAslCompiler -o${.TARGET} ${.ALLSRC} @@ -223,6 +227,7 @@ prparser.y.h: prparserparse.c mv -f prparserparse.h ${.TARGET} CLEANFILES+= \ + aslcompiler.y \ aslcompilerlex.c \ aslcompilerparse.c \ aslcompiler.y.h \ -- 2.41.0