1 /*******************************************************************************
2 *
3 * Module Name: dbmethod - Debug commands for control methods
4 *
5 ******************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acdispat.h"
155 #include "acnamesp.h"
156 #include "acdebug.h"
157 #include "acparser.h"
158 #include "acpredef.h"
159
160
161 #ifdef ACPI_DEBUGGER
162
163 #define _COMPONENT ACPI_CA_DEBUGGER
164 ACPI_MODULE_NAME ("dbmethod")
165
166 /* Local prototypes */
167
168 static ACPI_STATUS
169 AcpiDbWalkForExecute (
170 ACPI_HANDLE ObjHandle,
171 UINT32 NestingLevel,
172 void *Context,
173 void **ReturnValue);
174
175 static ACPI_STATUS
176 AcpiDbEvaluateObject (
177 ACPI_NAMESPACE_NODE *Node);
178
179
180 /*******************************************************************************
181 *
182 * FUNCTION: AcpiDbSetMethodBreakpoint
183 *
184 * PARAMETERS: Location - AML offset of breakpoint
185 * WalkState - Current walk info
186 * Op - Current Op (from parse walk)
187 *
188 * RETURN: None
189 *
190 * DESCRIPTION: Set a breakpoint in a control method at the specified
191 * AML offset
192 *
193 ******************************************************************************/
194
195 void
AcpiDbSetMethodBreakpoint(char * Location,ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)196 AcpiDbSetMethodBreakpoint (
197 char *Location,
198 ACPI_WALK_STATE *WalkState,
199 ACPI_PARSE_OBJECT *Op)
200 {
201 UINT32 Address;
202 UINT32 AmlOffset;
203
204
205 if (!Op)
206 {
207 AcpiOsPrintf ("There is no method currently executing\n");
208 return;
209 }
210
211 /* Get and verify the breakpoint address */
212
213 Address = strtoul (Location, NULL, 16);
214 AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
215 WalkState->ParserState.AmlStart);
216 if (Address <= AmlOffset)
217 {
218 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
219 Address, AmlOffset);
220 }
221
222 /* Save breakpoint in current walk */
223
224 WalkState->UserBreakpoint = Address;
225 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
226 }
227
228
229 /*******************************************************************************
230 *
231 * FUNCTION: AcpiDbSetMethodCallBreakpoint
232 *
233 * PARAMETERS: Op - Current Op (from parse walk)
234 *
235 * RETURN: None
236 *
237 * DESCRIPTION: Set a breakpoint in a control method at the specified
238 * AML offset
239 *
240 ******************************************************************************/
241
242 void
AcpiDbSetMethodCallBreakpoint(ACPI_PARSE_OBJECT * Op)243 AcpiDbSetMethodCallBreakpoint (
244 ACPI_PARSE_OBJECT *Op)
245 {
246
247
248 if (!Op)
249 {
250 AcpiOsPrintf ("There is no method currently executing\n");
251 return;
252 }
253
254 AcpiGbl_StepToNextCall = TRUE;
255 }
256
257
258 /*******************************************************************************
259 *
260 * FUNCTION: AcpiDbSetMethodData
261 *
262 * PARAMETERS: TypeArg - L for local, A for argument
263 * IndexArg - which one
264 * ValueArg - Value to set.
265 *
266 * RETURN: None
267 *
268 * DESCRIPTION: Set a local or argument for the running control method.
269 * NOTE: only object supported is Number.
270 *
271 ******************************************************************************/
272
273 void
AcpiDbSetMethodData(char * TypeArg,char * IndexArg,char * ValueArg)274 AcpiDbSetMethodData (
275 char *TypeArg,
276 char *IndexArg,
277 char *ValueArg)
278 {
279 char Type;
280 UINT32 Index;
281 UINT32 Value;
282 ACPI_WALK_STATE *WalkState;
283 ACPI_OPERAND_OBJECT *ObjDesc;
284 ACPI_STATUS Status;
285 ACPI_NAMESPACE_NODE *Node;
286
287
288 /* Validate TypeArg */
289
290 AcpiUtStrupr (TypeArg);
291 Type = TypeArg[0];
292 if ((Type != 'L') &&
293 (Type != 'A') &&
294 (Type != 'N'))
295 {
296 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
297 return;
298 }
299
300 Value = strtoul (ValueArg, NULL, 16);
301
302 if (Type == 'N')
303 {
304 Node = AcpiDbConvertToNode (IndexArg);
305 if (!Node)
306 {
307 return;
308 }
309
310 if (Node->Type != ACPI_TYPE_INTEGER)
311 {
312 AcpiOsPrintf ("Can only set Integer nodes\n");
313 return;
314 }
315 ObjDesc = Node->Object;
316 ObjDesc->Integer.Value = Value;
317 return;
318 }
319
320 /* Get the index and value */
321
322 Index = strtoul (IndexArg, NULL, 16);
323
324 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
325 if (!WalkState)
326 {
327 AcpiOsPrintf ("There is no method currently executing\n");
328 return;
329 }
330
331 /* Create and initialize the new object */
332
333 ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
334 if (!ObjDesc)
335 {
336 AcpiOsPrintf ("Could not create an internal object\n");
337 return;
338 }
339
340 /* Store the new object into the target */
341
342 switch (Type)
343 {
344 case 'A':
345
346 /* Set a method argument */
347
348 if (Index > ACPI_METHOD_MAX_ARG)
349 {
350 AcpiOsPrintf ("Arg%u - Invalid argument name\n",
351 Index);
352 goto Cleanup;
353 }
354
355 Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG,
356 Index, ObjDesc, WalkState);
357 if (ACPI_FAILURE (Status))
358 {
359 goto Cleanup;
360 }
361
362 ObjDesc = WalkState->Arguments[Index].Object;
363
364 AcpiOsPrintf ("Arg%u: ", Index);
365 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
366 break;
367
368 case 'L':
369
370 /* Set a method local */
371
372 if (Index > ACPI_METHOD_MAX_LOCAL)
373 {
374 AcpiOsPrintf ("Local%u - Invalid local variable name\n",
375 Index);
376 goto Cleanup;
377 }
378
379 Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL,
380 Index, ObjDesc, WalkState);
381 if (ACPI_FAILURE (Status))
382 {
383 goto Cleanup;
384 }
385
386 ObjDesc = WalkState->LocalVariables[Index].Object;
387
388 AcpiOsPrintf ("Local%u: ", Index);
389 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
390 break;
391
392 default:
393
394 break;
395 }
396
397 Cleanup:
398 AcpiUtRemoveReference (ObjDesc);
399 }
400
401
402 #ifdef ACPI_DISASSEMBLER
403 /*******************************************************************************
404 *
405 * FUNCTION: AcpiDbDisassembleAml
406 *
407 * PARAMETERS: Statements - Number of statements to disassemble
408 * Op - Current Op (from parse walk)
409 *
410 * RETURN: None
411 *
412 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
413 * of statements specified.
414 *
415 ******************************************************************************/
416
417 void
AcpiDbDisassembleAml(char * Statements,ACPI_PARSE_OBJECT * Op)418 AcpiDbDisassembleAml (
419 char *Statements,
420 ACPI_PARSE_OBJECT *Op)
421 {
422 UINT32 NumStatements = 8;
423
424
425 if (!Op)
426 {
427 AcpiOsPrintf ("There is no method currently executing\n");
428 return;
429 }
430
431 if (Statements)
432 {
433 NumStatements = strtoul (Statements, NULL, 0);
434 }
435
436 AcpiDmDisassemble (NULL, Op, NumStatements);
437 }
438
439
440 /*******************************************************************************
441 *
442 * FUNCTION: AcpiDbDisassembleMethod
443 *
444 * PARAMETERS: Name - Name of control method
445 *
446 * RETURN: None
447 *
448 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
449 * of statements specified.
450 *
451 ******************************************************************************/
452
453 ACPI_STATUS
AcpiDbDisassembleMethod(char * Name)454 AcpiDbDisassembleMethod (
455 char *Name)
456 {
457 ACPI_STATUS Status;
458 ACPI_PARSE_OBJECT *Op;
459 ACPI_WALK_STATE *WalkState;
460 ACPI_OPERAND_OBJECT *ObjDesc;
461 ACPI_NAMESPACE_NODE *Method;
462
463
464 Method = AcpiDbConvertToNode (Name);
465 if (!Method)
466 {
467 return (AE_BAD_PARAMETER);
468 }
469
470 if (Method->Type != ACPI_TYPE_METHOD)
471 {
472 ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method",
473 Name, AcpiUtGetTypeName (Method->Type)));
474 return (AE_BAD_PARAMETER);
475 }
476
477 ObjDesc = Method->Object;
478
479 Op = AcpiPsCreateScopeOp (ObjDesc->Method.AmlStart);
480 if (!Op)
481 {
482 return (AE_NO_MEMORY);
483 }
484
485 /* Create and initialize a new walk state */
486
487 WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
488 if (!WalkState)
489 {
490 return (AE_NO_MEMORY);
491 }
492
493 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
494 ObjDesc->Method.AmlStart,
495 ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
496 if (ACPI_FAILURE (Status))
497 {
498 return (Status);
499 }
500
501 Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
502 if (ACPI_FAILURE(Status))
503 {
504 return (Status);
505 }
506
507 WalkState->OwnerId = ObjDesc->Method.OwnerId;
508
509 /* Push start scope on scope stack and make it current */
510
511 Status = AcpiDsScopeStackPush (Method,
512 Method->Type, WalkState);
513 if (ACPI_FAILURE (Status))
514 {
515 return (Status);
516 }
517
518 /* Parse the entire method AML including deferred operators */
519
520 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
521 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
522
523 Status = AcpiPsParseAml (WalkState);
524 if (ACPI_FAILURE(Status))
525 {
526 return (Status);
527 }
528
529 (void) AcpiDmParseDeferredOps (Op);
530
531 /* Now we can disassemble the method */
532
533 AcpiGbl_DmOpt_Verbose = FALSE;
534 AcpiDmDisassemble (NULL, Op, 0);
535 AcpiGbl_DmOpt_Verbose = TRUE;
536
537 AcpiPsDeleteParseTree (Op);
538
539 /* Method cleanup */
540
541 AcpiNsDeleteNamespaceSubtree (Method);
542 AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId);
543 AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
544 return (AE_OK);
545 }
546 #endif
547
548
549 /*******************************************************************************
550 *
551 * FUNCTION: AcpiDbEvaluateObject
552 *
553 * PARAMETERS: Node - Namespace node for the object
554 *
555 * RETURN: Status
556 *
557 * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
558 * commands.
559 *
560 ******************************************************************************/
561
562 static ACPI_STATUS
AcpiDbEvaluateObject(ACPI_NAMESPACE_NODE * Node)563 AcpiDbEvaluateObject (
564 ACPI_NAMESPACE_NODE *Node)
565 {
566 char *Pathname;
567 UINT32 i;
568 ACPI_DEVICE_INFO *ObjInfo;
569 ACPI_OBJECT_LIST ParamObjects;
570 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
571 ACPI_BUFFER ReturnObj;
572 ACPI_STATUS Status;
573
574
575 Pathname = AcpiNsGetExternalPathname (Node);
576 if (!Pathname)
577 {
578 return (AE_OK);
579 }
580
581 /* Get the object info for number of method parameters */
582
583 Status = AcpiGetObjectInfo (Node, &ObjInfo);
584 if (ACPI_FAILURE (Status))
585 {
586 ACPI_FREE (Pathname);
587 return (Status);
588 }
589
590 ParamObjects.Pointer = NULL;
591 ParamObjects.Count = 0;
592
593 if (ObjInfo->Type == ACPI_TYPE_METHOD)
594 {
595 /* Setup default parameters */
596
597 for (i = 0; i < ObjInfo->ParamCount; i++)
598 {
599 Params[i].Type = ACPI_TYPE_INTEGER;
600 Params[i].Integer.Value = 1;
601 }
602
603 ParamObjects.Pointer = Params;
604 ParamObjects.Count = ObjInfo->ParamCount;
605 }
606
607 ACPI_FREE (ObjInfo);
608 ReturnObj.Pointer = NULL;
609 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
610
611 /* Do the actual method execution */
612
613 AcpiGbl_MethodExecuting = TRUE;
614
615 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
616 AcpiGbl_MethodExecuting = FALSE;
617
618 AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
619 if (ReturnObj.Length)
620 {
621 AcpiOsPrintf ("Evaluation of %s returned object %p, "
622 "external buffer length %X\n",
623 Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length);
624
625 AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
626 AcpiOsPrintf ("\n");
627 }
628
629 ACPI_FREE (Pathname);
630
631 /* Ignore status from method execution */
632
633 return (AE_OK);
634
635 /* Update count, check if we have executed enough methods */
636
637 }
638
639 /*******************************************************************************
640 *
641 * FUNCTION: AcpiDbWalkForExecute
642 *
643 * PARAMETERS: Callback from WalkNamespace
644 *
645 * RETURN: Status
646 *
647 * DESCRIPTION: Batch execution function. Evaluates all "predefined" objects --
648 * the nameseg begins with an underscore.
649 *
650 ******************************************************************************/
651
652 static ACPI_STATUS
AcpiDbWalkForExecute(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)653 AcpiDbWalkForExecute (
654 ACPI_HANDLE ObjHandle,
655 UINT32 NestingLevel,
656 void *Context,
657 void **ReturnValue)
658 {
659 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
660 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
661 ACPI_STATUS Status;
662 const ACPI_PREDEFINED_INFO *Predefined;
663
664
665 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
666 if (!Predefined)
667 {
668 return (AE_OK);
669 }
670
671 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
672 {
673 return (AE_OK);
674 }
675
676 AcpiDbEvaluateObject (Node);
677
678 /* Ignore status from object evaluation */
679
680 Status = AE_OK;
681
682 /* Update count, check if we have executed enough methods */
683
684 Info->Count++;
685 if (Info->Count >= Info->MaxCount)
686 {
687 Status = AE_CTRL_TERMINATE;
688 }
689
690 return (Status);
691 }
692
693
694 /*******************************************************************************
695 *
696 * FUNCTION: AcpiDbWalkForExecuteAll
697 *
698 * PARAMETERS: Callback from WalkNamespace
699 *
700 * RETURN: Status
701 *
702 * DESCRIPTION: Batch execution function. Evaluates all objects whose path ends
703 * with the nameseg "Info->NameSeg". Used for the "ALL" command.
704 *
705 ******************************************************************************/
706
707 static ACPI_STATUS
AcpiDbWalkForExecuteAll(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)708 AcpiDbWalkForExecuteAll (
709 ACPI_HANDLE ObjHandle,
710 UINT32 NestingLevel,
711 void *Context,
712 void **ReturnValue)
713 {
714 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
715 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
716 ACPI_STATUS Status;
717
718
719 if (!ACPI_COMPARE_NAMESEG (Node->Name.Ascii, Info->NameSeg))
720 {
721 return (AE_OK);
722 }
723
724 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
725 {
726 return (AE_OK);
727 }
728
729 /* Now evaluate the input object (node) */
730
731 AcpiDbEvaluateObject (Node);
732
733 /* Ignore status from method execution */
734
735 Status = AE_OK;
736
737 /* Update count of executed methods/objects */
738
739 Info->Count++;
740 return (Status);
741 }
742
743
744 /*******************************************************************************
745 *
746 * FUNCTION: AcpiDbEvaluatePredefinedNames
747 *
748 * PARAMETERS: None
749 *
750 * RETURN: None
751 *
752 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
753 * namespace, up to the max count, if specified.
754 *
755 ******************************************************************************/
756
757 void
AcpiDbEvaluatePredefinedNames(void)758 AcpiDbEvaluatePredefinedNames (
759 void)
760 {
761 ACPI_DB_EXECUTE_WALK Info;
762
763
764 Info.Count = 0;
765 Info.MaxCount = ACPI_UINT32_MAX;
766
767 /* Search all nodes in namespace */
768
769 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
770 AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
771
772 AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
773 }
774
775
776 /*******************************************************************************
777 *
778 * FUNCTION: AcpiDbEvaluateAll
779 *
780 * PARAMETERS: NoneAcpiGbl_DbMethodInfo
781 *
782 * RETURN: None
783 *
784 * DESCRIPTION: Namespace batch execution. Implements the "ALL" command.
785 * Execute all namepaths whose final nameseg matches the
786 * input nameseg.
787 *
788 ******************************************************************************/
789
790 void
AcpiDbEvaluateAll(char * NameSeg)791 AcpiDbEvaluateAll (
792 char *NameSeg)
793 {
794 ACPI_DB_EXECUTE_WALK Info;
795
796
797 Info.Count = 0;
798 Info.MaxCount = ACPI_UINT32_MAX;
799 ACPI_COPY_NAMESEG (Info.NameSeg, NameSeg);
800 Info.NameSeg[ACPI_NAMESEG_SIZE] = 0;
801
802 /* Search all nodes in namespace */
803
804 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
805 AcpiDbWalkForExecuteAll, NULL, (void *) &Info, NULL);
806
807 AcpiOsPrintf ("Evaluated %u names in the namespace\n", Info.Count);
808 }
809
810 #endif /* ACPI_DEBUGGER */
811