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


 318         /*
 319          * DataType is not a field name.
 320          * Examine first character of name for root or parent prefix operators
 321          */
 322         switch (*AmlAddress)
 323         {
 324         case AML_ROOT_PREFIX:
 325 
 326             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
 327                 AmlAddress));
 328 
 329             /*
 330              * Remember that we have a RootPrefix --
 331              * see comment in AcpiExAllocateNameString()
 332              */
 333             AmlAddress++;
 334             PrefixCount = ACPI_UINT32_MAX;
 335             HasPrefix = TRUE;
 336             break;
 337 
 338 
 339         case AML_PARENT_PREFIX:
 340 
 341             /* Increment past possibly multiple parent prefixes */
 342 
 343             do
 344             {
 345                 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
 346                     AmlAddress));
 347 
 348                 AmlAddress++;
 349                 PrefixCount++;
 350 
 351             } while (*AmlAddress == AML_PARENT_PREFIX);
 352 
 353             HasPrefix = TRUE;
 354             break;
 355 
 356 
 357         default:
 358 
 359             /* Not a prefix character */
 360 
 361             break;
 362         }
 363 
 364         /* Examine first character of name for name segment prefix operator */
 365 
 366         switch (*AmlAddress)
 367         {
 368         case AML_DUAL_NAME_PREFIX:
 369 
 370             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
 371                 AmlAddress));
 372 
 373             AmlAddress++;
 374             NameString = AcpiExAllocateNameString (PrefixCount, 2);
 375             if (!NameString)
 376             {
 377                 Status = AE_NO_MEMORY;
 378                 break;
 379             }
 380 
 381             /* Indicate that we processed a prefix */
 382 
 383             HasPrefix = TRUE;
 384 
 385             Status = AcpiExNameSegment (&AmlAddress, NameString);
 386             if (ACPI_SUCCESS (Status))
 387             {
 388                 Status = AcpiExNameSegment (&AmlAddress, NameString);
 389             }
 390             break;
 391 
 392 
 393         case AML_MULTI_NAME_PREFIX_OP:
 394 
 395             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
 396                 AmlAddress));
 397 
 398             /* Fetch count of segments remaining in name path */
 399 
 400             AmlAddress++;
 401             NumSegments = *AmlAddress;
 402 
 403             NameString = AcpiExAllocateNameString (PrefixCount, NumSegments);
 404             if (!NameString)
 405             {
 406                 Status = AE_NO_MEMORY;
 407                 break;
 408             }
 409 
 410             /* Indicate that we processed a prefix */
 411 
 412             AmlAddress++;
 413             HasPrefix = TRUE;
 414 
 415             while (NumSegments &&
 416                     (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
 417                         AE_OK)
 418             {
 419                 NumSegments--;
 420             }
 421 
 422             break;
 423 
 424 
 425         case 0:
 426 
 427             /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
 428 
 429             if (PrefixCount == ACPI_UINT32_MAX)
 430             {
 431                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 432                     "NameSeg is \"\\\" followed by NULL\n"));
 433             }
 434 
 435             /* Consume the NULL byte */
 436 
 437             AmlAddress++;
 438             NameString = AcpiExAllocateNameString (PrefixCount, 0);
 439             if (!NameString)
 440             {
 441                 Status = AE_NO_MEMORY;
 442                 break;
 443             }
 444 
 445             break;
 446 
 447 
 448         default:
 449 
 450             /* Name segment string */
 451 
 452             NameString = AcpiExAllocateNameString (PrefixCount, 1);
 453             if (!NameString)
 454             {
 455                 Status = AE_NO_MEMORY;
 456                 break;
 457             }
 458 
 459             Status = AcpiExNameSegment (&AmlAddress, NameString);
 460             break;
 461         }
 462     }
 463 
 464     if (AE_CTRL_PENDING == Status && HasPrefix)
 465     {
 466         /* Ran out of segments after processing a prefix */
 467 
 468         ACPI_ERROR ((AE_INFO,
 469             "Malformed Name at %p", NameString));
 470         Status = AE_AML_BAD_NAME;
 471     }
 472 
 473     if (ACPI_FAILURE (Status))
 474     {
 475         if (NameString)
 476         {
 477             ACPI_FREE (NameString);
 478         }
 479         return_ACPI_STATUS (Status);
 480     }
 481 
 482     *OutNameString = NameString;
 483     *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
 484 
 485     return_ACPI_STATUS (Status);
 486 }
 487 
 488 

   1 /******************************************************************************
   2  *
   3  * Module Name: exnames - interpreter/scanner name load/execute
   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.


 317         /*
 318          * DataType is not a field name.
 319          * Examine first character of name for root or parent prefix operators
 320          */
 321         switch (*AmlAddress)
 322         {
 323         case AML_ROOT_PREFIX:
 324 
 325             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
 326                 AmlAddress));
 327 
 328             /*
 329              * Remember that we have a RootPrefix --
 330              * see comment in AcpiExAllocateNameString()
 331              */
 332             AmlAddress++;
 333             PrefixCount = ACPI_UINT32_MAX;
 334             HasPrefix = TRUE;
 335             break;
 336 

 337         case AML_PARENT_PREFIX:
 338 
 339             /* Increment past possibly multiple parent prefixes */
 340 
 341             do
 342             {
 343                 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
 344                     AmlAddress));
 345 
 346                 AmlAddress++;
 347                 PrefixCount++;
 348 
 349             } while (*AmlAddress == AML_PARENT_PREFIX);
 350 
 351             HasPrefix = TRUE;
 352             break;
 353 

 354         default:
 355 
 356             /* Not a prefix character */
 357 
 358             break;
 359         }
 360 
 361         /* Examine first character of name for name segment prefix operator */
 362 
 363         switch (*AmlAddress)
 364         {
 365         case AML_DUAL_NAME_PREFIX:
 366 
 367             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
 368                 AmlAddress));
 369 
 370             AmlAddress++;
 371             NameString = AcpiExAllocateNameString (PrefixCount, 2);
 372             if (!NameString)
 373             {
 374                 Status = AE_NO_MEMORY;
 375                 break;
 376             }
 377 
 378             /* Indicate that we processed a prefix */
 379 
 380             HasPrefix = TRUE;
 381 
 382             Status = AcpiExNameSegment (&AmlAddress, NameString);
 383             if (ACPI_SUCCESS (Status))
 384             {
 385                 Status = AcpiExNameSegment (&AmlAddress, NameString);
 386             }
 387             break;
 388 

 389         case AML_MULTI_NAME_PREFIX_OP:
 390 
 391             ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
 392                 AmlAddress));
 393 
 394             /* Fetch count of segments remaining in name path */
 395 
 396             AmlAddress++;
 397             NumSegments = *AmlAddress;
 398 
 399             NameString = AcpiExAllocateNameString (PrefixCount, NumSegments);
 400             if (!NameString)
 401             {
 402                 Status = AE_NO_MEMORY;
 403                 break;
 404             }
 405 
 406             /* Indicate that we processed a prefix */
 407 
 408             AmlAddress++;
 409             HasPrefix = TRUE;
 410 
 411             while (NumSegments &&
 412                     (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
 413                         AE_OK)
 414             {
 415                 NumSegments--;
 416             }
 417 
 418             break;
 419 

 420         case 0:
 421 
 422             /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
 423 
 424             if (PrefixCount == ACPI_UINT32_MAX)
 425             {
 426                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 427                     "NameSeg is \"\\\" followed by NULL\n"));
 428             }
 429 
 430             /* Consume the NULL byte */
 431 
 432             AmlAddress++;
 433             NameString = AcpiExAllocateNameString (PrefixCount, 0);
 434             if (!NameString)
 435             {
 436                 Status = AE_NO_MEMORY;
 437                 break;
 438             }
 439 
 440             break;
 441 

 442         default:
 443 
 444             /* Name segment string */
 445 
 446             NameString = AcpiExAllocateNameString (PrefixCount, 1);
 447             if (!NameString)
 448             {
 449                 Status = AE_NO_MEMORY;
 450                 break;
 451             }
 452 
 453             Status = AcpiExNameSegment (&AmlAddress, NameString);
 454             break;
 455         }
 456     }
 457 
 458     if (AE_CTRL_PENDING == Status && HasPrefix)
 459     {
 460         /* Ran out of segments after processing a prefix */
 461 
 462         ACPI_ERROR ((AE_INFO,
 463             "Malformed Name at %p", NameString));
 464         Status = AE_AML_BAD_NAME;
 465     }
 466 
 467     if (ACPI_FAILURE (Status))
 468     {
 469         if (NameString)
 470         {
 471             ACPI_FREE (NameString);
 472         }
 473         return_ACPI_STATUS (Status);
 474     }
 475 
 476     *OutNameString = NameString;
 477     *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
 478 
 479     return_ACPI_STATUS (Status);
 480 }