From aa36cd6999384cddbfa0d030bcdd44e8bf9c7779 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Fri, 14 Feb 2020 19:19:39 +0000 Subject: [PATCH 01/22] Merge ACPICA 20200214. --- changes.txt | 102 +- generate/lint/files.lnt | 1 - generate/lint/lint.bat | 1 - generate/lint/readme.txt | 1 - generate/lint/std16.lnt | 1 - generate/lint/std64.lnt | 1 - generate/unix/Makefile.config | 26 +- generate/unix/acpidump/Makefile | 8 +- generate/unix/acpiexec/Makefile | 6 +- source/common/adisasm.c | 19 +- source/common/dmtables.c | 1 - source/compiler/aslanalyze.c | 14 +- source/compiler/aslcompile.c | 16 +- source/compiler/aslcompiler.h | 17 +- source/compiler/aslcompiler.y | 4921 ------------------ source/compiler/aslexternal.c | 44 +- source/compiler/aslload.c | 228 +- source/compiler/aslmessages.c | 13 +- source/compiler/aslmessages.h | 10 + source/compiler/aslmethod.c | 205 +- source/compiler/aslparseop.c | 15 +- source/compiler/aslprimaries.y | 2 +- source/compiler/aslrules.y | 23 +- source/compiler/asltransform.c | 84 +- source/compiler/aslutils.c | 41 +- source/compiler/aslxref.c | 57 +- source/compiler/cvparser.c | 16 +- source/components/events/evevent.c | 2 +- source/components/events/evxfgpe.c | 38 + source/components/hardware/hwgpe.c | 79 + source/components/hardware/hwsleep.c | 10 + source/components/namespace/nsnames.c | 6 +- source/components/namespace/nsxfname.c | 2 +- source/components/tables/tbxface.c | 12 +- source/components/utilities/utobject.c | 2 +- source/include/acconvert.h | 3 +- source/include/achware.h | 4 + source/include/acmacros.h | 4 +- source/include/acpixf.h | 6 +- source/include/actbl1.h | 2 +- source/include/actypes.h | 7 +- source/os_specific/service_layers/oswintbl.c | 541 +- tests/misc/grammar.asl | 10 +- tests/templates/templates.sh | 1 - 44 files changed, 1253 insertions(+), 5349 deletions(-) delete mode 100644 source/compiler/aslcompiler.y diff --git a/changes.txt b/changes.txt index dc02d248eee..b0edf21a8c2 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,101 @@ +---------------------------------------- +14 February 2020. Summary of changes for version 20200214: + + +1) ACPICA kernel-resident subsystem: + +Enable sleep button on ACPI legacy wake: Hibernation (S4) is triggered +in a guest when it receives a sleep trigger from the hypervisor. When the +guest resumes from this power state, it does not see the SleepEnabled +bit. In other words, the sleepHibernation (S4) is triggered in a guest +when it receives a sleep trigger from the hypervisor. When the guest +resumes from this power state, it does not see the SleepEnabled bit. In +other words, the sleep button is not enabled on waking from an S4 state. +This causes subsequent invocation of sleep state to fail since the +guest.button is not enabled on waking from an S4 state. This causes +subsequent invocation of sleep state to fail in the guest. Fix this +problem by enabling the sleep button in ACPI legacy wake. From Anchal +Agarwal . + +Implemented a new external interface, AcpiAnyGpeStatusSet (). To be used +for checking the status bits of all enabled GPEs in one go. It is needed +to distinguish spurious SCIs from genuine ones when deciding whether or +not to wake up the system from suspend-to-idle. + +Generic Makefiles: replace HOST name with ACPI_HOST: Some machines may be +using HOST in their environment to represent the host name for their +machines. Avoid this problem by renaming this variable from HOST to +ACPI_HOST. + +MSVC 2017 project files: Enable multiprocessor generation to improve +build performance. + +Added a macro to get the byte width of a Generic Address structure. New +ACPI_ACCESS_BYTE_WIDTH is in addition to the existing +ACPI_ACCESS_BIT_WIDTH. From Mika Westerberg. + + +2) iASL Compiler/Disassembler and ACPICA tools: + +iASL: Implemented full support for the (optional, rarely used) ReturnType +and ParameterTypesList for the Method, Function, and External operators. +For Method declarations, the number of individual ParameterTypes must +match the declaration of the number of arguments (NumArgs). This also +Fixes a problem with the External operator where extra/extraneous bytes +were emitted in the AML code if the optional ReturnType/ParameterTypes +were specified for a MethodObj declaration. +New error message: +1) Method NumArgs count does not match length of ParameterTypes list + +iASL: Implemented detection of type mismatches between External +declarations and named object declarations. Also, detect type mismatches +between multiple External declarations of the same Name. +New error messages: +1) Type mismatch between external declaration and actual object +declaration detected +2) Type mismatch between multiple external declarations detected + +iASL: Implemented new error messages for External operators that specify +a ReturnType and/or ParameterTypesList for any object type other than +control methods (MethodObj). +New error messages: +1) Return type is only allowed for Externals declared as MethodObj +2) Parameter type is only allowed for Externals declared as MethodObj + +iASL: Implemented two new remark/warning messages for ASL code that +creates named objects from within a control method. This is very +inefficient since the named object must be created and deleted each time +the method is executed. +New messages: +1) Creation of named objects within a method is highly inefficient, use +globals or method local variables instead (remark) +2) Static OperationRegion should be declared outside control method +(warning) + +iASL: Improved illegal forward reference detection by adding support to +detect forward-reference method invocations. + +iASL: Detect and issue an error message for NameStrings that contain too +many individual NameSegs (>255). This is an AML limitation that is +defined in the ACPI specification. +New message: +1) NameString contains too many NameSegs (>255) + +acpidump: windows: use GetSystemFirmwareTable API for all tables except +SSDT. By using this API, acpidump is able to get all tables in the XSDT + +iASL: Removed unused parser file and updated msvc2017 project files. +Removed the obsolete AslCompiler.y from the repository. + +iASL: msvc2017: Fixed macros in the file dependency list to prevent +unnecessary rebuilds. Replace %(Directory) with %(RelativeDir). + +Disassembler: Prevent spilling error messages to the output file. All +errors are directed to the console instead. These error messages +prevented re-compilation of the resulting disassembled ASL output file +(.DSL). + + ---------------------------------------- 10 January 2020. Summary of changes for version 20200110: @@ -8845,8 +8943,8 @@ much larger code and data size. Fix build error under Bison-2.4. -Dissasembler: Enhanced FADT support. Added decoding of the Boot -Architecture +Disassembler: Enhanced FADT support. Added decoding of the Boot +Architecture flags. Now decode all flags, regardless of the FADT version. Flag output includes the FADT version which first defined each flag. diff --git a/generate/lint/files.lnt b/generate/lint/files.lnt index ac0a36e7918..186874baed1 100644 --- a/generate/lint/files.lnt +++ b/generate/lint/files.lnt @@ -12,4 +12,3 @@ ..\..\source\components\resources\*.c ..\..\source\components\tables\*.c ..\..\source\components\utilities\*.c - diff --git a/generate/lint/lint.bat b/generate/lint/lint.bat index 18fde838db5..0f82d33d233 100644 --- a/generate/lint/lint.bat +++ b/generate/lint/lint.bat @@ -13,4 +13,3 @@ echo 32-bit lint completed >> LintOut.txt @echo off echo --- echo Output placed in LintOut.txt - diff --git a/generate/lint/readme.txt b/generate/lint/readme.txt index 3f427ad6bd6..4336320fb1f 100644 --- a/generate/lint/readme.txt +++ b/generate/lint/readme.txt @@ -11,4 +11,3 @@ std32.lnt - 32-bit options std64.lnt - 64-bit options options.lnt - common options others - windows/dos compiler option files - diff --git a/generate/lint/std16.lnt b/generate/lint/std16.lnt index c3a116a6e41..0919d0ed6de 100644 --- a/generate/lint/std16.lnt +++ b/generate/lint/std16.lnt @@ -13,4 +13,3 @@ c:\acpi\generate\lint\co-msc40.lnt options.lnt -mL -si2 -spN2 -spF4 -sl4 - diff --git a/generate/lint/std64.lnt b/generate/lint/std64.lnt index 441c9756a3a..032c457e57e 100644 --- a/generate/lint/std64.lnt +++ b/generate/lint/std64.lnt @@ -15,4 +15,3 @@ co.lnt options.lnt - diff --git a/generate/unix/Makefile.config b/generate/unix/Makefile.config index c28e8a9b196..742874566f1 100644 --- a/generate/unix/Makefile.config +++ b/generate/unix/Makefile.config @@ -26,15 +26,15 @@ # Notes: # gcc should be version 4 or greater, otherwise some of the options # used will not be recognized. -# Optional: Set HOST to an appropriate value (_LINUX, _FreeBSD, _APPLE, _CYGWIN, etc.) +# Optional: Set ACPI_HOST to an appropriate value (_LINUX, _FreeBSD, _APPLE, _CYGWIN, etc.) # See include/platform/acenv.h for supported values. -# Note: HOST is not nearly as important for applications as it +# Note: ACPI_HOST is not nearly as important for applications as it # is for the kernel-resident version of ACPICA, and it may # not be necessary to change it. # .SUFFIXES : PROGS = acpibin acpidump acpiexamples acpiexec acpihelp acpinames acpisrc acpixtract iasl -HOST ?= _CYGWIN +ACPI_HOST ?= _CYGWIN CC ?= gcc # @@ -52,26 +52,26 @@ UNAME_S := $(shell uname -s) # Host detection and configuration # ifeq ($(UNAME_S), Darwin) # Mac OS X -HOST = _APPLE +ACPI_HOST = _APPLE endif ifeq ($(UNAME_S), DragonFly) -HOST = _DragonFly +ACPI_HOST = _DragonFly endif ifeq ($(UNAME_S), FreeBSD) -HOST = _FreeBSD +ACPI_HOST = _FreeBSD endif ifeq ($(UNAME_S), NetBSD) -HOST = _NetBSD +ACPI_HOST = _NetBSD endif ifeq ($(UNAME_S), QNX) -HOST = _QNX +ACPI_HOST = _QNX endif -ifeq ($(HOST), _APPLE) +ifeq ($(ACPI_HOST), _APPLE) INSTALL = cp INSTALLFLAGS ?= -f else @@ -183,7 +183,7 @@ OPT_CFLAGS += -D_FORTIFY_SOURCE=2 endif CFLAGS += \ - -D$(HOST)\ + -D$(ACPI_HOST)\ -D_GNU_SOURCE\ -I$(ACPICA_INCLUDE) @@ -191,7 +191,7 @@ CFLAGS += \ # QNX requires __EXT to enable most functions in its C library, analogous # to _GNU_SOURCE. # -ifeq ($(HOST), _QNX) +ifeq ($(ACPI_HOST), _QNX) CFLAGS+=-D__EXT endif @@ -231,11 +231,11 @@ CWARNINGFLAGS += \ # # Per-host flags and exclusions # -ifneq ($(HOST), _FreeBSD) +ifneq ($(ACPI_HOST), _FreeBSD) CWARNINGFLAGS += \ -Wempty-body - ifneq ($(HOST), _APPLE) + ifneq ($(ACPI_HOST), _APPLE) CWARNINGFLAGS += \ -Woverride-init\ -Wlogical-op\ diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index 884708b8aa2..292eec71276 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -54,19 +54,19 @@ OBJECTS = \ # # Per-host interfaces # -ifeq ($(HOST), _DragonFly) +ifeq ($(ACPI_HOST), _DragonFly) HOST_FAMILY = BSD endif -ifeq ($(HOST), _FreeBSD) +ifeq ($(ACPI_HOST), _FreeBSD) HOST_FAMILY = BSD endif -ifeq ($(HOST), _NetBSD) +ifeq ($(ACPI_HOST), _NetBSD) HOST_FAMILY = BSD endif -ifeq ($(HOST), _QNX) +ifeq ($(ACPI_HOST), _QNX) HOST_FAMILY = BSD endif diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 9faf312147c..660afa9397b 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -255,12 +255,12 @@ CFLAGS += \ -DACPI_CHECKSUM_ABORT=TRUE endif -ifneq ($(HOST),_QNX) +ifneq ($(ACPI_HOST),_QNX) LDFLAGS += -lpthread endif -ifneq ($(HOST),_APPLE) -ifneq ($(HOST),_QNX) +ifneq ($(ACPI_HOST),_APPLE) +ifneq ($(ACPI_HOST),_QNX) LDFLAGS += -lrt endif endif diff --git a/source/common/adisasm.c b/source/common/adisasm.c index 60bd5fda839..015765ff582 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -156,6 +156,7 @@ #include "acnamesp.h" #include "acparser.h" #include "acapps.h" +#include "acconvert.h" #define _COMPONENT ACPI_TOOLS @@ -379,8 +380,6 @@ AdAmlDisassemble ( Status = AE_ERROR; goto Cleanup; } - - AcpiOsRedirectOutput (File); } *OutFilename = DisasmFilename; @@ -467,6 +466,11 @@ AdDisassembleOneTable ( if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) { + if (File) + { + AcpiOsRedirectOutput (File); + } + AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE); /* This is a "Data Table" (non-AML table) */ @@ -489,6 +493,10 @@ AdDisassembleOneTable ( return (AE_OK); } + /* Initialize the converter output file */ + + ASL_CV_INIT_FILETREE(Table, File); + /* * This is an AML table (DSDT or SSDT). * Always parse the tables, only option is what to display @@ -501,6 +509,13 @@ AdDisassembleOneTable ( return (Status); } + /* Redirect output for code generation and debugging output */ + + if (File) + { + AcpiOsRedirectOutput (File); + } + /* Debug output, namespace and parse tree */ if (AslCompilerdebug && File) diff --git a/source/common/dmtables.c b/source/common/dmtables.c index 3bc9c07a72c..ee18d26c965 100644 --- a/source/common/dmtables.c +++ b/source/common/dmtables.c @@ -506,7 +506,6 @@ AdParseTable ( AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); - ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength); AcpiUtSetIntegerWidth (Table->Revision); diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index 9139f4e979c..63feba2b127 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -151,6 +151,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acnamesp.h" #include @@ -421,6 +422,7 @@ AnCheckMethodReturnValue ( { ACPI_PARSE_OBJECT *OwningOp; ACPI_NAMESPACE_NODE *Node; + char *ExternalPath; Node = ArgOp->Asl.Node; @@ -435,18 +437,19 @@ AnCheckMethodReturnValue ( /* Examine the parent op of this method */ OwningOp = Node->Op; + ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE); + if (OwningOp->Asl.CompileFlags & OP_METHOD_NO_RETVAL) { /* Method NEVER returns a value */ - AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, ExternalPath); } else if (OwningOp->Asl.CompileFlags & OP_METHOD_SOME_NO_RETVAL) { /* Method SOMETIMES returns a value, SOMETIMES not */ - AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, - Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, ExternalPath); } else if (!(ThisNodeBtype & RequiredBtypes)) { @@ -470,6 +473,11 @@ AnCheckMethodReturnValue ( AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, AslGbl_MsgBuffer); } } + + if (ExternalPath) + { + ACPI_FREE (ExternalPath); + } } diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 0f145560377..9481b6bb2d6 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -647,7 +647,7 @@ void AslCompilerFileHeader ( UINT32 FileId) { - struct tm *NewTime; + char *NewTime; time_t Aclock; char *Prefix = ""; @@ -691,13 +691,17 @@ AslCompilerFileHeader ( /* Compilation header with timestamp */ - (void) time (&Aclock); - NewTime = localtime (&Aclock); + Aclock = time (NULL); + NewTime = ctime (&Aclock); FlPrintFile (FileId, - "%sCompilation of \"%s\" - %s%s\n", - Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), - Prefix); + "%sCompilation of \"%s\" -", + Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename); + + if (NewTime) + { + FlPrintFile (FileId, " %s%s\n", NewTime, Prefix); + } switch (FileId) { diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index e82a91e4662..9bebc3801d7 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -373,6 +373,15 @@ MtMethodAnalysisWalkEnd ( UINT32 Level, void *Context); +UINT32 +MtProcessTypeOp ( + ACPI_PARSE_OBJECT *TypeOp); + +UINT8 +MtProcessParameterTypeList ( + ACPI_PARSE_OBJECT *ParamTypeOp, + UINT32 *TypeList); + /* * aslbtypes - bitfield data types @@ -1233,10 +1242,14 @@ UtDumpBasicOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level); -void * -UtGetParentMethod ( +ACPI_NAMESPACE_NODE * +UtGetParentMethodNode ( ACPI_NAMESPACE_NODE *Node); +ACPI_PARSE_OBJECT * +UtGetParentMethodOp ( + ACPI_PARSE_OBJECT *Op); + BOOLEAN UtNodeIsDescendantOf ( ACPI_NAMESPACE_NODE *Node1, diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslcompiler.y deleted file mode 100644 index 94b6fa041b8..00000000000 --- a/source/compiler/aslcompiler.y +++ /dev/null @@ -1,4921 +0,0 @@ -%{ -/****************************************************************************** - * - * Module Name: aslparser.y - Master Bison/Yacc input file for iASL - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * 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. - * - * 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 MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "aslcompiler.h" -#include "acpi.h" -#include "accommon.h" - -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslparse") - -/* - * Global Notes: - * - * October 2005: The following list terms have been optimized (from the - * original ASL grammar in the ACPI specification) to force the immediate - * reduction of each list item so that the parse stack use doesn't increase on - * each list element and possibly overflow on very large lists (>4000 items). - * This dramatically reduces use of the parse stack overall. - * - * ArgList, TermList, ByteList, DWordList, PackageList, - * ResourceMacroList, and FieldUnitList - */ - -void * -AslLocalAllocate ( - unsigned int Size); - - -/* Bison/yacc configuration */ - -#define static -#undef malloc -#define malloc AslLocalAllocate -#undef alloca -#define alloca AslLocalAllocate -#define yytname AslCompilername - -#define YYINITDEPTH 600 /* State stack depth */ -#define YYDEBUG 1 /* Enable debug output */ -#define YYERROR_VERBOSE 1 /* Verbose error messages */ -#define YYFLAG -32768 - -/* Define YYMALLOC/YYFREE to prevent redefinition errors */ - -#define YYMALLOC AslLocalAllocate -#define YYFREE ACPI_FREE -%} - -/* - * Declare the type of values in the grammar - */ -%union { - UINT64 i; - char *s; - ACPI_PARSE_OBJECT *n; -} - -/* - * These shift/reduce conflicts are expected. There should be zero - * reduce/reduce conflicts. - */ -%expect 124 - -/*! [Begin] no source code translation */ - -/* - * The M4 macro processor is used to bring in the parser items, - * in order to keep this master file smaller, and to break up - * the various parser items. - */ - - -/* Token types */ - - - -/****************************************************************************** - * - * 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! - * - *****************************************************************************/ - -/* - * Most tokens are defined to return , which is a UINT64. - * - * These tokens return , a pointer to the associated lexed string: - * - * PARSEOP_NAMESEG - * PARSEOP_NAMESTRING - * PARSEOP_STRING_LITERAL - * PARSEOP_STRUCTURE_NAMESTRING - */ -%token PARSEOP_ACCESSAS -%token PARSEOP_ACCESSATTRIB_BLOCK -%token PARSEOP_ACCESSATTRIB_BLOCK_CALL -%token PARSEOP_ACCESSATTRIB_BYTE -%token PARSEOP_ACCESSATTRIB_BYTES -%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_DEFINITION_BLOCK -%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_I2C_SERIALBUS_V2 -%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_PINCONFIG -%token PARSEOP_PINFUNCTION -%token PARSEOP_PINGROUP -%token PARSEOP_PINGROUPCONFIG -%token PARSEOP_PINGROUPFUNCTION -%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_SPI_SERIALBUS_V2 -%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_UART_SERIALBUS_V2 -%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 - -/* ToPld macro */ - -%token PARSEOP_TOPLD -%token PARSEOP_PLD_REVISION -%token PARSEOP_PLD_IGNORECOLOR -%token PARSEOP_PLD_RED -%token PARSEOP_PLD_GREEN -%token PARSEOP_PLD_BLUE -%token PARSEOP_PLD_WIDTH -%token PARSEOP_PLD_HEIGHT -%token PARSEOP_PLD_USERVISIBLE -%token PARSEOP_PLD_DOCK -%token PARSEOP_PLD_LID -%token PARSEOP_PLD_PANEL -%token PARSEOP_PLD_VERTICALPOSITION -%token PARSEOP_PLD_HORIZONTALPOSITION -%token PARSEOP_PLD_SHAPE -%token PARSEOP_PLD_GROUPORIENTATION -%token PARSEOP_PLD_GROUPTOKEN -%token PARSEOP_PLD_GROUPPOSITION -%token PARSEOP_PLD_BAY -%token PARSEOP_PLD_EJECTABLE -%token PARSEOP_PLD_EJECTREQUIRED -%token PARSEOP_PLD_CABINETNUMBER -%token PARSEOP_PLD_CARDCAGENUMBER -%token PARSEOP_PLD_REFERENCE -%token PARSEOP_PLD_ROTATION -%token PARSEOP_PLD_ORDER -%token PARSEOP_PLD_RESERVED -%token PARSEOP_PLD_VERTICALOFFSET -%token PARSEOP_PLD_HORIZONTALOFFSET - -/* - * C-style expression parser. These must appear after all of the - * standard ASL operators and keywords. - * - * Note: The order of these tokens implements the precedence rules - * (low precedence to high). See aslrules.y for an exhaustive list. - */ -%right PARSEOP_EXP_EQUALS - PARSEOP_EXP_ADD_EQ - PARSEOP_EXP_SUB_EQ - PARSEOP_EXP_MUL_EQ - PARSEOP_EXP_DIV_EQ - PARSEOP_EXP_MOD_EQ - PARSEOP_EXP_SHL_EQ - PARSEOP_EXP_SHR_EQ - PARSEOP_EXP_AND_EQ - PARSEOP_EXP_XOR_EQ - PARSEOP_EXP_OR_EQ - -%left PARSEOP_EXP_LOGICAL_OR -%left PARSEOP_EXP_LOGICAL_AND -%left PARSEOP_EXP_OR -%left PARSEOP_EXP_XOR -%left PARSEOP_EXP_AND -%left PARSEOP_EXP_EQUAL - PARSEOP_EXP_NOT_EQUAL -%left PARSEOP_EXP_GREATER - PARSEOP_EXP_LESS - PARSEOP_EXP_GREATER_EQUAL - PARSEOP_EXP_LESS_EQUAL -%left PARSEOP_EXP_SHIFT_RIGHT - PARSEOP_EXP_SHIFT_LEFT -%left PARSEOP_EXP_ADD - PARSEOP_EXP_SUBTRACT -%left PARSEOP_EXP_MULTIPLY - PARSEOP_EXP_DIVIDE - PARSEOP_EXP_MODULO - -%right PARSEOP_EXP_NOT - PARSEOP_EXP_LOGICAL_NOT - -%left PARSEOP_EXP_INCREMENT - PARSEOP_EXP_DECREMENT - -%left PARSEOP_OPEN_PAREN - PARSEOP_CLOSE_PAREN - -/* Brackets for Index() support */ - -%left PARSEOP_EXP_INDEX_LEFT -%right PARSEOP_EXP_INDEX_RIGHT - -/* Macros */ - -%token PARSEOP_PRINTF -%token PARSEOP_FPRINTF -%token PARSEOP_FOR - -/* Structures */ - -%token PARSEOP_STRUCTURE -%token PARSEOP_STRUCTURE_NAMESTRING -%token PARSEOP_STRUCTURE_TAG -%token PARSEOP_STRUCTURE_ELEMENT -%token PARSEOP_STRUCTURE_INSTANCE -%token PARSEOP_STRUCTURE_REFERENCE -%token PARSEOP_STRUCTURE_POINTER - -/* Top level */ - -%token PARSEOP_ASL_CODE - - -/******************************************************************************* - * - * Tokens below are not in the aslmap.c file - * - ******************************************************************************/ - - -/* Tokens below this are not in the aslmap.c file */ - -/* Specific parentheses tokens are not used at this time */ - /* PARSEOP_EXP_PAREN_OPEN */ - /* PARSEOP_EXP_PAREN_CLOSE */ - -/* ASL+ variable creation */ - -%token PARSEOP_INTEGER_TYPE -%token PARSEOP_STRING_TYPE -%token PARSEOP_BUFFER_TYPE -%token PARSEOP_PACKAGE_TYPE -%token PARSEOP_REFERENCE_TYPE - - -/* - * Special functions. These should probably stay at the end of this - * table. - */ -%token PARSEOP___DATE__ -%token PARSEOP___FILE__ -%token PARSEOP___LINE__ -%token PARSEOP___PATH__ -%token PARSEOP___METHOD__ - - -/* Production types/names */ - - - -/****************************************************************************** - * - * Production names - * - *****************************************************************************/ - -%type ArgList -%type AslCode -%type BufferData -%type BufferTermData -%type CompilerDirective -%type DataObject -%type DefinitionBlockTerm -%type DefinitionBlockList -%type IntegerData -%type NamedObject -%type NameSpaceModifier -%type Object -%type PackageData -%type ParameterTypePackage -%type ParameterTypePackageList -%type ParameterTypesPackage -%type ParameterTypesPackageList -%type RequiredTarget -%type SimpleName -%type StringData -%type Target -%type Term -%type TermArg -%type TermList -%type MethodInvocationTerm - -/* 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 ElseIfTerm -%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 RawDataBufferTerm -%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 ObjectTypeSource -%type DerefOfSource -%type RefOfSource -%type CondRefOfSource -%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 - -/* Macros */ - -%type EISAIDTerm -%type ResourceMacroList -%type ResourceMacroTerm -%type ResourceTemplateTerm -%type PldKeyword -%type PldKeywordList -%type ToPLDTerm -%type ToUUIDTerm -%type UnicodeTerm -%type PrintfArgList -%type PrintfTerm -%type FprintfTerm -%type ForTerm - -/* Resource Descriptors */ - -%type ConnectionTerm -%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 I2cSerialBusTermV2 -%type InterruptTerm -%type IOTerm -%type IRQNoFlagsTerm -%type IRQTerm -%type Memory24Term -%type Memory32FixedTerm -%type Memory32Term -%type NameSeg -%type NameString -%type PinConfigTerm -%type PinFunctionTerm -%type PinGroupTerm -%type PinGroupConfigTerm -%type PinGroupFunctionTerm -%type QWordIOTerm -%type QWordMemoryTerm -%type QWordSpaceTerm -%type RegisterTerm -%type SpiSerialBusTerm -%type SpiSerialBusTermV2 -%type StartDependentFnNoPriTerm -%type StartDependentFnTerm -%type UartSerialBusTerm -%type UartSerialBusTermV2 -%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 OptionalAccessTypeKeyword -%type OptionalAddressingMode -%type OptionalAddressRange -%type OptionalBitsPerByte -%type OptionalBuffer_Last -%type OptionalByteConstExpr -%type OptionalCount -%type OptionalDataCount -%type OptionalDecodeType -%type OptionalDevicePolarity -%type OptionalDWordConstExpr -%type OptionalEndian -%type OptionalFlowControl -%type OptionalIoRestriction -%type OptionalListString -%type OptionalLockRuleKeyword -%type OptionalMaxType -%type OptionalMemType -%type OptionalMinType -%type OptionalNameString -%type OptionalNameString_First -%type OptionalNameString_Last -%type OptionalObjectTypeKeyword -%type OptionalParameterTypePackage -%type OptionalParameterTypesPackage -%type OptionalParentheses -%type OptionalParityType -%type OptionalPredicate -%type OptionalQWordConstExpr -%type OptionalRangeType -%type OptionalReference -%type OptionalResourceType -%type OptionalResourceType_First -%type OptionalProducerResourceType -%type OptionalReturnArg -%type OptionalSerializeRuleKeyword -%type OptionalShareType -%type OptionalShareType_First -%type OptionalSlaveMode -%type OptionalStopBits -%type OptionalStringData -%type OptionalSyncLevel -%type OptionalTermArg -%type OptionalTranslationType_Last -%type OptionalType -%type OptionalType_Last -%type OptionalUpdateRuleKeyword -%type OptionalWireMode -%type OptionalWordConst -%type OptionalWordConstExpr -%type OptionalXferSize - -/* - * ASL+ (C-style) parser - */ - -/* Expressions and symbolic operators */ - -%type Expression -%type EqualsTerm -%type IndexExpTerm - -/* ASL+ Named object declaration support */ -/* -%type NameTermAslPlus - -%type BufferBegin -%type BufferEnd -%type PackageBegin -%type PackageEnd -%type OptionalLength -*/ -/* ASL+ Structure declarations */ -/* -%type StructureTerm -%type StructureTermBegin -%type StructureType -%type StructureTag -%type StructureElementList -%type StructureElement -%type StructureElementType -%type OptionalStructureElementType -%type StructureId -*/ -/* Structure instantiantion */ -/* -%type StructureInstanceTerm -%type StructureTagReference -%type StructureInstanceEnd -*/ -/* Pseudo-instantiantion for method Args/Locals */ -/* -%type MethodStructureTerm -%type LocalStructureName -*/ -/* Direct structure references via the Index operator */ -/* -%type StructureReference -%type StructureIndexTerm -%type StructurePointerTerm -%type StructurePointerReference -%type OptionalDefinePointer -*/ - -%% - -/* Production rules */ - - - -/******************************************************************************* - * - * ASL Root and Secondary Terms - * - ******************************************************************************/ - -/* - * Root term. Allow multiple #line directives before the definition block - * to handle output from preprocessors - */ -AslCode - : DefinitionBlockList {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_ASL_CODE),1, $1);} - | error {YYABORT; $$ = NULL;} - ; - - -/* - * Note concerning support for "module-level code". - * - * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control - * methods (the so-called module-level code.) This support was explicitly - * removed in ACPI 2.0, but this type of code continues to be created by - * BIOS vendors. In order to support the disassembly and recompilation of - * such code (and the porting of ASL code to iASL), iASL supports this - * code in violation of the current ACPI specification. - * - * The grammar change to support module-level code is to revert the - * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the - * original use of {TermList} instead (see below.) This allows the use - * of Type1 and Type2 opcodes at module level. - * - * 04/2016: The module-level code is now allowed in the following terms: - * DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm. - * The ObjectList term is obsolete and has been removed. - */ -DefinitionBlockTerm - : PARSEOP_DEFINITION_BLOCK - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DEFINITION_BLOCK); COMMENT_CAPTURE_OFF;} - String ',' - String ',' - ByteConst ',' - String ',' - String ',' - DWordConst - PARSEOP_CLOSE_PAREN {TrSetOpIntegerWidth ($6,$8); - TrSetOpEndLineNumber ($3); COMMENT_CAPTURE_ON;} - '{' TermList '}' {$$ = TrLinkOpChildren ($3,7, - $4,$6,$8,$10,$12,$14,$18);} - ; - -DefinitionBlockList - : DefinitionBlockTerm - | DefinitionBlockTerm - DefinitionBlockList {$$ = TrLinkPeerOps (2, $1,$2);} - ; - - -/******* Basic ASCII identifiers **************************************************/ - -/* Allow IO, DMA, IRQ Resource macro and FOR macro names to also be used as identifiers */ - -NameString - : NameSeg {} - | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) $1);} - | PARSEOP_IO {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} - | PARSEOP_DMA {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} - | PARSEOP_IRQ {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} - | PARSEOP_FOR {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "FOR");} - ; -/* -NameSeg - : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) - TrNormalizeNameSeg ($1));} - ; -*/ - -NameSeg - : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, - (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - - -/******* Fundamental argument/statement types ***********************************/ - -Term - : Object {} - | Type1Opcode {} - | Type2Opcode {} - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Type2BufferOpcode {} - | Type2BufferOrStringOpcode {} - | error {$$ = AslDoError(); yyclearin;} - ; - -SuperName - : SimpleName {} - | DebugTerm {} - | Type6Opcode {} - ; - -Target - : {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */ - | ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);} - ; - -RequiredTarget - : ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);} - ; - -TermArg - : SimpleName {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | Type2Opcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | DataObject {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | PARSEOP_OPEN_PAREN - TermArg - PARSEOP_CLOSE_PAREN {$$ = TrSetOpFlags ($2, OP_IS_TERM_ARG);} - ; - -/* - NOTE: Removed from TermArg due to reduce/reduce conflicts: - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - | Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);} - -*/ - -MethodInvocationTerm - : NameString - PARSEOP_OPEN_PAREN {TrSetOpIntegerValue (PARSEOP_METHODCALL, $1); COMMENT_CAPTURE_OFF;} - ArgList - PARSEOP_CLOSE_PAREN {$$ = TrLinkChildOp ($1,$4); COMMENT_CAPTURE_ON;} - ; - -/* OptionalCount must appear before ByteList or an incorrect reduction will result */ - -OptionalCount - : {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' TermArg {$$ = $2;} - ; - -/* - * Data count for buffers and packages (byte count for buffers, - * element count for packages). - */ -OptionalDataCount - - /* Legacy ASL */ - : {$$ = NULL;} - | PARSEOP_OPEN_PAREN - TermArg - PARSEOP_CLOSE_PAREN {$$ = $2;} - | PARSEOP_OPEN_PAREN - PARSEOP_CLOSE_PAREN {$$ = NULL;} - - /* C-style (ASL+) -- adds equals term */ - - | PARSEOP_EXP_EQUALS {$$ = NULL;} - - | PARSEOP_OPEN_PAREN - TermArg - PARSEOP_CLOSE_PAREN - PARSEOP_EXP_EQUALS {$$ = $2;} - - | PARSEOP_OPEN_PAREN - PARSEOP_CLOSE_PAREN - String - PARSEOP_EXP_EQUALS {$$ = NULL;} - ; - - -/******* List Terms **************************************************/ - - /* ACPI 3.0 -- allow semicolons between terms */ - -TermList - : {$$ = NULL;} - | TermList Term {$$ = TrLinkPeerOp ( - TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);} - | TermList Term ';' {$$ = TrLinkPeerOp ( - TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);} - | TermList ';' Term {$$ = TrLinkPeerOp ( - TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);} - | TermList ';' Term ';' {$$ = TrLinkPeerOp ( - TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);} - ; - -ArgList - : {$$ = NULL;} - | TermArg - | ArgList ',' /* Allows a trailing comma at list end */ - | ArgList ',' - TermArg {$$ = TrLinkPeerOp ($1,$3);} - ; - -ByteList - : {$$ = NULL;} - | ByteConstExpr - | ByteList ',' /* Allows a trailing comma at list end */ - | ByteList ',' - ByteConstExpr {$$ = TrLinkPeerOp ($1,$3);} - ; - -DWordList - : {$$ = NULL;} - | DWordConstExpr - | DWordList ',' /* Allows a trailing comma at list end */ - | DWordList ',' - DWordConstExpr {$$ = TrLinkPeerOp ($1,$3);} - ; - -FieldUnitList - : {$$ = NULL;} - | FieldUnit - | FieldUnitList ',' /* Allows a trailing comma at list end */ - | FieldUnitList ',' - FieldUnit {$$ = TrLinkPeerOp ($1,$3);} - ; - -FieldUnit - : FieldUnitEntry {} - | OffsetTerm {} - | AccessAsTerm {} - | ConnectionTerm {} - ; - -FieldUnitEntry - : ',' AmlPackageLengthTerm {$$ = TrCreateOp (PARSEOP_RESERVED_BYTES,1,$2);} - | NameSeg ',' - AmlPackageLengthTerm {$$ = TrLinkChildOp ($1,$3);} - ; - -Object - : CompilerDirective {} - | NamedObject {} - | NameSpaceModifier {} -/* | StructureTerm {} */ - ; - -PackageList - : {$$ = NULL;} - | PackageElement - | PackageList ',' /* Allows a trailing comma at list end */ - | PackageList ',' - PackageElement {$$ = TrLinkPeerOp ($1,$3);} - ; - -PackageElement - : DataObject {} - | NameString {} - ; - - /* Rules for specifying the type of one method argument or return value */ - -ParameterTypePackage - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | ParameterTypePackage ',' - ObjectTypeKeyword {$$ = TrLinkPeerOps (2,$1,$3);} - ; - -ParameterTypePackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypePackage '}' {$$ = $2;} - ; - -OptionalParameterTypePackage - : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypePackageList {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} - ; - - /* Rules for specifying the types for method arguments */ - -ParameterTypesPackage - : ParameterTypePackageList {$$ = $1;} - | ParameterTypesPackage ',' - ParameterTypePackageList {$$ = TrLinkPeerOps (2,$1,$3);} - ; - -ParameterTypesPackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypesPackage '}' {$$ = $2;} - ; - -OptionalParameterTypesPackage - : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackageList {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} - ; - -/* - * Case-Default list; allow only one Default term and unlimited Case terms - */ -CaseDefaultTermList - : {$$ = NULL;} - | CaseTerm {} - | DefaultTerm {} - | CaseDefaultTermList - CaseTerm {$$ = TrLinkPeerOp ($1,$2);} - | CaseDefaultTermList - DefaultTerm {$$ = TrLinkPeerOp ($1,$2);} - -/* Original - attempts to force zero or one default term within the switch */ - -/* -CaseDefaultTermList - : {$$ = NULL;} - | CaseTermList - DefaultTerm - CaseTermList {$$ = TrLinkPeerOp ($1,TrLinkPeerOp ($2, $3));} - | CaseTermList - CaseTerm {$$ = TrLinkPeerOp ($1,$2);} - ; - -CaseTermList - : {$$ = NULL;} - | CaseTerm {} - | CaseTermList - CaseTerm {$$ = TrLinkPeerOp ($1,$2);} - ; -*/ - - -/******************************************************************************* - * - * ASL Data and Constant Terms - * - ******************************************************************************/ - -DataObject - : BufferData {} - | PackageData {} - | IntegerData {} - | StringData {} - ; - -BufferData - : Type5Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | BufferTerm {} - ; - -PackageData - : PackageTerm {} - ; - -IntegerData - : Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | Integer {} - | ConstTerm {} - ; - -StringData - : Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | String {} - ; - -ByteConst - : Integer {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);} - ; - -WordConst - : Integer {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);} - ; - -DWordConst - : Integer {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);} - ; - -QWordConst - : Integer {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);} - ; - -/* - * The OP_COMPILE_TIME_CONST flag in the following constant expressions - * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes - * to simple integers. It is an error if these types of expressions cannot be - * reduced, since the AML grammar for ****ConstExpr requires a simple constant. - * Note: The required byte length of the constant is passed through to the - * constant folding code in the node AmlLength field. - */ -ByteConstExpr - : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 1);} - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 1);} - | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);} - | ByteConst {} - ; - -WordConstExpr - : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 2);} - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 2);} - | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);} - | WordConst {} - ; - -DWordConstExpr - : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 4);} - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 4);} - | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);} - | DWordConst {} - ; - -QWordConstExpr - : Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 8);} - | Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST); - TrSetOpAmlLength ($1, 8);} - | ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);} - | QWordConst {} - ; - -ConstTerm - : ConstExprTerm {} - | PARSEOP_REVISION {$$ = TrCreateLeafOp (PARSEOP_REVISION);} - ; - -ConstExprTerm - : PARSEOP_ZERO {$$ = TrCreateValuedLeafOp (PARSEOP_ZERO, 0);} - | PARSEOP_ONE {$$ = TrCreateValuedLeafOp (PARSEOP_ONE, 1);} - | PARSEOP_ONES {$$ = TrCreateValuedLeafOp (PARSEOP_ONES, ACPI_UINT64_MAX);} - | PARSEOP___DATE__ {$$ = TrCreateConstantLeafOp (PARSEOP___DATE__);} - | PARSEOP___FILE__ {$$ = TrCreateConstantLeafOp (PARSEOP___FILE__);} - | PARSEOP___LINE__ {$$ = TrCreateConstantLeafOp (PARSEOP___LINE__);} - | PARSEOP___PATH__ {$$ = TrCreateConstantLeafOp (PARSEOP___PATH__);} - | PARSEOP___METHOD__ {$$ = TrCreateConstantLeafOp (PARSEOP___METHOD__);} - ; - -Integer - : PARSEOP_INTEGER {$$ = TrCreateValuedLeafOp (PARSEOP_INTEGER, - AslCompilerlval.i);} - ; - -String - : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafOp (PARSEOP_STRING_LITERAL, - (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - - -/******************************************************************************* - * - * ASL Opcode Terms - * - ******************************************************************************/ - -CompilerDirective - : IncludeTerm {} - | IncludeEndTerm {} - | ExternalTerm {} - ; - -NamedObject - : BankFieldTerm {} - | CreateBitFieldTerm {} - | CreateByteFieldTerm {} - | CreateDWordFieldTerm {} - | CreateFieldTerm {} - | CreateQWordFieldTerm {} - | CreateWordFieldTerm {} - | DataRegionTerm {} - | DeviceTerm {} - | EventTerm {} - | FieldTerm {} - | FunctionTerm {} - | IndexFieldTerm {} - | MethodTerm {} - | MutexTerm {} - | OpRegionTerm {} - | PowerResTerm {} - | ProcessorTerm {} - | ThermalZoneTerm {} - ; - -NameSpaceModifier - : AliasTerm {} - | NameTerm {} -/* | NameTermAslPlus {} */ - | ScopeTerm {} - ; - -SimpleName - : NameString {} - | LocalTerm {} - | ArgTerm {} - ; - -/* For ObjectType(), SuperName except for MethodInvocationTerm */ - -ObjectTypeSource - : SimpleName {} - | DebugTerm {} - | RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - | IndexExpTerm {} - ; - -/* For DeRefOf(), SuperName except for DerefOf and Debug */ - -DerefOfSource - : SimpleName {} - | RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - | IndexExpTerm {} - | StoreTerm {} - | EqualsTerm {} - | MethodInvocationTerm {} - ; - -/* For RefOf(), SuperName except for RefOf and MethodInvocationTerm */ - -RefOfSource - : SimpleName {} - | DebugTerm {} - | DerefOfTerm {} - | IndexTerm {} - | IndexExpTerm {} - ; - -/* For CondRefOf(), SuperName except for RefOf and MethodInvocationTerm */ - -CondRefOfSource - : SimpleName {} - | DebugTerm {} - | DerefOfTerm {} - | IndexTerm {} - | IndexExpTerm {} - ; - -/* - * Opcode types, as defined in the ACPI specification - */ -Type1Opcode - : BreakTerm {} - | BreakPointTerm {} - | ContinueTerm {} - | FatalTerm {} - | ForTerm {} - | ElseIfTerm {} - | LoadTerm {} - | NoOpTerm {} - | NotifyTerm {} - | ReleaseTerm {} - | ResetTerm {} - | ReturnTerm {} - | SignalTerm {} - | SleepTerm {} - | StallTerm {} - | SwitchTerm {} - | UnloadTerm {} - | WhileTerm {} - ; - -Type2Opcode - : AcquireTerm {} - | CondRefOfTerm {} - | CopyObjectTerm {} - | DerefOfTerm {} - | ObjectTypeTerm {} - | RefOfTerm {} - | SizeOfTerm {} - | StoreTerm {} - | EqualsTerm {} - | TimerTerm {} - | WaitTerm {} - | MethodInvocationTerm {} - ; - -/* - * Type 3/4/5 opcodes - */ -Type2IntegerOpcode /* "Type3" opcodes */ - : Expression {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | AddTerm {} - | AndTerm {} - | DecTerm {} - | DivideTerm {} - | FindSetLeftBitTerm {} - | FindSetRightBitTerm {} - | FromBCDTerm {} - | IncTerm {} - | IndexTerm {} -/* | StructureIndexTerm {} */ -/* | StructurePointerTerm {} */ - | LAndTerm {} - | LEqualTerm {} - | LGreaterTerm {} - | LGreaterEqualTerm {} - | LLessTerm {} - | LLessEqualTerm {} - | LNotTerm {} - | LNotEqualTerm {} - | LoadTableTerm {} - | LOrTerm {} - | MatchTerm {} - | ModTerm {} - | MultiplyTerm {} - | NAndTerm {} - | NOrTerm {} - | NotTerm {} - | OrTerm {} - | ShiftLeftTerm {} - | ShiftRightTerm {} - | SubtractTerm {} - | ToBCDTerm {} - | ToIntegerTerm {} - | XOrTerm {} - ; - -Type2StringOpcode /* "Type4" Opcodes */ - : ToDecimalStringTerm {} - | ToHexStringTerm {} - | ToStringTerm {} - ; - -Type2BufferOpcode /* "Type5" Opcodes */ - : ToBufferTerm {} - | ConcatResTerm {} - ; - -Type2BufferOrStringOpcode - : ConcatTerm {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);} - | PrintfTerm {} - | FprintfTerm {} - | MidTerm {} - ; - -/* - * A type 3 opcode evaluates to an Integer and cannot have a destination operand - */ -Type3Opcode - : EISAIDTerm {} - ; - -/* Obsolete -Type4Opcode - : ConcatTerm {} - | ToDecimalStringTerm {} - | ToHexStringTerm {} - | MidTerm {} - | ToStringTerm {} - ; -*/ - -/* Type 5 opcodes are a subset of Type2 opcodes, and return a constant */ - -Type5Opcode - : ResourceTemplateTerm {} - | UnicodeTerm {} - | ToPLDTerm {} - | ToUUIDTerm {} - ; - -Type6Opcode - : RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - | IndexExpTerm {} -/* | StructureIndexTerm {} */ -/* | StructurePointerTerm {} */ - | MethodInvocationTerm {} - ; - - -/******************************************************************************* - * - * ASL Helper Terms - * - ******************************************************************************/ - -AmlPackageLengthTerm - : Integer {$$ = TrSetOpIntegerValue (PARSEOP_PACKAGE_LENGTH, - (ACPI_PARSE_OBJECT *) $1);} - ; - -NameStringItem - : ',' NameString {$$ = $2;} - | ',' error {$$ = AslDoError (); yyclearin;} - ; - -TermArgItem - : ',' TermArg {$$ = $2;} - | ',' error {$$ = AslDoError (); yyclearin;} - ; - -OptionalReference - : {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ - | ',' TermArg {$$ = $2;} - ; - -OptionalReturnArg - : {$$ = TrSetOpFlags (TrCreateLeafOp (PARSEOP_ZERO), - OP_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ - | TermArg {$$ = $1;} - ; - -OptionalSerializeRuleKeyword - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' SerializeRuleKeyword {$$ = $2;} - ; - -OptionalTermArg - : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} - | TermArg {$$ = $1;} - ; - -OptionalWordConst - : {$$ = NULL;} - | WordConst {$$ = $1;} - ; - - - - -/******************************************************************************* - * - * ASL Primary Terms - * - ******************************************************************************/ - -AccessAsTerm - : PARSEOP_ACCESSAS - PARSEOP_OPEN_PAREN - AccessTypeKeyword - OptionalAccessAttribTerm - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_ACCESSAS,2,$3,$4);} - | PARSEOP_ACCESSAS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -AcquireTerm - : PARSEOP_ACQUIRE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp(PARSEOP_ACQUIRE);} - SuperName - ',' WordConstExpr - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$6);} - | PARSEOP_ACQUIRE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -AddTerm - : PARSEOP_ADD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ADD);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_ADD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -AliasTerm - : PARSEOP_ALIAS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ALIAS);} - NameString - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4, - TrSetOpFlags ($5, OP_IS_NAME_DECLARATION));} - | PARSEOP_ALIAS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -AndTerm - : PARSEOP_AND - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_AND);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_AND - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ArgTerm - : PARSEOP_ARG0 {$$ = TrCreateLeafOp (PARSEOP_ARG0);} - | PARSEOP_ARG1 {$$ = TrCreateLeafOp (PARSEOP_ARG1);} - | PARSEOP_ARG2 {$$ = TrCreateLeafOp (PARSEOP_ARG2);} - | PARSEOP_ARG3 {$$ = TrCreateLeafOp (PARSEOP_ARG3);} - | PARSEOP_ARG4 {$$ = TrCreateLeafOp (PARSEOP_ARG4);} - | PARSEOP_ARG5 {$$ = TrCreateLeafOp (PARSEOP_ARG5);} - | PARSEOP_ARG6 {$$ = TrCreateLeafOp (PARSEOP_ARG6);} - ; - -BankFieldTerm - : PARSEOP_BANKFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_BANKFIELD);} - NameString - NameStringItem - TermArgItem - OptionalAccessTypeKeyword - OptionalLockRuleKeyword - OptionalUpdateRuleKeyword - PARSEOP_CLOSE_PAREN '{' - FieldUnitList '}' {$$ = TrLinkOpChildren ($3,7, - $4,$5,$6,$7,$8,$9,$12);} - | PARSEOP_BANKFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN - '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -BreakTerm - : PARSEOP_BREAK {$$ = TrCreateOp (PARSEOP_BREAK, 0);} - ; - -BreakPointTerm - : PARSEOP_BREAKPOINT {$$ = TrCreateOp (PARSEOP_BREAKPOINT, 0);} - ; - -BufferTerm - : PARSEOP_BUFFER {$$ = TrCreateLeafOp (PARSEOP_BUFFER); COMMENT_CAPTURE_OFF; } - OptionalDataCount - '{' BufferTermData '}' {$$ = TrLinkOpChildren ($2,2,$3,$5); COMMENT_CAPTURE_ON;} - ; - -BufferTermData - : ByteList {} - | StringData {} - ; - -CaseTerm - : PARSEOP_CASE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CASE);} - DataObject - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_CASE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ConcatTerm - : PARSEOP_CONCATENATE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CONCATENATE);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ConcatResTerm - : PARSEOP_CONCATENATERESTEMPLATE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp ( - PARSEOP_CONCATENATERESTEMPLATE);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_CONCATENATERESTEMPLATE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CondRefOfTerm - : PARSEOP_CONDREFOF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CONDREFOF);} - CondRefOfSource - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_CONDREFOF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ConnectionTerm - : PARSEOP_CONNECTION - PARSEOP_OPEN_PAREN - NameString - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_CONNECTION,1,$3);} - | PARSEOP_CONNECTION - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CONNECTION);} - ResourceMacroTerm - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3, 1, - TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_RESOURCETEMPLATE), 3, - TrCreateLeafOp (PARSEOP_DEFAULT_ARG), - TrCreateLeafOp (PARSEOP_DEFAULT_ARG), - $4));} - | PARSEOP_CONNECTION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ContinueTerm - : PARSEOP_CONTINUE {$$ = TrCreateOp (PARSEOP_CONTINUE, 0);} - ; - -CopyObjectTerm - : PARSEOP_COPYOBJECT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_COPYOBJECT);} - TermArg - ',' SimpleName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4, - TrSetOpFlags ($6, OP_IS_TARGET));} - | PARSEOP_COPYOBJECT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateBitFieldTerm - : PARSEOP_CREATEBITFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEBITFIELD);} - TermArg - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5, - TrSetOpFlags ($6, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBITFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateByteFieldTerm - : PARSEOP_CREATEBYTEFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEBYTEFIELD);} - TermArg - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5, - TrSetOpFlags ($6, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEBYTEFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateDWordFieldTerm - : PARSEOP_CREATEDWORDFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEDWORDFIELD);} - TermArg - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5, - TrSetOpFlags ($6, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEDWORDFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateFieldTerm - : PARSEOP_CREATEFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEFIELD);} - TermArg - TermArgItem - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4,$4,$5,$6, - TrSetOpFlags ($7, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateQWordFieldTerm - : PARSEOP_CREATEQWORDFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEQWORDFIELD);} - TermArg - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5, - TrSetOpFlags ($6, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEQWORDFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -CreateWordFieldTerm - : PARSEOP_CREATEWORDFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_CREATEWORDFIELD);} - TermArg - TermArgItem - NameStringItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5, - TrSetOpFlags ($6, OP_IS_NAME_DECLARATION));} - | PARSEOP_CREATEWORDFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DataRegionTerm - : PARSEOP_DATATABLEREGION - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DATATABLEREGION);} - NameString - TermArgItem - TermArgItem - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$5,$6,$7);} - | PARSEOP_DATATABLEREGION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DebugTerm - : PARSEOP_DEBUG {$$ = TrCreateLeafOp (PARSEOP_DEBUG);} - ; - -DecTerm - : PARSEOP_DECREMENT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DECREMENT);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_DECREMENT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DefaultTerm - : PARSEOP_DEFAULT '{' {$$ = TrCreateLeafOp (PARSEOP_DEFAULT);} - TermList '}' {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_DEFAULT '{' - error '}' {$$ = AslDoError(); yyclearin;} - ; - -DerefOfTerm - : PARSEOP_DEREFOF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DEREFOF);} - DerefOfSource - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_DEREFOF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DeviceTerm - : PARSEOP_DEVICE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DEVICE);} - NameString - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,2, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$7);} - | PARSEOP_DEVICE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DivideTerm - : PARSEOP_DIVIDE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DIVIDE);} - TermArg - TermArgItem - Target - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_DIVIDE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -EISAIDTerm - : PARSEOP_EISAID - PARSEOP_OPEN_PAREN - StringData - PARSEOP_CLOSE_PAREN {$$ = TrSetOpIntegerValue (PARSEOP_EISAID, $3);} - | PARSEOP_EISAID - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ElseIfTerm - : IfTerm ElseTerm {$$ = TrLinkPeerOp ($1,$2);} - ; - -ElseTerm - : {$$ = NULL;} - | PARSEOP_ELSE '{' - TermList {$$ = TrCreateLeafOp (PARSEOP_ELSE);} - '}' {$$ = TrLinkOpChildren ($4,1,$3);} - - | PARSEOP_ELSE '{' - error '}' {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSE - error {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSEIF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ELSE);} - TermArg {$$ = TrCreateLeafOp (PARSEOP_IF);} - PARSEOP_CLOSE_PAREN '{' - TermList '}' {TrLinkOpChildren ($5,2,$4,$8);} - ElseTerm {TrLinkPeerOp ($5,$11);} - {$$ = TrLinkOpChildren ($3,1,$5);} - - | PARSEOP_ELSEIF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - - | PARSEOP_ELSEIF - error {$$ = AslDoError(); yyclearin;} - ; - -EventTerm - : PARSEOP_EVENT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_EVENT);} - NameString - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION));} - | PARSEOP_EVENT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ExternalTerm - : PARSEOP_EXTERNAL - PARSEOP_OPEN_PAREN - NameString - OptionalObjectTypeKeyword - OptionalParameterTypePackage - OptionalParameterTypesPackage - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} - | PARSEOP_EXTERNAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FatalTerm - : PARSEOP_FATAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FATAL);} - ByteConstExpr - ',' DWordConstExpr - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$6,$7);} - | PARSEOP_FATAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FieldTerm - : PARSEOP_FIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FIELD);} - NameString - OptionalAccessTypeKeyword - OptionalLockRuleKeyword - OptionalUpdateRuleKeyword - PARSEOP_CLOSE_PAREN '{' - FieldUnitList '}' {$$ = TrLinkOpChildren ($3,5,$4,$5,$6,$7,$10);} - | PARSEOP_FIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN - '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -FindSetLeftBitTerm - : PARSEOP_FINDSETLEFTBIT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FINDSETLEFTBIT);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETLEFTBIT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FindSetRightBitTerm - : PARSEOP_FINDSETRIGHTBIT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FINDSETRIGHTBIT);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_FINDSETRIGHTBIT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - - /* Convert a For() loop to a While() loop */ -ForTerm - : PARSEOP_FOR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WHILE);} - OptionalTermArg ',' {} - OptionalPredicate ',' - OptionalTermArg {$$ = TrLinkPeerOp ($4,$3); - TrSetOpParent ($9,$3);} /* New parent is WHILE */ - PARSEOP_CLOSE_PAREN - '{' TermList '}' {$$ = TrLinkOpChildren ($3,2,$7,$13);} - {$$ = TrLinkPeerOp ($13,$9); - $$ = $10;} - ; - -OptionalPredicate - : {$$ = TrCreateValuedLeafOp (PARSEOP_INTEGER, 1);} - | TermArg {$$ = $1;} - ; - -FprintfTerm - : PARSEOP_FPRINTF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FPRINTF);} - TermArg ',' - StringData - PrintfArgList - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$6,$7);} - | PARSEOP_FPRINTF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FromBCDTerm - : PARSEOP_FROMBCD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FROMBCD);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_FROMBCD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FunctionTerm - : PARSEOP_FUNCTION - PARSEOP_OPEN_PAREN {COMMENT_CAPTURE_OFF; $$ = TrCreateLeafOp (PARSEOP_METHOD); } - NameString - OptionalParameterTypePackage - OptionalParameterTypesPackage - PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON; } - TermList '}' {$$ = TrLinkOpChildren ($3,7, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0), - TrCreateLeafOp (PARSEOP_SERIALIZERULE_NOTSERIAL), - TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0),$5,$6,$10);} - | PARSEOP_FUNCTION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IfTerm - : PARSEOP_IF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_IF);} - TermArg - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - - | PARSEOP_IF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IncludeTerm - : PARSEOP_INCLUDE - PARSEOP_OPEN_PAREN - String - PARSEOP_CLOSE_PAREN {$$ = TrSetOpIntegerValue (PARSEOP_INCLUDE, $3); - FlOpenIncludeFile ($3);} - ; - -IncludeEndTerm - : PARSEOP_INCLUDE_END {$$ = TrCreateLeafOp (PARSEOP_INCLUDE_END); - TrSetOpCurrentFilename ($$);} - ; - -IncTerm - : PARSEOP_INCREMENT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_INCREMENT);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_INCREMENT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IndexFieldTerm - : PARSEOP_INDEXFIELD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_INDEXFIELD);} - NameString - NameStringItem - OptionalAccessTypeKeyword - OptionalLockRuleKeyword - OptionalUpdateRuleKeyword - PARSEOP_CLOSE_PAREN '{' - FieldUnitList '}' {$$ = TrLinkOpChildren ($3,6,$4,$5,$6,$7,$8,$11);} - | PARSEOP_INDEXFIELD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN - '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -IndexTerm - : PARSEOP_INDEX - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_INDEX);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_INDEX - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LAndTerm - : PARSEOP_LAND - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LAND);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LAND - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LEqualTerm - : PARSEOP_LEQUAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LEQUAL);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LEQUAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LGreaterEqualTerm - : PARSEOP_LGREATEREQUAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LLESS);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_LNOT, 1, - TrLinkOpChildren ($3,2,$4,$5));} - | PARSEOP_LGREATEREQUAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LGreaterTerm - : PARSEOP_LGREATER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LGREATER);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LGREATER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LLessEqualTerm - : PARSEOP_LLESSEQUAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LGREATER);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_LNOT, 1, - TrLinkOpChildren ($3,2,$4,$5));} - | PARSEOP_LLESSEQUAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LLessTerm - : PARSEOP_LLESS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LLESS);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LLESS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LNotEqualTerm - : PARSEOP_LNOTEQUAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LEQUAL);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_LNOT, 1, - TrLinkOpChildren ($3,2,$4,$5));} - | PARSEOP_LNOTEQUAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LNotTerm - : PARSEOP_LNOT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LNOT);} - TermArg - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_LNOT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LoadTableTerm - : PARSEOP_LOADTABLE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LOADTABLE);} - TermArg - TermArgItem - TermArgItem - OptionalListString - OptionalListString - OptionalReference - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$5,$6,$7,$8,$9);} - | PARSEOP_LOADTABLE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LoadTerm - : PARSEOP_LOAD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LOAD);} - NameString - RequiredTarget - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LOAD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -LocalTerm - : PARSEOP_LOCAL0 {$$ = TrCreateLeafOp (PARSEOP_LOCAL0);} - | PARSEOP_LOCAL1 {$$ = TrCreateLeafOp (PARSEOP_LOCAL1);} - | PARSEOP_LOCAL2 {$$ = TrCreateLeafOp (PARSEOP_LOCAL2);} - | PARSEOP_LOCAL3 {$$ = TrCreateLeafOp (PARSEOP_LOCAL3);} - | PARSEOP_LOCAL4 {$$ = TrCreateLeafOp (PARSEOP_LOCAL4);} - | PARSEOP_LOCAL5 {$$ = TrCreateLeafOp (PARSEOP_LOCAL5);} - | PARSEOP_LOCAL6 {$$ = TrCreateLeafOp (PARSEOP_LOCAL6);} - | PARSEOP_LOCAL7 {$$ = TrCreateLeafOp (PARSEOP_LOCAL7);} - ; - -LOrTerm - : PARSEOP_LOR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_LOR);} - TermArg - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_LOR - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -MatchTerm - : PARSEOP_MATCH - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MATCH);} - TermArg - ',' MatchOpKeyword - TermArgItem - ',' MatchOpKeyword - TermArgItem - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$6,$7,$9,$10,$11);} - | PARSEOP_MATCH - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -MethodTerm - : PARSEOP_METHOD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_METHOD); COMMENT_CAPTURE_OFF;} - NameString - OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} - OptionalSerializeRuleKeyword - OptionalByteConstExpr - OptionalParameterTypePackage - OptionalParameterTypesPackage - PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON;} - TermList '}' {$$ = TrLinkOpChildren ($3,7, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - $5,$7,$8,$9,$10,$14);} - | PARSEOP_METHOD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -MidTerm - : PARSEOP_MID - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MID);} - TermArg - TermArgItem - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4,$4,$5,$6,$7);} - | PARSEOP_MID - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ModTerm - : PARSEOP_MOD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MOD);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_MOD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -MultiplyTerm - : PARSEOP_MULTIPLY - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MULTIPLY);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_MULTIPLY - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -MutexTerm - : PARSEOP_MUTEX - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MUTEX);} - NameString - OptionalSyncLevel - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$5);} - | PARSEOP_MUTEX - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -NameTerm - : PARSEOP_NAME - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_NAME);} - NameString - ',' DataObject - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$6);} - | PARSEOP_NAME - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -NAndTerm - : PARSEOP_NAND - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_NAND);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_NAND - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -NoOpTerm - : PARSEOP_NOOP {$$ = TrCreateOp (PARSEOP_NOOP, 0);} - ; - -NOrTerm - : PARSEOP_NOR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_NOR);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_NOR - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -NotifyTerm - : PARSEOP_NOTIFY - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_NOTIFY);} - SuperName - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_NOTIFY - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -NotTerm - : PARSEOP_NOT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_NOT);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_NOT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ObjectTypeTerm - : PARSEOP_OBJECTTYPE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE);} - ObjectTypeSource - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_OBJECTTYPE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -OffsetTerm - : PARSEOP_OFFSET - PARSEOP_OPEN_PAREN - AmlPackageLengthTerm - PARSEOP_CLOSE_PAREN {$$ = TrCreateOp (PARSEOP_OFFSET,1,$3);} - | PARSEOP_OFFSET - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -OpRegionTerm - : PARSEOP_OPERATIONREGION - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_OPERATIONREGION);} - NameString - ',' OpRegionSpaceIdTerm - TermArgItem - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - $6,$7,$8);} - | PARSEOP_OPERATIONREGION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -OpRegionSpaceIdTerm - : RegionSpaceKeyword {} - | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -OrTerm - : PARSEOP_OR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_OR);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_OR - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PackageTerm - : PARSEOP_PACKAGE {$$ = TrCreateLeafOp (PARSEOP_VAR_PACKAGE);} - OptionalDataCount - '{' PackageList '}' {$$ = TrLinkOpChildren ($2,2,$3,$5);} - -PowerResTerm - : PARSEOP_POWERRESOURCE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_POWERRESOURCE);} - NameString - ',' ByteConstExpr - ',' WordConstExpr - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,4, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - $6,$8,$11);} - | PARSEOP_POWERRESOURCE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PrintfTerm - : PARSEOP_PRINTF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PRINTF);} - StringData - PrintfArgList - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_PRINTF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PrintfArgList - : {$$ = NULL;} - | TermArg {$$ = $1;} - | PrintfArgList ',' - TermArg {$$ = TrLinkPeerOp ($1, $3);} - ; - -ProcessorTerm - : PARSEOP_PROCESSOR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PROCESSOR);} - NameString - ',' ByteConstExpr - OptionalDWordConstExpr - OptionalByteConstExpr - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,5, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - $6,$7,$8,$11);} - | PARSEOP_PROCESSOR - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -RawDataBufferTerm - : PARSEOP_DATABUFFER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DATABUFFER);} - OptionalWordConst - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_DATABUFFER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -/* - * In RefOf, the node isn't really a target, but we can't keep track of it after - * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) - */ -RefOfTerm - : PARSEOP_REFOF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_REFOF);} - RefOfSource - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1, - TrSetOpFlags ($4, OP_IS_TARGET));} - | PARSEOP_REFOF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ReleaseTerm - : PARSEOP_RELEASE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_RELEASE);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_RELEASE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ResetTerm - : PARSEOP_RESET - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_RESET);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_RESET - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ReturnTerm - : PARSEOP_RETURN - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_RETURN);} - OptionalReturnArg - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_RETURN {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_RETURN),1, - TrSetOpFlags (TrCreateLeafOp (PARSEOP_ZERO), - OP_IS_NULL_RETURN));} - | PARSEOP_RETURN - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ScopeTerm - : PARSEOP_SCOPE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SCOPE);} - NameString - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,2, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$7);} - | PARSEOP_SCOPE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ShiftLeftTerm - : PARSEOP_SHIFTLEFT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTLEFT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ShiftRightTerm - : PARSEOP_SHIFTRIGHT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_SHIFTRIGHT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SignalTerm - : PARSEOP_SIGNAL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SIGNAL);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_SIGNAL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SizeOfTerm - : PARSEOP_SIZEOF - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SIZEOF);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_SIZEOF - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SleepTerm - : PARSEOP_SLEEP - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SLEEP);} - TermArg - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_SLEEP - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -StallTerm - : PARSEOP_STALL - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_STALL);} - TermArg - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_STALL - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -StoreTerm - : PARSEOP_STORE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_STORE);} - TermArg - ',' SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4, - TrSetOpFlags ($6, OP_IS_TARGET));} - | PARSEOP_STORE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SubtractTerm - : PARSEOP_SUBTRACT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SUBTRACT);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_SUBTRACT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SwitchTerm - : PARSEOP_SWITCH - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SWITCH);} - TermArg - PARSEOP_CLOSE_PAREN '{' - CaseDefaultTermList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_SWITCH - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ThermalZoneTerm - : PARSEOP_THERMALZONE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_THERMALZONE);} - NameString - PARSEOP_CLOSE_PAREN '{' - TermList '}' {$$ = TrLinkOpChildren ($3,2, - TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),$7);} - | PARSEOP_THERMALZONE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -TimerTerm - : PARSEOP_TIMER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TIMER);} - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,0);} - | PARSEOP_TIMER {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_TIMER),0);} - | PARSEOP_TIMER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToBCDTerm - : PARSEOP_TOBCD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOBCD);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_TOBCD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToBufferTerm - : PARSEOP_TOBUFFER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOBUFFER);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_TOBUFFER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToDecimalStringTerm - : PARSEOP_TODECIMALSTRING - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TODECIMALSTRING);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_TODECIMALSTRING - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToHexStringTerm - : PARSEOP_TOHEXSTRING - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOHEXSTRING);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_TOHEXSTRING - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToIntegerTerm - : PARSEOP_TOINTEGER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOINTEGER);} - TermArg - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_TOINTEGER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToPLDTerm - : PARSEOP_TOPLD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOPLD);} - PldKeywordList - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_TOPLD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PldKeywordList - : {$$ = NULL;} - | PldKeyword - PARSEOP_EXP_EQUALS Integer {$$ = TrLinkOpChildren ($1,1,$3);} - | PldKeyword - PARSEOP_EXP_EQUALS String {$$ = TrLinkOpChildren ($1,1,$3);} - | PldKeywordList ',' /* Allows a trailing comma at list end */ - | PldKeywordList ',' - PldKeyword - PARSEOP_EXP_EQUALS Integer {$$ = TrLinkPeerOp ($1,TrLinkOpChildren ($3,1,$5));} - | PldKeywordList ',' - PldKeyword - PARSEOP_EXP_EQUALS String {$$ = TrLinkPeerOp ($1,TrLinkOpChildren ($3,1,$5));} - ; - - -ToStringTerm - : PARSEOP_TOSTRING - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_TOSTRING);} - TermArg - OptionalCount - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_TOSTRING - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ToUUIDTerm - : PARSEOP_TOUUID - PARSEOP_OPEN_PAREN - StringData - PARSEOP_CLOSE_PAREN {$$ = TrSetOpIntegerValue (PARSEOP_TOUUID, $3);} - | PARSEOP_TOUUID - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -UnicodeTerm - : PARSEOP_UNICODE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_UNICODE);} - StringData - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,0,$4);} - | PARSEOP_UNICODE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -UnloadTerm - : PARSEOP_UNLOAD - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_UNLOAD);} - SuperName - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_UNLOAD - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -WaitTerm - : PARSEOP_WAIT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WAIT);} - SuperName - TermArgItem - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,2,$4,$5);} - | PARSEOP_WAIT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -XOrTerm - : PARSEOP_XOR - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_XOR);} - TermArg - TermArgItem - Target - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$5,$6);} - | PARSEOP_XOR - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -WhileTerm - : PARSEOP_WHILE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WHILE);} - TermArg - PARSEOP_CLOSE_PAREN - '{' TermList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_WHILE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - - - -/******************************************************************************* - * - * Production rules for the symbolic (c-style) operators - * - ******************************************************************************/ - -/* - * ASL Extensions: C-style math/logical operators and expressions. - * The implementation transforms these operators into the standard - * AML opcodes and syntax. - * - * Supported operators and precedence rules (high-to-low) - * - * NOTE: The operator precedence and associativity rules are - * implemented by the tokens in asltokens.y - * - * (left-to-right): - * 1) ( ) expr++ expr-- - * - * (right-to-left): - * 2) ! ~ - * - * (left-to-right): - * 3) * / % - * 4) + - - * 5) >> << - * 6) < > <= >= - * 7) == != - * 8) & - * 9) ^ - * 10) | - * 11) && - * 12) || - * - * (right-to-left): - * 13) = += -= *= /= %= <<= >>= &= ^= |= - */ - - -/******************************************************************************* - * - * Basic operations for math and logical expressions. - * - ******************************************************************************/ - -Expression - - /* Unary operators */ - - : PARSEOP_EXP_LOGICAL_NOT {$$ = TrCreateLeafOp (PARSEOP_LNOT);} - TermArg {$$ = TrLinkOpChildren ($2,1,$3);} - | PARSEOP_EXP_NOT {$$ = TrCreateLeafOp (PARSEOP_NOT);} - TermArg {$$ = TrLinkOpChildren ($2,2,$3,TrCreateNullTargetOp ());} - - | SuperName PARSEOP_EXP_INCREMENT {$$ = TrCreateLeafOp (PARSEOP_INCREMENT);} - {$$ = TrLinkOpChildren ($3,1,$1);} - | SuperName PARSEOP_EXP_DECREMENT {$$ = TrCreateLeafOp (PARSEOP_DECREMENT);} - {$$ = TrLinkOpChildren ($3,1,$1);} - - /* Binary operators: math and logical */ - - | TermArg PARSEOP_EXP_ADD {$$ = TrCreateLeafOp (PARSEOP_ADD);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_DIVIDE {$$ = TrCreateLeafOp (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkOpChildren ($3,4,$1,$4,TrCreateNullTargetOp (), - TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_MODULO {$$ = TrCreateLeafOp (PARSEOP_MOD);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_MULTIPLY {$$ = TrCreateLeafOp (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_SHIFT_LEFT {$$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_SHIFT_RIGHT {$$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_SUBTRACT {$$ = TrCreateLeafOp (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - - | TermArg PARSEOP_EXP_AND {$$ = TrCreateLeafOp (PARSEOP_AND);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_OR {$$ = TrCreateLeafOp (PARSEOP_OR);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - | TermArg PARSEOP_EXP_XOR {$$ = TrCreateLeafOp (PARSEOP_XOR);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4,TrCreateNullTargetOp ());} - - | TermArg PARSEOP_EXP_GREATER {$$ = TrCreateLeafOp (PARSEOP_LGREATER);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - | TermArg PARSEOP_EXP_GREATER_EQUAL {$$ = TrCreateLeafOp (PARSEOP_LGREATEREQUAL);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - | TermArg PARSEOP_EXP_LESS {$$ = TrCreateLeafOp (PARSEOP_LLESS);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - | TermArg PARSEOP_EXP_LESS_EQUAL {$$ = TrCreateLeafOp (PARSEOP_LLESSEQUAL);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - - | TermArg PARSEOP_EXP_EQUAL {$$ = TrCreateLeafOp (PARSEOP_LEQUAL);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - | TermArg PARSEOP_EXP_NOT_EQUAL {$$ = TrCreateLeafOp (PARSEOP_LNOTEQUAL);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - - | TermArg PARSEOP_EXP_LOGICAL_AND {$$ = TrCreateLeafOp (PARSEOP_LAND);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - | TermArg PARSEOP_EXP_LOGICAL_OR {$$ = TrCreateLeafOp (PARSEOP_LOR);} - TermArg {$$ = TrLinkOpChildren ($3,2,$1,$4);} - - /* Parentheses */ - - | PARSEOP_OPEN_PAREN - Expression - PARSEOP_CLOSE_PAREN {$$ = $2;} - - /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ - - | IndexExpTerm - ; - - /* - * Index term -- "BUF1[5] = " or " = BUF1[5] on either the left side - * of an equals (target) or the right side (source) - * Currently used in these terms: - * Expression - * ObjectTypeSource - * DerefOfSource - * Type6Opcode - */ -IndexExpTerm - - : SuperName - PARSEOP_EXP_INDEX_LEFT - TermArg - PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafOp (PARSEOP_INDEX); - TrLinkOpChildren ($$,3,$1,$3,TrCreateNullTargetOp ());} - ; - - -/******************************************************************************* - * - * All assignment-type operations -- math and logical. Includes simple - * assignment and compound assignments. - * - ******************************************************************************/ - -EqualsTerm - - /* Allow parens anywhere */ - - : PARSEOP_OPEN_PAREN - EqualsTerm - PARSEOP_CLOSE_PAREN {$$ = $2;} - - /* Simple Store() operation */ - - | SuperName - PARSEOP_EXP_EQUALS - TermArg {$$ = TrCreateAssignmentOp ($1, $3);} - - /* Chained equals: (a=RefOf)=b, a=b=c=d etc. */ - - | PARSEOP_OPEN_PAREN - EqualsTerm - PARSEOP_CLOSE_PAREN - PARSEOP_EXP_EQUALS - TermArg {$$ = TrCreateAssignmentOp ($2, $5);} - - /* Compound assignments -- Add (operand, operand, target) */ - - | TermArg PARSEOP_EXP_ADD_EQ {$$ = TrCreateLeafOp (PARSEOP_ADD);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_DIV_EQ {$$ = TrCreateLeafOp (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkOpChildren ($3,4,$1,$4,TrCreateNullTargetOp (), - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_MOD_EQ {$$ = TrCreateLeafOp (PARSEOP_MOD);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_MUL_EQ {$$ = TrCreateLeafOp (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_SHL_EQ {$$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_SHR_EQ {$$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_SUB_EQ {$$ = TrCreateLeafOp (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_AND_EQ {$$ = TrCreateLeafOp (PARSEOP_AND);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_OR_EQ {$$ = TrCreateLeafOp (PARSEOP_OR);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - - | TermArg PARSEOP_EXP_XOR_EQ {$$ = TrCreateLeafOp (PARSEOP_XOR);} - TermArg {$$ = TrLinkOpChildren ($3,3,$1,$4, - TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));} - ; - - - -/******************************************************************************* - * - * ASL Parameter Keyword Terms - * - ******************************************************************************/ - -AccessAttribKeyword - : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BLOCK);} - | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} - | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BYTE);} - | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_QUICK );} - | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_SND_RCV);} - | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_WORD);} - | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_WORD_CALL);} - | PARSEOP_ACCESSATTRIB_BYTES - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BYTES);} - ByteConst - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_BYTES - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_RAW_BYTES);} - ByteConst - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_PROCESS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} - ByteConst - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,1,$4);} - ; - -AccessTypeKeyword - : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_ANY);} - | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_BYTE);} - | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_WORD);} - | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_DWORD);} - | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_QWORD);} - | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_BUF);} - ; - -AddressingModeKeyword - : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafOp (PARSEOP_ADDRESSINGMODE_7BIT);} - | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafOp (PARSEOP_ADDRESSINGMODE_10BIT);} - ; - -AddressKeyword - : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_MEMORY);} - | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_RESERVED);} - | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_NVS);} - | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_ACPI);} - ; - -AddressSpaceKeyword - : ByteConst {$$ = UtCheckIntegerRange ($1, ACPI_NUM_PREDEFINED_REGIONS, 0xFF);} - | RegionSpaceKeyword {} - ; - -BitsPerByteKeyword - : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_FIVE);} - | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_SIX);} - | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_SEVEN);} - | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_EIGHT);} - | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_NINE);} - ; - -ClockPhaseKeyword - : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafOp (PARSEOP_CLOCKPHASE_FIRST);} - | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafOp (PARSEOP_CLOCKPHASE_SECOND);} - ; - -ClockPolarityKeyword - : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafOp (PARSEOP_CLOCKPOLARITY_LOW);} - | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafOp (PARSEOP_CLOCKPOLARITY_HIGH);} - ; - -DecodeKeyword - : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafOp (PARSEOP_DECODETYPE_POS);} - | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafOp (PARSEOP_DECODETYPE_SUB);} - ; - -DevicePolarityKeyword - : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafOp (PARSEOP_DEVICEPOLARITY_LOW);} - | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafOp (PARSEOP_DEVICEPOLARITY_HIGH);} - ; - -DMATypeKeyword - : PARSEOP_DMATYPE_A {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_A);} - | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_COMPATIBILITY);} - | PARSEOP_DMATYPE_B {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_B);} - | PARSEOP_DMATYPE_F {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_F);} - ; - -EndianKeyword - : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafOp (PARSEOP_ENDIAN_LITTLE);} - | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafOp (PARSEOP_ENDIAN_BIG);} - ; - -FlowControlKeyword - : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_HW);} - | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_NONE);} - | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_SW);} - ; - -InterruptLevel - : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVEBOTH);} - | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVEHIGH);} - | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVELOW);} - ; - -InterruptTypeKeyword - : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafOp (PARSEOP_INTTYPE_EDGE);} - | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafOp (PARSEOP_INTTYPE_LEVEL);} - ; - -IODecodeKeyword - : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafOp (PARSEOP_IODECODETYPE_16);} - | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafOp (PARSEOP_IODECODETYPE_10);} - ; - -IoRestrictionKeyword - : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_IN);} - | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_OUT);} - | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_NONE);} - | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_PRESERVE);} - ; - -LockRuleKeyword - : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafOp (PARSEOP_LOCKRULE_LOCK);} - | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafOp (PARSEOP_LOCKRULE_NOLOCK);} - ; - -MatchOpKeyword - : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MTR);} - | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MEQ);} - | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MLE);} - | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MLT);} - | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MGE);} - | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MGT);} - ; - -MaxKeyword - : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafOp (PARSEOP_MAXTYPE_FIXED);} - | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafOp (PARSEOP_MAXTYPE_NOTFIXED);} - ; - -MemTypeKeyword - : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_CACHEABLE);} - | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_WRITECOMBINING);} - | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_PREFETCHABLE);} - | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_NONCACHEABLE);} - ; - -MinKeyword - : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafOp (PARSEOP_MINTYPE_FIXED);} - | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafOp (PARSEOP_MINTYPE_NOTFIXED);} - ; - -ObjectTypeKeyword - : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_UNK);} - | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_INT);} - | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_STR);} - | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_BUF);} - | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_PKG);} - | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_FLD);} - | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_DEV);} - | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_EVT);} - | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_MTH);} - | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_MTX);} - | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_OPR);} - | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_POW);} - | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_PRO);} - | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_THZ);} - | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_BFF);} - | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_DDB);} - ; - -ParityTypeKeyword - : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_SPACE);} - | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_MARK);} - | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_ODD);} - | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_EVEN);} - | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_NONE);} - ; - -PinConfigByte - : PinConfigKeyword {$$ = $1;} - | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PinConfigKeyword - : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafOp (PARSEOP_PIN_NOPULL);} - | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLDOWN);} - | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLUP);} - | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLDEFAULT);} - ; - -PldKeyword - : PARSEOP_PLD_REVISION {$$ = TrCreateLeafOp (PARSEOP_PLD_REVISION);} - | PARSEOP_PLD_IGNORECOLOR {$$ = TrCreateLeafOp (PARSEOP_PLD_IGNORECOLOR);} - | PARSEOP_PLD_RED {$$ = TrCreateLeafOp (PARSEOP_PLD_RED);} - | PARSEOP_PLD_GREEN {$$ = TrCreateLeafOp (PARSEOP_PLD_GREEN);} - | PARSEOP_PLD_BLUE {$$ = TrCreateLeafOp (PARSEOP_PLD_BLUE);} - | PARSEOP_PLD_WIDTH {$$ = TrCreateLeafOp (PARSEOP_PLD_WIDTH);} - | PARSEOP_PLD_HEIGHT {$$ = TrCreateLeafOp (PARSEOP_PLD_HEIGHT);} - | PARSEOP_PLD_USERVISIBLE {$$ = TrCreateLeafOp (PARSEOP_PLD_USERVISIBLE);} - | PARSEOP_PLD_DOCK {$$ = TrCreateLeafOp (PARSEOP_PLD_DOCK);} - | PARSEOP_PLD_LID {$$ = TrCreateLeafOp (PARSEOP_PLD_LID);} - | PARSEOP_PLD_PANEL {$$ = TrCreateLeafOp (PARSEOP_PLD_PANEL);} - | PARSEOP_PLD_VERTICALPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_VERTICALPOSITION);} - | PARSEOP_PLD_HORIZONTALPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_HORIZONTALPOSITION);} - | PARSEOP_PLD_SHAPE {$$ = TrCreateLeafOp (PARSEOP_PLD_SHAPE);} - | PARSEOP_PLD_GROUPORIENTATION {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPORIENTATION);} - | PARSEOP_PLD_GROUPTOKEN {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPTOKEN);} - | PARSEOP_PLD_GROUPPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPPOSITION);} - | PARSEOP_PLD_BAY {$$ = TrCreateLeafOp (PARSEOP_PLD_BAY);} - | PARSEOP_PLD_EJECTABLE {$$ = TrCreateLeafOp (PARSEOP_PLD_EJECTABLE);} - | PARSEOP_PLD_EJECTREQUIRED {$$ = TrCreateLeafOp (PARSEOP_PLD_EJECTREQUIRED);} - | PARSEOP_PLD_CABINETNUMBER {$$ = TrCreateLeafOp (PARSEOP_PLD_CABINETNUMBER);} - | PARSEOP_PLD_CARDCAGENUMBER {$$ = TrCreateLeafOp (PARSEOP_PLD_CARDCAGENUMBER);} - | PARSEOP_PLD_REFERENCE {$$ = TrCreateLeafOp (PARSEOP_PLD_REFERENCE);} - | PARSEOP_PLD_ROTATION {$$ = TrCreateLeafOp (PARSEOP_PLD_ROTATION);} - | PARSEOP_PLD_ORDER {$$ = TrCreateLeafOp (PARSEOP_PLD_ORDER);} - | PARSEOP_PLD_RESERVED {$$ = TrCreateLeafOp (PARSEOP_PLD_RESERVED);} - | PARSEOP_PLD_VERTICALOFFSET {$$ = TrCreateLeafOp (PARSEOP_PLD_VERTICALOFFSET);} - | PARSEOP_PLD_HORIZONTALOFFSET {$$ = TrCreateLeafOp (PARSEOP_PLD_HORIZONTALOFFSET);} - ; - -RangeTypeKeyword - : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_ISAONLY);} - | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_NONISAONLY);} - | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_ENTIRE);} - ; - -RegionSpaceKeyword - : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_IO);} - | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_MEM);} - | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCI);} - | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_EC);} - | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_SMBUS);} - | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_CMOS);} - | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCIBAR);} - | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_IPMI);} - | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_GPIO);} - | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_GSBUS);} - | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCC);} - | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_FFIXEDHW);} - ; - -ResourceTypeKeyword - : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafOp (PARSEOP_RESOURCETYPE_CONSUMER);} - | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafOp (PARSEOP_RESOURCETYPE_PRODUCER);} - ; - -SerializeRuleKeyword - : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafOp (PARSEOP_SERIALIZERULE_SERIAL);} - | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafOp (PARSEOP_SERIALIZERULE_NOTSERIAL);} - ; - -ShareTypeKeyword - : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_SHARED);} - | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_EXCLUSIVE);} - | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_SHAREDWAKE);} - | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} - ; - -SlaveModeKeyword - : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafOp (PARSEOP_SLAVEMODE_CONTROLLERINIT);} - | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafOp (PARSEOP_SLAVEMODE_DEVICEINIT);} - ; - -StopBitsKeyword - : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_TWO);} - | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ONEPLUSHALF);} - | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ONE);} - | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ZERO);} - ; - -TranslationKeyword - : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafOp (PARSEOP_TRANSLATIONTYPE_SPARSE);} - | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafOp (PARSEOP_TRANSLATIONTYPE_DENSE);} - ; - -TypeKeyword - : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafOp (PARSEOP_TYPE_TRANSLATION);} - | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafOp (PARSEOP_TYPE_STATIC);} - ; - -UpdateRuleKeyword - : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_PRESERVE);} - | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_ONES);} - | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_ZEROS);} - ; - -WireModeKeyword - : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafOp (PARSEOP_WIREMODE_FOUR);} - | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafOp (PARSEOP_WIREMODE_THREE);} - ; - -XferSizeKeyword - : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_8, 0);} - | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_16, 1);} - | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_32, 2);} - | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_64, 3);} - | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_128, 4);} - | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_256, 5);} - ; - -XferTypeKeyword - : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_8);} - | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_8_16);} - | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_16);} - ; - - - - -/******************************************************************************* - * - * ASL Resource Template Terms - * - ******************************************************************************/ - -/* - * Note: Create two default nodes to allow conversion to a Buffer AML opcode - * Also, insert the EndTag at the end of the template. - */ -ResourceTemplateTerm - : PARSEOP_RESOURCETEMPLATE {COMMENT_CAPTURE_OFF;} - OptionalParentheses - '{' - ResourceMacroList '}' {$$ = TrCreateOp (PARSEOP_RESOURCETEMPLATE,4, - TrCreateLeafOp (PARSEOP_DEFAULT_ARG), - TrCreateLeafOp (PARSEOP_DEFAULT_ARG), - $5, - TrCreateLeafOp (PARSEOP_ENDTAG)); - COMMENT_CAPTURE_ON;} - ; - -OptionalParentheses - : {$$ = NULL;} - | PARSEOP_OPEN_PAREN - PARSEOP_CLOSE_PAREN {$$ = NULL;} - ; - -ResourceMacroList - : {$$ = NULL;} - | ResourceMacroList - ResourceMacroTerm {$$ = TrLinkPeerOp ($1,$2);} - ; - -ResourceMacroTerm - : DMATerm {} - | DWordIOTerm {} - | DWordMemoryTerm {} - | DWordSpaceTerm {} - | EndDependentFnTerm {} - | ExtendedIOTerm {} - | ExtendedMemoryTerm {} - | ExtendedSpaceTerm {} - | FixedDmaTerm {} - | FixedIOTerm {} - | GpioIntTerm {} - | GpioIoTerm {} - | I2cSerialBusTerm {} - | I2cSerialBusTermV2 {} - | InterruptTerm {} - | IOTerm {} - | IRQNoFlagsTerm {} - | IRQTerm {} - | Memory24Term {} - | Memory32FixedTerm {} - | Memory32Term {} - | PinConfigTerm {} - | PinFunctionTerm {} - | PinGroupTerm {} - | PinGroupConfigTerm {} - | PinGroupFunctionTerm {} - | QWordIOTerm {} - | QWordMemoryTerm {} - | QWordSpaceTerm {} - | RegisterTerm {} - | SpiSerialBusTerm {} - | SpiSerialBusTermV2 {} - | StartDependentFnNoPriTerm {} - | StartDependentFnTerm {} - | UartSerialBusTerm {} - | UartSerialBusTermV2 {} - | VendorLongTerm {} - | VendorShortTerm {} - | WordBusNumberTerm {} - | WordIOTerm {} - | WordSpaceTerm {} - ; - -DMATerm - : PARSEOP_DMA - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DMA);} - DMATypeKeyword - OptionalBusMasterKeyword - ',' XferTypeKeyword - OptionalNameString_Last - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,5,$4,$5,$7,$8,$11);} - | PARSEOP_DMA - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DWordIOTerm - : PARSEOP_DWORDIO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_DWORDIO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DWordMemoryTerm - : PARSEOP_DWORDMEMORY - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,16, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_DWORDMEMORY - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -DWordSpaceTerm - : PARSEOP_DWORDSPACE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_DWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_DWORDSPACE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -EndDependentFnTerm - : PARSEOP_ENDDEPENDENTFN - PARSEOP_OPEN_PAREN - PARSEOP_CLOSE_PAREN {$$ = TrCreateLeafOp (PARSEOP_ENDDEPENDENTFN);} - | PARSEOP_ENDDEPENDENTFN - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ExtendedIOTerm - : PARSEOP_EXTENDEDIO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_EXTENDEDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalType - OptionalTranslationType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} - | PARSEOP_EXTENDEDIO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ExtendedMemoryTerm - : PARSEOP_EXTENDEDMEMORY - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_EXTENDEDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalAddressRange - OptionalType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} - | PARSEOP_EXTENDEDMEMORY - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -ExtendedSpaceTerm - : PARSEOP_EXTENDEDSPACE PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_EXTENDEDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,13, - $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} - | PARSEOP_EXTENDEDSPACE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FixedDmaTerm - : PARSEOP_FIXEDDMA - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FIXEDDMA);} - WordConstExpr /* 04: DMA RequestLines */ - ',' WordConstExpr /* 06: DMA Channels */ - OptionalXferSize /* 07: DMA TransferSize */ - OptionalNameString /* 08: DescriptorName */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4,$4,$6,$7,$8);} - | PARSEOP_FIXEDDMA - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -FixedIOTerm - : PARSEOP_FIXEDIO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_FIXEDIO);} - WordConstExpr - ',' ByteConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,3,$4,$6,$7);} - | PARSEOP_FIXEDIO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -GpioIntTerm - : PARSEOP_GPIO_INT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_GPIO_INT);} - InterruptTypeKeyword /* 04: InterruptType */ - ',' InterruptLevel /* 06: InterruptLevel */ - OptionalShareType /* 07: SharedType */ - ',' PinConfigByte /* 09: PinConfig */ - OptionalWordConstExpr /* 10: DebounceTimeout */ - ',' StringData /* 12: ResourceSource */ - OptionalByteConstExpr /* 13: ResourceSourceIndex */ - OptionalResourceType /* 14: ResourceType */ - OptionalNameString /* 15: DescriptorName */ - OptionalBuffer_Last /* 16: VendorData */ - PARSEOP_CLOSE_PAREN '{' - DWordConstExpr '}' {$$ = TrLinkOpChildren ($3,11, - $4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} - | PARSEOP_GPIO_INT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -GpioIoTerm - : PARSEOP_GPIO_IO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_GPIO_IO);} - OptionalShareType_First /* 04: SharedType */ - ',' PinConfigByte /* 06: PinConfig */ - OptionalWordConstExpr /* 07: DebounceTimeout */ - OptionalWordConstExpr /* 08: DriveStrength */ - OptionalIoRestriction /* 09: IoRestriction */ - ',' StringData /* 11: ResourceSource */ - OptionalByteConstExpr /* 12: ResourceSourceIndex */ - OptionalResourceType /* 13: ResourceType */ - OptionalNameString /* 14: DescriptorName */ - OptionalBuffer_Last /* 15: VendorData */ - PARSEOP_CLOSE_PAREN '{' - DWordList '}' {$$ = TrLinkOpChildren ($3,11, - $4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} - | PARSEOP_GPIO_IO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -I2cSerialBusTerm - : PARSEOP_I2C_SERIALBUS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_I2C_SERIALBUS);} - WordConstExpr /* 04: SlaveAddress */ - OptionalSlaveMode /* 05: SlaveMode */ - ',' DWordConstExpr /* 07: ConnectionSpeed */ - OptionalAddressingMode /* 08: AddressingMode */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,10, - $4,$5,$7,$8,$10,$11,$12,$13, - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),$14);} - | PARSEOP_I2C_SERIALBUS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -I2cSerialBusTermV2 - : PARSEOP_I2C_SERIALBUS_V2 - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_I2C_SERIALBUS_V2);} - WordConstExpr /* 04: SlaveAddress */ - OptionalSlaveMode /* 05: SlaveMode */ - ',' DWordConstExpr /* 07: ConnectionSpeed */ - OptionalAddressingMode /* 08: AddressingMode */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalShareType /* 14: Share */ - OptionalBuffer_Last /* 15: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,10, - $4,$5,$7,$8,$10,$11,$12,$13,$14,$15);} - | PARSEOP_I2C_SERIALBUS_V2 - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -InterruptTerm - : PARSEOP_INTERRUPT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_INTERRUPT);} - OptionalResourceType_First - ',' InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - PARSEOP_CLOSE_PAREN '{' - DWordList '}' {$$ = TrLinkOpChildren ($3,8, - $4,$6,$8,$9,$10,$11,$12,$15);} - | PARSEOP_INTERRUPT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IOTerm - : PARSEOP_IO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_IO);} - IODecodeKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' ByteConstExpr - ',' ByteConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_IO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IRQNoFlagsTerm - : PARSEOP_IRQNOFLAGS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_IRQNOFLAGS);} - OptionalNameString_First - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_IRQNOFLAGS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -IRQTerm - : PARSEOP_IRQ - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_IRQ);} - InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalNameString_Last - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,5,$4,$6,$7,$8,$11);} - | PARSEOP_IRQ - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -Memory24Term - : PARSEOP_MEMORY24 - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MEMORY24);} - OptionalReadWriteKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY24 - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -Memory32FixedTerm - : PARSEOP_MEMORY32FIXED - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MEMORY32FIXED);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,4,$4,$6,$8,$9);} - | PARSEOP_MEMORY32FIXED - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -Memory32Term - : PARSEOP_MEMORY32 - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_MEMORY32);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY32 - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PinConfigTerm - : PARSEOP_PINCONFIG - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PINCONFIG);} - OptionalShareType_First /* 04: SharedType */ - ',' ByteConstExpr /* 06: PinConfigType */ - ',' DWordConstExpr /* 08: PinConfigValue */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - PARSEOP_CLOSE_PAREN '{' - DWordList '}' {$$ = TrLinkOpChildren ($3,9, - $4,$6,$8,$10,$11,$12,$13,$14,$17);} - | PARSEOP_PINCONFIG - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PinFunctionTerm - : PARSEOP_PINFUNCTION - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PINFUNCTION);} - OptionalShareType_First /* 04: SharedType */ - ',' PinConfigByte /* 06: PinConfig */ - ',' WordConstExpr /* 08: FunctionNumber */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - PARSEOP_CLOSE_PAREN '{' - DWordList '}' {$$ = TrLinkOpChildren ($3,9, - $4,$6,$8,$10,$11,$12,$13,$14,$17);} - | PARSEOP_PINFUNCTION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PinGroupTerm - : PARSEOP_PINGROUP - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PINGROUP);} - StringData /* 04: ResourceLabel */ - OptionalProducerResourceType /* 05: ResourceType */ - OptionalNameString /* 06: DescriptorName */ - OptionalBuffer_Last /* 07: VendorData */ - PARSEOP_CLOSE_PAREN '{' - DWordList '}' {$$ = TrLinkOpChildren ($3,5,$4,$5,$6,$7,$10);} - | PARSEOP_PINGROUP - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PinGroupConfigTerm - : PARSEOP_PINGROUPCONFIG - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PINGROUPCONFIG);} - OptionalShareType_First /* 04: SharedType */ - ',' ByteConstExpr /* 06: PinConfigType */ - ',' DWordConstExpr /* 08: PinConfigValue */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - ',' StringData /* 13: ResourceSourceLabel */ - OptionalResourceType /* 14: ResourceType */ - OptionalNameString /* 15: DescriptorName */ - OptionalBuffer_Last /* 16: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,9, - $4,$6,$8,$10,$11,$13,$14,$15,$16);} - | PARSEOP_PINGROUPCONFIG - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -PinGroupFunctionTerm - : PARSEOP_PINGROUPFUNCTION - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_PINGROUPFUNCTION);} - OptionalShareType_First /* 04: SharedType */ - ',' WordConstExpr /* 06: FunctionNumber */ - ',' StringData /* 08: ResourceSource */ - OptionalByteConstExpr /* 09: ResourceSourceIndex */ - ',' StringData /* 11: ResourceSourceLabel */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,8, - $4,$6,$8,$9,$11,$12,$13,$14);} - | PARSEOP_PINGROUPFUNCTION - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -QWordIOTerm - : PARSEOP_QWORDIO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_QWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_QWORDIO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -QWordMemoryTerm - : PARSEOP_QWORDMEMORY - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_QWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,16, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_QWORDMEMORY - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -QWordSpaceTerm - : PARSEOP_QWORDSPACE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_QWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_QWORDSPACE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -RegisterTerm - : PARSEOP_REGISTER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_REGISTER);} - AddressSpaceKeyword - ',' ByteConstExpr - ',' ByteConstExpr - ',' QWordConstExpr - OptionalAccessSize - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,6,$4,$6,$8,$10,$11,$12);} - | PARSEOP_REGISTER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SpiSerialBusTerm - : PARSEOP_SPI_SERIALBUS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SPI_SERIALBUS);} - WordConstExpr /* 04: DeviceSelection */ - OptionalDevicePolarity /* 05: DevicePolarity */ - OptionalWireMode /* 06: WireMode */ - ',' ByteConstExpr /* 08: DataBitLength */ - OptionalSlaveMode /* 09: SlaveMode */ - ',' DWordConstExpr /* 11: ConnectionSpeed */ - ',' ClockPolarityKeyword /* 13: ClockPolarity */ - ',' ClockPhaseKeyword /* 15: ClockPhase */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),$21);} - | PARSEOP_SPI_SERIALBUS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -SpiSerialBusTermV2 - : PARSEOP_SPI_SERIALBUS_V2 - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_SPI_SERIALBUS_V2);} - WordConstExpr /* 04: DeviceSelection */ - OptionalDevicePolarity /* 05: DevicePolarity */ - OptionalWireMode /* 06: WireMode */ - ',' ByteConstExpr /* 08: DataBitLength */ - OptionalSlaveMode /* 09: SlaveMode */ - ',' DWordConstExpr /* 11: ConnectionSpeed */ - ',' ClockPolarityKeyword /* 13: ClockPolarity */ - ',' ClockPhaseKeyword /* 15: ClockPhase */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalShareType /* 21: Share */ - OptionalBuffer_Last /* 22: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21,$22);} - | PARSEOP_SPI_SERIALBUS_V2 - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnNoPriTerm - : PARSEOP_STARTDEPENDENTFN_NOPRI - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_STARTDEPENDENTFN_NOPRI);} - PARSEOP_CLOSE_PAREN '{' - ResourceMacroList '}' {$$ = TrLinkOpChildren ($3,1,$6);} - | PARSEOP_STARTDEPENDENTFN_NOPRI - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnTerm - : PARSEOP_STARTDEPENDENTFN - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_STARTDEPENDENTFN);} - ByteConstExpr - ',' ByteConstExpr - PARSEOP_CLOSE_PAREN '{' - ResourceMacroList '}' {$$ = TrLinkOpChildren ($3,3,$4,$6,$9);} - | PARSEOP_STARTDEPENDENTFN - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -UartSerialBusTerm - : PARSEOP_UART_SERIALBUS - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_UART_SERIALBUS);} - DWordConstExpr /* 04: ConnectionSpeed */ - OptionalBitsPerByte /* 05: BitsPerByte */ - OptionalStopBits /* 06: StopBits */ - ',' ByteConstExpr /* 08: LinesInUse */ - OptionalEndian /* 09: Endianness */ - OptionalParityType /* 10: Parity */ - OptionalFlowControl /* 11: FlowControl */ - ',' WordConstExpr /* 13: Rx BufferSize */ - ',' WordConstExpr /* 15: Tx BufferSize */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),$21);} - | PARSEOP_UART_SERIALBUS - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -UartSerialBusTermV2 - : PARSEOP_UART_SERIALBUS_V2 - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_UART_SERIALBUS_V2);} - DWordConstExpr /* 04: ConnectionSpeed */ - OptionalBitsPerByte /* 05: BitsPerByte */ - OptionalStopBits /* 06: StopBits */ - ',' ByteConstExpr /* 08: LinesInUse */ - OptionalEndian /* 09: Endianness */ - OptionalParityType /* 10: Parity */ - OptionalFlowControl /* 11: FlowControl */ - ',' WordConstExpr /* 13: Rx BufferSize */ - ',' WordConstExpr /* 15: Tx BufferSize */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalShareType /* 21: Share */ - OptionalBuffer_Last /* 22: VendorData */ - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21,$22);} - | PARSEOP_UART_SERIALBUS_V2 - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -VendorLongTerm - : PARSEOP_VENDORLONG - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_VENDORLONG);} - OptionalNameString_First - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_VENDORLONG - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -VendorShortTerm - : PARSEOP_VENDORSHORT - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_VENDORSHORT);} - OptionalNameString_First - PARSEOP_CLOSE_PAREN '{' - ByteList '}' {$$ = TrLinkOpChildren ($3,2,$4,$7);} - | PARSEOP_VENDORSHORT - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -WordBusNumberTerm - : PARSEOP_WORDBUSNUMBER - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WORDBUSNUMBER);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,12, - $4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} - | PARSEOP_WORDBUSNUMBER - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -WordIOTerm - : PARSEOP_WORDIO - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,15, - $4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_WORDIO - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - -WordSpaceTerm - : PARSEOP_WORDSPACE - PARSEOP_OPEN_PAREN {$$ = TrCreateLeafOp (PARSEOP_WORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($3,14, - $4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_WORDSPACE - PARSEOP_OPEN_PAREN - error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} - ; - - - - -/******************************************************************************* - * - * ASL Helper Terms - * - ******************************************************************************/ - -OptionalBusMasterKeyword - : ',' {$$ = TrCreateLeafOp ( - PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafOp ( - PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafOp ( - PARSEOP_BUSMASTERTYPE_NOTMASTER);} - ; - -OptionalAccessAttribTerm - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - | ',' AccessAttribKeyword {$$ = $2;} - ; - -OptionalAccessSize - : {$$ = TrCreateValuedLeafOp ( - PARSEOP_BYTECONST, 0);} - | ',' {$$ = TrCreateValuedLeafOp ( - PARSEOP_BYTECONST, 0);} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalAccessTypeKeyword /* Default: AnyAcc */ - : {$$ = TrCreateLeafOp ( - PARSEOP_ACCESSTYPE_ANY);} - | ',' {$$ = TrCreateLeafOp ( - PARSEOP_ACCESSTYPE_ANY);} - | ',' AccessTypeKeyword {$$ = $2;} - ; - -OptionalAddressingMode - : ',' {$$ = NULL;} - | ',' AddressingModeKeyword {$$ = $2;} - ; - -OptionalAddressRange - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' AddressKeyword {$$ = $2;} - ; - -OptionalBitsPerByte - : ',' {$$ = NULL;} - | ',' BitsPerByteKeyword {$$ = $2;} - ; - -OptionalBuffer_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' RawDataBufferTerm {$$ = $2;} - ; - -OptionalByteConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalDecodeType - : ',' {$$ = NULL;} - | ',' DecodeKeyword {$$ = $2;} - ; - -OptionalDevicePolarity - : ',' {$$ = NULL;} - | ',' DevicePolarityKeyword {$$ = $2;} - ; - -OptionalDWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DWordConstExpr {$$ = $2;} - ; - -OptionalEndian - : ',' {$$ = NULL;} - | ',' EndianKeyword {$$ = $2;} - ; - -OptionalFlowControl - : ',' {$$ = NULL;} - | ',' FlowControlKeyword {$$ = $2;} - ; - -OptionalIoRestriction - : ',' {$$ = NULL;} - | ',' IoRestrictionKeyword {$$ = $2;} - ; - -OptionalListString - : {$$ = TrCreateValuedLeafOp ( - PARSEOP_STRING_LITERAL, - ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' {$$ = TrCreateValuedLeafOp ( - PARSEOP_STRING_LITERAL, - ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' TermArg {$$ = $2;} - ; - -OptionalLockRuleKeyword /* Default: NoLock */ - : {$$ = TrCreateLeafOp ( - PARSEOP_LOCKRULE_NOLOCK);} - | ',' {$$ = TrCreateLeafOp ( - PARSEOP_LOCKRULE_NOLOCK);} - | ',' LockRuleKeyword {$$ = $2;} - ; - -OptionalMaxType - : ',' {$$ = NULL;} - | ',' MaxKeyword {$$ = $2;} - ; - -OptionalMemType - : ',' {$$ = NULL;} - | ',' MemTypeKeyword {$$ = $2;} - ; - -OptionalMinType - : ',' {$$ = NULL;} - | ',' MinKeyword {$$ = $2;} - ; - -OptionalNameString - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_First - : {$$ = TrCreateLeafOp ( - PARSEOP_ZERO);} - | NameString {$$ = $1;} - ; - -OptionalObjectTypeKeyword - : {$$ = TrCreateLeafOp ( - PARSEOP_OBJECTTYPE_UNK);} - | ',' ObjectTypeKeyword {$$ = $2;} - ; - -OptionalParityType - : ',' {$$ = NULL;} - | ',' ParityTypeKeyword {$$ = $2;} - ; - -OptionalQWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' QWordConstExpr {$$ = $2;} - ; - -OptionalRangeType - : ',' {$$ = NULL;} - | ',' RangeTypeKeyword {$$ = $2;} - ; - -OptionalReadWriteKeyword - : {$$ = TrCreateLeafOp ( - PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafOp ( - PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafOp ( - PARSEOP_READWRITETYPE_READONLY);} - ; - -OptionalResourceType_First - : {$$ = TrCreateLeafOp ( - PARSEOP_RESOURCETYPE_CONSUMER);} - | ResourceTypeKeyword {$$ = $1;} - ; - -OptionalResourceType - : {$$ = TrCreateLeafOp ( - PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' {$$ = TrCreateLeafOp ( - PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' ResourceTypeKeyword {$$ = $2;} - ; - -/* Same as above except default is producer */ -OptionalProducerResourceType - : {$$ = TrCreateLeafOp ( - PARSEOP_RESOURCETYPE_PRODUCER);} - | ',' {$$ = TrCreateLeafOp ( - PARSEOP_RESOURCETYPE_PRODUCER);} - | ',' ResourceTypeKeyword {$$ = $2;} - ; - -OptionalSlaveMode - : ',' {$$ = NULL;} - | ',' SlaveModeKeyword {$$ = $2;} - ; - -OptionalShareType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ShareTypeKeyword {$$ = $2;} - ; - -OptionalShareType_First - : {$$ = NULL;} - | ShareTypeKeyword {$$ = $1;} - ; - -OptionalStopBits - : ',' {$$ = NULL;} - | ',' StopBitsKeyword {$$ = $2;} - ; - -OptionalStringData - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' StringData {$$ = $2;} - ; - -OptionalSyncLevel /* Default: 0 */ - : {$$ = TrCreateValuedLeafOp ( - PARSEOP_BYTECONST, 0);} - | ',' {$$ = TrCreateValuedLeafOp ( - PARSEOP_BYTECONST, 0);} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalTranslationType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TranslationKeyword {$$ = $2;} - ; - -OptionalType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalUpdateRuleKeyword /* Default: Preserve */ - : {$$ = TrCreateLeafOp ( - PARSEOP_UPDATERULE_PRESERVE);} - | ',' {$$ = TrCreateLeafOp ( - PARSEOP_UPDATERULE_PRESERVE);} - | ',' UpdateRuleKeyword {$$ = $2;} - ; - -OptionalWireMode - : ',' {$$ = NULL;} - | ',' WireModeKeyword {$$ = $2;} - ; - -OptionalWordConstExpr - : ',' {$$ = NULL;} - | ',' WordConstExpr {$$ = $2;} - ; - -OptionalXferSize - : {$$ = TrCreateValuedLeafOp ( - PARSEOP_XFERSIZE_32, 2);} - | ',' {$$ = TrCreateValuedLeafOp ( - PARSEOP_XFERSIZE_32, 2);} - | ',' XferSizeKeyword {$$ = $2;} - ; - -%% - -/*! [End] no source code translation !*/ - -/* Local support functions in C */ - - - -/****************************************************************************** - * - * Local support functions - * - *****************************************************************************/ - -/*! [Begin] no source code translation */ -int -AslCompilerwrap(void) -{ - return (1); -} -/*! [End] no source code translation !*/ - - -void * -AslLocalAllocate ( - unsigned int Size) -{ - void *Mem; - - - DbgPrint (ASL_PARSE_OUTPUT, - "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); - - Mem = ACPI_ALLOCATE_ZEROED (Size); - if (!Mem) - { - AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, - AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber, - AslGbl_InputByteCount, AslGbl_CurrentColumn, - AslGbl_Files[ASL_FILE_INPUT].Filename, NULL); - exit (1); - } - - return (Mem); -} - -ACPI_PARSE_OBJECT * -AslDoError ( - void) -{ - - return (TrCreateLeafOp (PARSEOP_ERRORNODE)); -} - - -/******************************************************************************* - * - * FUNCTION: UtGetOpName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * - * RETURN: Pointer to the opcode name - * - * DESCRIPTION: Get the ascii name of the parse opcode - * - ******************************************************************************/ - -char * -UtGetOpName ( - UINT32 ParseOpcode) -{ -#ifdef ASL_YYTNAME_START - /* - * First entries (ASL_YYTNAME_START) in yytname are special reserved names. - * Ignore first 8 characters of the name - */ - return ((char *) yytname - [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); -#else - return ("[Unknown parser generator]"); -#endif -} - diff --git a/source/compiler/aslexternal.c b/source/compiler/aslexternal.c index 37f07e87825..315247be60f 100644 --- a/source/compiler/aslexternal.c +++ b/source/compiler/aslexternal.c @@ -192,12 +192,54 @@ ExDoExternal ( ACPI_PARSE_OBJECT *Prev; ACPI_PARSE_OBJECT *Next; ACPI_PARSE_OBJECT *ArgCountOp; + ACPI_PARSE_OBJECT *TypeOp; + ACPI_PARSE_OBJECT *ExternTypeOp = Op->Asl.Child->Asl.Next; + UINT32 ExternType; + UINT8 ParamCount = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS; + UINT32 ParamTypes[ACPI_METHOD_NUM_ARGS]; + ExternType = AnMapObjTypeToBtype (ExternTypeOp); + + /* + * The parser allows optional parameter return types regardless of the + * type. Check object type keyword emit error if optional parameter/return + * types exist. + * + * Check the parameter return type + */ + TypeOp = ExternTypeOp->Asl.Next; + if (TypeOp->Asl.Child) + { + /* Ignore the return type for now. */ + + (void) MtProcessTypeOp (TypeOp->Asl.Child); + if (ExternType != ACPI_BTYPE_METHOD) + { + sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType)); + AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_RET_TYPE, TypeOp, + AslGbl_MsgBuffer); + } + } + + /* Check the parameter types */ + + TypeOp = TypeOp->Asl.Next; + if (TypeOp->Asl.Child) + { + ParamCount = MtProcessParameterTypeList (TypeOp->Asl.Child, ParamTypes); + if (ExternType != ACPI_BTYPE_METHOD) + { + sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType)); + AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_PARAM_TYPE, TypeOp, + AslGbl_MsgBuffer); + } + } + ArgCountOp = Op->Asl.Child->Asl.Next->Asl.Next; ArgCountOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST; - ArgCountOp->Asl.Value.Integer = 0; + ArgCountOp->Asl.Value.Integer = ParamCount; UtSetParseOpName (ArgCountOp); /* Create new list node of arbitrary type */ diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index d9728206f3c..0d26c641d92 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -196,6 +196,15 @@ LdCheckSpecialNames ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op); +static ACPI_STATUS +LdAnalyzeExternals ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op, + ACPI_OBJECT_TYPE ExternalOpType, + ACPI_OBJECT_TYPE ObjectType, + ACPI_WALK_STATE *WalkState); + + /******************************************************************************* * * FUNCTION: LdLoadNamespace @@ -575,7 +584,8 @@ LdNamespace1Begin ( /* Check for a possible illegal forward reference */ if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || - (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) + (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || + (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { /* * Op->Asl.Namepath will be NULL for these opcodes. @@ -591,7 +601,8 @@ LdNamespace1Begin ( * We only want references to named objects: * Store (2, WXYZ) -> Attempt to resolve the name */ - if (OpInfo->Class == AML_CLASS_NAMED_OBJECT) + if ((Op->Asl.ParseOpcode != PARSEOP_METHODCALL) && + (OpInfo->Class == AML_CLASS_NAMED_OBJECT)) { return (AE_OK); } @@ -899,56 +910,24 @@ LdNamespace1Begin ( Node->Type = (UINT8) ObjectType; Status = AE_OK; } - else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) - { - /* - * Allow one create on an object or segment that was - * previously declared External - */ - Node->Flags &= ~ANOBJ_IS_EXTERNAL; - Node->Type = (UINT8) ObjectType; - - /* Just retyped a node, probably will need to open a scope */ - - if (AcpiNsOpensScope (ObjectType)) - { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - Status = AE_OK; - } - else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) { - /* - * Allow externals in same scope as the definition of the - * actual object. Similar to C. Allows multiple definition - * blocks that refer to each other in the same file. - */ - Status = AE_OK; - } - else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && - (ObjectType == ACPI_TYPE_ANY)) - { - /* Allow update of externals of unknown type. */ - - if (AcpiNsOpensScope (ActualObjectType)) + Status = LdAnalyzeExternals (Node, Op, ActualObjectType, + ObjectType, WalkState); + if (ACPI_FAILURE (Status)) { - Node->Type = (UINT8) ActualObjectType; - Status = AE_OK; - } - else - { - sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName, - AcpiUtGetTypeName (Node->Type)); - AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer); - return_ACPI_STATUS (AE_OK); + if (Status == AE_ERROR) + { + /* + * The use of AE_ERROR here indicates that there was a + * compiler error emitted in LdAnalyzeExternals which + * means that the caller should proceed to the next Op + * for analysis of subsequent parse objects. + */ + Status = AE_OK; + } + return_ACPI_STATUS (Status); } } else @@ -1013,15 +992,17 @@ FinishNode: * Set the actual data type if appropriate (EXTERNAL term only) * As of 11/19/2019, ASL External() does not support parameter * counts. When an External method is loaded, the parameter count is - * unknown setting Node->Value to ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS - * indicates that the parameter count for this method is unknown. - * This information is used in ASL cross reference to help determine the - * parameter count through method calls. + * recorded in the external's arg count parameter. The parameter count may + * or may not be known in the declaration. If the value of this node turns + * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that + * we do not know the parameter count and that we must look at the usage of + * the External method call to get this information. */ if (ActualObjectType != ACPI_TYPE_ANY) { Node->Type = (UINT8) ActualObjectType; - Node->Value = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS; + Node->Value = (UINT32) + Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; } if (Op->Asl.ParseOpcode == PARSEOP_METHOD) @@ -1037,6 +1018,145 @@ FinishNode: } +/******************************************************************************* + * + * FUNCTION: LdAnalyzeExternals + * + * PARAMETERS: Node - Node that represents the named object + * Op - Named object declaring this named object + * ExternalOpType - Type of ExternalOp + * ObjectType - Type of Declared object + * WalkState - Current WalkState + * + * RETURN: Status + * + * DESCRIPTION: Node and Op represents an identically named object declaration + * that is either declared by the ASL external keyword or declared + * by operators that declare named objects (i.e. Name, Device, + * OperationRegion, and etc.). This function ensures that the + * declarations do not contradict each other. + * + ******************************************************************************/ + +static ACPI_STATUS +LdAnalyzeExternals ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op, + ACPI_OBJECT_TYPE ExternalOpType, + ACPI_OBJECT_TYPE ObjectType, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OBJECT_TYPE ActualExternalOpType; + ACPI_OBJECT_TYPE ActualOpType; + ACPI_PARSE_OBJECT *ExternalOp; + ACPI_PARSE_OBJECT *ActualOp; + + + /* + * The declaration represented by Node and Op must have the same type. + * The type of the external Op is represented by ExternalOpType. However, + * the type of the pre-existing declaration depends on whether if Op + * is an external declaration or an actual declaration. + */ + if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) + { + ActualExternalOpType = ExternalOpType; + ActualOpType = Node->Type; + } + else + { + ActualExternalOpType = Node->Type; + ActualOpType = ObjectType; + } + + if ((ActualOpType != ACPI_TYPE_ANY) && + (ActualExternalOpType != ACPI_TYPE_ANY) && + (ActualExternalOpType != ActualOpType)) + { + if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && + Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) + { + AslDualParseOpError (ASL_ERROR, + ASL_MSG_DUPLICATE_EXTERN_MISMATCH, Op, NULL, + ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, Node->Op, NULL); + } + else + { + if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && + Node->Op->Asl.ParseOpcode != PARSEOP_EXTERNAL) + { + ExternalOp = Op; + ActualOp = Node->Op; + } + else + { + ExternalOp = Node->Op; + ActualOp = Op; + } + AslDualParseOpError (ASL_ERROR, + ASL_MSG_DECLARATION_TYPE_MISMATCH, ExternalOp, NULL, + ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ActualOp, NULL); + } + } + + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) + { + /* + * Allow one create on an object or segment that was + * previously declared External + */ + Node->Flags &= ~ANOBJ_IS_EXTERNAL; + Node->Type = (UINT8) ObjectType; + + /* Just retyped a node, probably will need to open a scope */ + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Status = AE_OK; + } + else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * Allow externals in same scope as the definition of the + * actual object. Similar to C. Allows multiple definition + * blocks that refer to each other in the same file. + */ + Status = AE_OK; + } + else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + (ObjectType == ACPI_TYPE_ANY)) + { + /* Allow update of externals of unknown type. */ + + if (AcpiNsOpensScope (ExternalOpType)) + { + Node->Type = (UINT8) ExternalOpType; + Status = AE_OK; + } + else + { + sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName, + AcpiUtGetTypeName (Node->Type)); + AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer); + Status = AE_ERROR; + } + } + + return (Status); +} + + /******************************************************************************* * * FUNCTION: LdCheckSpecialNames diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 418df32c580..81280b28cb4 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -320,7 +320,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", /* ASL_MSG_SEEK */ "Could not seek file", /* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", -/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", +/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized due to creation of named objects within", /* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", /* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", /* ASL_MSG_STRING_LENGTH */ "String literal too long", @@ -370,7 +370,16 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_INVALID_PROCESSOR_UID */ "_UID inside processor declaration must be an integer", /* ASL_MSG_LEGACY_PROCESSOR_OP */ "Legacy Processor() keyword detected. Use Device() keyword instead.", /* ASL_MSG_NAMESTRING_LENGTH */ "NameString contains too many NameSegs (>255)", -/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:" +/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:", +/* ASL_MSG_EXTERN_INVALID_RET_TYPE */ "Return type is only allowed for Externals declared as MethodObj", +/* ASL_MSG_EXTERN_INVALID_PARAM_TYPE */ "Parameter type is only allowed for Externals declared as MethodObj", +/* ASL_MSG_NAMED_OBJECT_CREATION */ "Creation of named objects within a method is highly inefficient, use globals or method local variables instead", +/* ASL_MSG_ARG_COUNT_MISMATCH */ "Method NumArgs count does not match length of ParameterTypes list", +/* ASL_MSG_STATIC_OPREGION_IN_METHOD */ "Static OperationRegion should be declared outside control method", +/* ASL_MSG_DECLARATION_TYPE_MISMATCH */ "Type mismatch between external declaration and actual object declaration detected", +/* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", +/* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", +/* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", }; /* Table compiler */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index fb3513abddc..6d5ffd4d6d5 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -373,6 +373,16 @@ typedef enum ASL_MSG_LEGACY_PROCESSOR_OP, ASL_MSG_NAMESTRING_LENGTH, ASL_MSG_CASE_FOUND_HERE, + ASL_MSG_EXTERN_INVALID_RET_TYPE, + ASL_MSG_EXTERN_INVALID_PARAM_TYPE, + ASL_MSG_NAMED_OBJECT_CREATION, + ASL_MSG_ARG_COUNT_MISMATCH, + ASL_MSG_STATIC_OPREGION_IN_METHOD, + ASL_MSG_DECLARATION_TYPE_MISMATCH, + ASL_MSG_TYPE_MISMATCH_FOUND_HERE, + ASL_MSG_DUPLICATE_EXTERN_MISMATCH, + ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, + /* These messages are used by the Data Table compiler only */ diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index b7b7ec42f3a..d56f4817c9e 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -151,6 +151,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acnamesp.h" #include "acparser.h" #include "amlcode.h" @@ -166,6 +167,10 @@ MtCheckNamedObjectInMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo); +static void +MtCheckStaticOperationRegionInMethod ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -197,7 +202,6 @@ MtMethodAnalysisWalkBegin ( char ArgName[] = "Arg0"; ACPI_PARSE_OBJECT *ArgNode; ACPI_PARSE_OBJECT *NextType; - ACPI_PARSE_OBJECT *NextParamType; UINT8 ActualArgs = 0; BOOLEAN HidExists; BOOLEAN AdrExists; @@ -282,50 +286,35 @@ MtMethodAnalysisWalkBegin ( Next = Next->Asl.Next; NextType = Next->Asl.Child; - while (NextType) - { - /* Get and map each of the ReturnTypes */ - MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); - NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - NextType = NextType->Asl.Next; - } + MethodInfo->ValidReturnTypes = MtProcessTypeOp (NextType); /* Get the ParameterType node */ Next = Next->Asl.Next; NextType = Next->Asl.Child; - while (NextType) + if (!NextType) { - if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) - { - NextParamType = NextType->Asl.Child; - while (NextParamType) - { - MethodInfo->ValidArgTypes[ActualArgs] |= - AnMapObjTypeToBtype (NextParamType); - - NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - NextParamType = NextParamType->Asl.Next; - } - } - else - { - MethodInfo->ValidArgTypes[ActualArgs] = - AnMapObjTypeToBtype (NextType); - - NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - ActualArgs++; - } - - NextType = NextType->Asl.Next; + /* + * The optional parameter types list was omitted at the source + * level. Use the Argument count parameter instead. + */ + ActualArgs = MethodInfo->NumArguments; + } + else + { + ActualArgs = MtProcessParameterTypeList (NextType, + MethodInfo->ValidArgTypes); } if ((MethodInfo->NumArguments) && (MethodInfo->NumArguments != ActualArgs)) { - /* error: Param list did not match number of args */ + sprintf (AslGbl_MsgBuffer, + "Length = %u", ActualArgs); + AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_MISMATCH, + Op->Asl.Child->Asl.Next, AslGbl_MsgBuffer); } /* Allow numarguments == 0 for Function() */ @@ -576,6 +565,8 @@ MtMethodAnalysisWalkBegin ( AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); } + + MtCheckStaticOperationRegionInMethod (Op); break; case PARSEOP_NAME: @@ -628,6 +619,71 @@ MtMethodAnalysisWalkBegin ( } +/******************************************************************************* + * + * FUNCTION: MtProcessTypeOp + * + * PARAMETERS: Op - Op representing a btype + * + * RETURN: Btype represented by Op + * + * DESCRIPTION: Process a parse object that represents single parameter type or + * a return type in method, function, and external declarations. + * + ******************************************************************************/ + +UINT32 +MtProcessTypeOp ( + ACPI_PARSE_OBJECT *TypeOp) +{ + UINT32 Btype = ACPI_BTYPE_ANY; + + + while (TypeOp) + { + Btype |= AnMapObjTypeToBtype (TypeOp); + TypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + TypeOp = TypeOp->Asl.Next; + } + + return (Btype); +} + + +/******************************************************************************* + * + * FUNCTION: MtProcessParameterTypeList + * + * PARAMETERS: Op - Op representing a btype + * + * RETURN: Btype represented by Op + * + * DESCRIPTION: Process a parse object that represents a parameter type list in + * method, function, and external declarations. + * + ******************************************************************************/ + +UINT8 +MtProcessParameterTypeList ( + ACPI_PARSE_OBJECT *ParamTypeOp, + UINT32 *TypeList) +{ + UINT8 ParameterCount = 0; + + + while (ParamTypeOp) + { + TypeList[ParameterCount] = + MtProcessTypeOp (ParamTypeOp->Asl.Child); + + ParameterCount++; + ParamTypeOp = ParamTypeOp->Asl.Next; + } + + return (ParameterCount); +} + + /******************************************************************************* * * FUNCTION: MtCheckNamedObjectInMethod @@ -649,6 +705,7 @@ MtCheckNamedObjectInMethod ( ASL_METHOD_INFO *MethodInfo) { const ACPI_OPCODE_INFO *OpInfo; + char *ExternalPath; /* We don't care about actual method declarations or scopes */ @@ -672,27 +729,97 @@ MtCheckNamedObjectInMethod ( /* * 1) Mark the method as a method that creates named objects. * - * 2) If the method is non-serialized, emit a remark that the method + * 2) Issue a remark indicating the inefficiency of creating named + * objects within a method (Except for compiler-emitted temporary + * variables). + * + * 3) If the method is non-serialized, emit a remark that the method * should be serialized. * * Reason: If a thread blocks within the method for any reason, and * another thread enters the method, the method will fail because * an attempt will be made to create the same object twice. */ + ExternalPath = AcpiNsGetNormalizedPathname (MethodInfo->Op->Asl.Node, TRUE); + + /* No error for compiler temp variables (name starts with "_T_") */ + + if ((Op->Asl.NameSeg[0] != '_') && + (Op->Asl.NameSeg[1] != 'T') && + (Op->Asl.NameSeg[2] != '_')) + { + AslError (ASL_REMARK, ASL_MSG_NAMED_OBJECT_CREATION, Op, + ExternalPath); + } + MethodInfo->CreatesNamedObjects = TRUE; if (!MethodInfo->ShouldBeSerialized) { AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op, - "due to creation of named objects within"); + ExternalPath); /* Emit message only ONCE per method */ MethodInfo->ShouldBeSerialized = TRUE; } + + if (ExternalPath) + { + ACPI_FREE (ExternalPath); + } } } +/******************************************************************************* + * + * FUNCTION: MtCheckStaticOperationRegionInMethod + * + * PARAMETERS: Op - Current parser op + * + * RETURN: None + * + * DESCRIPTION: Warns if an Operation Region with static address or length + * is declared inside a control method + * + ******************************************************************************/ + +static void +MtCheckStaticOperationRegionInMethod( + ACPI_PARSE_OBJECT* Op) +{ + ACPI_PARSE_OBJECT* AddressOp; + ACPI_PARSE_OBJECT* LengthOp; + + + if (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION) + { + return; + } + + /* + * OperationRegion should have 4 arguments defined. At this point, we + * assume that the parse tree is well-formed. + */ + AddressOp = Op->Asl.Child->Asl.Next->Asl.Next; + LengthOp = Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next; + + if (UtGetParentMethodOp (Op) && + AddressOp->Asl.ParseOpcode == PARSEOP_INTEGER && + LengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) + { + /* + * At this point, a static operation region declared inside of a + * control method has been found. Throw a warning because this is + * highly inefficient. + */ + AslError(ASL_WARNING, ASL_MSG_STATIC_OPREGION_IN_METHOD, Op, NULL); + } + + return; +} + + /******************************************************************************* * * FUNCTION: MtMethodAnalysisWalkEnd @@ -714,6 +841,7 @@ MtMethodAnalysisWalkEnd ( { ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; + char *ExternalPath; switch (Op->Asl.ParseOpcode) @@ -766,8 +894,15 @@ MtMethodAnalysisWalkEnd ( if (MethodInfo->NumReturnNoValue && MethodInfo->NumReturnWithValue) { + ExternalPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); + AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, - Op->Asl.ExternalName); + ExternalPath); + + if (ExternalPath) + { + ACPI_FREE (ExternalPath); + } } /* diff --git a/source/compiler/aslparseop.c b/source/compiler/aslparseop.c index b58d4e6623f..46875413e43 100644 --- a/source/compiler/aslparseop.c +++ b/source/compiler/aslparseop.c @@ -743,13 +743,18 @@ TrCreateConstantLeafOp ( /* Get a copy of the current time */ + Op->Asl.Value.String = ""; CurrentTime = time (NULL); - StaticTimeString = ctime (&CurrentTime); - TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1); - strcpy (TimeString, StaticTimeString); - TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */ - Op->Asl.Value.String = TimeString; + StaticTimeString = ctime (&CurrentTime); + if (StaticTimeString) + { + TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1); + strcpy (TimeString, StaticTimeString); + + TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */ + Op->Asl.Value.String = TimeString; + } break; default: /* This would be an internal error */ diff --git a/source/compiler/aslprimaries.y b/source/compiler/aslprimaries.y index 7bbf4155ab7..1fb9e501ddd 100644 --- a/source/compiler/aslprimaries.y +++ b/source/compiler/aslprimaries.y @@ -663,7 +663,7 @@ FunctionTerm PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON; } TermList '}' {$$ = TrLinkOpChildren ($3,7, TrSetOpFlags ($4, OP_IS_NAME_DECLARATION), - TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0), + TrCreateLeafOp (PARSEOP_DEFAULT_ARG), TrCreateLeafOp (PARSEOP_SERIALIZERULE_NOTSERIAL), TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0),$5,$6,$10);} | PARSEOP_FUNCTION diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index 9035e8bb41f..f998527b3a3 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -421,14 +421,16 @@ ParameterTypePackage ParameterTypePackageList : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypePackage '}' {$$ = $2;} + | ObjectTypeKeyword {$$ = TrLinkOpChildren ( + TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);} + | '{' ParameterTypePackage '}' {$$ = TrLinkOpChildren ( + TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} ; + OptionalParameterTypePackage - : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypePackageList {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} + : {$$ = NULL;} + | ',' ParameterTypePackageList {$$ = $2;} ; /* Rules for specifying the types for method arguments */ @@ -441,14 +443,15 @@ ParameterTypesPackage ParameterTypesPackageList : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypesPackage '}' {$$ = $2;} + | ObjectTypeKeyword {$$ = TrLinkOpChildren ( + TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);} + | '{' ParameterTypesPackage '}' {$$ = TrLinkOpChildren ( + TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} ; OptionalParameterTypesPackage - : {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackageList {$$ = TrLinkOpChildren ( - TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);} + : {$$ = NULL;} + | ',' ParameterTypesPackageList {$$ = $2;} ; /* diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index dcb60f7a31d..67adf82ee28 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -205,6 +205,10 @@ TrCheckForBufferMatch ( ACPI_PARSE_OBJECT *Next1, ACPI_PARSE_OBJECT *Next2); +static void +TrDoMethod ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -463,11 +467,8 @@ TrTransformSubtree ( break; case PARSEOP_METHOD: - /* - * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global, - * however - */ - AslGbl_TempCount = 0; + + TrDoMethod (Op); break; case PARSEOP_EXTERNAL: @@ -1240,3 +1241,76 @@ TrCheckForBufferMatch ( return (TRUE); } + + +/******************************************************************************* + * + * FUNCTION: TrDoMethod + * + * PARAMETERS: Op - Parse node for SWITCH + * + * RETURN: None + * + * DESCRIPTION: Determine that parameter count of an ASL method node by + * translating the parameter count parse node from + * PARSEOP_DEFAULT_ARG to PARSEOP_BYTECONST. + * + ******************************************************************************/ + +static void +TrDoMethod ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ArgCountOp; + UINT8 ArgCount; + ACPI_PARSE_OBJECT *ParameterOp; + + + /* + * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global, + * however + */ + AslGbl_TempCount = 0; + + ArgCountOp = Op->Asl.Child->Asl.Next; + if (ArgCountOp->Asl.ParseOpcode == PARSEOP_BYTECONST) + { + /* + * Parameter count for this method has already been recorded in the + * method declaration. + */ + return; + } + + /* + * Parameter count has been omitted in the method declaration. + * Count the amount of arguments here. + */ + ParameterOp = ArgCountOp->Asl.Next->Asl.Next->Asl.Next->Asl.Next; + if (ParameterOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + ArgCount = 0; + ParameterOp = ParameterOp->Asl.Child; + + while (ParameterOp) + { + ParameterOp = ParameterOp->Asl.Next; + ArgCount++; + } + + ArgCountOp->Asl.Value.Integer = ArgCount; + ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST; + } + else + { + /* + * Method parameters can be counted by analyzing the Parameter type + * list. If the Parameter list contains more than 1 parameter, it + * is nested under PARSEOP_DEFAULT_ARG. When there is only 1 + * parameter, the parse tree contains a single node representing + * that type. + */ + ArgCountOp->Asl.Value.Integer = 1; + ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST; + } +} diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 4233318f0ea..42ef2c0b88c 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -298,7 +298,7 @@ UtNodeIsDescendantOf ( /******************************************************************************* * - * FUNCTION: UtGetParentMethod + * FUNCTION: UtGetParentMethodNode * * PARAMETERS: Node - Namespace node for any object * @@ -309,8 +309,8 @@ UtNodeIsDescendantOf ( * ******************************************************************************/ -void * -UtGetParentMethod ( +ACPI_NAMESPACE_NODE * +UtGetParentMethodNode ( ACPI_NAMESPACE_NODE *Node) { ACPI_NAMESPACE_NODE *ParentNode; @@ -338,6 +338,41 @@ UtGetParentMethod ( } +/******************************************************************************* + * + * FUNCTION: UtGetParentMethodOp + * + * PARAMETERS: Op - Parse Op to be checked + * + * RETURN: Control method Op if found. NULL otherwise + * + * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if + * the input Op is not within a control method. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +UtGetParentMethodOp ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextOp; + + + NextOp = Op->Asl.Parent; + while (NextOp) + { + if (NextOp->Asl.AmlOpcode == AML_METHOD_OP) + { + return (NextOp); + } + + NextOp = NextOp->Asl.Parent; + } + + return (NULL); /* No parent method found */ +} + + /******************************************************************************* * * FUNCTION: UtDisplaySupportedTables diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index 2649373f3af..38356aa2ef5 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -180,10 +180,6 @@ XfValidateCrossReference ( const ACPI_OPCODE_INFO *OpInfo, ACPI_NAMESPACE_NODE *Node); -static ACPI_PARSE_OBJECT * -XfGetParentMethod ( - ACPI_PARSE_OBJECT *Op); - static BOOLEAN XfObjectExists ( char *Name); @@ -380,41 +376,6 @@ XfCheckFieldRange ( } -/******************************************************************************* - * - * FUNCTION: XfGetParentMethod - * - * PARAMETERS: Op - Parse Op to be checked - * - * RETURN: Control method Op if found. NULL otherwise - * - * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if - * the input Op is not within a control method. - * - ******************************************************************************/ - -static ACPI_PARSE_OBJECT * -XfGetParentMethod ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *NextOp; - - - NextOp = Op->Asl.Parent; - while (NextOp) - { - if (NextOp->Asl.AmlOpcode == AML_METHOD_OP) - { - return (NextOp); - } - - NextOp = NextOp->Asl.Parent; - } - - return (NULL); /* No parent method found */ -} - - /******************************************************************************* * * FUNCTION: XfNamespaceLocateBegin @@ -539,7 +500,7 @@ XfNamespaceLocateBegin ( { /* Find parent method Op */ - NextOp = XfGetParentMethod (Op); + NextOp = UtGetParentMethodOp (Op); if (!NextOp) { return_ACPI_STATUS (AE_OK); @@ -576,7 +537,7 @@ XfNamespaceLocateBegin ( { /* Find parent method Op */ - NextOp = XfGetParentMethod (Op); + NextOp = UtGetParentMethodOp (Op); if (!NextOp) { return_ACPI_STATUS (AE_OK); @@ -814,10 +775,10 @@ XfNamespaceLocateBegin ( * same method or outside of any method, this is a forward reference * and should be reported as a compiler error. */ - DeclarationParentMethod = UtGetParentMethod (Node); - ReferenceParentMethod = XfGetParentMethod (Op); + DeclarationParentMethod = UtGetParentMethodNode (Node); + ReferenceParentMethod = UtGetParentMethodOp (Op); - /* case 1: declaration and refrence are both outside of method */ + /* case 1: declaration and reference are both outside of method */ if (!ReferenceParentMethod && !DeclarationParentMethod) { @@ -1337,8 +1298,8 @@ XfNamespaceLocateEnd ( * execution of A) * * NOTES: - * A null pointer returned by either XfGetParentMethod or - * UtGetParentMethod indicates that the parameter object is not + * A null pointer returned by either UtGetParentMethodOp or + * UtGetParentMethodNode indicates that the parameter object is not * within a control method. * * Five cases are handled: Case(Op, Node) @@ -1371,8 +1332,8 @@ XfValidateCrossReference ( * 1) Search upwards in parse tree for owner of the referencing object * 2) Search upwards in namespace to find the owner of the referenced object */ - ReferencingMethodOp = XfGetParentMethod (Op); - ReferencedMethodNode = UtGetParentMethod (Node); + ReferencingMethodOp = UtGetParentMethodOp (Op); + ReferencedMethodNode = UtGetParentMethodNode (Node); if (!ReferencingMethodOp && !ReferencedMethodNode) { diff --git a/source/compiler/cvparser.c b/source/compiler/cvparser.c index 0e0a5b80d1b..370b80361ce 100644 --- a/source/compiler/cvparser.c +++ b/source/compiler/cvparser.c @@ -230,8 +230,7 @@ CvIsFilename ( * FUNCTION: CvInitFileTree * * PARAMETERS: Table - input table - * AmlStart - Address of the starting point of the AML. - * AmlLength - Length of the AML file. + * RootFile - Output file that defines the DefinitionBlock * * RETURN: None * @@ -243,8 +242,7 @@ CvIsFilename ( void CvInitFileTree ( ACPI_TABLE_HEADER *Table, - UINT8 *AmlStart, - UINT32 AmlLength) + FILE *RootFile) { UINT8 *TreeAml; UINT8 *FileEnd; @@ -252,6 +250,8 @@ CvInitFileTree ( char *PreviousFilename = NULL; char *ParentFilename = NULL; char *ChildFilename = NULL; + UINT8 *AmlStart; + UINT32 AmlLength; if (!AcpiGbl_CaptureComments) @@ -259,9 +259,13 @@ CvInitFileTree ( return; } + + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); + CvDbgPrint ("AmlLength: %x\n", AmlLength); CvDbgPrint ("AmlStart: %p\n", AmlStart); - CvDbgPrint ("AmlEnd?: %p\n", AmlStart+AmlLength); + CvDbgPrint ("AmlEnd: %p\n", AmlStart+AmlLength); AcpiGbl_FileTreeRoot = AcpiOsAcquireObject (AcpiGbl_FileCache); @@ -273,7 +277,7 @@ CvInitFileTree ( /* Set the root file to the current open file */ - AcpiGbl_FileTreeRoot->File = AcpiGbl_OutputFile; + AcpiGbl_FileTreeRoot->File = RootFile; /* * Set this to true because we don't need to output diff --git a/source/components/events/evevent.c b/source/components/events/evevent.c index 800dd962b31..0afc7473d76 100644 --- a/source/components/events/evevent.c +++ b/source/components/events/evevent.c @@ -299,7 +299,7 @@ AcpiEvFixedEventInitialize ( /* * Initialize the structure that keeps track of fixed event handlers and - * enable the fixed events. + * disable all of the fixed events. */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { diff --git a/source/components/events/evxfgpe.c b/source/components/events/evxfgpe.c index 131021f126c..d652c29fb8e 100644 --- a/source/components/events/evxfgpe.c +++ b/source/components/events/evxfgpe.c @@ -1065,6 +1065,44 @@ AcpiEnableAllWakeupGpes ( ACPI_EXPORT_SYMBOL (AcpiEnableAllWakeupGpes) +/****************************************************************************** + * + * FUNCTION: AcpiAnyGpeStatusSet + * + * PARAMETERS: None + * + * RETURN: Whether or not the status bit is set for any GPE + * + * DESCRIPTION: Check the status bits of all enabled GPEs and return TRUE if any + * of them is set or FALSE otherwise. + * + ******************************************************************************/ + +UINT32 +AcpiAnyGpeStatusSet ( + void) +{ + ACPI_STATUS Status; + UINT8 Ret; + + + ACPI_FUNCTION_TRACE (AcpiAnyGpeStatusSet); + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + Ret = AcpiHwCheckAllGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return (Ret); +} + +ACPI_EXPORT_SYMBOL(AcpiAnyGpeStatusSet) + + /******************************************************************************* * * FUNCTION: AcpiInstallGpeBlock diff --git a/source/components/hardware/hwgpe.c b/source/components/hardware/hwgpe.c index f0b32bd6363..e8ad8926ce1 100644 --- a/source/components/hardware/hwgpe.c +++ b/source/components/hardware/hwgpe.c @@ -635,6 +635,58 @@ AcpiHwEnableWakeupGpeBlock ( } +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeBlockStatus + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Success + * + * DESCRIPTION: Produce a combined GPE status bits mask for the given block. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwGetGpeBlockStatus( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *RetPtr) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT64 InEnable; + UINT64 InStatus; + ACPI_STATUS Status; + UINT8 *Ret = RetPtr; + UINT32 i; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + Status = AcpiHwRead (&InEnable, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + continue; + } + + Status = AcpiHwRead (&InStatus, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + continue; + } + + *Ret |= InEnable & InStatus; + } + + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: AcpiHwDisableAllGpes @@ -715,4 +767,31 @@ AcpiHwEnableAllWakeupGpes ( return_ACPI_STATUS (Status); } + +/****************************************************************************** + * + * FUNCTION: AcpiHwCheckAllGpes + * + * PARAMETERS: None + * + * RETURN: Combined status of all GPEs + * + * DESCRIPTION: Check all enabled GPEs in all GPE blocks and return TRUE if the + * status bit is set for at least one of them of FALSE otherwise. + * + ******************************************************************************/ + +UINT8 +AcpiHwCheckAllGpes ( + void) +{ + UINT8 Ret = 0; + + + ACPI_FUNCTION_TRACE (AcpiHwCheckAllGpes); + + (void) AcpiEvWalkGpeList (AcpiHwGetGpeBlockStatus, &Ret); + return (Ret != 0); +} + #endif /* !ACPI_REDUCED_HARDWARE */ diff --git a/source/components/hardware/hwsleep.c b/source/components/hardware/hwsleep.c index 3ad4ae23c3a..016f62be3aa 100644 --- a/source/components/hardware/hwsleep.c +++ b/source/components/hardware/hwsleep.c @@ -464,6 +464,16 @@ AcpiHwLegacyWake ( AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, ACPI_CLEAR_STATUS); + /* Enable sleep button */ + + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[ACPI_EVENT_SLEEP_BUTTON].EnableRegisterId, + ACPI_ENABLE_EVENT); + + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[ACPI_EVENT_SLEEP_BUTTON].StatusRegisterId, + ACPI_CLEAR_STATUS); + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WORKING); return_ACPI_STATUS (Status); } diff --git a/source/components/namespace/nsnames.c b/source/components/namespace/nsnames.c index eebdd1a2db9..a9509195c89 100644 --- a/source/components/namespace/nsnames.c +++ b/source/components/namespace/nsnames.c @@ -336,7 +336,7 @@ AcpiNsHandleToPathname ( /* Build the path in the caller buffer */ (void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer, - RequiredSize, NoTrailing); + (UINT32) RequiredSize, NoTrailing); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", (char *) Buffer->Pointer, (UINT32) RequiredSize)); @@ -509,7 +509,7 @@ AcpiNsGetNormalizedPathname ( /* Build the path in the allocated buffer */ - (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing); + (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, (UINT32) Size, NoTrailing); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%s: Path \"%s\"\n", ACPI_GET_FUNCTION_NAME, NameBuffer)); @@ -542,7 +542,7 @@ AcpiNsBuildPrefixedPathname ( char *FullPath = NULL; char *ExternalPath = NULL; char *PrefixPath = NULL; - UINT32 PrefixPathLength = 0; + ACPI_SIZE PrefixPathLength = 0; /* If there is a prefix, get the pathname to it */ diff --git a/source/components/namespace/nsxfname.c b/source/components/namespace/nsxfname.c index 5b3d5a9bed6..53a2f4bfa27 100644 --- a/source/components/namespace/nsxfname.c +++ b/source/components/namespace/nsxfname.c @@ -714,7 +714,7 @@ AcpiInstallMethod ( MethodFlags = *ParserState.Aml++; AmlStart = ParserState.Aml; - AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); + AmlLength = (UINT32) ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); /* * Allocate resources up-front. We don't want to have to delete a new diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c index 3c17ee001a3..682cb5a80d3 100644 --- a/source/components/tables/tbxface.c +++ b/source/components/tables/tbxface.c @@ -368,14 +368,14 @@ ACPI_EXPORT_SYMBOL_INIT (AcpiReallocateRootTable) * * PARAMETERS: Signature - ACPI signature of needed table * Instance - Which instance (for SSDTs) - * OutTableHeader - The pointer to the table header to fill + * OutTableHeader - The pointer to the where the table header + * is returned * - * RETURN: Status and pointer to mapped table header + * RETURN: Status and a copy of the table header * - * DESCRIPTION: Finds an ACPI table header. - * - * NOTE: Caller is responsible in unmapping the header with - * AcpiOsUnmapMemory + * DESCRIPTION: Finds and returns an ACPI table header. Caller provides the + * memory where a copy of the header is to be returned + * (fixed length). * ******************************************************************************/ diff --git a/source/components/utilities/utobject.c b/source/components/utilities/utobject.c index e4b9305802b..71244e51882 100644 --- a/source/components/utilities/utobject.c +++ b/source/components/utilities/utobject.c @@ -192,7 +192,7 @@ AcpiUtGetElementLength ( * * NOTE: We always allocate the worst-case object descriptor because * these objects are cached, and we want them to be - * one-size-satisifies-any-request. This in itself may not be + * one-size-satisfies-any-request. This in itself may not be * the most memory efficient, but the efficiency of the object * cache should more than make up for this! * diff --git a/source/include/acconvert.h b/source/include/acconvert.h index 2894b729202..0962a164343 100644 --- a/source/include/acconvert.h +++ b/source/include/acconvert.h @@ -237,8 +237,7 @@ CgWriteAmlComment ( void CvInitFileTree ( ACPI_TABLE_HEADER *Table, - UINT8 *AmlStart, - UINT32 AmlLength); + FILE *RootFile); void CvClearOpComments ( diff --git a/source/include/achware.h b/source/include/achware.h index 646cef85681..9ff14d95784 100644 --- a/source/include/achware.h +++ b/source/include/achware.h @@ -315,6 +315,10 @@ ACPI_STATUS AcpiHwEnableAllWakeupGpes ( void); +UINT8 +AcpiHwCheckAllGpes ( + void); + ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, diff --git a/source/include/acmacros.h b/source/include/acmacros.h index 340875e8257..71cd18e208b 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -625,7 +625,7 @@ #define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) CvPrintOneCommentType (a,b,c,d); #define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) CvPrintOneCommentList (a,b); #define ASL_CV_FILE_HAS_SWITCHED(a) CvFileHasSwitched(a) -#define ASL_CV_INIT_FILETREE(a,b,c) CvInitFileTree(a,b,c); +#define ASL_CV_INIT_FILETREE(a,b) CvInitFileTree(a,b); #else @@ -640,7 +640,7 @@ #define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) #define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) #define ASL_CV_FILE_HAS_SWITCHED(a) 0 -#define ASL_CV_INIT_FILETREE(a,b,c) +#define ASL_CV_INIT_FILETREE(a,b) #endif diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 10e5e79a423..a39d180e949 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20200110 +#define ACPI_CA_VERSION 0x20200214 #include "acconfig.h" #include "actypes.h" @@ -1109,6 +1109,10 @@ ACPI_STATUS AcpiEnableAllWakeupGpes ( void)) +ACPI_HW_DEPENDENT_RETURN_UINT32 ( + UINT32 AcpiAnyGpeStatusSet ( + void)) + ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiGetGpeDevice ( diff --git a/source/include/actbl1.h b/source/include/actbl1.h index 6cb327a10a1..1f0d5c2f456 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -1149,7 +1149,7 @@ enum AcpiErstInstructions enum AcpiErstCommandStatus { - ACPI_ERST_SUCESS = 0, + ACPI_ERST_SUCCESS = 0, ACPI_ERST_NO_SPACE = 1, ACPI_ERST_NOT_AVAILABLE = 2, ACPI_ERST_FAILURE = 3, diff --git a/source/include/actypes.h b/source/include/actypes.h index 532d1fa82db..c7d2c9aa69e 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -683,11 +683,12 @@ typedef UINT64 ACPI_INTEGER; strnlen (a, ACPI_NAMESEG_SIZE) == ACPI_NAMESEG_SIZE) /* - * Algorithm to obtain access bit width. - * Can be used with AccessWidth of ACPI_GENERIC_ADDRESS and AccessSize of + * Algorithm to obtain access bit or byte width. + * Can be used with AccessSize field of ACPI_GENERIC_ADDRESS and * ACPI_RESOURCE_GENERIC_REGISTER. */ -#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + 2)) +#define ACPI_ACCESS_BIT_WIDTH(AccessSize) (1 << ((AccessSize) + 2)) +#define ACPI_ACCESS_BYTE_WIDTH(AccessSize) (1 << ((AccessSize) - 1)) /******************************************************************************* diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c index 9fde3687d87..5a32c122c70 100644 --- a/source/os_specific/service_layers/oswintbl.c +++ b/source/os_specific/service_layers/oswintbl.c @@ -179,20 +179,17 @@ static char KeyBuffer[LOCAL_BUFFER_SIZE]; static char ErrorBuffer[LOCAL_BUFFER_SIZE]; /* - * Tables supported in the Windows registry. Zero or more SSDTs are assumed to - * follow these tables. + * List of table signatures reported by EnumSystemFirmwareTables () */ -static char *SupportedTables[] = -{ - "DSDT", - "RSDT", - "FACS", - "FACP" -}; +UINT32 *Gbl_AvailableTableSignatures; +UINT32 Gbl_TableCount = 0; +UINT32 Gbl_SsdtInstance = 0; -/* Number of table names for the table above. */ +BOOLEAN Gbl_TableListInitialized = FALSE; -#define ACPI_OS_NUM_TABLE_ENTRIES 4 +static ACPI_STATUS +OslTableInitialize ( + void); /****************************************************************************** @@ -264,7 +261,8 @@ AcpiOsGetTableByAddress ( * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns * AE_LIMIT when an invalid index is reached. Index is not * necessarily an index into the RSDT/XSDT. - * Table is obtained from the Windows registry. + * SSDT tables are obtained from the Windows registry. All other + * tables are obtained through GetSystemFirmwareTable (). * * NOTE: Cannot get the physical address from the windows registry; * zero is returned instead. @@ -280,35 +278,327 @@ AcpiOsGetTableByIndex ( { ACPI_STATUS Status; char *Signature; + UINT32 CurrentInstance; - if (Index < ACPI_OS_NUM_TABLE_ENTRIES) + /* Enumerate all ACPI table signatures on first invocation of this function */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) { - Signature = SupportedTables[Index]; - Index = 0; + return (Status); + } + + /* Validate Index */ + + if (Index < Gbl_TableCount) + { + Signature = malloc (ACPI_NAMESEG_SIZE + 1); + if (!Signature) + { + return (AE_NO_MEMORY); + } + + Signature = memmove (Signature, &Gbl_AvailableTableSignatures[Index], ACPI_NAMESEG_SIZE); } else { - Signature = ACPI_SIG_SSDT; - Index -= ACPI_OS_NUM_TABLE_ENTRIES; + return (AE_LIMIT); } - Status = AcpiOsGetTableByName (Signature, Index, Table, Address); + if (ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) + { + CurrentInstance = Gbl_SsdtInstance; + Gbl_SsdtInstance++; + } + else + { + CurrentInstance = 0; + } + Status = AcpiOsGetTableByName (Signature, CurrentInstance, Table, Address); if (ACPI_SUCCESS (Status)) { - *Instance = Index; + *Instance = CurrentInstance; } else if (Status == AE_NOT_FOUND && ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) { /* Treat SSDTs that are not found as invalid index. */ - Status = (AE_LIMIT); + Status = AE_LIMIT; } + free (Signature); return (Status); } +/****************************************************************************** + * + * FUNCTION: OslTableInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize ACPI table data. Enumerate all ACPI table signatures + * and save them to a global list. + * + *****************************************************************************/ +static ACPI_STATUS +OslTableInitialize ( + void) +{ + UINT32 ResultSize; + UINT32 DataSize; + + if (Gbl_TableListInitialized) + { + return (AE_OK); + } + + /* + * ACPI table signatures are always 4 characters. Therefore, the data size + * buffer should be a multiple of 4 + */ + DataSize = EnumSystemFirmwareTables ('ACPI', NULL, 0); + if (DataSize % ACPI_NAMESEG_SIZE) + { + return (AE_ERROR); + } + + /* + * EnumSystemFirmwareTables () does not report the DSDT or XSDT. Work around this + * by adding these entries manually. + */ + Gbl_TableCount = 2 + DataSize / ACPI_NAMESEG_SIZE; + Gbl_AvailableTableSignatures = malloc (Gbl_TableCount * ACPI_NAMESEG_SIZE); + if (!Gbl_AvailableTableSignatures) + { + return (AE_NO_MEMORY); + } + + ResultSize = EnumSystemFirmwareTables ('ACPI', Gbl_AvailableTableSignatures, DataSize); + if (ResultSize > DataSize) + { + return (AE_ERROR); + } + + /* Insert the DSDT and XSDT tables signatures */ + + Gbl_AvailableTableSignatures [Gbl_TableCount - 1] = 'TDSD'; + Gbl_AvailableTableSignatures [Gbl_TableCount - 2] = 'TDSX'; + + Gbl_TableListInitialized = TRUE; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: WindowsGetTableFromRegistry + * + * PARAMETERS: Signature - ACPI Signature for desired table. Must be + * a null terminated 4-character string. + * Instance - For SSDTs (0...n). Use 0 otherwise. + * Table - Where a pointer to the table is returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Instance is beyond valid limit + * AE_NOT_FOUND: A table with the signature was not found + * + * DESCRIPTION: Get an ACPI table via a table signature (4 ASCII characters). + * Returns AE_LIMIT when an invalid instance is reached. + * Table is obtained from the Windows registry. + * + * NOTE: Assumes the input signature is uppercase. + * Cannot get the physical address from the windows registry; + * zero is returned instead. + * + *****************************************************************************/ + +static ACPI_STATUS +WindowsGetTableFromRegistry ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) +{ + HKEY Handle = NULL; + LONG WinStatus; + ULONG Type; + ULONG NameSize; + ULONG DataSize; + HKEY SubKey; + ULONG i; + ACPI_TABLE_HEADER *ReturnTable; + ACPI_STATUS Status = AE_OK; + + + /* Get a handle to the table key */ + + while (1) + { + strcpy(KeyBuffer, "HARDWARE\\ACPI\\"); + if (AcpiUtSafeStrcat(KeyBuffer, sizeof(KeyBuffer), Signature)) + { + return (AE_BUFFER_OVERFLOW); + } + + /* + * Windows stores SSDT at SSDT, SSD1, ..., SSD9, SSDA, ..., SSDS, SSDT, + * SSDU, ..., SSDY. If the first (0th) and the 29th tables have the same + * OEM ID, Table ID and Revision, then the 29th entry will overwrite the + * first entry... Let's hope that we do not have that many entries. + */ + if (Instance > 0 && ACPI_COMPARE_NAMESEG(Signature, ACPI_SIG_SSDT)) + { + if (Instance < 10) + { + KeyBuffer[strlen(KeyBuffer) - 1] = '0' + (char)Instance; + } + else if (Instance < 29) + { + KeyBuffer[strlen(KeyBuffer) - 1] = 'A' + (char)(Instance - 10); + } + else + { + return (AE_LIMIT); + } + } + + WinStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyBuffer, + 0L, KEY_READ, &Handle); + + if (WinStatus != ERROR_SUCCESS) + { + /* + * Somewhere along the way, MS changed the registry entry for + * the FADT from + * HARDWARE/ACPI/FACP to + * HARDWARE/ACPI/FADT. + * + * This code allows for both. + */ + if (ACPI_COMPARE_NAMESEG(Signature, "FACP")) + { + Signature = "FADT"; + } + else if (ACPI_COMPARE_NAMESEG(Signature, "XSDT")) + { + Signature = "RSDT"; + } + else if (ACPI_COMPARE_NAMESEG(Signature, ACPI_SIG_SSDT)) + { + /* + * SSDT may not be present on older Windows versions, but it is + * also possible that the index is not found. + */ + return (AE_NOT_FOUND); + } + else + { + fprintf(stderr, + "Could not find %s in registry at %s: %s (WinStatus=0x%X)\n", + Signature, KeyBuffer, WindowsFormatException(WinStatus), WinStatus); + return (AE_NOT_FOUND); + } + } + else + { + break; + } + } + + /* Actual data for the table is down a couple levels */ + + for (i = 0; ;) + { + WinStatus = RegEnumKey(Handle, i, KeyBuffer, sizeof(KeyBuffer)); + i++; + if (WinStatus == ERROR_NO_MORE_ITEMS) + { + break; + } + + WinStatus = RegOpenKey(Handle, KeyBuffer, &SubKey); + if (WinStatus != ERROR_SUCCESS) + { + fprintf(stderr, "Could not open %s entry: %s\n", + Signature, WindowsFormatException(WinStatus)); + Status = AE_ERROR; + goto Cleanup; + } + + RegCloseKey(Handle); + Handle = SubKey; + i = 0; + } + + /* Find the (binary) table entry */ + + for (i = 0; ; i++) + { + NameSize = sizeof(KeyBuffer); + WinStatus = RegEnumValue(Handle, i, KeyBuffer, &NameSize, NULL, + &Type, NULL, 0); + if (WinStatus != ERROR_SUCCESS) + { + fprintf(stderr, "Could not get %s registry entry: %s\n", + Signature, WindowsFormatException(WinStatus)); + Status = AE_ERROR; + goto Cleanup; + } + + if (Type == REG_BINARY) + { + break; + } + } + + /* Get the size of the table */ + + WinStatus = RegQueryValueEx(Handle, KeyBuffer, NULL, NULL, + NULL, &DataSize); + if (WinStatus != ERROR_SUCCESS) + { + fprintf(stderr, "Could not read the %s table size: %s\n", + Signature, WindowsFormatException(WinStatus)); + Status = AE_ERROR; + goto Cleanup; + } + + /* Allocate a new buffer for the table */ + + ReturnTable = malloc(DataSize); + if (!ReturnTable) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the actual table from the registry */ + + WinStatus = RegQueryValueEx(Handle, KeyBuffer, NULL, NULL, + (UCHAR *)ReturnTable, &DataSize); + + if (WinStatus != ERROR_SUCCESS) + { + fprintf(stderr, "Could not read %s data: %s\n", + Signature, WindowsFormatException(WinStatus)); + free(ReturnTable); + Status = AE_ERROR; + goto Cleanup; + } + + *Table = ReturnTable; + *Address = 0; + +Cleanup: + RegCloseKey(Handle); + return (Status); +} + /****************************************************************************** * @@ -335,189 +625,60 @@ AcpiOsGetTableByIndex ( *****************************************************************************/ ACPI_STATUS -AcpiOsGetTableByName ( - char *Signature, - UINT32 Instance, - ACPI_TABLE_HEADER **Table, - ACPI_PHYSICAL_ADDRESS *Address) +AcpiOsGetTableByName( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) { - HKEY Handle = NULL; - LONG WinStatus; - ULONG Type; - ULONG NameSize; - ULONG DataSize; - HKEY SubKey; - ULONG i; - ACPI_TABLE_HEADER *ReturnTable; - ACPI_STATUS Status = AE_OK; + LONG Result; + ACPI_STATUS Status = AE_OK; + UINT32 DataSize; + ACPI_TABLE_HEADER *ReturnTable; + UINT32 UIntSignature = 0; /* Multiple instances are only supported for SSDT tables. */ - if (Instance > 0 && !ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) - { - return (AE_LIMIT); - } + if (Instance > 0 && !ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) + { + return (AE_LIMIT); + } - /* Get a handle to the table key */ + if (ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) + { + Status = WindowsGetTableFromRegistry ("SSDT", Instance, Table, Address); + return (Status); + } - while (1) - { - strcpy (KeyBuffer, "HARDWARE\\ACPI\\"); - if (AcpiUtSafeStrcat (KeyBuffer, sizeof (KeyBuffer), Signature)) - { - return (AE_BUFFER_OVERFLOW); - } + /* GetSystemFirmwareTable requires the table signature to be UINT32 */ - /* - * Windows stores SSDT at SSDT, SSD1, ..., SSD9, SSDA, ..., SSDS, SSDT, - * SSDU, ..., SSDY. If the first (0th) and the 29th tables have the same - * OEM ID, Table ID and Revision, then the 29th entry will overwrite the - * first entry... Let's hope that we do not have that many entries. - */ - if (Instance > 0 && ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) - { - if (Instance < 10) - { - KeyBuffer[strlen (KeyBuffer) - 1] = '0' + (char) Instance; - } - else if (Instance < 29) - { - KeyBuffer[strlen (KeyBuffer) - 1] = 'A' + (char) (Instance - 10); - } - else - { - return (AE_LIMIT); - } - } + UIntSignature = *ACPI_CAST_PTR (UINT32, Signature); + DataSize = GetSystemFirmwareTable('ACPI', UIntSignature, NULL, 0); + if (!DataSize) + { + fprintf(stderr, "The table signature %s does not exist.", Signature); + return (AE_ERROR); + } - WinStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE, KeyBuffer, - 0L, KEY_READ, &Handle); + ReturnTable = malloc(DataSize); + if (!ReturnTable) + { + return (AE_NO_MEMORY); + } - if (WinStatus != ERROR_SUCCESS) - { - /* - * Somewhere along the way, MS changed the registry entry for - * the FADT from - * HARDWARE/ACPI/FACP to - * HARDWARE/ACPI/FADT. - * - * This code allows for both. - */ - if (ACPI_COMPARE_NAMESEG (Signature, "FACP")) - { - Signature = "FADT"; - } - else if (ACPI_COMPARE_NAMESEG (Signature, "XSDT")) - { - Signature = "RSDT"; - } - else if (ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_SSDT)) - { - /* SSDT may not be present on older Windows versions, but it is - * also possible that the index is not found. */ - return (AE_NOT_FOUND); - } - else - { - fprintf (stderr, - "Could not find %s in registry at %s: %s (WinStatus=0x%X)\n", - Signature, KeyBuffer, WindowsFormatException (WinStatus), WinStatus); - return (AE_NOT_FOUND); - } - } - else - { - break; - } - } + Result = GetSystemFirmwareTable('ACPI', UIntSignature, ReturnTable, DataSize); + if (Result > (LONG) DataSize) + { + /* Clean up */ - /* Actual data for the table is down a couple levels */ - - for (i = 0; ;) - { - WinStatus = RegEnumKey (Handle, i, KeyBuffer, sizeof (KeyBuffer)); - i++; - if (WinStatus == ERROR_NO_MORE_ITEMS) - { - break; - } - - WinStatus = RegOpenKey (Handle, KeyBuffer, &SubKey); - if (WinStatus != ERROR_SUCCESS) - { - fprintf (stderr, "Could not open %s entry: %s\n", - Signature, WindowsFormatException (WinStatus)); - Status = AE_ERROR; - goto Cleanup; - } - - RegCloseKey (Handle); - Handle = SubKey; - i = 0; - } - - /* Find the (binary) table entry */ - - for (i = 0; ; i++) - { - NameSize = sizeof (KeyBuffer); - WinStatus = RegEnumValue (Handle, i, KeyBuffer, &NameSize, NULL, - &Type, NULL, 0); - if (WinStatus != ERROR_SUCCESS) - { - fprintf (stderr, "Could not get %s registry entry: %s\n", - Signature, WindowsFormatException (WinStatus)); - Status = AE_ERROR; - goto Cleanup; - } - - if (Type == REG_BINARY) - { - break; - } - } - - /* Get the size of the table */ - - WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, - NULL, &DataSize); - if (WinStatus != ERROR_SUCCESS) - { - fprintf (stderr, "Could not read the %s table size: %s\n", - Signature, WindowsFormatException (WinStatus)); - Status = AE_ERROR; - goto Cleanup; - } - - /* Allocate a new buffer for the table */ - - ReturnTable = malloc (DataSize); - if (!ReturnTable) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Get the actual table from the registry */ - - WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, - (UCHAR *) ReturnTable, &DataSize); - if (WinStatus != ERROR_SUCCESS) - { - fprintf (stderr, "Could not read %s data: %s\n", - Signature, WindowsFormatException (WinStatus)); - free (ReturnTable); - Status = AE_ERROR; - goto Cleanup; - } + fprintf (stderr, "Could not read %s data\n", Signature); + free (ReturnTable); + return (AE_ERROR); + } *Table = ReturnTable; - *Address = 0; - -Cleanup: - RegCloseKey (Handle); - return (Status); + return (Status); } diff --git a/tests/misc/grammar.asl b/tests/misc/grammar.asl index 6eb77de6668..64e09afad4b 100644 --- a/tests/misc/grammar.asl +++ b/tests/misc/grammar.asl @@ -5692,7 +5692,7 @@ DefinitionBlock ( { Return (0x41) } // Local1 indicates Local0 is not a Number If (LEqual (Local0, 0)) // Number is type 1 - { Return (0x42) } // non-existant signal was acquired + { Return (0x42) } // non-existent signal was acquired Store ("Acquire signal timeout PASS", Debug) @@ -5713,7 +5713,7 @@ DefinitionBlock ( { Return (0x51) } // Local1 indicates Local0 is not a Number If (LEqual (Local0, 0)) // Number is type 1 - { Return (0x52) } // non-existant signal was acquired + { Return (0x52) } // non-existent signal was acquired Store ("Reset signal PASS", Debug) @@ -5727,7 +5727,7 @@ DefinitionBlock ( { Return (0x61) } // Local1 indicates Local0 is not a Number If (LEqual (Local0, 0)) // Number is type 1 - { Return (0x62) } // non-existant signal was acquired + { Return (0x62) } // non-existent signal was acquired Store ("Zero Lvalue PASS", Debug) @@ -5741,7 +5741,7 @@ DefinitionBlock ( { Return (0x71) } // Local1 indicates Local0 is not a Number If (LEqual (Local0, 0)) // Number is type 1 - { Return (0x72) } // non-existant signal was acquired + { Return (0x72) } // non-existent signal was acquired Store ("One Lvalue PASS", Debug) @@ -5782,7 +5782,7 @@ DefinitionBlock ( { Return (0x84) } // Local1 indicates Local0 is not a Number If (LEqual (Local0, 0)) // Number is type 1 - { Return (0x85) } // non-existant signal was acquired + { Return (0x85) } // non-existent signal was acquired Store ("Acquire Lvalue signal timeout PASS", Debug) diff --git a/tests/templates/templates.sh b/tests/templates/templates.sh index 06c08143df4..ce503698174 100755 --- a/tests/templates/templates.sh +++ b/tests/templates/templates.sh @@ -47,4 +47,3 @@ for f in $files ; do diff -pu -I" \*" $sig.asl $sig.dsl >> diff.log fi done - From 9fcda2f48d1c362e097f553e97d3739c484b09a9 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 14 Feb 2020 19:33:50 +0000 Subject: [PATCH 02/22] Update OpenSSH upgrade instructions to use https, not ftp ftp://ftp.openbsd.org/ does not work. --- crypto/openssh/FREEBSD-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade index 35f6595fe24..7ec9c6aac3c 100644 --- a/crypto/openssh/FREEBSD-upgrade +++ b/crypto/openssh/FREEBSD-upgrade @@ -5,7 +5,7 @@ pretty fast once you're done with this checklist. 01) Download the latest OpenSSH-portable tarball and signature from - OpenBSD (ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/). + OpenBSD (https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/). 02) Verify the signature: From 1881ae23a3a3a7f209e00f5ac613d95b0350b334 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 14 Feb 2020 20:25:04 +0000 Subject: [PATCH 03/22] mips: fix kernel build after r357804 Drop the padding down the size of a single uintptr_t to account for pc_zpcpu_offset --- sys/mips/include/pcpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/mips/include/pcpu.h b/sys/mips/include/pcpu.h index 031f452614c..fea594729e9 100644 --- a/sys/mips/include/pcpu.h +++ b/sys/mips/include/pcpu.h @@ -57,7 +57,7 @@ vm_offset_t pc_cmap2_addr; /* KVA page for copy window 2 */ \ vm_offset_t pc_qmap_addr; /* KVA page for temporary mappings */ \ pt_entry_t *pc_qmap_ptep; /* PTE for temporary mapping KVA */ \ - char __pad[101] + char __pad[97] #endif #ifdef __mips_n64 From 23f6a81e4930c69f1fdcbb90de30ce03561bb4cf Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 14 Feb 2020 22:32:33 +0000 Subject: [PATCH 04/22] Update version in openssh FREEBSD-vendor metadata It appears that FREEBSD-vendor is an idea that never really took off and we should probably just remove it, but until then we might as well record the correct version. --- crypto/openssh/FREEBSD-vendor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/openssh/FREEBSD-vendor b/crypto/openssh/FREEBSD-vendor index 0fa56d03f5d..f48cbb6c307 100644 --- a/crypto/openssh/FREEBSD-vendor +++ b/crypto/openssh/FREEBSD-vendor @@ -1,6 +1,6 @@ # $FreeBSD$ Project: Portable OpenSSH ProjectURL: http://www.openssh.com/portable.html -Version: 5.2p1 +Version: 7.9p1 License: BSD Maintainer: des From 082a6b2a92888cf799c7a0408a78e2d7ad9320bb Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:15:41 +0000 Subject: [PATCH 05/22] Make atomic_load_ptr type-aware Returned value has type based on the argument, meaning consumers no longer have to cast in the commmon case. This commit keeps the kernel compilable without patching the rest. --- sys/amd64/amd64/pmap.c | 6 +++--- sys/sys/_cscan_atomic.h | 6 +++++- sys/sys/atomic_common.h | 2 +- sys/x86/x86/mp_x86.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 3f1963954c9..4542612c2e9 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -796,7 +796,7 @@ again: PV_STAT(i = 0); for (p = &pmap_invl_gen_head;; p = prev.next) { PV_STAT(i++); - prevl = atomic_load_ptr(&p->next); + prevl = (uintptr_t)atomic_load_ptr(&p->next); if ((prevl & PMAP_INVL_GEN_NEXT_INVALID) != 0) { PV_STAT(atomic_add_long(&invl_start_restart, 1)); lock_delay(&lda); @@ -903,7 +903,7 @@ pmap_delayed_invl_finish_u(void) again: for (p = &pmap_invl_gen_head; p != NULL; p = (void *)prevl) { - prevl = atomic_load_ptr(&p->next); + prevl = (uintptr_t)atomic_load_ptr(&p->next); if ((prevl & PMAP_INVL_GEN_NEXT_INVALID) != 0) { PV_STAT(atomic_add_long(&invl_finish_restart, 1)); lock_delay(&lda); @@ -954,7 +954,7 @@ DB_SHOW_COMMAND(di_queue, pmap_di_queue) for (p = &pmap_invl_gen_head, first = true; p != NULL; p = pn, first = false) { - nextl = atomic_load_ptr(&p->next); + nextl = (uintptr_t)atomic_load_ptr(&p->next); pn = (void *)(nextl & ~PMAP_INVL_GEN_NEXT_INVALID); td = first ? NULL : __containerof(p, struct thread, td_md.md_invl_gen); diff --git a/sys/sys/_cscan_atomic.h b/sys/sys/_cscan_atomic.h index 93c557bcee5..045f66c0556 100644 --- a/sys/sys/_cscan_atomic.h +++ b/sys/sys/_cscan_atomic.h @@ -170,7 +170,11 @@ void kcsan_atomic_thread_fence_seq_cst(void); #define atomic_fcmpset_acq_ptr kcsan_atomic_fcmpset_acq_ptr #define atomic_fcmpset_rel_ptr kcsan_atomic_fcmpset_rel_ptr #define atomic_fetchadd_ptr kcsan_atomic_fetchadd_ptr -#define atomic_load_ptr(x) kcsan_atomic_load_ptr((volatile uintptr_t *)(x)) +#define atomic_load_ptr(x) ({ \ + __typeof(*x) __retptr; \ + __retptr = (void *)kcsan_atomic_load_ptr((volatile uintptr_t *)(x)); \ + __retptr; \ +}) #define atomic_load_acq_ptr kcsan_atomic_load_acq_ptr #define atomic_readandclear_ptr kcsan_atomic_readandclear_ptr #define atomic_set_ptr kcsan_atomic_set_ptr diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h index 889d491cc1a..63311b5a312 100644 --- a/sys/sys/atomic_common.h +++ b/sys/sys/atomic_common.h @@ -41,7 +41,7 @@ #define atomic_load_short(p) (*(volatile u_short *)(p)) #define atomic_load_int(p) (*(volatile u_int *)(p)) #define atomic_load_long(p) (*(volatile u_long *)(p)) -#define atomic_load_ptr(p) (*(volatile uintptr_t*)(p)) +#define atomic_load_ptr(p) (*(volatile __typeof(p))(p)) #define atomic_load_8(p) (*(volatile uint8_t *)(p)) #define atomic_load_16(p) (*(volatile uint16_t *)(p)) #define atomic_load_32(p) (*(volatile uint32_t *)(p)) diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 5aec0e09414..e8d8b980174 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -1106,7 +1106,7 @@ smp_after_idle_runnable(void *arg __unused) for (cpu = 1; cpu < mp_ncpus; cpu++) { pc = pcpu_find(cpu); - while (atomic_load_ptr(&pc->pc_curpcb) == (uintptr_t)NULL) + while (atomic_load_ptr(&pc->pc_curpcb) == NULL) cpu_spinwait(); kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages * PAGE_SIZE); From 23ed568caa61b05a0b69e06b413ff6b3061bbb3b Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:16:29 +0000 Subject: [PATCH 06/22] vm: remove no longer needed atomic_load_ptr casts --- sys/vm/vm_mmap.c | 3 +-- sys/vm/vm_page.c | 8 +++----- sys/vm/vm_pageout.c | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 092673c706a..b87f7612c5e 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -895,8 +895,7 @@ retry: while (object == NULL || m->object != object) { if (object != NULL) VM_OBJECT_WUNLOCK(object); - object = (vm_object_t)atomic_load_ptr( - &m->object); + object = atomic_load_ptr(&m->object); if (object == NULL) goto retry; VM_OBJECT_WLOCK(object); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 087604d534a..3b281d7a9e2 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2500,8 +2500,7 @@ retry: pa); } #endif - else if ((object = - (vm_object_t)atomic_load_ptr(&m->object)) != NULL) { + else if ((object = atomic_load_ptr(&m->object)) != NULL) { /* * The page is considered eligible for relocation if * and only if it could be laundered or reclaimed by @@ -2643,8 +2642,7 @@ vm_page_reclaim_run(int req_class, int domain, u_long npages, vm_page_t m_run, */ if (vm_page_wired(m)) error = EBUSY; - else if ((object = - (vm_object_t)atomic_load_ptr(&m->object)) != NULL) { + else if ((object = atomic_load_ptr(&m->object)) != NULL) { /* * The page is relocated if and only if it could be * laundered or reclaimed by the page daemon. @@ -4065,7 +4063,7 @@ vm_page_release(vm_page_t m, int flags) if ((flags & VPR_TRYFREE) != 0) { for (;;) { - object = (vm_object_t)atomic_load_ptr(&m->object); + object = atomic_load_ptr(&m->object); if (object == NULL) break; /* Depends on type-stability. */ diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index e660a4c2552..d045fc34329 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -767,7 +767,7 @@ scan: if (object == NULL || object != m->object) { if (object != NULL) VM_OBJECT_WUNLOCK(object); - object = (vm_object_t)atomic_load_ptr(&m->object); + object = atomic_load_ptr(&m->object); if (__predict_false(object == NULL)) /* The page is being freed by another thread. */ continue; @@ -1238,7 +1238,7 @@ act_scan: * A page's object pointer may be set to NULL before * the object lock is acquired. */ - object = (vm_object_t)atomic_load_ptr(&m->object); + object = atomic_load_ptr(&m->object); if (__predict_false(object == NULL)) /* * The page has been removed from its object. @@ -1481,7 +1481,7 @@ vm_pageout_scan_inactive(struct vm_domain *vmd, int shortage, if (object == NULL || object != m->object) { if (object != NULL) VM_OBJECT_WUNLOCK(object); - object = (vm_object_t)atomic_load_ptr(&m->object); + object = atomic_load_ptr(&m->object); if (__predict_false(object == NULL)) /* The page is being freed by another thread. */ continue; From a201ef9d8284e195d4b3d6d3fba9e30cdde8df1c Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:17:03 +0000 Subject: [PATCH 07/22] amd64: remove no longer needed atomic_load_ptr casts --- sys/amd64/amd64/trap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 2dda8f41b71..ecd2edc94a8 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -932,7 +932,7 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *)) { int (*hook)(struct trapframe *); - hook = (int (*)(struct trapframe *))atomic_load_ptr(hookp); + hook = atomic_load_ptr(hookp); enable_intr(); if (hook != NULL) return ((hook)(frame) == 0); @@ -1075,7 +1075,7 @@ amd64_syscall_ret_flush_l1d_check(int error) if (error != EEXIST && error != EAGAIN && error != EXDEV && error != ENOENT && error != ENOTCONN && error != EINPROGRESS) { - p = (void *)atomic_load_ptr(&syscall_ret_l1d_flush); + p = atomic_load_ptr(&syscall_ret_l1d_flush); if (p != NULL) p(); } From f50a2474b787306cd73fe889cfc3976db3a23a36 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:17:18 +0000 Subject: [PATCH 08/22] arm64: remove no longer needed atomic_load_ptr casts --- sys/arm64/arm64/gicv3_its.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index e69981f1b68..869e424687f 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -547,7 +547,7 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) { void *conf_table; - conf_table = (void *)atomic_load_ptr((uintptr_t *)&conf_base); + conf_table = atomic_load_ptr(&conf_base); if (conf_table == NULL) { conf_table = contigmalloc(LPI_CONFTAB_SIZE, M_GICV3_ITS, M_WAITOK, 0, LPI_CONFTAB_MAX_ADDR, @@ -556,8 +556,7 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) if (atomic_cmpset_ptr((uintptr_t *)&conf_base, (uintptr_t)NULL, (uintptr_t)conf_table) == 0) { contigfree(conf_table, LPI_CONFTAB_SIZE, M_GICV3_ITS); - conf_table = - (void *)atomic_load_ptr((uintptr_t *)&conf_base); + conf_table = atomic_load_ptr(&conf_base); } } sc->sc_conf_base = conf_table; From 4ef55e371ab1a13fa28b4d33688c57fab83c3b1b Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:17:37 +0000 Subject: [PATCH 09/22] i386: remove no longer needed atomic_load_ptr casts --- sys/i386/i386/trap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 9ba4428beb4..54b28b80ef7 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -976,7 +976,7 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *)) { int (*hook)(struct trapframe *); - hook = (int (*)(struct trapframe *))atomic_load_ptr(hookp); + hook = atomic_load_ptr(hookp); enable_intr(); if (hook != NULL) return ((hook)(frame) == 0); From 5bc6a91f546f819bc581f601396abf3cda582c9c Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:18:03 +0000 Subject: [PATCH 10/22] kcov: remove no longer needed atomic_load_ptr casts --- sys/kern/subr_coverage.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/kern/subr_coverage.c b/sys/kern/subr_coverage.c index 0c1b280a135..e38f3b36e78 100644 --- a/sys/kern/subr_coverage.c +++ b/sys/kern/subr_coverage.c @@ -95,7 +95,7 @@ __sanitizer_cov_trace_pc(void) { cov_trace_pc_t trace_pc; - trace_pc = (cov_trace_pc_t)atomic_load_ptr(&cov_trace_pc); + trace_pc = atomic_load_ptr(&cov_trace_pc); if (trace_pc != NULL) trace_pc((uint64_t)__builtin_return_address(0)); } @@ -110,7 +110,7 @@ __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(0), arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -121,7 +121,7 @@ __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(1), arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -132,7 +132,7 @@ __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(2), arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -143,7 +143,7 @@ __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(3), arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -154,7 +154,7 @@ __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(0) | COV_CMP_CONST, arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -165,7 +165,7 @@ __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(1) | COV_CMP_CONST, arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -176,7 +176,7 @@ __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(2) | COV_CMP_CONST, arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -187,7 +187,7 @@ __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) { cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp != NULL) trace_cmp(COV_CMP_SIZE(3) | COV_CMP_CONST, arg1, arg2, (uint64_t)__builtin_return_address(0)); @@ -205,7 +205,7 @@ __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) uint64_t i, count, ret, type; cov_trace_cmp_t trace_cmp; - trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); + trace_cmp = atomic_load_ptr(&cov_trace_cmp); if (trace_cmp == NULL) return; From 8f86349f8b59d22607508cd850040ad05ab77d17 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:18:22 +0000 Subject: [PATCH 11/22] fd: remove no longer needed atomic_load_ptr casts --- sys/kern/kern_descrip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 9d98275785f..024af05d8f7 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -847,7 +847,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) * and any vfs op on this vnode going forward will return an * error (meaning return value in this case is meaningless). */ - mp = (struct mount *)atomic_load_ptr(&vp->v_mount); + mp = atomic_load_ptr(&vp->v_mount); if (__predict_false(mp == NULL)) { fdrop(fp, td); error = EBADF; @@ -2741,7 +2741,7 @@ fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, * table before this fd was closed, so it is possible * that there is a stale fp pointer in cached version. */ - fdt = (struct fdescenttbl *)atomic_load_ptr(&fdp->fd_files); + fdt = atomic_load_ptr(&fdp->fd_files); continue; } /* From df0d5a2a85db5485571448955a32e323eb3528f6 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 23:18:32 +0000 Subject: [PATCH 12/22] vfs: remove no longer needed atomic_load_ptr casts --- sys/kern/vfs_subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d3a4947938d..0ba7b22f89e 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6139,7 +6139,7 @@ vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp) if (!vfs_op_thread_enter(mp)) return (vfs_cache_root_fallback(mp, flags, vpp)); - vp = (struct vnode *)atomic_load_ptr(&mp->mnt_rootvnode); + vp = atomic_load_ptr(&mp->mnt_rootvnode); if (vp == NULL || VN_IS_DOOMED(vp)) { vfs_op_thread_exit(mp); return (vfs_cache_root_fallback(mp, flags, vpp)); From 6cf2362e2c7e9061611f93a48ec654a5b7451d6b Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 14 Feb 2020 23:27:45 +0000 Subject: [PATCH 13/22] Consolidate read code for timecounters and fix possible overflow in bintime()/binuptime(). The algorithm to read the consistent snapshot of current timehand is repeated in each accessor, including the details proper rollup detection and synchronization with the writer. In fact there are only two different kind of readers: one for bintime()/binuptime() which has to do the in-place calculation, and another kind which fetches some member from struct timehand. Extract the logic into type-checked macros, GETTHBINTIME() for bintime calculation, and GETTHMEMBER() for safe read of a structure' member. This way, the synchronization is only written in bintime_off() and getthmember(). In bintime_off(), use overflow-safe calculation of th_scale * delta(timecounter). In tc_windup, pre-calculate the min delta value which overflows and require slow algorithm, into the new timehands th_large_delta member. This part with overflow fix was written by Bruce Evans. Reported by: Mark Millard (the overflow issue) Tested by: pho Discussed with: emaste Sponsored by: The FreeBSD Foundation (kib) MFC after: 3 weeks --- sys/kern/kern_tc.c | 232 +++++++++++++++++---------------------------- 1 file changed, 87 insertions(+), 145 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 75ea0d37334..cfb63fb8d02 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -72,6 +72,7 @@ struct timehands { struct timecounter *th_counter; int64_t th_adjustment; uint64_t th_scale; + u_int th_large_delta; u_int th_offset_count; struct bintime th_offset; struct bintime th_bintime; @@ -87,6 +88,7 @@ static struct timehands ths[16] = { [0] = { .th_counter = &dummy_timecounter, .th_scale = (uint64_t)-1 / 1000000, + .th_large_delta = 1000000, .th_offset = { .sec = 1 }, .th_generation = 1, }, @@ -202,20 +204,72 @@ tc_delta(struct timehands *th) * the comment in for a description of these 12 functions. */ -#ifdef FFCLOCK -void -fbclock_binuptime(struct bintime *bt) +static __inline void +bintime_off(struct bintime *bt, u_int off) { struct timehands *th; - unsigned int gen; + struct bintime *btp; + uint64_t scale, x; + u_int delta, gen, large_delta; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_offset; - bintime_addx(bt, th->th_scale * tc_delta(th)); + btp = (struct bintime *)((vm_offset_t)th + off); + *bt = *btp; + scale = th->th_scale; + delta = tc_delta(th); + large_delta = th->th_large_delta; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); + + if (__predict_false(delta >= large_delta)) { + /* Avoid overflow for scale * delta. */ + x = (scale >> 32) * delta; + bt->sec += x >> 32; + bintime_addx(bt, x << 32); + bintime_addx(bt, (scale & 0xffffffff) * delta); + } else { + bintime_addx(bt, scale * delta); + } +} +#define GETTHBINTIME(dst, member) \ +do { \ + _Static_assert(_Generic(((struct timehands *)NULL)->member, \ + struct bintime: 1, default: 0) == 1, \ + "struct timehands member is not of struct bintime type"); \ + bintime_off(dst, __offsetof(struct timehands, member)); \ +} while (0) + +static __inline void +getthmember(void *out, size_t out_size, u_int off) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + memcpy(out, (char *)th + off, out_size); + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); +} +#define GETTHMEMBER(dst, member) \ +do { \ + _Static_assert(_Generic(*dst, \ + __typeof(((struct timehands *)NULL)->member): 1, \ + default: 0) == 1, \ + "*dst and struct timehands member have different types"); \ + getthmember(dst, sizeof(*dst), __offsetof(struct timehands, \ + member)); \ +} while (0) + +#ifdef FFCLOCK +void +fbclock_binuptime(struct bintime *bt) +{ + + GETTHBINTIME(bt, th_offset); } void @@ -239,16 +293,8 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { - struct timehands *th; - unsigned int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_bintime; - bintime_addx(bt, th->th_scale * tc_delta(th)); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHBINTIME(bt, th_bintime); } void @@ -272,100 +318,55 @@ fbclock_microtime(struct timeval *tvp) void fbclock_getbinuptime(struct bintime *bt) { - struct timehands *th; - unsigned int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_offset; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(bt, th_offset); } void fbclock_getnanouptime(struct timespec *tsp) { - struct timehands *th; - unsigned int gen; + struct bintime bt; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - bintime2timespec(&th->th_offset, tsp); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(&bt, th_offset); + bintime2timespec(&bt, tsp); } void fbclock_getmicrouptime(struct timeval *tvp) { - struct timehands *th; - unsigned int gen; + struct bintime bt; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - bintime2timeval(&th->th_offset, tvp); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(&bt, th_offset); + bintime2timeval(&bt, tvp); } void fbclock_getbintime(struct bintime *bt) { - struct timehands *th; - unsigned int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_bintime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(bt, th_bintime); } void fbclock_getnanotime(struct timespec *tsp) { - struct timehands *th; - unsigned int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *tsp = th->th_nanotime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(tsp, th_nanotime); } void fbclock_getmicrotime(struct timeval *tvp) { - struct timehands *th; - unsigned int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *tvp = th->th_microtime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(tvp, th_microtime); } #else /* !FFCLOCK */ + void binuptime(struct bintime *bt) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_offset; - bintime_addx(bt, th->th_scale * tc_delta(th)); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHBINTIME(bt, th_offset); } void @@ -389,16 +390,8 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_bintime; - bintime_addx(bt, th->th_scale * tc_delta(th)); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHBINTIME(bt, th_bintime); } void @@ -422,85 +415,47 @@ microtime(struct timeval *tvp) void getbinuptime(struct bintime *bt) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_offset; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(bt, th_offset); } void getnanouptime(struct timespec *tsp) { - struct timehands *th; - u_int gen; + struct bintime bt; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - bintime2timespec(&th->th_offset, tsp); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(&bt, th_offset); + bintime2timespec(&bt, tsp); } void getmicrouptime(struct timeval *tvp) { - struct timehands *th; - u_int gen; + struct bintime bt; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - bintime2timeval(&th->th_offset, tvp); - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(&bt, th_offset); + bintime2timeval(&bt, tvp); } void getbintime(struct bintime *bt) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_bintime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(bt, th_bintime); } void getnanotime(struct timespec *tsp) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *tsp = th->th_nanotime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(tsp, th_nanotime); } void getmicrotime(struct timeval *tvp) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *tvp = th->th_microtime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(tvp, th_microtime); } #endif /* FFCLOCK */ @@ -516,15 +471,8 @@ getboottime(struct timeval *boottime) void getboottimebin(struct bintime *boottimebin) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *boottimebin = th->th_boottime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(boottimebin, th_boottime); } #ifdef FFCLOCK @@ -1040,15 +988,8 @@ getmicrotime(struct timeval *tvp) void dtrace_getnanotime(struct timespec *tsp) { - struct timehands *th; - u_int gen; - do { - th = timehands; - gen = atomic_load_acq_int(&th->th_generation); - *tsp = th->th_nanotime; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != th->th_generation); + GETTHMEMBER(tsp, th_nanotime); } /* @@ -1466,6 +1407,7 @@ tc_windup(struct bintime *new_boottimebin) scale += (th->th_adjustment / 1024) * 2199; scale /= th->th_counter->tc_frequency; th->th_scale = scale * 2; + th->th_large_delta = MIN(((uint64_t)1 << 63) / scale, UINT_MAX); /* * Now that the struct timehands is again consistent, set the new From fad5873462454df977e07f751db7022612d9f333 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:28:06 +0000 Subject: [PATCH 14/22] capsicum: add cap_rights_init_zero, cap_rights_init_one, cap_rights_set_one ... which allow the compiler to generate relevant code in place without resorting to calling to a routine at runtime. --- sys/sys/capsicum.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/sys/capsicum.h b/sys/sys/capsicum.h index 8bc5195bdfe..6da1722eaaf 100644 --- a/sys/sys/capsicum.h +++ b/sys/sys/capsicum.h @@ -351,6 +351,27 @@ void __cap_rights_sysinit(void *arg); _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00, "unsupported version of capsicum rights"); +#define cap_rights_init_zero(r) ({ \ + cap_rights_t *_r = (r); \ + CAP_NONE(_r); \ + _r; \ +}) + +#define cap_rights_init_one(r, right) ({ \ + CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \ + cap_rights_t *_r = (r); \ + CAP_NONE(_r); \ + _r->cr_rights[CAPIDXBIT(right) - 1] |= right; \ + _r; \ +}) + +#define cap_rights_set_one(r, right) ({ \ + CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \ + cap_rights_t *_r = (r); \ + _r->cr_rights[CAPIDXBIT(right) - 1] |= right; \ + _r; \ +}) + /* * Allow checking caps which are possibly getting modified at the same time. * The caller is expected to determine whether the result is legitimate via From e126c5a3e8a9880dd79a58840f256d3ffcb3f302 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:28:42 +0000 Subject: [PATCH 15/22] vfs: use new capsicum helpers --- sys/kern/vfs_acl.c | 8 ++++---- sys/kern/vfs_extattr.c | 8 ++++---- sys/kern/vfs_lookup.c | 6 +++--- sys/kern/vfs_syscalls.c | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index 9479706d041..aeefd21b374 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -436,7 +436,7 @@ sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap) AUDIT_ARG_FD(uap->filedes); error = getvnode(td, uap->filedes, - cap_rights_init(&rights, CAP_ACL_GET), &fp); + cap_rights_init_one(&rights, CAP_ACL_GET), &fp); if (error == 0) { error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp); fdrop(fp, td); @@ -456,7 +456,7 @@ sys___acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap) AUDIT_ARG_FD(uap->filedes); error = getvnode(td, uap->filedes, - cap_rights_init(&rights, CAP_ACL_SET), &fp); + cap_rights_init_one(&rights, CAP_ACL_SET), &fp); if (error == 0) { error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp); fdrop(fp, td); @@ -512,7 +512,7 @@ sys___acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap) AUDIT_ARG_FD(uap->filedes); error = getvnode(td, uap->filedes, - cap_rights_init(&rights, CAP_ACL_DELETE), &fp); + cap_rights_init_one(&rights, CAP_ACL_DELETE), &fp); if (error == 0) { error = vacl_delete(td, fp->f_vnode, uap->type); fdrop(fp, td); @@ -569,7 +569,7 @@ sys___acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap) AUDIT_ARG_FD(uap->filedes); error = getvnode(td, uap->filedes, - cap_rights_init(&rights, CAP_ACL_CHECK), &fp); + cap_rights_init_one(&rights, CAP_ACL_CHECK), &fp); if (error == 0) { error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp); fdrop(fp, td); diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 11867ead52a..1be73b95c0e 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -243,7 +243,7 @@ sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap) AUDIT_ARG_TEXT(attrname); error = getvnode(td, uap->fd, - cap_rights_init(&rights, CAP_EXTATTR_SET), &fp); + cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp); if (error) return (error); @@ -410,7 +410,7 @@ sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap) AUDIT_ARG_TEXT(attrname); error = getvnode(td, uap->fd, - cap_rights_init(&rights, CAP_EXTATTR_GET), &fp); + cap_rights_init_one(&rights, CAP_EXTATTR_GET), &fp); if (error) return (error); @@ -545,7 +545,7 @@ sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap) AUDIT_ARG_TEXT(attrname); error = getvnode(td, uap->fd, - cap_rights_init(&rights, CAP_EXTATTR_DELETE), &fp); + cap_rights_init_one(&rights, CAP_EXTATTR_DELETE), &fp); if (error) return (error); @@ -691,7 +691,7 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap) AUDIT_ARG_FD(uap->fd); AUDIT_ARG_VALUE(uap->attrnamespace); error = getvnode(td, uap->fd, - cap_rights_init(&rights, CAP_EXTATTR_LIST), &fp); + cap_rights_init_one(&rights, CAP_EXTATTR_LIST), &fp); if (error) return (error); diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index dd415726526..1659598d5e4 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -440,7 +440,7 @@ namei(struct nameidata *ndp) } else { vrefact(ndp->ni_rootdir); rights = ndp->ni_rightsneeded; - cap_rights_set(&rights, CAP_LOOKUP); + cap_rights_set_one(&rights, CAP_LOOKUP); if (cnp->cn_flags & AUDITVNODE1) AUDIT_ARG_ATFD1(ndp->ni_dirfd); @@ -493,7 +493,7 @@ namei(struct nameidata *ndp) vrefact(ndp->ni_beneath_latch); } else { rights = ndp->ni_rightsneeded; - cap_rights_set(&rights, CAP_LOOKUP); + cap_rights_set_one(&rights, CAP_LOOKUP); error = fgetvp_rights(td, ndp->ni_dirfd, &rights, &dirfd_caps, &ndp->ni_beneath_latch); if (error == 0 && dp->v_type != VDIR) { @@ -1344,7 +1344,7 @@ NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags, enum uio_seg segflg, if (rightsp != NULL) ndp->ni_rightsneeded = *rightsp; else - cap_rights_init(&ndp->ni_rightsneeded); + cap_rights_init_zero(&ndp->ni_rightsneeded); } /* diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 162051f666b..136337449a2 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -966,34 +966,34 @@ flags_to_rights(int flags, cap_rights_t *rightsp) { if (flags & O_EXEC) { - cap_rights_set(rightsp, CAP_FEXECVE); + cap_rights_set_one(rightsp, CAP_FEXECVE); } else { switch ((flags & O_ACCMODE)) { case O_RDONLY: - cap_rights_set(rightsp, CAP_READ); + cap_rights_set_one(rightsp, CAP_READ); break; case O_RDWR: - cap_rights_set(rightsp, CAP_READ); + cap_rights_set_one(rightsp, CAP_READ); /* FALLTHROUGH */ case O_WRONLY: - cap_rights_set(rightsp, CAP_WRITE); + cap_rights_set_one(rightsp, CAP_WRITE); if (!(flags & (O_APPEND | O_TRUNC))) - cap_rights_set(rightsp, CAP_SEEK); + cap_rights_set_one(rightsp, CAP_SEEK); break; } } if (flags & O_CREAT) - cap_rights_set(rightsp, CAP_CREATE); + cap_rights_set_one(rightsp, CAP_CREATE); if (flags & O_TRUNC) - cap_rights_set(rightsp, CAP_FTRUNCATE); + cap_rights_set_one(rightsp, CAP_FTRUNCATE); if (flags & (O_SYNC | O_FSYNC)) - cap_rights_set(rightsp, CAP_FSYNC); + cap_rights_set_one(rightsp, CAP_FSYNC); if (flags & (O_EXLOCK | O_SHLOCK)) - cap_rights_set(rightsp, CAP_FLOCK); + cap_rights_set_one(rightsp, CAP_FLOCK); } /* @@ -1048,7 +1048,7 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, AUDIT_ARG_FFLAGS(flags); AUDIT_ARG_MODE(mode); - cap_rights_init(&rights, CAP_LOOKUP); + cap_rights_init_one(&rights, CAP_LOOKUP); flags_to_rights(flags, &rights); /* * Only one of the O_EXEC, O_RDONLY, O_WRONLY and O_RDWR flags @@ -3752,7 +3752,7 @@ kern_frmdirat(struct thread *td, int dfd, const char *path, int fd, fp = NULL; if (fd != FD_NONE) { - error = getvnode(td, fd, cap_rights_init(&rights, CAP_LOOKUP), + error = getvnode(td, fd, cap_rights_init_one(&rights, CAP_LOOKUP), &fp); if (error != 0) return (error); From 32a86c44ee7f82e11b2993f2c68a99b428251675 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:28:55 +0000 Subject: [PATCH 16/22] fd: use new capsicum helpers --- sys/kern/kern_descrip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 024af05d8f7..45975c79f36 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3601,7 +3601,7 @@ export_file_to_kinfo(struct file *fp, int fd, cap_rights_t *rightsp, if (rightsp != NULL) kif->kf_cap_rights = *rightsp; else - cap_rights_init(&kif->kf_cap_rights); + cap_rights_init_zero(&kif->kf_cap_rights); kif->kf_fd = fd; kif->kf_ref_count = fp->f_count; kif->kf_offset = foffset_get(fp); @@ -3632,7 +3632,7 @@ export_vnode_to_kinfo(struct vnode *vp, int fd, int fflags, if (error == 0) kif->kf_status |= KF_ATTR_VALID; kif->kf_flags = xlate_fflags(fflags); - cap_rights_init(&kif->kf_cap_rights); + cap_rights_init_zero(&kif->kf_cap_rights); kif->kf_fd = fd; kif->kf_ref_count = -1; kif->kf_offset = -1; From 3379d2f926cafb6eb6e56f15af2ba77489b45b73 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:29:07 +0000 Subject: [PATCH 17/22] vm: use new capsicum helpers --- sys/vm/vm_mmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index b87f7612c5e..018bcde6276 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -389,15 +389,15 @@ kern_mmap_fpcheck(struct thread *td, uintptr_t addr0, size_t len, int prot, * rights, but also return the maximum rights to be combined * with maxprot later. */ - cap_rights_init(&rights, CAP_MMAP); + cap_rights_init_one(&rights, CAP_MMAP); if (prot & PROT_READ) - cap_rights_set(&rights, CAP_MMAP_R); + cap_rights_set_one(&rights, CAP_MMAP_R); if ((flags & MAP_SHARED) != 0) { if (prot & PROT_WRITE) - cap_rights_set(&rights, CAP_MMAP_W); + cap_rights_set_one(&rights, CAP_MMAP_W); } if (prot & PROT_EXEC) - cap_rights_set(&rights, CAP_MMAP_X); + cap_rights_set_one(&rights, CAP_MMAP_X); error = fget_mmap(td, fd, &rights, &cap_maxprot, &fp); if (error != 0) goto done; From 6b25673f3f39264bc331001e517a3442c4a29852 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:29:40 +0000 Subject: [PATCH 18/22] sctp: use new capsicum helpers --- sys/netinet/sctp_syscalls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/sctp_syscalls.c b/sys/netinet/sctp_syscalls.c index fe95a197e8a..52631f7fc5a 100644 --- a/sys/netinet/sctp_syscalls.c +++ b/sys/netinet/sctp_syscalls.c @@ -219,14 +219,14 @@ sys_sctp_generic_sendmsg (td, uap) u_sinfo = &sinfo; } - cap_rights_init(&rights, CAP_SEND); + cap_rights_init_one(&rights, CAP_SEND); if (uap->tolen != 0) { error = getsockaddr(&to, uap->to, uap->tolen); if (error != 0) { to = NULL; goto sctp_bad2; } - cap_rights_set(&rights, CAP_CONNECT); + cap_rights_set_one(&rights, CAP_CONNECT); } AUDIT_ARG_FD(uap->sd); @@ -332,14 +332,14 @@ sys_sctp_generic_sendmsg_iov(td, uap) return (error); u_sinfo = &sinfo; } - cap_rights_init(&rights, CAP_SEND); + cap_rights_init_one(&rights, CAP_SEND); if (uap->tolen != 0) { error = getsockaddr(&to, uap->to, uap->tolen); if (error != 0) { to = NULL; goto sctp_bad2; } - cap_rights_set(&rights, CAP_CONNECT); + cap_rights_set_one(&rights, CAP_CONNECT); } AUDIT_ARG_FD(uap->sd); From 5af9cdaf8a58831705281199a41dcaba1a67d343 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:29:58 +0000 Subject: [PATCH 19/22] cloudabi: use new capsicum helpers --- sys/compat/cloudabi/cloudabi_file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/compat/cloudabi/cloudabi_file.c b/sys/compat/cloudabi/cloudabi_file.c index 6b9225b9341..f998809665b 100644 --- a/sys/compat/cloudabi/cloudabi_file.c +++ b/sys/compat/cloudabi/cloudabi_file.c @@ -214,7 +214,7 @@ cloudabi_sys_file_open(struct thread *td, fds.fs_rights_base | fds.fs_rights_inheriting, &rights); if (error != 0) return (error); - cap_rights_set(&rights, CAP_LOOKUP); + cap_rights_set_one(&rights, CAP_LOOKUP); /* Convert rights to corresponding access mode. */ read = (fds.fs_rights_base & (CLOUDABI_RIGHT_FD_READ | @@ -227,7 +227,7 @@ cloudabi_sys_file_open(struct thread *td, /* Convert open flags. */ if ((uap->oflags & CLOUDABI_O_CREAT) != 0) { fflags |= O_CREAT; - cap_rights_set(&rights, CAP_CREATE); + cap_rights_set_one(&rights, CAP_CREATE); } if ((uap->oflags & CLOUDABI_O_DIRECTORY) != 0) fflags |= O_DIRECTORY; @@ -235,7 +235,7 @@ cloudabi_sys_file_open(struct thread *td, fflags |= O_EXCL; if ((uap->oflags & CLOUDABI_O_TRUNC) != 0) { fflags |= O_TRUNC; - cap_rights_set(&rights, CAP_FTRUNCATE); + cap_rights_set_one(&rights, CAP_FTRUNCATE); } if ((fds.fs_flags & CLOUDABI_FDFLAG_APPEND) != 0) fflags |= O_APPEND; @@ -244,12 +244,12 @@ cloudabi_sys_file_open(struct thread *td, if ((fds.fs_flags & (CLOUDABI_FDFLAG_SYNC | CLOUDABI_FDFLAG_DSYNC | CLOUDABI_FDFLAG_RSYNC)) != 0) { fflags |= O_SYNC; - cap_rights_set(&rights, CAP_FSYNC); + cap_rights_set_one(&rights, CAP_FSYNC); } if ((uap->dirfd.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) == 0) fflags |= O_NOFOLLOW; if (write && (fflags & (O_APPEND | O_TRUNC)) == 0) - cap_rights_set(&rights, CAP_SEEK); + cap_rights_set_one(&rights, CAP_SEEK); /* Allocate new file descriptor. */ error = falloc_noinstall(td, &fp); From 445faddf7f158fa5ae3f07168a5ddb7f02d88831 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:30:13 +0000 Subject: [PATCH 20/22] kqueue: use new capsicum helpers --- sys/kern/kern_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 28d43b2a34e..c87a3810849 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1195,11 +1195,11 @@ kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct file *fp; int error; - cap_rights_init(&rights); + cap_rights_init_zero(&rights); if (nchanges > 0) - cap_rights_set(&rights, CAP_KQUEUE_CHANGE); + cap_rights_set_one(&rights, CAP_KQUEUE_CHANGE); if (nevents > 0) - cap_rights_set(&rights, CAP_KQUEUE_EVENT); + cap_rights_set_one(&rights, CAP_KQUEUE_EVENT); error = fget(td, fd, &rights, &fp); if (error != 0) return (error); From eb40664d833884856cc80cf0368717b659699dbf Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:30:27 +0000 Subject: [PATCH 21/22] capsicum: use new helpers --- sys/kern/subr_capability.c | 86 +++++++++++++++++++------------------- sys/kern/sys_capability.c | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/sys/kern/subr_capability.c b/sys/kern/subr_capability.c index 5f2862b4ef3..f2316b59b9d 100644 --- a/sys/kern/subr_capability.c +++ b/sys/kern/subr_capability.c @@ -103,50 +103,50 @@ __read_mostly cap_rights_t cap_no_rights; static void __cap_rights_sysinit1(void *arg) { - cap_rights_init(&cap_accept_rights, CAP_ACCEPT); - cap_rights_init(&cap_bind_rights, CAP_BIND); - cap_rights_init(&cap_connect_rights, CAP_CONNECT); - cap_rights_init(&cap_event_rights, CAP_EVENT); - cap_rights_init(&cap_fchdir_rights, CAP_FCHDIR); - cap_rights_init(&cap_fchflags_rights, CAP_FCHFLAGS); - cap_rights_init(&cap_fchmod_rights, CAP_FCHMOD); - cap_rights_init(&cap_fchown_rights, CAP_FCHOWN); - cap_rights_init(&cap_fcntl_rights, CAP_FCNTL); - cap_rights_init(&cap_fexecve_rights, CAP_FEXECVE); - cap_rights_init(&cap_flock_rights, CAP_FLOCK); - cap_rights_init(&cap_fpathconf_rights, CAP_FPATHCONF); - cap_rights_init(&cap_fstat_rights, CAP_FSTAT); - cap_rights_init(&cap_fstatfs_rights, CAP_FSTATFS); - cap_rights_init(&cap_fsync_rights, CAP_FSYNC); - cap_rights_init(&cap_ftruncate_rights, CAP_FTRUNCATE); - cap_rights_init(&cap_futimes_rights, CAP_FUTIMES); - cap_rights_init(&cap_getpeername_rights, CAP_GETPEERNAME); - cap_rights_init(&cap_getsockname_rights, CAP_GETSOCKNAME); - cap_rights_init(&cap_getsockopt_rights, CAP_GETSOCKOPT); - cap_rights_init(&cap_ioctl_rights, CAP_IOCTL); - cap_rights_init(&cap_linkat_source_rights, CAP_LINKAT_SOURCE); - cap_rights_init(&cap_linkat_target_rights, CAP_LINKAT_TARGET); - cap_rights_init(&cap_listen_rights, CAP_LISTEN); - cap_rights_init(&cap_mkdirat_rights, CAP_MKDIRAT); - cap_rights_init(&cap_mkfifoat_rights, CAP_MKFIFOAT); - cap_rights_init(&cap_mknodat_rights, CAP_MKNODAT); - cap_rights_init(&cap_mmap_rights, CAP_MMAP); - cap_rights_init(&cap_pdgetpid_rights, CAP_PDGETPID); - cap_rights_init(&cap_pdkill_rights, CAP_PDKILL); - cap_rights_init(&cap_pread_rights, CAP_PREAD); - cap_rights_init(&cap_pwrite_rights, CAP_PWRITE); - cap_rights_init(&cap_read_rights, CAP_READ); - cap_rights_init(&cap_recv_rights, CAP_RECV); - cap_rights_init(&cap_renameat_source_rights, CAP_RENAMEAT_SOURCE); - cap_rights_init(&cap_renameat_target_rights, CAP_RENAMEAT_TARGET); - cap_rights_init(&cap_seek_rights, CAP_SEEK); - cap_rights_init(&cap_send_rights, CAP_SEND); + cap_rights_init_one(&cap_accept_rights, CAP_ACCEPT); + cap_rights_init_one(&cap_bind_rights, CAP_BIND); + cap_rights_init_one(&cap_connect_rights, CAP_CONNECT); + cap_rights_init_one(&cap_event_rights, CAP_EVENT); + cap_rights_init_one(&cap_fchdir_rights, CAP_FCHDIR); + cap_rights_init_one(&cap_fchflags_rights, CAP_FCHFLAGS); + cap_rights_init_one(&cap_fchmod_rights, CAP_FCHMOD); + cap_rights_init_one(&cap_fchown_rights, CAP_FCHOWN); + cap_rights_init_one(&cap_fcntl_rights, CAP_FCNTL); + cap_rights_init_one(&cap_fexecve_rights, CAP_FEXECVE); + cap_rights_init_one(&cap_flock_rights, CAP_FLOCK); + cap_rights_init_one(&cap_fpathconf_rights, CAP_FPATHCONF); + cap_rights_init_one(&cap_fstat_rights, CAP_FSTAT); + cap_rights_init_one(&cap_fstatfs_rights, CAP_FSTATFS); + cap_rights_init_one(&cap_fsync_rights, CAP_FSYNC); + cap_rights_init_one(&cap_ftruncate_rights, CAP_FTRUNCATE); + cap_rights_init_one(&cap_futimes_rights, CAP_FUTIMES); + cap_rights_init_one(&cap_getpeername_rights, CAP_GETPEERNAME); + cap_rights_init_one(&cap_getsockname_rights, CAP_GETSOCKNAME); + cap_rights_init_one(&cap_getsockopt_rights, CAP_GETSOCKOPT); + cap_rights_init_one(&cap_ioctl_rights, CAP_IOCTL); + cap_rights_init_one(&cap_linkat_source_rights, CAP_LINKAT_SOURCE); + cap_rights_init_one(&cap_linkat_target_rights, CAP_LINKAT_TARGET); + cap_rights_init_one(&cap_listen_rights, CAP_LISTEN); + cap_rights_init_one(&cap_mkdirat_rights, CAP_MKDIRAT); + cap_rights_init_one(&cap_mkfifoat_rights, CAP_MKFIFOAT); + cap_rights_init_one(&cap_mknodat_rights, CAP_MKNODAT); + cap_rights_init_one(&cap_mmap_rights, CAP_MMAP); + cap_rights_init_one(&cap_pdgetpid_rights, CAP_PDGETPID); + cap_rights_init_one(&cap_pdkill_rights, CAP_PDKILL); + cap_rights_init_one(&cap_pread_rights, CAP_PREAD); + cap_rights_init_one(&cap_pwrite_rights, CAP_PWRITE); + cap_rights_init_one(&cap_read_rights, CAP_READ); + cap_rights_init_one(&cap_recv_rights, CAP_RECV); + cap_rights_init_one(&cap_renameat_source_rights, CAP_RENAMEAT_SOURCE); + cap_rights_init_one(&cap_renameat_target_rights, CAP_RENAMEAT_TARGET); + cap_rights_init_one(&cap_seek_rights, CAP_SEEK); + cap_rights_init_one(&cap_send_rights, CAP_SEND); cap_rights_init(&cap_send_connect_rights, CAP_SEND, CAP_CONNECT); - cap_rights_init(&cap_setsockopt_rights, CAP_SETSOCKOPT); - cap_rights_init(&cap_shutdown_rights, CAP_SHUTDOWN); - cap_rights_init(&cap_symlinkat_rights, CAP_SYMLINKAT); - cap_rights_init(&cap_unlinkat_rights, CAP_UNLINKAT); - cap_rights_init(&cap_write_rights, CAP_WRITE); + cap_rights_init_one(&cap_setsockopt_rights, CAP_SETSOCKOPT); + cap_rights_init_one(&cap_shutdown_rights, CAP_SHUTDOWN); + cap_rights_init_one(&cap_symlinkat_rights, CAP_SYMLINKAT); + cap_rights_init_one(&cap_unlinkat_rights, CAP_UNLINKAT); + cap_rights_init_one(&cap_write_rights, CAP_WRITE); cap_rights_init(&cap_no_rights); } SYSINIT(cap_rights1_sysinit, SI_SUB_COPYRIGHT, SI_ORDER_ANY, \ diff --git a/sys/kern/sys_capability.c b/sys/kern/sys_capability.c index d6a09ddcfac..e1eb0faf29a 100644 --- a/sys/kern/sys_capability.c +++ b/sys/kern/sys_capability.c @@ -267,7 +267,7 @@ sys_cap_rights_limit(struct thread *td, struct cap_rights_limit_args *uap) cap_rights_t rights; int error, version; - cap_rights_init(&rights); + cap_rights_init_zero(&rights); error = copyin(uap->rightsp, &rights, sizeof(rights.cr_rights[0])); if (error != 0) From 074ad60a4c77a08c3317387c677f01c207dae129 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 15 Feb 2020 13:00:39 +0000 Subject: [PATCH 22/22] vfs: make write suspension mandatory At the time opt-in was introduced adding yourself as a writer was esrializing across the mount point. Nowadays it is fully per-cpu, the only impact being a small single-threaded hit on top of what's there right now. Vast majority of the overhead stems from the call to VOP_GETWRITEMOUNT which has is done regardless. Should someone want to microoptimize this single-threaded they can coalesce looking the mount up with adding a write to it. --- sys/fs/tmpfs/tmpfs_vfsops.c | 10 ---------- sys/kern/vfs_vnops.c | 28 ++-------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 2ce471d9917..b3304cf2601 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -88,7 +88,6 @@ static int tmpfs_root(struct mount *, int flags, struct vnode **); static int tmpfs_fhtovp(struct mount *, struct fid *, int, struct vnode **); static int tmpfs_statfs(struct mount *, struct statfs *); -static void tmpfs_susp_clean(struct mount *); static const char *tmpfs_opts[] = { "from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export", @@ -646,14 +645,6 @@ tmpfs_sync(struct mount *mp, int waitfor) return (0); } -/* - * The presence of a susp_clean method tells the VFS to track writes. - */ -static void -tmpfs_susp_clean(struct mount *mp __unused) -{ -} - static int tmpfs_init(struct vfsconf *conf) { @@ -679,7 +670,6 @@ struct vfsops tmpfs_vfsops = { .vfs_statfs = tmpfs_statfs, .vfs_fhtovp = tmpfs_fhtovp, .vfs_sync = tmpfs_sync, - .vfs_susp_clean = tmpfs_susp_clean, .vfs_init = tmpfs_init, .vfs_uninit = tmpfs_uninit, }; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index b6748de8a8d..d0c438d1622 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1643,13 +1643,6 @@ vn_closefile(struct file *fp, struct thread *td) return (error); } -static bool -vn_suspendable(struct mount *mp) -{ - - return (mp->mnt_op->vfs_susp_clean != NULL); -} - /* * Preparing to start a filesystem write operation. If the operation is * permitted, then we bump the count of operations in progress and @@ -1729,12 +1722,6 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags) if ((mp = *mpp) == NULL) return (0); - if (!vn_suspendable(mp)) { - if (vp != NULL || (flags & V_MNTREF) != 0) - vfs_rel(mp); - return (0); - } - /* * VOP_GETWRITEMOUNT() returns with the mp refcount held through * a vfs_ref(). @@ -1780,12 +1767,6 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) if ((mp = *mpp) == NULL) return (0); - if (!vn_suspendable(mp)) { - if (vp != NULL || (flags & V_MNTREF) != 0) - vfs_rel(mp); - return (0); - } - /* * VOP_GETWRITEMOUNT() returns with the mp refcount held through * a vfs_ref(). @@ -1829,7 +1810,7 @@ vn_finished_write(struct mount *mp) { int c; - if (mp == NULL || !vn_suspendable(mp)) + if (mp == NULL) return; if (vfs_op_thread_enter(mp)) { @@ -1863,7 +1844,7 @@ vn_finished_write(struct mount *mp) void vn_finished_secondary_write(struct mount *mp) { - if (mp == NULL || !vn_suspendable(mp)) + if (mp == NULL) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1884,8 +1865,6 @@ vfs_write_suspend(struct mount *mp, int flags) { int error; - MPASS(vn_suspendable(mp)); - vfs_op_enter(mp); MNT_ILOCK(mp); @@ -1934,8 +1913,6 @@ void vfs_write_resume(struct mount *mp, int flags) { - MPASS(vn_suspendable(mp)); - MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner")); @@ -1970,7 +1947,6 @@ vfs_write_suspend_umnt(struct mount *mp) { int error; - MPASS(vn_suspendable(mp)); KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0, ("vfs_write_suspend_umnt: recursed"));