Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | |
2 | * |
||
3 | * Module Name: aslutils -- compiler utilities |
||
4 | * |
||
5 | *****************************************************************************/ |
||
6 | |||
7 | |||
8 | * |
||
9 | * 1. Copyright Notice |
||
10 | * |
||
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
||
2216 | Serge | 12 | * All rights reserved. |
1498 | serge | 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 | |||
117 | |||
118 | #include "aslcompiler.y.h" |
||
119 | #include "acdisasm.h" |
||
2216 | Serge | 120 | #include "acnamesp.h" |
1498 | serge | 121 | #include "amlcode.h" |
122 | #include |
||
2216 | Serge | 123 | |
1498 | serge | 124 | |
125 | ACPI_MODULE_NAME ("aslutils") |
||
126 | |||
127 | |||
2216 | Serge | 128 | { |
1498 | serge | 129 | '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
130 | }; |
||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | UtPadNameWithUnderscores ( |
||
137 | char *NameSeg, |
||
138 | char *PaddedNameSeg); |
||
139 | |||
140 | |||
141 | UtAttachNameseg ( |
||
142 | ACPI_PARSE_OBJECT *Op, |
||
143 | char *Name); |
||
144 | |||
145 | |||
146 | |||
147 | * |
||
148 | * FUNCTION: UtDisplaySupportedTables |
||
2216 | Serge | 149 | * |
150 | * PARAMETERS: None |
||
151 | * |
||
152 | * RETURN: None |
||
153 | * |
||
154 | * DESCRIPTION: Print all supported ACPI table names. |
||
155 | * |
||
156 | ******************************************************************************/ |
||
157 | |||
158 | |||
159 | UtDisplaySupportedTables ( |
||
160 | void) |
||
161 | { |
||
162 | ACPI_DMTABLE_DATA *TableData; |
||
163 | UINT32 i = 6; |
||
164 | |||
165 | |||
166 | |||
167 | "version %8.8X:\n" |
||
168 | " ASL and Data Table compilers\n" |
||
169 | " AML and Data Table disassemblers\n" |
||
170 | " ACPI table template generator\n\n", ACPI_CA_VERSION); |
||
171 | |||
172 | |||
173 | |||
174 | |||
175 | printf ("%8u) %s %s\n", 2, ACPI_SIG_SSDT, "Secondary System Description Table"); |
||
176 | printf ("%8u) %s %s\n", 3, ACPI_SIG_FADT, "Fixed ACPI Description Table (FADT)"); |
||
177 | printf ("%8u) %s %s\n", 4, ACPI_SIG_FACS, "Firmware ACPI Control Structure"); |
||
178 | printf ("%8u) %s %s\n", 5, ACPI_RSDP_NAME, "Root System Description Pointer"); |
||
179 | |||
180 | |||
181 | |||
182 | |||
183 | { |
||
184 | printf ("%8u) %s %s\n", i, TableData->Signature, TableData->Name); |
||
185 | i++; |
||
186 | } |
||
187 | } |
||
188 | |||
189 | |||
190 | |||
191 | * |
||
192 | * FUNCTION: AcpiPsDisplayConstantOpcodes |
||
1498 | serge | 193 | * |
194 | * PARAMETERS: None |
||
195 | * |
||
196 | * RETURN: None |
||
197 | * |
||
198 | * DESCRIPTION: Print AML opcodes that can be used in constant expressions. |
||
199 | * |
||
200 | ******************************************************************************/ |
||
201 | |||
202 | |||
203 | UtDisplayConstantOpcodes ( |
||
204 | void) |
||
205 | { |
||
206 | UINT32 i; |
||
207 | |||
208 | |||
209 | |||
210 | |||
211 | |||
212 | { |
||
213 | if (AcpiGbl_AmlOpInfo[i].Flags & AML_CONSTANT) |
||
214 | { |
||
215 | printf ("%s\n", AcpiGbl_AmlOpInfo[i].Name); |
||
216 | } |
||
217 | } |
||
218 | } |
||
219 | |||
220 | |||
221 | |||
222 | * |
||
223 | * FUNCTION: UtLocalCalloc |
||
224 | * |
||
225 | * PARAMETERS: Size - Bytes to be allocated |
||
226 | * |
||
227 | * RETURN: Pointer to the allocated memory. Guaranteed to be valid. |
||
228 | * |
||
229 | * DESCRIPTION: Allocate zero-initialized memory. Aborts the compile on an |
||
230 | * allocation failure, on the assumption that nothing more can be |
||
231 | * accomplished. |
||
232 | * |
||
233 | ******************************************************************************/ |
||
234 | |||
235 | |||
236 | UtLocalCalloc ( |
||
237 | UINT32 Size) |
||
238 | { |
||
239 | void *Allocated; |
||
240 | |||
241 | |||
242 | |||
243 | if (!Allocated) |
||
244 | { |
||
245 | AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, |
||
246 | Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, |
||
247 | Gbl_InputByteCount, Gbl_CurrentColumn, |
||
248 | Gbl_Files[ASL_FILE_INPUT].Filename, NULL); |
||
249 | |||
250 | |||
251 | exit (1); |
||
252 | } |
||
253 | |||
254 | |||
255 | TotalAllocated += Size; |
||
256 | return (Allocated); |
||
257 | } |
||
258 | |||
259 | |||
260 | |||
261 | * |
||
262 | * FUNCTION: UtBeginEvent |
||
263 | * |
||
264 | * PARAMETERS: Name - Ascii name of this event |
||
265 | * |
||
266 | * RETURN: Event - Event number (integer index) |
||
267 | * |
||
268 | * DESCRIPTION: Saves the current time with this event |
||
269 | * |
||
270 | ******************************************************************************/ |
||
271 | |||
272 | |||
273 | UtBeginEvent ( |
||
274 | char *Name) |
||
275 | { |
||
276 | |||
277 | |||
278 | { |
||
279 | AcpiOsPrintf ("Ran out of compiler event structs!\n"); |
||
280 | return (AslGbl_NextEvent); |
||
281 | } |
||
282 | |||
283 | |||
284 | |||
285 | |||
286 | AslGbl_Events[AslGbl_NextEvent].EventName = Name; |
||
287 | AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; |
||
288 | |||
289 | |||
290 | } |
||
291 | |||
292 | |||
293 | |||
294 | * |
||
295 | * FUNCTION: UtEndEvent |
||
296 | * |
||
297 | * PARAMETERS: Event - Event number (integer index) |
||
298 | * |
||
299 | * RETURN: None |
||
300 | * |
||
301 | * DESCRIPTION: Saves the current time (end time) with this event |
||
302 | * |
||
303 | ******************************************************************************/ |
||
304 | |||
305 | |||
306 | UtEndEvent ( |
||
307 | UINT8 Event) |
||
308 | { |
||
309 | |||
310 | |||
311 | { |
||
312 | return; |
||
313 | } |
||
314 | |||
315 | |||
316 | |||
317 | |||
318 | } |
||
319 | |||
320 | |||
321 | |||
322 | * |
||
323 | * FUNCTION: UtHexCharToValue |
||
324 | * |
||
325 | * PARAMETERS: HexChar - Hex character in Ascii |
||
326 | * |
||
327 | * RETURN: The binary value of the hex character |
||
328 | * |
||
329 | * DESCRIPTION: Perform ascii-to-hex translation |
||
330 | * |
||
331 | ******************************************************************************/ |
||
332 | |||
333 | |||
334 | UtHexCharToValue ( |
||
335 | int HexChar) |
||
336 | { |
||
337 | |||
338 | |||
339 | { |
||
340 | return ((UINT8) (HexChar - 0x30)); |
||
341 | } |
||
342 | |||
343 | |||
344 | { |
||
345 | return ((UINT8) (HexChar - 0x37)); |
||
346 | } |
||
347 | |||
348 | |||
349 | } |
||
350 | |||
351 | |||
352 | |||
353 | * |
||
354 | * FUNCTION: UtConvertByteToHex |
||
355 | * |
||
356 | * PARAMETERS: RawByte - Binary data |
||
357 | * Buffer - Pointer to where the hex bytes will be stored |
||
358 | * |
||
359 | * RETURN: Ascii hex byte is stored in Buffer. |
||
360 | * |
||
361 | * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed |
||
362 | * with "0x" |
||
363 | * |
||
364 | ******************************************************************************/ |
||
365 | |||
366 | |||
367 | UtConvertByteToHex ( |
||
368 | UINT8 RawByte, |
||
369 | UINT8 *Buffer) |
||
370 | { |
||
371 | |||
372 | |||
373 | Buffer[1] = 'x'; |
||
374 | |||
375 | |||
2216 | Serge | 376 | Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; |
377 | } |
||
1498 | serge | 378 | |
379 | |||
380 | |||
381 | * |
||
382 | * FUNCTION: UtConvertByteToAsmHex |
||
383 | * |
||
384 | * PARAMETERS: RawByte - Binary data |
||
385 | * Buffer - Pointer to where the hex bytes will be stored |
||
386 | * |
||
387 | * RETURN: Ascii hex byte is stored in Buffer. |
||
388 | * |
||
389 | * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed |
||
390 | * with "0x" |
||
391 | * |
||
392 | ******************************************************************************/ |
||
393 | |||
394 | |||
395 | UtConvertByteToAsmHex ( |
||
396 | UINT8 RawByte, |
||
397 | UINT8 *Buffer) |
||
398 | { |
||
399 | |||
400 | |||
401 | Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; |
||
2216 | Serge | 402 | Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; |
403 | Buffer[3] = 'h'; |
||
1498 | serge | 404 | } |
405 | |||
406 | |||
407 | |||
408 | * |
||
409 | * FUNCTION: DbgPrint |
||
410 | * |
||
411 | * PARAMETERS: Type - Type of output |
||
412 | * Fmt - Printf format string |
||
413 | * ... - variable printf list |
||
414 | * |
||
415 | * RETURN: None |
||
416 | * |
||
417 | * DESCRIPTION: Conditional print statement. Prints to stderr only if the |
||
418 | * debug flag is set. |
||
419 | * |
||
420 | ******************************************************************************/ |
||
421 | |||
422 | |||
423 | DbgPrint ( |
||
424 | UINT32 Type, |
||
425 | char *Fmt, |
||
426 | ...) |
||
427 | { |
||
428 | va_list Args; |
||
429 | |||
430 | |||
431 | |||
432 | |||
433 | |||
434 | { |
||
435 | return; |
||
436 | } |
||
437 | |||
438 | |||
439 | (!(AslCompilerdebug))) |
||
440 | { |
||
441 | return; |
||
442 | } |
||
443 | |||
444 | |||
445 | va_end (Args); |
||
446 | return; |
||
447 | } |
||
448 | |||
449 | |||
450 | |||
451 | * |
||
452 | * FUNCTION: UtPrintFormattedName |
||
453 | * |
||
454 | * PARAMETERS: ParseOpcode - Parser keyword ID |
||
455 | * Level - Indentation level |
||
456 | * |
||
457 | * RETURN: None |
||
458 | * |
||
459 | * DESCRIPTION: Print the ascii name of the parse opcode. |
||
460 | * |
||
461 | ******************************************************************************/ |
||
462 | |||
463 | |||
464 | |||
465 | |||
466 | UtPrintFormattedName ( |
||
467 | UINT16 ParseOpcode, |
||
468 | UINT32 Level) |
||
469 | { |
||
470 | |||
471 | |||
472 | { |
||
473 | DbgPrint (ASL_TREE_OUTPUT, |
||
474 | "%*s", (3 * Level), " "); |
||
475 | } |
||
476 | DbgPrint (ASL_TREE_OUTPUT, |
||
477 | " %-20.20s", UtGetOpName (ParseOpcode)); |
||
478 | |||
479 | |||
480 | { |
||
481 | DbgPrint (ASL_TREE_OUTPUT, |
||
482 | "%*s", (TEXT_OFFSET - Level) * 3, " "); |
||
483 | } |
||
484 | } |
||
485 | |||
486 | |||
487 | |||
488 | * |
||
489 | * FUNCTION: UtSetParseOpName |
||
490 | * |
||
491 | * PARAMETERS: Op |
||
492 | * |
||
493 | * RETURN: None |
||
494 | * |
||
495 | * DESCRIPTION: Insert the ascii name of the parse opcode |
||
496 | * |
||
497 | ******************************************************************************/ |
||
498 | |||
499 | |||
500 | UtSetParseOpName ( |
||
501 | ACPI_PARSE_OBJECT *Op) |
||
502 | { |
||
503 | |||
504 | |||
505 | ACPI_MAX_PARSEOP_NAME); |
||
506 | } |
||
507 | |||
508 | |||
509 | |||
510 | * |
||
511 | * FUNCTION: UtDisplaySummary |
||
512 | * |
||
513 | * PARAMETERS: FileID - ID of outpout file |
||
514 | * |
||
515 | * RETURN: None |
||
516 | * |
||
517 | * DESCRIPTION: Display compilation statistics |
||
518 | * |
||
519 | ******************************************************************************/ |
||
520 | |||
521 | |||
522 | UtDisplaySummary ( |
||
523 | UINT32 FileId) |
||
524 | { |
||
525 | |||
526 | |||
527 | { |
||
528 | /* Compiler name and version number */ |
||
529 | |||
530 | |||
2216 | Serge | 531 | ASL_COMPILER_NAME, (UINT32) ACPI_CA_VERSION, ACPI_WIDTH, __DATE__); |
532 | } |
||
1498 | serge | 533 | |
534 | |||
535 | { |
||
536 | FlPrintFile (FileId, |
||
537 | "Table Input: %s - %u lines, %u bytes, %u fields\n", |
||
538 | Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, |
||
539 | Gbl_InputByteCount, Gbl_InputFieldCount); |
||
540 | |||
541 | |||
542 | { |
||
543 | FlPrintFile (FileId, |
||
544 | "Binary Output: %s - %u bytes\n\n", |
||
545 | Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength); |
||
546 | } |
||
547 | } |
||
548 | else |
||
549 | { |
||
550 | /* Input/Output summary */ |
||
551 | |||
552 | |||
553 | "ASL Input: %s - %u lines, %u bytes, %u keywords\n", |
||
554 | Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, |
||
555 | Gbl_InputByteCount, TotalKeywords); |
||
556 | |||
557 | |||
558 | |||
559 | |||
560 | { |
||
561 | FlPrintFile (FileId, |
||
562 | "AML Output: %s - %u bytes, %u named objects, %u executable opcodes\n\n", |
||
563 | Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, |
||
564 | TotalNamedObjects, TotalExecutableOpcodes); |
||
565 | } |
||
566 | } |
||
567 | |||
568 | |||
569 | |||
570 | |||
571 | "Compilation complete. %u Errors, %u Warnings, %u Remarks", |
||
572 | Gbl_ExceptionCount[ASL_ERROR], |
||
573 | Gbl_ExceptionCount[ASL_WARNING] + |
||
574 | Gbl_ExceptionCount[ASL_WARNING2] + |
||
575 | Gbl_ExceptionCount[ASL_WARNING3], |
||
576 | Gbl_ExceptionCount[ASL_REMARK]); |
||
577 | |||
578 | |||
579 | { |
||
580 | FlPrintFile (FileId, |
||
581 | ", %u Optimizations", Gbl_ExceptionCount[ASL_OPTIMIZATION]); |
||
582 | } |
||
583 | |||
584 | |||
585 | } |
||
586 | |||
587 | |||
588 | |||
589 | * |
||
590 | * FUNCTION: UtDisplaySummary |
||
591 | * |
||
592 | * PARAMETERS: Op - Integer parse node |
||
593 | * LowValue - Smallest allowed value |
||
594 | * HighValue - Largest allowed value |
||
595 | * |
||
596 | * RETURN: Op if OK, otherwise NULL |
||
597 | * |
||
598 | * DESCRIPTION: Check integer for an allowable range |
||
599 | * |
||
600 | ******************************************************************************/ |
||
601 | |||
602 | |||
603 | UtCheckIntegerRange ( |
||
604 | ACPI_PARSE_OBJECT *Op, |
||
605 | UINT32 LowValue, |
||
606 | UINT32 HighValue) |
||
607 | { |
||
608 | char *ParseError = NULL; |
||
609 | char Buffer[64]; |
||
610 | |||
611 | |||
612 | |||
613 | { |
||
614 | return NULL; |
||
615 | } |
||
616 | |||
617 | |||
618 | { |
||
619 | ParseError = "Value below valid range"; |
||
620 | Op->Asl.Value.Integer = LowValue; |
||
621 | } |
||
622 | |||
623 | |||
624 | { |
||
625 | ParseError = "Value above valid range"; |
||
626 | Op->Asl.Value.Integer = HighValue; |
||
627 | } |
||
628 | |||
629 | |||
630 | { |
||
631 | sprintf (Buffer, "%s 0x%X-0x%X", ParseError, LowValue, HighValue); |
||
632 | AslCompilererror (Buffer); |
||
633 | |||
634 | |||
635 | } |
||
636 | |||
637 | |||
638 | } |
||
639 | |||
640 | |||
641 | |||
642 | * |
||
643 | * FUNCTION: UtGetStringBuffer |
||
644 | * |
||
645 | * PARAMETERS: Length - Size of buffer requested |
||
646 | * |
||
647 | * RETURN: Pointer to the buffer. Aborts on allocation failure |
||
648 | * |
||
649 | * DESCRIPTION: Allocate a string buffer. Bypass the local |
||
650 | * dynamic memory manager for performance reasons (This has a |
||
651 | * major impact on the speed of the compiler.) |
||
652 | * |
||
653 | ******************************************************************************/ |
||
654 | |||
655 | |||
656 | UtGetStringBuffer ( |
||
657 | UINT32 Length) |
||
658 | { |
||
659 | char *Buffer; |
||
660 | |||
661 | |||
662 | |||
663 | { |
||
664 | Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); |
||
665 | Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + |
||
666 | Length; |
||
667 | } |
||
668 | |||
669 | |||
670 | Gbl_StringCacheNext += Length; |
||
671 | |||
672 | |||
673 | } |
||
674 | |||
675 | |||
676 | |||
677 | * |
||
678 | * FUNCTION: UtInternalizeName |
||
679 | * |
||
680 | * PARAMETERS: ExternalName - Name to convert |
||
681 | * ConvertedName - Where the converted name is returned |
||
682 | * |
||
683 | * RETURN: Status |
||
684 | * |
||
685 | * DESCRIPTION: Convert an external (ASL) name to an internal (AML) name |
||
686 | * |
||
687 | ******************************************************************************/ |
||
688 | |||
689 | |||
690 | UtInternalizeName ( |
||
691 | char *ExternalName, |
||
692 | char **ConvertedName) |
||
693 | { |
||
694 | ACPI_NAMESTRING_INFO Info; |
||
695 | ACPI_STATUS Status; |
||
696 | |||
697 | |||
698 | |||
699 | { |
||
700 | return (AE_OK); |
||
701 | } |
||
702 | |||
703 | |||
704 | |||
705 | |||
706 | AcpiNsGetInternalNameLength (&Info); |
||
707 | |||
708 | |||
709 | |||
710 | |||
711 | if (!Info.InternalName) |
||
712 | { |
||
713 | return (AE_NO_MEMORY); |
||
714 | } |
||
715 | |||
716 | |||
717 | |||
718 | |||
719 | if (ACPI_FAILURE (Status)) |
||
720 | { |
||
721 | return (Status); |
||
722 | } |
||
723 | |||
724 | |||
725 | return (AE_OK); |
||
726 | } |
||
727 | |||
728 | |||
729 | |||
730 | * |
||
731 | * FUNCTION: UtPadNameWithUnderscores |
||
732 | * |
||
733 | * PARAMETERS: NameSeg - Input nameseg |
||
734 | * PaddedNameSeg - Output padded nameseg |
||
735 | * |
||
736 | * RETURN: Padded nameseg. |
||
737 | * |
||
738 | * DESCRIPTION: Pads a NameSeg with underscores if necessary to form a full |
||
739 | * ACPI_NAME. |
||
740 | * |
||
741 | ******************************************************************************/ |
||
742 | |||
743 | |||
744 | UtPadNameWithUnderscores ( |
||
745 | char *NameSeg, |
||
746 | char *PaddedNameSeg) |
||
747 | { |
||
748 | UINT32 i; |
||
749 | |||
750 | |||
751 | |||
752 | { |
||
753 | if (*NameSeg) |
||
754 | { |
||
755 | *PaddedNameSeg = *NameSeg; |
||
756 | NameSeg++; |
||
757 | } |
||
758 | else |
||
759 | { |
||
760 | *PaddedNameSeg = '_'; |
||
761 | } |
||
762 | PaddedNameSeg++; |
||
763 | } |
||
764 | } |
||
765 | |||
766 | |||
767 | |||
768 | * |
||
769 | * FUNCTION: UtAttachNameseg |
||
770 | * |
||
771 | * PARAMETERS: Op - Parent parse node |
||
772 | * Name - Full ExternalName |
||
773 | * |
||
774 | * RETURN: None; Sets the NameSeg field in parent node |
||
775 | * |
||
776 | * DESCRIPTION: Extract the last nameseg of the ExternalName and store it |
||
777 | * in the NameSeg field of the Op. |
||
778 | * |
||
779 | ******************************************************************************/ |
||
780 | |||
781 | |||
782 | UtAttachNameseg ( |
||
783 | ACPI_PARSE_OBJECT *Op, |
||
784 | char *Name) |
||
785 | { |
||
786 | char *NameSeg; |
||
787 | char PaddedNameSeg[4]; |
||
788 | |||
789 | |||
790 | |||
791 | { |
||
792 | return; |
||
793 | } |
||
794 | |||
795 | |||
796 | |||
797 | |||
798 | if (NameSeg) |
||
799 | { |
||
800 | /* Found last dot, we have also found the final nameseg */ |
||
801 | |||
802 | |||
803 | UtPadNameWithUnderscores (NameSeg, PaddedNameSeg); |
||
804 | } |
||
805 | else |
||
806 | { |
||
807 | /* No dots in the namepath, there is only a single nameseg. */ |
||
808 | /* Handle prefixes */ |
||
809 | |||
810 | |||
811 | { |
||
812 | Name++; |
||
813 | } |
||
814 | |||
815 | |||
816 | |||
817 | |||
818 | } |
||
819 | |||
820 | |||
821 | } |
||
822 | |||
823 | |||
824 | |||
825 | * |
||
826 | * FUNCTION: UtAttachNamepathToOwner |
||
827 | * |
||
828 | * PARAMETERS: Op - Parent parse node |
||
829 | * NameOp - Node that contains the name |
||
830 | * |
||
831 | * RETURN: Sets the ExternalName and Namepath in the parent node |
||
832 | * |
||
833 | * DESCRIPTION: Store the name in two forms in the parent node: The original |
||
834 | * (external) name, and the internalized name that is used within |
||
835 | * the ACPI namespace manager. |
||
836 | * |
||
837 | ******************************************************************************/ |
||
838 | |||
839 | |||
840 | UtAttachNamepathToOwner ( |
||
841 | ACPI_PARSE_OBJECT *Op, |
||
842 | ACPI_PARSE_OBJECT *NameOp) |
||
843 | { |
||
844 | ACPI_STATUS Status; |
||
845 | |||
846 | |||
847 | |||
848 | |||
849 | |||
850 | |||
851 | |||
852 | |||
853 | |||
854 | |||
855 | |||
856 | |||
857 | |||
858 | |||
859 | |||
860 | |||
861 | |||
862 | if (ACPI_FAILURE (Status)) |
||
863 | { |
||
864 | /* TBD: abort on no memory */ |
||
865 | } |
||
866 | } |
||
867 | |||
868 | |||
869 | |||
870 | * |
||
871 | * FUNCTION: UtDoConstant |
||
872 | * |
||
873 | * PARAMETERS: String - Hex, Octal, or Decimal string |
||
874 | * |
||
875 | * RETURN: Converted Integer |
||
876 | * |
||
877 | * DESCRIPTION: Convert a string to an integer. With error checking. |
||
878 | * |
||
879 | ******************************************************************************/ |
||
880 | |||
881 | |||
882 | UtDoConstant ( |
||
883 | char *String) |
||
884 | { |
||
885 | ACPI_STATUS Status; |
||
886 | UINT64 Converted; |
||
887 | char ErrBuf[64]; |
||
888 | |||
889 | |||
890 | |||
891 | if (ACPI_FAILURE (Status)) |
||
892 | { |
||
893 | sprintf (ErrBuf, "%s %s\n", "Conversion error:", |
||
894 | AcpiFormatException (Status)); |
||
895 | AslCompilererror (ErrBuf); |
||
896 | } |
||
897 | |||
898 | |||
899 | } |
||
900 | |||
901 | |||
902 | |||
903 | |||
904 | |||
905 | * |
||
906 | * FUNCTION: UtStrtoul64 |
||
907 | * |
||
908 | * PARAMETERS: String - Null terminated string |
||
909 | * Terminater - Where a pointer to the terminating byte is |
||
910 | * returned |
||
911 | * Base - Radix of the string |
||
912 | * |
||
913 | * RETURN: Converted value |
||
914 | * |
||
915 | * DESCRIPTION: Convert a string into an unsigned value. |
||
916 | * |
||
917 | ******************************************************************************/ |
||
918 | |||
919 | |||
2216 | Serge | 920 | UtStrtoul64 ( |
1498 | serge | 921 | char *String, |
922 | UINT32 Base, |
||
923 | UINT64 *RetInteger) |
||
924 | { |
||
925 | UINT32 Index; |
||
926 | UINT32 Sign; |
||
927 | UINT64 ReturnValue = 0; |
||
928 | ACPI_STATUS Status = AE_OK; |
||
929 | |||
930 | |||
931 | |||
932 | |||
933 | |||
934 | { |
||
935 | case 0: |
||
936 | case 8: |
||
937 | case 10: |
||
938 | case 16: |
||
939 | break; |
||
940 | |||
941 | |||
942 | /* |
||
943 | * The specified Base parameter is not in the domain of |
||
944 | * this function: |
||
945 | */ |
||
946 | return (AE_BAD_PARAMETER); |
||
947 | } |
||
948 | |||
949 | |||
950 | |||
951 | |||
952 | { |
||
953 | ++String; |
||
954 | } |
||
955 | |||
956 | |||
957 | * The buffer may contain an optional plus or minus sign. |
||
958 | * If it does, then skip over it but remember what is was: |
||
959 | */ |
||
960 | if (*String == '-') |
||
961 | { |
||
962 | Sign = NEGATIVE; |
||
963 | ++String; |
||
964 | } |
||
965 | else if (*String == '+') |
||
966 | { |
||
967 | ++String; |
||
968 | Sign = POSITIVE; |
||
969 | } |
||
970 | else |
||
971 | { |
||
972 | Sign = POSITIVE; |
||
973 | } |
||
974 | |||
975 | |||
976 | * If the input parameter Base is zero, then we need to |
||
977 | * determine if it is octal, decimal, or hexadecimal: |
||
978 | */ |
||
979 | if (Base == 0) |
||
980 | { |
||
981 | if (*String == '0') |
||
982 | { |
||
983 | if (tolower ((int) *(++String)) == 'x') |
||
984 | { |
||
985 | Base = 16; |
||
986 | ++String; |
||
987 | } |
||
988 | else |
||
989 | { |
||
990 | Base = 8; |
||
991 | } |
||
992 | } |
||
993 | else |
||
994 | { |
||
995 | Base = 10; |
||
996 | } |
||
997 | } |
||
998 | |||
999 | |||
1000 | * For octal and hexadecimal bases, skip over the leading |
||
1001 | * 0 or 0x, if they are present. |
||
1002 | */ |
||
1003 | if (Base == 8 && *String == '0') |
||
1004 | { |
||
1005 | String++; |
||
1006 | } |
||
1007 | |||
1008 | |||
1009 | *String == '0' && |
||
1010 | tolower ((int) *(++String)) == 'x') |
||
1011 | { |
||
1012 | String++; |
||
1013 | } |
||
1014 | |||
1015 | |||
1016 | |||
1017 | |||
1018 | { |
||
1019 | if (isdigit ((int) *String)) |
||
1020 | { |
||
1021 | Index = ((UINT8) *String) - '0'; |
||
1022 | } |
||
1023 | else |
||
1024 | { |
||
1025 | Index = (UINT8) toupper ((int) *String); |
||
1026 | if (isupper ((int) Index)) |
||
1027 | { |
||
1028 | Index = Index - 'A' + 10; |
||
1029 | } |
||
1030 | else |
||
1031 | { |
||
1032 | goto ErrorExit; |
||
1033 | } |
||
1034 | } |
||
1035 | |||
1036 | |||
1037 | { |
||
1038 | goto ErrorExit; |
||
1039 | } |
||
1040 | |||
1041 | |||
1042 | |||
1043 | |||
1044 | (UINT64) Base)) |
||
1045 | { |
||
1046 | goto ErrorExit; |
||
1047 | } |
||
1048 | else |
||
1049 | { |
||
1050 | ReturnValue *= Base; |
||
1051 | ReturnValue += Index; |
||
1052 | } |
||
1053 | |||
1054 | |||
1055 | } |
||
1056 | |||
1057 | |||
1058 | |||
1059 | |||
1060 | |||
1061 | { |
||
1062 | ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; |
||
1063 | } |
||
1064 | |||
1065 | |||
1066 | return (Status); |
||
1067 | |||
1068 | |||
1069 | |||
1070 | switch (Base) |
||
1071 | { |
||
1072 | case 8: |
||
1073 | Status = AE_BAD_OCTAL_CONSTANT; |
||
1074 | break; |
||
1075 | |||
1076 | |||
1077 | Status = AE_BAD_DECIMAL_CONSTANT; |
||
1078 | break; |
||
1079 | |||
1080 | |||
1081 | Status = AE_BAD_HEX_CONSTANT; |
||
1082 | break; |
||
1083 | |||
1084 | |||
1085 | /* Base validated above */ |
||
1086 | break; |
||
1087 | } |
||
1088 | |||
1089 | |||
1090 | }>>>=>=>> |
||
1091 |