diff options
Diffstat (limited to 'sys/contrib/dev/acpica/components/debugger')
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbcmds.c | 195 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbconvert.c | 23 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbdisply.c | 202 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbexec.c | 95 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbfileio.c | 148 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbhistry.c | 14 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbinput.c | 347 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbmethod.c | 49 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbnames.c | 170 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbobject.c | 580 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbstats.c | 26 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbtest.c | 54 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbutils.c | 45 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbxface.c | 158 |
14 files changed, 1463 insertions, 643 deletions
diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c index c11451d..191b1b4 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 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,6 @@ #include <contrib/dev/acpica/include/acresrc.h> #include <contrib/dev/acpica/include/actables.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbcmds") @@ -86,6 +85,9 @@ AcpiDbDoOneSleepState ( UINT8 SleepState); +static char *AcpiDbTraceMethodName = NULL; + + /******************************************************************************* * * FUNCTION: AcpiDbConvertToNode @@ -111,12 +113,11 @@ AcpiDbConvertToNode ( { /* Numeric argument, convert */ - Address = ACPI_STRTOUL (InString, NULL, 16); + Address = strtoul (InString, NULL, 16); Node = ACPI_TO_POINTER (Address); if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Address %p is invalid", - Node); + AcpiOsPrintf ("Address %p is invalid", Node); return (NULL); } @@ -125,7 +126,7 @@ AcpiDbConvertToNode ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", - Node, AcpiUtGetDescriptorName (Node)); + Node, AcpiUtGetDescriptorName (Node)); return (NULL); } } @@ -138,7 +139,8 @@ AcpiDbConvertToNode ( Node = AcpiDbLocalNsLookup (InString); if (!Node) { - AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n", + AcpiOsPrintf ( + "Could not find [%s] in namespace, defaulting to root node\n", InString); Node = AcpiGbl_RootNode; } @@ -189,7 +191,7 @@ AcpiDbSleep ( /* Convert argument to binary and invoke the sleep state */ - SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); + SleepState = (UINT8) strtoul (ObjectArg, NULL, 0); AcpiDbDoOneSleepState (SleepState); return_ACPI_STATUS (AE_OK); } @@ -201,7 +203,7 @@ AcpiDbSleep ( * * PARAMETERS: SleepState - Desired sleep state (0-5) * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Simulate a sleep/wake sequence * @@ -338,7 +340,8 @@ AcpiDbDisplayTableInfo ( /* Header */ - AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n"); + AcpiOsPrintf ("Idx ID Status Type " + "TableHeader (Sig, Address, Length, Misc)\n"); /* Walk the entire root table list */ @@ -402,7 +405,7 @@ AcpiDbDisplayTableInfo ( { /* If the pointer is null, the table has been unloaded */ - ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", + ACPI_INFO (("%4.4s - Table has been unloaded", TableDesc->Signature.Ascii)); } } @@ -497,7 +500,8 @@ AcpiDbSendNotify ( else { AcpiOsPrintf ( - "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n", + "Named object [%4.4s] Type %s, " + "must be Device/Thermal/Processor type\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); } } @@ -530,8 +534,7 @@ AcpiDbDisplayInterfaces ( if (!ActionArg) { - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, - ACPI_WAIT_FOREVER); + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); NextInterface = AcpiGbl_SupportedInterfaces; while (NextInterface) @@ -540,6 +543,7 @@ AcpiDbDisplayInterfaces ( { AcpiOsPrintf ("%s\n", NextInterface->Name); } + NextInterface = NextInterface->Next; } @@ -561,7 +565,7 @@ AcpiDbDisplayInterfaces ( /* Install - install an interface */ - SubString = ACPI_STRSTR ("INSTALL", ActionArg); + SubString = strstr ("INSTALL", ActionArg); if (SubString) { Status = AcpiInstallInterface (InterfaceNameArg); @@ -575,7 +579,7 @@ AcpiDbDisplayInterfaces ( /* Remove - remove an interface */ - SubString = ACPI_STRSTR ("REMOVE", ActionArg); + SubString = strstr ("REMOVE", ActionArg); if (SubString) { Status = AcpiRemoveInterface (InterfaceNameArg); @@ -645,7 +649,8 @@ AcpiDbDisplayTemplate ( if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n", + AcpiOsPrintf ( + "Could not convert Buffer to a resource list: %s, %s\n", BufferArg, AcpiFormatException (Status)); goto DumpBuffer; } @@ -706,7 +711,8 @@ 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); } @@ -730,16 +736,18 @@ AcpiDmCompareAmlResources ( if (Aml1Length != Aml2Length) { AcpiOsPrintf ( - "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n", + "**** Length mismatch in descriptor [%.2X] type %2.2X, " + "Offset %8.8X Len1 %X, Len2 %X ****\n", Count, ResourceType, Offset, Aml1Length, Aml2Length); } /* Check for descriptor byte match */ - else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) + else if (memcmp (Aml1, Aml2, Aml1Length)) { AcpiOsPrintf ( - "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", + "**** Data mismatch in descriptor [%.2X] type %2.2X, " + "Offset %8.8X ****\n", Count, ResourceType, Offset); for (i = 0; i < Aml1Length; i++) @@ -747,7 +755,8 @@ AcpiDmCompareAmlResources ( if (Aml1[i] != Aml2[i]) { AcpiOsPrintf ( - "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n", + "Mismatch at byte offset %.2X: is %2.2X, " + "should be %2.2X\n", i, Aml2[i], Aml1[i]); } } @@ -904,7 +913,7 @@ AcpiDbDeviceResources ( Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - ParentPath = AcpiNsGetExternalPathname (Node); + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); if (!ParentPath) { return (AE_NO_MEMORY); @@ -912,10 +921,15 @@ AcpiDbDeviceResources ( /* Get handles to the resource methods for this device */ - (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)); + (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) { goto Cleanup; /* Nothing to do */ @@ -990,7 +1004,7 @@ GetCrs: /* Get the _CRS resource list (test ALLOCATE buffer) */ ReturnBuffer.Pointer = NULL; - ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiGetCurrentResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1059,7 +1073,7 @@ GetPrs: } ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiGetPossibleResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1069,7 +1083,8 @@ GetPrs: goto GetAei; } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiRsDumpResourceList (ACPI_CAST_PTR ( + ACPI_RESOURCE, AcpiGbl_DbBuffer)); } @@ -1081,7 +1096,7 @@ GetAei: AcpiOsPrintf ("Evaluating _AEI\n"); ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1092,7 +1107,7 @@ GetAei: } ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiGetEventResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1102,7 +1117,8 @@ GetAei: goto Cleanup; } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiRsDumpResourceList (ACPI_CAST_PTR ( + ACPI_RESOURCE, AcpiGbl_DbBuffer)); } @@ -1138,10 +1154,10 @@ AcpiDbDisplayResources ( /* Asterisk means "display resources for all devices" */ - if (!ObjectArg || (!ACPI_STRCMP (ObjectArg, "*"))) + if (!ObjectArg || (!strcmp (ObjectArg, "*"))) { (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); } else { @@ -1152,7 +1168,8 @@ AcpiDbDisplayResources ( { if (Node->Type != ACPI_TYPE_DEVICE) { - AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n", + AcpiOsPrintf ( + "%4.4s: Name is not a device object (%s)\n", Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); } else @@ -1191,7 +1208,7 @@ AcpiDbGenerateGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); + GpeNumber = strtoul (GpeArg, NULL, 0); /* * If no block arg, or block arg == 0 or 1, use the FADT-defined @@ -1199,15 +1216,15 @@ AcpiDbGenerateGpe ( */ if (BlockArg) { - BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); + BlockNumber = strtoul (BlockArg, NULL, 0); if (BlockNumber == 1) { BlockNumber = 0; } } - GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), - GpeNumber); + GpeEventInfo = AcpiEvGetGpeEventInfo ( + ACPI_TO_POINTER (BlockNumber), GpeNumber); if (!GpeEventInfo) { AcpiOsPrintf ("Invalid GPE\n"); @@ -1217,6 +1234,19 @@ AcpiDbGenerateGpe ( (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); } + +/******************************************************************************* + * + * FUNCTION: AcpiDbGenerateSci + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch. + * + ******************************************************************************/ + void AcpiDbGenerateSci ( void) @@ -1226,4 +1256,87 @@ AcpiDbGenerateSci ( #endif /* !ACPI_REDUCED_HARDWARE */ -#endif /* ACPI_DEBUGGER */ + +/******************************************************************************* + * + * FUNCTION: AcpiDbTrace + * + * PARAMETERS: EnableArg - ENABLE/AML to enable tracer + * DISABLE to disable tracer + * MethodArg - Method to trace + * OnceArg - Whether trace once + * + * RETURN: None + * + * DESCRIPTION: Control method tracing facility + * + ******************************************************************************/ + +void +AcpiDbTrace ( + char *EnableArg, + char *MethodArg, + char *OnceArg) +{ + UINT32 DebugLevel = 0; + UINT32 DebugLayer = 0; + UINT32 Flags = 0; + + + AcpiUtStrupr (EnableArg); + AcpiUtStrupr (OnceArg); + + if (MethodArg) + { + if (AcpiDbTraceMethodName) + { + ACPI_FREE (AcpiDbTraceMethodName); + AcpiDbTraceMethodName = NULL; + } + + AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1); + if (!AcpiDbTraceMethodName) + { + AcpiOsPrintf ("Failed to allocate method name (%s)\n", + MethodArg); + return; + } + + strcpy (AcpiDbTraceMethodName, MethodArg); + } + + if (!strcmp (EnableArg, "ENABLE") || + !strcmp (EnableArg, "METHOD") || + !strcmp (EnableArg, "OPCODE")) + { + if (!strcmp (EnableArg, "ENABLE")) + { + /* Inherit current console settings */ + + DebugLevel = AcpiGbl_DbConsoleDebugLevel; + DebugLayer = AcpiDbgLayer; + } + else + { + /* Restrict console output to trace points only */ + + DebugLevel = ACPI_LV_TRACE_POINT; + DebugLayer = ACPI_EXECUTER; + } + + Flags = ACPI_TRACE_ENABLED; + + if (!strcmp (EnableArg, "OPCODE")) + { + Flags |= ACPI_TRACE_OPCODE; + } + + if (OnceArg && !strcmp (OnceArg, "ONCE")) + { + Flags |= ACPI_TRACE_ONESHOT; + } + } + + (void) AcpiDebugTrace (AcpiDbTraceMethodName, + DebugLevel, DebugLayer, Flags); +} diff --git a/sys/contrib/dev/acpica/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/components/debugger/dbconvert.c index f6c0286..09379a8 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbconvert.c +++ b/sys/contrib/dev/acpica/components/debugger/dbconvert.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbconvert") @@ -77,7 +76,7 @@ AcpiDbHexCharToValue ( /* Digit must be ascii [0-9a-fA-F] */ - if (!ACPI_IS_XDIGIT (HexChar)) + if (!isxdigit (HexChar)) { return (AE_BAD_HEX_CONSTANT); } @@ -88,7 +87,7 @@ AcpiDbHexCharToValue ( } else { - Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37); + Value = (UINT8) (toupper (HexChar) - 0x37); } *ReturnValue = Value; @@ -199,7 +198,7 @@ AcpiDbConvertToBuffer ( } j++; - i+=2; + i += 2; while (String[i] && ((String[i] == ',') || (String[i] == ' '))) { @@ -306,7 +305,7 @@ AcpiDbConvertToObject ( Object->Type = ACPI_TYPE_STRING; Object->String.Pointer = String; - Object->String.Length = (UINT32) ACPI_STRLEN (String); + Object->String.Length = (UINT32) strlen (String); break; case ACPI_TYPE_BUFFER: @@ -322,7 +321,8 @@ AcpiDbConvertToObject ( default: Object->Type = ACPI_TYPE_INTEGER; - Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); + Status = AcpiUtStrtoul64 (String, 16, AcpiGbl_IntegerByteWidth, + &Object->Integer.Value); break; } @@ -466,12 +466,12 @@ AcpiDbDumpPldBuffer ( NewBuffer = AcpiDbEncodePldBuffer (PldInfo); if (!NewBuffer) { - return; + goto Exit; } /* The two bit-packed buffers should match */ - if (ACPI_MEMCMP (NewBuffer, BufferDesc->Buffer.Pointer, + if (memcmp (NewBuffer, BufferDesc->Buffer.Pointer, BufferDesc->Buffer.Length)) { AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n"); @@ -525,8 +525,7 @@ AcpiDbDumpPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalOffset", PldInfo->HorizontalOffset); } - ACPI_FREE (PldInfo); ACPI_FREE (NewBuffer); +Exit: + ACPI_FREE (PldInfo); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/components/debugger/dbdisply.c index 507c2b0..8db59bc 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/components/debugger/dbdisply.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,12 +48,10 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acevents.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbdisply") @@ -141,7 +139,7 @@ AcpiDbGetPointer ( ACPI_SIZE Address; - Address = ACPI_STRTOUL (Target, NULL, 16); + Address = strtoul (Target, NULL, 16); ObjPtr = ACPI_TO_POINTER (Address); return (ObjPtr); } @@ -243,7 +241,8 @@ AcpiDbDecodeAndDisplayObject ( ObjPtr = AcpiDbGetPointer (Target); if (!AcpiOsReadable (ObjPtr, 16)) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", + AcpiOsPrintf ( + "Address %p is invalid in this address space\n", ObjPtr); return; } @@ -259,7 +258,8 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) { AcpiOsPrintf ( - "Cannot read entire Named object at address %p\n", ObjPtr); + "Cannot read entire Named object at address %p\n", + ObjPtr); return; } @@ -272,13 +272,14 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", + AcpiOsPrintf ( + "Cannot read entire ACPI object at address %p\n", ObjPtr); return; } - AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, - ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), + Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjPtr, 1); break; @@ -289,12 +290,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) { AcpiOsPrintf ( - "Cannot read entire Parser object at address %p\n", ObjPtr); + "Cannot read entire Parser object at address %p\n", + ObjPtr); return; } - AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, - ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), + Display, ACPI_UINT32_MAX); AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); break; @@ -333,7 +335,7 @@ AcpiDbDecodeAndDisplayObject ( DumpNode: /* Now dump the NS node */ - Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); + Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not convert name to pathname\n"); @@ -366,8 +368,8 @@ DumpNode: return; } - AcpiUtDebugDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), - Display, ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer ((void *) ObjDesc, + sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjDesc, 1); } } @@ -412,14 +414,13 @@ AcpiDbDisplayMethodInfo ( } ObjDesc = WalkState->MethodDesc; - Node = WalkState->MethodNode; + Node = WalkState->MethodNode; AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", - AcpiUtGetNodeName (Node)); + AcpiUtGetNodeName (Node)); AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", - (UINT32) ObjDesc->Method.ParamCount, - (UINT32) ObjDesc->Method.SyncLevel); - + (UINT32) ObjDesc->Method.ParamCount, + (UINT32) ObjDesc->Method.SyncLevel); RootOp = StartOp; while (RootOp->Common.Parent) @@ -513,7 +514,7 @@ AcpiDbDisplayLocals ( return; } - AcpiDmDisplayLocals (WalkState); + AcpiDbDecodeLocals (WalkState); } @@ -543,7 +544,7 @@ AcpiDbDisplayArguments ( return; } - AcpiDmDisplayArguments (WalkState); + AcpiDbDecodeArguments (WalkState); } @@ -580,7 +581,7 @@ AcpiDbDisplayResults ( } ObjDesc = WalkState->MethodDesc; - Node = WalkState->MethodNode; + Node = WalkState->MethodNode; if (WalkState->Results) { @@ -588,7 +589,7 @@ AcpiDbDisplayResults ( } AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", - AcpiUtGetNodeName (Node), ResultCount); + AcpiUtGetNodeName (Node), ResultCount); /* From the top element of result stack */ @@ -599,12 +600,14 @@ AcpiDbDisplayResults ( { ObjDesc = Frame->Results.ObjDesc[Index]; AcpiOsPrintf ("Result%u: ", i); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + if (Index == 0) { Frame = Frame->Results.Next; Index = ACPI_RESULTS_FRAME_OBJ_NUM; } + Index--; } } @@ -643,7 +646,6 @@ AcpiDbDisplayCallingTree ( while (WalkState) { Node = WalkState->MethodNode; - AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); WalkState = WalkState->Next; @@ -655,7 +657,7 @@ AcpiDbDisplayCallingTree ( * * FUNCTION: AcpiDbDisplayObjectType * - * PARAMETERS: Name - User entered NS node handle or name + * PARAMETERS: ObjectArg - User entered NS node handle * * RETURN: None * @@ -665,21 +667,19 @@ AcpiDbDisplayCallingTree ( void AcpiDbDisplayObjectType ( - char *Name) + char *ObjectArg) { - ACPI_NAMESPACE_NODE *Node; + ACPI_SIZE Arg; + ACPI_HANDLE Handle; ACPI_DEVICE_INFO *Info; ACPI_STATUS Status; UINT32 i; - Node = AcpiDbConvertToNode (Name); - if (!Node) - { - return; - } + Arg = strtoul (ObjectArg, NULL, 16); + Handle = ACPI_TO_POINTER (Arg); - Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info); + Status = AcpiGetObjectInfo (Handle, &Info); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get object info, %s\n", @@ -687,38 +687,29 @@ AcpiDbDisplayObjectType ( return; } - if (Info->Valid & ACPI_VALID_ADR) - { - AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus, Info->Flags); - } - if (Info->Valid & ACPI_VALID_SXDS) - { - AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3]); - } - if (Info->Valid & ACPI_VALID_SXWS) - { - AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", - Info->LowestDstates[0], Info->LowestDstates[1], - Info->LowestDstates[2], Info->LowestDstates[3], - Info->LowestDstates[4]); - } + AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus, Info->Flags); + + AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3]); + + AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", + Info->LowestDstates[0], Info->LowestDstates[1], + Info->LowestDstates[2], Info->LowestDstates[3], + Info->LowestDstates[4]); if (Info->Valid & ACPI_VALID_HID) { AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); } + if (Info->Valid & ACPI_VALID_UID) { AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); } - if (Info->Valid & ACPI_VALID_SUB) - { - AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String); - } + if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibleIdList.Count; i++) @@ -755,6 +746,13 @@ AcpiDbDisplayResultObject ( ACPI_WALK_STATE *WalkState) { +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) + { + return; + } +#endif + /* Only display if single stepping */ if (!AcpiGbl_CmSingleStep) @@ -763,7 +761,7 @@ AcpiDbDisplayResultObject ( } AcpiOsPrintf ("ResultObj: "); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); AcpiOsPrintf ("\n"); } @@ -787,13 +785,20 @@ AcpiDbDisplayArgumentObject ( ACPI_WALK_STATE *WalkState) { +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) + { + return; + } +#endif + if (!AcpiGbl_CmSingleStep) { return; } AcpiOsPrintf ("ArgObj: "); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); } @@ -843,7 +848,8 @@ AcpiDbDisplayGpes ( GpeBlock = GpeXruptInfo->GpeBlockListHead; while (GpeBlock) { - Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); + Status = AcpiGetName (GpeBlock->Node, + ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not convert name to pathname\n"); @@ -858,13 +864,16 @@ AcpiDbDisplayGpes ( GpeType = "GPE Block Device"; } - AcpiOsPrintf ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", + AcpiOsPrintf ( + "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); - AcpiOsPrintf (" Registers: %u (%u GPEs)\n", + AcpiOsPrintf ( + " Registers: %u (%u GPEs)\n", GpeBlock->RegisterCount, GpeBlock->GpeCount); - AcpiOsPrintf (" GPE range: 0x%X to 0x%X on interrupt %u\n", + AcpiOsPrintf ( + " GPE range: 0x%X to 0x%X on interrupt %u\n", GpeBlock->BlockBaseNumber, GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), GpeXruptInfo->InterruptNumber); @@ -872,8 +881,10 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ( " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", GpeBlock->RegisterInfo, - ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), - ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); + ACPI_FORMAT_UINT64 ( + GpeBlock->RegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 ( + GpeBlock->RegisterInfo->EnableAddress.Address)); AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); @@ -884,14 +895,18 @@ AcpiDbDisplayGpes ( GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; AcpiOsPrintf ( - " Reg %u: (GPE %.2X-%.2X) RunEnable %2.2X WakeEnable %2.2X" + " Reg %u: (GPE %.2X-%.2X) " + "RunEnable %2.2X WakeEnable %2.2X" " Status %8.8X%8.8X Enable %8.8X%8.8X\n", i, GpeRegisterInfo->BaseGpeNumber, - GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), + GpeRegisterInfo->BaseGpeNumber + + (ACPI_GPE_REGISTER_WIDTH - 1), GpeRegisterInfo->EnableForRun, GpeRegisterInfo->EnableForWake, - ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), - ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); + ACPI_FORMAT_UINT64 ( + GpeRegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 ( + GpeRegisterInfo->EnableAddress.Address)); /* Now look at the individual GPEs in this byte register */ @@ -959,7 +974,9 @@ AcpiDbDisplayGpes ( Count++; Notify = Notify->Next; } - AcpiOsPrintf ("Implicit Notify on %u devices", Count); + + AcpiOsPrintf ("Implicit Notify on %u devices", + Count); break; case ACPI_GPE_DISPATCH_RAW_HANDLER: @@ -977,9 +994,11 @@ AcpiDbDisplayGpes ( AcpiOsPrintf (")\n"); } } + Block++; GpeBlock = GpeBlock->Next; } + GpeXruptInfo = GpeXruptInfo->Next; } } @@ -1018,23 +1037,21 @@ AcpiDbDisplayHandlers ( for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++) { SpaceId = AcpiGbl_SpaceIdList[i]; - HandlerObj = ObjDesc->Device.Handler; AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId); - while (HandlerObj) + HandlerObj = AcpiEvFindRegionHandler ( + SpaceId, ObjDesc->CommonNotify.Handler); + if (HandlerObj) { - if (AcpiGbl_SpaceIdList[i] == HandlerObj->AddressSpace.SpaceId) - { - AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, - (HandlerObj->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", - HandlerObj->AddressSpace.Handler); - goto FoundHandler; - } + AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, + (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? + "Default" : "User", + HandlerObj->AddressSpace.Handler); - HandlerObj = HandlerObj->AddressSpace.Next; + goto FoundHandler; } /* There is no handler for this SpaceId */ @@ -1046,7 +1063,7 @@ AcpiDbDisplayHandlers ( /* Find all handlers for user-defined SpaceIDs */ - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; while (HandlerObj) { if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN) @@ -1055,7 +1072,8 @@ AcpiDbDisplayHandlers ( "User-defined ID", HandlerObj->AddressSpace.SpaceId); AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, (HandlerObj->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? + "Default" : "User", HandlerObj->AddressSpace.Handler); } @@ -1091,7 +1109,9 @@ AcpiDbDisplayHandlers ( for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++) { - AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name); + AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, + AcpiGbl_HandlerList[i].Name); + if (AcpiGbl_HandlerList[i].Handler) { AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", @@ -1109,8 +1129,8 @@ AcpiDbDisplayHandlers ( AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n"); (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, - NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, + NULL, NULL, NULL); } @@ -1146,7 +1166,7 @@ AcpiDbDisplayNonRootHandlers ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -1154,7 +1174,7 @@ AcpiDbDisplayNonRootHandlers ( /* Display all handlers associated with this device */ - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; while (HandlerObj) { AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, @@ -1174,5 +1194,3 @@ AcpiDbDisplayNonRootHandlers ( ACPI_FREE (Pathname); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbexec.c b/sys/contrib/dev/acpica/components/debugger/dbexec.c index 79c0ee9..00890e6 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/components/debugger/dbexec.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,6 @@ #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/acnamesp.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbexec") @@ -213,7 +212,8 @@ AcpiDbExecuteMethod ( if (Status == AE_BUFFER_OVERFLOW) { ACPI_ERROR ((AE_INFO, - "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", + "Possible overflow of internal debugger " + "buffer (size 0x%X needed 0x%X)", ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length)); } } @@ -380,10 +380,11 @@ AcpiDbExecutionWalk ( Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); - AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", AcpiUtGetNodeName (Node), - AcpiFormatException (Status)); - AcpiGbl_MethodExecuting = FALSE; + AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", + AcpiUtGetNodeName (Node), + AcpiFormatException (Status)); + AcpiGbl_MethodExecuting = FALSE; return (AE_OK); } @@ -394,6 +395,7 @@ AcpiDbExecutionWalk ( * * PARAMETERS: Name - Name of method to execute * Args - Parameters to the method + * Types - * Flags - single step/no single step * * RETURN: None @@ -414,12 +416,23 @@ AcpiDbExecute ( ACPI_BUFFER ReturnObj; char *NameString; - #ifdef ACPI_DEBUG_OUTPUT UINT32 PreviousAllocations; UINT32 Allocations; +#endif + /* + * Allow one execution to be performed by debugger or single step + * execution will be dead locked by the interpreter mutexes. + */ + if (AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("Only one debugger execution is allowed.\n"); + return; + } + +#ifdef ACPI_DEBUG_OUTPUT /* Memory allocation tracking */ PreviousAllocations = AcpiDbGetOutstandingAllocations (); @@ -428,20 +441,20 @@ AcpiDbExecute ( if (*Name == '*') { (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); return; } else { - NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); + NameString = ACPI_ALLOCATE (strlen (Name) + 1); if (!NameString) { return; } - ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); - ACPI_STRCPY (NameString, Name); + strcpy (NameString, Name); AcpiUtStrupr (NameString); AcpiGbl_DbMethodInfo.Name = NameString; AcpiGbl_DbMethodInfo.Args = Args; @@ -464,7 +477,8 @@ AcpiDbExecute ( &AcpiGbl_DbMethodInfo.Method); if (ACPI_SUCCESS (Status)) { - Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); + Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, + &ReturnObj); } ACPI_FREE (NameString); } @@ -485,15 +499,17 @@ AcpiDbExecute ( if (Allocations > 0) { - AcpiOsPrintf ("0x%X Outstanding allocations after evaluation of %s\n", - Allocations, AcpiGbl_DbMethodInfo.Pathname); + AcpiOsPrintf ( + "0x%X Outstanding allocations after evaluation of %s\n", + Allocations, AcpiGbl_DbMethodInfo.Pathname); } #endif if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Evaluation of %s failed with status %s\n", - AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); + AcpiGbl_DbMethodInfo.Pathname, + AcpiFormatException (Status)); } else { @@ -502,15 +518,18 @@ AcpiDbExecute ( if (ReturnObj.Length) { AcpiOsPrintf ( - "Evaluation of %s returned object %p, external buffer length %X\n", + "Evaluation of %s returned object %p, " + "external buffer length %X\n", AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); + AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); /* Dump a _PLD buffer if present */ if (ACPI_COMPARE_NAME ((ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - AcpiGbl_DbMethodInfo.Method)->Name.Ascii), METHOD_NAME__PLD)) + AcpiGbl_DbMethodInfo.Method)->Name.Ascii), + METHOD_NAME__PLD)) { AcpiDbDumpPldBuffer (ReturnObj.Pointer); } @@ -563,8 +582,10 @@ AcpiDbMethodThread ( if (Info->InitArgs) { - AcpiDbUint32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); - AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); + AcpiDbUint32ToHexString (Info->NumCreated, + Info->IndexOfThreadStr); + AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), + Info->IdOfThreadStr); } if (Info->Threads && (Info->NumCreated < Info->NumThreads)) @@ -599,13 +620,15 @@ AcpiDbMethodThread ( #if 0 if ((i % 100) == 0) { - AcpiOsPrintf ("%u loops, Thread 0x%x\n", i, AcpiOsGetThreadId ()); + AcpiOsPrintf ("%u loops, Thread 0x%x\n", + i, AcpiOsGetThreadId ()); } if (ReturnObj.Length) { AcpiOsPrintf ("Evaluation of %s returned object %p Buflen %X\n", - Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); + Info->Pathname, ReturnObj.Pointer, + (UINT32) ReturnObj.Length); AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); } #endif @@ -614,7 +637,8 @@ AcpiDbMethodThread ( /* Signal our completion */ Allow = 0; - (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); + (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, + 1, ACPI_WAIT_FOREVER); Info->NumCompleted++; if (Info->NumCompleted == Info->NumThreads) @@ -630,7 +654,8 @@ AcpiDbMethodThread ( Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", + AcpiOsPrintf ( + "Could not signal debugger thread sync semaphore, %s\n", AcpiFormatException (Status)); } } @@ -669,8 +694,8 @@ AcpiDbCreateExecutionThreads ( /* Get the arguments */ - NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); - NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); + NumThreads = strtoul (NumThreadsArg, NULL, 0); + NumLoops = strtoul (NumLoopsArg, NULL, 0); if (!NumThreads || !NumLoops) { @@ -686,7 +711,8 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization with the main thread, %s\n", AcpiFormatException (Status)); return; } @@ -698,8 +724,10 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization between the created threads, %s\n", AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (MainThreadGate); return; } @@ -707,19 +735,22 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization of AcpiGbl_DbMethodInfo, %s\n", AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); (void) AcpiOsDeleteSemaphore (MainThreadGate); return; } - ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); /* Array to store IDs of threads */ AcpiGbl_DbMethodInfo.NumThreads = NumThreads; Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads; + AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size); if (AcpiGbl_DbMethodInfo.Threads == NULL) { @@ -729,7 +760,7 @@ AcpiDbCreateExecutionThreads ( (void) AcpiOsDeleteSemaphore (InfoGate); return; } - ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); + memset (AcpiGbl_DbMethodInfo.Threads, 0, Size); /* Setup the context to be passed to each thread */ @@ -780,7 +811,7 @@ AcpiDbCreateExecutionThreads ( for (i = 0; i < (NumThreads); i++) { - Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, + Status = AcpiOsExecute (OSL_DEBUGGER_EXEC_THREAD, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); if (ACPI_FAILURE (Status)) { @@ -807,5 +838,3 @@ CleanupAndExit: AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); AcpiGbl_DbMethodInfo.Threads = NULL; } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c index 59a9a52..38f3678 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,14 +46,16 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/actables.h> - -#if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) +#include <stdio.h> +#ifdef ACPI_APPLICATION +#include <contrib/dev/acpica/include/acapps.h> +#endif #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") -#ifdef ACPI_DEBUGGER +#ifdef ACPI_DEBUGGER /******************************************************************************* * * FUNCTION: AcpiDbCloseDebugFile @@ -78,7 +80,8 @@ AcpiDbCloseDebugFile ( fclose (AcpiGbl_DebugFile); AcpiGbl_DebugFile = NULL; AcpiGbl_DbOutputToFile = FALSE; - AcpiOsPrintf ("Debug output file %s closed\n", AcpiGbl_DbDebugFilename); + AcpiOsPrintf ("Debug output file %s closed\n", + AcpiGbl_DbDebugFilename); } #endif } @@ -112,7 +115,7 @@ AcpiDbOpenDebugFile ( } AcpiOsPrintf ("Debug output file %s opened\n", Name); - ACPI_STRNCPY (AcpiGbl_DbDebugFilename, Name, + strncpy (AcpiGbl_DbDebugFilename, Name, sizeof (AcpiGbl_DbDebugFilename)); AcpiGbl_DbOutputToFile = TRUE; @@ -121,134 +124,35 @@ AcpiDbOpenDebugFile ( #endif -#ifdef ACPI_APPLICATION -#include <contrib/dev/acpica/include/acapps.h> - -/******************************************************************************* - * - * FUNCTION: AeLocalLoadTable - * - * PARAMETERS: Table - pointer to a buffer containing the entire - * table to be loaded - * - * RETURN: Status - * - * DESCRIPTION: This function is called to load a table from the caller's - * buffer. The buffer must contain an entire ACPI Table including - * a valid header. The header fields will be verified, and if it - * is determined that the table is invalid, the call will fail. - * - ******************************************************************************/ - -static ACPI_STATUS -AeLocalLoadTable ( - ACPI_TABLE_HEADER *Table) -{ - ACPI_STATUS Status = AE_OK; -/* ACPI_TABLE_DESC TableInfo; */ - - - ACPI_FUNCTION_TRACE (AeLocalLoadTable); -#if 0 - - - if (!Table) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - TableInfo.Pointer = Table; - Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Install the new table into the local data structures */ - - Status = AcpiTbInitTableDescriptor (&TableInfo); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* Table already exists, no error */ - - Status = AE_OK; - } - - /* Free table allocated by AcpiTbGetTable */ - - AcpiTbDeleteSingleTable (&TableInfo); - return_ACPI_STATUS (Status); - } - -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) - - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - /* Uninstall table and free the buffer */ - - AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT); - return_ACPI_STATUS (Status); - } -#endif -#endif - - return_ACPI_STATUS (Status); -} -#endif - - /******************************************************************************* * - * FUNCTION: AcpiDbGetTableFromFile + * FUNCTION: AcpiDbLoadTables * - * PARAMETERS: Filename - File where table is located - * ReturnTable - Where a pointer to the table is returned + * PARAMETERS: ListHead - List of ACPI tables to load * * RETURN: Status * - * DESCRIPTION: Load an ACPI table from a file + * DESCRIPTION: Load ACPI tables from a previously constructed table list. * ******************************************************************************/ ACPI_STATUS -AcpiDbGetTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **ReturnTable, - BOOLEAN MustBeAmlFile) +AcpiDbLoadTables ( + ACPI_NEW_TABLE_DESC *ListHead) { -#ifdef ACPI_APPLICATION ACPI_STATUS Status; + ACPI_NEW_TABLE_DESC *TableListHead; ACPI_TABLE_HEADER *Table; - BOOLEAN IsAmlTable = TRUE; - Status = AcpiUtReadTableFromFile (Filename, &Table); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* Load all ACPI tables in the list */ - if (MustBeAmlFile) + TableListHead = ListHead; + while (TableListHead) { - IsAmlTable = AcpiUtIsAmlTable (Table); - if (!IsAmlTable) - { - ACPI_EXCEPTION ((AE_INFO, AE_OK, - "Input for -e is not an AML table: " - "\"%4.4s\" (must be DSDT/SSDT)", - Table->Signature)); - return (AE_TYPE); - } - } + Table = TableListHead->Table; - if (IsAmlTable) - { - /* Attempt to recognize and install the table */ - - Status = AeLocalLoadTable (Table); + Status = AcpiLoadTable (Table); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -265,22 +169,12 @@ AcpiDbGetTableFromFile ( return (Status); } - AcpiTbPrintTableHeader (0, Table); - fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); - } - AcpiGbl_AcpiHardwarePresent = FALSE; - if (ReturnTable) - { - *ReturnTable = Table; + TableListHead = TableListHead->Next; } - -#endif /* ACPI_APPLICATION */ return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/components/debugger/dbhistry.c index e945779..b55f108 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica/components/debugger/dbhistry.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbhistry") @@ -92,7 +91,7 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ - CmdLen = (UINT16) ACPI_STRLEN (CommandLine); + CmdLen = (UINT16) strlen (CommandLine); if (!CmdLen) { return; @@ -100,8 +99,9 @@ AcpiDbAddToHistory ( if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL) { - BufferLen = (UINT16) ACPI_STRLEN ( + BufferLen = (UINT16) strlen ( AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command); + if (CmdLen > BufferLen) { AcpiOsFree (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex]. @@ -116,7 +116,7 @@ AcpiDbAddToHistory ( AcpiOsAllocate (CmdLen + 1); } - ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, + strcpy (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine); AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = @@ -217,7 +217,7 @@ AcpiDbGetFromHistory ( else { - CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); + CmdNum = strtoul (CommandNumArg, NULL, 0); } return (AcpiDbGetHistoryByIndex (CmdNum)); @@ -269,5 +269,3 @@ AcpiDbGetHistoryByIndex ( AcpiOsPrintf ("Invalid history number: %u\n", HistoryIndex); return (NULL); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c index 623bc48..a52ee4d 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,12 +45,14 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> - -#ifdef ACPI_DEBUGGER +#ifdef ACPI_APPLICATION +#include <contrib/dev/acpica/include/acapps.h> +#endif #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbinput") + /* Local prototypes */ static UINT32 @@ -67,7 +69,7 @@ AcpiDbSingleThread ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll); static void @@ -76,7 +78,7 @@ AcpiDbDisplayHelp ( static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help); @@ -95,20 +97,15 @@ enum AcpiExDebuggerCommands CMD_BREAKPOINT, CMD_BUSINFO, CMD_CALL, - CMD_CLOSE, CMD_DEBUG, CMD_DISASSEMBLE, CMD_DISASM, CMD_DUMP, - CMD_ENABLEACPI, CMD_EVALUATE, - CMD_EVENT, CMD_EXECUTE, CMD_EXIT, CMD_FIND, CMD_GO, - CMD_GPE, - CMD_GPES, CMD_HANDLERS, CMD_HELP, CMD_HELP2, @@ -120,14 +117,12 @@ enum AcpiExDebuggerCommands CMD_INTO, CMD_LEVEL, CMD_LIST, - CMD_LOAD, CMD_LOCALS, CMD_LOCKS, CMD_METHODS, CMD_NAMESPACE, CMD_NOTIFY, CMD_OBJECTS, - CMD_OPEN, CMD_OSI, CMD_OWNER, CMD_PATHS, @@ -137,20 +132,32 @@ enum AcpiExDebuggerCommands CMD_REFERENCES, CMD_RESOURCES, CMD_RESULTS, - CMD_SCI, CMD_SET, - CMD_SLEEP, CMD_STATS, CMD_STOP, CMD_TABLES, CMD_TEMPLATE, - CMD_TERMINATE, - CMD_TEST, - CMD_THREADS, CMD_TRACE, CMD_TREE, CMD_TYPE, - CMD_UNLOAD +#ifdef ACPI_APPLICATION + CMD_ENABLEACPI, + CMD_EVENT, + CMD_GPE, + CMD_GPES, + CMD_SCI, + CMD_SLEEP, + + CMD_CLOSE, + CMD_LOAD, + CMD_OPEN, + CMD_UNLOAD, + + CMD_TERMINATE, + CMD_THREADS, + + CMD_TEST, +#endif }; #define CMD_FIRST_VALID 2 @@ -168,20 +175,15 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"BREAKPOINT", 1}, {"BUSINFO", 0}, {"CALL", 0}, - {"CLOSE", 0}, {"DEBUG", 1}, {"DISASSEMBLE", 1}, {"DISASM", 1}, {"DUMP", 1}, - {"ENABLEACPI", 0}, {"EVALUATE", 1}, - {"EVENT", 1}, {"EXECUTE", 1}, {"EXIT", 0}, {"FIND", 1}, {"GO", 0}, - {"GPE", 1}, - {"GPES", 0}, {"HANDLERS", 0}, {"HELP", 0}, {"?", 0}, @@ -193,14 +195,12 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"INTO", 0}, {"LEVEL", 0}, {"LIST", 0}, - {"LOAD", 1}, {"LOCALS", 0}, {"LOCKS", 0}, {"METHODS", 0}, {"NAMESPACE", 0}, {"NOTIFY", 2}, - {"OBJECTS", 1}, - {"OPEN", 1}, + {"OBJECTS", 0}, {"OSI", 0}, {"OWNER", 1}, {"PATHS", 0}, @@ -210,20 +210,32 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"REFERENCES", 1}, {"RESOURCES", 0}, {"RESULTS", 0}, - {"SCI", 0}, {"SET", 3}, - {"SLEEP", 0}, {"STATS", 1}, {"STOP", 0}, {"TABLES", 0}, {"TEMPLATE", 1}, - {"TERMINATE", 0}, - {"TEST", 1}, - {"THREADS", 3}, {"TRACE", 1}, {"TREE", 0}, {"TYPE", 1}, +#ifdef ACPI_APPLICATION + {"ENABLEACPI", 0}, + {"EVENT", 1}, + {"GPE", 1}, + {"GPES", 0}, + {"SCI", 0}, + {"SLEEP", 0}, + + {"CLOSE", 0}, + {"LOAD", 1}, + {"OPEN", 1}, {"UNLOAD", 1}, + + {"TERMINATE", 0}, + {"THREADS", 3}, + + {"TEST", 1}, +#endif {NULL, 0} }; @@ -237,7 +249,6 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Allocations", "Display list of current memory allocations\n"}, {2, " Dump <Address>|<Namepath>", "\n"}, {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"}, - {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, {1, " Handlers", "Info about global handlers\n"}, {1, " Help [Command]", "This help screen or individual command\n"}, {1, " History", "Display command history buffer\n"}, @@ -254,7 +265,6 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Stack", "Display CPU stack usage\n"}, {1, " Tables", "Info about current ACPI table(s)\n"}, {1, " Tables", "Display info about loaded ACPI tables\n"}, - {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, {1, " ! <CommandNumber>", "Execute command from history buffer\n"}, {1, " !!", "Execute last command again\n"}, @@ -266,16 +276,15 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Methods", "Display list of loaded control methods\n"}, {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"}, {1, " Notify <Object> <Value>", "Send a notification on Object\n"}, - {1, " Objects <ObjectType>", "Display all objects of the given type\n"}, + {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"}, {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"}, {1, " Paths", "Display full pathnames of namespace objects\n"}, {1, " Predefined", "Check all predefined names\n"}, - {1, " Prefix [<NamePath>]", "Set or Get current execution prefix\n"}, + {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"}, {1, " References <Addr>", "Find all references to object at addr\n"}, {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"}, {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"}, {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"}, - {1, " Terminate", "Delete namespace and all internal objects\n"}, {1, " Type <Object>", "Display object type\n"}, {0, "\nControl Method Execution Commands:","\n"}, @@ -297,15 +306,20 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Results", "Display method result stack\n"}, {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"}, {1, " Stop", "Terminate control method\n"}, - {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, - {1, " Trace <method name>", "Trace method execution\n"}, + {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"}, + {1, " Enable", "Enable all messages\n"}, + {1, " Disable", "Disable tracing\n"}, + {1, " Method", "Enable method execution messages\n"}, + {1, " Opcode", "Enable opcode execution messages\n"}, {1, " Tree", "Display control method calling tree\n"}, {1, " <Enter>", "Single step next AML opcode (over calls)\n"}, - {0, "\nHardware Related Commands:", "\n"}, +#ifdef ACPI_APPLICATION + {0, "\nHardware Simulation Commands:", "\n"}, + {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"}, {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"}, - {1, " Gpes", "Display info on all GPEs\n"}, + {1, " Gpes", "Display info on all GPE devices\n"}, {1, " Sci", "Generate an SCI\n"}, {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"}, @@ -313,11 +327,17 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Close", "Close debug output file\n"}, {1, " Load <Input Filename>", "Load ACPI table from a file\n"}, {1, " Open <Output Filename>", "Open a file for debug output\n"}, + {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, + + {0, "\nUser Space Commands:", "\n"}, + {1, " Terminate", "Delete namespace and all internal objects\n"}, + {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, {0, "\nDebug Test Commands:", "\n"}, {3, " Test <TestName>", "Invoke a debug test\n"}, {1, " Objects", "Read/write/compare all namespace data objects\n"}, {1, " Predefined", "Execute all ACPI predefined names (_STA, etc.)\n"}, +#endif {0, NULL, NULL} }; @@ -338,7 +358,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help) { char *Invocation = Help->Invocation; @@ -361,7 +381,7 @@ AcpiDbMatchCommandHelp ( while ((*Command) && (*Invocation) && (*Invocation != ' ')) { - if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation)) + if (tolower ((int) *Command) != tolower ((int) *Invocation)) { return (FALSE); } @@ -400,7 +420,7 @@ AcpiDbMatchCommandHelp ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll) { const ACPI_DB_COMMAND_HELP *Next; @@ -641,7 +661,8 @@ AcpiDbGetLine ( if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf), InputBuffer)) { - AcpiOsPrintf ("Buffer overflow while parsing input line (max %u characters)\n", + AcpiOsPrintf ( + "Buffer overflow while parsing input line (max %u characters)\n", sizeof (AcpiGbl_DbParsedBuf)); return (0); } @@ -661,10 +682,7 @@ AcpiDbGetLine ( /* Uppercase the actual command */ - if (AcpiGbl_DbArgs[0]) - { - AcpiUtStrupr (AcpiGbl_DbArgs[0]); - } + AcpiUtStrupr (AcpiGbl_DbArgs[0]); Count = i; if (Count) @@ -702,8 +720,9 @@ AcpiDbMatchCommand ( for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) { - if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == - AcpiGbl_DbCommands[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) == + AcpiGbl_DbCommands[i].Name) { return (i); } @@ -744,20 +763,27 @@ AcpiDbCommandDispatch ( /* If AcpiTerminate has been called, terminate this thread */ - if (AcpiGbl_DbTerminateThreads) + if (AcpiGbl_DbTerminateLoop) { return (AE_CTRL_TERMINATE); } - - /* Add all commands that come here to the history buffer */ - - AcpiDbAddToHistory (InputBuffer); + /* Find command and add to the history buffer */ ParamCount = AcpiDbGetLine (InputBuffer); CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); Temp = 0; + /* + * We don't want to add the !! command to the history buffer. It + * would cause an infinite loop because it would always be the + * previous command. + */ + if (CommandIndex != CMD_HISTORY_LAST) + { + AcpiDbAddToHistory (InputBuffer); + } + /* Verify that we have the minimum number of params */ if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) @@ -766,7 +792,8 @@ AcpiDbCommandDispatch ( ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); - AcpiDbDisplayCommandInfo (AcpiGbl_DbCommands[CommandIndex].Name, FALSE); + AcpiDbDisplayCommandInfo ( + AcpiGbl_DbCommands[CommandIndex].Name, FALSE); return (AE_CTRL_TRUE); } @@ -811,11 +838,6 @@ AcpiDbCommandDispatch ( Status = AE_OK; break; - case CMD_CLOSE: - - AcpiDbCloseDebugFile (); - break; - case CMD_DEBUG: AcpiDbExecute (AcpiGbl_DbArgs[1], @@ -833,23 +855,6 @@ AcpiDbCommandDispatch ( AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; - case CMD_ENABLEACPI: -#if (!ACPI_REDUCED_HARDWARE) - - Status = AcpiEnable(); - if (ACPI_FAILURE(Status)) - { - AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); - return (Status); - } -#endif /* !ACPI_REDUCED_HARDWARE */ - break; - - case CMD_EVENT: - - AcpiOsPrintf ("Event command not implemented\n"); - break; - case CMD_EVALUATE: case CMD_EXECUTE: @@ -867,16 +872,6 @@ AcpiDbCommandDispatch ( AcpiGbl_CmSingleStep = FALSE; return (AE_OK); - case CMD_GPE: - - AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); - break; - - case CMD_GPES: - - AcpiDbDisplayGpes (); - break; - case CMD_HANDLERS: AcpiDbDisplayHandlers (); @@ -938,16 +933,18 @@ AcpiDbCommandDispatch ( if (ParamCount == 0) { - AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", + AcpiOsPrintf ( + "Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); - AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", + AcpiOsPrintf ( + "Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); } else if (ParamCount == 2) { Temp = AcpiGbl_DbConsoleDebugLevel; - AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], - NULL, 16); + AcpiGbl_DbConsoleDebugLevel = + strtoul (AcpiGbl_DbArgs[1], NULL, 16); AcpiOsPrintf ( "Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); @@ -955,7 +952,7 @@ AcpiDbCommandDispatch ( else { Temp = AcpiGbl_DbDebugLevel; - AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); + AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16); AcpiOsPrintf ( "Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); @@ -967,11 +964,6 @@ AcpiDbCommandDispatch ( AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); break; - case CMD_LOAD: - - Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL, FALSE); - break; - case CMD_LOCKS: AcpiDbDisplayLocks (); @@ -994,7 +986,7 @@ AcpiDbCommandDispatch ( case CMD_NOTIFY: - Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); + Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0); AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); break; @@ -1004,11 +996,6 @@ AcpiDbCommandDispatch ( Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; - case CMD_OPEN: - - AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); - break; - case CMD_OSI: AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); @@ -1024,11 +1011,6 @@ AcpiDbCommandDispatch ( AcpiDbDumpNamespacePaths (); break; - case CMD_PREDEFINED: - - AcpiDbCheckPredefinedNames (); - break; - case CMD_PREFIX: AcpiDbSetScope (AcpiGbl_DbArgs[1]); @@ -1049,22 +1031,12 @@ AcpiDbCommandDispatch ( AcpiDbDisplayResults (); break; - case CMD_SCI: - - AcpiDbGenerateSci (); - break; - case CMD_SET: AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); break; - case CMD_SLEEP: - - Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); - break; - case CMD_STATS: Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); @@ -1084,6 +1056,89 @@ AcpiDbCommandDispatch ( AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]); break; + case CMD_TRACE: + + AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + break; + + case CMD_TREE: + + AcpiDbDisplayCallingTree (); + break; + + case CMD_TYPE: + + AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); + break; + +#ifdef ACPI_APPLICATION + + /* Hardware simulation commands. */ + + case CMD_ENABLEACPI: +#if (!ACPI_REDUCED_HARDWARE) + + Status = AcpiEnable(); + if (ACPI_FAILURE(Status)) + { + AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); + return (Status); + } +#endif /* !ACPI_REDUCED_HARDWARE */ + break; + + case CMD_EVENT: + + AcpiOsPrintf ("Event command not implemented\n"); + break; + + case CMD_GPE: + + AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); + break; + + case CMD_GPES: + + AcpiDbDisplayGpes (); + break; + + case CMD_SCI: + + AcpiDbGenerateSci (); + break; + + case CMD_SLEEP: + + Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); + break; + + /* File I/O commands. */ + + case CMD_CLOSE: + + AcpiDbCloseDebugFile (); + break; + + case CMD_LOAD: + { + ACPI_NEW_TABLE_DESC *ListHead = NULL; + + Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1], + ACPI_GET_ALL_TABLES, &ListHead); + if (ACPI_SUCCESS (Status)) + { + AcpiDbLoadTables (ListHead); + } + } + break; + + case CMD_OPEN: + + AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); + break; + + /* User space commands. */ + case CMD_TERMINATE: AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); @@ -1094,39 +1149,33 @@ AcpiDbCommandDispatch ( * re-creating the semaphores! */ + AcpiGbl_DbTerminateLoop = TRUE; /* AcpiInitialize (NULL); */ break; - case CMD_TEST: - - AcpiDbExecuteTest (AcpiGbl_DbArgs[1]); - break; - case CMD_THREADS: AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); break; - case CMD_TRACE: - - (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); - break; + /* Debug test commands. */ - case CMD_TREE: + case CMD_PREDEFINED: - AcpiDbDisplayCallingTree (); + AcpiDbCheckPredefinedNames (); break; - case CMD_TYPE: + case CMD_TEST: - AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); + AcpiDbExecuteTest (AcpiGbl_DbArgs[1]); break; case CMD_UNLOAD: AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]); break; +#endif case CMD_EXIT: case CMD_QUIT: @@ -1142,8 +1191,10 @@ AcpiDbCommandDispatch ( AcpiDbgLevel = ACPI_DEBUG_DEFAULT; } +#ifdef ACPI_APPLICATION AcpiDbCloseDebugFile (); - AcpiGbl_DbTerminateThreads = TRUE; +#endif + AcpiGbl_DbTerminateLoop = TRUE; return (AE_CTRL_TERMINATE); case CMD_NOT_FOUND: @@ -1183,12 +1234,13 @@ AcpiDbExecuteThread ( ACPI_STATUS MStatus; - while (Status != AE_CTRL_TERMINATE) + while (Status != AE_CTRL_TERMINATE && !AcpiGbl_DbTerminateLoop) { AcpiGbl_MethodExecuting = FALSE; AcpiGbl_StepToNextCall = FALSE; - MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + MStatus = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (MStatus)) { return; @@ -1196,12 +1248,9 @@ AcpiDbExecuteThread ( Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); - MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); - if (ACPI_FAILURE (MStatus)) - { - return; - } + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); } + AcpiGbl_DbThreadsTerminated = TRUE; } @@ -1256,7 +1305,7 @@ AcpiDbUserCommands ( /* TBD: [Restructure] Need a separate command line buffer for step mode */ - while (!AcpiGbl_DbTerminateThreads) + while (!AcpiGbl_DbTerminateLoop) { /* Force output to console until a command is entered */ @@ -1291,13 +1340,10 @@ AcpiDbUserCommands ( * Signal the debug thread that we have a command to execute, * and wait for the command to complete. */ - Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return (Status); @@ -1311,12 +1357,5 @@ AcpiDbUserCommands ( } } - /* - * Only this thread (the original thread) should actually terminate the - * subsystem, because all the semaphores are deleted during termination - */ - Status = AcpiTerminate (); return (Status); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/components/debugger/dbmethod.c index 5224854..2d047f5 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbmethod.c +++ b/sys/contrib/dev/acpica/components/debugger/dbmethod.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,13 +46,10 @@ #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbmethod") @@ -79,6 +76,7 @@ AcpiDbSetMethodBreakpoint ( ACPI_PARSE_OBJECT *Op) { UINT32 Address; + UINT32 AmlOffset; if (!Op) @@ -89,11 +87,13 @@ AcpiDbSetMethodBreakpoint ( /* Get and verify the breakpoint address */ - Address = ACPI_STRTOUL (Location, NULL, 16); - if (Address <= Op->Common.AmlOffset) + Address = strtoul (Location, NULL, 16); + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + WalkState->ParserState.AmlStart); + if (Address <= AmlOffset) { AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", - Address, Op->Common.AmlOffset); + Address, AmlOffset); } /* Save breakpoint in current walk */ @@ -174,7 +174,7 @@ AcpiDbSetMethodData ( return; } - Value = ACPI_STRTOUL (ValueArg, NULL, 16); + Value = strtoul (ValueArg, NULL, 16); if (Type == 'N') { @@ -196,7 +196,7 @@ AcpiDbSetMethodData ( /* Get the index and value */ - Index = ACPI_STRTOUL (IndexArg, NULL, 16); + Index = strtoul (IndexArg, NULL, 16); WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) @@ -224,12 +224,13 @@ AcpiDbSetMethodData ( if (Index > ACPI_METHOD_MAX_ARG) { - AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); + AcpiOsPrintf ("Arg%u - Invalid argument name\n", + Index); goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, - WalkState); + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, + Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -238,7 +239,7 @@ AcpiDbSetMethodData ( ObjDesc = WalkState->Arguments[Index].Object; AcpiOsPrintf ("Arg%u: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); break; case 'L': @@ -247,12 +248,13 @@ AcpiDbSetMethodData ( if (Index > ACPI_METHOD_MAX_LOCAL) { - AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); + AcpiOsPrintf ("Local%u - Invalid local variable name\n", + Index); goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, - WalkState); + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, + Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -261,7 +263,7 @@ AcpiDbSetMethodData ( ObjDesc = WalkState->LocalVariables[Index].Object; AcpiOsPrintf ("Local%u: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); break; default: @@ -304,7 +306,7 @@ AcpiDbDisassembleAml ( if (Statements) { - NumStatements = ACPI_STRTOUL (Statements, NULL, 0); + NumStatements = strtoul (Statements, NULL, 0); } #ifdef ACPI_DISASSEMBLER @@ -352,7 +354,7 @@ AcpiDbDisassembleMethod ( ObjDesc = Method->Object; - Op = AcpiPsCreateScopeOp (); + Op = AcpiPsCreateScopeOp (ObjDesc->Method.AmlStart); if (!Op) { return (AE_NO_MEMORY); @@ -392,15 +394,16 @@ AcpiDbDisassembleMethod ( WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); + +#ifdef ACPI_DISASSEMBLER (void) AcpiDmParseDeferredOps (Op); /* Now we can disassemble the method */ - AcpiGbl_DbOpt_Verbose = FALSE; -#ifdef ACPI_DISASSEMBLER + AcpiGbl_DmOpt_Verbose = FALSE; AcpiDmDisassemble (NULL, Op, 0); + AcpiGbl_DmOpt_Verbose = TRUE; #endif - AcpiGbl_DbOpt_Verbose = TRUE; AcpiPsDeleteParseTree (Op); @@ -411,5 +414,3 @@ AcpiDbDisassembleMethod ( AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbnames.c b/sys/contrib/dev/acpica/components/debugger/dbnames.c index d749b1d..f91bf97 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbnames.c +++ b/sys/contrib/dev/acpica/components/debugger/dbnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,8 +48,6 @@ #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbnames") @@ -78,6 +76,13 @@ AcpiDbWalkForSpecificObjects ( void **ReturnValue); static ACPI_STATUS +AcpiDbWalkForObjectCounts ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS AcpiDbIntegrityWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -125,7 +130,13 @@ static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] = {"BANKFIELDS"}, {"INDEXFIELDS"}, {"REFERENCES"}, - {"ALIAS"}, + {"ALIASES"}, + {"METHODALIASES"}, + {"NOTIFY"}, + {"ADDRESSHANDLER"}, + {"RESOURCE"}, + {"RESOURCEFIELD"}, + {"SCOPES"}, {NULL} /* Must be null terminated */ }; @@ -163,8 +174,8 @@ AcpiDbSetScope ( { /* Validate new scope from the root */ - Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -176,8 +187,8 @@ AcpiDbSetScope ( { /* Validate new scope relative to old scope */ - Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -194,7 +205,7 @@ AcpiDbSetScope ( } if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), - "\\")) + "\\")) { Status = AE_BUFFER_OVERFLOW; goto ErrorExit; @@ -248,7 +259,7 @@ AcpiDbDumpNamespace ( if (DepthArg) { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + MaxDepth = strtoul (DepthArg, NULL, 0); } } @@ -319,13 +330,13 @@ AcpiDbDumpNamespaceByOwner ( ACPI_OWNER_ID OwnerId; - OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); + OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0); /* Now we can check for the depth argument */ if (DepthArg) { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + MaxDepth = strtoul (DepthArg, NULL, 0); } AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); @@ -334,8 +345,8 @@ AcpiDbDumpNamespaceByOwner ( /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, - SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, + OwnerId, SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -374,7 +385,8 @@ AcpiDbWalkAndMatchName ( /* Wildcard support */ if ((RequestedName[i] != '?') && - (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) + (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) + ObjHandle)->Name.Ascii[i])) { /* No match, just exit */ @@ -385,10 +397,11 @@ AcpiDbWalkAndMatchName ( /* Get the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + AcpiOsPrintf ("Could Not get pathname for object %p\n", + ObjHandle); } else { @@ -426,7 +439,7 @@ AcpiDbFindNameInNamespace ( char *AcpiNamePtr = AcpiName; - if (ACPI_STRLEN (NameArg) > 4) + if (strlen (NameArg) > ACPI_NAME_SIZE) { AcpiOsPrintf ("Name must be no longer than 4 characters\n"); return (AE_OK); @@ -444,8 +457,8 @@ AcpiDbFindNameInNamespace ( /* Walk the namespace from the root */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); return (AE_OK); @@ -486,7 +499,7 @@ AcpiDbWalkForPredefinedNames ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -546,8 +559,9 @@ AcpiDbCheckPredefinedNames ( /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames, + NULL, (void *) &Count, NULL); AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); } @@ -555,6 +569,43 @@ AcpiDbCheckPredefinedNames ( /******************************************************************************* * + * FUNCTION: AcpiDbWalkForObjectCounts + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForObjectCounts ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + + if (Node->Type > ACPI_TYPE_NS_NODE_MAX) + { + AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n", + Node->Name.Ascii, Node->Type); + } + else + { + Info->Types[Node->Type]++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbWalkForSpecificObjects * * PARAMETERS: Callback from WalkNamespace @@ -582,7 +633,7 @@ AcpiDbWalkForSpecificObjects ( /* Get and display the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); @@ -619,7 +670,39 @@ AcpiDbDisplayObjects ( { ACPI_WALK_INFO Info; ACPI_OBJECT_TYPE Type; + ACPI_OBJECT_INFO *ObjectInfo; + UINT32 i; + UINT32 TotalObjects = 0; + + + /* No argument means display summary/count of all object types */ + if (!ObjTypeArg) + { + ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO)); + + /* Walk the namespace from the root */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL, + (void *) ObjectInfo, NULL); + + AcpiOsPrintf ("\nSummary of namespace objects:\n\n"); + + for (i = 0; i < ACPI_TOTAL_TYPES; i++) + { + AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i], + AcpiUtGetTypeName (i)); + + TotalObjects += ObjectInfo->Types[i]; + } + + AcpiOsPrintf ("\n%8u Total namespace objects\n\n", + TotalObjects); + + ACPI_FREE (ObjectInfo); + return (AE_OK); + } /* Get the object type */ @@ -645,7 +728,7 @@ AcpiDbDisplayObjects ( /* Walk the namespace from the root */ (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); + AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); AcpiOsPrintf ( "\nFound %u objects of type [%s] in the current ACPI Namespace\n", @@ -689,9 +772,11 @@ AcpiDbIntegrityWalk ( { if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n", - Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node), - ACPI_DESC_TYPE_NAMED); + AcpiOsPrintf ( + "Invalid Descriptor Type for Node %p [%s] - " + "is %2.2X should be %2.2X\n", + Node, AcpiUtGetDescriptorName (Node), + ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED); return (AE_OK); } @@ -713,7 +798,7 @@ AcpiDbIntegrityWalk ( return (AE_OK); } - if (!AcpiUtValidAcpiName (Node->Name.Ascii)) + if (!AcpiUtValidNameseg (Node->Name.Ascii)) { AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); return (AE_OK); @@ -754,8 +839,8 @@ AcpiDbCheckIntegrity ( /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", Info.Nodes, Info.Objects); @@ -830,13 +915,14 @@ AcpiDbFindReferences ( /* Convert string to object pointer */ - Address = ACPI_STRTOUL (ObjectArg, NULL, 16); + Address = strtoul (ObjectArg, NULL, 16); ObjDesc = ACPI_TO_POINTER (Address); /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL, + (void *) ObjDesc, NULL); } @@ -877,7 +963,7 @@ AcpiDbBusWalk ( /* Exit if there is no _PRT under this device */ Status = AcpiGetHandle (Node, METHOD_NAME__PRT, - ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); + ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); if (ACPI_FAILURE (Status)) { return (AE_OK); @@ -886,10 +972,11 @@ AcpiDbBusWalk ( /* Get the full path to this device object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + AcpiOsPrintf ("Could Not get pathname for object %p\n", + ObjHandle); return (AE_OK); } @@ -918,7 +1005,8 @@ AcpiDbBusWalk ( if (Info->Valid & ACPI_VALID_ADR) { - AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); + AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Info->Address)); } else { @@ -979,8 +1067,6 @@ AcpiDbGetBusInfo ( { /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbBusWalk, NULL, NULL, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbobject.c b/sys/contrib/dev/acpica/components/debugger/dbobject.c new file mode 100644 index 0000000..062ad25 --- /dev/null +++ b/sys/contrib/dev/acpica/components/debugger/dbobject.c @@ -0,0 +1,580 @@ +/******************************************************************************* + * + * Module Name: dbobject - ACPI object decode and display + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/acdebug.h> + + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("dbobject") + + +/* Local prototypes */ + +static void +AcpiDbDecodeNode ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpMethodInfo + * + * PARAMETERS: Status - Method execution status + * WalkState - Current state of the parse tree walk + * + * RETURN: None + * + * DESCRIPTION: Called when a method has been aborted because of an error. + * Dumps the method execution stack, and the method locals/args, + * and disassembles the AML opcode that failed. + * + ******************************************************************************/ + +void +AcpiDbDumpMethodInfo ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState) +{ + ACPI_THREAD_STATE *Thread; + + + /* Ignore control codes, they are not errors */ + + if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL) + { + return; + } + + /* We may be executing a deferred opcode */ + + if (WalkState->DeferredNode) + { + AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); + return; + } + + /* + * If there is no Thread, we are not actually executing a method. + * This can happen when the iASL compiler calls the interpreter + * to perform constant folding. + */ + Thread = WalkState->Thread; + if (!Thread) + { + return; + } + + /* Display the method locals and arguments */ + + AcpiOsPrintf ("\n"); + AcpiDbDecodeLocals (WalkState); + AcpiOsPrintf ("\n"); + AcpiDbDecodeArguments (WalkState); + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers. + * + ******************************************************************************/ + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 i; + + + if (!ObjDesc) + { + AcpiOsPrintf (" Uninitialized"); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf (" %p [%s]", ObjDesc, + AcpiUtGetDescriptorName (ObjDesc)); + return; + } + + AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc)); + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf (" %8.8X%8.8X", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("(%u) \"%.60s", + ObjDesc->String.Length, ObjDesc->String.Pointer); + + if (ObjDesc->String.Length > 60) + { + AcpiOsPrintf ("..."); + } + else + { + AcpiOsPrintf ("\""); + } + break; + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length); + for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++) + { + AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]); + } + break; + + default: + + AcpiOsPrintf (" %p", ObjDesc); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeNode + * + * PARAMETERS: Node - Object to be displayed + * + * RETURN: None + * + * DESCRIPTION: Short display of a namespace node + * + ******************************************************************************/ + +static void +AcpiDbDecodeNode ( + ACPI_NAMESPACE_NODE *Node) +{ + + AcpiOsPrintf ("<Node> Name %4.4s", + AcpiUtGetNodeName (Node)); + + if (Node->Flags & ANOBJ_METHOD_ARG) + { + AcpiOsPrintf (" [Method Arg]"); + } + if (Node->Flags & ANOBJ_METHOD_LOCAL) + { + AcpiOsPrintf (" [Method Local]"); + } + + switch (Node->Type) + { + /* These types have no attached object */ + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf (" Device"); + break; + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf (" Thermal Zone"); + break; + + default: + + AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node)); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object + * + ******************************************************************************/ + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + UINT8 Type; + + + AcpiOsPrintf ("%p ", ObjDesc); + + if (!ObjDesc) + { + AcpiOsPrintf ("<Null Object>\n"); + return; + } + + /* Decode the object type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_PARSER: + + AcpiOsPrintf ("<Parser> "); + break; + + case ACPI_DESC_TYPE_NAMED: + + AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc); + break; + + case ACPI_DESC_TYPE_OPERAND: + + Type = ObjDesc->Common.Type; + if (Type > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type); + return; + } + + /* Decode the ACPI object type */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc)); + + /* Decode the refererence */ + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + + AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); + if (WalkState) + { + ObjDesc = WalkState->LocalVariables + [ObjDesc->Reference.Value].Object; + AcpiOsPrintf ("%p", ObjDesc); + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case ACPI_REFCLASS_ARG: + + AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); + if (WalkState) + { + ObjDesc = WalkState->Arguments + [ObjDesc->Reference.Value].Object; + AcpiOsPrintf ("%p", ObjDesc); + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case ACPI_REFCLASS_INDEX: + + switch (ObjDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + AcpiOsPrintf ("%p", ObjDesc->Reference.Object); + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); + break; + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("%p", ObjDesc->Reference.Where); + if (!ObjDesc->Reference.Where) + { + AcpiOsPrintf (" Uninitialized WHERE pointer"); + } + else + { + AcpiDbDecodeInternalObject ( + *(ObjDesc->Reference.Where)); + } + break; + + default: + + AcpiOsPrintf ("Unknown index target type"); + break; + } + break; + + case ACPI_REFCLASS_REFOF: + + if (!ObjDesc->Reference.Object) + { + AcpiOsPrintf ( + "Uninitialized reference subobject pointer"); + break; + } + + /* Reference can be to a Node or an Operand object */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object)) + { + case ACPI_DESC_TYPE_NAMED: + + AcpiDbDecodeNode (ObjDesc->Reference.Object); + break; + + case ACPI_DESC_TYPE_OPERAND: + + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); + break; + + default: + break; + } + break; + + case ACPI_REFCLASS_NAME: + + AcpiDbDecodeNode (ObjDesc->Reference.Node); + break; + + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: + + AcpiOsPrintf ("\n"); + break; + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); + break; + } + break; + + default: + + AcpiOsPrintf ("<Obj> "); + AcpiDbDecodeInternalObject (ObjDesc); + break; + } + break; + + default: + + AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]", + AcpiUtGetDescriptorName (ObjDesc)); + break; + } + + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeLocals + * + * PARAMETERS: WalkState - State for current method + * + * RETURN: None + * + * DESCRIPTION: Display all locals for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDecodeLocals ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + BOOLEAN DisplayLocals = FALSE; + + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + + if (!Node) + { + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); + return; + } + + if (Node->Type != ACPI_TYPE_METHOD) + { + AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); + return; + } + + /* Are any locals actually set? */ + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + if (ObjDesc) + { + DisplayLocals = TRUE; + break; + } + } + + /* If any are set, only display the ones that are set */ + + if (DisplayLocals) + { + AcpiOsPrintf ("\nInitialized Local Variables for method [%4.4s]:\n", + AcpiUtGetNodeName (Node)); + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + if (ObjDesc) + { + AcpiOsPrintf (" Local%X: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } + } + } + else + { + AcpiOsPrintf ( + "No Local Variables are initialized for method [%4.4s]\n", + AcpiUtGetNodeName (Node)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeArguments + * + * PARAMETERS: WalkState - State for current method + * + * RETURN: None + * + * DESCRIPTION: Display all arguments for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDecodeArguments ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + BOOLEAN DisplayArgs = FALSE; + + + Node = WalkState->MethodNode; + ObjDesc = WalkState->MethodDesc; + + if (!Node) + { + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); + return; + } + + if (Node->Type != ACPI_TYPE_METHOD) + { + AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); + return; + } + + /* Are any arguments actually set? */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + if (ObjDesc) + { + DisplayArgs = TRUE; + break; + } + } + + /* If any are set, only display the ones that are set */ + + if (DisplayArgs) + { + AcpiOsPrintf ( + "Initialized Arguments for Method [%4.4s]: " + "(%X arguments defined for method invocation)\n", + AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount); + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + if (ObjDesc) + { + AcpiOsPrintf (" Arg%u: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } + } + } + else + { + AcpiOsPrintf ( + "No Arguments are initialized for method [%4.4s]\n", + AcpiUtGetNodeName (Node)); + } +} diff --git a/sys/contrib/dev/acpica/components/debugger/dbstats.c b/sys/contrib/dev/acpica/components/debugger/dbstats.c index ecedcf9..7b48ba0 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbstats.c +++ b/sys/contrib/dev/acpica/components/debugger/dbstats.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,11 +46,11 @@ #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/acnamesp.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbstats") + /* Local prototypes */ static void @@ -127,7 +127,8 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Depth MaxD Avail Size] %8.2X %8.2X %8.2X %8.2X\n", + " Cache: [Depth MaxD Avail Size] " + "%8.2X %8.2X %8.2X %8.2X\n", List->CurrentDepth, List->MaxDepth, List->MaxDepth - List->CurrentDepth, @@ -138,7 +139,8 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Requests Hits Misses ObjSize] %8.2X %8.2X %8.2X %8.2X\n", + " Cache: [Requests Hits Misses ObjSize] " + "%8.2X %8.2X %8.2X %8.2X\n", List->Requests, List->Hits, List->Requests - List->Hits, @@ -150,7 +152,8 @@ AcpiDbListInfo ( if (List->ObjectSize) { AcpiOsPrintf ( - " Mem: [Alloc Free Max CurSize Outstanding] %8.2X %8.2X %8.2X %8.2X %8.2X\n", + " Mem: [Alloc Free Max CurSize Outstanding] " + "%8.2X %8.2X %8.2X %8.2X %8.2X\n", List->TotalAllocated, List->TotalFreed, List->MaxOccupied, @@ -160,7 +163,8 @@ AcpiDbListInfo ( else { AcpiOsPrintf ( - " Mem: [Alloc Free Max CurSize Outstanding Total] %8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", + " Mem: [Alloc Free Max CurSize Outstanding Total] " + "%8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", List->TotalAllocated, List->TotalFreed, List->MaxOccupied, @@ -335,7 +339,7 @@ AcpiDbClassifyOneObject ( Op = AcpiPsGetDepthNext (Root, Op); SizeOfParseTree = (NumGrammarElements - NumMethodElements) * - (UINT32) sizeof (ACPI_PARSE_OBJECT); + (UINT32) sizeof (ACPI_PARSE_OBJECT); SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); @@ -374,7 +378,7 @@ AcpiDbCountNamespaceObjects ( } (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); + ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); } @@ -435,6 +439,7 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i), AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]); } + AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown", AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc); @@ -532,7 +537,8 @@ AcpiDbDisplayStatistics ( case CMD_STAT_STACK: #if defined(ACPI_DEBUG_OUTPUT) - Temp = (UINT32) ACPI_PTR_DIFF (AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); + Temp = (UINT32) ACPI_PTR_DIFF ( + AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n"); AcpiOsPrintf ("Entry Stack Pointer %p\n", AcpiGbl_EntryStackPointer); @@ -550,5 +556,3 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("\n"); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbtest.c b/sys/contrib/dev/acpica/components/debugger/dbtest.c index ab14984..6be75f2 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbtest.c +++ b/sys/contrib/dev/acpica/components/debugger/dbtest.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,6 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbtest") @@ -124,8 +123,8 @@ static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] = * used to read and write the various namespace objects. The point * is to force the AML interpreter do all of the work. */ -#define ACPI_DB_READ_METHOD "\\_T98" -#define ACPI_DB_WRITE_METHOD "\\_T99" +#define ACPI_DB_READ_METHOD "\\_T98" +#define ACPI_DB_WRITE_METHOD "\\_T99" static ACPI_HANDLE ReadHandle = NULL; static ACPI_HANDLE WriteHandle = NULL; @@ -283,7 +282,7 @@ AcpiDbTestAllObjects ( /* Walk the entire namespace, testing each supported named data object */ (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL); } @@ -646,7 +645,7 @@ AcpiDbTestBufferType ( * count is not an integral number of bytes. Zero out the * unused bits. */ - ACPI_MEMSET (Buffer, BUFFER_FILL_VALUE, ByteLength); + memset (Buffer, BUFFER_FILL_VALUE, ByteLength); ExtraBits = BitLength % 8; if (ExtraBits) { @@ -671,7 +670,7 @@ AcpiDbTestBufferType ( goto Exit; } - if (ACPI_MEMCMP (Temp2->Buffer.Pointer, Buffer, ByteLength)) + if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength)) { AcpiOsPrintf (" MISMATCH 2: New buffer value"); } @@ -695,7 +694,8 @@ AcpiDbTestBufferType ( goto Exit; } - if (ACPI_MEMCMP (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength)) + if (memcmp (Temp1->Buffer.Pointer, + Temp3->Buffer.Pointer, ByteLength)) { AcpiOsPrintf (" MISMATCH 3: While restoring original buffer"); } @@ -751,7 +751,7 @@ AcpiDbTestStringType ( /* Write a new value */ WriteValue.Type = ACPI_TYPE_STRING; - WriteValue.String.Length = ACPI_STRLEN (ValueToWrite); + WriteValue.String.Length = strlen (ValueToWrite); WriteValue.String.Pointer = ValueToWrite; Status = AcpiDbWriteToObject (Node, &WriteValue); @@ -768,7 +768,7 @@ AcpiDbTestStringType ( goto Exit; } - if (ACPI_STRCMP (Temp2->String.Pointer, ValueToWrite)) + if (strcmp (Temp2->String.Pointer, ValueToWrite)) { AcpiOsPrintf (" MISMATCH 2: %s, expecting %s", Temp2->String.Pointer, ValueToWrite); @@ -776,7 +776,7 @@ AcpiDbTestStringType ( /* Write back the original value */ - WriteValue.String.Length = ACPI_STRLEN (Temp1->String.Pointer); + WriteValue.String.Length = strlen (Temp1->String.Pointer); WriteValue.String.Pointer = Temp1->String.Pointer; Status = AcpiDbWriteToObject (Node, &WriteValue); @@ -793,7 +793,7 @@ AcpiDbTestStringType ( goto Exit; } - if (ACPI_STRCMP (Temp1->String.Pointer, Temp3->String.Pointer)) + if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer)) { AcpiOsPrintf (" MISMATCH 3: %s, expecting %s", Temp3->String.Pointer, Temp1->String.Pointer); @@ -847,7 +847,8 @@ AcpiDbReadFromObject ( ReturnObj.Length = ACPI_ALLOCATE_BUFFER; AcpiGbl_MethodExecuting = TRUE; - Status = AcpiEvaluateObject (ReadHandle, NULL, &ParamObjects, &ReturnObj); + Status = AcpiEvaluateObject (ReadHandle, NULL, + &ParamObjects, &ReturnObj); AcpiGbl_MethodExecuting = FALSE; if (ACPI_FAILURE (Status)) @@ -885,8 +886,8 @@ AcpiDbReadFromObject ( AcpiOsPrintf (" Unsupported return object type, %s", AcpiUtGetTypeName (RetValue->Type)); - AcpiOsFree (ReturnObj.Pointer); + AcpiOsFree (ReturnObj.Pointer); return (AE_TYPE); } @@ -926,7 +927,7 @@ AcpiDbWriteToObject ( /* Copy the incoming user parameter */ - ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT)); + memcpy (&Params[1], Value, sizeof (ACPI_OBJECT)); ParamObjects.Count = 2; ParamObjects.Pointer = Params; @@ -970,15 +971,17 @@ AcpiDbEvaluateAllPredefinedNames ( if (CountArg) { - Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0); + Info.MaxCount = strtoul (CountArg, NULL, 0); } /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbEvaluateOnePredefinedName, NULL, (void *) &Info, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbEvaluateOnePredefinedName, NULL, + (void *) &Info, NULL); - AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count); + AcpiOsPrintf ( + "Evaluated %u predefined names in the namespace\n", Info.Count); } @@ -1031,7 +1034,7 @@ AcpiDbEvaluateOnePredefinedName ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -1076,8 +1079,10 @@ AcpiDbEvaluateOnePredefinedName ( case ACPI_TYPE_STRING: - ThisParam->String.Pointer = "This is the default argument string"; - ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer); + ThisParam->String.Pointer = + "This is the default argument string"; + ThisParam->String.Length = + strlen (ThisParam->String.Pointer); break; case ACPI_TYPE_BUFFER: @@ -1116,7 +1121,8 @@ AcpiDbEvaluateOnePredefinedName ( Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); - AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); + AcpiOsPrintf ("%-32s returned %s\n", + Pathname, AcpiFormatException (Status)); AcpiGbl_MethodExecuting = FALSE; ACPI_FREE (Pathname); @@ -1134,5 +1140,3 @@ AcpiDbEvaluateOnePredefinedName ( return (Status); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbutils.c b/sys/contrib/dev/acpica/components/debugger/dbutils.c index 5db98e1..8e56c20 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/components/debugger/dbutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,14 +45,12 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbutils") + /* Local prototypes */ #ifdef ACPI_OBSOLETE_FUNCTIONS @@ -65,8 +63,6 @@ AcpiDbDumpBuffer ( UINT32 Address); #endif -static char *Converter = "0123456789ABCDEF"; - /******************************************************************************* * @@ -96,7 +92,9 @@ AcpiDbMatchArgument ( for (i = 0; Arguments[i].Name; i++) { - if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, Arguments[i].Name), + ACPI_CAST_PTR (char, UserArgument)) == Arguments[i].Name) { return (i); } @@ -128,7 +126,8 @@ AcpiDbSetOutputDestination ( AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; - if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile) + if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && + AcpiGbl_DbOutputToFile) { AcpiDbgLevel = AcpiGbl_DbDebugLevel; } @@ -181,7 +180,7 @@ AcpiDbDumpExternalObject ( case ACPI_TYPE_INTEGER: AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: @@ -200,8 +199,10 @@ AcpiDbDumpExternalObject ( { AcpiOsPrintf ("\n"); } - AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), - ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT); + + AcpiUtDebugDumpBuffer ( + ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT); } else { @@ -212,18 +213,19 @@ AcpiDbDumpExternalObject ( case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("[Package] Contains %u Elements:\n", - ObjDesc->Package.Count); + ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) { - AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1); + AcpiDbDumpExternalObject ( + &ObjDesc->Package.Elements[i], Level+1); } break; case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[Object Reference] = "); - AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); + AcpiDbDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; case ACPI_TYPE_PROCESSOR: @@ -336,12 +338,13 @@ AcpiDbLocalNsLookup ( * Lookup the name. * (Uses root node as the search starting point) */ - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not locate name: %s, %s\n", - Name, AcpiFormatException (Status)); + Name, AcpiFormatException (Status)); } ACPI_FREE (InternalPath); @@ -375,7 +378,7 @@ AcpiDbUint32ToHexString ( if (Value == 0) { - ACPI_STRCPY (Buffer, "0"); + strcpy (Buffer, "0"); return; } @@ -383,7 +386,7 @@ AcpiDbUint32ToHexString ( for (i = 7; i >= 0; i--) { - Buffer[i] = Converter [Value & 0x0F]; + Buffer[i] = AcpiGbl_UpperHexDigits [Value & 0x0F]; Value = Value >> 4; } } @@ -505,8 +508,6 @@ AcpiDbDumpBuffer ( AcpiDbgLevel |= ACPI_LV_TABLES; AcpiUtDebugDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, - ACPI_UINT32_MAX); + ACPI_UINT32_MAX); } #endif - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c index d72ee5e..2bcd47c 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,11 +45,8 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbxface") @@ -104,12 +101,10 @@ AcpiDbStartCommand ( { /* Handshake with the front-end that gets user command lines */ - Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); + + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return (Status); @@ -140,7 +135,8 @@ AcpiDbStartCommand ( ACPI_DB_LINE_BUFFER_SIZE, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing command line")); return (Status); } } @@ -156,6 +152,40 @@ AcpiDbStartCommand ( /******************************************************************************* * + * FUNCTION: AcpiDbSignalBreakPoint + * + * PARAMETERS: WalkState - Current walk + * + * RETURN: Status + * + * DESCRIPTION: Called for AML_BREAK_POINT_OP + * + ******************************************************************************/ + +void +AcpiDbSignalBreakPoint ( + ACPI_WALK_STATE *WalkState) +{ + +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return; + } +#endif + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + AcpiGbl_CmSingleStep = TRUE; + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbSingleStep * * PARAMETERS: WalkState - Current walk @@ -179,11 +209,19 @@ AcpiDbSingleStep ( UINT32 OriginalDebugLevel; ACPI_PARSE_OBJECT *DisplayOp; ACPI_PARSE_OBJECT *ParentOp; + UINT32 AmlOffset; ACPI_FUNCTION_ENTRY (); +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return (AE_OK); + } +#endif + /* Check the abort flag */ if (AcpiGbl_AbortMethod) @@ -192,15 +230,18 @@ AcpiDbSingleStep ( return (AE_ABORT_METHOD); } + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + WalkState->ParserState.AmlStart); + /* Check for single-step breakpoint */ if (WalkState->MethodBreakpoint && - (WalkState->MethodBreakpoint <= Op->Common.AmlOffset)) + (WalkState->MethodBreakpoint <= AmlOffset)) { /* Check if the breakpoint has been reached or passed */ /* Hit the breakpoint, resume single step, reset breakpoint */ - AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset); + AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -209,10 +250,10 @@ AcpiDbSingleStep ( /* Check for user breakpoint (Must be on exact Aml offset) */ else if (WalkState->UserBreakpoint && - (WalkState->UserBreakpoint == Op->Common.AmlOffset)) + (WalkState->UserBreakpoint == AmlOffset)) { AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", - Op->Common.AmlOffset); + AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -394,7 +435,7 @@ AcpiDbSingleStep ( /******************************************************************************* * - * FUNCTION: AcpiDbInitialize + * FUNCTION: AcpiInitializeDebugger * * PARAMETERS: None * @@ -405,13 +446,13 @@ AcpiDbSingleStep ( ******************************************************************************/ ACPI_STATUS -AcpiDbInitialize ( +AcpiInitializeDebugger ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (DbInitialize); + ACPI_FUNCTION_TRACE (AcpiInitializeDebugger); /* Init globals */ @@ -424,10 +465,6 @@ AcpiDbInitialize ( AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_DbOpt_Disasm = FALSE; -#ifdef ACPI_DISASSEMBLER - AcpiGbl_DbOpt_Verbose = TRUE; -#endif AcpiGbl_DbOpt_NoIniMethods = FALSE; AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); @@ -435,7 +472,7 @@ AcpiDbInitialize ( { return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); + memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); /* Initial scope is the root */ @@ -443,6 +480,10 @@ AcpiDbInitialize ( AcpiGbl_DbScopeBuf [1] = 0; AcpiGbl_DbScopeNode = AcpiGbl_RootNode; + /* Initialize user commands loop */ + + AcpiGbl_DbTerminateLoop = FALSE; + /* * If configured for multi-thread support, the debug executor runs in * a separate thread so that the front end can be in another address @@ -452,14 +493,16 @@ AcpiDbInitialize ( { /* These were created with one unit, grab it */ - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); return_ACPI_STATUS (Status); } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); @@ -468,28 +511,31 @@ AcpiDbInitialize ( /* Create the debug execution thread to execute commands */ - Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL); + AcpiGbl_DbThreadsTerminated = FALSE; + Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD, + AcpiDbExecuteThread, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not start debugger thread")); + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not start debugger thread")); + AcpiGbl_DbThreadsTerminated = TRUE; return_ACPI_STATUS (Status); } } - -#ifdef ACPI_DISASSEMBLER - if (!AcpiGbl_DbOpt_Verbose) + else { - AcpiGbl_DbOpt_Disasm = TRUE; + AcpiGbl_DbThreadId = AcpiOsGetThreadId (); } -#endif return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger) + /******************************************************************************* * - * FUNCTION: AcpiDbTerminate + * FUNCTION: AcpiTerminateDebugger * * PARAMETERS: None * @@ -500,10 +546,26 @@ AcpiDbInitialize ( ******************************************************************************/ void -AcpiDbTerminate ( +AcpiTerminateDebugger ( void) { + /* Terminate the AML Debugger */ + + AcpiGbl_DbTerminateLoop = TRUE; + + if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) + { + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); + + /* Wait the AML Debugger threads */ + + while (!AcpiGbl_DbThreadsTerminated) + { + AcpiOsSleep (100); + } + } + if (AcpiGbl_DbBuffer) { AcpiOsFree (AcpiGbl_DbBuffer); @@ -515,34 +577,26 @@ AcpiDbTerminate ( AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; } +ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger) + -#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * - * FUNCTION: AcpiDbMethodEnd + * FUNCTION: AcpiSetDebuggerThreadId * - * PARAMETERS: WalkState - Current walk + * PARAMETERS: ThreadId - Debugger thread ID * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Called at method termination + * DESCRIPTION: Set debugger thread ID * ******************************************************************************/ void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState) +AcpiSetDebuggerThreadId ( + ACPI_THREAD_ID ThreadId) { - - if (!AcpiGbl_CmSingleStep) - { - return; - } - - AcpiOsPrintf ("<Method Terminating>\n"); - - AcpiDbStartCommand (WalkState, NULL); + AcpiGbl_DbThreadId = ThreadId; } -#endif -#endif /* ACPI_DEBUGGER */ +ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId) |