1*3446Smrj /******************************************************************************* 2*3446Smrj * 3*3446Smrj * Module Name: utmisc - common utility procedures 4*3446Smrj * $Revision: 1.146 $ 5*3446Smrj * 6*3446Smrj ******************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj 118*3446Smrj #define __UTMISC_C__ 119*3446Smrj 120*3446Smrj #include "acpi.h" 121*3446Smrj #include "acnamesp.h" 122*3446Smrj 123*3446Smrj 124*3446Smrj #define _COMPONENT ACPI_UTILITIES 125*3446Smrj ACPI_MODULE_NAME ("utmisc") 126*3446Smrj 127*3446Smrj 128*3446Smrj /******************************************************************************* 129*3446Smrj * 130*3446Smrj * FUNCTION: AcpiUtIsAmlTable 131*3446Smrj * 132*3446Smrj * PARAMETERS: Table - An ACPI table 133*3446Smrj * 134*3446Smrj * RETURN: TRUE if table contains executable AML; FALSE otherwise 135*3446Smrj * 136*3446Smrj * DESCRIPTION: Check ACPI Signature for a table that contains AML code. 137*3446Smrj * Currently, these are DSDT,SSDT,PSDT. All other table types are 138*3446Smrj * data tables that do not contain AML code. 139*3446Smrj * 140*3446Smrj ******************************************************************************/ 141*3446Smrj 142*3446Smrj BOOLEAN 143*3446Smrj AcpiUtIsAmlTable ( 144*3446Smrj ACPI_TABLE_HEADER *Table) 145*3446Smrj { 146*3446Smrj 147*3446Smrj /* These are the only tables that contain executable AML */ 148*3446Smrj 149*3446Smrj if (ACPI_COMPARE_NAME (Table->Signature, DSDT_SIG) || 150*3446Smrj ACPI_COMPARE_NAME (Table->Signature, PSDT_SIG) || 151*3446Smrj ACPI_COMPARE_NAME (Table->Signature, SSDT_SIG)) 152*3446Smrj { 153*3446Smrj return (TRUE); 154*3446Smrj } 155*3446Smrj 156*3446Smrj return (FALSE); 157*3446Smrj } 158*3446Smrj 159*3446Smrj 160*3446Smrj /******************************************************************************* 161*3446Smrj * 162*3446Smrj * FUNCTION: AcpiUtAllocateOwnerId 163*3446Smrj * 164*3446Smrj * PARAMETERS: OwnerId - Where the new owner ID is returned 165*3446Smrj * 166*3446Smrj * RETURN: Status 167*3446Smrj * 168*3446Smrj * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to 169*3446Smrj * track objects created by the table or method, to be deleted 170*3446Smrj * when the method exits or the table is unloaded. 171*3446Smrj * 172*3446Smrj ******************************************************************************/ 173*3446Smrj 174*3446Smrj ACPI_STATUS 175*3446Smrj AcpiUtAllocateOwnerId ( 176*3446Smrj ACPI_OWNER_ID *OwnerId) 177*3446Smrj { 178*3446Smrj ACPI_NATIVE_UINT i; 179*3446Smrj ACPI_NATIVE_UINT j; 180*3446Smrj ACPI_NATIVE_UINT k; 181*3446Smrj ACPI_STATUS Status; 182*3446Smrj 183*3446Smrj 184*3446Smrj ACPI_FUNCTION_TRACE (UtAllocateOwnerId); 185*3446Smrj 186*3446Smrj 187*3446Smrj /* Guard against multiple allocations of ID to the same location */ 188*3446Smrj 189*3446Smrj if (*OwnerId) 190*3446Smrj { 191*3446Smrj ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId)); 192*3446Smrj return_ACPI_STATUS (AE_ALREADY_EXISTS); 193*3446Smrj } 194*3446Smrj 195*3446Smrj /* Mutex for the global ID mask */ 196*3446Smrj 197*3446Smrj Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); 198*3446Smrj if (ACPI_FAILURE (Status)) 199*3446Smrj { 200*3446Smrj return_ACPI_STATUS (Status); 201*3446Smrj } 202*3446Smrj 203*3446Smrj /* 204*3446Smrj * Find a free owner ID, cycle through all possible IDs on repeated 205*3446Smrj * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have 206*3446Smrj * to be scanned twice. 207*3446Smrj */ 208*3446Smrj for (i = 0, j = AcpiGbl_LastOwnerIdIndex; 209*3446Smrj i < (ACPI_NUM_OWNERID_MASKS + 1); 210*3446Smrj i++, j++) 211*3446Smrj { 212*3446Smrj if (j >= ACPI_NUM_OWNERID_MASKS) 213*3446Smrj { 214*3446Smrj j = 0; /* Wraparound to start of mask array */ 215*3446Smrj } 216*3446Smrj 217*3446Smrj for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++) 218*3446Smrj { 219*3446Smrj if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX) 220*3446Smrj { 221*3446Smrj /* There are no free IDs in this mask */ 222*3446Smrj 223*3446Smrj break; 224*3446Smrj } 225*3446Smrj 226*3446Smrj if (!(AcpiGbl_OwnerIdMask[j] & (1 << k))) 227*3446Smrj { 228*3446Smrj /* 229*3446Smrj * Found a free ID. The actual ID is the bit index plus one, 230*3446Smrj * making zero an invalid Owner ID. Save this as the last ID 231*3446Smrj * allocated and update the global ID mask. 232*3446Smrj */ 233*3446Smrj AcpiGbl_OwnerIdMask[j] |= (1 << k); 234*3446Smrj 235*3446Smrj AcpiGbl_LastOwnerIdIndex = (UINT8) j; 236*3446Smrj AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1); 237*3446Smrj 238*3446Smrj /* 239*3446Smrj * Construct encoded ID from the index and bit position 240*3446Smrj * 241*3446Smrj * Note: Last [j].k (bit 255) is never used and is marked 242*3446Smrj * permanently allocated (prevents +1 overflow) 243*3446Smrj */ 244*3446Smrj *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j)); 245*3446Smrj 246*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, 247*3446Smrj "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId)); 248*3446Smrj goto Exit; 249*3446Smrj } 250*3446Smrj } 251*3446Smrj 252*3446Smrj AcpiGbl_NextOwnerIdOffset = 0; 253*3446Smrj } 254*3446Smrj 255*3446Smrj /* 256*3446Smrj * All OwnerIds have been allocated. This typically should 257*3446Smrj * not happen since the IDs are reused after deallocation. The IDs are 258*3446Smrj * allocated upon table load (one per table) and method execution, and 259*3446Smrj * they are released when a table is unloaded or a method completes 260*3446Smrj * execution. 261*3446Smrj * 262*3446Smrj * If this error happens, there may be very deep nesting of invoked control 263*3446Smrj * methods, or there may be a bug where the IDs are not released. 264*3446Smrj */ 265*3446Smrj Status = AE_OWNER_ID_LIMIT; 266*3446Smrj ACPI_ERROR ((AE_INFO, 267*3446Smrj "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); 268*3446Smrj 269*3446Smrj Exit: 270*3446Smrj (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); 271*3446Smrj return_ACPI_STATUS (Status); 272*3446Smrj } 273*3446Smrj 274*3446Smrj 275*3446Smrj /******************************************************************************* 276*3446Smrj * 277*3446Smrj * FUNCTION: AcpiUtReleaseOwnerId 278*3446Smrj * 279*3446Smrj * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID 280*3446Smrj * 281*3446Smrj * RETURN: None. No error is returned because we are either exiting a 282*3446Smrj * control method or unloading a table. Either way, we would 283*3446Smrj * ignore any error anyway. 284*3446Smrj * 285*3446Smrj * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 286*3446Smrj * 287*3446Smrj ******************************************************************************/ 288*3446Smrj 289*3446Smrj void 290*3446Smrj AcpiUtReleaseOwnerId ( 291*3446Smrj ACPI_OWNER_ID *OwnerIdPtr) 292*3446Smrj { 293*3446Smrj ACPI_OWNER_ID OwnerId = *OwnerIdPtr; 294*3446Smrj ACPI_STATUS Status; 295*3446Smrj ACPI_NATIVE_UINT Index; 296*3446Smrj UINT32 Bit; 297*3446Smrj 298*3446Smrj 299*3446Smrj ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId); 300*3446Smrj 301*3446Smrj 302*3446Smrj /* Always clear the input OwnerId (zero is an invalid ID) */ 303*3446Smrj 304*3446Smrj *OwnerIdPtr = 0; 305*3446Smrj 306*3446Smrj /* Zero is not a valid OwnerID */ 307*3446Smrj 308*3446Smrj if (OwnerId == 0) 309*3446Smrj { 310*3446Smrj ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId)); 311*3446Smrj return_VOID; 312*3446Smrj } 313*3446Smrj 314*3446Smrj /* Mutex for the global ID mask */ 315*3446Smrj 316*3446Smrj Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); 317*3446Smrj if (ACPI_FAILURE (Status)) 318*3446Smrj { 319*3446Smrj return_VOID; 320*3446Smrj } 321*3446Smrj 322*3446Smrj /* Normalize the ID to zero */ 323*3446Smrj 324*3446Smrj OwnerId--; 325*3446Smrj 326*3446Smrj /* Decode ID to index/offset pair */ 327*3446Smrj 328*3446Smrj Index = ACPI_DIV_32 (OwnerId); 329*3446Smrj Bit = 1 << ACPI_MOD_32 (OwnerId); 330*3446Smrj 331*3446Smrj /* Free the owner ID only if it is valid */ 332*3446Smrj 333*3446Smrj if (AcpiGbl_OwnerIdMask[Index] & Bit) 334*3446Smrj { 335*3446Smrj AcpiGbl_OwnerIdMask[Index] ^= Bit; 336*3446Smrj } 337*3446Smrj else 338*3446Smrj { 339*3446Smrj ACPI_ERROR ((AE_INFO, 340*3446Smrj "Release of non-allocated OwnerId: %2.2X", OwnerId + 1)); 341*3446Smrj } 342*3446Smrj 343*3446Smrj (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); 344*3446Smrj return_VOID; 345*3446Smrj } 346*3446Smrj 347*3446Smrj 348*3446Smrj /******************************************************************************* 349*3446Smrj * 350*3446Smrj * FUNCTION: AcpiUtStrupr (strupr) 351*3446Smrj * 352*3446Smrj * PARAMETERS: SrcString - The source string to convert 353*3446Smrj * 354*3446Smrj * RETURN: None 355*3446Smrj * 356*3446Smrj * DESCRIPTION: Convert string to uppercase 357*3446Smrj * 358*3446Smrj * NOTE: This is not a POSIX function, so it appears here, not in utclib.c 359*3446Smrj * 360*3446Smrj ******************************************************************************/ 361*3446Smrj 362*3446Smrj void 363*3446Smrj AcpiUtStrupr ( 364*3446Smrj char *SrcString) 365*3446Smrj { 366*3446Smrj char *String; 367*3446Smrj 368*3446Smrj 369*3446Smrj ACPI_FUNCTION_ENTRY (); 370*3446Smrj 371*3446Smrj 372*3446Smrj if (!SrcString) 373*3446Smrj { 374*3446Smrj return; 375*3446Smrj } 376*3446Smrj 377*3446Smrj /* Walk entire string, uppercasing the letters */ 378*3446Smrj 379*3446Smrj for (String = SrcString; *String; String++) 380*3446Smrj { 381*3446Smrj *String = (char) ACPI_TOUPPER (*String); 382*3446Smrj } 383*3446Smrj 384*3446Smrj return; 385*3446Smrj } 386*3446Smrj 387*3446Smrj 388*3446Smrj /******************************************************************************* 389*3446Smrj * 390*3446Smrj * FUNCTION: AcpiUtPrintString 391*3446Smrj * 392*3446Smrj * PARAMETERS: String - Null terminated ASCII string 393*3446Smrj * MaxLength - Maximum output length 394*3446Smrj * 395*3446Smrj * RETURN: None 396*3446Smrj * 397*3446Smrj * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape 398*3446Smrj * sequences. 399*3446Smrj * 400*3446Smrj ******************************************************************************/ 401*3446Smrj 402*3446Smrj void 403*3446Smrj AcpiUtPrintString ( 404*3446Smrj char *String, 405*3446Smrj UINT8 MaxLength) 406*3446Smrj { 407*3446Smrj UINT32 i; 408*3446Smrj 409*3446Smrj 410*3446Smrj if (!String) 411*3446Smrj { 412*3446Smrj AcpiOsPrintf ("<\"NULL STRING PTR\">"); 413*3446Smrj return; 414*3446Smrj } 415*3446Smrj 416*3446Smrj AcpiOsPrintf ("\""); 417*3446Smrj for (i = 0; String[i] && (i < MaxLength); i++) 418*3446Smrj { 419*3446Smrj /* Escape sequences */ 420*3446Smrj 421*3446Smrj switch (String[i]) 422*3446Smrj { 423*3446Smrj case 0x07: 424*3446Smrj AcpiOsPrintf ("\\a"); /* BELL */ 425*3446Smrj break; 426*3446Smrj 427*3446Smrj case 0x08: 428*3446Smrj AcpiOsPrintf ("\\b"); /* BACKSPACE */ 429*3446Smrj break; 430*3446Smrj 431*3446Smrj case 0x0C: 432*3446Smrj AcpiOsPrintf ("\\f"); /* FORMFEED */ 433*3446Smrj break; 434*3446Smrj 435*3446Smrj case 0x0A: 436*3446Smrj AcpiOsPrintf ("\\n"); /* LINEFEED */ 437*3446Smrj break; 438*3446Smrj 439*3446Smrj case 0x0D: 440*3446Smrj AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ 441*3446Smrj break; 442*3446Smrj 443*3446Smrj case 0x09: 444*3446Smrj AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ 445*3446Smrj break; 446*3446Smrj 447*3446Smrj case 0x0B: 448*3446Smrj AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ 449*3446Smrj break; 450*3446Smrj 451*3446Smrj case '\'': /* Single Quote */ 452*3446Smrj case '\"': /* Double Quote */ 453*3446Smrj case '\\': /* Backslash */ 454*3446Smrj AcpiOsPrintf ("\\%c", (int) String[i]); 455*3446Smrj break; 456*3446Smrj 457*3446Smrj default: 458*3446Smrj 459*3446Smrj /* Check for printable character or hex escape */ 460*3446Smrj 461*3446Smrj if (ACPI_IS_PRINT (String[i])) 462*3446Smrj { 463*3446Smrj /* This is a normal character */ 464*3446Smrj 465*3446Smrj AcpiOsPrintf ("%c", (int) String[i]); 466*3446Smrj } 467*3446Smrj else 468*3446Smrj { 469*3446Smrj /* All others will be Hex escapes */ 470*3446Smrj 471*3446Smrj AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); 472*3446Smrj } 473*3446Smrj break; 474*3446Smrj } 475*3446Smrj } 476*3446Smrj AcpiOsPrintf ("\""); 477*3446Smrj 478*3446Smrj if (i == MaxLength && String[i]) 479*3446Smrj { 480*3446Smrj AcpiOsPrintf ("..."); 481*3446Smrj } 482*3446Smrj } 483*3446Smrj 484*3446Smrj 485*3446Smrj /******************************************************************************* 486*3446Smrj * 487*3446Smrj * FUNCTION: AcpiUtDwordByteSwap 488*3446Smrj * 489*3446Smrj * PARAMETERS: Value - Value to be converted 490*3446Smrj * 491*3446Smrj * RETURN: UINT32 integer with bytes swapped 492*3446Smrj * 493*3446Smrj * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) 494*3446Smrj * 495*3446Smrj ******************************************************************************/ 496*3446Smrj 497*3446Smrj UINT32 498*3446Smrj AcpiUtDwordByteSwap ( 499*3446Smrj UINT32 Value) 500*3446Smrj { 501*3446Smrj union 502*3446Smrj { 503*3446Smrj UINT32 Value; 504*3446Smrj UINT8 Bytes[4]; 505*3446Smrj } Out; 506*3446Smrj union 507*3446Smrj { 508*3446Smrj UINT32 Value; 509*3446Smrj UINT8 Bytes[4]; 510*3446Smrj } In; 511*3446Smrj 512*3446Smrj 513*3446Smrj ACPI_FUNCTION_ENTRY (); 514*3446Smrj 515*3446Smrj 516*3446Smrj In.Value = Value; 517*3446Smrj 518*3446Smrj Out.Bytes[0] = In.Bytes[3]; 519*3446Smrj Out.Bytes[1] = In.Bytes[2]; 520*3446Smrj Out.Bytes[2] = In.Bytes[1]; 521*3446Smrj Out.Bytes[3] = In.Bytes[0]; 522*3446Smrj 523*3446Smrj return (Out.Value); 524*3446Smrj } 525*3446Smrj 526*3446Smrj 527*3446Smrj /******************************************************************************* 528*3446Smrj * 529*3446Smrj * FUNCTION: AcpiUtSetIntegerWidth 530*3446Smrj * 531*3446Smrj * PARAMETERS: Revision From DSDT header 532*3446Smrj * 533*3446Smrj * RETURN: None 534*3446Smrj * 535*3446Smrj * DESCRIPTION: Set the global integer bit width based upon the revision 536*3446Smrj * of the DSDT. For Revision 1 and 0, Integers are 32 bits. 537*3446Smrj * For Revision 2 and above, Integers are 64 bits. Yes, this 538*3446Smrj * makes a difference. 539*3446Smrj * 540*3446Smrj ******************************************************************************/ 541*3446Smrj 542*3446Smrj void 543*3446Smrj AcpiUtSetIntegerWidth ( 544*3446Smrj UINT8 Revision) 545*3446Smrj { 546*3446Smrj 547*3446Smrj if (Revision <= 1) 548*3446Smrj { 549*3446Smrj /* 32-bit case */ 550*3446Smrj 551*3446Smrj AcpiGbl_IntegerBitWidth = 32; 552*3446Smrj AcpiGbl_IntegerNybbleWidth = 8; 553*3446Smrj AcpiGbl_IntegerByteWidth = 4; 554*3446Smrj } 555*3446Smrj else 556*3446Smrj { 557*3446Smrj /* 64-bit case (ACPI 2.0+) */ 558*3446Smrj 559*3446Smrj AcpiGbl_IntegerBitWidth = 64; 560*3446Smrj AcpiGbl_IntegerNybbleWidth = 16; 561*3446Smrj AcpiGbl_IntegerByteWidth = 8; 562*3446Smrj } 563*3446Smrj } 564*3446Smrj 565*3446Smrj 566*3446Smrj #ifdef ACPI_DEBUG_OUTPUT 567*3446Smrj /******************************************************************************* 568*3446Smrj * 569*3446Smrj * FUNCTION: AcpiUtDisplayInitPathname 570*3446Smrj * 571*3446Smrj * PARAMETERS: Type - Object type of the node 572*3446Smrj * ObjHandle - Handle whose pathname will be displayed 573*3446Smrj * Path - Additional path string to be appended. 574*3446Smrj * (NULL if no extra path) 575*3446Smrj * 576*3446Smrj * RETURN: ACPI_STATUS 577*3446Smrj * 578*3446Smrj * DESCRIPTION: Display full pathname of an object, DEBUG ONLY 579*3446Smrj * 580*3446Smrj ******************************************************************************/ 581*3446Smrj 582*3446Smrj void 583*3446Smrj AcpiUtDisplayInitPathname ( 584*3446Smrj UINT8 Type, 585*3446Smrj ACPI_NAMESPACE_NODE *ObjHandle, 586*3446Smrj char *Path) 587*3446Smrj { 588*3446Smrj ACPI_STATUS Status; 589*3446Smrj ACPI_BUFFER Buffer; 590*3446Smrj 591*3446Smrj 592*3446Smrj ACPI_FUNCTION_ENTRY (); 593*3446Smrj 594*3446Smrj 595*3446Smrj /* Only print the path if the appropriate debug level is enabled */ 596*3446Smrj 597*3446Smrj if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) 598*3446Smrj { 599*3446Smrj return; 600*3446Smrj } 601*3446Smrj 602*3446Smrj /* Get the full pathname to the node */ 603*3446Smrj 604*3446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 605*3446Smrj Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 606*3446Smrj if (ACPI_FAILURE (Status)) 607*3446Smrj { 608*3446Smrj return; 609*3446Smrj } 610*3446Smrj 611*3446Smrj /* Print what we're doing */ 612*3446Smrj 613*3446Smrj switch (Type) 614*3446Smrj { 615*3446Smrj case ACPI_TYPE_METHOD: 616*3446Smrj AcpiOsPrintf ("Executing "); 617*3446Smrj break; 618*3446Smrj 619*3446Smrj default: 620*3446Smrj AcpiOsPrintf ("Initializing "); 621*3446Smrj break; 622*3446Smrj } 623*3446Smrj 624*3446Smrj /* Print the object type and pathname */ 625*3446Smrj 626*3446Smrj AcpiOsPrintf ("%-12s %s", 627*3446Smrj AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); 628*3446Smrj 629*3446Smrj /* Extra path is used to append names like _STA, _INI, etc. */ 630*3446Smrj 631*3446Smrj if (Path) 632*3446Smrj { 633*3446Smrj AcpiOsPrintf (".%s", Path); 634*3446Smrj } 635*3446Smrj AcpiOsPrintf ("\n"); 636*3446Smrj 637*3446Smrj ACPI_FREE (Buffer.Pointer); 638*3446Smrj } 639*3446Smrj #endif 640*3446Smrj 641*3446Smrj 642*3446Smrj /******************************************************************************* 643*3446Smrj * 644*3446Smrj * FUNCTION: AcpiUtValidAcpiChar 645*3446Smrj * 646*3446Smrj * PARAMETERS: Char - The character to be examined 647*3446Smrj * Position - Byte position (0-3) 648*3446Smrj * 649*3446Smrj * RETURN: TRUE if the character is valid, FALSE otherwise 650*3446Smrj * 651*3446Smrj * DESCRIPTION: Check for a valid ACPI character. Must be one of: 652*3446Smrj * 1) Upper case alpha 653*3446Smrj * 2) numeric 654*3446Smrj * 3) underscore 655*3446Smrj * 656*3446Smrj * We allow a '!' as the last character because of the ASF! table 657*3446Smrj * 658*3446Smrj ******************************************************************************/ 659*3446Smrj 660*3446Smrj BOOLEAN 661*3446Smrj AcpiUtValidAcpiChar ( 662*3446Smrj char Character, 663*3446Smrj ACPI_NATIVE_UINT Position) 664*3446Smrj { 665*3446Smrj 666*3446Smrj if (!((Character >= 'A' && Character <= 'Z') || 667*3446Smrj (Character >= '0' && Character <= '9') || 668*3446Smrj (Character == '_'))) 669*3446Smrj { 670*3446Smrj /* Allow a '!' in the last position */ 671*3446Smrj 672*3446Smrj if (Character == '!' && Position == 3) 673*3446Smrj { 674*3446Smrj return (TRUE); 675*3446Smrj } 676*3446Smrj 677*3446Smrj return (FALSE); 678*3446Smrj } 679*3446Smrj 680*3446Smrj return (TRUE); 681*3446Smrj } 682*3446Smrj 683*3446Smrj 684*3446Smrj /******************************************************************************* 685*3446Smrj * 686*3446Smrj * FUNCTION: AcpiUtValidAcpiName 687*3446Smrj * 688*3446Smrj * PARAMETERS: Name - The name to be examined 689*3446Smrj * 690*3446Smrj * RETURN: TRUE if the name is valid, FALSE otherwise 691*3446Smrj * 692*3446Smrj * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: 693*3446Smrj * 1) Upper case alpha 694*3446Smrj * 2) numeric 695*3446Smrj * 3) underscore 696*3446Smrj * 697*3446Smrj ******************************************************************************/ 698*3446Smrj 699*3446Smrj BOOLEAN 700*3446Smrj AcpiUtValidAcpiName ( 701*3446Smrj UINT32 Name) 702*3446Smrj { 703*3446Smrj ACPI_NATIVE_UINT i; 704*3446Smrj 705*3446Smrj 706*3446Smrj ACPI_FUNCTION_ENTRY (); 707*3446Smrj 708*3446Smrj 709*3446Smrj for (i = 0; i < ACPI_NAME_SIZE; i++) 710*3446Smrj { 711*3446Smrj if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) 712*3446Smrj { 713*3446Smrj return (FALSE); 714*3446Smrj } 715*3446Smrj } 716*3446Smrj 717*3446Smrj return (TRUE); 718*3446Smrj } 719*3446Smrj 720*3446Smrj 721*3446Smrj /******************************************************************************* 722*3446Smrj * 723*3446Smrj * FUNCTION: AcpiUtRepairName 724*3446Smrj * 725*3446Smrj * PARAMETERS: Name - The ACPI name to be repaired 726*3446Smrj * 727*3446Smrj * RETURN: Repaired version of the name 728*3446Smrj * 729*3446Smrj * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and 730*3446Smrj * return the new name. 731*3446Smrj * 732*3446Smrj ******************************************************************************/ 733*3446Smrj 734*3446Smrj ACPI_NAME 735*3446Smrj AcpiUtRepairName ( 736*3446Smrj ACPI_NAME Name) 737*3446Smrj { 738*3446Smrj char *NamePtr = ACPI_CAST_PTR (char, &Name); 739*3446Smrj char NewName[ACPI_NAME_SIZE]; 740*3446Smrj ACPI_NATIVE_UINT i; 741*3446Smrj 742*3446Smrj 743*3446Smrj for (i = 0; i < ACPI_NAME_SIZE; i++) 744*3446Smrj { 745*3446Smrj NewName[i] = NamePtr[i]; 746*3446Smrj 747*3446Smrj /* 748*3446Smrj * Replace a bad character with something printable, yet technically 749*3446Smrj * still invalid. This prevents any collisions with existing "good" 750*3446Smrj * names in the namespace. 751*3446Smrj */ 752*3446Smrj if (!AcpiUtValidAcpiChar (NamePtr[i], i)) 753*3446Smrj { 754*3446Smrj NewName[i] = '*'; 755*3446Smrj } 756*3446Smrj } 757*3446Smrj 758*3446Smrj return (*ACPI_CAST_PTR (UINT32, NewName)); 759*3446Smrj } 760*3446Smrj 761*3446Smrj 762*3446Smrj /******************************************************************************* 763*3446Smrj * 764*3446Smrj * FUNCTION: AcpiUtStrtoul64 765*3446Smrj * 766*3446Smrj * PARAMETERS: String - Null terminated string 767*3446Smrj * Base - Radix of the string: 16 or ACPI_ANY_BASE; 768*3446Smrj * ACPI_ANY_BASE means 'in behalf of ToInteger' 769*3446Smrj * RetInteger - Where the converted integer is returned 770*3446Smrj * 771*3446Smrj * RETURN: Status and Converted value 772*3446Smrj * 773*3446Smrj * DESCRIPTION: Convert a string into an unsigned value. Performs either a 774*3446Smrj * 32-bit or 64-bit conversion, depending on the current mode 775*3446Smrj * of the interpreter. 776*3446Smrj * NOTE: Does not support Octal strings, not needed. 777*3446Smrj * 778*3446Smrj ******************************************************************************/ 779*3446Smrj 780*3446Smrj ACPI_STATUS 781*3446Smrj AcpiUtStrtoul64 ( 782*3446Smrj char *String, 783*3446Smrj UINT32 Base, 784*3446Smrj ACPI_INTEGER *RetInteger) 785*3446Smrj { 786*3446Smrj UINT32 ThisDigit = 0; 787*3446Smrj ACPI_INTEGER ReturnValue = 0; 788*3446Smrj ACPI_INTEGER Quotient; 789*3446Smrj ACPI_INTEGER Dividend; 790*3446Smrj UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); 791*3446Smrj UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); 792*3446Smrj UINT8 ValidDigits = 0; 793*3446Smrj UINT8 SignOf0x = 0; 794*3446Smrj UINT8 Term = 0; 795*3446Smrj 796*3446Smrj 797*3446Smrj ACPI_FUNCTION_TRACE_STR (UtStroul64, String); 798*3446Smrj 799*3446Smrj 800*3446Smrj switch (Base) 801*3446Smrj { 802*3446Smrj case ACPI_ANY_BASE: 803*3446Smrj case 16: 804*3446Smrj break; 805*3446Smrj 806*3446Smrj default: 807*3446Smrj /* Invalid Base */ 808*3446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER); 809*3446Smrj } 810*3446Smrj 811*3446Smrj if (!String) 812*3446Smrj { 813*3446Smrj goto ErrorExit; 814*3446Smrj } 815*3446Smrj 816*3446Smrj /* Skip over any white space in the buffer */ 817*3446Smrj 818*3446Smrj while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) 819*3446Smrj { 820*3446Smrj String++; 821*3446Smrj } 822*3446Smrj 823*3446Smrj if (ToIntegerOp) 824*3446Smrj { 825*3446Smrj /* 826*3446Smrj * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. 827*3446Smrj * We need to determine if it is decimal or hexadecimal. 828*3446Smrj */ 829*3446Smrj if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) 830*3446Smrj { 831*3446Smrj SignOf0x = 1; 832*3446Smrj Base = 16; 833*3446Smrj 834*3446Smrj /* Skip over the leading '0x' */ 835*3446Smrj String += 2; 836*3446Smrj } 837*3446Smrj else 838*3446Smrj { 839*3446Smrj Base = 10; 840*3446Smrj } 841*3446Smrj } 842*3446Smrj 843*3446Smrj /* Any string left? Check that '0x' is not followed by white space. */ 844*3446Smrj 845*3446Smrj if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') 846*3446Smrj { 847*3446Smrj if (ToIntegerOp) 848*3446Smrj { 849*3446Smrj goto ErrorExit; 850*3446Smrj } 851*3446Smrj else 852*3446Smrj { 853*3446Smrj goto AllDone; 854*3446Smrj } 855*3446Smrj } 856*3446Smrj 857*3446Smrj /* 858*3446Smrj * Perform a 32-bit or 64-bit conversion, depending upon the current 859*3446Smrj * execution mode of the interpreter 860*3446Smrj */ 861*3446Smrj Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; 862*3446Smrj 863*3446Smrj /* Main loop: convert the string to a 32- or 64-bit integer */ 864*3446Smrj 865*3446Smrj while (*String) 866*3446Smrj { 867*3446Smrj if (ACPI_IS_DIGIT (*String)) 868*3446Smrj { 869*3446Smrj /* Convert ASCII 0-9 to Decimal value */ 870*3446Smrj 871*3446Smrj ThisDigit = ((UINT8) *String) - '0'; 872*3446Smrj } 873*3446Smrj else if (Base == 10) 874*3446Smrj { 875*3446Smrj /* Digit is out of range; possible in ToInteger case only */ 876*3446Smrj 877*3446Smrj Term = 1; 878*3446Smrj } 879*3446Smrj else 880*3446Smrj { 881*3446Smrj ThisDigit = (UINT8) ACPI_TOUPPER (*String); 882*3446Smrj if (ACPI_IS_XDIGIT ((char) ThisDigit)) 883*3446Smrj { 884*3446Smrj /* Convert ASCII Hex char to value */ 885*3446Smrj 886*3446Smrj ThisDigit = ThisDigit - 'A' + 10; 887*3446Smrj } 888*3446Smrj else 889*3446Smrj { 890*3446Smrj Term = 1; 891*3446Smrj } 892*3446Smrj } 893*3446Smrj 894*3446Smrj if (Term) 895*3446Smrj { 896*3446Smrj if (ToIntegerOp) 897*3446Smrj { 898*3446Smrj goto ErrorExit; 899*3446Smrj } 900*3446Smrj else 901*3446Smrj { 902*3446Smrj break; 903*3446Smrj } 904*3446Smrj } 905*3446Smrj else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) 906*3446Smrj { 907*3446Smrj /* Skip zeros */ 908*3446Smrj String++; 909*3446Smrj continue; 910*3446Smrj } 911*3446Smrj 912*3446Smrj ValidDigits++; 913*3446Smrj 914*3446Smrj if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) 915*3446Smrj { 916*3446Smrj /* 917*3446Smrj * This is ToInteger operation case. 918*3446Smrj * No any restrictions for string-to-integer conversion, 919*3446Smrj * see ACPI spec. 920*3446Smrj */ 921*3446Smrj goto ErrorExit; 922*3446Smrj } 923*3446Smrj 924*3446Smrj /* Divide the digit into the correct position */ 925*3446Smrj 926*3446Smrj (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), 927*3446Smrj Base, &Quotient, NULL); 928*3446Smrj 929*3446Smrj if (ReturnValue > Quotient) 930*3446Smrj { 931*3446Smrj if (ToIntegerOp) 932*3446Smrj { 933*3446Smrj goto ErrorExit; 934*3446Smrj } 935*3446Smrj else 936*3446Smrj { 937*3446Smrj break; 938*3446Smrj } 939*3446Smrj } 940*3446Smrj 941*3446Smrj ReturnValue *= Base; 942*3446Smrj ReturnValue += ThisDigit; 943*3446Smrj String++; 944*3446Smrj } 945*3446Smrj 946*3446Smrj /* All done, normal exit */ 947*3446Smrj 948*3446Smrj AllDone: 949*3446Smrj 950*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", 951*3446Smrj ACPI_FORMAT_UINT64 (ReturnValue))); 952*3446Smrj 953*3446Smrj *RetInteger = ReturnValue; 954*3446Smrj return_ACPI_STATUS (AE_OK); 955*3446Smrj 956*3446Smrj 957*3446Smrj ErrorExit: 958*3446Smrj /* Base was set/validated above */ 959*3446Smrj 960*3446Smrj if (Base == 10) 961*3446Smrj { 962*3446Smrj return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); 963*3446Smrj } 964*3446Smrj else 965*3446Smrj { 966*3446Smrj return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); 967*3446Smrj } 968*3446Smrj } 969*3446Smrj 970*3446Smrj 971*3446Smrj /******************************************************************************* 972*3446Smrj * 973*3446Smrj * FUNCTION: AcpiUtCreateUpdateStateAndPush 974*3446Smrj * 975*3446Smrj * PARAMETERS: Object - Object to be added to the new state 976*3446Smrj * Action - Increment/Decrement 977*3446Smrj * StateList - List the state will be added to 978*3446Smrj * 979*3446Smrj * RETURN: Status 980*3446Smrj * 981*3446Smrj * DESCRIPTION: Create a new state and push it 982*3446Smrj * 983*3446Smrj ******************************************************************************/ 984*3446Smrj 985*3446Smrj ACPI_STATUS 986*3446Smrj AcpiUtCreateUpdateStateAndPush ( 987*3446Smrj ACPI_OPERAND_OBJECT *Object, 988*3446Smrj UINT16 Action, 989*3446Smrj ACPI_GENERIC_STATE **StateList) 990*3446Smrj { 991*3446Smrj ACPI_GENERIC_STATE *State; 992*3446Smrj 993*3446Smrj 994*3446Smrj ACPI_FUNCTION_ENTRY (); 995*3446Smrj 996*3446Smrj 997*3446Smrj /* Ignore null objects; these are expected */ 998*3446Smrj 999*3446Smrj if (!Object) 1000*3446Smrj { 1001*3446Smrj return (AE_OK); 1002*3446Smrj } 1003*3446Smrj 1004*3446Smrj State = AcpiUtCreateUpdateState (Object, Action); 1005*3446Smrj if (!State) 1006*3446Smrj { 1007*3446Smrj return (AE_NO_MEMORY); 1008*3446Smrj } 1009*3446Smrj 1010*3446Smrj AcpiUtPushGenericState (StateList, State); 1011*3446Smrj return (AE_OK); 1012*3446Smrj } 1013*3446Smrj 1014*3446Smrj 1015*3446Smrj /******************************************************************************* 1016*3446Smrj * 1017*3446Smrj * FUNCTION: AcpiUtWalkPackageTree 1018*3446Smrj * 1019*3446Smrj * PARAMETERS: SourceObject - The package to walk 1020*3446Smrj * TargetObject - Target object (if package is being copied) 1021*3446Smrj * WalkCallback - Called once for each package element 1022*3446Smrj * Context - Passed to the callback function 1023*3446Smrj * 1024*3446Smrj * RETURN: Status 1025*3446Smrj * 1026*3446Smrj * DESCRIPTION: Walk through a package 1027*3446Smrj * 1028*3446Smrj ******************************************************************************/ 1029*3446Smrj 1030*3446Smrj ACPI_STATUS 1031*3446Smrj AcpiUtWalkPackageTree ( 1032*3446Smrj ACPI_OPERAND_OBJECT *SourceObject, 1033*3446Smrj void *TargetObject, 1034*3446Smrj ACPI_PKG_CALLBACK WalkCallback, 1035*3446Smrj void *Context) 1036*3446Smrj { 1037*3446Smrj ACPI_STATUS Status = AE_OK; 1038*3446Smrj ACPI_GENERIC_STATE *StateList = NULL; 1039*3446Smrj ACPI_GENERIC_STATE *State; 1040*3446Smrj UINT32 ThisIndex; 1041*3446Smrj ACPI_OPERAND_OBJECT *ThisSourceObj; 1042*3446Smrj 1043*3446Smrj 1044*3446Smrj ACPI_FUNCTION_TRACE (UtWalkPackageTree); 1045*3446Smrj 1046*3446Smrj 1047*3446Smrj State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); 1048*3446Smrj if (!State) 1049*3446Smrj { 1050*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 1051*3446Smrj } 1052*3446Smrj 1053*3446Smrj while (State) 1054*3446Smrj { 1055*3446Smrj /* Get one element of the package */ 1056*3446Smrj 1057*3446Smrj ThisIndex = State->Pkg.Index; 1058*3446Smrj ThisSourceObj = (ACPI_OPERAND_OBJECT *) 1059*3446Smrj State->Pkg.SourceObject->Package.Elements[ThisIndex]; 1060*3446Smrj 1061*3446Smrj /* 1062*3446Smrj * Check for: 1063*3446Smrj * 1) An uninitialized package element. It is completely 1064*3446Smrj * legal to declare a package and leave it uninitialized 1065*3446Smrj * 2) Not an internal object - can be a namespace node instead 1066*3446Smrj * 3) Any type other than a package. Packages are handled in else 1067*3446Smrj * case below. 1068*3446Smrj */ 1069*3446Smrj if ((!ThisSourceObj) || 1070*3446Smrj (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || 1071*3446Smrj (ACPI_GET_OBJECT_TYPE (ThisSourceObj) != ACPI_TYPE_PACKAGE)) 1072*3446Smrj { 1073*3446Smrj Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, 1074*3446Smrj State, Context); 1075*3446Smrj if (ACPI_FAILURE (Status)) 1076*3446Smrj { 1077*3446Smrj return_ACPI_STATUS (Status); 1078*3446Smrj } 1079*3446Smrj 1080*3446Smrj State->Pkg.Index++; 1081*3446Smrj while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) 1082*3446Smrj { 1083*3446Smrj /* 1084*3446Smrj * We've handled all of the objects at this level, This means 1085*3446Smrj * that we have just completed a package. That package may 1086*3446Smrj * have contained one or more packages itself. 1087*3446Smrj * 1088*3446Smrj * Delete this state and pop the previous state (package). 1089*3446Smrj */ 1090*3446Smrj AcpiUtDeleteGenericState (State); 1091*3446Smrj State = AcpiUtPopGenericState (&StateList); 1092*3446Smrj 1093*3446Smrj /* Finished when there are no more states */ 1094*3446Smrj 1095*3446Smrj if (!State) 1096*3446Smrj { 1097*3446Smrj /* 1098*3446Smrj * We have handled all of the objects in the top level 1099*3446Smrj * package just add the length of the package objects 1100*3446Smrj * and exit 1101*3446Smrj */ 1102*3446Smrj return_ACPI_STATUS (AE_OK); 1103*3446Smrj } 1104*3446Smrj 1105*3446Smrj /* 1106*3446Smrj * Go back up a level and move the index past the just 1107*3446Smrj * completed package object. 1108*3446Smrj */ 1109*3446Smrj State->Pkg.Index++; 1110*3446Smrj } 1111*3446Smrj } 1112*3446Smrj else 1113*3446Smrj { 1114*3446Smrj /* This is a subobject of type package */ 1115*3446Smrj 1116*3446Smrj Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, 1117*3446Smrj State, Context); 1118*3446Smrj if (ACPI_FAILURE (Status)) 1119*3446Smrj { 1120*3446Smrj return_ACPI_STATUS (Status); 1121*3446Smrj } 1122*3446Smrj 1123*3446Smrj /* 1124*3446Smrj * Push the current state and create a new one 1125*3446Smrj * The callback above returned a new target package object. 1126*3446Smrj */ 1127*3446Smrj AcpiUtPushGenericState (&StateList, State); 1128*3446Smrj State = AcpiUtCreatePkgState (ThisSourceObj, 1129*3446Smrj State->Pkg.ThisTargetObj, 0); 1130*3446Smrj if (!State) 1131*3446Smrj { 1132*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 1133*3446Smrj } 1134*3446Smrj } 1135*3446Smrj } 1136*3446Smrj 1137*3446Smrj /* We should never get here */ 1138*3446Smrj 1139*3446Smrj return_ACPI_STATUS (AE_AML_INTERNAL); 1140*3446Smrj } 1141*3446Smrj 1142*3446Smrj 1143*3446Smrj /******************************************************************************* 1144*3446Smrj * 1145*3446Smrj * FUNCTION: AcpiUtError, AcpiUtWarning, AcpiUtInfo 1146*3446Smrj * 1147*3446Smrj * PARAMETERS: ModuleName - Caller's module name (for error output) 1148*3446Smrj * LineNumber - Caller's line number (for error output) 1149*3446Smrj * Format - Printf format string + additional args 1150*3446Smrj * 1151*3446Smrj * RETURN: None 1152*3446Smrj * 1153*3446Smrj * DESCRIPTION: Print message with module/line/version info 1154*3446Smrj * 1155*3446Smrj ******************************************************************************/ 1156*3446Smrj 1157*3446Smrj void ACPI_INTERNAL_VAR_XFACE 1158*3446Smrj AcpiUtError ( 1159*3446Smrj char *ModuleName, 1160*3446Smrj UINT32 LineNumber, 1161*3446Smrj char *Format, 1162*3446Smrj ...) 1163*3446Smrj { 1164*3446Smrj va_list args; 1165*3446Smrj 1166*3446Smrj 1167*3446Smrj AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); 1168*3446Smrj 1169*3446Smrj va_start (args, Format); 1170*3446Smrj AcpiOsVprintf (Format, args); 1171*3446Smrj AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); 1172*3446Smrj } 1173*3446Smrj 1174*3446Smrj void ACPI_INTERNAL_VAR_XFACE 1175*3446Smrj AcpiUtException ( 1176*3446Smrj char *ModuleName, 1177*3446Smrj UINT32 LineNumber, 1178*3446Smrj ACPI_STATUS Status, 1179*3446Smrj char *Format, 1180*3446Smrj ...) 1181*3446Smrj { 1182*3446Smrj va_list args; 1183*3446Smrj 1184*3446Smrj 1185*3446Smrj AcpiOsPrintf ("ACPI Exception (%s-%04d): %s, ", ModuleName, LineNumber, 1186*3446Smrj AcpiFormatException (Status)); 1187*3446Smrj 1188*3446Smrj va_start (args, Format); 1189*3446Smrj AcpiOsVprintf (Format, args); 1190*3446Smrj AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); 1191*3446Smrj } 1192*3446Smrj 1193*3446Smrj void ACPI_INTERNAL_VAR_XFACE 1194*3446Smrj AcpiUtWarning ( 1195*3446Smrj char *ModuleName, 1196*3446Smrj UINT32 LineNumber, 1197*3446Smrj char *Format, 1198*3446Smrj ...) 1199*3446Smrj { 1200*3446Smrj va_list args; 1201*3446Smrj 1202*3446Smrj 1203*3446Smrj AcpiOsPrintf ("ACPI Warning (%s-%04d): ", ModuleName, LineNumber); 1204*3446Smrj 1205*3446Smrj va_start (args, Format); 1206*3446Smrj AcpiOsVprintf (Format, args); 1207*3446Smrj AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); 1208*3446Smrj } 1209*3446Smrj 1210*3446Smrj void ACPI_INTERNAL_VAR_XFACE 1211*3446Smrj AcpiUtInfo ( 1212*3446Smrj char *ModuleName, 1213*3446Smrj UINT32 LineNumber, 1214*3446Smrj char *Format, 1215*3446Smrj ...) 1216*3446Smrj { 1217*3446Smrj va_list args; 1218*3446Smrj 1219*3446Smrj 1220*3446Smrj AcpiOsPrintf ("ACPI (%s-%04d): ", ModuleName, LineNumber); 1221*3446Smrj 1222*3446Smrj va_start (args, Format); 1223*3446Smrj AcpiOsVprintf (Format, args); 1224*3446Smrj AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); 1225*3446Smrj } 1226*3446Smrj 1227