void
AcpiDmDumpMethodInfo (
ACPI_STATUS Status,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
ACPI_THREAD_STATE *Thread;
ACPI_WALK_STATE *NextWalkState;
ACPI_NAMESPACE_NODE *PreviousMethod = NULL;
/* 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 exception and method name */
AcpiOsPrintf ("\n**** Exception %s during execution of method ",
AcpiFormatException (Status));
AcpiNsPrintNodePathname (WalkState->MethodNode, NULL);
/* Display stack of executing methods */
AcpiOsPrintf ("\n\nMethod Execution Stack:\n");
NextWalkState = Thread->WalkStateList;
/* Walk list of linked walk states */
while (NextWalkState)
{
AcpiOsPrintf (" Method [%4.4s] executing: ",
AcpiUtGetNodeName (NextWalkState->MethodNode));
/* First method is the currently executing method */
if (NextWalkState == WalkState)
{
if (Op)
{
/* Display currently executing ASL statement */
Next = Op->Common.Next;
Op->Common.Next = NULL;
AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX);
Op->Common.Next = Next;
}
}
else
{
/*
* This method has called another method
* NOTE: the method call parse subtree is already deleted at this
* point, so we cannot disassemble the method invocation.
*/
AcpiOsPrintf ("Call to method ");
AcpiNsPrintNodePathname (PreviousMethod, NULL);
}
PreviousMethod = NextWalkState->MethodNode;
NextWalkState = NextWalkState->Next;
AcpiOsPrintf ("\n");
}
/* Display the method locals and arguments */
AcpiOsPrintf ("\n");
AcpiDmDisplayLocals (WalkState);
AcpiOsPrintf ("\n");
AcpiDmDisplayArguments (WalkState);
AcpiOsPrintf ("\n");
}
void
AcpiDbExecute (
NATIVE_CHAR *Name,
NATIVE_CHAR **Args,
UINT32 Flags)
{
ACPI_STATUS Status;
ACPI_BUFFER ReturnObj;
#ifdef ACPI_DEBUG
UINT32 PreviousAllocations;
UINT32 Allocations;
/* Memory allocation tracking */
PreviousAllocations = AcpiDbGetOutstandingAllocations ();
#endif
AcpiGbl_DbMethodInfo.Name = Name;
AcpiGbl_DbMethodInfo.Args = Args;
AcpiGbl_DbMethodInfo.Flags = Flags;
AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj);
/*
* Allow any handlers in separate threads to complete.
* (Such as Notify handlers invoked from AML executed above).
*/
AcpiOsSleep (0, 10);
#ifdef ACPI_DEBUG
/* Memory allocation tracking */
Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations;
AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT);
if (Allocations > 0)
{
AcpiOsPrintf ("Outstanding: %ld allocations after execution\n",
Allocations);
}
#endif
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Execution of %s failed with status %s\n",
AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status));
}
else
{
/* Display a return object, if any */
if (ReturnObj.Length)
{
AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, ReturnObj.Length);
AcpiDbDumpObject (ReturnObj.Pointer, 1);
}
}
AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
}
开发者ID:MarginC,项目名称:kame,代码行数:69,代码来源:dbexec.c
示例5: AcpiEvaluateObject
//.........这里部分代码省略.........
Status = AcpiNsEvaluate (Info);
}
/*
* If we are expecting a return value, and all went well above,
* copy the return value to an external object.
*/
if (ReturnBuffer)
{
if (!Info->ReturnObject)
{
ReturnBuffer->Length = 0;
}
else
{
if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
ACPI_DESC_TYPE_NAMED)
{
/*
* If we received a NS Node as a return object, this means that
* the object we are evaluating has nothing interesting to
* return (such as a mutex, etc.) We return an error because
* these types are essentially unsupported by this interface.
* We don't check up front because this makes it easier to add
* support for various types at a later date if necessary.
*/
Status = AE_TYPE;
Info->ReturnObject = NULL; /* No need to delete a NS Node */
ReturnBuffer->Length = 0;
}
if (ACPI_SUCCESS (Status))
{
/* Dereference Index and RefOf references */
AcpiNsResolveReferences (Info);
/* Get the size of the returned object */
Status = AcpiUtGetObjectSize (Info->ReturnObject,
&BufferSpaceNeeded);
if (ACPI_SUCCESS (Status))
{
/* Validate/Allocate/Clear caller buffer */
Status = AcpiUtInitializeBuffer (ReturnBuffer,
BufferSpaceNeeded);
if (ACPI_FAILURE (Status))
{
/*
* Caller's buffer is too small or a new one can't
* be allocated
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed buffer size %X, %s\n",
(UINT32) BufferSpaceNeeded,
AcpiFormatException (Status)));
}
else
{
/* We have enough space for the object, build it */
Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject,
ReturnBuffer);
}
}
}
}
}
if (Info->ReturnObject)
{
/*
* Delete the internal return object. NOTE: Interpreter must be
* locked to avoid race condition.
*/
AcpiExEnterInterpreter ();
/* Remove one reference on the return object (should delete it) */
AcpiUtRemoveReference (Info->ReturnObject);
AcpiExExitInterpreter ();
}
Cleanup:
/* Free the input parameter list (if we created one) */
if (Info->Parameters)
{
/* Free the allocated parameter block */
AcpiUtDeleteInternalObjectList (Info->Parameters);
}
ACPI_FREE (Info);
return_ACPI_STATUS (Status);
}
ACPI_STATUS
AcpiDsInitOneObject (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_OBJECT_TYPE Type;
ACPI_STATUS Status;
ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
ACPI_FUNCTION_NAME ("DsInitOneObject");
/*
* We are only interested in objects owned by the table that
* was just loaded
*/
if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId !=
Info->TableDesc->TableId)
{
return (AE_OK);
}
Info->ObjectCount++;
/* And even then, we are only interested in a few object types */
Type = AcpiNsGetType (ObjHandle);
switch (Type)
{
case ACPI_TYPE_REGION:
Status = AcpiDsInitializeRegion (ObjHandle);
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n",
ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii,
AcpiFormatException (Status)));
}
Info->OpRegionCount++;
break;
case ACPI_TYPE_METHOD:
Info->MethodCount++;
/* Print a dot for each method unless we are going to print the entire pathname */
if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
}
/*
* Set the execution data width (32 or 64) based upon the
* revision number of the parent ACPI table.
* TBD: This is really for possible future support of integer width
* on a per-table basis. Currently, we just use a global for the width.
*/
if (Info->TableDesc->Pointer->Revision == 1)
{
((ACPI_NAMESPACE_NODE *) ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32;
}
/*
* Always parse methods to detect errors, we may delete
* the parse tree below
*/
Status = AcpiDsParseMethod (ObjHandle);
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii,
AcpiFormatException (Status)));
/* This parse failed, but we will continue parsing more methods */
break;
}
/*
* Delete the parse tree. We simple re-parse the method
* for every execution since there isn't much overhead
*/
AcpiNsDeleteNamespaceSubtree (ObjHandle);
AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId);
break;
case ACPI_TYPE_DEVICE:
Info->DeviceCount++;
break;
//.........这里部分代码省略.........
ACPI_STATUS
AcpiDbLoadAcpiTable (
NATIVE_CHAR *Filename)
{
#ifdef ACPI_APPLICATION
FILE *fp;
ACPI_STATUS Status;
ACPI_TABLE_HEADER *TablePtr;
UINT32 TableLength;
/* Open the file */
fp = fopen (Filename, "rb");
if (!fp)
{
AcpiOsPrintf ("Could not open file %s\n", Filename);
return (AE_ERROR);
}
/* Get the entire file */
AcpiOsPrintf ("Loading Acpi table from file %s\n", Filename);
Status = AcpiDbLoadTable (fp, &TablePtr, &TableLength);
fclose(fp);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Couldn't get table from the file\n");
return (Status);
}
/* Attempt to recognize and install the table */
Status = AeLocalLoadTable (TablePtr);
if (ACPI_FAILURE (Status))
{
if (Status == AE_EXIST)
{
AcpiOsPrintf ("Table %4.4s is already installed\n",
&TablePtr->Signature);
}
else
{
AcpiOsPrintf ("Could not install table, %s\n",
AcpiFormatException (Status));
}
ACPI_MEM_FREE (TablePtr);
return (Status);
}
AcpiOsPrintf ("%4.4s at %p successfully installed and loaded\n",
&TablePtr->Signature, TablePtr);
AcpiGbl_AcpiHardwarePresent = FALSE;
#endif /* ACPI_APPLICATION */
return (AE_OK);
}
开发者ID:MarginC,项目名称:kame,代码行数:63,代码来源:dbfileio.c
示例10: AcpiAttachData
Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2,
AcpiGbl_RootNode);
ACPI_CHECK_OK (AcpiAttachData, Status);
/* Test support for multiple attaches */
Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
ACPI_CHECK_OK (AcpiAttachData, Status);
Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle);
ACPI_CHECK_OK (AcpiAttachData, Status);
}
else
{
printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
}
/*
* Install handlers that will override the default handlers for some of
* the space IDs.
*/
AeOverrideRegionHandlers ();
/*
* Initialize the global Region Handler space
* MCW 3/23/00
*/
AeRegions.NumberOfRegions = 0;
AeRegions.RegionList = NULL;
return (AE_OK);
//.........这里部分代码省略.........
* If we are expecting a return value, and all went well above,
* copy the return value to an external object.
*/
if (!ReturnBuffer)
{
goto CleanupReturnObject;
}
if (!Info->ReturnObject)
{
ReturnBuffer->Length = 0;
goto Cleanup;
}
if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
ACPI_DESC_TYPE_NAMED)
{
/*
* If we received a NS Node as a return object, this means that
* the object we are evaluating has nothing interesting to
* return (such as a mutex, etc.) We return an error because
* these types are essentially unsupported by this interface.
* We don't check up front because this makes it easier to add
* support for various types at a later date if necessary.
*/
Status = AE_TYPE;
Info->ReturnObject = NULL; /* No need to delete a NS Node */
ReturnBuffer->Length = 0;
}
if (ACPI_FAILURE (Status))
{
goto CleanupReturnObject;
}
/* Dereference Index and RefOf references */
AcpiNsResolveReferences (Info);
/* Get the size of the returned object */
Status = AcpiUtGetObjectSize (Info->ReturnObject,
&BufferSpaceNeeded);
if (ACPI_SUCCESS (Status))
{
/* Validate/Allocate/Clear caller buffer */
Status = AcpiUtInitializeBuffer (ReturnBuffer,
BufferSpaceNeeded);
if (ACPI_FAILURE (Status))
{
/*
* Caller's buffer is too small or a new one can't
* be allocated
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed buffer size %X, %s\n",
(UINT32) BufferSpaceNeeded,
AcpiFormatException (Status)));
}
else
{
/* We have enough space for the object, build it */
Status = AcpiUtCopyIobjectToEobject (
Info->ReturnObject, ReturnBuffer);
}
}
CleanupReturnObject:
if (Info->ReturnObject)
{
/*
* Delete the internal return object. NOTE: Interpreter must be
* locked to avoid race condition.
*/
AcpiExEnterInterpreter ();
/* Remove one reference on the return object (should delete it) */
AcpiUtRemoveReference (Info->ReturnObject);
AcpiExExitInterpreter ();
}
Cleanup:
/* Free the input parameter list (if we created one) */
if (Info->Parameters)
{
/* Free the allocated parameter block */
AcpiUtDeleteInternalObjectList (Info->Parameters);
}
ACPI_FREE (Info);
return_ACPI_STATUS (Status);
}
static ACPI_STATUS
AslDoDisassembly (
void)
{
ACPI_STATUS Status;
/* ACPICA subsystem initialization */
Status = AdInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
Status = AcpiAllocateRootTable (4);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
AcpiFormatException (Status));
return (Status);
}
/* Handle additional output files for disassembler */
AslGbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix);
/* This is where the disassembly happens */
AcpiGbl_DmOpt_Disasm = TRUE;
Status = AdAmlDisassemble (AslToFile,
AslGbl_Files[ASL_FILE_INPUT].Filename, AslGbl_OutputFilenamePrefix,
&AslGbl_Files[ASL_FILE_INPUT].Filename);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Check if any control methods were unresolved */
AcpiDmUnresolvedWarning (0);
/* Shutdown compiler and ACPICA subsystem */
AeClearErrorLog ();
(void) AcpiTerminate ();
/*
* AslGbl_Files[ASL_FILE_INPUT].Filename was replaced with the
* .DSL disassembly file, which can now be compiled if requested
*/
if (AslGbl_DoCompile)
{
AcpiOsPrintf ("\nCompiling \"%s\"\n",
AslGbl_Files[ASL_FILE_INPUT].Filename);
return (AE_CTRL_CONTINUE);
}
/* No need to free the filename string */
AslGbl_Files[ASL_FILE_INPUT].Filename = NULL;
UtDeleteLocalCaches ();
return (AE_OK);
}
请发表评论