xref: /freebsd/sys/contrib/dev/acpica/common/dmswitch.c (revision 8bab661a3316d8bd9b9fbd11a3b4371b91507bd2)
1 /******************************************************************************
2  *
3  * Module Name: adwalk - Disassembler routines for switch statements
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2022, 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 <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acparser.h>
155 #include <contrib/dev/acpica/include/amlcode.h>
156 #include <contrib/dev/acpica/include/acdisasm.h>
157 #include <contrib/dev/acpica/include/acdispat.h>
158 #include <contrib/dev/acpica/include/acnamesp.h>
159 #include <contrib/dev/acpica/include/acapps.h>
160 
161 
162 #define _COMPONENT          ACPI_CA_DISASSEMBLER
163         ACPI_MODULE_NAME    ("dmswitch")
164 
165 static BOOLEAN
166 AcpiDmIsSwitchBlock (
167     ACPI_PARSE_OBJECT       *Op,
168     char                    **Temp);
169 
170 static BOOLEAN
171 AcpiDmIsCaseBlock (
172     ACPI_PARSE_OBJECT       *Op);
173 
174 
175 /*******************************************************************************
176  *
177  * FUNCTION:    AcpiDmProcessSwitch
178  *
179  * PARAMETERS:  Op              - Object to be examined
180  *
181  * RETURN:      ACPI_STATUS
182  *
183  * DESCRIPTION: Walk function to create a list of all temporary (_T_) objects.
184  *              If a While loop is found that can be converted to a Switch, do
185  *              the conversion, remove the temporary name from the list, and
186  *              mark the parse op with an IGNORE flag.
187  *
188  ******************************************************************************/
189 
190 ACPI_STATUS
191 AcpiDmProcessSwitch (
192     ACPI_PARSE_OBJECT       *Op)
193 {
194     char                    *Temp = NULL;
195     ACPI_PARSE_OBJECT_LIST  *NewTemp;
196     ACPI_PARSE_OBJECT_LIST  *Current;
197     ACPI_PARSE_OBJECT_LIST  *Previous;
198     BOOLEAN                 FoundTemp = FALSE;
199 
200 
201     switch (Op->Common.AmlOpcode)
202     {
203     case AML_NAME_OP:
204 
205         Temp = (char *) (&Op->Named.Name);
206 
207         if (!strncmp(Temp, "_T_", 3))
208         {
209             /* Allocate and init a new Temp List node */
210 
211             NewTemp = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PARSE_OBJECT_LIST));
212             if (!NewTemp)
213             {
214                 return (AE_NO_MEMORY);
215             }
216 
217             if (AcpiGbl_TempListHead)
218             {
219                 Current = AcpiGbl_TempListHead;
220                 AcpiGbl_TempListHead = NewTemp;
221                 AcpiGbl_TempListHead->Op = Op;
222                 AcpiGbl_TempListHead->Next = Current;
223             }
224             else
225             {
226                 AcpiGbl_TempListHead = NewTemp;
227                 AcpiGbl_TempListHead->Op = Op;
228                 AcpiGbl_TempListHead->Next = NULL;
229             }
230         }
231         break;
232 
233     case AML_WHILE_OP:
234 
235         if (!AcpiDmIsSwitchBlock (Op, &Temp))
236         {
237             break;
238         }
239 
240         /* Found a Switch */
241 
242         Op->Common.DisasmOpcode = ACPI_DASM_SWITCH;
243 
244         Previous = Current = AcpiGbl_TempListHead;
245         while (Current)
246         {
247             /* Note, if we get here Temp is not NULL */
248 
249             if (!strncmp(Temp, (char *) (&Current->Op->Named.Name), 4))
250             {
251                 /* Match found. Ignore disassembly */
252 
253                 Current->Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
254 
255                 /* Remove from list */
256 
257                 if (Current == AcpiGbl_TempListHead)
258                 {
259                     AcpiGbl_TempListHead = Current->Next;
260                 }
261                 else
262                 {
263                     Previous->Next = Current->Next;
264                 }
265 
266                 Current->Op = NULL;
267                 Current->Next = NULL;
268                 ACPI_FREE (Current);
269                 FoundTemp = TRUE;
270                 break;
271             }
272 
273             Previous = Current;
274             Current = Current->Next;
275         }
276 
277         if (!FoundTemp)
278         {
279             fprintf (stderr,
280                 "Warning: Declaration for temp name %.4s not found\n", Temp);
281         }
282         break;
283 
284     default:
285         break;
286     }
287 
288     return (AE_OK);
289 }
290 
291 
292 /*******************************************************************************
293  *
294  * FUNCTION:    AcpiDmClearTempList
295  *
296  * PARAMETERS:  None
297  *
298  * RETURN:      None
299  *
300  * DESCRIPTION: Removes any remaining temporary objects from global list and
301  *              frees
302  *
303  ******************************************************************************/
304 
305 void
306 AcpiDmClearTempList (
307     void)
308 {
309     ACPI_PARSE_OBJECT_LIST      *Current;
310 
311 
312     while (AcpiGbl_TempListHead)
313     {
314         Current = AcpiGbl_TempListHead;
315         AcpiGbl_TempListHead = AcpiGbl_TempListHead->Next;
316         Current->Op = NULL;
317         Current->Next = NULL;
318         ACPI_FREE (Current);
319     }
320 }
321 
322 
323 /*******************************************************************************
324  *
325  * FUNCTION:    AcpiDmIsSwitchBlock
326  *
327  * PARAMETERS:  Op              - While Object
328  *              Temp            - Where the compiler temp name is returned
329  *                                  (_T_x)
330  *
331  * RETURN:      TRUE if While block can be converted to a Switch/Case block
332  *
333  * DESCRIPTION: Determines if While block is a Switch/Case statement. Modifies
334  *              parse tree to allow for Switch/Case disassembly during walk.
335  *
336  * EXAMPLE: Example of parse tree to be converted
337  *
338  *    While
339  *        One
340  *        Store
341  *            ByteConst
342  *             -NamePath-
343  *        If
344  *            LEqual
345  *                -NamePath-
346  *                Zero
347  *            Return
348  *                One
349  *        Else
350  *            Return
351  *                WordConst
352  *        Break
353  *
354  ******************************************************************************/
355 
356 BOOLEAN
357 AcpiDmIsSwitchBlock (
358     ACPI_PARSE_OBJECT       *Op,
359     char                    **Temp)
360 {
361     ACPI_PARSE_OBJECT       *OneOp;
362     ACPI_PARSE_OBJECT       *StoreOp;
363     ACPI_PARSE_OBJECT       *NamePathOp;
364     ACPI_PARSE_OBJECT       *PredicateOp;
365     ACPI_PARSE_OBJECT       *CurrentOp;
366     ACPI_PARSE_OBJECT       *TempOp;
367 
368 
369     /* Check for One Op Predicate */
370 
371     OneOp = AcpiPsGetArg (Op, 0);
372     if (!OneOp || (OneOp->Common.AmlOpcode != AML_ONE_OP))
373     {
374         return (FALSE);
375     }
376 
377     /* Check for Store Op */
378 
379     StoreOp = OneOp->Common.Next;
380     if (!StoreOp || (StoreOp->Common.AmlOpcode != AML_STORE_OP))
381     {
382         return (FALSE);
383     }
384 
385     /* Check for Name Op with _T_ string */
386 
387     NamePathOp = AcpiPsGetArg (StoreOp, 1);
388     if (!NamePathOp ||
389         (NamePathOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
390     {
391         return (FALSE);
392     }
393 
394     if (strncmp ((char *) (NamePathOp->Common.Value.Name), "_T_", 3))
395     {
396         return (FALSE);
397     }
398 
399     *Temp = (char *) (NamePathOp->Common.Value.Name);
400 
401     /* This is a Switch/Case control block */
402 
403     /* Ignore the One Op Predicate */
404 
405     OneOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
406 
407     /* Ignore the Store Op, but not the children */
408 
409     StoreOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
410 
411     /*
412      * First arg of Store Op is the Switch condition.
413      * Mark it as a Switch predicate and as a parameter list for paren
414      * closing and correct indentation.
415      */
416     PredicateOp = AcpiPsGetArg (StoreOp, 0);
417     PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
418     PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
419 
420     /* Ignore the Name Op */
421 
422     NamePathOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
423 
424     /* Remaining opcodes are the Case statements (If/ElseIf's) */
425 
426     CurrentOp = StoreOp->Common.Next;
427     while (AcpiDmIsCaseBlock (CurrentOp))
428     {
429         /* Block is a Case structure */
430 
431         if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
432         {
433             /* ElseIf */
434 
435             CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
436             CurrentOp = AcpiPsGetArg (CurrentOp, 0);
437         }
438 
439         /* If */
440 
441         CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
442 
443         /*
444          * Mark the parse tree for Case disassembly. There are two
445          * types of Case statements. The first type of statement begins with
446          * an LEqual. The second starts with an LNot and uses a Match statement
447          * on a Package of constants.
448          */
449         TempOp = AcpiPsGetArg (CurrentOp, 0);
450         switch (TempOp->Common.AmlOpcode)
451         {
452         case (AML_LOGICAL_EQUAL_OP):
453 
454             /* Ignore just the LEqual Op */
455 
456             TempOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
457 
458             /* Ignore the NamePath Op */
459 
460             TempOp = AcpiPsGetArg (TempOp, 0);
461             TempOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
462 
463             /*
464              * Second arg of LEqual will be the Case predicate.
465              * Mark it as a predicate and also as a parameter list for paren
466              * closing and correct indentation.
467              */
468             PredicateOp = TempOp->Common.Next;
469             PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
470             PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
471             break;
472 
473         case (AML_LOGICAL_NOT_OP):
474 
475             /*
476              * The Package will be the predicate of the Case statement.
477              * It's under:
478              *            LNOT
479              *                LEQUAL
480              *                    MATCH
481              *                        PACKAGE
482              */
483 
484             /* Get the LEqual Op from LNot */
485 
486             TempOp = AcpiPsGetArg (TempOp, 0);
487 
488             /* Get the Match Op from LEqual */
489 
490             TempOp = AcpiPsGetArg (TempOp, 0);
491 
492             /* Get the Package Op from Match */
493 
494             PredicateOp = AcpiPsGetArg (TempOp, 0);
495 
496             /* Mark as parameter list for paren closing */
497 
498             PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
499 
500             /*
501              * The Package list would be too deeply indented if we
502              * chose to simply ignore the all the parent opcodes, so
503              * we rearrange the parse tree instead.
504              */
505 
506             /*
507              * Save the second arg of the If/Else Op which is the
508              * block code of code for this Case statement.
509              */
510             TempOp = AcpiPsGetArg (CurrentOp, 1);
511 
512             /*
513              * Move the Package Op to the child (predicate) of the
514              * Case statement.
515              */
516             CurrentOp->Common.Value.Arg = PredicateOp;
517             PredicateOp->Common.Parent = CurrentOp;
518 
519             /* Add the block code */
520 
521             PredicateOp->Common.Next = TempOp;
522             break;
523 
524         default:
525 
526             /* Should never get here */
527             break;
528         }
529 
530         /* Advance to next Case block */
531 
532         CurrentOp = CurrentOp->Common.Next;
533     }
534 
535     /* If CurrentOp is now an Else, then this is a Default block */
536 
537     if (CurrentOp && CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
538     {
539         CurrentOp->Common.DisasmOpcode = ACPI_DASM_DEFAULT;
540     }
541 
542     /*
543      * From the first If advance to the Break op. It's possible to
544      * have an Else (Default) op here when there is only one Case
545      * statement, so check for it.
546      */
547     CurrentOp = StoreOp->Common.Next->Common.Next;
548     if (!CurrentOp)
549     {
550         return (FALSE);
551     }
552     if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
553     {
554         CurrentOp = CurrentOp->Common.Next;
555         if (!CurrentOp)
556         {
557             return (FALSE);
558         }
559     }
560 
561     /* Ignore the Break Op */
562 
563     CurrentOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
564     return (TRUE);
565 }
566 
567 
568 /*******************************************************************************
569  *
570  * FUNCTION:    AcpiDmIsCaseBlock
571  *
572  * PARAMETERS:  Op              - Object to test
573  *
574  * RETURN:      TRUE if Object is beginning of a Case block.
575  *
576  * DESCRIPTION: Determines if an Object is the beginning of a Case block for a
577  *              Switch/Case statement. Parse tree must be one of the following
578  *              forms:
579  *
580  *              Else (Optional)
581  *                  If
582  *                      LEqual
583  *                          -NamePath- _T_x
584  *
585  *              Else (Optional)
586  *                  If
587  *                      LNot
588  *                          LEqual
589  *                              Match
590  *                                  Package
591  *                                      ByteConst
592  *                                      -NamePath- _T_x
593  *
594  ******************************************************************************/
595 
596 static BOOLEAN
597 AcpiDmIsCaseBlock (
598     ACPI_PARSE_OBJECT       *Op)
599 {
600     ACPI_PARSE_OBJECT       *CurrentOp;
601 
602 
603     if (!Op)
604     {
605         return (FALSE);
606     }
607 
608     /* Look for an If or ElseIf */
609 
610     CurrentOp = Op;
611     if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
612     {
613         CurrentOp = AcpiPsGetArg (CurrentOp, 0);
614         if (!CurrentOp)
615         {
616             return (FALSE);
617         }
618     }
619 
620     if (!CurrentOp || CurrentOp->Common.AmlOpcode != AML_IF_OP)
621     {
622         return (FALSE);
623     }
624 
625     /* Child must be LEqual or LNot */
626 
627     CurrentOp = AcpiPsGetArg (CurrentOp, 0);
628     if (!CurrentOp)
629     {
630         return (FALSE);
631     }
632 
633     switch (CurrentOp->Common.AmlOpcode)
634     {
635     case (AML_LOGICAL_EQUAL_OP):
636 
637         /* Next child must be NamePath with string _T_ */
638 
639         CurrentOp = AcpiPsGetArg (CurrentOp, 0);
640         if (!CurrentOp || !CurrentOp->Common.Value.Name ||
641             strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
642         {
643             return (FALSE);
644         }
645         break;
646 
647     case (AML_LOGICAL_NOT_OP):
648 
649         /* Child of LNot must be LEqual op */
650 
651         CurrentOp = AcpiPsGetArg (CurrentOp, 0);
652         if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LOGICAL_EQUAL_OP))
653         {
654             return (FALSE);
655         }
656 
657         /* Child of LNot must be Match op */
658 
659         CurrentOp = AcpiPsGetArg (CurrentOp, 0);
660         if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_MATCH_OP))
661         {
662             return (FALSE);
663         }
664 
665         /* First child of Match must be Package op */
666 
667         CurrentOp = AcpiPsGetArg (CurrentOp, 0);
668         if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_PACKAGE_OP))
669         {
670             return (FALSE);
671         }
672 
673         /* Third child of Match must be NamePath with string _T_ */
674 
675         CurrentOp = AcpiPsGetArg (CurrentOp->Common.Parent, 2);
676         if (!CurrentOp || !CurrentOp->Common.Value.Name ||
677             strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
678         {
679             return (FALSE);
680         }
681         break;
682 
683     default:
684 
685         return (FALSE);
686     }
687 
688     return (TRUE);
689 }
690