xref: /freebsd/sys/contrib/dev/acpica/compiler/aslpredef.c (revision bb15ca603fa442c72dde3f3cb8b46db6970e3950)
1 /******************************************************************************
2  *
3  * Module Name: aslpredef - support for ACPI predefined names
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #define ACPI_CREATE_PREDEFINED_TABLE
45 
46 #include <contrib/dev/acpica/compiler/aslcompiler.h>
47 #include "aslcompiler.y.h"
48 #include <contrib/dev/acpica/include/acpredef.h>
49 
50 
51 #define _COMPONENT          ACPI_COMPILER
52         ACPI_MODULE_NAME    ("aslpredef")
53 
54 
55 /* Local prototypes */
56 
57 static void
58 ApCheckForUnexpectedReturnValue (
59     ACPI_PARSE_OBJECT       *Op,
60     ASL_METHOD_INFO         *MethodInfo);
61 
62 static UINT32
63 ApCheckForSpecialName (
64     ACPI_PARSE_OBJECT       *Op,
65     char                    *Name);
66 
67 static void
68 ApCheckObjectType (
69     ACPI_PARSE_OBJECT       *Op,
70     UINT32                  ExpectedBtypes);
71 
72 static void
73 ApGetExpectedTypes (
74     char                    *Buffer,
75     UINT32                  ExpectedBtypes);
76 
77 
78 /*
79  * Names for the types that can be returned by the predefined objects.
80  * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
81  */
82 static const char   *AcpiRtypeNames[] =
83 {
84     "/Integer",
85     "/String",
86     "/Buffer",
87     "/Package",
88     "/Reference",
89 };
90 
91 /*
92  * Predefined names for use in Resource Descriptors. These names do not
93  * appear in the global Predefined Name table (since these names never
94  * appear in actual AML byte code, only in the original ASL)
95  */
96 static const ACPI_PREDEFINED_INFO      ResourceNames[] = {
97     {{"_ALN",     0,      0}},
98     {{"_ASI",     0,      0}},
99     {{"_ASZ",     0,      0}},
100     {{"_ATT",     0,      0}},
101     {{"_BAS",     0,      0}},
102     {{"_BM_",     0,      0}},
103     {{"_DBT",     0,      0}},  /* Acpi 5.0 */
104     {{"_DEC",     0,      0}},
105     {{"_DPL",     0,      0}},  /* Acpi 5.0 */
106     {{"_DRS",     0,      0}},  /* Acpi 5.0 */
107     {{"_END",     0,      0}},  /* Acpi 5.0 */
108     {{"_FLC",     0,      0}},  /* Acpi 5.0 */
109     {{"_GRA",     0,      0}},
110     {{"_HE_",     0,      0}},
111     {{"_INT",     0,      0}},
112     {{"_IOR",     0,      0}},  /* Acpi 5.0 */
113     {{"_LEN",     0,      0}},
114     {{"_LIN",     0,      0}},  /* Acpi 5.0 */
115     {{"_LL_",     0,      0}},
116     {{"_MAF",     0,      0}},
117     {{"_MAX",     0,      0}},
118     {{"_MEM",     0,      0}},
119     {{"_MIF",     0,      0}},
120     {{"_MIN",     0,      0}},
121     {{"_MOD",     0,      0}},  /* Acpi 5.0 */
122     {{"_MTP",     0,      0}},
123     {{"_PAR",     0,      0}},  /* Acpi 5.0 */
124     {{"_PHA",     0,      0}},  /* Acpi 5.0 */
125     {{"_PIN",     0,      0}},  /* Acpi 5.0 */
126     {{"_PPI",     0,      0}},  /* Acpi 5.0 */
127     {{"_POL",     0,      0}},  /* Acpi 5.0 */
128     {{"_RBO",     0,      0}},
129     {{"_RBW",     0,      0}},
130     {{"_RNG",     0,      0}},
131     {{"_RT_",     0,      0}},  /* Acpi 3.0 */
132     {{"_RW_",     0,      0}},
133     {{"_RXL",     0,      0}},  /* Acpi 5.0 */
134     {{"_SHR",     0,      0}},
135     {{"_SIZ",     0,      0}},
136     {{"_SLV",     0,      0}},  /* Acpi 5.0 */
137     {{"_SPE",     0,      0}},  /* Acpi 5.0 */
138     {{"_STB",     0,      0}},  /* Acpi 5.0 */
139     {{"_TRA",     0,      0}},
140     {{"_TRS",     0,      0}},
141     {{"_TSF",     0,      0}},  /* Acpi 3.0 */
142     {{"_TTP",     0,      0}},
143     {{"_TXL",     0,      0}},  /* Acpi 5.0 */
144     {{"_TYP",     0,      0}},
145     {{"_VEN",     0,      0}},  /* Acpi 5.0 */
146     {{{0,0,0,0},  0,      0}}   /* Table terminator */
147 };
148 
149 static const ACPI_PREDEFINED_INFO      ScopeNames[] = {
150     {{"_SB_",     0,      0}},
151     {{"_SI_",     0,      0}},
152     {{"_TZ_",     0,      0}},
153     {{{0,0,0,0},  0,      0}}   /* Table terminator */
154 };
155 
156 
157 /*******************************************************************************
158  *
159  * FUNCTION:    ApCheckForPredefinedMethod
160  *
161  * PARAMETERS:  Op              - A parse node of type "METHOD".
162  *              MethodInfo      - Saved info about this method
163  *
164  * RETURN:      None
165  *
166  * DESCRIPTION: If method is a predefined name, check that the number of
167  *              arguments and the return type (returns a value or not)
168  *              is correct.
169  *
170  ******************************************************************************/
171 
172 BOOLEAN
173 ApCheckForPredefinedMethod (
174     ACPI_PARSE_OBJECT       *Op,
175     ASL_METHOD_INFO         *MethodInfo)
176 {
177     UINT32                  Index;
178     UINT32                  RequiredArgsCurrent;
179     UINT32                  RequiredArgsOld;
180 
181 
182     /* Check for a match against the predefined name list */
183 
184     Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
185 
186     switch (Index)
187     {
188     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
189     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
190     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
191 
192         /* Just return, nothing to do */
193         return (FALSE);
194 
195 
196     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
197 
198         Gbl_ReservedMethods++;
199 
200         /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */
201 
202         if (MethodInfo->NumArguments != 0)
203         {
204             sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, 0);
205 
206             AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
207                 MsgBuffer);
208         }
209         break;
210 
211 
212     default:
213         /*
214          * Matched a predefined method name
215          *
216          * Validate the ASL-defined argument count. Allow two different legal
217          * arg counts.
218          */
219         Gbl_ReservedMethods++;
220 
221         RequiredArgsCurrent = PredefinedNames[Index].Info.ParamCount & 0x0F;
222         RequiredArgsOld = PredefinedNames[Index].Info.ParamCount >> 4;
223 
224         if ((MethodInfo->NumArguments != RequiredArgsCurrent) &&
225             (MethodInfo->NumArguments != RequiredArgsOld))
226         {
227             sprintf (MsgBuffer, "%4.4s requires %u",
228                 PredefinedNames[Index].Info.Name, RequiredArgsCurrent);
229 
230             if (MethodInfo->NumArguments > RequiredArgsCurrent)
231             {
232                 AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
233                     MsgBuffer);
234             }
235             else
236             {
237                 AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
238                     MsgBuffer);
239             }
240         }
241 
242         /*
243          * Check if method returns no value, but the predefined name is
244          * required to return a value
245          */
246         if (MethodInfo->NumReturnNoValue &&
247             PredefinedNames[Index].Info.ExpectedBtypes)
248         {
249             ApGetExpectedTypes (StringBuffer,
250                 PredefinedNames[Index].Info.ExpectedBtypes);
251 
252             sprintf (MsgBuffer, "%s required for %4.4s",
253                 StringBuffer, PredefinedNames[Index].Info.Name);
254 
255             AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
256                 MsgBuffer);
257         }
258         break;
259     }
260 
261     return (TRUE);
262 }
263 
264 
265 /*******************************************************************************
266  *
267  * FUNCTION:    ApCheckForUnexpectedReturnValue
268  *
269  * PARAMETERS:  Op              - A parse node of type "RETURN".
270  *              MethodInfo      - Saved info about this method
271  *
272  * RETURN:      None
273  *
274  * DESCRIPTION: Check for an unexpected return value from a predefined method.
275  *              Invoked for predefined methods that are defined to not return
276  *              any value. If there is a return value, issue a remark, since
277  *              the ASL writer may be confused as to the method definition
278  *              and/or functionality.
279  *
280  * Note: We ignore all return values of "Zero", since this is what a standalone
281  *       Return() statement will always generate -- so we ignore it here --
282  *       i.e., there is no difference between Return() and Return(Zero).
283  *       Also, a null Return() will be disassembled to return(Zero) -- so, we
284  *       don't want to generate extraneous remarks/warnings for a disassembled
285  *       ASL file.
286  *
287  ******************************************************************************/
288 
289 static void
290 ApCheckForUnexpectedReturnValue (
291     ACPI_PARSE_OBJECT       *Op,
292     ASL_METHOD_INFO         *MethodInfo)
293 {
294     ACPI_PARSE_OBJECT       *ReturnValueOp;
295 
296 
297     /* Ignore Return() and Return(Zero) (they are the same) */
298 
299     ReturnValueOp = Op->Asl.Child;
300     if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
301     {
302         return;
303     }
304 
305     /* We have a valid return value, but the reserved name did not expect it */
306 
307     AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
308         Op, MethodInfo->Op->Asl.ExternalName);
309 }
310 
311 
312 /*******************************************************************************
313  *
314  * FUNCTION:    ApCheckPredefinedReturnValue
315  *
316  * PARAMETERS:  Op              - A parse node of type "RETURN".
317  *              MethodInfo      - Saved info about this method
318  *
319  * RETURN:      None
320  *
321  * DESCRIPTION: If method is a predefined name, attempt to validate the return
322  *              value. Only "static" types can be validated - a simple return
323  *              of an integer/string/buffer/package or a named reference to
324  *              a static object. Values such as a Localx or Argx or a control
325  *              method invocation are not checked. Issue a warning if there is
326  *              a valid return value, but the reserved method defines no
327  *              return value.
328  *
329  ******************************************************************************/
330 
331 void
332 ApCheckPredefinedReturnValue (
333     ACPI_PARSE_OBJECT       *Op,
334     ASL_METHOD_INFO         *MethodInfo)
335 {
336     UINT32                  Index;
337     ACPI_PARSE_OBJECT       *ReturnValueOp;
338 
339 
340     /* Check parent method for a match against the predefined name list */
341 
342     Index = ApCheckForPredefinedName (MethodInfo->Op,
343                 MethodInfo->Op->Asl.NameSeg);
344 
345     switch (Index)
346     {
347     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
348 
349         /* No return value expected, warn if there is one */
350 
351         ApCheckForUnexpectedReturnValue (Op, MethodInfo);
352         return;
353 
354     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
355     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
356     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
357 
358         /* Just return, nothing to do */
359         return;
360 
361     default: /* A standard predefined ACPI name */
362 
363         if (!PredefinedNames[Index].Info.ExpectedBtypes)
364         {
365             /* No return value expected, warn if there is one */
366 
367             ApCheckForUnexpectedReturnValue (Op, MethodInfo);
368             return;
369         }
370 
371         /* Get the object returned, it is the next argument */
372 
373         ReturnValueOp = Op->Asl.Child;
374         switch (ReturnValueOp->Asl.ParseOpcode)
375         {
376         case PARSEOP_ZERO:
377         case PARSEOP_ONE:
378         case PARSEOP_ONES:
379         case PARSEOP_INTEGER:
380         case PARSEOP_STRING_LITERAL:
381         case PARSEOP_BUFFER:
382         case PARSEOP_PACKAGE:
383 
384             /* Static data return object - check against expected type */
385 
386             ApCheckObjectType (ReturnValueOp,
387                 PredefinedNames[Index].Info.ExpectedBtypes);
388             break;
389 
390         default:
391 
392             /*
393              * All other ops are very difficult or impossible to typecheck at
394              * compile time. These include all Localx, Argx, and method
395              * invocations. Also, NAMESEG and NAMESTRING because the type of
396              * any named object can be changed at runtime (for example,
397              * CopyObject will change the type of the target object.)
398              */
399             break;
400         }
401     }
402 }
403 
404 
405 /*******************************************************************************
406  *
407  * FUNCTION:    ApCheckForPredefinedObject
408  *
409  * PARAMETERS:  Op              - A parse node
410  *              Name            - The ACPI name to be checked
411  *
412  * RETURN:      None
413  *
414  * DESCRIPTION: Check for a predefined name for a static object (created via
415  *              the ASL Name operator). If it is a predefined ACPI name, ensure
416  *              that the name does not require any arguments (which would
417  *              require a control method implemenation of the name), and that
418  *              the type of the object is one of the expected types for the
419  *              predefined name.
420  *
421  ******************************************************************************/
422 
423 void
424 ApCheckForPredefinedObject (
425     ACPI_PARSE_OBJECT       *Op,
426     char                    *Name)
427 {
428     UINT32                  Index;
429 
430 
431     /*
432      * Check for a real predefined name -- not a resource descriptor name
433      * or a predefined scope name
434      */
435     Index = ApCheckForPredefinedName (Op, Name);
436 
437     switch (Index)
438     {
439     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
440     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
441     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
442 
443         /* Nothing to do */
444         return;
445 
446     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
447 
448         /*
449          * These names must be control methods, by definition in ACPI spec.
450          * Also because they are defined to return no value. None of them
451          * require any arguments.
452          */
453         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
454             "with zero arguments");
455         return;
456 
457     default: /* A standard predefined ACPI name */
458 
459         /*
460          * If this predefined name requires input arguments, then
461          * it must be implemented as a control method
462          */
463         if (PredefinedNames[Index].Info.ParamCount > 0)
464         {
465             AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
466                 "with arguments");
467             return;
468         }
469 
470         /*
471          * If no return value is expected from this predefined name, then
472          * it follows that it must be implemented as a control method
473          * (with zero args, because the args > 0 case was handled above)
474          * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx
475          */
476         if (!PredefinedNames[Index].Info.ExpectedBtypes)
477         {
478             AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
479                 "with zero arguments");
480             return;
481         }
482 
483         /* Typecheck the actual object, it is the next argument */
484 
485         ApCheckObjectType (Op->Asl.Child->Asl.Next,
486             PredefinedNames[Index].Info.ExpectedBtypes);
487         return;
488     }
489 }
490 
491 
492 /*******************************************************************************
493  *
494  * FUNCTION:    ApCheckForPredefinedName
495  *
496  * PARAMETERS:  Op              - A parse node
497  *              Name            - NameSeg to check
498  *
499  * RETURN:      None
500  *
501  * DESCRIPTION: Check a NameSeg against the reserved list.
502  *
503  ******************************************************************************/
504 
505 UINT32
506 ApCheckForPredefinedName (
507     ACPI_PARSE_OBJECT       *Op,
508     char                    *Name)
509 {
510     UINT32                  i;
511 
512 
513     if (Name[0] == 0)
514     {
515         AcpiOsPrintf ("Found a null name, external = %s\n",
516             Op->Asl.ExternalName);
517     }
518 
519     /* All reserved names are prefixed with a single underscore */
520 
521     if (Name[0] != '_')
522     {
523         return (ACPI_NOT_RESERVED_NAME);
524     }
525 
526     /* Check for a standard predefined method name */
527 
528     for (i = 0; PredefinedNames[i].Info.Name[0]; i++)
529     {
530         if (ACPI_COMPARE_NAME (Name, PredefinedNames[i].Info.Name))
531         {
532             /* Return index into predefined array */
533             return (i);
534         }
535     }
536 
537     /* Check for resource names and predefined scope names */
538 
539     for (i = 0; ResourceNames[i].Info.Name[0]; i++)
540     {
541         if (ACPI_COMPARE_NAME (Name, ResourceNames[i].Info.Name))
542         {
543             return (ACPI_PREDEFINED_NAME);
544         }
545     }
546 
547     for (i = 0; ScopeNames[i].Info.Name[0]; i++)
548     {
549         if (ACPI_COMPARE_NAME (Name, ScopeNames[i].Info.Name))
550         {
551             return (ACPI_PREDEFINED_NAME);
552         }
553     }
554 
555     /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */
556 
557     return (ApCheckForSpecialName (Op, Name));
558 }
559 
560 
561 /*******************************************************************************
562  *
563  * FUNCTION:    ApCheckForSpecialName
564  *
565  * PARAMETERS:  Op              - A parse node
566  *              Name            - NameSeg to check
567  *
568  * RETURN:      None
569  *
570  * DESCRIPTION: Check for the "special" predefined names -
571  *              _Lxx, _Exx, _Qxx, _Wxx, and _T_x
572  *
573  ******************************************************************************/
574 
575 static UINT32
576 ApCheckForSpecialName (
577     ACPI_PARSE_OBJECT       *Op,
578     char                    *Name)
579 {
580 
581     /*
582      * Check for the "special" predefined names. We already know that the
583      * first character is an underscore.
584      *   GPE:  _Lxx
585      *   GPE:  _Exx
586      *   GPE:  _Wxx
587      *   EC:   _Qxx
588      */
589     if ((Name[1] == 'L') ||
590         (Name[1] == 'E') ||
591         (Name[1] == 'W') ||
592         (Name[1] == 'Q'))
593     {
594         /* The next two characters must be hex digits */
595 
596         if ((isxdigit ((int) Name[2])) &&
597             (isxdigit ((int) Name[3])))
598         {
599             return (ACPI_EVENT_RESERVED_NAME);
600         }
601     }
602 
603     /* Check for the names reserved for the compiler itself: _T_x */
604 
605     else if ((Op->Asl.ExternalName[1] == 'T') &&
606              (Op->Asl.ExternalName[2] == '_'))
607     {
608         /* Ignore if actually emitted by the compiler */
609 
610         if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED)
611         {
612             return (ACPI_NOT_RESERVED_NAME);
613         }
614 
615         /*
616          * Was not actually emitted by the compiler. This is a special case,
617          * however. If the ASL code being compiled was the result of a
618          * dissasembly, it may possibly contain valid compiler-emitted names
619          * of the form "_T_x". We don't want to issue an error or even a
620          * warning and force the user to manually change the names. So, we
621          * will issue a remark instead.
622          */
623         AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName);
624         return (ACPI_COMPILER_RESERVED_NAME);
625     }
626 
627     /*
628      * The name didn't match any of the known predefined names. Flag it as a
629      * warning, since the entire namespace starting with an underscore is
630      * reserved by the ACPI spec.
631      */
632     AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op,
633         Op->Asl.ExternalName);
634 
635     return (ACPI_NOT_RESERVED_NAME);
636 }
637 
638 
639 /*******************************************************************************
640  *
641  * FUNCTION:    ApCheckObjectType
642  *
643  * PARAMETERS:  Op              - Current parse node
644  *              ExpectedBtypes  - Bitmap of expected return type(s)
645  *
646  * RETURN:      None
647  *
648  * DESCRIPTION: Check if the object type is one of the types that is expected
649  *              by the predefined name. Only a limited number of object types
650  *              can be returned by the predefined names.
651  *
652  ******************************************************************************/
653 
654 static void
655 ApCheckObjectType (
656     ACPI_PARSE_OBJECT       *Op,
657     UINT32                  ExpectedBtypes)
658 {
659     UINT32                  ReturnBtype;
660 
661 
662     switch (Op->Asl.ParseOpcode)
663     {
664     case PARSEOP_ZERO:
665     case PARSEOP_ONE:
666     case PARSEOP_ONES:
667     case PARSEOP_INTEGER:
668         ReturnBtype = ACPI_RTYPE_INTEGER;
669         break;
670 
671     case PARSEOP_BUFFER:
672         ReturnBtype = ACPI_RTYPE_BUFFER;
673         break;
674 
675     case PARSEOP_STRING_LITERAL:
676         ReturnBtype = ACPI_RTYPE_STRING;
677         break;
678 
679     case PARSEOP_PACKAGE:
680     case PARSEOP_VAR_PACKAGE:
681         ReturnBtype = ACPI_RTYPE_PACKAGE;
682         break;
683 
684     default:
685         /* Not one of the supported object types */
686 
687         goto TypeErrorExit;
688     }
689 
690     /* Exit if the object is one of the expected types */
691 
692     if (ReturnBtype & ExpectedBtypes)
693     {
694         return;
695     }
696 
697 
698 TypeErrorExit:
699 
700     /* Format the expected types and emit an error message */
701 
702     ApGetExpectedTypes (StringBuffer, ExpectedBtypes);
703 
704     sprintf (MsgBuffer, "found %s, requires %s",
705         UtGetOpName (Op->Asl.ParseOpcode), StringBuffer);
706 
707     AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op,
708         MsgBuffer);
709 }
710 
711 
712 /*******************************************************************************
713  *
714  * FUNCTION:    ApDisplayReservedNames
715  *
716  * PARAMETERS:  None
717  *
718  * RETURN:      None
719  *
720  * DESCRIPTION: Dump information about the ACPI predefined names and predefined
721  *              resource descriptor names.
722  *
723  ******************************************************************************/
724 
725 void
726 ApDisplayReservedNames (
727     void)
728 {
729     const ACPI_PREDEFINED_INFO  *ThisName;
730     char                        TypeBuffer[48]; /* Room for 5 types */
731     UINT32                      Count;
732 
733 
734     /*
735      * Predefined names/methods
736      */
737     printf ("\nPredefined Name Information\n\n");
738 
739     Count = 0;
740     ThisName = PredefinedNames;
741     while (ThisName->Info.Name[0])
742     {
743         printf ("%4.4s    Requires %u arguments, ",
744             ThisName->Info.Name, ThisName->Info.ParamCount & 0x0F);
745 
746         if (ThisName->Info.ExpectedBtypes)
747         {
748             ApGetExpectedTypes (TypeBuffer, ThisName->Info.ExpectedBtypes);
749             printf ("Must return: %s\n", TypeBuffer);
750         }
751         else
752         {
753             printf ("No return value\n");
754         }
755 
756         /*
757          * Skip next entry in the table if this name returns a Package
758          * (next entry contains the package info)
759          */
760         if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
761         {
762             ThisName++;
763         }
764 
765         Count++;
766         ThisName++;
767     }
768 
769     printf ("%u Predefined Names are recognized\n", Count);
770 
771     /*
772      * Resource Descriptor names
773      */
774     printf ("\nResource Descriptor Predefined Names\n\n");
775 
776     Count = 0;
777     ThisName = ResourceNames;
778     while (ThisName->Info.Name[0])
779     {
780         printf ("%4.4s    Resource Descriptor\n", ThisName->Info.Name);
781         Count++;
782         ThisName++;
783     }
784 
785     printf ("%u Resource Descriptor Names are recognized\n", Count);
786 
787     /*
788      * Predefined scope names
789      */
790     printf ("\nPredefined Scope Names\n\n");
791 
792     ThisName = ScopeNames;
793     while (ThisName->Info.Name[0])
794     {
795         printf ("%4.4s    Scope\n", ThisName->Info.Name);
796         ThisName++;
797     }
798 }
799 
800 
801 /*******************************************************************************
802  *
803  * FUNCTION:    ApGetExpectedTypes
804  *
805  * PARAMETERS:  Buffer              - Where the formatted string is returned
806  *              ExpectedBTypes      - Bitfield of expected data types
807  *
808  * RETURN:      None, formatted string
809  *
810  * DESCRIPTION: Format the expected object types into a printable string.
811  *
812  ******************************************************************************/
813 
814 static void
815 ApGetExpectedTypes (
816     char                        *Buffer,
817     UINT32                      ExpectedBtypes)
818 {
819     UINT32                      ThisRtype;
820     UINT32                      i;
821     UINT32                      j;
822 
823 
824     j = 1;
825     Buffer[0] = 0;
826     ThisRtype = ACPI_RTYPE_INTEGER;
827 
828     for (i = 0; i < ACPI_NUM_RTYPES; i++)
829     {
830         /* If one of the expected types, concatenate the name of this type */
831 
832         if (ExpectedBtypes & ThisRtype)
833         {
834             ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]);
835             j = 0;              /* Use name separator from now on */
836         }
837         ThisRtype <<= 1;    /* Next Rtype */
838     }
839 }
840