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