1a159c266SJung-uk Kim /******************************************************************************* 2a159c266SJung-uk Kim * 3a159c266SJung-uk Kim * Module Name: dbutils - AML debugger utilities 4a159c266SJung-uk Kim * 5a159c266SJung-uk Kim ******************************************************************************/ 6a159c266SJung-uk Kim 7a159c266SJung-uk Kim /* 8a159c266SJung-uk Kim * Copyright (C) 2000 - 2012, Intel Corp. 9a159c266SJung-uk Kim * All rights reserved. 10a159c266SJung-uk Kim * 11a159c266SJung-uk Kim * Redistribution and use in source and binary forms, with or without 12a159c266SJung-uk Kim * modification, are permitted provided that the following conditions 13a159c266SJung-uk Kim * are met: 14a159c266SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 15a159c266SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 16a159c266SJung-uk Kim * without modification. 17a159c266SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18a159c266SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 19a159c266SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 20a159c266SJung-uk Kim * including a substantially similar Disclaimer requirement for further 21a159c266SJung-uk Kim * binary redistribution. 22a159c266SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 23a159c266SJung-uk Kim * of any contributors may be used to endorse or promote products derived 24a159c266SJung-uk Kim * from this software without specific prior written permission. 25a159c266SJung-uk Kim * 26a159c266SJung-uk Kim * Alternatively, this software may be distributed under the terms of the 27a159c266SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 28a159c266SJung-uk Kim * Software Foundation. 29a159c266SJung-uk Kim * 30a159c266SJung-uk Kim * NO WARRANTY 31a159c266SJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32a159c266SJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33a159c266SJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34a159c266SJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35a159c266SJung-uk Kim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36a159c266SJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37a159c266SJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38a159c266SJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39a159c266SJung-uk Kim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40a159c266SJung-uk Kim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41a159c266SJung-uk Kim * POSSIBILITY OF SUCH DAMAGES. 42a159c266SJung-uk Kim */ 43a159c266SJung-uk Kim 44a159c266SJung-uk Kim 45a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h> 46a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h> 47a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 48a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdebug.h> 49a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 50a159c266SJung-uk Kim 51a159c266SJung-uk Kim 52a159c266SJung-uk Kim #ifdef ACPI_DEBUGGER 53a159c266SJung-uk Kim 54a159c266SJung-uk Kim #define _COMPONENT ACPI_CA_DEBUGGER 55a159c266SJung-uk Kim ACPI_MODULE_NAME ("dbutils") 56a159c266SJung-uk Kim 57a159c266SJung-uk Kim /* Local prototypes */ 58a159c266SJung-uk Kim 59a159c266SJung-uk Kim #ifdef ACPI_OBSOLETE_FUNCTIONS 60a159c266SJung-uk Kim ACPI_STATUS 61a159c266SJung-uk Kim AcpiDbSecondPassParse ( 62a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Root); 63a159c266SJung-uk Kim 64a159c266SJung-uk Kim void 65a159c266SJung-uk Kim AcpiDbDumpBuffer ( 66a159c266SJung-uk Kim UINT32 Address); 67a159c266SJung-uk Kim #endif 68a159c266SJung-uk Kim 69a159c266SJung-uk Kim static char *Converter = "0123456789ABCDEF"; 70a159c266SJung-uk Kim 71a159c266SJung-uk Kim 72a159c266SJung-uk Kim /******************************************************************************* 73a159c266SJung-uk Kim * 74a159c266SJung-uk Kim * FUNCTION: AcpiDbMatchArgument 75a159c266SJung-uk Kim * 76a159c266SJung-uk Kim * PARAMETERS: UserArgument - User command line 77a159c266SJung-uk Kim * Arguments - Array of commands to match against 78a159c266SJung-uk Kim * 79a159c266SJung-uk Kim * RETURN: Index into command array or ACPI_TYPE_NOT_FOUND if not found 80a159c266SJung-uk Kim * 81a159c266SJung-uk Kim * DESCRIPTION: Search command array for a command match 82a159c266SJung-uk Kim * 83a159c266SJung-uk Kim ******************************************************************************/ 84a159c266SJung-uk Kim 85a159c266SJung-uk Kim ACPI_OBJECT_TYPE 86a159c266SJung-uk Kim AcpiDbMatchArgument ( 87a159c266SJung-uk Kim char *UserArgument, 88042ff955SJung-uk Kim ACPI_DB_ARGUMENT_INFO *Arguments) 89a159c266SJung-uk Kim { 90a159c266SJung-uk Kim UINT32 i; 91a159c266SJung-uk Kim 92a159c266SJung-uk Kim 93a159c266SJung-uk Kim if (!UserArgument || UserArgument[0] == 0) 94a159c266SJung-uk Kim { 95a159c266SJung-uk Kim return (ACPI_TYPE_NOT_FOUND); 96a159c266SJung-uk Kim } 97a159c266SJung-uk Kim 98a159c266SJung-uk Kim for (i = 0; Arguments[i].Name; i++) 99a159c266SJung-uk Kim { 100a159c266SJung-uk Kim if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) 101a159c266SJung-uk Kim { 102a159c266SJung-uk Kim return (i); 103a159c266SJung-uk Kim } 104a159c266SJung-uk Kim } 105a159c266SJung-uk Kim 106a159c266SJung-uk Kim /* Argument not recognized */ 107a159c266SJung-uk Kim 108a159c266SJung-uk Kim return (ACPI_TYPE_NOT_FOUND); 109a159c266SJung-uk Kim } 110a159c266SJung-uk Kim 111a159c266SJung-uk Kim 112a159c266SJung-uk Kim /******************************************************************************* 113a159c266SJung-uk Kim * 114a159c266SJung-uk Kim * FUNCTION: AcpiDbSetOutputDestination 115a159c266SJung-uk Kim * 116a159c266SJung-uk Kim * PARAMETERS: OutputFlags - Current flags word 117a159c266SJung-uk Kim * 118a159c266SJung-uk Kim * RETURN: None 119a159c266SJung-uk Kim * 120a159c266SJung-uk Kim * DESCRIPTION: Set the current destination for debugger output. Also sets 121a159c266SJung-uk Kim * the debug output level accordingly. 122a159c266SJung-uk Kim * 123a159c266SJung-uk Kim ******************************************************************************/ 124a159c266SJung-uk Kim 125a159c266SJung-uk Kim void 126a159c266SJung-uk Kim AcpiDbSetOutputDestination ( 127a159c266SJung-uk Kim UINT32 OutputFlags) 128a159c266SJung-uk Kim { 129a159c266SJung-uk Kim 130a159c266SJung-uk Kim AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; 131a159c266SJung-uk Kim 132a159c266SJung-uk Kim if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile) 133a159c266SJung-uk Kim { 134a159c266SJung-uk Kim AcpiDbgLevel = AcpiGbl_DbDebugLevel; 135a159c266SJung-uk Kim } 136a159c266SJung-uk Kim else 137a159c266SJung-uk Kim { 138a159c266SJung-uk Kim AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; 139a159c266SJung-uk Kim } 140a159c266SJung-uk Kim } 141a159c266SJung-uk Kim 142a159c266SJung-uk Kim 143a159c266SJung-uk Kim /******************************************************************************* 144a159c266SJung-uk Kim * 145a159c266SJung-uk Kim * FUNCTION: AcpiDbDumpExternalObject 146a159c266SJung-uk Kim * 147a159c266SJung-uk Kim * PARAMETERS: ObjDesc - External ACPI object to dump 148a159c266SJung-uk Kim * Level - Nesting level. 149a159c266SJung-uk Kim * 150a159c266SJung-uk Kim * RETURN: None 151a159c266SJung-uk Kim * 152a159c266SJung-uk Kim * DESCRIPTION: Dump the contents of an ACPI external object 153a159c266SJung-uk Kim * 154a159c266SJung-uk Kim ******************************************************************************/ 155a159c266SJung-uk Kim 156a159c266SJung-uk Kim void 157a159c266SJung-uk Kim AcpiDbDumpExternalObject ( 158a159c266SJung-uk Kim ACPI_OBJECT *ObjDesc, 159a159c266SJung-uk Kim UINT32 Level) 160a159c266SJung-uk Kim { 161a159c266SJung-uk Kim UINT32 i; 162a159c266SJung-uk Kim 163a159c266SJung-uk Kim 164a159c266SJung-uk Kim if (!ObjDesc) 165a159c266SJung-uk Kim { 166a159c266SJung-uk Kim AcpiOsPrintf ("[Null Object]\n"); 167a159c266SJung-uk Kim return; 168a159c266SJung-uk Kim } 169a159c266SJung-uk Kim 170a159c266SJung-uk Kim for (i = 0; i < Level; i++) 171a159c266SJung-uk Kim { 172a159c266SJung-uk Kim AcpiOsPrintf (" "); 173a159c266SJung-uk Kim } 174a159c266SJung-uk Kim 175a159c266SJung-uk Kim switch (ObjDesc->Type) 176a159c266SJung-uk Kim { 177a159c266SJung-uk Kim case ACPI_TYPE_ANY: 178a159c266SJung-uk Kim 179a159c266SJung-uk Kim AcpiOsPrintf ("[Null Object] (Type=0)\n"); 180a159c266SJung-uk Kim break; 181a159c266SJung-uk Kim 182a159c266SJung-uk Kim 183a159c266SJung-uk Kim case ACPI_TYPE_INTEGER: 184a159c266SJung-uk Kim 185a159c266SJung-uk Kim AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", 186a159c266SJung-uk Kim ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); 187a159c266SJung-uk Kim break; 188a159c266SJung-uk Kim 189a159c266SJung-uk Kim 190a159c266SJung-uk Kim case ACPI_TYPE_STRING: 191a159c266SJung-uk Kim 192a159c266SJung-uk Kim AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length); 193eef1b955SJung-uk Kim AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); 194a159c266SJung-uk Kim AcpiOsPrintf ("\n"); 195a159c266SJung-uk Kim break; 196a159c266SJung-uk Kim 197a159c266SJung-uk Kim 198a159c266SJung-uk Kim case ACPI_TYPE_BUFFER: 199a159c266SJung-uk Kim 200a159c266SJung-uk Kim AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); 201a159c266SJung-uk Kim if (ObjDesc->Buffer.Length) 202a159c266SJung-uk Kim { 203a159c266SJung-uk Kim if (ObjDesc->Buffer.Length > 16) 204a159c266SJung-uk Kim { 205a159c266SJung-uk Kim AcpiOsPrintf ("\n"); 206a159c266SJung-uk Kim } 207*8ef1a331SJung-uk Kim AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), 208a159c266SJung-uk Kim ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT); 209a159c266SJung-uk Kim } 210a159c266SJung-uk Kim else 211a159c266SJung-uk Kim { 212a159c266SJung-uk Kim AcpiOsPrintf ("\n"); 213a159c266SJung-uk Kim } 214a159c266SJung-uk Kim break; 215a159c266SJung-uk Kim 216a159c266SJung-uk Kim 217a159c266SJung-uk Kim case ACPI_TYPE_PACKAGE: 218a159c266SJung-uk Kim 219a159c266SJung-uk Kim AcpiOsPrintf ("[Package] Contains %u Elements:\n", 220a159c266SJung-uk Kim ObjDesc->Package.Count); 221a159c266SJung-uk Kim 222a159c266SJung-uk Kim for (i = 0; i < ObjDesc->Package.Count; i++) 223a159c266SJung-uk Kim { 224a159c266SJung-uk Kim AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1); 225a159c266SJung-uk Kim } 226a159c266SJung-uk Kim break; 227a159c266SJung-uk Kim 228a159c266SJung-uk Kim 229a159c266SJung-uk Kim case ACPI_TYPE_LOCAL_REFERENCE: 230a159c266SJung-uk Kim 231a159c266SJung-uk Kim AcpiOsPrintf ("[Object Reference] = "); 232a159c266SJung-uk Kim AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); 233a159c266SJung-uk Kim break; 234a159c266SJung-uk Kim 235a159c266SJung-uk Kim 236a159c266SJung-uk Kim case ACPI_TYPE_PROCESSOR: 237a159c266SJung-uk Kim 238a159c266SJung-uk Kim AcpiOsPrintf ("[Processor]\n"); 239a159c266SJung-uk Kim break; 240a159c266SJung-uk Kim 241a159c266SJung-uk Kim 242a159c266SJung-uk Kim case ACPI_TYPE_POWER: 243a159c266SJung-uk Kim 244a159c266SJung-uk Kim AcpiOsPrintf ("[Power Resource]\n"); 245a159c266SJung-uk Kim break; 246a159c266SJung-uk Kim 247a159c266SJung-uk Kim 248a159c266SJung-uk Kim default: 249a159c266SJung-uk Kim 250a159c266SJung-uk Kim AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type); 251a159c266SJung-uk Kim break; 252a159c266SJung-uk Kim } 253a159c266SJung-uk Kim } 254a159c266SJung-uk Kim 255a159c266SJung-uk Kim 256a159c266SJung-uk Kim /******************************************************************************* 257a159c266SJung-uk Kim * 258a159c266SJung-uk Kim * FUNCTION: AcpiDbPrepNamestring 259a159c266SJung-uk Kim * 260a159c266SJung-uk Kim * PARAMETERS: Name - String to prepare 261a159c266SJung-uk Kim * 262a159c266SJung-uk Kim * RETURN: None 263a159c266SJung-uk Kim * 264a159c266SJung-uk Kim * DESCRIPTION: Translate all forward slashes and dots to backslashes. 265a159c266SJung-uk Kim * 266a159c266SJung-uk Kim ******************************************************************************/ 267a159c266SJung-uk Kim 268a159c266SJung-uk Kim void 269a159c266SJung-uk Kim AcpiDbPrepNamestring ( 270a159c266SJung-uk Kim char *Name) 271a159c266SJung-uk Kim { 272a159c266SJung-uk Kim 273a159c266SJung-uk Kim if (!Name) 274a159c266SJung-uk Kim { 275a159c266SJung-uk Kim return; 276a159c266SJung-uk Kim } 277a159c266SJung-uk Kim 278a159c266SJung-uk Kim AcpiUtStrupr (Name); 279a159c266SJung-uk Kim 280a159c266SJung-uk Kim /* Convert a leading forward slash to a backslash */ 281a159c266SJung-uk Kim 282a159c266SJung-uk Kim if (*Name == '/') 283a159c266SJung-uk Kim { 284a159c266SJung-uk Kim *Name = '\\'; 285a159c266SJung-uk Kim } 286a159c266SJung-uk Kim 287a159c266SJung-uk Kim /* Ignore a leading backslash, this is the root prefix */ 288a159c266SJung-uk Kim 289a159c266SJung-uk Kim if (*Name == '\\') 290a159c266SJung-uk Kim { 291a159c266SJung-uk Kim Name++; 292a159c266SJung-uk Kim } 293a159c266SJung-uk Kim 294a159c266SJung-uk Kim /* Convert all slash path separators to dots */ 295a159c266SJung-uk Kim 296a159c266SJung-uk Kim while (*Name) 297a159c266SJung-uk Kim { 298a159c266SJung-uk Kim if ((*Name == '/') || 299a159c266SJung-uk Kim (*Name == '\\')) 300a159c266SJung-uk Kim { 301a159c266SJung-uk Kim *Name = '.'; 302a159c266SJung-uk Kim } 303a159c266SJung-uk Kim 304a159c266SJung-uk Kim Name++; 305a159c266SJung-uk Kim } 306a159c266SJung-uk Kim } 307a159c266SJung-uk Kim 308a159c266SJung-uk Kim 309a159c266SJung-uk Kim /******************************************************************************* 310a159c266SJung-uk Kim * 311a159c266SJung-uk Kim * FUNCTION: AcpiDbLocalNsLookup 312a159c266SJung-uk Kim * 313a159c266SJung-uk Kim * PARAMETERS: Name - Name to lookup 314a159c266SJung-uk Kim * 315a159c266SJung-uk Kim * RETURN: Pointer to a namespace node, null on failure 316a159c266SJung-uk Kim * 317a159c266SJung-uk Kim * DESCRIPTION: Lookup a name in the ACPI namespace 318a159c266SJung-uk Kim * 319a159c266SJung-uk Kim * Note: Currently begins search from the root. Could be enhanced to use 320a159c266SJung-uk Kim * the current prefix (scope) node as the search beginning point. 321a159c266SJung-uk Kim * 322a159c266SJung-uk Kim ******************************************************************************/ 323a159c266SJung-uk Kim 324a159c266SJung-uk Kim ACPI_NAMESPACE_NODE * 325a159c266SJung-uk Kim AcpiDbLocalNsLookup ( 326a159c266SJung-uk Kim char *Name) 327a159c266SJung-uk Kim { 328a159c266SJung-uk Kim char *InternalPath; 329a159c266SJung-uk Kim ACPI_STATUS Status; 330a159c266SJung-uk Kim ACPI_NAMESPACE_NODE *Node = NULL; 331a159c266SJung-uk Kim 332a159c266SJung-uk Kim 333a159c266SJung-uk Kim AcpiDbPrepNamestring (Name); 334a159c266SJung-uk Kim 335a159c266SJung-uk Kim /* Build an internal namestring */ 336a159c266SJung-uk Kim 337a159c266SJung-uk Kim Status = AcpiNsInternalizeName (Name, &InternalPath); 338a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 339a159c266SJung-uk Kim { 340a159c266SJung-uk Kim AcpiOsPrintf ("Invalid namestring: %s\n", Name); 341a159c266SJung-uk Kim return (NULL); 342a159c266SJung-uk Kim } 343a159c266SJung-uk Kim 344a159c266SJung-uk Kim /* 345a159c266SJung-uk Kim * Lookup the name. 346a159c266SJung-uk Kim * (Uses root node as the search starting point) 347a159c266SJung-uk Kim */ 348a159c266SJung-uk Kim Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 349a159c266SJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); 350a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 351a159c266SJung-uk Kim { 352a159c266SJung-uk Kim AcpiOsPrintf ("Could not locate name: %s, %s\n", 353a159c266SJung-uk Kim Name, AcpiFormatException (Status)); 354a159c266SJung-uk Kim } 355a159c266SJung-uk Kim 356a159c266SJung-uk Kim ACPI_FREE (InternalPath); 357a159c266SJung-uk Kim return (Node); 358a159c266SJung-uk Kim } 359a159c266SJung-uk Kim 360a159c266SJung-uk Kim 361a159c266SJung-uk Kim /******************************************************************************* 362a159c266SJung-uk Kim * 363f38b0f21SJung-uk Kim * FUNCTION: AcpiDbUint32ToHexString 364a159c266SJung-uk Kim * 365a159c266SJung-uk Kim * PARAMETERS: Value - The value to be converted to string 366a159c266SJung-uk Kim * Buffer - Buffer for result (not less than 11 bytes) 367a159c266SJung-uk Kim * 368a159c266SJung-uk Kim * RETURN: None 369a159c266SJung-uk Kim * 370a159c266SJung-uk Kim * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image 371a159c266SJung-uk Kim * 372a159c266SJung-uk Kim * NOTE: It is the caller's responsibility to ensure that the length of buffer 373a159c266SJung-uk Kim * is sufficient. 374a159c266SJung-uk Kim * 375a159c266SJung-uk Kim ******************************************************************************/ 376a159c266SJung-uk Kim 377a159c266SJung-uk Kim void 378f38b0f21SJung-uk Kim AcpiDbUint32ToHexString ( 379a159c266SJung-uk Kim UINT32 Value, 380a159c266SJung-uk Kim char *Buffer) 381a159c266SJung-uk Kim { 382a159c266SJung-uk Kim int i; 383a159c266SJung-uk Kim 384a159c266SJung-uk Kim 385a159c266SJung-uk Kim if (Value == 0) 386a159c266SJung-uk Kim { 387a159c266SJung-uk Kim ACPI_STRCPY (Buffer, "0"); 388a159c266SJung-uk Kim return; 389a159c266SJung-uk Kim } 390a159c266SJung-uk Kim 391a159c266SJung-uk Kim Buffer[8] = '\0'; 392a159c266SJung-uk Kim 393a159c266SJung-uk Kim for (i = 7; i >= 0; i--) 394a159c266SJung-uk Kim { 395a159c266SJung-uk Kim Buffer[i] = Converter [Value & 0x0F]; 396a159c266SJung-uk Kim Value = Value >> 4; 397a159c266SJung-uk Kim } 398a159c266SJung-uk Kim } 399a159c266SJung-uk Kim 400a159c266SJung-uk Kim 401a159c266SJung-uk Kim #ifdef ACPI_OBSOLETE_FUNCTIONS 402a159c266SJung-uk Kim /******************************************************************************* 403a159c266SJung-uk Kim * 404a159c266SJung-uk Kim * FUNCTION: AcpiDbSecondPassParse 405a159c266SJung-uk Kim * 406a159c266SJung-uk Kim * PARAMETERS: Root - Root of the parse tree 407a159c266SJung-uk Kim * 408a159c266SJung-uk Kim * RETURN: Status 409a159c266SJung-uk Kim * 410a159c266SJung-uk Kim * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until 411a159c266SJung-uk Kim * second pass to parse the control methods 412a159c266SJung-uk Kim * 413a159c266SJung-uk Kim ******************************************************************************/ 414a159c266SJung-uk Kim 415a159c266SJung-uk Kim ACPI_STATUS 416a159c266SJung-uk Kim AcpiDbSecondPassParse ( 417a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Root) 418a159c266SJung-uk Kim { 419a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op = Root; 420a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Method; 421a159c266SJung-uk Kim ACPI_PARSE_OBJECT *SearchOp; 422a159c266SJung-uk Kim ACPI_PARSE_OBJECT *StartOp; 423a159c266SJung-uk Kim ACPI_STATUS Status = AE_OK; 424a159c266SJung-uk Kim UINT32 BaseAmlOffset; 425a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState; 426a159c266SJung-uk Kim 427a159c266SJung-uk Kim 428a159c266SJung-uk Kim ACPI_FUNCTION_ENTRY (); 429a159c266SJung-uk Kim 430a159c266SJung-uk Kim 431a159c266SJung-uk Kim AcpiOsPrintf ("Pass two parse ....\n"); 432a159c266SJung-uk Kim 433a159c266SJung-uk Kim while (Op) 434a159c266SJung-uk Kim { 435a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_METHOD_OP) 436a159c266SJung-uk Kim { 437a159c266SJung-uk Kim Method = Op; 438a159c266SJung-uk Kim 439a159c266SJung-uk Kim /* Create a new walk state for the parse */ 440a159c266SJung-uk Kim 441a159c266SJung-uk Kim WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 442a159c266SJung-uk Kim if (!WalkState) 443a159c266SJung-uk Kim { 444a159c266SJung-uk Kim return (AE_NO_MEMORY); 445a159c266SJung-uk Kim } 446a159c266SJung-uk Kim 447a159c266SJung-uk Kim /* Init the Walk State */ 448a159c266SJung-uk Kim 449a159c266SJung-uk Kim WalkState->ParserState.Aml = 450a159c266SJung-uk Kim WalkState->ParserState.AmlStart = Method->Named.Data; 451a159c266SJung-uk Kim WalkState->ParserState.AmlEnd = 452a159c266SJung-uk Kim WalkState->ParserState.PkgEnd = Method->Named.Data + 453a159c266SJung-uk Kim Method->Named.Length; 454a159c266SJung-uk Kim WalkState->ParserState.StartScope = Op; 455a159c266SJung-uk Kim 456a159c266SJung-uk Kim WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 457a159c266SJung-uk Kim WalkState->AscendingCallback = AcpiDsLoad1EndOp; 458a159c266SJung-uk Kim 459a159c266SJung-uk Kim /* Perform the AML parse */ 460a159c266SJung-uk Kim 461a159c266SJung-uk Kim Status = AcpiPsParseAml (WalkState); 462a159c266SJung-uk Kim 463a159c266SJung-uk Kim BaseAmlOffset = (Method->Common.Value.Arg)->Common.AmlOffset + 1; 464a159c266SJung-uk Kim StartOp = (Method->Common.Value.Arg)->Common.Next; 465a159c266SJung-uk Kim SearchOp = StartOp; 466a159c266SJung-uk Kim 467a159c266SJung-uk Kim while (SearchOp) 468a159c266SJung-uk Kim { 469a159c266SJung-uk Kim SearchOp->Common.AmlOffset += BaseAmlOffset; 470a159c266SJung-uk Kim SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); 471a159c266SJung-uk Kim } 472a159c266SJung-uk Kim } 473a159c266SJung-uk Kim 474a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_REGION_OP) 475a159c266SJung-uk Kim { 476a159c266SJung-uk Kim /* TBD: [Investigate] this isn't quite the right thing to do! */ 477a159c266SJung-uk Kim /* 478a159c266SJung-uk Kim * 479a159c266SJung-uk Kim * Method = (ACPI_DEFERRED_OP *) Op; 480a159c266SJung-uk Kim * Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength); 481a159c266SJung-uk Kim */ 482a159c266SJung-uk Kim } 483a159c266SJung-uk Kim 484a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 485a159c266SJung-uk Kim { 486a159c266SJung-uk Kim break; 487a159c266SJung-uk Kim } 488a159c266SJung-uk Kim 489a159c266SJung-uk Kim Op = AcpiPsGetDepthNext (Root, Op); 490a159c266SJung-uk Kim } 491a159c266SJung-uk Kim 492a159c266SJung-uk Kim return (Status); 493a159c266SJung-uk Kim } 494a159c266SJung-uk Kim 495a159c266SJung-uk Kim 496a159c266SJung-uk Kim /******************************************************************************* 497a159c266SJung-uk Kim * 498a159c266SJung-uk Kim * FUNCTION: AcpiDbDumpBuffer 499a159c266SJung-uk Kim * 500a159c266SJung-uk Kim * PARAMETERS: Address - Pointer to the buffer 501a159c266SJung-uk Kim * 502a159c266SJung-uk Kim * RETURN: None 503a159c266SJung-uk Kim * 504a159c266SJung-uk Kim * DESCRIPTION: Print a portion of a buffer 505a159c266SJung-uk Kim * 506a159c266SJung-uk Kim ******************************************************************************/ 507a159c266SJung-uk Kim 508a159c266SJung-uk Kim void 509a159c266SJung-uk Kim AcpiDbDumpBuffer ( 510a159c266SJung-uk Kim UINT32 Address) 511a159c266SJung-uk Kim { 512a159c266SJung-uk Kim 513a159c266SJung-uk Kim AcpiOsPrintf ("\nLocation %X:\n", Address); 514a159c266SJung-uk Kim 515a159c266SJung-uk Kim AcpiDbgLevel |= ACPI_LV_TABLES; 516*8ef1a331SJung-uk Kim AcpiUtDebugDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, 517a159c266SJung-uk Kim ACPI_UINT32_MAX); 518a159c266SJung-uk Kim } 519a159c266SJung-uk Kim #endif 520a159c266SJung-uk Kim 521a159c266SJung-uk Kim #endif /* ACPI_DEBUGGER */ 522