Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20131218
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: dswload - Dispatcher first pass namespace load callbacks
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  64  * FUNCTION:    AcpiDsInitCallbacks
  65  *
  66  * PARAMETERS:  WalkState       - Current state of the parse tree walk
  67  *              PassNumber      - 1, 2, or 3
  68  *
  69  * RETURN:      Status
  70  *
  71  * DESCRIPTION: Init walk state callbacks
  72  *
  73  ******************************************************************************/
  74 
  75 ACPI_STATUS
  76 AcpiDsInitCallbacks (
  77     ACPI_WALK_STATE         *WalkState,
  78     UINT32                  PassNumber)
  79 {
  80 
  81     switch (PassNumber)
  82     {
  83     case 1:

  84         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
  85                                         ACPI_PARSE_DELETE_TREE;
  86         WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
  87         WalkState->AscendingCallback  = AcpiDsLoad1EndOp;
  88         break;
  89 
  90     case 2:

  91         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
  92                                         ACPI_PARSE_DELETE_TREE;
  93         WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
  94         WalkState->AscendingCallback  = AcpiDsLoad2EndOp;
  95         break;
  96 
  97     case 3:

  98 #ifndef ACPI_NO_METHOD_EXECUTION
  99         WalkState->ParseFlags        |= ACPI_PARSE_EXECUTE  |
 100                                         ACPI_PARSE_DELETE_TREE;
 101         WalkState->DescendingCallback = AcpiDsExecBeginOp;
 102         WalkState->AscendingCallback  = AcpiDsExecEndOp;
 103 #endif
 104         break;
 105 
 106     default:

 107         return (AE_BAD_PARAMETER);
 108     }
 109 
 110     return (AE_OK);
 111 }
 112 
 113 
 114 /*******************************************************************************
 115  *
 116  * FUNCTION:    AcpiDsLoad1BeginOp
 117  *
 118  * PARAMETERS:  WalkState       - Current state of the parse tree walk
 119  *              OutOp           - Where to return op if a new one is created
 120  *
 121  * RETURN:      Status
 122  *
 123  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
 124  *
 125  ******************************************************************************/
 126 


 157 
 158         if (Op->Common.Node)
 159         {
 160             *OutOp = Op;
 161             return_ACPI_STATUS (AE_OK);
 162         }
 163     }
 164 
 165     Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
 166 
 167     /* Map the raw opcode into an internal object type */
 168 
 169     ObjectType = WalkState->OpInfo->ObjectType;
 170 
 171     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 172         "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType)));
 173 
 174     switch (WalkState->Opcode)
 175     {
 176     case AML_SCOPE_OP:
 177 
 178         /*
 179          * The target name of the Scope() operator must exist at this point so
 180          * that we can actually open the scope to enter new names underneath it.
 181          * Allow search-to-root for single namesegs.
 182          */
 183         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
 184                         ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
 185 #ifdef ACPI_ASL_COMPILER
 186         if (Status == AE_NOT_FOUND)
 187         {
 188             /*
 189              * Table disassembly:
 190              * Target of Scope() not found. Generate an External for it, and
 191              * insert the name into the namespace.
 192              */
 193             AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0);
 194             Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
 195                        ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
 196                        WalkState, &Node);
 197         }
 198 #endif
 199         if (ACPI_FAILURE (Status))
 200         {
 201             ACPI_ERROR_NAMESPACE (Path, Status);
 202             return_ACPI_STATUS (Status);
 203         }
 204 
 205         /*
 206          * Check to make sure that the target is
 207          * one of the opcodes that actually opens a scope
 208          */
 209         switch (Node->Type)
 210         {
 211         case ACPI_TYPE_ANY:
 212         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
 213         case ACPI_TYPE_DEVICE:
 214         case ACPI_TYPE_POWER:
 215         case ACPI_TYPE_PROCESSOR:
 216         case ACPI_TYPE_THERMAL:
 217 
 218             /* These are acceptable types */
 219             break;
 220 
 221         case ACPI_TYPE_INTEGER:
 222         case ACPI_TYPE_STRING:
 223         case ACPI_TYPE_BUFFER:
 224 
 225             /*
 226              * These types we will allow, but we will change the type.
 227              * This enables some existing code of the form:
 228              *
 229              *  Name (DEB, 0)
 230              *  Scope (DEB) { ... }
 231              *
 232              * Note: silently change the type here. On the second pass,
 233              * we will report a warning
 234              */
 235             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 236                 "Type override - [%4.4s] had invalid type (%s) "
 237                 "for Scope operator, changed to type ANY\n",
 238                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
 239 
 240             Node->Type = ACPI_TYPE_ANY;
 241             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
 242             break;
 243 













 244         default:
 245 
 246             /* All other types are an error */
 247 
 248             ACPI_ERROR ((AE_INFO,
 249                 "Invalid type (%s) for target of "
 250                 "Scope operator [%4.4s] (Cannot override)",
 251                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
 252 
 253             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 254         }
 255         break;
 256 
 257 
 258     default:
 259         /*
 260          * For all other named opcodes, we will enter the name into
 261          * the namespace.
 262          *
 263          * Setup the search flags.
 264          * Since we are entering a name into the namespace, we do not want to
 265          * enable the search-to-root upsearch.
 266          *
 267          * There are only two conditions where it is acceptable that the name
 268          * already exists:
 269          *    1) the Scope() operator can reopen a scoping object that was
 270          *       previously defined (Scope, Method, Device, etc.)
 271          *    2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
 272          *       BufferField, or Package), the name of the object is already
 273          *       in the namespace.
 274          */
 275         if (WalkState->DeferredNode)
 276         {
 277             /* This name is already in the namespace, get the node */


   1 /******************************************************************************
   2  *
   3  * Module Name: dswload - Dispatcher first pass namespace load callbacks
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  64  * FUNCTION:    AcpiDsInitCallbacks
  65  *
  66  * PARAMETERS:  WalkState       - Current state of the parse tree walk
  67  *              PassNumber      - 1, 2, or 3
  68  *
  69  * RETURN:      Status
  70  *
  71  * DESCRIPTION: Init walk state callbacks
  72  *
  73  ******************************************************************************/
  74 
  75 ACPI_STATUS
  76 AcpiDsInitCallbacks (
  77     ACPI_WALK_STATE         *WalkState,
  78     UINT32                  PassNumber)
  79 {
  80 
  81     switch (PassNumber)
  82     {
  83     case 1:
  84 
  85         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
  86                                         ACPI_PARSE_DELETE_TREE;
  87         WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
  88         WalkState->AscendingCallback  = AcpiDsLoad1EndOp;
  89         break;
  90 
  91     case 2:
  92 
  93         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
  94                                         ACPI_PARSE_DELETE_TREE;
  95         WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
  96         WalkState->AscendingCallback  = AcpiDsLoad2EndOp;
  97         break;
  98 
  99     case 3:
 100 
 101 #ifndef ACPI_NO_METHOD_EXECUTION
 102         WalkState->ParseFlags        |= ACPI_PARSE_EXECUTE  |
 103                                         ACPI_PARSE_DELETE_TREE;
 104         WalkState->DescendingCallback = AcpiDsExecBeginOp;
 105         WalkState->AscendingCallback  = AcpiDsExecEndOp;
 106 #endif
 107         break;
 108 
 109     default:
 110 
 111         return (AE_BAD_PARAMETER);
 112     }
 113 
 114     return (AE_OK);
 115 }
 116 
 117 
 118 /*******************************************************************************
 119  *
 120  * FUNCTION:    AcpiDsLoad1BeginOp
 121  *
 122  * PARAMETERS:  WalkState       - Current state of the parse tree walk
 123  *              OutOp           - Where to return op if a new one is created
 124  *
 125  * RETURN:      Status
 126  *
 127  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
 128  *
 129  ******************************************************************************/
 130 


 161 
 162         if (Op->Common.Node)
 163         {
 164             *OutOp = Op;
 165             return_ACPI_STATUS (AE_OK);
 166         }
 167     }
 168 
 169     Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
 170 
 171     /* Map the raw opcode into an internal object type */
 172 
 173     ObjectType = WalkState->OpInfo->ObjectType;
 174 
 175     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 176         "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType)));
 177 
 178     switch (WalkState->Opcode)
 179     {
 180     case AML_SCOPE_OP:

 181         /*
 182          * The target name of the Scope() operator must exist at this point so
 183          * that we can actually open the scope to enter new names underneath it.
 184          * Allow search-to-root for single namesegs.
 185          */
 186         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
 187                         ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
 188 #ifdef ACPI_ASL_COMPILER
 189         if (Status == AE_NOT_FOUND)
 190         {
 191             /*
 192              * Table disassembly:
 193              * Target of Scope() not found. Generate an External for it, and
 194              * insert the name into the namespace.
 195              */
 196             AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0);
 197             Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
 198                        ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
 199                        WalkState, &Node);
 200         }
 201 #endif
 202         if (ACPI_FAILURE (Status))
 203         {
 204             ACPI_ERROR_NAMESPACE (Path, Status);
 205             return_ACPI_STATUS (Status);
 206         }
 207 
 208         /*
 209          * Check to make sure that the target is
 210          * one of the opcodes that actually opens a scope
 211          */
 212         switch (Node->Type)
 213         {
 214         case ACPI_TYPE_ANY:
 215         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
 216         case ACPI_TYPE_DEVICE:
 217         case ACPI_TYPE_POWER:
 218         case ACPI_TYPE_PROCESSOR:
 219         case ACPI_TYPE_THERMAL:
 220 
 221             /* These are acceptable types */
 222             break;
 223 
 224         case ACPI_TYPE_INTEGER:
 225         case ACPI_TYPE_STRING:
 226         case ACPI_TYPE_BUFFER:

 227             /*
 228              * These types we will allow, but we will change the type.
 229              * This enables some existing code of the form:
 230              *
 231              *  Name (DEB, 0)
 232              *  Scope (DEB) { ... }
 233              *
 234              * Note: silently change the type here. On the second pass,
 235              * we will report a warning
 236              */
 237             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 238                 "Type override - [%4.4s] had invalid type (%s) "
 239                 "for Scope operator, changed to type ANY\n",
 240                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
 241 
 242             Node->Type = ACPI_TYPE_ANY;
 243             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
 244             break;
 245 
 246         case ACPI_TYPE_METHOD:
 247             /*
 248              * Allow scope change to root during execution of module-level
 249              * code. Root is typed METHOD during this time.
 250              */
 251             if ((Node == AcpiGbl_RootNode) &&
 252                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
 253             {
 254                 break;
 255             }
 256 
 257             /*lint -fallthrough */
 258 
 259         default:
 260 
 261             /* All other types are an error */
 262 
 263             ACPI_ERROR ((AE_INFO,
 264                 "Invalid type (%s) for target of "
 265                 "Scope operator [%4.4s] (Cannot override)",
 266                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
 267 
 268             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 269         }
 270         break;
 271 

 272     default:
 273         /*
 274          * For all other named opcodes, we will enter the name into
 275          * the namespace.
 276          *
 277          * Setup the search flags.
 278          * Since we are entering a name into the namespace, we do not want to
 279          * enable the search-to-root upsearch.
 280          *
 281          * There are only two conditions where it is acceptable that the name
 282          * already exists:
 283          *    1) the Scope() operator can reopen a scoping object that was
 284          *       previously defined (Scope, Method, Device, etc.)
 285          *    2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
 286          *       BufferField, or Package), the name of the object is already
 287          *       in the namespace.
 288          */
 289         if (WalkState->DeferredNode)
 290         {
 291             /* This name is already in the namespace, get the node */