Path: blob/main/sys/contrib/dev/acpica/compiler/aslpredef.c
48373 views
/******************************************************************************1*2* Module Name: aslpredef - support for ACPI predefined names3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#define ACPI_CREATE_PREDEFINED_TABLE152#define ACPI_CREATE_RESOURCE_TABLE153154#include <contrib/dev/acpica/compiler/aslcompiler.h>155#include "aslcompiler.y.h"156#include <contrib/dev/acpica/include/acpredef.h>157#include <contrib/dev/acpica/include/acnamesp.h>158159160#define _COMPONENT ACPI_COMPILER161ACPI_MODULE_NAME ("aslpredef")162163164/* Local prototypes */165166static void167ApCheckForUnexpectedReturnValue (168ACPI_PARSE_OBJECT *Op,169ASL_METHOD_INFO *MethodInfo);170171static UINT32172ApCheckForSpecialName (173ACPI_PARSE_OBJECT *Op,174char *Name);175176177/*******************************************************************************178*179* FUNCTION: ApCheckForPredefinedMethod180*181* PARAMETERS: Op - A parse node of type "METHOD".182* MethodInfo - Saved info about this method183*184* RETURN: None185*186* DESCRIPTION: If method is a predefined name, check that the number of187* arguments and the return type (returns a value or not)188* is correct.189*190******************************************************************************/191192BOOLEAN193ApCheckForPredefinedMethod (194ACPI_PARSE_OBJECT *Op,195ASL_METHOD_INFO *MethodInfo)196{197UINT32 Index;198UINT32 RequiredArgCount;199const ACPI_PREDEFINED_INFO *ThisName;200201202/* Check for a match against the predefined name list */203204Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);205206switch (Index)207{208case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */209case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */210case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */211212/* Just return, nothing to do */213return (FALSE);214215216case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */217218AslGbl_ReservedMethods++;219220/* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */221222if (MethodInfo->NumArguments != 0)223{224sprintf (AslGbl_MsgBuffer, "%s requires %d", Op->Asl.ExternalName, 0);225226AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,227AslGbl_MsgBuffer);228}229break;230231232default:233/*234* Matched a predefined method name - validate the ASL-defined235* argument count against the ACPI specification.236*237* Some methods are allowed to have a "minimum" number of args238* (_SCP) because their definition in ACPI has changed over time.239*/240AslGbl_ReservedMethods++;241ThisName = &AcpiGbl_PredefinedMethods[Index];242RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList);243244if (MethodInfo->NumArguments != RequiredArgCount)245{246sprintf (AslGbl_MsgBuffer, "%4.4s requires %u",247ThisName->Info.Name, RequiredArgCount);248249if (MethodInfo->NumArguments < RequiredArgCount)250{251AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,252AslGbl_MsgBuffer);253}254else if ((MethodInfo->NumArguments > RequiredArgCount) &&255!(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))256{257AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,258AslGbl_MsgBuffer);259}260}261262/*263* Check if method returns no value, but the predefined name is264* required to return a value265*/266if (MethodInfo->NumReturnNoValue &&267ThisName->Info.ExpectedBtypes)268{269AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer,270ThisName->Info.ExpectedBtypes);271272sprintf (AslGbl_MsgBuffer, "%s required for %4.4s",273AslGbl_StringBuffer, ThisName->Info.Name);274275AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,276AslGbl_MsgBuffer);277}278break;279}280281return (TRUE);282}283284285/*******************************************************************************286*287* FUNCTION: ApCheckForUnexpectedReturnValue288*289* PARAMETERS: Op - A parse node of type "RETURN".290* MethodInfo - Saved info about this method291*292* RETURN: None293*294* DESCRIPTION: Check for an unexpected return value from a predefined method.295* Invoked for predefined methods that are defined to not return296* any value. If there is a return value, issue a remark, since297* the ASL writer may be confused as to the method definition298* and/or functionality.299*300* Note: We ignore all return values of "Zero", since this is what a standalone301* Return() statement will always generate -- so we ignore it here --302* i.e., there is no difference between Return() and Return(Zero).303* Also, a null Return() will be disassembled to return(Zero) -- so, we304* don't want to generate extraneous remarks/warnings for a disassembled305* ASL file.306*307******************************************************************************/308309static void310ApCheckForUnexpectedReturnValue (311ACPI_PARSE_OBJECT *Op,312ASL_METHOD_INFO *MethodInfo)313{314ACPI_PARSE_OBJECT *ReturnValueOp;315316317/* Ignore Return() and Return(Zero) (they are the same) */318319ReturnValueOp = Op->Asl.Child;320if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)321{322return;323}324325/* We have a valid return value, but the reserved name did not expect it */326327AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,328Op, MethodInfo->Op->Asl.ExternalName);329}330331332/*******************************************************************************333*334* FUNCTION: ApCheckPredefinedReturnValue335*336* PARAMETERS: Op - A parse node of type "RETURN".337* MethodInfo - Saved info about this method338*339* RETURN: None340*341* DESCRIPTION: If method is a predefined name, attempt to validate the return342* value. Only "static" types can be validated - a simple return343* of an integer/string/buffer/package or a named reference to344* a static object. Values such as a Localx or Argx or a control345* method invocation are not checked. Issue a warning if there is346* a valid return value, but the reserved method defines no347* return value.348*349******************************************************************************/350351void352ApCheckPredefinedReturnValue (353ACPI_PARSE_OBJECT *Op,354ASL_METHOD_INFO *MethodInfo)355{356UINT32 Index;357ACPI_PARSE_OBJECT *ReturnValueOp;358const ACPI_PREDEFINED_INFO *ThisName;359360361/*362* Check parent method for a match against the predefined name list.363*364* Note: Disable compiler errors/warnings because any errors will be365* caught when analyzing the parent method. Eliminates duplicate errors.366*/367AslGbl_AllExceptionsDisabled = TRUE;368Index = ApCheckForPredefinedName (MethodInfo->Op,369MethodInfo->Op->Asl.NameSeg);370AslGbl_AllExceptionsDisabled = FALSE;371372switch (Index)373{374case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */375376/* No return value expected, warn if there is one */377378ApCheckForUnexpectedReturnValue (Op, MethodInfo);379return;380381case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */382case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */383case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */384385/* Just return, nothing to do */386return;387388default: /* A standard predefined ACPI name */389390ThisName = &AcpiGbl_PredefinedMethods[Index];391if (!ThisName->Info.ExpectedBtypes)392{393/* No return value expected, warn if there is one */394395ApCheckForUnexpectedReturnValue (Op, MethodInfo);396return;397}398399/* Get the object returned, it is the next argument */400401ReturnValueOp = Op->Asl.Child;402switch (ReturnValueOp->Asl.ParseOpcode)403{404case PARSEOP_ZERO:405case PARSEOP_ONE:406case PARSEOP_ONES:407case PARSEOP_INTEGER:408case PARSEOP_STRING_LITERAL:409case PARSEOP_BUFFER:410case PARSEOP_PACKAGE:411412/* Static data return object - check against expected type */413414ApCheckObjectType (ThisName->Info.Name, ReturnValueOp,415ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);416417/* For packages, check the individual package elements */418419if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE)420{421ApCheckPackage (ReturnValueOp, ThisName);422}423break;424425default:426/*427* All other ops are very difficult or impossible to typecheck at428* compile time. These include all Localx, Argx, and method429* invocations. Also, NAMESEG and NAMESTRING because the type of430* any named object can be changed at runtime (for example,431* CopyObject will change the type of the target object.)432*/433break;434}435}436}437438439/*******************************************************************************440*441* FUNCTION: ApCheckForPredefinedObject442*443* PARAMETERS: Op - A parse node444* Name - The ACPI name to be checked445*446* RETURN: None447*448* DESCRIPTION: Check for a predefined name for a static object (created via449* the ASL Name operator). If it is a predefined ACPI name, ensure450* that the name does not require any arguments (which would451* require a control method implementation of the name), and that452* the type of the object is one of the expected types for the453* predefined name.454*455******************************************************************************/456457void458ApCheckForPredefinedObject (459ACPI_PARSE_OBJECT *Op,460char *Name)461{462UINT32 Index;463ACPI_PARSE_OBJECT *ObjectOp;464const ACPI_PREDEFINED_INFO *ThisName;465466467/*468* Check for a real predefined name -- not a resource descriptor name469* or a predefined scope name470*/471Index = ApCheckForPredefinedName (Op, Name);472473switch (Index)474{475case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */476case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */477case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */478479/* Nothing to do */480return;481482case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */483484/*485* These names must be control methods, by definition in ACPI spec.486* Also because they are defined to return no value. None of them487* require any arguments.488*/489AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,490"with zero arguments");491return;492493default:494495break;496}497498/* A standard predefined ACPI name */499500/*501* If this predefined name requires input arguments, then502* it must be implemented as a control method503*/504ThisName = &AcpiGbl_PredefinedMethods[Index];505if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0)506{507AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,508"with arguments");509return;510}511512/*513* If no return value is expected from this predefined name, then514* it follows that it must be implemented as a control method515* (with zero args, because the args > 0 case was handled above)516* Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx517*/518if (!ThisName->Info.ExpectedBtypes)519{520AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,521"with zero arguments");522return;523}524525/* Typecheck the actual object, it is the next argument */526527ObjectOp = Op->Asl.Child->Asl.Next;528ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next,529ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);530531/* For packages, check the individual package elements */532533if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE)534{535ApCheckPackage (ObjectOp, ThisName);536}537}538539540/*******************************************************************************541*542* FUNCTION: ApCheckForPredefinedName543*544* PARAMETERS: Op - A parse node545* Name - NameSeg to check546*547* RETURN: None548*549* DESCRIPTION: Check a NameSeg against the reserved list.550*551******************************************************************************/552553UINT32554ApCheckForPredefinedName (555ACPI_PARSE_OBJECT *Op,556char *Name)557{558UINT32 i;559const ACPI_PREDEFINED_INFO *ThisName;560561562if (Name[0] == 0)563{564AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,565"Zero length name found");566}567568/* All reserved names are prefixed with a single underscore */569570if (Name[0] != '_')571{572return (ACPI_NOT_RESERVED_NAME);573}574575/* Check for a standard predefined method name */576577ThisName = AcpiGbl_PredefinedMethods;578for (i = 0; ThisName->Info.Name[0]; i++)579{580if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))581{582/* Return index into predefined array */583return (i);584}585586ThisName++; /* Does not account for extra package data, but is OK */587}588589/* Check for resource names and predefined scope names */590591ThisName = AcpiGbl_ResourceNames;592while (ThisName->Info.Name[0])593{594if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))595{596return (ACPI_PREDEFINED_NAME);597}598599ThisName++;600}601602ThisName = AcpiGbl_ScopeNames;603while (ThisName->Info.Name[0])604{605if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))606{607return (ACPI_PREDEFINED_NAME);608}609610ThisName++;611}612613/* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */614615return (ApCheckForSpecialName (Op, Name));616}617618619/*******************************************************************************620*621* FUNCTION: ApCheckForSpecialName622*623* PARAMETERS: Op - A parse node624* Name - NameSeg to check625*626* RETURN: None627*628* DESCRIPTION: Check for the "special" predefined names -629* _Lxx, _Exx, _Qxx, _Wxx, and _T_x630*631******************************************************************************/632633static UINT32634ApCheckForSpecialName (635ACPI_PARSE_OBJECT *Op,636char *Name)637{638639/*640* Check for the "special" predefined names. We already know that the641* first character is an underscore.642* GPE: _Lxx643* GPE: _Exx644* GPE: _Wxx645* EC: _Qxx646*/647if ((Name[1] == 'L') ||648(Name[1] == 'E') ||649(Name[1] == 'W') ||650(Name[1] == 'Q'))651{652/* The next two characters must be hex digits */653654if ((isxdigit ((int) Name[2])) &&655(isxdigit ((int) Name[3])))656{657return (ACPI_EVENT_RESERVED_NAME);658}659}660661/* Check for the names reserved for the compiler itself: _T_x */662663else if ((Op->Asl.ExternalName[1] == 'T') &&664(Op->Asl.ExternalName[2] == '_'))665{666/* Ignore if actually emitted by the compiler */667668if (Op->Asl.CompileFlags & OP_COMPILER_EMITTED)669{670return (ACPI_NOT_RESERVED_NAME);671}672673/*674* Was not actually emitted by the compiler. This is a special case,675* however. If the ASL code being compiled was the result of a676* disassembly, it may possibly contain valid compiler-emitted names677* of the form "_T_x". We don't want to issue an error or even a678* warning and force the user to manually change the names. So, we679* will issue a remark instead.680*/681AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED,682Op, Op->Asl.ExternalName);683return (ACPI_COMPILER_RESERVED_NAME);684}685686/*687* The name didn't match any of the known predefined names. Flag it as a688* warning, since the entire namespace starting with an underscore is689* reserved by the ACPI spec.690*/691AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME,692Op, Op->Asl.ExternalName);693694return (ACPI_NOT_RESERVED_NAME);695}696697698/*******************************************************************************699*700* FUNCTION: ApCheckObjectType701*702* PARAMETERS: PredefinedName - Name of the predefined object we are checking703* Op - Current parse node704* ExpectedBtypes - Bitmap of expected return type(s)705* PackageIndex - Index of object within parent package (if706* applicable - ACPI_NOT_PACKAGE_ELEMENT707* otherwise)708*709* RETURN: None710*711* DESCRIPTION: Check if the object type is one of the types that is expected712* by the predefined name. Only a limited number of object types713* can be returned by the predefined names.714*715******************************************************************************/716717ACPI_STATUS718ApCheckObjectType (719const char *PredefinedName,720ACPI_PARSE_OBJECT *Op,721UINT32 ExpectedBtypes,722UINT32 PackageIndex)723{724UINT32 ReturnBtype;725char *TypeName;726727728if (!Op)729{730return (AE_TYPE);731}732733/* Map the parse opcode to a bitmapped return type (RTYPE) */734735switch (Op->Asl.ParseOpcode)736{737case PARSEOP_ZERO:738case PARSEOP_ONE:739case PARSEOP_ONES:740case PARSEOP_INTEGER:741742ReturnBtype = ACPI_RTYPE_INTEGER;743TypeName = "Integer";744break;745746case PARSEOP_STRING_LITERAL:747748ReturnBtype = ACPI_RTYPE_STRING;749TypeName = "String";750break;751752case PARSEOP_BUFFER:753754ReturnBtype = ACPI_RTYPE_BUFFER;755TypeName = "Buffer";756break;757758case PARSEOP_PACKAGE:759case PARSEOP_VAR_PACKAGE:760761ReturnBtype = ACPI_RTYPE_PACKAGE;762TypeName = "Package";763break;764765case PARSEOP_NAMESEG:766case PARSEOP_NAMESTRING:767/*768* Ignore any named references within a package object.769*770* For Package objects, references are allowed instead of any of the771* standard data types (Integer/String/Buffer/Package). These772* references are resolved at runtime. NAMESEG and NAMESTRING are773* impossible to typecheck at compile time because the type of774* any named object can be changed at runtime (for example,775* CopyObject will change the type of the target object).776*/777if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)778{779return (AE_OK);780}781782ReturnBtype = ACPI_RTYPE_REFERENCE;783TypeName = "Reference";784break;785786default:787788/* Not one of the supported object types */789790TypeName = UtGetOpName (Op->Asl.ParseOpcode);791goto TypeErrorExit;792}793794/* Exit if the object is one of the expected types */795796if (ReturnBtype & ExpectedBtypes)797{798return (AE_OK);799}800801802TypeErrorExit:803804/* Format the expected types and emit an error message */805806AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, ExpectedBtypes);807808if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)809{810sprintf (AslGbl_MsgBuffer, "%4.4s: found %s, %s required",811PredefinedName, TypeName, AslGbl_StringBuffer);812}813else814{815sprintf (AslGbl_MsgBuffer, "%4.4s: found %s at index %u, %s required",816PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer);817}818819AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);820return (AE_TYPE);821}822823824/*******************************************************************************825*826* FUNCTION: ApDisplayReservedNames827*828* PARAMETERS: None829*830* RETURN: None831*832* DESCRIPTION: Dump information about the ACPI predefined names and predefined833* resource descriptor names.834*835******************************************************************************/836837void838ApDisplayReservedNames (839void)840{841const ACPI_PREDEFINED_INFO *ThisName;842UINT32 Count;843UINT32 NumTypes;844845846/*847* Predefined names/methods848*/849printf ("\nPredefined Name Information\n\n");850851Count = 0;852ThisName = AcpiGbl_PredefinedMethods;853while (ThisName->Info.Name[0])854{855AcpiUtDisplayPredefinedMethod (AslGbl_MsgBuffer, ThisName, FALSE);856Count++;857ThisName = AcpiUtGetNextPredefinedMethod (ThisName);858}859860printf ("%u Predefined Names are recognized\n", Count);861862/*863* Resource Descriptor names864*/865printf ("\nPredefined Names for Resource Descriptor Fields\n\n");866867Count = 0;868ThisName = AcpiGbl_ResourceNames;869while (ThisName->Info.Name[0])870{871NumTypes = AcpiUtGetResourceBitWidth (AslGbl_MsgBuffer,872ThisName->Info.ArgumentList);873874printf ("%4.4s Field is %s bits wide%s\n",875ThisName->Info.Name, AslGbl_MsgBuffer,876(NumTypes > 1) ? " (depending on descriptor type)" : "");877878Count++;879ThisName++;880}881882printf ("%u Resource Descriptor Field Names are recognized\n", Count);883884/*885* Predefined scope names886*/887printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n");888889ThisName = AcpiGbl_ScopeNames;890while (ThisName->Info.Name[0])891{892printf ("%4.4s Scope/Device\n", ThisName->Info.Name);893ThisName++;894}895}896897898