diff options
author | jkim <jkim@FreeBSD.org> | 2013-01-17 23:56:43 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-01-17 23:56:43 +0000 |
commit | 2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4 (patch) | |
tree | a7cdf321edb5a438878660c0df9e9bf8a70038e1 /sys/contrib/dev/acpica/components/debugger/dbcmds.c | |
parent | 39b667a9d0968b8b54185d03b5b8bb2670346424 (diff) | |
parent | 8f7c8be022add76a280165a4247448f1fcd77631 (diff) | |
download | FreeBSD-src-2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4.zip FreeBSD-src-2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4.tar.gz |
Merge ACPICA 20130117.
Diffstat (limited to 'sys/contrib/dev/acpica/components/debugger/dbcmds.c')
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbcmds.c | 259 |
1 files changed, 178 insertions, 81 deletions
diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c index 5120fcb..64c299c 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/components/debugger/dbcmds.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2012, Intel Corp. + * Copyright (C) 2000 - 2013, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,17 +82,21 @@ AcpiDbDeviceResources ( void *Context, void **ReturnValue); +static void +AcpiDbDoOneSleepState ( + UINT8 SleepState); + /******************************************************************************* * * FUNCTION: AcpiDbConvertToNode * - * PARAMETERS: InString - String to convert + * PARAMETERS: InString - String to convert * * RETURN: Pointer to a NS node * * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or - * alpha strings. + * alphanumeric strings. * ******************************************************************************/ @@ -126,9 +130,9 @@ AcpiDbConvertToNode ( } else { - /* Alpha argument */ - /* The parameter is a name string that must be resolved to a - * Named obj + /* + * Alpha argument: The parameter is a name string that must be + * resolved to a Namespace object. */ Node = AcpiDbLocalNsLookup (InString); if (!Node) @@ -145,11 +149,12 @@ AcpiDbConvertToNode ( * * FUNCTION: AcpiDbSleep * - * PARAMETERS: ObjectArg - Desired sleep state (0-5) + * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means + * invoke all possible sleep states. * * RETURN: Status * - * DESCRIPTION: Simulate a sleep/wake sequence + * DESCRIPTION: Simulate sleep/wake sequences * ******************************************************************************/ @@ -157,50 +162,124 @@ ACPI_STATUS AcpiDbSleep ( char *ObjectArg) { - ACPI_STATUS Status; UINT8 SleepState; + UINT32 i; ACPI_FUNCTION_TRACE (AcpiDbSleep); + /* Null input (no arguments) means to invoke all sleep states */ + + if (!ObjectArg) + { + AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n", + ACPI_S_STATES_MAX); + + for (i = 0; i <= ACPI_S_STATES_MAX; i++) + { + AcpiDbDoOneSleepState ((UINT8) i); + } + + return_ACPI_STATUS (AE_OK); + } + + /* Convert argument to binary and invoke the sleep state */ + SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); + AcpiDbDoOneSleepState (SleepState); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDoOneSleepState + * + * PARAMETERS: SleepState - Desired sleep state (0-5) + * + * RETURN: Status + * + * DESCRIPTION: Simulate a sleep/wake sequence + * + ******************************************************************************/ + +static void +AcpiDbDoOneSleepState ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + UINT8 SleepTypeA; + UINT8 SleepTypeB; + + + /* Validate parameter */ + + if (SleepState > ACPI_S_STATES_MAX) + { + AcpiOsPrintf ("Sleep state %d out of range (%d max)\n", + SleepState, ACPI_S_STATES_MAX); + return; + } + + AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n", + SleepState, AcpiGbl_SleepStateNames[SleepState]); + + /* Get the values for the sleep type registers (for display only) */ + + Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not evaluate [%s] method, %s\n", + AcpiGbl_SleepStateNames[SleepState], + AcpiFormatException (Status)); + return; + } - AcpiOsPrintf ("**** Prepare to sleep ****\n"); + AcpiOsPrintf ( + "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n", + SleepState, SleepTypeA, SleepTypeB); + + /* Invoke the various sleep/wake interfaces */ + + AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n", + SleepState); Status = AcpiEnterSleepStatePrep (SleepState); if (ACPI_FAILURE (Status)) { goto ErrorExit; } - AcpiOsPrintf ("**** Going to sleep ****\n"); + AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n", + SleepState); Status = AcpiEnterSleepState (SleepState); if (ACPI_FAILURE (Status)) { goto ErrorExit; } - AcpiOsPrintf ("**** Prepare to return from sleep ****\n"); + AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n", + SleepState); Status = AcpiLeaveSleepStatePrep (SleepState); if (ACPI_FAILURE (Status)) { goto ErrorExit; } - AcpiOsPrintf ("**** Returning from sleep ****\n"); + AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n", + SleepState); Status = AcpiLeaveSleepState (SleepState); if (ACPI_FAILURE (Status)) { goto ErrorExit; } - return_ACPI_STATUS (Status); + return; ErrorExit: - - ACPI_EXCEPTION ((AE_INFO, Status, "During sleep test")); - return_ACPI_STATUS (Status); + ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d", + SleepState)); } @@ -236,7 +315,7 @@ AcpiDbDisplayLocks ( * * FUNCTION: AcpiDbDisplayTableInfo * - * PARAMETERS: TableArg - String with name of table to be displayed + * PARAMETERS: TableArg - Name of table to be displayed * * RETURN: None * @@ -377,8 +456,8 @@ AcpiDbUnloadAcpiTable ( * * FUNCTION: AcpiDbSendNotify * - * PARAMETERS: Name - Name of ACPI object to send the notify to - * Value - Value of the notify to send. + * PARAMETERS: Name - Name of ACPI object where to send notify + * Value - Value of the notify to send. * * RETURN: None * @@ -416,7 +495,8 @@ AcpiDbSendNotify ( } else { - AcpiOsPrintf ("Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n", + AcpiOsPrintf ( + "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); } } @@ -453,7 +533,6 @@ AcpiDbDisplayInterfaces ( ACPI_WAIT_FOREVER); NextInterface = AcpiGbl_SupportedInterfaces; - while (NextInterface) { if (!(NextInterface->Flags & ACPI_OSI_INVALID)) @@ -518,7 +597,7 @@ AcpiDbDisplayInterfaces ( * * FUNCTION: AcpiDbDisplayTemplate * - * PARAMETERS: BufferArg - Buffer name or addrss + * PARAMETERS: BufferArg - Buffer name or address * * RETURN: None * @@ -532,7 +611,7 @@ AcpiDbDisplayTemplate ( { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_BUFFER ReturnObj; + ACPI_BUFFER ReturnBuffer; /* Translate BufferArg to an Named object */ @@ -553,12 +632,12 @@ AcpiDbDisplayTemplate ( return; } - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; /* Attempt to convert the raw buffer to a resource list */ - Status = AcpiRsCreateResourceList (Node->Object, &ReturnObj); + Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer); AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); AcpiDbgLevel |= ACPI_LV_RESOURCES; @@ -573,7 +652,7 @@ AcpiDbDisplayTemplate ( /* Now we can dump the resource list */ AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, - ReturnObj.Pointer)); + ReturnBuffer.Pointer)); DumpBuffer: AcpiOsPrintf ("\nRaw data buffer:\n"); @@ -666,7 +745,8 @@ AcpiDmCompareAmlResources ( { if (Aml1[i] != Aml2[i]) { - AcpiOsPrintf ("Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n", + AcpiOsPrintf ( + "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n", i, Aml2[i], Aml1[i]); } } @@ -693,8 +773,8 @@ AcpiDmCompareAmlResources ( * * FUNCTION: AcpiDmTestResourceConversion * - * PARAMETERS: Node - Parent device node - * Name - resource method name (_CRS) + * PARAMETERS: Node - Parent device node + * Name - resource method name (_CRS) * * RETURN: Status * @@ -709,8 +789,8 @@ AcpiDmTestResourceConversion ( char *Name) { ACPI_STATUS Status; - ACPI_BUFFER ReturnObj; - ACPI_BUFFER ResourceObj; + ACPI_BUFFER ReturnBuffer; + ACPI_BUFFER ResourceBuffer; ACPI_BUFFER NewAml; ACPI_OBJECT *OriginalAml; @@ -718,12 +798,12 @@ AcpiDmTestResourceConversion ( AcpiOsPrintf ("Resource Conversion Comparison:\n"); NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; /* Get the original _CRS AML resource template */ - Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj); + Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not obtain %s: %s\n", @@ -733,7 +813,7 @@ AcpiDmTestResourceConversion ( /* Get the AML resource template, converted to internal resource structs */ - Status = AcpiGetCurrentResources (Node, &ResourceObj); + Status = AcpiGetCurrentResources (Node, &ResourceBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", @@ -743,7 +823,7 @@ AcpiDmTestResourceConversion ( /* Convert internal resource list to external AML resource template */ - Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml); + Status = AcpiRsCreateAmlResources (ResourceBuffer.Pointer, &NewAml); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", @@ -753,7 +833,7 @@ AcpiDmTestResourceConversion ( /* Compare original AML to the newly created AML resource list */ - OriginalAml = ReturnObj.Pointer; + OriginalAml = ReturnBuffer.Pointer; AcpiDmCompareAmlResources ( OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, @@ -763,9 +843,9 @@ AcpiDmTestResourceConversion ( ACPI_FREE (NewAml.Pointer); Exit2: - ACPI_FREE (ResourceObj.Pointer); + ACPI_FREE (ResourceBuffer.Pointer); Exit1: - ACPI_FREE (ReturnObj.Pointer); + ACPI_FREE (ReturnBuffer.Pointer); return (Status); } @@ -778,7 +858,8 @@ Exit1: * * RETURN: Status * - * DESCRIPTION: Simple callback to exercise AcpiWalkResources + * DESCRIPTION: Simple callback to exercise AcpiWalkResources and + * AcpiWalkResourceBuffer. * ******************************************************************************/ @@ -817,7 +898,7 @@ AcpiDbDeviceResources ( ACPI_NAMESPACE_NODE *PrsNode = NULL; ACPI_NAMESPACE_NODE *AeiNode = NULL; char *ParentPath; - ACPI_BUFFER ReturnObj; + ACPI_BUFFER ReturnBuffer; ACPI_STATUS Status; @@ -843,8 +924,8 @@ AcpiDbDeviceResources ( /* Prepare for a return object of arbitrary size */ - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; /* _PRT */ @@ -853,7 +934,7 @@ AcpiDbDeviceResources ( { AcpiOsPrintf ("Evaluating _PRT\n"); - Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnObj); + Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not evaluate _PRT: %s\n", @@ -861,10 +942,10 @@ AcpiDbDeviceResources ( goto GetCrs; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); + Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", @@ -883,10 +964,10 @@ GetCrs: { AcpiOsPrintf ("Evaluating _CRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnObj); + Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not evaluate _CRS: %s\n", @@ -894,7 +975,7 @@ GetCrs: goto GetPrs; } - /* This code is here to exercise the AcpiWalkResources interface */ + /* This code exercises the AcpiWalkResources interface */ Status = AcpiWalkResources (Node, METHOD_NAME__CRS, AcpiDbResourceCallback, NULL); @@ -905,12 +986,12 @@ GetCrs: goto GetPrs; } - /* Get the _CRS resource list */ + /* Get the _CRS resource list (test ALLOCATE buffer) */ - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = NULL; + ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetCurrentResources (Node, &ReturnObj); + Status = AcpiGetCurrentResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", @@ -918,26 +999,41 @@ GetCrs: goto GetPrs; } + /* This code exercises the AcpiWalkResourceBuffer interface */ + + Status = AcpiWalkResourceBuffer (&ReturnBuffer, + AcpiDbResourceCallback, NULL); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n", + AcpiFormatException (Status)); + goto EndCrs; + } + /* Dump the _CRS resource list */ AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, - ReturnObj.Pointer)); + ReturnBuffer.Pointer)); /* - * Perform comparison of original AML to newly created AML. This tests both - * the AML->Resource conversion and the Resource->Aml conversion. + * 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); + (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); /* Execute _SRS with the resource list */ - Status = AcpiSetCurrentResources (Node, &ReturnObj); + Status = AcpiSetCurrentResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status)); - goto GetPrs; + goto EndCrs; } + +EndCrs: + ACPI_FREE_BUFFER (ReturnBuffer); } @@ -948,10 +1044,10 @@ GetPrs: { AcpiOsPrintf ("Evaluating _PRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnObj); + Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not evaluate _PRS: %s\n", @@ -959,10 +1055,10 @@ GetPrs: goto GetAei; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetPossibleResources (Node, &ReturnObj); + Status = AcpiGetPossibleResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", @@ -981,10 +1077,10 @@ GetAei: { AcpiOsPrintf ("Evaluating _AEI\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnObj); + Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not evaluate _AEI: %s\n", @@ -992,10 +1088,10 @@ GetAei: goto Cleanup; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Pointer = AcpiGbl_DbBuffer; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetEventResources (Node, &ReturnObj); + Status = AcpiGetEventResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiGetEventResources failed: %s\n", @@ -1017,8 +1113,9 @@ Cleanup: * * FUNCTION: AcpiDbDisplayResources * - * PARAMETERS: ObjectArg - String object name or object pointer. - * "*" means "display resources for all devices" + * PARAMETERS: ObjectArg - String object name or object pointer. + * "*" means "display resources for all + * devices" * * RETURN: None * @@ -1071,13 +1168,13 @@ AcpiDbDisplayResources ( * * FUNCTION: AcpiDbGenerateGpe * - * PARAMETERS: GpeArg - Raw GPE number, ascii string - * BlockArg - GPE block number, ascii string - * 0 or 1 for FADT GPE blocks + * PARAMETERS: GpeArg - Raw GPE number, ascii string + * BlockArg - GPE block number, ascii string + * 0 or 1 for FADT GPE blocks * * RETURN: None * - * DESCRIPTION: Generate a GPE + * DESCRIPTION: Simulate firing of a GPE * ******************************************************************************/ |