Print this page
acpica-unix2-20130823
PANKOVs restructure

@@ -3,11 +3,11 @@
  * Module Name: dbmethod - Debug commands for control methods
  *
  ******************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2011, Intel Corp.
+ * Copyright (C) 2000 - 2013, 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:

@@ -47,10 +47,11 @@
 #include "acdispat.h"
 #include "acnamesp.h"
 #include "acdebug.h"
 #include "acdisasm.h"
 #include "acparser.h"
+#include "acpredef.h"
 
 
 #ifdef ACPI_DEBUGGER
 
 #define _COMPONENT          ACPI_CA_DEBUGGER

@@ -268,10 +269,11 @@
         AcpiOsPrintf ("Local%u: ", Index);
         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
         break;
 
     default:
+
         break;
     }
 
 Cleanup:
     AcpiUtRemoveReference (ObjDesc);

@@ -343,10 +345,17 @@
     if (!Method)
     {
         return (AE_BAD_PARAMETER);
     }
 
+    if (Method->Type != ACPI_TYPE_METHOD)
+    {
+        ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method",
+            Name, AcpiUtGetTypeName (Method->Type)));
+        return (AE_BAD_PARAMETER);
+    }
+
     ObjDesc = Method->Object;
 
     Op = AcpiPsCreateScopeOp ();
     if (!Op)
     {

@@ -367,18 +376,43 @@
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
-    /* Parse the AML */
+    Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
+    WalkState->OwnerId = ObjDesc->Method.OwnerId;
 
+    /* Push start scope on scope stack and make it current */
+
+    Status = AcpiDsScopeStackPush (Method,
+        Method->Type, WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /* Parse the entire method AML including deferred operators */
+
     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
+
     Status = AcpiPsParseAml (WalkState);
+    (void) AcpiDmParseDeferredOps (Op);
 
+    /* Now we can disassemble the method */
+
+    AcpiGbl_DbOpt_verbose = FALSE;
     AcpiDmDisassemble (NULL, Op, 0);
+    AcpiGbl_DbOpt_verbose = TRUE;
+
     AcpiPsDeleteParseTree (Op);
+
+    /* Method cleanup */
+
+    AcpiNsDeleteNamespaceSubtree (Method);
+    AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId);
+    AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
     return (AE_OK);
 }
 
 
 /*******************************************************************************

@@ -400,22 +434,28 @@
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
-    ACPI_EXECUTE_WALK       *Info = (ACPI_EXECUTE_WALK *) Context;
-    ACPI_BUFFER             ReturnObj;
-    ACPI_STATUS             Status;
+    ACPI_DB_EXECUTE_WALK        *Info = (ACPI_DB_EXECUTE_WALK *) Context;
     char                    *Pathname;
-    UINT32                  i;
+    const ACPI_PREDEFINED_INFO  *Predefined;
     ACPI_DEVICE_INFO        *ObjInfo;
     ACPI_OBJECT_LIST        ParamObjects;
     ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
-    const ACPI_PREDEFINED_INFO *Predefined;
+    ACPI_OBJECT                 *ThisParam;
+    ACPI_BUFFER                 ReturnObj;
+    ACPI_STATUS                 Status;
+    UINT16                      ArgTypeList;
+    UINT8                       ArgCount;
+    UINT8                       ArgType;
+    UINT32                      i;
 
 
-    Predefined = AcpiNsCheckForPredefinedName (Node);
+    /* The name must be a predefined ACPI name */
+
+    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
     if (!Predefined)
     {
         return (AE_OK);
     }
 

@@ -436,25 +476,68 @@
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
-    ParamObjects.Pointer = NULL;
     ParamObjects.Count   = 0;
+    ParamObjects.Pointer = NULL;
 
     if (ObjInfo->Type == ACPI_TYPE_METHOD)
     {
-        /* Setup default parameters */
+        /* Setup default parameters (with proper types) */
 
-        for (i = 0; i < ObjInfo->ParamCount; i++)
+        ArgTypeList = Predefined->Info.ArgumentList;
+        ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
+
+        /*
+         * Setup the ACPI-required number of arguments, regardless of what
+         * the actual method defines. If there is a difference, then the
+         * method is wrong and a warning will be issued during execution.
+         */
+        ThisParam = Params;
+        for (i = 0; i < ArgCount; i++)
         {
-            Params[i].Type           = ACPI_TYPE_INTEGER;
-            Params[i].Integer.Value  = 1;
+            ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
+            ThisParam->Type = ArgType;
+
+            switch (ArgType)
+            {
+            case ACPI_TYPE_INTEGER:
+
+                ThisParam->Integer.Value = 1;
+                break;
+
+            case ACPI_TYPE_STRING:
+
+                ThisParam->String.Pointer = "This is the default argument string";
+                ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
+                break;
+
+            case ACPI_TYPE_BUFFER:
+
+                ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
+                ThisParam->Buffer.Length = 48;
+                break;
+
+             case ACPI_TYPE_PACKAGE:
+
+                ThisParam->Package.Elements = NULL;
+                ThisParam->Package.Count = 0;
+                break;
+
+           default:
+
+                AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
+                    Pathname, ArgType);
+                break;
         }
 
+            ThisParam++;
+        }
+
+        ParamObjects.Count = ArgCount;
         ParamObjects.Pointer     = Params;
-        ParamObjects.Count       = ObjInfo->ParamCount;
     }
 
     ACPI_FREE (ObjInfo);
     ReturnObj.Pointer = NULL;
     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;

@@ -500,11 +583,11 @@
 
 void
 AcpiDbBatchExecute (
     char                    *CountArg)
 {
-    ACPI_EXECUTE_WALK       Info;
+    ACPI_DB_EXECUTE_WALK    Info;
 
 
     Info.Count = 0;
     Info.MaxCount = ACPI_UINT32_MAX;
 

@@ -517,9 +600,9 @@
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                 AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
 
-    AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count);
+    AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
 }
 
 #endif /* ACPI_DEBUGGER */