diff options
Diffstat (limited to 'usr/src/uts/intel/io/acpica/debugger/dbcmds.c')
-rw-r--r-- | usr/src/uts/intel/io/acpica/debugger/dbcmds.c | 473 |
1 files changed, 365 insertions, 108 deletions
diff --git a/usr/src/uts/intel/io/acpica/debugger/dbcmds.c b/usr/src/uts/intel/io/acpica/debugger/dbcmds.c index 73387b872c..459cd916ee 100644 --- a/usr/src/uts/intel/io/acpica/debugger/dbcmds.c +++ b/usr/src/uts/intel/io/acpica/debugger/dbcmds.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2011, Intel Corp. + * Copyright (C) 2000 - 2012, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,7 @@ #include "accommon.h" #include "acevents.h" #include "acdebug.h" +#include "acnamesp.h" #include "acresrc.h" #include "actables.h" @@ -69,6 +70,18 @@ AcpiDmTestResourceConversion ( ACPI_NAMESPACE_NODE *Node, char *Name); +static ACPI_STATUS +AcpiDbResourceCallback ( + ACPI_RESOURCE *Resource, + void *Context); + +static ACPI_STATUS +AcpiDbDeviceResources ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -148,28 +161,49 @@ AcpiDbSleep ( UINT8 SleepState; + ACPI_FUNCTION_TRACE (AcpiDbSleep); + + SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); AcpiOsPrintf ("**** Prepare to sleep ****\n"); Status = AcpiEnterSleepStatePrep (SleepState); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } AcpiOsPrintf ("**** Going to sleep ****\n"); - Status = AcpiEnterSleepState (SleepState); + Status = AcpiEnterSleepState (SleepState, ACPI_NO_OPTIONAL_METHODS); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } - AcpiOsPrintf ("**** returning from sleep ****\n"); + AcpiOsPrintf ("**** Prepare to return from sleep ****\n"); + Status = AcpiLeaveSleepStatePrep (SleepState, ACPI_NO_OPTIONAL_METHODS); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + AcpiOsPrintf ("**** Returning from sleep ****\n"); Status = AcpiLeaveSleepState (SleepState); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } return (Status); + + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, "During sleep test")); + return (Status); } + /******************************************************************************* * * FUNCTION: AcpiDbDisplayLocks @@ -339,25 +373,20 @@ AcpiDbSendNotify ( return; } - /* Decode Named object type */ + /* Dispatch the notify if legal */ - switch (Node->Type) + if (AcpiEvIsNotifyObject (Node)) { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_THERMAL: - - /* Send the notify */ - Status = AcpiEvQueueNotifyRequest (Node, Value); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not queue notify\n"); } - break; - - default: - AcpiOsPrintf ("Named object is not a device or a thermal object\n"); - break; + } + else + { + AcpiOsPrintf ("Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); } } @@ -456,6 +485,78 @@ AcpiDbDisplayInterfaces ( /******************************************************************************* * + * FUNCTION: AcpiDbDisplayTemplate + * + * PARAMETERS: BufferArg - Buffer name or addrss + * + * RETURN: None + * + * DESCRIPTION: Dump a buffer that contains a resource template + * + ******************************************************************************/ + +void +AcpiDbDisplayTemplate ( + char *BufferArg) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_BUFFER ReturnObj; + + + /* Translate BufferArg to an Named object */ + + Node = AcpiDbConvertToNode (BufferArg); + if (!Node || (Node == AcpiGbl_RootNode)) + { + AcpiOsPrintf ("Invalid argument: %s\n", BufferArg); + return; + } + + /* We must have a buffer object */ + + if (Node->Type != ACPI_TYPE_BUFFER) + { + AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n", + BufferArg); + return; + } + + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + + /* Attempt to convert the raw buffer to a resource list */ + + Status = AcpiRsCreateResourceList (Node->Object, &ReturnObj); + + AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + AcpiDbgLevel |= ACPI_LV_RESOURCES; + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n", + BufferArg, AcpiFormatException (Status)); + goto DumpBuffer; + } + + /* Now we can dump the resource list */ + + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, + ReturnObj.Pointer)); + +DumpBuffer: + AcpiOsPrintf ("\nRaw data buffer:\n"); + AcpiUtDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer, + Node->Object->Buffer.Length, + DB_BYTE_DISPLAY, ACPI_UINT32_MAX); + + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + return; +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmCompareAmlResources * * PARAMETERS: Aml1Buffer - Contains first resource list @@ -479,11 +580,14 @@ AcpiDmCompareAmlResources ( { UINT8 *Aml1; UINT8 *Aml2; + UINT8 *Aml1End; + UINT8 *Aml2End; ACPI_RSDESC_SIZE Aml1Length; ACPI_RSDESC_SIZE Aml2Length; ACPI_RSDESC_SIZE Offset = 0; UINT8 ResourceType; UINT32 Count = 0; + UINT32 i; /* Compare overall buffer sizes (may be different due to size rounding) */ @@ -491,16 +595,18 @@ AcpiDmCompareAmlResources ( if (Aml1BufferLength != Aml2BufferLength) { AcpiOsPrintf ( - "**** Buffer length mismatch in converted AML: original %X new %X ****\n", + "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n", Aml1BufferLength, Aml2BufferLength); } Aml1 = Aml1Buffer; Aml2 = Aml2Buffer; + Aml1End = Aml1Buffer + Aml1BufferLength; + Aml2End = Aml2Buffer + Aml2BufferLength; /* Walk the descriptor lists, comparing each descriptor */ - while (Aml1 < (Aml1Buffer + Aml1BufferLength)) + while ((Aml1 < Aml1End) && (Aml2 < Aml2End)) { /* Get the lengths of each descriptor */ @@ -513,7 +619,7 @@ AcpiDmCompareAmlResources ( if (Aml1Length != Aml2Length) { AcpiOsPrintf ( - "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n", + "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n", Count, ResourceType, Offset, Aml1Length, Aml2Length); } @@ -524,6 +630,15 @@ AcpiDmCompareAmlResources ( AcpiOsPrintf ( "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", Count, ResourceType, Offset); + + for (i = 0; i < Aml1Length; i++) + { + if (Aml1[i] != Aml2[i]) + { + AcpiOsPrintf ("Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n", + i, Aml2[i], Aml1[i]); + } + } } /* Exit on EndTag descriptor */ @@ -626,160 +741,301 @@ Exit1: /******************************************************************************* * - * FUNCTION: AcpiDbDisplayResources + * FUNCTION: AcpiDbResourceCallback * - * PARAMETERS: ObjectArg - String with hex value of the object + * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Display the resource objects associated with a device. + * DESCRIPTION: Simple callback to exercise AcpiWalkResources * ******************************************************************************/ -void -AcpiDbDisplayResources ( - char *ObjectArg) +static ACPI_STATUS +AcpiDbResourceCallback ( + ACPI_RESOURCE *Resource, + void *Context) +{ + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDeviceResources + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbDeviceResources ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) { ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *PrtNode = NULL; + ACPI_NAMESPACE_NODE *CrsNode = NULL; + ACPI_NAMESPACE_NODE *PrsNode = NULL; + ACPI_NAMESPACE_NODE *AeiNode = NULL; + char *ParentPath; ACPI_BUFFER ReturnObj; + ACPI_STATUS Status; - AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiDbgLevel |= ACPI_LV_RESOURCES; + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ParentPath = AcpiNsGetExternalPathname (Node); + if (!ParentPath) + { + return (AE_NO_MEMORY); + } - /* Convert string to object pointer */ + /* Get handles to the resource methods for this device */ - Node = AcpiDbConvertToNode (ObjectArg); - if (!Node) + (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode)); + if (!PrtNode && !CrsNode && !PrsNode && !AeiNode) { - return; + goto Cleanup; /* Nothing to do */ } + AcpiOsPrintf ("\nDevice: %s\n", ParentPath); + /* Prepare for a return object of arbitrary size */ ReturnObj.Pointer = AcpiGbl_DbBuffer; ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + /* _PRT */ - AcpiOsPrintf ("Evaluating _PRT\n"); + if (PrtNode) + { + AcpiOsPrintf ("Evaluating _PRT\n"); - /* Check if _PRT exists */ + Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not evaluate _PRT: %s\n", + AcpiFormatException (Status)); + goto GetCrs; + } - Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not obtain _PRT: %s\n", - AcpiFormatException (Status)); - goto GetCrs; - } + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", + AcpiFormatException (Status)); + goto GetCrs; + } - Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", - AcpiFormatException (Status)); - goto GetCrs; + AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); } - AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); - /* _CRS */ GetCrs: - AcpiOsPrintf ("Evaluating _CRS\n"); + if (CrsNode) + { + AcpiOsPrintf ("Evaluating _CRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - /* Check if _CRS exists */ + Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not evaluate _CRS: %s\n", + AcpiFormatException (Status)); + goto GetPrs; + } - Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not obtain _CRS: %s\n", - AcpiFormatException (Status)); - goto GetPrs; - } + /* This code is here to exercise the AcpiWalkResources interface */ - /* Get the _CRS resource list */ + Status = AcpiWalkResources (Node, METHOD_NAME__CRS, + AcpiDbResourceCallback, NULL); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiWalkResources failed: %s\n", + AcpiFormatException (Status)); + goto GetPrs; + } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + /* Get the _CRS resource list */ - Status = AcpiGetCurrentResources (Node, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", - AcpiFormatException (Status)); - goto GetPrs; - } + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - /* Dump the _CRS resource list */ + Status = AcpiGetCurrentResources (Node, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", + AcpiFormatException (Status)); + goto GetPrs; + } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, - ReturnObj.Pointer)); + /* Dump the _CRS resource list */ - /* - * Perform comparison of original AML to newly created AML. This tests both - * the AML->Resource conversion and the Resource->Aml conversion. - */ - Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, + ReturnObj.Pointer)); - /* Execute _SRS with the resource list */ + /* + * Perform comparison of original AML to newly created AML. This tests both + * the AML->Resource conversion and the Resource->Aml conversion. + */ + Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); - Status = AcpiSetCurrentResources (Node, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", - AcpiFormatException (Status)); - goto GetPrs; + /* Execute _SRS with the resource list */ + + Status = AcpiSetCurrentResources (Node, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", + AcpiFormatException (Status)); + goto GetPrs; + } } /* _PRS */ GetPrs: - AcpiOsPrintf ("Evaluating _PRS\n"); + if (PrsNode) + { + AcpiOsPrintf ("Evaluating _PRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not evaluate _PRS: %s\n", + AcpiFormatException (Status)); + goto GetAei; + } - /* Check if _PRS exists */ + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not obtain _PRS: %s\n", - AcpiFormatException (Status)); - goto Cleanup; + Status = AcpiGetPossibleResources (Node, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", + AcpiFormatException (Status)); + goto GetAei; + } + + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetPossibleResources (Node, &ReturnObj); - if (ACPI_FAILURE (Status)) + /* _AEI */ + +GetAei: + if (AeiNode) { - AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", - AcpiFormatException (Status)); - goto Cleanup; + AcpiOsPrintf ("Evaluating _AEI\n"); + + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not evaluate _AEI: %s\n", + AcpiFormatException (Status)); + goto Cleanup; + } + + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + Status = AcpiGetEventResources (Node, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiGetEventResources failed: %s\n", + AcpiFormatException (Status)); + goto Cleanup; + } + + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); Cleanup: + ACPI_FREE (ParentPath); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResources + * + * PARAMETERS: ObjectArg - String object name or object pointer. + * "*" means "display resources for all devices" + * + * RETURN: None + * + * DESCRIPTION: Display the resource objects associated with a device. + * + ******************************************************************************/ + +void +AcpiDbDisplayResources ( + char *ObjectArg) +{ + ACPI_NAMESPACE_NODE *Node; + + + AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + AcpiDbgLevel |= ACPI_LV_RESOURCES; + + /* Asterisk means "display resources for all devices" */ + + if (!ACPI_STRCMP (ObjectArg, "*")) + { + (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); + } + else + { + /* Convert string to object pointer */ + + Node = AcpiDbConvertToNode (ObjectArg); + if (Node) + { + if (Node->Type != ACPI_TYPE_DEVICE) + { + AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n", + Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); + } + else + { + (void) AcpiDbDeviceResources (Node, 0, NULL, NULL); + } + } + } AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); - return; } +#if (!ACPI_REDUCED_HARDWARE) /******************************************************************************* * * FUNCTION: AcpiDbGenerateGpe @@ -818,5 +1074,6 @@ AcpiDbGenerateGpe ( (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); } +#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* ACPI_DEBUGGER */ |