xref: /freebsd/sys/contrib/dev/acpica/components/debugger/dbmethod.c (revision 722b16673c40aedf280895f2f2f676bb494518d7)
1a159c266SJung-uk Kim /*******************************************************************************
2a159c266SJung-uk Kim  *
3a159c266SJung-uk Kim  * Module Name: dbmethod - Debug commands for control methods
4a159c266SJung-uk Kim  *
5a159c266SJung-uk Kim  ******************************************************************************/
6a159c266SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11*722b1667SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
12a159c266SJung-uk Kim  * All rights reserved.
13a159c266SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119a159c266SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120a159c266SJung-uk Kim  * modification, are permitted provided that the following conditions
121a159c266SJung-uk Kim  * are met:
122a159c266SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123a159c266SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124a159c266SJung-uk Kim  *    without modification.
125a159c266SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a159c266SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127a159c266SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128a159c266SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129a159c266SJung-uk Kim  *    binary redistribution.
130a159c266SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131a159c266SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132a159c266SJung-uk Kim  *    from this software without specific prior written permission.
133a159c266SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147a159c266SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148a159c266SJung-uk Kim  * Software Foundation.
149a159c266SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151a159c266SJung-uk Kim 
152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
154a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h>
155a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
156a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdebug.h>
157a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
158895f26a9SJung-uk Kim #include <contrib/dev/acpica/include/acpredef.h>
159a159c266SJung-uk Kim 
160a159c266SJung-uk Kim 
161a159c266SJung-uk Kim #define _COMPONENT          ACPI_CA_DEBUGGER
162a159c266SJung-uk Kim         ACPI_MODULE_NAME    ("dbmethod")
163a159c266SJung-uk Kim 
164493deb39SJung-uk Kim /* Local prototypes */
165493deb39SJung-uk Kim 
166493deb39SJung-uk Kim static ACPI_STATUS
167493deb39SJung-uk Kim AcpiDbWalkForExecute (
168493deb39SJung-uk Kim     ACPI_HANDLE             ObjHandle,
169493deb39SJung-uk Kim     UINT32                  NestingLevel,
170493deb39SJung-uk Kim     void                    *Context,
171493deb39SJung-uk Kim     void                    **ReturnValue);
172493deb39SJung-uk Kim 
173f15e9afbSJung-uk Kim static ACPI_STATUS
174f15e9afbSJung-uk Kim AcpiDbEvaluateObject (
175f15e9afbSJung-uk Kim     ACPI_NAMESPACE_NODE     *Node);
176f15e9afbSJung-uk Kim 
177a159c266SJung-uk Kim 
178a159c266SJung-uk Kim /*******************************************************************************
179a159c266SJung-uk Kim  *
180a159c266SJung-uk Kim  * FUNCTION:    AcpiDbSetMethodBreakpoint
181a159c266SJung-uk Kim  *
182a159c266SJung-uk Kim  * PARAMETERS:  Location            - AML offset of breakpoint
183a159c266SJung-uk Kim  *              WalkState           - Current walk info
184a159c266SJung-uk Kim  *              Op                  - Current Op (from parse walk)
185a159c266SJung-uk Kim  *
186a159c266SJung-uk Kim  * RETURN:      None
187a159c266SJung-uk Kim  *
188a159c266SJung-uk Kim  * DESCRIPTION: Set a breakpoint in a control method at the specified
189a159c266SJung-uk Kim  *              AML offset
190a159c266SJung-uk Kim  *
191a159c266SJung-uk Kim  ******************************************************************************/
192a159c266SJung-uk Kim 
193a159c266SJung-uk Kim void
AcpiDbSetMethodBreakpoint(char * Location,ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)194a159c266SJung-uk Kim AcpiDbSetMethodBreakpoint (
195a159c266SJung-uk Kim     char                    *Location,
196a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState,
197a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op)
198a159c266SJung-uk Kim {
199a159c266SJung-uk Kim     UINT32                  Address;
200fe0f0bbbSJung-uk Kim     UINT32                  AmlOffset;
201a159c266SJung-uk Kim 
202a159c266SJung-uk Kim 
203a159c266SJung-uk Kim     if (!Op)
204a159c266SJung-uk Kim     {
205a159c266SJung-uk Kim         AcpiOsPrintf ("There is no method currently executing\n");
206a159c266SJung-uk Kim         return;
207a159c266SJung-uk Kim     }
208a159c266SJung-uk Kim 
209a159c266SJung-uk Kim     /* Get and verify the breakpoint address */
210a159c266SJung-uk Kim 
2115ef50723SJung-uk Kim     Address = strtoul (Location, NULL, 16);
212fe0f0bbbSJung-uk Kim     AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
213fe0f0bbbSJung-uk Kim         WalkState->ParserState.AmlStart);
214fe0f0bbbSJung-uk Kim     if (Address <= AmlOffset)
215a159c266SJung-uk Kim     {
216a159c266SJung-uk Kim         AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
217fe0f0bbbSJung-uk Kim             Address, AmlOffset);
218a159c266SJung-uk Kim     }
219a159c266SJung-uk Kim 
220a159c266SJung-uk Kim     /* Save breakpoint in current walk */
221a159c266SJung-uk Kim 
222a159c266SJung-uk Kim     WalkState->UserBreakpoint = Address;
223a159c266SJung-uk Kim     AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
224a159c266SJung-uk Kim }
225a159c266SJung-uk Kim 
226a159c266SJung-uk Kim 
227a159c266SJung-uk Kim /*******************************************************************************
228a159c266SJung-uk Kim  *
229a159c266SJung-uk Kim  * FUNCTION:    AcpiDbSetMethodCallBreakpoint
230a159c266SJung-uk Kim  *
231a159c266SJung-uk Kim  * PARAMETERS:  Op                  - Current Op (from parse walk)
232a159c266SJung-uk Kim  *
233a159c266SJung-uk Kim  * RETURN:      None
234a159c266SJung-uk Kim  *
235a159c266SJung-uk Kim  * DESCRIPTION: Set a breakpoint in a control method at the specified
236a159c266SJung-uk Kim  *              AML offset
237a159c266SJung-uk Kim  *
238a159c266SJung-uk Kim  ******************************************************************************/
239a159c266SJung-uk Kim 
240a159c266SJung-uk Kim void
AcpiDbSetMethodCallBreakpoint(ACPI_PARSE_OBJECT * Op)241a159c266SJung-uk Kim AcpiDbSetMethodCallBreakpoint (
242a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op)
243a159c266SJung-uk Kim {
244a159c266SJung-uk Kim 
245a159c266SJung-uk Kim 
246a159c266SJung-uk Kim     if (!Op)
247a159c266SJung-uk Kim     {
248a159c266SJung-uk Kim         AcpiOsPrintf ("There is no method currently executing\n");
249a159c266SJung-uk Kim         return;
250a159c266SJung-uk Kim     }
251a159c266SJung-uk Kim 
252a159c266SJung-uk Kim     AcpiGbl_StepToNextCall = TRUE;
253a159c266SJung-uk Kim }
254a159c266SJung-uk Kim 
255a159c266SJung-uk Kim 
256a159c266SJung-uk Kim /*******************************************************************************
257a159c266SJung-uk Kim  *
258a159c266SJung-uk Kim  * FUNCTION:    AcpiDbSetMethodData
259a159c266SJung-uk Kim  *
260a159c266SJung-uk Kim  * PARAMETERS:  TypeArg         - L for local, A for argument
261a159c266SJung-uk Kim  *              IndexArg        - which one
262a159c266SJung-uk Kim  *              ValueArg        - Value to set.
263a159c266SJung-uk Kim  *
264a159c266SJung-uk Kim  * RETURN:      None
265a159c266SJung-uk Kim  *
266a159c266SJung-uk Kim  * DESCRIPTION: Set a local or argument for the running control method.
267a159c266SJung-uk Kim  *              NOTE: only object supported is Number.
268a159c266SJung-uk Kim  *
269a159c266SJung-uk Kim  ******************************************************************************/
270a159c266SJung-uk Kim 
271a159c266SJung-uk Kim void
AcpiDbSetMethodData(char * TypeArg,char * IndexArg,char * ValueArg)272a159c266SJung-uk Kim AcpiDbSetMethodData (
273a159c266SJung-uk Kim     char                    *TypeArg,
274a159c266SJung-uk Kim     char                    *IndexArg,
275a159c266SJung-uk Kim     char                    *ValueArg)
276a159c266SJung-uk Kim {
277a159c266SJung-uk Kim     char                    Type;
278a159c266SJung-uk Kim     UINT32                  Index;
279a159c266SJung-uk Kim     UINT32                  Value;
280a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState;
281a159c266SJung-uk Kim     ACPI_OPERAND_OBJECT     *ObjDesc;
282a159c266SJung-uk Kim     ACPI_STATUS             Status;
283a159c266SJung-uk Kim     ACPI_NAMESPACE_NODE     *Node;
284a159c266SJung-uk Kim 
285a159c266SJung-uk Kim 
286a159c266SJung-uk Kim     /* Validate TypeArg */
287a159c266SJung-uk Kim 
288a159c266SJung-uk Kim     AcpiUtStrupr (TypeArg);
289a159c266SJung-uk Kim     Type = TypeArg[0];
290a159c266SJung-uk Kim     if ((Type != 'L') &&
291a159c266SJung-uk Kim         (Type != 'A') &&
292a159c266SJung-uk Kim         (Type != 'N'))
293a159c266SJung-uk Kim     {
294a159c266SJung-uk Kim         AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
295a159c266SJung-uk Kim         return;
296a159c266SJung-uk Kim     }
297a159c266SJung-uk Kim 
2985ef50723SJung-uk Kim     Value = strtoul (ValueArg, NULL, 16);
299a159c266SJung-uk Kim 
300a159c266SJung-uk Kim     if (Type == 'N')
301a159c266SJung-uk Kim     {
302a159c266SJung-uk Kim         Node = AcpiDbConvertToNode (IndexArg);
303313a0c13SJung-uk Kim         if (!Node)
304313a0c13SJung-uk Kim         {
305313a0c13SJung-uk Kim             return;
306313a0c13SJung-uk Kim         }
307313a0c13SJung-uk Kim 
308a159c266SJung-uk Kim         if (Node->Type != ACPI_TYPE_INTEGER)
309a159c266SJung-uk Kim         {
310a159c266SJung-uk Kim             AcpiOsPrintf ("Can only set Integer nodes\n");
311a159c266SJung-uk Kim             return;
312a159c266SJung-uk Kim         }
313a159c266SJung-uk Kim         ObjDesc = Node->Object;
314a159c266SJung-uk Kim         ObjDesc->Integer.Value = Value;
315a159c266SJung-uk Kim         return;
316a159c266SJung-uk Kim     }
317a159c266SJung-uk Kim 
318a159c266SJung-uk Kim     /* Get the index and value */
319a159c266SJung-uk Kim 
3205ef50723SJung-uk Kim     Index = strtoul (IndexArg, NULL, 16);
321a159c266SJung-uk Kim 
322a159c266SJung-uk Kim     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
323a159c266SJung-uk Kim     if (!WalkState)
324a159c266SJung-uk Kim     {
325a159c266SJung-uk Kim         AcpiOsPrintf ("There is no method currently executing\n");
326a159c266SJung-uk Kim         return;
327a159c266SJung-uk Kim     }
328a159c266SJung-uk Kim 
329a159c266SJung-uk Kim     /* Create and initialize the new object */
330a159c266SJung-uk Kim 
331a159c266SJung-uk Kim     ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
332a159c266SJung-uk Kim     if (!ObjDesc)
333a159c266SJung-uk Kim     {
334a159c266SJung-uk Kim         AcpiOsPrintf ("Could not create an internal object\n");
335a159c266SJung-uk Kim         return;
336a159c266SJung-uk Kim     }
337a159c266SJung-uk Kim 
338a159c266SJung-uk Kim     /* Store the new object into the target */
339a159c266SJung-uk Kim 
340a159c266SJung-uk Kim     switch (Type)
341a159c266SJung-uk Kim     {
342a159c266SJung-uk Kim     case 'A':
343a159c266SJung-uk Kim 
344a159c266SJung-uk Kim         /* Set a method argument */
345a159c266SJung-uk Kim 
346a159c266SJung-uk Kim         if (Index > ACPI_METHOD_MAX_ARG)
347a159c266SJung-uk Kim         {
34870e6ab8fSJung-uk Kim             AcpiOsPrintf ("Arg%u - Invalid argument name\n",
34970e6ab8fSJung-uk Kim                 Index);
350a159c266SJung-uk Kim             goto Cleanup;
351a159c266SJung-uk Kim         }
352a159c266SJung-uk Kim 
35370e6ab8fSJung-uk Kim         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG,
35470e6ab8fSJung-uk Kim             Index, ObjDesc, WalkState);
355a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
356a159c266SJung-uk Kim         {
357a159c266SJung-uk Kim             goto Cleanup;
358a159c266SJung-uk Kim         }
359a159c266SJung-uk Kim 
360a159c266SJung-uk Kim         ObjDesc = WalkState->Arguments[Index].Object;
361a159c266SJung-uk Kim 
362a159c266SJung-uk Kim         AcpiOsPrintf ("Arg%u: ", Index);
363fe0f0bbbSJung-uk Kim         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
364a159c266SJung-uk Kim         break;
365a159c266SJung-uk Kim 
366a159c266SJung-uk Kim     case 'L':
367a159c266SJung-uk Kim 
368a159c266SJung-uk Kim         /* Set a method local */
369a159c266SJung-uk Kim 
370a159c266SJung-uk Kim         if (Index > ACPI_METHOD_MAX_LOCAL)
371a159c266SJung-uk Kim         {
37270e6ab8fSJung-uk Kim             AcpiOsPrintf ("Local%u - Invalid local variable name\n",
37370e6ab8fSJung-uk Kim                 Index);
374a159c266SJung-uk Kim             goto Cleanup;
375a159c266SJung-uk Kim         }
376a159c266SJung-uk Kim 
37770e6ab8fSJung-uk Kim         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL,
37870e6ab8fSJung-uk Kim             Index, ObjDesc, WalkState);
379a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
380a159c266SJung-uk Kim         {
381a159c266SJung-uk Kim             goto Cleanup;
382a159c266SJung-uk Kim         }
383a159c266SJung-uk Kim 
384a159c266SJung-uk Kim         ObjDesc = WalkState->LocalVariables[Index].Object;
385a159c266SJung-uk Kim 
386a159c266SJung-uk Kim         AcpiOsPrintf ("Local%u: ", Index);
387fe0f0bbbSJung-uk Kim         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
388a159c266SJung-uk Kim         break;
389a159c266SJung-uk Kim 
390a159c266SJung-uk Kim     default:
391a9d8d09cSJung-uk Kim 
392a159c266SJung-uk Kim         break;
393a159c266SJung-uk Kim     }
394a159c266SJung-uk Kim 
395a159c266SJung-uk Kim Cleanup:
396a159c266SJung-uk Kim     AcpiUtRemoveReference (ObjDesc);
397a159c266SJung-uk Kim }
398a159c266SJung-uk Kim 
399a159c266SJung-uk Kim 
40051f42badSJung-uk Kim #ifdef ACPI_DISASSEMBLER
401a159c266SJung-uk Kim /*******************************************************************************
402a159c266SJung-uk Kim  *
403a159c266SJung-uk Kim  * FUNCTION:    AcpiDbDisassembleAml
404a159c266SJung-uk Kim  *
405a159c266SJung-uk Kim  * PARAMETERS:  Statements          - Number of statements to disassemble
406a159c266SJung-uk Kim  *              Op                  - Current Op (from parse walk)
407a159c266SJung-uk Kim  *
408a159c266SJung-uk Kim  * RETURN:      None
409a159c266SJung-uk Kim  *
410a159c266SJung-uk Kim  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
411a159c266SJung-uk Kim  *              of statements specified.
412a159c266SJung-uk Kim  *
413a159c266SJung-uk Kim  ******************************************************************************/
414a159c266SJung-uk Kim 
415a159c266SJung-uk Kim void
AcpiDbDisassembleAml(char * Statements,ACPI_PARSE_OBJECT * Op)416a159c266SJung-uk Kim AcpiDbDisassembleAml (
417a159c266SJung-uk Kim     char                    *Statements,
418a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op)
419a159c266SJung-uk Kim {
420a159c266SJung-uk Kim     UINT32                  NumStatements = 8;
421a159c266SJung-uk Kim 
422a159c266SJung-uk Kim 
423a159c266SJung-uk Kim     if (!Op)
424a159c266SJung-uk Kim     {
425a159c266SJung-uk Kim         AcpiOsPrintf ("There is no method currently executing\n");
426a159c266SJung-uk Kim         return;
427a159c266SJung-uk Kim     }
428a159c266SJung-uk Kim 
429a159c266SJung-uk Kim     if (Statements)
430a159c266SJung-uk Kim     {
4315ef50723SJung-uk Kim         NumStatements = strtoul (Statements, NULL, 0);
432a159c266SJung-uk Kim     }
433a159c266SJung-uk Kim 
434a159c266SJung-uk Kim     AcpiDmDisassemble (NULL, Op, NumStatements);
435a159c266SJung-uk Kim }
436a159c266SJung-uk Kim 
437a159c266SJung-uk Kim 
438a159c266SJung-uk Kim /*******************************************************************************
439a159c266SJung-uk Kim  *
440a159c266SJung-uk Kim  * FUNCTION:    AcpiDbDisassembleMethod
441a159c266SJung-uk Kim  *
442a159c266SJung-uk Kim  * PARAMETERS:  Name            - Name of control method
443a159c266SJung-uk Kim  *
444a159c266SJung-uk Kim  * RETURN:      None
445a159c266SJung-uk Kim  *
446a159c266SJung-uk Kim  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
447a159c266SJung-uk Kim  *              of statements specified.
448a159c266SJung-uk Kim  *
449a159c266SJung-uk Kim  ******************************************************************************/
450a159c266SJung-uk Kim 
451a159c266SJung-uk Kim ACPI_STATUS
AcpiDbDisassembleMethod(char * Name)452a159c266SJung-uk Kim AcpiDbDisassembleMethod (
453a159c266SJung-uk Kim     char                    *Name)
454a159c266SJung-uk Kim {
455a159c266SJung-uk Kim     ACPI_STATUS             Status;
456a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op;
457a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState;
458a159c266SJung-uk Kim     ACPI_OPERAND_OBJECT     *ObjDesc;
459a159c266SJung-uk Kim     ACPI_NAMESPACE_NODE     *Method;
460a159c266SJung-uk Kim 
461a159c266SJung-uk Kim 
462a159c266SJung-uk Kim     Method = AcpiDbConvertToNode (Name);
463a159c266SJung-uk Kim     if (!Method)
464a159c266SJung-uk Kim     {
465a159c266SJung-uk Kim         return (AE_BAD_PARAMETER);
466a159c266SJung-uk Kim     }
467a159c266SJung-uk Kim 
468ed17e06eSJung-uk Kim     if (Method->Type != ACPI_TYPE_METHOD)
469ed17e06eSJung-uk Kim     {
470ed17e06eSJung-uk Kim         ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method",
471ed17e06eSJung-uk Kim             Name, AcpiUtGetTypeName (Method->Type)));
472ed17e06eSJung-uk Kim         return (AE_BAD_PARAMETER);
473ed17e06eSJung-uk Kim     }
474ed17e06eSJung-uk Kim 
475a159c266SJung-uk Kim     ObjDesc = Method->Object;
476a159c266SJung-uk Kim 
477fe0f0bbbSJung-uk Kim     Op = AcpiPsCreateScopeOp (ObjDesc->Method.AmlStart);
478a159c266SJung-uk Kim     if (!Op)
479a159c266SJung-uk Kim     {
480a159c266SJung-uk Kim         return (AE_NO_MEMORY);
481a159c266SJung-uk Kim     }
482a159c266SJung-uk Kim 
483a159c266SJung-uk Kim     /* Create and initialize a new walk state */
484a159c266SJung-uk Kim 
485a159c266SJung-uk Kim     WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
486a159c266SJung-uk Kim     if (!WalkState)
487a159c266SJung-uk Kim     {
488a159c266SJung-uk Kim         return (AE_NO_MEMORY);
489a159c266SJung-uk Kim     }
490a159c266SJung-uk Kim 
491a159c266SJung-uk Kim     Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
492a159c266SJung-uk Kim         ObjDesc->Method.AmlStart,
493a159c266SJung-uk Kim         ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
494a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
495a159c266SJung-uk Kim     {
496a159c266SJung-uk Kim         return (Status);
497a159c266SJung-uk Kim     }
498a159c266SJung-uk Kim 
499ed17e06eSJung-uk Kim     Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
500a009b7dcSJung-uk Kim     if (ACPI_FAILURE(Status))
501a009b7dcSJung-uk Kim     {
502a009b7dcSJung-uk Kim         return (Status);
503a009b7dcSJung-uk Kim     }
504a009b7dcSJung-uk Kim 
505ed17e06eSJung-uk Kim     WalkState->OwnerId = ObjDesc->Method.OwnerId;
506ed17e06eSJung-uk Kim 
507ed17e06eSJung-uk Kim     /* Push start scope on scope stack and make it current */
508ed17e06eSJung-uk Kim 
509ed17e06eSJung-uk Kim     Status = AcpiDsScopeStackPush (Method,
510ed17e06eSJung-uk Kim         Method->Type, WalkState);
511ed17e06eSJung-uk Kim     if (ACPI_FAILURE (Status))
512ed17e06eSJung-uk Kim     {
513ed17e06eSJung-uk Kim         return (Status);
514ed17e06eSJung-uk Kim     }
515ed17e06eSJung-uk Kim 
516ed17e06eSJung-uk Kim     /* Parse the entire method AML including deferred operators */
517a159c266SJung-uk Kim 
518a159c266SJung-uk Kim     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
519a159c266SJung-uk Kim     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
520a159c266SJung-uk Kim 
521ed17e06eSJung-uk Kim     Status = AcpiPsParseAml (WalkState);
522a009b7dcSJung-uk Kim     if (ACPI_FAILURE(Status))
523a009b7dcSJung-uk Kim     {
524a009b7dcSJung-uk Kim         return (Status);
525a009b7dcSJung-uk Kim     }
526a009b7dcSJung-uk Kim 
527efcc2a30SJung-uk Kim     (void) AcpiDmParseDeferredOps (Op);
528ed17e06eSJung-uk Kim 
529ed17e06eSJung-uk Kim     /* Now we can disassemble the method */
530ed17e06eSJung-uk Kim 
53170e6ab8fSJung-uk Kim     AcpiGbl_DmOpt_Verbose = FALSE;
532a159c266SJung-uk Kim     AcpiDmDisassemble (NULL, Op, 0);
53370e6ab8fSJung-uk Kim     AcpiGbl_DmOpt_Verbose = TRUE;
534ed17e06eSJung-uk Kim 
535a159c266SJung-uk Kim     AcpiPsDeleteParseTree (Op);
536ed17e06eSJung-uk Kim 
537ed17e06eSJung-uk Kim     /* Method cleanup */
538ed17e06eSJung-uk Kim 
539ed17e06eSJung-uk Kim     AcpiNsDeleteNamespaceSubtree (Method);
540ed17e06eSJung-uk Kim     AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId);
541ed17e06eSJung-uk Kim     AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
542a159c266SJung-uk Kim     return (AE_OK);
543a159c266SJung-uk Kim }
54451f42badSJung-uk Kim #endif
545493deb39SJung-uk Kim 
546493deb39SJung-uk Kim 
547493deb39SJung-uk Kim /*******************************************************************************
548493deb39SJung-uk Kim  *
549f15e9afbSJung-uk Kim  * FUNCTION:    AcpiDbEvaluateObject
550493deb39SJung-uk Kim  *
551f15e9afbSJung-uk Kim  * PARAMETERS:  Node                - Namespace node for the object
552493deb39SJung-uk Kim  *
553493deb39SJung-uk Kim  * RETURN:      Status
554493deb39SJung-uk Kim  *
555f15e9afbSJung-uk Kim  * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
556f15e9afbSJung-uk Kim  *              commands.
557493deb39SJung-uk Kim  *
558493deb39SJung-uk Kim  ******************************************************************************/
559493deb39SJung-uk Kim 
560493deb39SJung-uk Kim static ACPI_STATUS
AcpiDbEvaluateObject(ACPI_NAMESPACE_NODE * Node)561f15e9afbSJung-uk Kim AcpiDbEvaluateObject (
562f15e9afbSJung-uk Kim     ACPI_NAMESPACE_NODE     *Node)
563493deb39SJung-uk Kim {
564493deb39SJung-uk Kim     char                    *Pathname;
565493deb39SJung-uk Kim     UINT32                  i;
566493deb39SJung-uk Kim     ACPI_DEVICE_INFO        *ObjInfo;
567493deb39SJung-uk Kim     ACPI_OBJECT_LIST        ParamObjects;
568493deb39SJung-uk Kim     ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
569f15e9afbSJung-uk Kim     ACPI_BUFFER             ReturnObj;
570f15e9afbSJung-uk Kim     ACPI_STATUS             Status;
571493deb39SJung-uk Kim 
572493deb39SJung-uk Kim 
573493deb39SJung-uk Kim     Pathname = AcpiNsGetExternalPathname (Node);
574493deb39SJung-uk Kim     if (!Pathname)
575493deb39SJung-uk Kim     {
576493deb39SJung-uk Kim         return (AE_OK);
577493deb39SJung-uk Kim     }
578493deb39SJung-uk Kim 
579493deb39SJung-uk Kim     /* Get the object info for number of method parameters */
580493deb39SJung-uk Kim 
581f15e9afbSJung-uk Kim     Status = AcpiGetObjectInfo (Node, &ObjInfo);
582493deb39SJung-uk Kim     if (ACPI_FAILURE (Status))
583493deb39SJung-uk Kim     {
5840d84335fSJung-uk Kim         ACPI_FREE (Pathname);
585493deb39SJung-uk Kim         return (Status);
586493deb39SJung-uk Kim     }
587493deb39SJung-uk Kim 
588493deb39SJung-uk Kim     ParamObjects.Pointer = NULL;
589493deb39SJung-uk Kim     ParamObjects.Count   = 0;
590493deb39SJung-uk Kim 
591493deb39SJung-uk Kim     if (ObjInfo->Type == ACPI_TYPE_METHOD)
592493deb39SJung-uk Kim     {
593493deb39SJung-uk Kim         /* Setup default parameters */
594493deb39SJung-uk Kim 
595493deb39SJung-uk Kim         for (i = 0; i < ObjInfo->ParamCount; i++)
596493deb39SJung-uk Kim         {
597493deb39SJung-uk Kim             Params[i].Type           = ACPI_TYPE_INTEGER;
598493deb39SJung-uk Kim             Params[i].Integer.Value  = 1;
599493deb39SJung-uk Kim         }
600493deb39SJung-uk Kim 
601493deb39SJung-uk Kim         ParamObjects.Pointer     = Params;
602493deb39SJung-uk Kim         ParamObjects.Count       = ObjInfo->ParamCount;
603493deb39SJung-uk Kim     }
604493deb39SJung-uk Kim 
605493deb39SJung-uk Kim     ACPI_FREE (ObjInfo);
606493deb39SJung-uk Kim     ReturnObj.Pointer = NULL;
607493deb39SJung-uk Kim     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
608493deb39SJung-uk Kim 
609493deb39SJung-uk Kim     /* Do the actual method execution */
610493deb39SJung-uk Kim 
611493deb39SJung-uk Kim     AcpiGbl_MethodExecuting = TRUE;
612493deb39SJung-uk Kim 
613493deb39SJung-uk Kim     Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
614f15e9afbSJung-uk Kim     AcpiGbl_MethodExecuting = FALSE;
615493deb39SJung-uk Kim 
616493deb39SJung-uk Kim     AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
617f15e9afbSJung-uk Kim     if (ReturnObj.Length)
618f15e9afbSJung-uk Kim     {
619f15e9afbSJung-uk Kim         AcpiOsPrintf ("Evaluation of %s returned object %p, "
620f15e9afbSJung-uk Kim             "external buffer length %X\n",
621f15e9afbSJung-uk Kim             Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length);
622f15e9afbSJung-uk Kim 
623f15e9afbSJung-uk Kim         AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
624f15e9afbSJung-uk Kim         AcpiOsPrintf ("\n");
625f15e9afbSJung-uk Kim     }
626f15e9afbSJung-uk Kim 
627493deb39SJung-uk Kim     ACPI_FREE (Pathname);
628493deb39SJung-uk Kim 
629493deb39SJung-uk Kim     /* Ignore status from method execution */
630493deb39SJung-uk Kim 
631f15e9afbSJung-uk Kim     return (AE_OK);
632f15e9afbSJung-uk Kim 
633f15e9afbSJung-uk Kim     /* Update count, check if we have executed enough methods */
634f15e9afbSJung-uk Kim 
635f15e9afbSJung-uk Kim }
636f15e9afbSJung-uk Kim 
637f15e9afbSJung-uk Kim /*******************************************************************************
638f15e9afbSJung-uk Kim  *
639f15e9afbSJung-uk Kim  * FUNCTION:    AcpiDbWalkForExecute
640f15e9afbSJung-uk Kim  *
641f15e9afbSJung-uk Kim  * PARAMETERS:  Callback from WalkNamespace
642f15e9afbSJung-uk Kim  *
643f15e9afbSJung-uk Kim  * RETURN:      Status
644f15e9afbSJung-uk Kim  *
645f15e9afbSJung-uk Kim  * DESCRIPTION: Batch execution function. Evaluates all "predefined" objects --
646f15e9afbSJung-uk Kim  *              the nameseg begins with an underscore.
647f15e9afbSJung-uk Kim  *
648f15e9afbSJung-uk Kim  ******************************************************************************/
649f15e9afbSJung-uk Kim 
650f15e9afbSJung-uk Kim static ACPI_STATUS
AcpiDbWalkForExecute(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)651f15e9afbSJung-uk Kim AcpiDbWalkForExecute (
652f15e9afbSJung-uk Kim     ACPI_HANDLE             ObjHandle,
653f15e9afbSJung-uk Kim     UINT32                  NestingLevel,
654f15e9afbSJung-uk Kim     void                    *Context,
655f15e9afbSJung-uk Kim     void                    **ReturnValue)
656f15e9afbSJung-uk Kim {
657f15e9afbSJung-uk Kim     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
658f15e9afbSJung-uk Kim     ACPI_DB_EXECUTE_WALK    *Info = (ACPI_DB_EXECUTE_WALK *) Context;
659f15e9afbSJung-uk Kim     ACPI_STATUS             Status;
660f15e9afbSJung-uk Kim     const ACPI_PREDEFINED_INFO *Predefined;
661f15e9afbSJung-uk Kim 
662f15e9afbSJung-uk Kim 
663f15e9afbSJung-uk Kim     Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
664f15e9afbSJung-uk Kim     if (!Predefined)
665f15e9afbSJung-uk Kim     {
666f15e9afbSJung-uk Kim         return (AE_OK);
667f15e9afbSJung-uk Kim     }
668f15e9afbSJung-uk Kim 
669f15e9afbSJung-uk Kim     if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
670f15e9afbSJung-uk Kim     {
671f15e9afbSJung-uk Kim         return (AE_OK);
672f15e9afbSJung-uk Kim     }
673f15e9afbSJung-uk Kim 
674f15e9afbSJung-uk Kim     AcpiDbEvaluateObject (Node);
675f15e9afbSJung-uk Kim 
676f15e9afbSJung-uk Kim     /* Ignore status from object evaluation */
677f15e9afbSJung-uk Kim 
678493deb39SJung-uk Kim     Status = AE_OK;
679493deb39SJung-uk Kim 
680493deb39SJung-uk Kim     /* Update count, check if we have executed enough methods */
681493deb39SJung-uk Kim 
682493deb39SJung-uk Kim     Info->Count++;
683493deb39SJung-uk Kim     if (Info->Count >= Info->MaxCount)
684493deb39SJung-uk Kim     {
685493deb39SJung-uk Kim         Status = AE_CTRL_TERMINATE;
686493deb39SJung-uk Kim     }
687493deb39SJung-uk Kim 
688493deb39SJung-uk Kim     return (Status);
689493deb39SJung-uk Kim }
690493deb39SJung-uk Kim 
691493deb39SJung-uk Kim 
692493deb39SJung-uk Kim /*******************************************************************************
693493deb39SJung-uk Kim  *
694f15e9afbSJung-uk Kim  * FUNCTION:    AcpiDbWalkForExecuteAll
695f15e9afbSJung-uk Kim  *
696f15e9afbSJung-uk Kim  * PARAMETERS:  Callback from WalkNamespace
697f15e9afbSJung-uk Kim  *
698f15e9afbSJung-uk Kim  * RETURN:      Status
699f15e9afbSJung-uk Kim  *
700f15e9afbSJung-uk Kim  * DESCRIPTION: Batch execution function. Evaluates all objects whose path ends
701f15e9afbSJung-uk Kim  *              with the nameseg "Info->NameSeg". Used for the "ALL" command.
702f15e9afbSJung-uk Kim  *
703f15e9afbSJung-uk Kim  ******************************************************************************/
704f15e9afbSJung-uk Kim 
705f15e9afbSJung-uk Kim static ACPI_STATUS
AcpiDbWalkForExecuteAll(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)706f15e9afbSJung-uk Kim AcpiDbWalkForExecuteAll (
707f15e9afbSJung-uk Kim     ACPI_HANDLE             ObjHandle,
708f15e9afbSJung-uk Kim     UINT32                  NestingLevel,
709f15e9afbSJung-uk Kim     void                    *Context,
710f15e9afbSJung-uk Kim     void                    **ReturnValue)
711f15e9afbSJung-uk Kim {
712f15e9afbSJung-uk Kim     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
713f15e9afbSJung-uk Kim     ACPI_DB_EXECUTE_WALK    *Info = (ACPI_DB_EXECUTE_WALK *) Context;
714f15e9afbSJung-uk Kim     ACPI_STATUS             Status;
715f15e9afbSJung-uk Kim 
716f15e9afbSJung-uk Kim 
717f15e9afbSJung-uk Kim     if (!ACPI_COMPARE_NAMESEG (Node->Name.Ascii, Info->NameSeg))
718f15e9afbSJung-uk Kim     {
719f15e9afbSJung-uk Kim         return (AE_OK);
720f15e9afbSJung-uk Kim     }
721f15e9afbSJung-uk Kim 
722f15e9afbSJung-uk Kim     if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
723f15e9afbSJung-uk Kim     {
724f15e9afbSJung-uk Kim         return (AE_OK);
725f15e9afbSJung-uk Kim     }
726f15e9afbSJung-uk Kim 
727f15e9afbSJung-uk Kim     /* Now evaluate the input object (node) */
728f15e9afbSJung-uk Kim 
729f15e9afbSJung-uk Kim     AcpiDbEvaluateObject (Node);
730f15e9afbSJung-uk Kim 
731f15e9afbSJung-uk Kim     /* Ignore status from method execution */
732f15e9afbSJung-uk Kim 
733f15e9afbSJung-uk Kim     Status = AE_OK;
734f15e9afbSJung-uk Kim 
735f15e9afbSJung-uk Kim     /* Update count of executed methods/objects */
736f15e9afbSJung-uk Kim 
737f15e9afbSJung-uk Kim     Info->Count++;
738f15e9afbSJung-uk Kim     return (Status);
739f15e9afbSJung-uk Kim }
740f15e9afbSJung-uk Kim 
741f15e9afbSJung-uk Kim 
742f15e9afbSJung-uk Kim /*******************************************************************************
743f15e9afbSJung-uk Kim  *
744493deb39SJung-uk Kim  * FUNCTION:    AcpiDbEvaluatePredefinedNames
745493deb39SJung-uk Kim  *
746493deb39SJung-uk Kim  * PARAMETERS:  None
747493deb39SJung-uk Kim  *
748493deb39SJung-uk Kim  * RETURN:      None
749493deb39SJung-uk Kim  *
750493deb39SJung-uk Kim  * DESCRIPTION: Namespace batch execution. Execute predefined names in the
751493deb39SJung-uk Kim  *              namespace, up to the max count, if specified.
752493deb39SJung-uk Kim  *
753493deb39SJung-uk Kim  ******************************************************************************/
754493deb39SJung-uk Kim 
755493deb39SJung-uk Kim void
AcpiDbEvaluatePredefinedNames(void)756493deb39SJung-uk Kim AcpiDbEvaluatePredefinedNames (
757493deb39SJung-uk Kim     void)
758493deb39SJung-uk Kim {
759493deb39SJung-uk Kim     ACPI_DB_EXECUTE_WALK    Info;
760493deb39SJung-uk Kim 
761493deb39SJung-uk Kim 
762493deb39SJung-uk Kim     Info.Count = 0;
763493deb39SJung-uk Kim     Info.MaxCount = ACPI_UINT32_MAX;
764493deb39SJung-uk Kim 
765493deb39SJung-uk Kim     /* Search all nodes in namespace */
766493deb39SJung-uk Kim 
767493deb39SJung-uk Kim     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
768493deb39SJung-uk Kim                 AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
769493deb39SJung-uk Kim 
770493deb39SJung-uk Kim     AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
771493deb39SJung-uk Kim }
772f15e9afbSJung-uk Kim 
773f15e9afbSJung-uk Kim 
774f15e9afbSJung-uk Kim /*******************************************************************************
775f15e9afbSJung-uk Kim  *
776f15e9afbSJung-uk Kim  * FUNCTION:    AcpiDbEvaluateAll
777f15e9afbSJung-uk Kim  *
778f15e9afbSJung-uk Kim  * PARAMETERS:  NoneAcpiGbl_DbMethodInfo
779f15e9afbSJung-uk Kim  *
780f15e9afbSJung-uk Kim  * RETURN:      None
781f15e9afbSJung-uk Kim  *
782f15e9afbSJung-uk Kim  * DESCRIPTION: Namespace batch execution. Implements the "ALL" command.
783f15e9afbSJung-uk Kim  *              Execute all namepaths whose final nameseg matches the
784f15e9afbSJung-uk Kim  *              input nameseg.
785f15e9afbSJung-uk Kim  *
786f15e9afbSJung-uk Kim  ******************************************************************************/
787f15e9afbSJung-uk Kim 
788f15e9afbSJung-uk Kim void
AcpiDbEvaluateAll(char * NameSeg)789f15e9afbSJung-uk Kim AcpiDbEvaluateAll (
790f15e9afbSJung-uk Kim     char                    *NameSeg)
791f15e9afbSJung-uk Kim {
792f15e9afbSJung-uk Kim     ACPI_DB_EXECUTE_WALK    Info;
793f15e9afbSJung-uk Kim 
794f15e9afbSJung-uk Kim 
795f15e9afbSJung-uk Kim     Info.Count = 0;
796f15e9afbSJung-uk Kim     Info.MaxCount = ACPI_UINT32_MAX;
797f15e9afbSJung-uk Kim     ACPI_COPY_NAMESEG (Info.NameSeg, NameSeg);
798f15e9afbSJung-uk Kim     Info.NameSeg[ACPI_NAMESEG_SIZE] = 0;
799f15e9afbSJung-uk Kim 
800f15e9afbSJung-uk Kim     /* Search all nodes in namespace */
801f15e9afbSJung-uk Kim 
802f15e9afbSJung-uk Kim     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
803f15e9afbSJung-uk Kim                 AcpiDbWalkForExecuteAll, NULL, (void *) &Info, NULL);
804f15e9afbSJung-uk Kim 
805f15e9afbSJung-uk Kim     AcpiOsPrintf ("Evaluated %u names in the namespace\n", Info.Count);
806f15e9afbSJung-uk Kim }
807