Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 /*******************************************************************************
   2  *
   3  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
   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.


 104      */
 105     AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
 106 
 107     /* Enter the pre-defined names in the name table */
 108 
 109     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 110         "Entering predefined entries into namespace\n"));
 111 
 112     for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
 113     {
 114         /* _OSI is optional for now, will be permanent later */
 115 
 116         if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
 117         {
 118             continue;
 119         }
 120 
 121         Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
 122                         ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
 123                         NULL, &NewNode);
 124 
 125         if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
 126         {
 127             ACPI_EXCEPTION ((AE_INFO, Status,
 128                 "Could not create predefined name %s",
 129                 InitVal->Name));

 130         }
 131 
 132         /*
 133          * Name entered successfully. If entry in PreDefinedNames[] specifies
 134          * an initial value, create the initial value.
 135          */
 136         if (InitVal->Val)
 137         {
 138             Status = AcpiOsPredefinedOverride (InitVal, &Val);
 139             if (ACPI_FAILURE (Status))
 140             {
 141                 ACPI_ERROR ((AE_INFO,
 142                     "Could not override predefined %s",
 143                     InitVal->Name));
 144             }
 145 
 146             if (!Val)
 147             {
 148                 Val = InitVal->Val;
 149             }
 150 
 151             /*
 152              * Entry requests an initial value, allocate a
 153              * descriptor for it.
 154              */
 155             ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
 156             if (!ObjDesc)
 157             {
 158                 Status = AE_NO_MEMORY;
 159                 goto UnlockAndExit;
 160             }
 161 
 162             /*
 163              * Convert value string from table entry to
 164              * internal representation. Only types actually
 165              * used for initial values are implemented here.
 166              */
 167             switch (InitVal->Type)
 168             {
 169             case ACPI_TYPE_METHOD:

 170                 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
 171                 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
 172 
 173 #if defined (ACPI_ASL_COMPILER)
 174 
 175                 /* Save the parameter count for the iASL compiler */
 176 
 177                 NewNode->Value = ObjDesc->Method.ParamCount;
 178 #else
 179                 /* Mark this as a very SPECIAL method */
 180 
 181                 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
 182                 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
 183 #endif
 184                 break;
 185 
 186             case ACPI_TYPE_INTEGER:
 187 
 188                 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
 189                 break;
 190 
 191 
 192             case ACPI_TYPE_STRING:
 193 
 194                 /* Build an object around the static string */
 195 
 196                 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
 197                 ObjDesc->String.Pointer = Val;
 198                 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
 199                 break;
 200 
 201 
 202             case ACPI_TYPE_MUTEX:
 203 
 204                 ObjDesc->Mutex.Node = NewNode;
 205                 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
 206 
 207                 /* Create a mutex */
 208 
 209                 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
 210                 if (ACPI_FAILURE (Status))
 211                 {
 212                     AcpiUtRemoveReference (ObjDesc);
 213                     goto UnlockAndExit;
 214                 }
 215 
 216                 /* Special case for ACPI Global Lock */
 217 
 218                 if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
 219                 {
 220                     AcpiGbl_GlobalLockMutex = ObjDesc;
 221 
 222                     /* Create additional counting semaphore for global lock */
 223 
 224                     Status = AcpiOsCreateSemaphore (
 225                                 1, 0, &AcpiGbl_GlobalLockSemaphore);
 226                     if (ACPI_FAILURE (Status))
 227                     {
 228                         AcpiUtRemoveReference (ObjDesc);
 229                         goto UnlockAndExit;
 230                     }
 231                 }
 232                 break;
 233 
 234 
 235             default:
 236 
 237                 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
 238                     InitVal->Type));
 239                 AcpiUtRemoveReference (ObjDesc);
 240                 ObjDesc = NULL;
 241                 continue;
 242             }
 243 
 244             /* Store pointer to value descriptor in the Node */
 245 
 246             Status = AcpiNsAttachObject (NewNode, ObjDesc,
 247                         ObjDesc->Common.Type);
 248 
 249             /* Remove local reference to the object */
 250 
 251             AcpiUtRemoveReference (ObjDesc);
 252         }
 253     }
 254 


 433             {
 434                 /* Name is fully qualified, no search rules apply */
 435 
 436                 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
 437 
 438                 /*
 439                  * Point past this prefix to the name segment
 440                  * part or the next Parent Prefix
 441                  */
 442                 Path++;
 443 
 444                 /* Backup to the parent node */
 445 
 446                 NumCarats++;
 447                 ThisNode = ThisNode->Parent;
 448                 if (!ThisNode)
 449                 {
 450                     /* Current scope has no parent scope */
 451 
 452                     ACPI_ERROR ((AE_INFO,
 453                         "ACPI path has too many parent prefixes (^) "
 454                         "- reached beyond root node"));
 455                     return_ACPI_STATUS (AE_NOT_FOUND);
 456                 }
 457             }
 458 
 459             if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
 460             {
 461                 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 462                     "Search scope is [%4.4s], path has %u carat(s)\n",
 463                     AcpiUtGetNodeName (ThisNode), NumCarats));
 464             }
 465         }
 466 
 467         /*
 468          * Determine the number of ACPI name segments in this pathname.
 469          *
 470          * The segment part consists of either:
 471          *  - A Null name segment (0)
 472          *  - A DualNamePrefix followed by two 4-byte name segments
 473          *  - A MultiNamePrefix followed by a byte indicating the
 474          *      number of segments and the segments themselves.


 680 
 681     if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
 682     {
 683         /*
 684          * If entry is a type which opens a scope, push the new scope on the
 685          * scope stack.
 686          */
 687         if (AcpiNsOpensScope (Type))
 688         {
 689             Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
 690             if (ACPI_FAILURE (Status))
 691             {
 692                 return_ACPI_STATUS (Status);
 693             }
 694         }
 695     }
 696 
 697     *ReturnNode = ThisNode;
 698     return_ACPI_STATUS (AE_OK);
 699 }
 700 
   1 /*******************************************************************************
   2  *
   3  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
   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.


 104      */
 105     AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
 106 
 107     /* Enter the pre-defined names in the name table */
 108 
 109     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 110         "Entering predefined entries into namespace\n"));
 111 
 112     for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
 113     {
 114         /* _OSI is optional for now, will be permanent later */
 115 
 116         if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
 117         {
 118             continue;
 119         }
 120 
 121         Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
 122                         ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
 123                         NULL, &NewNode);
 124         if (ACPI_FAILURE (Status))

 125         {
 126             ACPI_EXCEPTION ((AE_INFO, Status,
 127                 "Could not create predefined name %s",
 128                 InitVal->Name));
 129             continue;
 130         }
 131 
 132         /*
 133          * Name entered successfully. If entry in PreDefinedNames[] specifies
 134          * an initial value, create the initial value.
 135          */
 136         if (InitVal->Val)
 137         {
 138             Status = AcpiOsPredefinedOverride (InitVal, &Val);
 139             if (ACPI_FAILURE (Status))
 140             {
 141                 ACPI_ERROR ((AE_INFO,
 142                     "Could not override predefined %s",
 143                     InitVal->Name));
 144             }
 145 
 146             if (!Val)
 147             {
 148                 Val = InitVal->Val;
 149             }
 150 
 151             /*
 152              * Entry requests an initial value, allocate a
 153              * descriptor for it.
 154              */
 155             ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
 156             if (!ObjDesc)
 157             {
 158                 Status = AE_NO_MEMORY;
 159                 goto UnlockAndExit;
 160             }
 161 
 162             /*
 163              * Convert value string from table entry to
 164              * internal representation. Only types actually
 165              * used for initial values are implemented here.
 166              */
 167             switch (InitVal->Type)
 168             {
 169             case ACPI_TYPE_METHOD:
 170 
 171                 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
 172                 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
 173 
 174 #if defined (ACPI_ASL_COMPILER)
 175 
 176                 /* Save the parameter count for the iASL compiler */
 177 
 178                 NewNode->Value = ObjDesc->Method.ParamCount;
 179 #else
 180                 /* Mark this as a very SPECIAL method */
 181 
 182                 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
 183                 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
 184 #endif
 185                 break;
 186 
 187             case ACPI_TYPE_INTEGER:
 188 
 189                 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
 190                 break;
 191 

 192             case ACPI_TYPE_STRING:
 193 
 194                 /* Build an object around the static string */
 195 
 196                 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
 197                 ObjDesc->String.Pointer = Val;
 198                 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
 199                 break;
 200 

 201             case ACPI_TYPE_MUTEX:
 202 
 203                 ObjDesc->Mutex.Node = NewNode;
 204                 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
 205 
 206                 /* Create a mutex */
 207 
 208                 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
 209                 if (ACPI_FAILURE (Status))
 210                 {
 211                     AcpiUtRemoveReference (ObjDesc);
 212                     goto UnlockAndExit;
 213                 }
 214 
 215                 /* Special case for ACPI Global Lock */
 216 
 217                 if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
 218                 {
 219                     AcpiGbl_GlobalLockMutex = ObjDesc;
 220 
 221                     /* Create additional counting semaphore for global lock */
 222 
 223                     Status = AcpiOsCreateSemaphore (
 224                                 1, 0, &AcpiGbl_GlobalLockSemaphore);
 225                     if (ACPI_FAILURE (Status))
 226                     {
 227                         AcpiUtRemoveReference (ObjDesc);
 228                         goto UnlockAndExit;
 229                     }
 230                 }
 231                 break;
 232 

 233             default:
 234 
 235                 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
 236                     InitVal->Type));
 237                 AcpiUtRemoveReference (ObjDesc);
 238                 ObjDesc = NULL;
 239                 continue;
 240             }
 241 
 242             /* Store pointer to value descriptor in the Node */
 243 
 244             Status = AcpiNsAttachObject (NewNode, ObjDesc,
 245                         ObjDesc->Common.Type);
 246 
 247             /* Remove local reference to the object */
 248 
 249             AcpiUtRemoveReference (ObjDesc);
 250         }
 251     }
 252 


 431             {
 432                 /* Name is fully qualified, no search rules apply */
 433 
 434                 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
 435 
 436                 /*
 437                  * Point past this prefix to the name segment
 438                  * part or the next Parent Prefix
 439                  */
 440                 Path++;
 441 
 442                 /* Backup to the parent node */
 443 
 444                 NumCarats++;
 445                 ThisNode = ThisNode->Parent;
 446                 if (!ThisNode)
 447                 {
 448                     /* Current scope has no parent scope */
 449 
 450                     ACPI_ERROR ((AE_INFO,
 451                         "%s: Path has too many parent prefixes (^) "
 452                         "- reached beyond root node", Pathname));
 453                     return_ACPI_STATUS (AE_NOT_FOUND);
 454                 }
 455             }
 456 
 457             if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
 458             {
 459                 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
 460                     "Search scope is [%4.4s], path has %u carat(s)\n",
 461                     AcpiUtGetNodeName (ThisNode), NumCarats));
 462             }
 463         }
 464 
 465         /*
 466          * Determine the number of ACPI name segments in this pathname.
 467          *
 468          * The segment part consists of either:
 469          *  - A Null name segment (0)
 470          *  - A DualNamePrefix followed by two 4-byte name segments
 471          *  - A MultiNamePrefix followed by a byte indicating the
 472          *      number of segments and the segments themselves.


 678 
 679     if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
 680     {
 681         /*
 682          * If entry is a type which opens a scope, push the new scope on the
 683          * scope stack.
 684          */
 685         if (AcpiNsOpensScope (Type))
 686         {
 687             Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
 688             if (ACPI_FAILURE (Status))
 689             {
 690                 return_ACPI_STATUS (Status);
 691             }
 692         }
 693     }
 694 
 695     *ReturnNode = ThisNode;
 696     return_ACPI_STATUS (AE_OK);
 697 }