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