167754Smsmith/******************************************************************************* 267754Smsmith * 3218590Sjkim * Module Name: dbcmds - Miscellaneous debug commands and output routines 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88316303Sjkim * PARTICULAR PURPOSE. 89316303Sjkim * 90316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97316303Sjkim * LIMITED REMEDY. 98316303Sjkim * 99316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100316303Sjkim * software or system incorporating such software without first obtaining any 101316303Sjkim * required license or other approval from the U. S. Department of Commerce or 102316303Sjkim * any other agency or department of the United States Government. In the 103316303Sjkim * event Licensee exports any such software from the United States or 104316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 105316303Sjkim * ensure that the distribution and export/re-export of the software is in 106316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109316303Sjkim * software, or service, directly or indirectly, to any country for which the 110316303Sjkim * United States government or any agency thereof requires an export license, 111316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 112316303Sjkim * such license, approval or letter. 113316303Sjkim * 114316303Sjkim ***************************************************************************** 115316303Sjkim * 116316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 117316303Sjkim * following license: 118316303Sjkim * 119217365Sjkim * Redistribution and use in source and binary forms, with or without 120217365Sjkim * modification, are permitted provided that the following conditions 121217365Sjkim * are met: 122217365Sjkim * 1. Redistributions of source code must retain the above copyright 123217365Sjkim * notice, this list of conditions, and the following disclaimer, 124217365Sjkim * without modification. 125217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 127217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 128217365Sjkim * including a substantially similar Disclaimer requirement for further 129217365Sjkim * binary redistribution. 130217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 131217365Sjkim * of any contributors may be used to endorse or promote products derived 132217365Sjkim * from this software without specific prior written permission. 13367754Smsmith * 134316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145316303Sjkim * 146316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 147217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 148217365Sjkim * Software Foundation. 14967754Smsmith * 150316303Sjkim *****************************************************************************/ 15167754Smsmith 152193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 153193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 154193341Sjkim#include <contrib/dev/acpica/include/acevents.h> 155193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 156228110Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 157193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 158193341Sjkim#include <contrib/dev/acpica/include/actables.h> 159138287Smarks 16067754Smsmith 161102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 16291116Smsmith ACPI_MODULE_NAME ("dbcmds") 16367754Smsmith 164198237Sjkim 165151937Sjkim/* Local prototypes */ 16667754Smsmith 167151937Sjkimstatic void 168151937SjkimAcpiDmCompareAmlResources ( 169151937Sjkim UINT8 *Aml1Buffer, 170151937Sjkim ACPI_RSDESC_SIZE Aml1BufferLength, 171151937Sjkim UINT8 *Aml2Buffer, 172151937Sjkim ACPI_RSDESC_SIZE Aml2BufferLength); 173151937Sjkim 174151937Sjkimstatic ACPI_STATUS 175151937SjkimAcpiDmTestResourceConversion ( 176151937Sjkim ACPI_NAMESPACE_NODE *Node, 177151937Sjkim char *Name); 178151937Sjkim 179228110Sjkimstatic ACPI_STATUS 180228110SjkimAcpiDbResourceCallback ( 181228110Sjkim ACPI_RESOURCE *Resource, 182228110Sjkim void *Context); 183151937Sjkim 184228110Sjkimstatic ACPI_STATUS 185228110SjkimAcpiDbDeviceResources ( 186228110Sjkim ACPI_HANDLE ObjHandle, 187228110Sjkim UINT32 NestingLevel, 188228110Sjkim void *Context, 189228110Sjkim void **ReturnValue); 190228110Sjkim 191245582Sjkimstatic void 192245582SjkimAcpiDbDoOneSleepState ( 193245582Sjkim UINT8 SleepState); 194228110Sjkim 195245582Sjkim 196285797Sjkimstatic char *AcpiDbTraceMethodName = NULL; 197285797Sjkim 198287168Sjkim 199138287Smarks/******************************************************************************* 200138287Smarks * 201151937Sjkim * FUNCTION: AcpiDbConvertToNode 202151937Sjkim * 203245582Sjkim * PARAMETERS: InString - String to convert 204151937Sjkim * 205151937Sjkim * RETURN: Pointer to a NS node 206151937Sjkim * 207241973Sjkim * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or 208245582Sjkim * alphanumeric strings. 209151937Sjkim * 210151937Sjkim ******************************************************************************/ 211151937Sjkim 212218590SjkimACPI_NAMESPACE_NODE * 213151937SjkimAcpiDbConvertToNode ( 214151937Sjkim char *InString) 215151937Sjkim{ 216151937Sjkim ACPI_NAMESPACE_NODE *Node; 217252279Sjkim ACPI_SIZE Address; 218151937Sjkim 219151937Sjkim 220151937Sjkim if ((*InString >= 0x30) && (*InString <= 0x39)) 221151937Sjkim { 222151937Sjkim /* Numeric argument, convert */ 223151937Sjkim 224284583Sjkim Address = strtoul (InString, NULL, 16); 225252279Sjkim Node = ACPI_TO_POINTER (Address); 226151937Sjkim if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 227151937Sjkim { 228298714Sjkim AcpiOsPrintf ("Address %p is invalid", Node); 229151937Sjkim return (NULL); 230151937Sjkim } 231151937Sjkim 232151937Sjkim /* Make sure pointer is valid NS node */ 233151937Sjkim 234151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 235151937Sjkim { 236272444Sjkim AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", 237298714Sjkim Node, AcpiUtGetDescriptorName (Node)); 238151937Sjkim return (NULL); 239151937Sjkim } 240151937Sjkim } 241151937Sjkim else 242151937Sjkim { 243245582Sjkim /* 244245582Sjkim * Alpha argument: The parameter is a name string that must be 245245582Sjkim * resolved to a Namespace object. 246151937Sjkim */ 247151937Sjkim Node = AcpiDbLocalNsLookup (InString); 248151937Sjkim if (!Node) 249151937Sjkim { 250287168Sjkim AcpiOsPrintf ( 251287168Sjkim "Could not find [%s] in namespace, defaulting to root node\n", 252272444Sjkim InString); 253151937Sjkim Node = AcpiGbl_RootNode; 254151937Sjkim } 255151937Sjkim } 256151937Sjkim 257151937Sjkim return (Node); 258151937Sjkim} 259151937Sjkim 260151937Sjkim 261151937Sjkim/******************************************************************************* 262151937Sjkim * 263138287Smarks * FUNCTION: AcpiDbSleep 264138287Smarks * 265245582Sjkim * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means 266245582Sjkim * invoke all possible sleep states. 267138287Smarks * 268138287Smarks * RETURN: Status 269138287Smarks * 270245582Sjkim * DESCRIPTION: Simulate sleep/wake sequences 271138287Smarks * 272138287Smarks ******************************************************************************/ 273138287Smarks 274129684SnjlACPI_STATUS 275129684SnjlAcpiDbSleep ( 276129684Snjl char *ObjectArg) 277129684Snjl{ 278129684Snjl UINT8 SleepState; 279245582Sjkim UINT32 i; 280129684Snjl 281129684Snjl 282231844Sjkim ACPI_FUNCTION_TRACE (AcpiDbSleep); 283231844Sjkim 284231844Sjkim 285245582Sjkim /* Null input (no arguments) means to invoke all sleep states */ 286245582Sjkim 287245582Sjkim if (!ObjectArg) 288245582Sjkim { 289245582Sjkim AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n", 290245582Sjkim ACPI_S_STATES_MAX); 291245582Sjkim 292245582Sjkim for (i = 0; i <= ACPI_S_STATES_MAX; i++) 293245582Sjkim { 294245582Sjkim AcpiDbDoOneSleepState ((UINT8) i); 295245582Sjkim } 296245582Sjkim 297245582Sjkim return_ACPI_STATUS (AE_OK); 298245582Sjkim } 299245582Sjkim 300245582Sjkim /* Convert argument to binary and invoke the sleep state */ 301245582Sjkim 302284583Sjkim SleepState = (UINT8) strtoul (ObjectArg, NULL, 0); 303245582Sjkim AcpiDbDoOneSleepState (SleepState); 304245582Sjkim return_ACPI_STATUS (AE_OK); 305245582Sjkim} 306129684Snjl 307245582Sjkim 308245582Sjkim/******************************************************************************* 309245582Sjkim * 310245582Sjkim * FUNCTION: AcpiDbDoOneSleepState 311245582Sjkim * 312245582Sjkim * PARAMETERS: SleepState - Desired sleep state (0-5) 313245582Sjkim * 314287168Sjkim * RETURN: None 315245582Sjkim * 316245582Sjkim * DESCRIPTION: Simulate a sleep/wake sequence 317245582Sjkim * 318245582Sjkim ******************************************************************************/ 319245582Sjkim 320245582Sjkimstatic void 321245582SjkimAcpiDbDoOneSleepState ( 322245582Sjkim UINT8 SleepState) 323245582Sjkim{ 324245582Sjkim ACPI_STATUS Status; 325245582Sjkim UINT8 SleepTypeA; 326245582Sjkim UINT8 SleepTypeB; 327245582Sjkim 328245582Sjkim 329245582Sjkim /* Validate parameter */ 330245582Sjkim 331245582Sjkim if (SleepState > ACPI_S_STATES_MAX) 332245582Sjkim { 333245582Sjkim AcpiOsPrintf ("Sleep state %d out of range (%d max)\n", 334245582Sjkim SleepState, ACPI_S_STATES_MAX); 335245582Sjkim return; 336245582Sjkim } 337245582Sjkim 338245582Sjkim AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n", 339245582Sjkim SleepState, AcpiGbl_SleepStateNames[SleepState]); 340245582Sjkim 341245582Sjkim /* Get the values for the sleep type registers (for display only) */ 342245582Sjkim 343245582Sjkim Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB); 344245582Sjkim if (ACPI_FAILURE (Status)) 345245582Sjkim { 346245582Sjkim AcpiOsPrintf ("Could not evaluate [%s] method, %s\n", 347245582Sjkim AcpiGbl_SleepStateNames[SleepState], 348245582Sjkim AcpiFormatException (Status)); 349245582Sjkim return; 350245582Sjkim } 351245582Sjkim 352245582Sjkim AcpiOsPrintf ( 353245582Sjkim "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n", 354245582Sjkim SleepState, SleepTypeA, SleepTypeB); 355245582Sjkim 356245582Sjkim /* Invoke the various sleep/wake interfaces */ 357245582Sjkim 358245582Sjkim AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n", 359245582Sjkim SleepState); 360129684Snjl Status = AcpiEnterSleepStatePrep (SleepState); 361129684Snjl if (ACPI_FAILURE (Status)) 362129684Snjl { 363231844Sjkim goto ErrorExit; 364129684Snjl } 365129684Snjl 366245582Sjkim AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n", 367245582Sjkim SleepState); 368239340Sjkim Status = AcpiEnterSleepState (SleepState); 369129684Snjl if (ACPI_FAILURE (Status)) 370129684Snjl { 371231844Sjkim goto ErrorExit; 372129684Snjl } 373129684Snjl 374245582Sjkim AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n", 375245582Sjkim SleepState); 376239340Sjkim Status = AcpiLeaveSleepStatePrep (SleepState); 377231844Sjkim if (ACPI_FAILURE (Status)) 378231844Sjkim { 379231844Sjkim goto ErrorExit; 380231844Sjkim } 381231844Sjkim 382245582Sjkim AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n", 383245582Sjkim SleepState); 384129684Snjl Status = AcpiLeaveSleepState (SleepState); 385231844Sjkim if (ACPI_FAILURE (Status)) 386231844Sjkim { 387231844Sjkim goto ErrorExit; 388231844Sjkim } 389129684Snjl 390245582Sjkim return; 391231844Sjkim 392231844Sjkim 393231844SjkimErrorExit: 394245582Sjkim ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d", 395245582Sjkim SleepState)); 396129684Snjl} 397129684Snjl 398231844Sjkim 39967754Smsmith/******************************************************************************* 40067754Smsmith * 40177424Smsmith * FUNCTION: AcpiDbDisplayLocks 40277424Smsmith * 40377424Smsmith * PARAMETERS: None 40477424Smsmith * 40577424Smsmith * RETURN: None 40677424Smsmith * 40777424Smsmith * DESCRIPTION: Display information about internal mutexes. 40877424Smsmith * 40977424Smsmith ******************************************************************************/ 41077424Smsmith 41177424Smsmithvoid 412151937SjkimAcpiDbDisplayLocks ( 413151937Sjkim void) 41477424Smsmith{ 41577424Smsmith UINT32 i; 41677424Smsmith 41777424Smsmith 418167802Sjkim for (i = 0; i < ACPI_MAX_MUTEX; i++) 41977424Smsmith { 42077424Smsmith AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 421167802Sjkim AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED 422167802Sjkim ? "Locked" : "Unlocked"); 42377424Smsmith } 42477424Smsmith} 42577424Smsmith 42677424Smsmith 42777424Smsmith/******************************************************************************* 42877424Smsmith * 42967754Smsmith * FUNCTION: AcpiDbDisplayTableInfo 43067754Smsmith * 431245582Sjkim * PARAMETERS: TableArg - Name of table to be displayed 43267754Smsmith * 43367754Smsmith * RETURN: None 43467754Smsmith * 435241973Sjkim * DESCRIPTION: Display information about loaded tables. Current 43667754Smsmith * implementation displays all loaded tables. 43767754Smsmith * 43867754Smsmith ******************************************************************************/ 43967754Smsmith 44067754Smsmithvoid 44167754SmsmithAcpiDbDisplayTableInfo ( 442114237Snjl char *TableArg) 44367754Smsmith{ 444193267Sjkim UINT32 i; 445117521Snjl ACPI_TABLE_DESC *TableDesc; 446193267Sjkim ACPI_STATUS Status; 44767754Smsmith 44867754Smsmith 449238381Sjkim /* Header */ 450238381Sjkim 451287168Sjkim AcpiOsPrintf ("Idx ID Status Type " 452287168Sjkim "TableHeader (Sig, Address, Length, Misc)\n"); 453238381Sjkim 454193267Sjkim /* Walk the entire root table list */ 455193267Sjkim 456207344Sjkim for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 45767754Smsmith { 458167802Sjkim TableDesc = &AcpiGbl_RootTableList.Tables[i]; 459167802Sjkim 460238381Sjkim /* Index and Table ID */ 461238381Sjkim 462238381Sjkim AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId); 463238381Sjkim 464238381Sjkim /* Decode the table flags */ 465238381Sjkim 466238381Sjkim if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED)) 467238381Sjkim { 468238381Sjkim AcpiOsPrintf ("NotLoaded "); 469238381Sjkim } 470238381Sjkim else 471238381Sjkim { 472238381Sjkim AcpiOsPrintf (" Loaded "); 473238381Sjkim } 474238381Sjkim 475238381Sjkim switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) 476238381Sjkim { 477272444Sjkim case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: 478250838Sjkim 479272444Sjkim AcpiOsPrintf ("External/virtual "); 480238381Sjkim break; 481238381Sjkim 482272444Sjkim case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: 483250838Sjkim 484272444Sjkim AcpiOsPrintf ("Internal/physical "); 485238381Sjkim break; 486238381Sjkim 487272444Sjkim case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: 488250838Sjkim 489272444Sjkim AcpiOsPrintf ("Internal/virtual "); 490238381Sjkim break; 491238381Sjkim 492238381Sjkim default: 493250838Sjkim 494272444Sjkim AcpiOsPrintf ("INVALID TYPE "); 495238381Sjkim break; 496238381Sjkim } 497238381Sjkim 498193267Sjkim /* Make sure that the table is mapped */ 499193267Sjkim 500272444Sjkim Status = AcpiTbValidateTable (TableDesc); 501193267Sjkim if (ACPI_FAILURE (Status)) 50267754Smsmith { 503193267Sjkim return; 50467754Smsmith } 505193267Sjkim 506193267Sjkim /* Dump the table header */ 507193267Sjkim 508193267Sjkim if (TableDesc->Pointer) 509193267Sjkim { 510193267Sjkim AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); 511193267Sjkim } 512193267Sjkim else 513193267Sjkim { 514193267Sjkim /* If the pointer is null, the table has been unloaded */ 515193267Sjkim 516298714Sjkim ACPI_INFO (("%4.4s - Table has been unloaded", 517193267Sjkim TableDesc->Signature.Ascii)); 518193267Sjkim } 51967754Smsmith } 52067754Smsmith} 52167754Smsmith 52267754Smsmith 52367754Smsmith/******************************************************************************* 52467754Smsmith * 52567754Smsmith * FUNCTION: AcpiDbUnloadAcpiTable 52667754Smsmith * 527238381Sjkim * PARAMETERS: ObjectName - Namespace pathname for an object that 528238381Sjkim * is owned by the table to be unloaded 52967754Smsmith * 530238381Sjkim * RETURN: None 53167754Smsmith * 532238381Sjkim * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned 533238381Sjkim * by the table. 53467754Smsmith * 53567754Smsmith ******************************************************************************/ 53667754Smsmith 53767754Smsmithvoid 53867754SmsmithAcpiDbUnloadAcpiTable ( 539238381Sjkim char *ObjectName) 54067754Smsmith{ 541238381Sjkim ACPI_NAMESPACE_NODE *Node; 54267754Smsmith ACPI_STATUS Status; 54367754Smsmith 54467754Smsmith 545238381Sjkim /* Translate name to an Named object */ 54667754Smsmith 547238381Sjkim Node = AcpiDbConvertToNode (ObjectName); 548238381Sjkim if (!Node) 54967754Smsmith { 550238381Sjkim return; 551238381Sjkim } 55267754Smsmith 553238381Sjkim Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node)); 554238381Sjkim if (ACPI_SUCCESS (Status)) 555238381Sjkim { 556238381Sjkim AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n", 557238381Sjkim ObjectName, Node); 55867754Smsmith } 559238381Sjkim else 560238381Sjkim { 561238381Sjkim AcpiOsPrintf ("%s, while unloading parent table of [%s]\n", 562238381Sjkim AcpiFormatException (Status), ObjectName); 563238381Sjkim } 56467754Smsmith} 56567754Smsmith 56667754Smsmith 56767754Smsmith/******************************************************************************* 56867754Smsmith * 56967754Smsmith * FUNCTION: AcpiDbSendNotify 57067754Smsmith * 571245582Sjkim * PARAMETERS: Name - Name of ACPI object where to send notify 572245582Sjkim * Value - Value of the notify to send. 57367754Smsmith * 57467754Smsmith * RETURN: None 57567754Smsmith * 576241973Sjkim * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 57767754Smsmith * named object as an ACPI notify. 57867754Smsmith * 57967754Smsmith ******************************************************************************/ 58067754Smsmith 58167754Smsmithvoid 58267754SmsmithAcpiDbSendNotify ( 583114237Snjl char *Name, 58467754Smsmith UINT32 Value) 58567754Smsmith{ 58667754Smsmith ACPI_NAMESPACE_NODE *Node; 58799679Siwasaki ACPI_STATUS Status; 58867754Smsmith 58967754Smsmith 59067754Smsmith /* Translate name to an Named object */ 59167754Smsmith 592151937Sjkim Node = AcpiDbConvertToNode (Name); 59367754Smsmith if (!Node) 59467754Smsmith { 59567754Smsmith return; 59667754Smsmith } 59767754Smsmith 598234623Sjkim /* Dispatch the notify if legal */ 59967754Smsmith 600234623Sjkim if (AcpiEvIsNotifyObject (Node)) 60167754Smsmith { 60299679Siwasaki Status = AcpiEvQueueNotifyRequest (Node, Value); 60399679Siwasaki if (ACPI_FAILURE (Status)) 60499679Siwasaki { 60599679Siwasaki AcpiOsPrintf ("Could not queue notify\n"); 60699679Siwasaki } 60767754Smsmith } 608234623Sjkim else 609234623Sjkim { 610245582Sjkim AcpiOsPrintf ( 611287168Sjkim "Named object [%4.4s] Type %s, " 612287168Sjkim "must be Device/Thermal/Processor type\n", 613234623Sjkim AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); 614234623Sjkim } 61567754Smsmith} 61667754Smsmith 61767754Smsmith 61867754Smsmith/******************************************************************************* 61967754Smsmith * 620210976Sjkim * FUNCTION: AcpiDbDisplayInterfaces 621210976Sjkim * 622210976Sjkim * PARAMETERS: ActionArg - Null, "install", or "remove" 623210976Sjkim * InterfaceNameArg - Name for install/remove options 624210976Sjkim * 625210976Sjkim * RETURN: None 626210976Sjkim * 627210976Sjkim * DESCRIPTION: Display or modify the global _OSI interface list 628210976Sjkim * 629210976Sjkim ******************************************************************************/ 630210976Sjkim 631210976Sjkimvoid 632210976SjkimAcpiDbDisplayInterfaces ( 633210976Sjkim char *ActionArg, 634210976Sjkim char *InterfaceNameArg) 635210976Sjkim{ 636210976Sjkim ACPI_INTERFACE_INFO *NextInterface; 637210976Sjkim char *SubString; 638210976Sjkim ACPI_STATUS Status; 639210976Sjkim 640210976Sjkim 641210976Sjkim /* If no arguments, just display current interface list */ 642210976Sjkim 643210976Sjkim if (!ActionArg) 644210976Sjkim { 645287168Sjkim (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 646210976Sjkim 647210976Sjkim NextInterface = AcpiGbl_SupportedInterfaces; 648210976Sjkim while (NextInterface) 649210976Sjkim { 650210976Sjkim if (!(NextInterface->Flags & ACPI_OSI_INVALID)) 651210976Sjkim { 652210976Sjkim AcpiOsPrintf ("%s\n", NextInterface->Name); 653210976Sjkim } 654287168Sjkim 655210976Sjkim NextInterface = NextInterface->Next; 656210976Sjkim } 657210976Sjkim 658210976Sjkim AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 659210976Sjkim return; 660210976Sjkim } 661210976Sjkim 662210976Sjkim /* If ActionArg exists, so must InterfaceNameArg */ 663210976Sjkim 664210976Sjkim if (!InterfaceNameArg) 665210976Sjkim { 666210976Sjkim AcpiOsPrintf ("Missing Interface Name argument\n"); 667210976Sjkim return; 668210976Sjkim } 669210976Sjkim 670210976Sjkim /* Uppercase the action for match below */ 671210976Sjkim 672210976Sjkim AcpiUtStrupr (ActionArg); 673210976Sjkim 674210976Sjkim /* Install - install an interface */ 675210976Sjkim 676284583Sjkim SubString = strstr ("INSTALL", ActionArg); 677210976Sjkim if (SubString) 678210976Sjkim { 679210976Sjkim Status = AcpiInstallInterface (InterfaceNameArg); 680210976Sjkim if (ACPI_FAILURE (Status)) 681210976Sjkim { 682210976Sjkim AcpiOsPrintf ("%s, while installing \"%s\"\n", 683210976Sjkim AcpiFormatException (Status), InterfaceNameArg); 684210976Sjkim } 685210976Sjkim return; 686210976Sjkim } 687210976Sjkim 688210976Sjkim /* Remove - remove an interface */ 689210976Sjkim 690284583Sjkim SubString = strstr ("REMOVE", ActionArg); 691210976Sjkim if (SubString) 692210976Sjkim { 693210976Sjkim Status = AcpiRemoveInterface (InterfaceNameArg); 694210976Sjkim if (ACPI_FAILURE (Status)) 695210976Sjkim { 696210976Sjkim AcpiOsPrintf ("%s, while removing \"%s\"\n", 697210976Sjkim AcpiFormatException (Status), InterfaceNameArg); 698210976Sjkim } 699210976Sjkim return; 700210976Sjkim } 701210976Sjkim 702210976Sjkim /* Invalid ActionArg */ 703210976Sjkim 704210976Sjkim AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg); 705210976Sjkim return; 706210976Sjkim} 707210976Sjkim 708210976Sjkim 709210976Sjkim/******************************************************************************* 710210976Sjkim * 711228110Sjkim * FUNCTION: AcpiDbDisplayTemplate 712228110Sjkim * 713245582Sjkim * PARAMETERS: BufferArg - Buffer name or address 714228110Sjkim * 715228110Sjkim * RETURN: None 716228110Sjkim * 717228110Sjkim * DESCRIPTION: Dump a buffer that contains a resource template 718228110Sjkim * 719228110Sjkim ******************************************************************************/ 720228110Sjkim 721228110Sjkimvoid 722228110SjkimAcpiDbDisplayTemplate ( 723228110Sjkim char *BufferArg) 724228110Sjkim{ 725228110Sjkim ACPI_NAMESPACE_NODE *Node; 726228110Sjkim ACPI_STATUS Status; 727245582Sjkim ACPI_BUFFER ReturnBuffer; 728228110Sjkim 729228110Sjkim 730228110Sjkim /* Translate BufferArg to an Named object */ 731228110Sjkim 732228110Sjkim Node = AcpiDbConvertToNode (BufferArg); 733228110Sjkim if (!Node || (Node == AcpiGbl_RootNode)) 734228110Sjkim { 735228110Sjkim AcpiOsPrintf ("Invalid argument: %s\n", BufferArg); 736228110Sjkim return; 737228110Sjkim } 738228110Sjkim 739228110Sjkim /* We must have a buffer object */ 740228110Sjkim 741228110Sjkim if (Node->Type != ACPI_TYPE_BUFFER) 742228110Sjkim { 743228110Sjkim AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n", 744228110Sjkim BufferArg); 745228110Sjkim return; 746228110Sjkim } 747228110Sjkim 748245582Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 749245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 750228110Sjkim 751228110Sjkim /* Attempt to convert the raw buffer to a resource list */ 752228110Sjkim 753245582Sjkim Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer); 754228110Sjkim 755228110Sjkim AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 756228110Sjkim AcpiDbgLevel |= ACPI_LV_RESOURCES; 757228110Sjkim 758228110Sjkim if (ACPI_FAILURE (Status)) 759228110Sjkim { 760287168Sjkim AcpiOsPrintf ( 761287168Sjkim "Could not convert Buffer to a resource list: %s, %s\n", 762228110Sjkim BufferArg, AcpiFormatException (Status)); 763228110Sjkim goto DumpBuffer; 764228110Sjkim } 765228110Sjkim 766228110Sjkim /* Now we can dump the resource list */ 767228110Sjkim 768228110Sjkim AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, 769245582Sjkim ReturnBuffer.Pointer)); 770228110Sjkim 771228110SjkimDumpBuffer: 772228110Sjkim AcpiOsPrintf ("\nRaw data buffer:\n"); 773241973Sjkim AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer, 774228110Sjkim Node->Object->Buffer.Length, 775228110Sjkim DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 776228110Sjkim 777228110Sjkim AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 778228110Sjkim return; 779228110Sjkim} 780228110Sjkim 781228110Sjkim 782228110Sjkim/******************************************************************************* 783228110Sjkim * 784151937Sjkim * FUNCTION: AcpiDmCompareAmlResources 785151937Sjkim * 786151937Sjkim * PARAMETERS: Aml1Buffer - Contains first resource list 787151937Sjkim * Aml1BufferLength - Length of first resource list 788151937Sjkim * Aml2Buffer - Contains second resource list 789151937Sjkim * Aml2BufferLength - Length of second resource list 790151937Sjkim * 791151937Sjkim * RETURN: None 792151937Sjkim * 793151937Sjkim * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in 794151937Sjkim * order to isolate a miscompare to an individual resource) 795151937Sjkim * 796151937Sjkim ******************************************************************************/ 797151937Sjkim 798151937Sjkimstatic void 799151937SjkimAcpiDmCompareAmlResources ( 800151937Sjkim UINT8 *Aml1Buffer, 801151937Sjkim ACPI_RSDESC_SIZE Aml1BufferLength, 802151937Sjkim UINT8 *Aml2Buffer, 803151937Sjkim ACPI_RSDESC_SIZE Aml2BufferLength) 804151937Sjkim{ 805151937Sjkim UINT8 *Aml1; 806151937Sjkim UINT8 *Aml2; 807228110Sjkim UINT8 *Aml1End; 808228110Sjkim UINT8 *Aml2End; 809151937Sjkim ACPI_RSDESC_SIZE Aml1Length; 810151937Sjkim ACPI_RSDESC_SIZE Aml2Length; 811151937Sjkim ACPI_RSDESC_SIZE Offset = 0; 812151937Sjkim UINT8 ResourceType; 813151937Sjkim UINT32 Count = 0; 814228110Sjkim UINT32 i; 815151937Sjkim 816151937Sjkim 817151937Sjkim /* Compare overall buffer sizes (may be different due to size rounding) */ 818151937Sjkim 819151937Sjkim if (Aml1BufferLength != Aml2BufferLength) 820151937Sjkim { 821151937Sjkim AcpiOsPrintf ( 822287168Sjkim "**** Buffer length mismatch in converted " 823287168Sjkim "AML: Original %X, New %X ****\n", 824151937Sjkim Aml1BufferLength, Aml2BufferLength); 825151937Sjkim } 826151937Sjkim 827151937Sjkim Aml1 = Aml1Buffer; 828151937Sjkim Aml2 = Aml2Buffer; 829228110Sjkim Aml1End = Aml1Buffer + Aml1BufferLength; 830228110Sjkim Aml2End = Aml2Buffer + Aml2BufferLength; 831151937Sjkim 832151937Sjkim /* Walk the descriptor lists, comparing each descriptor */ 833151937Sjkim 834228110Sjkim while ((Aml1 < Aml1End) && (Aml2 < Aml2End)) 835151937Sjkim { 836151937Sjkim /* Get the lengths of each descriptor */ 837151937Sjkim 838151937Sjkim Aml1Length = AcpiUtGetDescriptorLength (Aml1); 839151937Sjkim Aml2Length = AcpiUtGetDescriptorLength (Aml2); 840151937Sjkim ResourceType = AcpiUtGetResourceType (Aml1); 841151937Sjkim 842151937Sjkim /* Check for descriptor length match */ 843151937Sjkim 844151937Sjkim if (Aml1Length != Aml2Length) 845151937Sjkim { 846151937Sjkim AcpiOsPrintf ( 847287168Sjkim "**** Length mismatch in descriptor [%.2X] type %2.2X, " 848287168Sjkim "Offset %8.8X Len1 %X, Len2 %X ****\n", 849151937Sjkim Count, ResourceType, Offset, Aml1Length, Aml2Length); 850151937Sjkim } 851151937Sjkim 852151937Sjkim /* Check for descriptor byte match */ 853151937Sjkim 854284583Sjkim else if (memcmp (Aml1, Aml2, Aml1Length)) 855151937Sjkim { 856151937Sjkim AcpiOsPrintf ( 857287168Sjkim "**** Data mismatch in descriptor [%.2X] type %2.2X, " 858287168Sjkim "Offset %8.8X ****\n", 859151937Sjkim Count, ResourceType, Offset); 860228110Sjkim 861228110Sjkim for (i = 0; i < Aml1Length; i++) 862228110Sjkim { 863228110Sjkim if (Aml1[i] != Aml2[i]) 864228110Sjkim { 865245582Sjkim AcpiOsPrintf ( 866287168Sjkim "Mismatch at byte offset %.2X: is %2.2X, " 867287168Sjkim "should be %2.2X\n", 868228110Sjkim i, Aml2[i], Aml1[i]); 869228110Sjkim } 870228110Sjkim } 871151937Sjkim } 872151937Sjkim 873151937Sjkim /* Exit on EndTag descriptor */ 874151937Sjkim 875151937Sjkim if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) 876151937Sjkim { 877151937Sjkim return; 878151937Sjkim } 879151937Sjkim 880151937Sjkim /* Point to next descriptor in each buffer */ 881151937Sjkim 882151937Sjkim Count++; 883151937Sjkim Offset += Aml1Length; 884151937Sjkim Aml1 += Aml1Length; 885167802Sjkim Aml2 += Aml2Length; 886151937Sjkim } 887151937Sjkim} 888151937Sjkim 889151937Sjkim 890151937Sjkim/******************************************************************************* 891151937Sjkim * 892151937Sjkim * FUNCTION: AcpiDmTestResourceConversion 893151937Sjkim * 894245582Sjkim * PARAMETERS: Node - Parent device node 895245582Sjkim * Name - resource method name (_CRS) 896151937Sjkim * 897151937Sjkim * RETURN: Status 898151937Sjkim * 899151937Sjkim * DESCRIPTION: Compare the original AML with a conversion of the AML to 900151937Sjkim * internal resource list, then back to AML. 901151937Sjkim * 902151937Sjkim ******************************************************************************/ 903151937Sjkim 904151937Sjkimstatic ACPI_STATUS 905151937SjkimAcpiDmTestResourceConversion ( 906151937Sjkim ACPI_NAMESPACE_NODE *Node, 907151937Sjkim char *Name) 908151937Sjkim{ 909151937Sjkim ACPI_STATUS Status; 910245582Sjkim ACPI_BUFFER ReturnBuffer; 911245582Sjkim ACPI_BUFFER ResourceBuffer; 912151937Sjkim ACPI_BUFFER NewAml; 913151937Sjkim ACPI_OBJECT *OriginalAml; 914151937Sjkim 915151937Sjkim 916151937Sjkim AcpiOsPrintf ("Resource Conversion Comparison:\n"); 917151937Sjkim 918151937Sjkim NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 919245582Sjkim ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 920245582Sjkim ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 921151937Sjkim 922151937Sjkim /* Get the original _CRS AML resource template */ 923151937Sjkim 924245582Sjkim Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer); 925151937Sjkim if (ACPI_FAILURE (Status)) 926151937Sjkim { 927151937Sjkim AcpiOsPrintf ("Could not obtain %s: %s\n", 928151937Sjkim Name, AcpiFormatException (Status)); 929151937Sjkim return (Status); 930151937Sjkim } 931151937Sjkim 932151937Sjkim /* Get the AML resource template, converted to internal resource structs */ 933151937Sjkim 934245582Sjkim Status = AcpiGetCurrentResources (Node, &ResourceBuffer); 935151937Sjkim if (ACPI_FAILURE (Status)) 936151937Sjkim { 937151937Sjkim AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 938151937Sjkim AcpiFormatException (Status)); 939151937Sjkim goto Exit1; 940151937Sjkim } 941151937Sjkim 942151937Sjkim /* Convert internal resource list to external AML resource template */ 943151937Sjkim 944272444Sjkim Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml); 945151937Sjkim if (ACPI_FAILURE (Status)) 946151937Sjkim { 947151937Sjkim AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", 948151937Sjkim AcpiFormatException (Status)); 949151937Sjkim goto Exit2; 950151937Sjkim } 951151937Sjkim 952151937Sjkim /* Compare original AML to the newly created AML resource list */ 953151937Sjkim 954245582Sjkim OriginalAml = ReturnBuffer.Pointer; 955151937Sjkim 956272444Sjkim AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer, 957272444Sjkim (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, 958193267Sjkim NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length); 959151937Sjkim 960151937Sjkim /* Cleanup and exit */ 961151937Sjkim 962167802Sjkim ACPI_FREE (NewAml.Pointer); 963151937SjkimExit2: 964245582Sjkim ACPI_FREE (ResourceBuffer.Pointer); 965151937SjkimExit1: 966245582Sjkim ACPI_FREE (ReturnBuffer.Pointer); 967151937Sjkim return (Status); 968151937Sjkim} 969151937Sjkim 970151937Sjkim 971151937Sjkim/******************************************************************************* 972151937Sjkim * 973228110Sjkim * FUNCTION: AcpiDbResourceCallback 97473561Smsmith * 975228110Sjkim * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK 97673561Smsmith * 977228110Sjkim * RETURN: Status 97873561Smsmith * 979245582Sjkim * DESCRIPTION: Simple callback to exercise AcpiWalkResources and 980245582Sjkim * AcpiWalkResourceBuffer. 98173561Smsmith * 98273561Smsmith ******************************************************************************/ 98373561Smsmith 984228110Sjkimstatic ACPI_STATUS 985228110SjkimAcpiDbResourceCallback ( 986228110Sjkim ACPI_RESOURCE *Resource, 987228110Sjkim void *Context) 98873561Smsmith{ 989228110Sjkim 990228110Sjkim return (AE_OK); 991228110Sjkim} 992228110Sjkim 993228110Sjkim 994228110Sjkim/******************************************************************************* 995228110Sjkim * 996228110Sjkim * FUNCTION: AcpiDbDeviceResources 997228110Sjkim * 998228110Sjkim * PARAMETERS: ACPI_WALK_CALLBACK 999228110Sjkim * 1000228110Sjkim * RETURN: Status 1001228110Sjkim * 1002228110Sjkim * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object. 1003228110Sjkim * 1004228110Sjkim ******************************************************************************/ 1005228110Sjkim 1006228110Sjkimstatic ACPI_STATUS 1007228110SjkimAcpiDbDeviceResources ( 1008228110Sjkim ACPI_HANDLE ObjHandle, 1009228110Sjkim UINT32 NestingLevel, 1010228110Sjkim void *Context, 1011228110Sjkim void **ReturnValue) 1012228110Sjkim{ 1013151937Sjkim ACPI_NAMESPACE_NODE *Node; 1014228110Sjkim ACPI_NAMESPACE_NODE *PrtNode = NULL; 1015228110Sjkim ACPI_NAMESPACE_NODE *CrsNode = NULL; 1016228110Sjkim ACPI_NAMESPACE_NODE *PrsNode = NULL; 1017228110Sjkim ACPI_NAMESPACE_NODE *AeiNode = NULL; 1018228110Sjkim char *ParentPath; 1019245582Sjkim ACPI_BUFFER ReturnBuffer; 102073561Smsmith ACPI_STATUS Status; 102173561Smsmith 102273561Smsmith 1023228110Sjkim Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 1024298714Sjkim ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); 1025228110Sjkim if (!ParentPath) 1026228110Sjkim { 1027228110Sjkim return (AE_NO_MEMORY); 1028228110Sjkim } 102973561Smsmith 1030228110Sjkim /* Get handles to the resource methods for this device */ 103173561Smsmith 1032287168Sjkim (void) AcpiGetHandle (Node, METHOD_NAME__PRT, 1033287168Sjkim ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode)); 1034287168Sjkim (void) AcpiGetHandle (Node, METHOD_NAME__CRS, 1035287168Sjkim ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode)); 1036287168Sjkim (void) AcpiGetHandle (Node, METHOD_NAME__PRS, 1037287168Sjkim ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode)); 1038287168Sjkim (void) AcpiGetHandle (Node, METHOD_NAME__AEI, 1039287168Sjkim ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode)); 1040287168Sjkim 1041228110Sjkim if (!PrtNode && !CrsNode && !PrsNode && !AeiNode) 1042151937Sjkim { 1043228110Sjkim goto Cleanup; /* Nothing to do */ 1044151937Sjkim } 104573561Smsmith 1046228110Sjkim AcpiOsPrintf ("\nDevice: %s\n", ParentPath); 1047228110Sjkim 104873561Smsmith /* Prepare for a return object of arbitrary size */ 104973561Smsmith 1050245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1051245582Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 105273561Smsmith 1053228110Sjkim 105477424Smsmith /* _PRT */ 105577424Smsmith 1056228110Sjkim if (PrtNode) 1057228110Sjkim { 1058228110Sjkim AcpiOsPrintf ("Evaluating _PRT\n"); 105977424Smsmith 1060245582Sjkim Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer); 1061228110Sjkim if (ACPI_FAILURE (Status)) 1062228110Sjkim { 1063228110Sjkim AcpiOsPrintf ("Could not evaluate _PRT: %s\n", 1064228110Sjkim AcpiFormatException (Status)); 1065228110Sjkim goto GetCrs; 1066228110Sjkim } 1067151937Sjkim 1068245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1069245582Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 107073561Smsmith 1071245582Sjkim Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer); 1072228110Sjkim if (ACPI_FAILURE (Status)) 1073228110Sjkim { 1074228110Sjkim AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", 1075228110Sjkim AcpiFormatException (Status)); 1076228110Sjkim goto GetCrs; 1077228110Sjkim } 107873561Smsmith 1079228110Sjkim AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); 108077424Smsmith } 108177424Smsmith 108277424Smsmith 108377424Smsmith /* _CRS */ 108483174Smsmith 108583174SmsmithGetCrs: 1086228110Sjkim if (CrsNode) 1087228110Sjkim { 1088228110Sjkim AcpiOsPrintf ("Evaluating _CRS\n"); 108977424Smsmith 1090245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1091245582Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 109277424Smsmith 1093245582Sjkim Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer); 1094228110Sjkim if (ACPI_FAILURE (Status)) 1095228110Sjkim { 1096228110Sjkim AcpiOsPrintf ("Could not evaluate _CRS: %s\n", 1097228110Sjkim AcpiFormatException (Status)); 1098228110Sjkim goto GetPrs; 1099228110Sjkim } 1100151937Sjkim 1101245582Sjkim /* This code exercises the AcpiWalkResources interface */ 110277424Smsmith 1103228110Sjkim Status = AcpiWalkResources (Node, METHOD_NAME__CRS, 1104228110Sjkim AcpiDbResourceCallback, NULL); 1105228110Sjkim if (ACPI_FAILURE (Status)) 1106228110Sjkim { 1107228110Sjkim AcpiOsPrintf ("AcpiWalkResources failed: %s\n", 1108228110Sjkim AcpiFormatException (Status)); 1109228110Sjkim goto GetPrs; 1110228110Sjkim } 111177424Smsmith 1112245582Sjkim /* Get the _CRS resource list (test ALLOCATE buffer) */ 1113151937Sjkim 1114245582Sjkim ReturnBuffer.Pointer = NULL; 1115298714Sjkim ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 111677424Smsmith 1117245582Sjkim Status = AcpiGetCurrentResources (Node, &ReturnBuffer); 1118228110Sjkim if (ACPI_FAILURE (Status)) 1119228110Sjkim { 1120228110Sjkim AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 1121228110Sjkim AcpiFormatException (Status)); 1122228110Sjkim goto GetPrs; 1123228110Sjkim } 1124151937Sjkim 1125245582Sjkim /* This code exercises the AcpiWalkResourceBuffer interface */ 1126245582Sjkim 1127245582Sjkim Status = AcpiWalkResourceBuffer (&ReturnBuffer, 1128245582Sjkim AcpiDbResourceCallback, NULL); 1129245582Sjkim if (ACPI_FAILURE (Status)) 1130245582Sjkim { 1131245582Sjkim AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n", 1132245582Sjkim AcpiFormatException (Status)); 1133245582Sjkim goto EndCrs; 1134245582Sjkim } 1135245582Sjkim 1136228110Sjkim /* Dump the _CRS resource list */ 1137151937Sjkim 1138228110Sjkim AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, 1139245582Sjkim ReturnBuffer.Pointer)); 1140151937Sjkim 1141228110Sjkim /* 1142245582Sjkim * Perform comparison of original AML to newly created AML. This 1143245582Sjkim * tests both the AML->Resource conversion and the Resource->AML 1144245582Sjkim * conversion. 1145228110Sjkim */ 1146245582Sjkim (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); 1147151937Sjkim 1148228110Sjkim /* Execute _SRS with the resource list */ 1149228110Sjkim 1150246849Sjkim AcpiOsPrintf ("Evaluating _SRS\n"); 1151246849Sjkim 1152245582Sjkim Status = AcpiSetCurrentResources (Node, &ReturnBuffer); 1153228110Sjkim if (ACPI_FAILURE (Status)) 1154228110Sjkim { 1155228110Sjkim AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", 1156228110Sjkim AcpiFormatException (Status)); 1157245582Sjkim goto EndCrs; 1158228110Sjkim } 1159245582Sjkim 1160245582SjkimEndCrs: 1161272444Sjkim ACPI_FREE (ReturnBuffer.Pointer); 116291116Smsmith } 116383174Smsmith 116491116Smsmith 116577424Smsmith /* _PRS */ 116683174Smsmith 116783174SmsmithGetPrs: 1168228110Sjkim if (PrsNode) 1169228110Sjkim { 1170228110Sjkim AcpiOsPrintf ("Evaluating _PRS\n"); 117177424Smsmith 1172245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1173245582Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 117477424Smsmith 1175245582Sjkim Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer); 1176228110Sjkim if (ACPI_FAILURE (Status)) 1177228110Sjkim { 1178228110Sjkim AcpiOsPrintf ("Could not evaluate _PRS: %s\n", 1179228110Sjkim AcpiFormatException (Status)); 1180228110Sjkim goto GetAei; 1181228110Sjkim } 1182151937Sjkim 1183245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1184298714Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1185228110Sjkim 1186245582Sjkim Status = AcpiGetPossibleResources (Node, &ReturnBuffer); 1187228110Sjkim if (ACPI_FAILURE (Status)) 1188228110Sjkim { 1189228110Sjkim AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", 1190228110Sjkim AcpiFormatException (Status)); 1191228110Sjkim goto GetAei; 1192228110Sjkim } 1193228110Sjkim 1194287168Sjkim AcpiRsDumpResourceList (ACPI_CAST_PTR ( 1195287168Sjkim ACPI_RESOURCE, AcpiGbl_DbBuffer)); 119673561Smsmith } 119773561Smsmith 119877424Smsmith 1199228110Sjkim /* _AEI */ 1200228110Sjkim 1201228110SjkimGetAei: 1202228110Sjkim if (AeiNode) 120373561Smsmith { 1204228110Sjkim AcpiOsPrintf ("Evaluating _AEI\n"); 1205228110Sjkim 1206245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1207298714Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1208228110Sjkim 1209245582Sjkim Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer); 1210228110Sjkim if (ACPI_FAILURE (Status)) 1211228110Sjkim { 1212228110Sjkim AcpiOsPrintf ("Could not evaluate _AEI: %s\n", 1213228110Sjkim AcpiFormatException (Status)); 1214228110Sjkim goto Cleanup; 1215228110Sjkim } 1216228110Sjkim 1217245582Sjkim ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1218298714Sjkim ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1219228110Sjkim 1220245582Sjkim Status = AcpiGetEventResources (Node, &ReturnBuffer); 1221228110Sjkim if (ACPI_FAILURE (Status)) 1222228110Sjkim { 1223228110Sjkim AcpiOsPrintf ("AcpiGetEventResources failed: %s\n", 1224228110Sjkim AcpiFormatException (Status)); 1225228110Sjkim goto Cleanup; 1226228110Sjkim } 1227228110Sjkim 1228287168Sjkim AcpiRsDumpResourceList (ACPI_CAST_PTR ( 1229287168Sjkim ACPI_RESOURCE, AcpiGbl_DbBuffer)); 123073561Smsmith } 123177424Smsmith 1232151937Sjkim 123373561SmsmithCleanup: 1234228110Sjkim ACPI_FREE (ParentPath); 1235228110Sjkim return (AE_OK); 1236228110Sjkim} 123773561Smsmith 1238228110Sjkim 1239228110Sjkim/******************************************************************************* 1240228110Sjkim * 1241228110Sjkim * FUNCTION: AcpiDbDisplayResources 1242228110Sjkim * 1243245582Sjkim * PARAMETERS: ObjectArg - String object name or object pointer. 1244246849Sjkim * NULL or "*" means "display resources for 1245246849Sjkim * all devices" 1246228110Sjkim * 1247228110Sjkim * RETURN: None 1248228110Sjkim * 1249228110Sjkim * DESCRIPTION: Display the resource objects associated with a device. 1250228110Sjkim * 1251228110Sjkim ******************************************************************************/ 1252228110Sjkim 1253228110Sjkimvoid 1254228110SjkimAcpiDbDisplayResources ( 1255228110Sjkim char *ObjectArg) 1256228110Sjkim{ 1257228110Sjkim ACPI_NAMESPACE_NODE *Node; 1258228110Sjkim 1259228110Sjkim 1260228110Sjkim AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1261228110Sjkim AcpiDbgLevel |= ACPI_LV_RESOURCES; 1262228110Sjkim 1263228110Sjkim /* Asterisk means "display resources for all devices" */ 1264228110Sjkim 1265284583Sjkim if (!ObjectArg || (!strcmp (ObjectArg, "*"))) 1266228110Sjkim { 1267228110Sjkim (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1268287168Sjkim ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); 1269228110Sjkim } 1270228110Sjkim else 1271228110Sjkim { 1272228110Sjkim /* Convert string to object pointer */ 1273228110Sjkim 1274228110Sjkim Node = AcpiDbConvertToNode (ObjectArg); 1275228110Sjkim if (Node) 1276228110Sjkim { 1277228110Sjkim if (Node->Type != ACPI_TYPE_DEVICE) 1278228110Sjkim { 1279287168Sjkim AcpiOsPrintf ( 1280287168Sjkim "%4.4s: Name is not a device object (%s)\n", 1281228110Sjkim Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); 1282228110Sjkim } 1283228110Sjkim else 1284228110Sjkim { 1285228110Sjkim (void) AcpiDbDeviceResources (Node, 0, NULL, NULL); 1286228110Sjkim } 1287228110Sjkim } 1288228110Sjkim } 1289228110Sjkim 129091116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 129173561Smsmith} 129273561Smsmith 129373561Smsmith 1294231844Sjkim#if (!ACPI_REDUCED_HARDWARE) 129599679Siwasaki/******************************************************************************* 129699679Siwasaki * 1297114237Snjl * FUNCTION: AcpiDbGenerateGpe 1298114237Snjl * 1299245582Sjkim * PARAMETERS: GpeArg - Raw GPE number, ascii string 1300245582Sjkim * BlockArg - GPE block number, ascii string 1301245582Sjkim * 0 or 1 for FADT GPE blocks 1302114237Snjl * 1303114237Snjl * RETURN: None 1304114237Snjl * 1305245582Sjkim * DESCRIPTION: Simulate firing of a GPE 1306114237Snjl * 1307114237Snjl ******************************************************************************/ 1308114237Snjl 1309114237Snjlvoid 1310114237SnjlAcpiDbGenerateGpe ( 1311114237Snjl char *GpeArg, 1312114237Snjl char *BlockArg) 1313114237Snjl{ 1314272444Sjkim UINT32 BlockNumber = 0; 1315114237Snjl UINT32 GpeNumber; 1316114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo; 1317114237Snjl 1318114237Snjl 1319284583Sjkim GpeNumber = strtoul (GpeArg, NULL, 0); 1320114237Snjl 1321272444Sjkim /* 1322272444Sjkim * If no block arg, or block arg == 0 or 1, use the FADT-defined 1323272444Sjkim * GPE blocks. 1324272444Sjkim */ 1325272444Sjkim if (BlockArg) 1326272444Sjkim { 1327284583Sjkim BlockNumber = strtoul (BlockArg, NULL, 0); 1328272444Sjkim if (BlockNumber == 1) 1329272444Sjkim { 1330272444Sjkim BlockNumber = 0; 1331272444Sjkim } 1332272444Sjkim } 1333114237Snjl 1334298714Sjkim GpeEventInfo = AcpiEvGetGpeEventInfo ( 1335298714Sjkim ACPI_TO_POINTER (BlockNumber), GpeNumber); 1336114237Snjl if (!GpeEventInfo) 1337114237Snjl { 1338114237Snjl AcpiOsPrintf ("Invalid GPE\n"); 1339114237Snjl return; 1340114237Snjl } 1341114237Snjl 1342216471Sjkim (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); 1343114237Snjl} 1344254745Sjkim 1345287168Sjkim 1346287168Sjkim/******************************************************************************* 1347287168Sjkim * 1348287168Sjkim * FUNCTION: AcpiDbGenerateSci 1349287168Sjkim * 1350287168Sjkim * PARAMETERS: None 1351287168Sjkim * 1352287168Sjkim * RETURN: None 1353287168Sjkim * 1354287168Sjkim * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch. 1355287168Sjkim * 1356287168Sjkim ******************************************************************************/ 1357287168Sjkim 1358254745Sjkimvoid 1359254745SjkimAcpiDbGenerateSci ( 1360254745Sjkim void) 1361254745Sjkim{ 1362254745Sjkim AcpiEvSciDispatch (); 1363254745Sjkim} 1364254745Sjkim 1365231844Sjkim#endif /* !ACPI_REDUCED_HARDWARE */ 1366114237Snjl 1367285797Sjkim 1368285797Sjkim/******************************************************************************* 1369285797Sjkim * 1370285797Sjkim * FUNCTION: AcpiDbTrace 1371285797Sjkim * 1372285797Sjkim * PARAMETERS: EnableArg - ENABLE/AML to enable tracer 1373285797Sjkim * DISABLE to disable tracer 1374285797Sjkim * MethodArg - Method to trace 1375285797Sjkim * OnceArg - Whether trace once 1376285797Sjkim * 1377285797Sjkim * RETURN: None 1378285797Sjkim * 1379285797Sjkim * DESCRIPTION: Control method tracing facility 1380285797Sjkim * 1381285797Sjkim ******************************************************************************/ 1382285797Sjkim 1383285797Sjkimvoid 1384285797SjkimAcpiDbTrace ( 1385285797Sjkim char *EnableArg, 1386285797Sjkim char *MethodArg, 1387285797Sjkim char *OnceArg) 1388285797Sjkim{ 1389285797Sjkim UINT32 DebugLevel = 0; 1390285797Sjkim UINT32 DebugLayer = 0; 1391285797Sjkim UINT32 Flags = 0; 1392285797Sjkim 1393285797Sjkim 1394298714Sjkim AcpiUtStrupr (EnableArg); 1395298714Sjkim AcpiUtStrupr (OnceArg); 1396287168Sjkim 1397285797Sjkim if (MethodArg) 1398285797Sjkim { 1399285797Sjkim if (AcpiDbTraceMethodName) 1400285797Sjkim { 1401285797Sjkim ACPI_FREE (AcpiDbTraceMethodName); 1402285797Sjkim AcpiDbTraceMethodName = NULL; 1403285797Sjkim } 1404287168Sjkim 1405285797Sjkim AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1); 1406285797Sjkim if (!AcpiDbTraceMethodName) 1407285797Sjkim { 1408287168Sjkim AcpiOsPrintf ("Failed to allocate method name (%s)\n", 1409287168Sjkim MethodArg); 1410285797Sjkim return; 1411285797Sjkim } 1412287168Sjkim 1413285797Sjkim strcpy (AcpiDbTraceMethodName, MethodArg); 1414285797Sjkim } 1415287168Sjkim 1416285797Sjkim if (!strcmp (EnableArg, "ENABLE") || 1417285797Sjkim !strcmp (EnableArg, "METHOD") || 1418285797Sjkim !strcmp (EnableArg, "OPCODE")) 1419285797Sjkim { 1420285797Sjkim if (!strcmp (EnableArg, "ENABLE")) 1421285797Sjkim { 1422285797Sjkim /* Inherit current console settings */ 1423285797Sjkim 1424285797Sjkim DebugLevel = AcpiGbl_DbConsoleDebugLevel; 1425285797Sjkim DebugLayer = AcpiDbgLayer; 1426285797Sjkim } 1427285797Sjkim else 1428285797Sjkim { 1429285797Sjkim /* Restrict console output to trace points only */ 1430285797Sjkim 1431285797Sjkim DebugLevel = ACPI_LV_TRACE_POINT; 1432285797Sjkim DebugLayer = ACPI_EXECUTER; 1433285797Sjkim } 1434285797Sjkim 1435285797Sjkim Flags = ACPI_TRACE_ENABLED; 1436287168Sjkim 1437285797Sjkim if (!strcmp (EnableArg, "OPCODE")) 1438285797Sjkim { 1439285797Sjkim Flags |= ACPI_TRACE_OPCODE; 1440285797Sjkim } 1441287168Sjkim 1442285797Sjkim if (OnceArg && !strcmp (OnceArg, "ONCE")) 1443285797Sjkim { 1444285797Sjkim Flags |= ACPI_TRACE_ONESHOT; 1445285797Sjkim } 1446285797Sjkim } 1447285797Sjkim 1448285797Sjkim (void) AcpiDebugTrace (AcpiDbTraceMethodName, 1449287168Sjkim DebugLevel, DebugLayer, Flags); 1450285797Sjkim} 1451