xref: /freebsd/sys/contrib/dev/acpica/compiler/aslcompiler.h (revision d93a896ef95946b0bf1219866fcb324b78543444)
1 /******************************************************************************
2  *
3  * Module Name: aslcompiler.h - common include file for iASL
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #ifndef __ASLCOMPILER_H
153 #define __ASLCOMPILER_H
154 
155 #include <contrib/dev/acpica/include/acpi.h>
156 #include <contrib/dev/acpica/include/accommon.h>
157 #include <contrib/dev/acpica/include/amlresrc.h>
158 #include <contrib/dev/acpica/include/acdebug.h>
159 
160 /* Microsoft-specific */
161 
162 #if (defined WIN32 || defined WIN64)
163 
164 /* warn : used #pragma pack */
165 #pragma warning(disable:4103)
166 
167 /* warn : named type definition in parentheses */
168 #pragma warning(disable:4115)
169 #endif
170 
171 #include <stdio.h>
172 #include <stdlib.h>
173 #include <string.h>
174 #include <errno.h>
175 #include <ctype.h>
176 
177 /* Compiler headers */
178 
179 #include <contrib/dev/acpica/compiler/asldefine.h>
180 #include <contrib/dev/acpica/compiler/asltypes.h>
181 #include <contrib/dev/acpica/compiler/aslmessages.h>
182 #include <contrib/dev/acpica/compiler/aslglobal.h>
183 #include <contrib/dev/acpica/compiler/preprocess.h>
184 
185 
186 /*******************************************************************************
187  *
188  * Compiler prototypes
189  *
190  ******************************************************************************/
191 
192 /*
193  * Main ASL parser - generated from flex/bison, lex/yacc, etc.
194  */
195 ACPI_PARSE_OBJECT *
196 AslDoError (
197     void);
198 
199 int
200 AslCompilerlex(
201     void);
202 
203 void
204 AslResetCurrentLineBuffer (
205     void);
206 
207 void
208 AslInsertLineBuffer (
209     int                     SourceChar);
210 
211 int
212 AslPopInputFileStack (
213     void);
214 
215 void
216 AslPushInputFileStack (
217     FILE                    *InputFile,
218     char                    *Filename);
219 
220 void
221 AslParserCleanup (
222     void);
223 
224 
225 /*
226  * aslstartup - entered from main()
227  */
228 void
229 AslInitializeGlobals (
230     void);
231 
232 typedef
233 ACPI_STATUS (*ASL_PATHNAME_CALLBACK) (
234     char *);
235 
236 ACPI_STATUS
237 AslDoOneFile (
238     char                    *Filename);
239 
240 ACPI_STATUS
241 AslCheckForErrorExit (
242     void);
243 
244 
245 /*
246  * aslcompile - compile mainline
247  */
248 void
249 AslCompilerSignon (
250     UINT32                  FileId);
251 
252 void
253 AslCompilerFileHeader (
254     UINT32                  FileId);
255 
256 int
257 CmDoCompile (
258     void);
259 
260 void
261 CmDoOutputFiles (
262     void);
263 
264 void
265 CmCleanupAndExit (
266     void);
267 
268 void
269 CmDeleteCaches (
270     void);
271 
272 
273 /*
274  * aslascii - ascii support
275  */
276 ACPI_STATUS
277 FlIsFileAsciiSource (
278     char                    *Filename,
279     BOOLEAN                 DisplayErrors);
280 
281 
282 /*
283  * aslwalks - semantic analysis and parse tree walks
284  */
285 ACPI_STATUS
286 AnOtherSemanticAnalysisWalkBegin (
287     ACPI_PARSE_OBJECT       *Op,
288     UINT32                  Level,
289     void                    *Context);
290 
291 ACPI_STATUS
292 AnOtherSemanticAnalysisWalkEnd (
293     ACPI_PARSE_OBJECT       *Op,
294     UINT32                  Level,
295     void                    *Context);
296 
297 ACPI_STATUS
298 AnOperandTypecheckWalkEnd (
299     ACPI_PARSE_OBJECT       *Op,
300     UINT32                  Level,
301     void                    *Context);
302 
303 ACPI_STATUS
304 AnMethodTypingWalkEnd (
305     ACPI_PARSE_OBJECT       *Op,
306     UINT32                  Level,
307     void                    *Context);
308 
309 
310 /*
311  * aslmethod - Control method analysis walk
312  */
313 ACPI_STATUS
314 MtMethodAnalysisWalkBegin (
315     ACPI_PARSE_OBJECT       *Op,
316     UINT32                  Level,
317     void                    *Context);
318 
319 ACPI_STATUS
320 MtMethodAnalysisWalkEnd (
321     ACPI_PARSE_OBJECT       *Op,
322     UINT32                  Level,
323     void                    *Context);
324 
325 
326 /*
327  * aslbtypes - bitfield data types
328  */
329 UINT32
330 AnMapObjTypeToBtype (
331     ACPI_PARSE_OBJECT       *Op);
332 
333 UINT32
334 AnMapArgTypeToBtype (
335     UINT32                  ArgType);
336 
337 UINT32
338 AnGetBtype (
339     ACPI_PARSE_OBJECT       *Op);
340 
341 void
342 AnFormatBtype (
343     char                    *Buffer,
344     UINT32                  Btype);
345 
346 
347 /*
348  * aslanalyze - Support functions for parse tree walks
349  */
350 void
351 AnCheckId (
352     ACPI_PARSE_OBJECT       *Op,
353     ACPI_NAME               Type);
354 
355 /* Values for Type argument above */
356 
357 #define ASL_TYPE_HID        0
358 #define ASL_TYPE_CID        1
359 
360 BOOLEAN
361 AnIsInternalMethod (
362     ACPI_PARSE_OBJECT       *Op);
363 
364 UINT32
365 AnGetInternalMethodReturnType (
366     ACPI_PARSE_OBJECT       *Op);
367 
368 BOOLEAN
369 AnLastStatementIsReturn (
370     ACPI_PARSE_OBJECT       *Op);
371 
372 void
373 AnCheckMethodReturnValue (
374     ACPI_PARSE_OBJECT       *Op,
375     const ACPI_OPCODE_INFO  *OpInfo,
376     ACPI_PARSE_OBJECT       *ArgOp,
377     UINT32                  RequiredBtypes,
378     UINT32                  ThisNodeBtype);
379 
380 BOOLEAN
381 AnIsResultUsed (
382     ACPI_PARSE_OBJECT       *Op);
383 
384 void
385 ApCheckForGpeNameConflict (
386     ACPI_PARSE_OBJECT       *Op);
387 
388 void
389 ApCheckRegMethod (
390     ACPI_PARSE_OBJECT       *Op);
391 
392 BOOLEAN
393 ApFindNameInScope (
394     char                    *Name,
395     ACPI_PARSE_OBJECT       *Op);
396 
397 BOOLEAN
398 ApFindNameInDeviceTree (
399     char                    *Name,
400     ACPI_PARSE_OBJECT       *Op);
401 
402 /*
403  * aslerror - error handling/reporting
404  */
405 void
406 AslAbort (
407     void);
408 
409 void
410 AslError (
411     UINT8                   Level,
412     UINT16                  MessageId,
413     ACPI_PARSE_OBJECT       *Op,
414     char                    *ExtraMessage);
415 
416 void
417 AslCheckExpectedExceptions (
418     void);
419 
420 ACPI_STATUS
421 AslExpectException (
422     char                    *MessageIdString);
423 
424 ACPI_STATUS
425 AslDisableException (
426     char                    *MessageIdString);
427 
428 BOOLEAN
429 AslIsExceptionIgnored (
430     UINT8                   Level,
431     UINT16                  MessageId);
432 
433 void
434 AslCoreSubsystemError (
435     ACPI_PARSE_OBJECT       *Op,
436     ACPI_STATUS             Status,
437     char                    *ExtraMessage,
438     BOOLEAN                 Abort);
439 
440 int
441 AslCompilererror(
442     const char              *s);
443 
444 void
445 AslCommonError (
446     UINT8                   Level,
447     UINT16                  MessageId,
448     UINT32                  CurrentLineNumber,
449     UINT32                  LogicalLineNumber,
450     UINT32                  LogicalByteOffset,
451     UINT32                  Column,
452     char                    *Filename,
453     char                    *ExtraMessage);
454 
455 void
456 AslCommonError2 (
457     UINT8                   Level,
458     UINT16                  MessageId,
459     UINT32                  LineNumber,
460     UINT32                  Column,
461     char                    *SourceLine,
462     char                    *Filename,
463     char                    *ExtraMessage);
464 
465 void
466 AePrintException (
467     UINT32                  FileId,
468     ASL_ERROR_MSG           *Enode,
469     char                    *Header);
470 
471 void
472 AePrintErrorLog (
473     UINT32                  FileId);
474 
475 void
476 AeClearErrorLog (
477     void);
478 
479 
480 /*
481  * asllisting - generate all "listing" type files
482  */
483 void
484 LsDoListings (
485     void);
486 
487 void
488 LsWriteNodeToAsmListing (
489     ACPI_PARSE_OBJECT       *Op);
490 
491 void
492 LsWriteNode (
493     ACPI_PARSE_OBJECT       *Op,
494     UINT32                  FileId);
495 
496 void
497 LsDumpParseTree (
498     void);
499 
500 
501 /*
502  * asllistsup - Listing file support utilities
503  */
504 void
505 LsDumpAscii (
506     UINT32                  FileId,
507     UINT32                  Count,
508     UINT8                   *Buffer);
509 
510 void
511 LsDumpAsciiInComment (
512     UINT32                  FileId,
513     UINT32                  Count,
514     UINT8                   *Buffer);
515 
516 void
517 LsCheckException (
518     UINT32                  LineNumber,
519     UINT32                  FileId);
520 
521 void
522 LsFlushListingBuffer (
523     UINT32                  FileId);
524 
525 void
526 LsWriteListingHexBytes (
527     UINT8                   *Buffer,
528     UINT32                  Length,
529     UINT32                  FileId);
530 
531 void
532 LsWriteSourceLines (
533     UINT32                  ToLineNumber,
534     UINT32                  ToLogicalLineNumber,
535     UINT32                  FileId);
536 
537 UINT32
538 LsWriteOneSourceLine (
539     UINT32                  FileId);
540 
541 void
542 LsPushNode (
543     char                    *Filename);
544 
545 ASL_LISTING_NODE *
546 LsPopNode (
547     void);
548 
549 
550 /*
551  * aslhex - generate all "hex" output files (C, ASM, ASL)
552  */
553 void
554 HxDoHexOutput (
555     void);
556 
557 
558 /*
559  * aslfold - constant folding
560  */
561 ACPI_STATUS
562 OpcAmlConstantWalk (
563     ACPI_PARSE_OBJECT       *Op,
564     UINT32                  Level,
565     void                    *Context);
566 
567 
568 /*
569  * aslmessages - exception strings
570  */
571 const char *
572 AeDecodeMessageId (
573     UINT16                  MessageId);
574 
575 const char *
576 AeDecodeExceptionLevel (
577     UINT8                   Level);
578 
579 UINT16
580 AeBuildFullExceptionCode (
581     UINT8                   Level,
582     UINT16                  MessageId);
583 
584 /*
585  * asloffset - generate C offset file for BIOS support
586  */
587 ACPI_STATUS
588 LsAmlOffsetWalk (
589     ACPI_PARSE_OBJECT       *Op,
590     UINT32                  Level,
591     void                    *Context);
592 
593 void
594 LsDoOffsetTableHeader (
595     UINT32                  FileId);
596 
597 void
598 LsDoOffsetTableFooter (
599     UINT32                  FileId);
600 
601 
602 /*
603  * aslopcodes - generate AML opcodes
604  */
605 ACPI_STATUS
606 OpcAmlOpcodeWalk (
607     ACPI_PARSE_OBJECT       *Op,
608     UINT32                  Level,
609     void                    *Context);
610 
611 ACPI_STATUS
612 OpcAmlOpcodeUpdateWalk (
613     ACPI_PARSE_OBJECT       *Op,
614     UINT32                  Level,
615     void                    *Context);
616 
617 void
618 OpcGenerateAmlOpcode (
619     ACPI_PARSE_OBJECT       *Op);
620 
621 UINT32
622 OpcSetOptimalIntegerSize (
623     ACPI_PARSE_OBJECT       *Op);
624 
625 void
626 OpcGetIntegerWidth (
627     ACPI_PARSE_OBJECT       *Op);
628 
629 
630 /*
631  * asloperands - generate AML operands for the AML opcodes
632  */
633 ACPI_PARSE_OBJECT  *
634 UtGetArg (
635     ACPI_PARSE_OBJECT       *Op,
636     UINT32                  Argn);
637 
638 void
639 OpnGenerateAmlOperands (
640     ACPI_PARSE_OBJECT       *Op);
641 
642 void
643 OpnDoPackage (
644     ACPI_PARSE_OBJECT       *Op);
645 
646 
647 /*
648  * aslopt - optmization
649  */
650 void
651 OptOptimizeNamePath (
652     ACPI_PARSE_OBJECT       *Op,
653     UINT32                  Flags,
654     ACPI_WALK_STATE         *WalkState,
655     char                    *AmlNameString,
656     ACPI_NAMESPACE_NODE     *TargetNode);
657 
658 
659 /*
660  * aslpld - ToPLD macro support
661  */
662 void
663 OpcDoPld (
664     ACPI_PARSE_OBJECT       *Op);
665 
666 
667 /*
668  * aslprintf - Printf/Fprintf macros
669  */
670 void
671 OpcDoPrintf (
672     ACPI_PARSE_OBJECT       *Op);
673 
674 void
675 OpcDoFprintf (
676     ACPI_PARSE_OBJECT       *Op);
677 
678 
679 /*
680  * aslprune - parse tree pruner
681  */
682 void
683 AslPruneParseTree (
684     UINT32                  PruneDepth,
685     UINT32                  Type);
686 
687 
688 /*
689  * aslcodegen - code generation
690  */
691 void
692 CgGenerateAmlOutput (
693     void);
694 
695 void
696 CgLocalWriteAmlData (
697     ACPI_PARSE_OBJECT       *Op,
698     void                    *Buffer,
699     UINT32                  Length);
700 
701 
702 /*
703  * aslfile
704  */
705 void
706 FlOpenFile (
707     UINT32                  FileId,
708     char                    *Filename,
709     char                    *Mode);
710 
711 
712 /*
713  * asllength - calculate/adjust AML package lengths
714  */
715 ACPI_STATUS
716 LnPackageLengthWalk (
717     ACPI_PARSE_OBJECT       *Op,
718     UINT32                  Level,
719     void                    *Context);
720 
721 ACPI_STATUS
722 LnInitLengthsWalk (
723     ACPI_PARSE_OBJECT       *Op,
724     UINT32                  Level,
725     void                    *Context);
726 
727 void
728 CgGenerateAmlLengths (
729     ACPI_PARSE_OBJECT       *Op);
730 
731 
732 /*
733  * aslmap - opcode mappings and reserved method names
734  */
735 ACPI_OBJECT_TYPE
736 AslMapNamedOpcodeToDataType (
737     UINT16                  Opcode);
738 
739 
740 /*
741  * aslpredef - ACPI predefined names support
742  */
743 BOOLEAN
744 ApCheckForPredefinedMethod (
745     ACPI_PARSE_OBJECT       *Op,
746     ASL_METHOD_INFO         *MethodInfo);
747 
748 void
749 ApCheckPredefinedReturnValue (
750     ACPI_PARSE_OBJECT       *Op,
751     ASL_METHOD_INFO         *MethodInfo);
752 
753 UINT32
754 ApCheckForPredefinedName (
755     ACPI_PARSE_OBJECT       *Op,
756     char                    *Name);
757 
758 void
759 ApCheckForPredefinedObject (
760     ACPI_PARSE_OBJECT       *Op,
761     char                    *Name);
762 
763 ACPI_STATUS
764 ApCheckObjectType (
765     const char              *PredefinedName,
766     ACPI_PARSE_OBJECT       *Op,
767     UINT32                  ExpectedBtypes,
768     UINT32                  PackageIndex);
769 
770 void
771 ApDisplayReservedNames (
772     void);
773 
774 
775 /*
776  * aslprepkg - ACPI predefined names support for packages
777  */
778 void
779 ApCheckPackage (
780     ACPI_PARSE_OBJECT           *ParentOp,
781     const ACPI_PREDEFINED_INFO  *Predefined);
782 
783 
784 /*
785  * asltransform - parse tree transformations
786  */
787 ACPI_STATUS
788 TrAmlTransformWalkBegin (
789     ACPI_PARSE_OBJECT       *Op,
790     UINT32                  Level,
791     void                    *Context);
792 
793 ACPI_STATUS
794 TrAmlTransformWalkEnd (
795     ACPI_PARSE_OBJECT       *Op,
796     UINT32                  Level,
797     void                    *Context);
798 
799 
800 /*
801  * aslexternal - External opcode support
802  */
803 ACPI_STATUS
804 ExAmlExternalWalkBegin (
805     ACPI_PARSE_OBJECT       *Op,
806     UINT32                  Level,
807     void                    *Context);
808 
809 ACPI_STATUS
810 ExAmlExternalWalkEnd (
811     ACPI_PARSE_OBJECT       *Op,
812     UINT32                  Level,
813     void                    *Context);
814 
815 void
816 ExDoExternal (
817     ACPI_PARSE_OBJECT       *Op);
818 
819 /* Values for "Visitation" parameter above */
820 
821 #define ASL_WALK_VISIT_DOWNWARD     0x01
822 #define ASL_WALK_VISIT_UPWARD       0x02
823 #define ASL_WALK_VISIT_TWICE        (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
824 
825 
826 /*
827  * aslparseop.c - Parse op create/allocate/cache
828  */
829 ACPI_PARSE_OBJECT *
830 TrCreateOp (
831     UINT32                  ParseOpcode,
832     UINT32                  NumChildren,
833     ...);
834 
835 ACPI_PARSE_OBJECT *
836 TrCreateLeafOp (
837     UINT32                  ParseOpcode);
838 
839 ACPI_PARSE_OBJECT *
840 TrCreateNullTargetOp (
841     void);
842 
843 ACPI_PARSE_OBJECT *
844 TrCreateAssignmentOp (
845     ACPI_PARSE_OBJECT       *Target,
846     ACPI_PARSE_OBJECT       *Source);
847 
848 ACPI_PARSE_OBJECT *
849 TrCreateTargetOp (
850     ACPI_PARSE_OBJECT       *OriginalOp,
851     ACPI_PARSE_OBJECT       *ParentOp);
852 
853 ACPI_PARSE_OBJECT *
854 TrCreateValuedLeafOp (
855     UINT32                  ParseOpcode,
856     UINT64                  Value);
857 
858 ACPI_PARSE_OBJECT *
859 TrCreateConstantLeafOp (
860     UINT32                  ParseOpcode);
861 
862 ACPI_PARSE_OBJECT *
863 TrAllocateOp (
864     UINT32                  ParseOpcode);
865 
866 void
867 TrPrintOpFlags (
868     UINT32                  Flags,
869     UINT32                  OutputLevel);
870 
871 
872 /*
873  * asltree.c - Parse tree management
874  */
875 void
876 TrSetOpParent (
877     ACPI_PARSE_OBJECT       *Op,
878     ACPI_PARSE_OBJECT       *ParentOp);
879 
880 ACPI_PARSE_OBJECT *
881 TrSetOpIntegerValue (
882     UINT32                  ParseOpcode,
883     ACPI_PARSE_OBJECT       *Op);
884 
885 void
886 TrSetOpEndLineNumber (
887     ACPI_PARSE_OBJECT       *Op);
888 
889 void
890 TrSetOpCurrentFilename (
891     ACPI_PARSE_OBJECT       *Op);
892 
893 ACPI_PARSE_OBJECT *
894 TrLinkOpChildren (
895     ACPI_PARSE_OBJECT       *Op,
896     UINT32                  NumChildren,
897     ...);
898 
899 ACPI_PARSE_OBJECT *
900 TrLinkPeerOp (
901     ACPI_PARSE_OBJECT       *Op1,
902     ACPI_PARSE_OBJECT       *Op2);
903 
904 ACPI_PARSE_OBJECT *
905 TrLinkChildOp (
906     ACPI_PARSE_OBJECT       *Op1,
907     ACPI_PARSE_OBJECT       *Op2);
908 
909 ACPI_PARSE_OBJECT *
910 TrSetOpFlags (
911     ACPI_PARSE_OBJECT       *Op,
912     UINT32                  Flags);
913 
914 ACPI_PARSE_OBJECT *
915 TrSetOpAmlLength (
916     ACPI_PARSE_OBJECT       *Op,
917     UINT32                  Length);
918 
919 ACPI_PARSE_OBJECT *
920 TrLinkPeerOps (
921     UINT32                  NumPeers,
922     ...);
923 
924 ACPI_STATUS
925 TrWalkParseTree (
926     ACPI_PARSE_OBJECT       *Op,
927     UINT32                  Visitation,
928     ASL_WALK_CALLBACK       DescendingCallback,
929     ASL_WALK_CALLBACK       AscendingCallback,
930     void                    *Context);
931 
932 
933 /*
934  * aslfiles - File I/O support
935  */
936 void
937 FlAddIncludeDirectory (
938     char                    *Dir);
939 
940 char *
941 FlMergePathnames (
942     char                    *PrefixDir,
943     char                    *FilePathname);
944 
945 void
946 FlOpenIncludeFile (
947     ACPI_PARSE_OBJECT       *Op);
948 
949 void
950 FlFileError (
951     UINT32                  FileId,
952     UINT8                   ErrorId);
953 
954 UINT32
955 FlGetFileSize (
956     UINT32                  FileId);
957 
958 ACPI_STATUS
959 FlReadFile (
960     UINT32                  FileId,
961     void                    *Buffer,
962     UINT32                  Length);
963 
964 void
965 FlWriteFile (
966     UINT32                  FileId,
967     void                    *Buffer,
968     UINT32                  Length);
969 
970 void
971 FlSeekFile (
972     UINT32                  FileId,
973     long                    Offset);
974 
975 void
976 FlCloseFile (
977     UINT32                  FileId);
978 
979 void
980 FlPrintFile (
981     UINT32                  FileId,
982     char                    *Format,
983     ...);
984 
985 void
986 FlDeleteFile (
987     UINT32                  FileId);
988 
989 void
990 FlSetLineNumber (
991     UINT32                  LineNumber);
992 
993 void
994 FlSetFilename (
995     char                    *Filename);
996 
997 ACPI_STATUS
998 FlOpenInputFile (
999     char                    *InputFilename);
1000 
1001 ACPI_STATUS
1002 FlOpenAmlOutputFile (
1003     char                    *InputFilename);
1004 
1005 ACPI_STATUS
1006 FlOpenMiscOutputFiles (
1007     char                    *InputFilename);
1008 
1009 /*
1010  * aslhwmap - hardware map summary
1011  */
1012 void
1013 MpEmitMappingInfo (
1014     void);
1015 
1016 
1017 /*
1018  * asload - load namespace in prep for cross reference
1019  */
1020 ACPI_STATUS
1021 LdLoadNamespace (
1022     ACPI_PARSE_OBJECT       *RootOp);
1023 
1024 
1025 /*
1026  * asllookup - namespace lookup functions
1027  */
1028 void
1029 LkFindUnreferencedObjects (
1030     void);
1031 
1032 /*
1033  * aslhelp - help screens
1034  */
1035 void
1036 Usage (
1037     void);
1038 
1039 void
1040 AslFilenameHelp (
1041     void);
1042 
1043 void
1044 AslDisassemblyHelp (
1045     void);
1046 
1047 
1048 /*
1049  * aslnamesp - namespace output file generation
1050  */
1051 ACPI_STATUS
1052 NsDisplayNamespace (
1053     void);
1054 
1055 void
1056 NsSetupNamespaceListing (
1057     void                    *Handle);
1058 
1059 /*
1060  * asloptions - command line processing
1061  */
1062 int
1063 AslCommandLine (
1064     int                     argc,
1065     char                    **argv);
1066 
1067 /*
1068  * aslxref - namespace cross reference
1069  */
1070 ACPI_STATUS
1071 XfCrossReferenceNamespace (
1072     void);
1073 
1074 
1075 /*
1076  * aslxrefout
1077  */
1078 void
1079 OtPrintHeaders (
1080     char                    *Message);
1081 
1082 void
1083 OtCreateXrefFile (
1084     void);
1085 
1086 void
1087 OtXrefWalkPart1 (
1088     ACPI_PARSE_OBJECT       *Op,
1089     UINT32                  Level,
1090     ASL_METHOD_INFO         *MethodInfo);
1091 
1092 
1093 /*
1094  * aslutils - common compiler utilites
1095  */
1096 void
1097 DbgPrint (
1098     UINT32                  Type,
1099     char                    *Format,
1100     ...);
1101 
1102 /* Type values for above */
1103 
1104 #define ASL_DEBUG_OUTPUT    0
1105 #define ASL_PARSE_OUTPUT    1
1106 #define ASL_TREE_OUTPUT     2
1107 
1108 UINT8
1109 UtIsBigEndianMachine (
1110     void);
1111 
1112 BOOLEAN
1113 UtQueryForOverwrite (
1114     char                    *Pathname);
1115 
1116 void
1117 UtDumpStringOp (
1118     ACPI_PARSE_OBJECT       *Op,
1119     UINT32                  Level);
1120 
1121 void
1122 UtDumpIntegerOp (
1123     ACPI_PARSE_OBJECT       *Op,
1124     UINT32                  Level,
1125     UINT32                  IntegerLength);
1126 
1127 void
1128 UtDumpBasicOp (
1129     ACPI_PARSE_OBJECT       *Op,
1130     UINT32                  Level);
1131 
1132 void
1133 UtDisplaySupportedTables (
1134     void);
1135 
1136 void
1137 UtDisplayConstantOpcodes (
1138     void);
1139 
1140 UINT8
1141 UtBeginEvent (
1142     char                    *Name);
1143 
1144 void
1145 UtEndEvent (
1146     UINT8                   Event);
1147 
1148 void *
1149 UtLocalCalloc (
1150     UINT32                  Size);
1151 
1152 void
1153 UtDisplaySummary (
1154     UINT32                  FileId);
1155 
1156 void
1157 UtConvertByteToHex (
1158     UINT8                   RawByte,
1159     UINT8                   *Buffer);
1160 
1161 void
1162 UtConvertByteToAsmHex (
1163     UINT8                   RawByte,
1164     UINT8                   *Buffer);
1165 
1166 char *
1167 UtGetOpName (
1168     UINT32                  ParseOpcode);
1169 
1170 void
1171 UtSetParseOpName (
1172     ACPI_PARSE_OBJECT       *Op);
1173 
1174 char *
1175 UtStringCacheCalloc (
1176     UINT32                  Length);
1177 
1178 void
1179 UtExpandLineBuffers (
1180     void);
1181 
1182 void
1183 UtFreeLineBuffers (
1184     void);
1185 
1186 ACPI_STATUS
1187 UtInternalizeName (
1188     char                    *ExternalName,
1189     char                    **ConvertedName);
1190 
1191 void
1192 UtAttachNamepathToOwner (
1193     ACPI_PARSE_OBJECT       *Op,
1194     ACPI_PARSE_OBJECT       *NameNode);
1195 
1196 ACPI_PARSE_OBJECT *
1197 UtCheckIntegerRange (
1198     ACPI_PARSE_OBJECT       *Op,
1199     UINT32                  LowValue,
1200     UINT32                  HighValue);
1201 
1202 UINT64
1203 UtDoConstant (
1204     char                    *String);
1205 
1206 
1207 /*
1208  * asluuid - UUID support
1209  */
1210 ACPI_STATUS
1211 AuValidateUuid (
1212     char                    *InString);
1213 
1214 ACPI_STATUS
1215 AuConvertUuidToString (
1216     char                    *UuIdBuffer,
1217     char                    *OutString);
1218 
1219 /*
1220  * aslresource - Resource template generation utilities
1221  */
1222 void
1223 RsSmallAddressCheck (
1224     UINT8                   Type,
1225     UINT32                  Minimum,
1226     UINT32                  Maximum,
1227     UINT32                  Length,
1228     UINT32                  Alignment,
1229     ACPI_PARSE_OBJECT       *MinOp,
1230     ACPI_PARSE_OBJECT       *MaxOp,
1231     ACPI_PARSE_OBJECT       *LengthOp,
1232     ACPI_PARSE_OBJECT       *AlignOp,
1233     ACPI_PARSE_OBJECT       *Op);
1234 
1235 void
1236 RsLargeAddressCheck (
1237     UINT64                  Minimum,
1238     UINT64                  Maximum,
1239     UINT64                  Length,
1240     UINT64                  Granularity,
1241     UINT8                   Flags,
1242     ACPI_PARSE_OBJECT       *MinOp,
1243     ACPI_PARSE_OBJECT       *MaxOp,
1244     ACPI_PARSE_OBJECT       *LengthOp,
1245     ACPI_PARSE_OBJECT       *GranOp,
1246     ACPI_PARSE_OBJECT       *Op);
1247 
1248 UINT16
1249 RsGetStringDataLength (
1250     ACPI_PARSE_OBJECT       *InitializerOp);
1251 
1252 ASL_RESOURCE_NODE *
1253 RsAllocateResourceNode (
1254     UINT32                  Size);
1255 
1256 void
1257 RsCreateResourceField (
1258     ACPI_PARSE_OBJECT       *Op,
1259     char                    *Name,
1260     UINT32                  ByteOffset,
1261     UINT32                  BitOffset,
1262     UINT32                  BitLength);
1263 
1264 void
1265 RsSetFlagBits (
1266     UINT8                   *Flags,
1267     ACPI_PARSE_OBJECT       *Op,
1268     UINT8                   Position,
1269     UINT8                   DefaultBit);
1270 
1271 void
1272 RsSetFlagBits16 (
1273     UINT16                  *Flags,
1274     ACPI_PARSE_OBJECT       *Op,
1275     UINT8                   Position,
1276     UINT8                   DefaultBit);
1277 
1278 ACPI_PARSE_OBJECT *
1279 RsCompleteNodeAndGetNext (
1280     ACPI_PARSE_OBJECT       *Op);
1281 
1282 void
1283 RsCheckListForDuplicates (
1284     ACPI_PARSE_OBJECT       *Op);
1285 
1286 ASL_RESOURCE_NODE *
1287 RsDoOneResourceDescriptor (
1288     ASL_RESOURCE_INFO       *Info,
1289     UINT8                   *State);
1290 
1291 /* Values for State above */
1292 
1293 #define ACPI_RSTATE_NORMAL              0
1294 #define ACPI_RSTATE_START_DEPENDENT     1
1295 #define ACPI_RSTATE_DEPENDENT_LIST      2
1296 
1297 UINT32
1298 RsLinkDescriptorChain (
1299     ASL_RESOURCE_NODE       **PreviousRnode,
1300     ASL_RESOURCE_NODE       *Rnode);
1301 
1302 void
1303 RsDoResourceTemplate (
1304     ACPI_PARSE_OBJECT       *Op);
1305 
1306 
1307 /*
1308  * aslrestype1 - Miscellaneous Small descriptors
1309  */
1310 ASL_RESOURCE_NODE *
1311 RsDoEndTagDescriptor (
1312     ASL_RESOURCE_INFO       *Info);
1313 
1314 ASL_RESOURCE_NODE *
1315 RsDoEndDependentDescriptor (
1316     ASL_RESOURCE_INFO       *Info);
1317 
1318 ASL_RESOURCE_NODE *
1319 RsDoMemory24Descriptor (
1320     ASL_RESOURCE_INFO       *Info);
1321 
1322 ASL_RESOURCE_NODE *
1323 RsDoMemory32Descriptor (
1324     ASL_RESOURCE_INFO       *Info);
1325 
1326 ASL_RESOURCE_NODE *
1327 RsDoMemory32FixedDescriptor (
1328     ASL_RESOURCE_INFO       *Info);
1329 
1330 ASL_RESOURCE_NODE *
1331 RsDoStartDependentDescriptor (
1332     ASL_RESOURCE_INFO       *Info);
1333 
1334 ASL_RESOURCE_NODE *
1335 RsDoStartDependentNoPriDescriptor (
1336     ASL_RESOURCE_INFO       *Info);
1337 
1338 ASL_RESOURCE_NODE *
1339 RsDoVendorSmallDescriptor (
1340     ASL_RESOURCE_INFO       *Info);
1341 
1342 
1343 /*
1344  * aslrestype1i - I/O-related Small descriptors
1345  */
1346 ASL_RESOURCE_NODE *
1347 RsDoDmaDescriptor (
1348     ASL_RESOURCE_INFO       *Info);
1349 
1350 ASL_RESOURCE_NODE *
1351 RsDoFixedDmaDescriptor (
1352     ASL_RESOURCE_INFO       *Info);
1353 
1354 ASL_RESOURCE_NODE *
1355 RsDoFixedIoDescriptor (
1356     ASL_RESOURCE_INFO       *Info);
1357 
1358 ASL_RESOURCE_NODE *
1359 RsDoIoDescriptor (
1360     ASL_RESOURCE_INFO       *Info);
1361 
1362 ASL_RESOURCE_NODE *
1363 RsDoIrqDescriptor (
1364     ASL_RESOURCE_INFO       *Info);
1365 
1366 ASL_RESOURCE_NODE *
1367 RsDoIrqNoFlagsDescriptor (
1368     ASL_RESOURCE_INFO       *Info);
1369 
1370 
1371 /*
1372  * aslrestype2 - Large resource descriptors
1373  */
1374 ASL_RESOURCE_NODE *
1375 RsDoInterruptDescriptor (
1376     ASL_RESOURCE_INFO       *Info);
1377 
1378 ASL_RESOURCE_NODE *
1379 RsDoVendorLargeDescriptor (
1380     ASL_RESOURCE_INFO       *Info);
1381 
1382 ASL_RESOURCE_NODE *
1383 RsDoGeneralRegisterDescriptor (
1384     ASL_RESOURCE_INFO       *Info);
1385 
1386 ASL_RESOURCE_NODE *
1387 RsDoGpioIntDescriptor (
1388     ASL_RESOURCE_INFO       *Info);
1389 
1390 ASL_RESOURCE_NODE *
1391 RsDoGpioIoDescriptor (
1392     ASL_RESOURCE_INFO       *Info);
1393 
1394 ASL_RESOURCE_NODE *
1395 RsDoI2cSerialBusDescriptor (
1396     ASL_RESOURCE_INFO       *Info);
1397 
1398 ASL_RESOURCE_NODE *
1399 RsDoSpiSerialBusDescriptor (
1400     ASL_RESOURCE_INFO       *Info);
1401 
1402 ASL_RESOURCE_NODE *
1403 RsDoUartSerialBusDescriptor (
1404     ASL_RESOURCE_INFO       *Info);
1405 
1406 ASL_RESOURCE_NODE *
1407 RsDoPinFunctionDescriptor (
1408     ASL_RESOURCE_INFO       *Info);
1409 
1410 ASL_RESOURCE_NODE *
1411 RsDoPinConfigDescriptor (
1412     ASL_RESOURCE_INFO       *Info);
1413 
1414 ASL_RESOURCE_NODE *
1415 RsDoPinGroupDescriptor (
1416     ASL_RESOURCE_INFO       *Info);
1417 
1418 ASL_RESOURCE_NODE *
1419 RsDoPinGroupFunctionDescriptor (
1420     ASL_RESOURCE_INFO       *Info);
1421 
1422 ASL_RESOURCE_NODE *
1423 RsDoPinGroupConfigDescriptor (
1424     ASL_RESOURCE_INFO       *Info);
1425 
1426 /*
1427  * aslrestype2d - DWord address descriptors
1428  */
1429 ASL_RESOURCE_NODE *
1430 RsDoDwordIoDescriptor (
1431     ASL_RESOURCE_INFO       *Info);
1432 
1433 ASL_RESOURCE_NODE *
1434 RsDoDwordMemoryDescriptor (
1435     ASL_RESOURCE_INFO       *Info);
1436 
1437 ASL_RESOURCE_NODE *
1438 RsDoDwordSpaceDescriptor (
1439     ASL_RESOURCE_INFO       *Info);
1440 
1441 
1442 /*
1443  * aslrestype2e - Extended address descriptors
1444  */
1445 ASL_RESOURCE_NODE *
1446 RsDoExtendedIoDescriptor (
1447     ASL_RESOURCE_INFO       *Info);
1448 
1449 ASL_RESOURCE_NODE *
1450 RsDoExtendedMemoryDescriptor (
1451     ASL_RESOURCE_INFO       *Info);
1452 
1453 ASL_RESOURCE_NODE *
1454 RsDoExtendedSpaceDescriptor (
1455     ASL_RESOURCE_INFO       *Info);
1456 
1457 
1458 /*
1459  * aslrestype2q - QWord address descriptors
1460  */
1461 ASL_RESOURCE_NODE *
1462 RsDoQwordIoDescriptor (
1463     ASL_RESOURCE_INFO       *Info);
1464 
1465 ASL_RESOURCE_NODE *
1466 RsDoQwordMemoryDescriptor (
1467     ASL_RESOURCE_INFO       *Info);
1468 
1469 ASL_RESOURCE_NODE *
1470 RsDoQwordSpaceDescriptor (
1471     ASL_RESOURCE_INFO       *Info);
1472 
1473 
1474 /*
1475  * aslrestype2w - Word address descriptors
1476  */
1477 ASL_RESOURCE_NODE *
1478 RsDoWordIoDescriptor (
1479     ASL_RESOURCE_INFO       *Info);
1480 
1481 ASL_RESOURCE_NODE *
1482 RsDoWordSpaceDescriptor (
1483     ASL_RESOURCE_INFO       *Info);
1484 
1485 ASL_RESOURCE_NODE *
1486 RsDoWordBusNumberDescriptor (
1487     ASL_RESOURCE_INFO       *Info);
1488 
1489 
1490 /*
1491  * Entry to data table compiler subsystem
1492  */
1493 ACPI_STATUS
1494 DtDoCompile(
1495     void);
1496 
1497 ACPI_STATUS
1498 DtCreateTemplates (
1499     char                    **argv);
1500 
1501 
1502 /*
1503  * ASL/ASL+ converter debug
1504  */
1505 void
1506 CvDbgPrint (
1507     char                    *Fmt,
1508     ...);
1509 
1510 
1511 #endif /*  __ASLCOMPILER_H */
1512