Merge branch 'vendor/FILE'
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / aslcompiler.h
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 "acpi.h"
156 #include "accommon.h"
157 #include "amlresrc.h"
158 #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 "asldefine.h"
180 #include "asltypes.h"
181 #include "aslmessages.h"
182 #include "aslglobal.h"
183 #include "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 void
894 TrSetOpIntegerWidth (
895     ACPI_PARSE_OBJECT       *TableSignature,
896     ACPI_PARSE_OBJECT       *Revision);
897
898 ACPI_PARSE_OBJECT *
899 TrLinkOpChildren (
900     ACPI_PARSE_OBJECT       *Op,
901     UINT32                  NumChildren,
902     ...);
903
904 ACPI_PARSE_OBJECT *
905 TrLinkPeerOp (
906     ACPI_PARSE_OBJECT       *Op1,
907     ACPI_PARSE_OBJECT       *Op2);
908
909 ACPI_PARSE_OBJECT *
910 TrLinkChildOp (
911     ACPI_PARSE_OBJECT       *Op1,
912     ACPI_PARSE_OBJECT       *Op2);
913
914 ACPI_PARSE_OBJECT *
915 TrSetOpFlags (
916     ACPI_PARSE_OBJECT       *Op,
917     UINT32                  Flags);
918
919 ACPI_PARSE_OBJECT *
920 TrSetOpAmlLength (
921     ACPI_PARSE_OBJECT       *Op,
922     UINT32                  Length);
923
924 ACPI_PARSE_OBJECT *
925 TrLinkPeerOps (
926     UINT32                  NumPeers,
927     ...);
928
929 ACPI_STATUS
930 TrWalkParseTree (
931     ACPI_PARSE_OBJECT       *Op,
932     UINT32                  Visitation,
933     ASL_WALK_CALLBACK       DescendingCallback,
934     ASL_WALK_CALLBACK       AscendingCallback,
935     void                    *Context);
936
937
938 /*
939  * aslfiles - File I/O support
940  */
941 void
942 FlAddIncludeDirectory (
943     char                    *Dir);
944
945 char *
946 FlMergePathnames (
947     char                    *PrefixDir,
948     char                    *FilePathname);
949
950 void
951 FlOpenIncludeFile (
952     ACPI_PARSE_OBJECT       *Op);
953
954 void
955 FlFileError (
956     UINT32                  FileId,
957     UINT8                   ErrorId);
958
959 UINT32
960 FlGetFileSize (
961     UINT32                  FileId);
962
963 ACPI_STATUS
964 FlReadFile (
965     UINT32                  FileId,
966     void                    *Buffer,
967     UINT32                  Length);
968
969 void
970 FlWriteFile (
971     UINT32                  FileId,
972     void                    *Buffer,
973     UINT32                  Length);
974
975 void
976 FlSeekFile (
977     UINT32                  FileId,
978     long                    Offset);
979
980 void
981 FlCloseFile (
982     UINT32                  FileId);
983
984 void
985 FlPrintFile (
986     UINT32                  FileId,
987     char                    *Format,
988     ...);
989
990 void
991 FlDeleteFile (
992     UINT32                  FileId);
993
994 void
995 FlSetLineNumber (
996     UINT32                  LineNumber);
997
998 void
999 FlSetFilename (
1000     char                    *Filename);
1001
1002 ACPI_STATUS
1003 FlOpenInputFile (
1004     char                    *InputFilename);
1005
1006 ACPI_STATUS
1007 FlOpenAmlOutputFile (
1008     char                    *InputFilename);
1009
1010 ACPI_STATUS
1011 FlOpenMiscOutputFiles (
1012     char                    *InputFilename);
1013
1014 /*
1015  * aslhwmap - hardware map summary
1016  */
1017 void
1018 MpEmitMappingInfo (
1019     void);
1020
1021
1022 /*
1023  * asload - load namespace in prep for cross reference
1024  */
1025 ACPI_STATUS
1026 LdLoadNamespace (
1027     ACPI_PARSE_OBJECT       *RootOp);
1028
1029
1030 /*
1031  * asllookup - namespace lookup functions
1032  */
1033 void
1034 LkFindUnreferencedObjects (
1035     void);
1036
1037 /*
1038  * aslhelp - help screens
1039  */
1040 void
1041 Usage (
1042     void);
1043
1044 void
1045 AslFilenameHelp (
1046     void);
1047
1048 void
1049 AslDisassemblyHelp (
1050     void);
1051
1052
1053 /*
1054  * aslnamesp - namespace output file generation
1055  */
1056 ACPI_STATUS
1057 NsDisplayNamespace (
1058     void);
1059
1060 void
1061 NsSetupNamespaceListing (
1062     void                    *Handle);
1063
1064 /*
1065  * asloptions - command line processing
1066  */
1067 int
1068 AslCommandLine (
1069     int                     argc,
1070     char                    **argv);
1071
1072 /*
1073  * aslxref - namespace cross reference
1074  */
1075 ACPI_STATUS
1076 XfCrossReferenceNamespace (
1077     void);
1078
1079
1080 /*
1081  * aslxrefout
1082  */
1083 void
1084 OtPrintHeaders (
1085     char                    *Message);
1086
1087 void
1088 OtCreateXrefFile (
1089     void);
1090
1091 void
1092 OtXrefWalkPart1 (
1093     ACPI_PARSE_OBJECT       *Op,
1094     UINT32                  Level,
1095     ASL_METHOD_INFO         *MethodInfo);
1096
1097
1098 /*
1099  * aslutils - common compiler utilites
1100  */
1101 void
1102 DbgPrint (
1103     UINT32                  Type,
1104     char                    *Format,
1105     ...);
1106
1107 /* Type values for above */
1108
1109 #define ASL_DEBUG_OUTPUT    0
1110 #define ASL_PARSE_OUTPUT    1
1111 #define ASL_TREE_OUTPUT     2
1112
1113 UINT8
1114 UtIsBigEndianMachine (
1115     void);
1116
1117 BOOLEAN
1118 UtQueryForOverwrite (
1119     char                    *Pathname);
1120
1121 void
1122 UtDumpStringOp (
1123     ACPI_PARSE_OBJECT       *Op,
1124     UINT32                  Level);
1125
1126 void
1127 UtDumpIntegerOp (
1128     ACPI_PARSE_OBJECT       *Op,
1129     UINT32                  Level,
1130     UINT32                  IntegerLength);
1131
1132 void
1133 UtDumpBasicOp (
1134     ACPI_PARSE_OBJECT       *Op,
1135     UINT32                  Level);
1136
1137 void
1138 UtDisplaySupportedTables (
1139     void);
1140
1141 void
1142 UtDisplayConstantOpcodes (
1143     void);
1144
1145 UINT8
1146 UtBeginEvent (
1147     char                    *Name);
1148
1149 void
1150 UtEndEvent (
1151     UINT8                   Event);
1152
1153 void *
1154 UtLocalCalloc (
1155     UINT32                  Size);
1156
1157 void
1158 UtDisplaySummary (
1159     UINT32                  FileId);
1160
1161 void
1162 UtConvertByteToHex (
1163     UINT8                   RawByte,
1164     UINT8                   *Buffer);
1165
1166 void
1167 UtConvertByteToAsmHex (
1168     UINT8                   RawByte,
1169     UINT8                   *Buffer);
1170
1171 char *
1172 UtGetOpName (
1173     UINT32                  ParseOpcode);
1174
1175 void
1176 UtSetParseOpName (
1177     ACPI_PARSE_OBJECT       *Op);
1178
1179 char *
1180 UtStringCacheCalloc (
1181     UINT32                  Length);
1182
1183 void
1184 UtExpandLineBuffers (
1185     void);
1186
1187 void
1188 UtFreeLineBuffers (
1189     void);
1190
1191 ACPI_STATUS
1192 UtInternalizeName (
1193     char                    *ExternalName,
1194     char                    **ConvertedName);
1195
1196 void
1197 UtAttachNamepathToOwner (
1198     ACPI_PARSE_OBJECT       *Op,
1199     ACPI_PARSE_OBJECT       *NameNode);
1200
1201 ACPI_PARSE_OBJECT *
1202 UtCheckIntegerRange (
1203     ACPI_PARSE_OBJECT       *Op,
1204     UINT32                  LowValue,
1205     UINT32                  HighValue);
1206
1207 UINT64
1208 UtDoConstant (
1209     char                    *String);
1210
1211
1212 /*
1213  * asluuid - UUID support
1214  */
1215 ACPI_STATUS
1216 AuValidateUuid (
1217     char                    *InString);
1218
1219 ACPI_STATUS
1220 AuConvertUuidToString (
1221     char                    *UuIdBuffer,
1222     char                    *OutString);
1223
1224 /*
1225  * aslresource - Resource template generation utilities
1226  */
1227 void
1228 RsSmallAddressCheck (
1229     UINT8                   Type,
1230     UINT32                  Minimum,
1231     UINT32                  Maximum,
1232     UINT32                  Length,
1233     UINT32                  Alignment,
1234     ACPI_PARSE_OBJECT       *MinOp,
1235     ACPI_PARSE_OBJECT       *MaxOp,
1236     ACPI_PARSE_OBJECT       *LengthOp,
1237     ACPI_PARSE_OBJECT       *AlignOp,
1238     ACPI_PARSE_OBJECT       *Op);
1239
1240 void
1241 RsLargeAddressCheck (
1242     UINT64                  Minimum,
1243     UINT64                  Maximum,
1244     UINT64                  Length,
1245     UINT64                  Granularity,
1246     UINT8                   Flags,
1247     ACPI_PARSE_OBJECT       *MinOp,
1248     ACPI_PARSE_OBJECT       *MaxOp,
1249     ACPI_PARSE_OBJECT       *LengthOp,
1250     ACPI_PARSE_OBJECT       *GranOp,
1251     ACPI_PARSE_OBJECT       *Op);
1252
1253 UINT16
1254 RsGetStringDataLength (
1255     ACPI_PARSE_OBJECT       *InitializerOp);
1256
1257 ASL_RESOURCE_NODE *
1258 RsAllocateResourceNode (
1259     UINT32                  Size);
1260
1261 void
1262 RsCreateResourceField (
1263     ACPI_PARSE_OBJECT       *Op,
1264     char                    *Name,
1265     UINT32                  ByteOffset,
1266     UINT32                  BitOffset,
1267     UINT32                  BitLength);
1268
1269 void
1270 RsSetFlagBits (
1271     UINT8                   *Flags,
1272     ACPI_PARSE_OBJECT       *Op,
1273     UINT8                   Position,
1274     UINT8                   DefaultBit);
1275
1276 void
1277 RsSetFlagBits16 (
1278     UINT16                  *Flags,
1279     ACPI_PARSE_OBJECT       *Op,
1280     UINT8                   Position,
1281     UINT8                   DefaultBit);
1282
1283 ACPI_PARSE_OBJECT *
1284 RsCompleteNodeAndGetNext (
1285     ACPI_PARSE_OBJECT       *Op);
1286
1287 void
1288 RsCheckListForDuplicates (
1289     ACPI_PARSE_OBJECT       *Op);
1290
1291 ASL_RESOURCE_NODE *
1292 RsDoOneResourceDescriptor (
1293     ASL_RESOURCE_INFO       *Info,
1294     UINT8                   *State);
1295
1296 /* Values for State above */
1297
1298 #define ACPI_RSTATE_NORMAL              0
1299 #define ACPI_RSTATE_START_DEPENDENT     1
1300 #define ACPI_RSTATE_DEPENDENT_LIST      2
1301
1302 UINT32
1303 RsLinkDescriptorChain (
1304     ASL_RESOURCE_NODE       **PreviousRnode,
1305     ASL_RESOURCE_NODE       *Rnode);
1306
1307 void
1308 RsDoResourceTemplate (
1309     ACPI_PARSE_OBJECT       *Op);
1310
1311
1312 /*
1313  * aslrestype1 - Miscellaneous Small descriptors
1314  */
1315 ASL_RESOURCE_NODE *
1316 RsDoEndTagDescriptor (
1317     ASL_RESOURCE_INFO       *Info);
1318
1319 ASL_RESOURCE_NODE *
1320 RsDoEndDependentDescriptor (
1321     ASL_RESOURCE_INFO       *Info);
1322
1323 ASL_RESOURCE_NODE *
1324 RsDoMemory24Descriptor (
1325     ASL_RESOURCE_INFO       *Info);
1326
1327 ASL_RESOURCE_NODE *
1328 RsDoMemory32Descriptor (
1329     ASL_RESOURCE_INFO       *Info);
1330
1331 ASL_RESOURCE_NODE *
1332 RsDoMemory32FixedDescriptor (
1333     ASL_RESOURCE_INFO       *Info);
1334
1335 ASL_RESOURCE_NODE *
1336 RsDoStartDependentDescriptor (
1337     ASL_RESOURCE_INFO       *Info);
1338
1339 ASL_RESOURCE_NODE *
1340 RsDoStartDependentNoPriDescriptor (
1341     ASL_RESOURCE_INFO       *Info);
1342
1343 ASL_RESOURCE_NODE *
1344 RsDoVendorSmallDescriptor (
1345     ASL_RESOURCE_INFO       *Info);
1346
1347
1348 /*
1349  * aslrestype1i - I/O-related Small descriptors
1350  */
1351 ASL_RESOURCE_NODE *
1352 RsDoDmaDescriptor (
1353     ASL_RESOURCE_INFO       *Info);
1354
1355 ASL_RESOURCE_NODE *
1356 RsDoFixedDmaDescriptor (
1357     ASL_RESOURCE_INFO       *Info);
1358
1359 ASL_RESOURCE_NODE *
1360 RsDoFixedIoDescriptor (
1361     ASL_RESOURCE_INFO       *Info);
1362
1363 ASL_RESOURCE_NODE *
1364 RsDoIoDescriptor (
1365     ASL_RESOURCE_INFO       *Info);
1366
1367 ASL_RESOURCE_NODE *
1368 RsDoIrqDescriptor (
1369     ASL_RESOURCE_INFO       *Info);
1370
1371 ASL_RESOURCE_NODE *
1372 RsDoIrqNoFlagsDescriptor (
1373     ASL_RESOURCE_INFO       *Info);
1374
1375
1376 /*
1377  * aslrestype2 - Large resource descriptors
1378  */
1379 ASL_RESOURCE_NODE *
1380 RsDoInterruptDescriptor (
1381     ASL_RESOURCE_INFO       *Info);
1382
1383 ASL_RESOURCE_NODE *
1384 RsDoVendorLargeDescriptor (
1385     ASL_RESOURCE_INFO       *Info);
1386
1387 ASL_RESOURCE_NODE *
1388 RsDoGeneralRegisterDescriptor (
1389     ASL_RESOURCE_INFO       *Info);
1390
1391 ASL_RESOURCE_NODE *
1392 RsDoGpioIntDescriptor (
1393     ASL_RESOURCE_INFO       *Info);
1394
1395 ASL_RESOURCE_NODE *
1396 RsDoGpioIoDescriptor (
1397     ASL_RESOURCE_INFO       *Info);
1398
1399 ASL_RESOURCE_NODE *
1400 RsDoI2cSerialBusDescriptor (
1401     ASL_RESOURCE_INFO       *Info);
1402
1403 ASL_RESOURCE_NODE *
1404 RsDoSpiSerialBusDescriptor (
1405     ASL_RESOURCE_INFO       *Info);
1406
1407 ASL_RESOURCE_NODE *
1408 RsDoUartSerialBusDescriptor (
1409     ASL_RESOURCE_INFO       *Info);
1410
1411 ASL_RESOURCE_NODE *
1412 RsDoPinFunctionDescriptor (
1413     ASL_RESOURCE_INFO       *Info);
1414
1415 ASL_RESOURCE_NODE *
1416 RsDoPinConfigDescriptor (
1417     ASL_RESOURCE_INFO       *Info);
1418
1419 ASL_RESOURCE_NODE *
1420 RsDoPinGroupDescriptor (
1421     ASL_RESOURCE_INFO       *Info);
1422
1423 ASL_RESOURCE_NODE *
1424 RsDoPinGroupFunctionDescriptor (
1425     ASL_RESOURCE_INFO       *Info);
1426
1427 ASL_RESOURCE_NODE *
1428 RsDoPinGroupConfigDescriptor (
1429     ASL_RESOURCE_INFO       *Info);
1430
1431 /*
1432  * aslrestype2d - DWord address descriptors
1433  */
1434 ASL_RESOURCE_NODE *
1435 RsDoDwordIoDescriptor (
1436     ASL_RESOURCE_INFO       *Info);
1437
1438 ASL_RESOURCE_NODE *
1439 RsDoDwordMemoryDescriptor (
1440     ASL_RESOURCE_INFO       *Info);
1441
1442 ASL_RESOURCE_NODE *
1443 RsDoDwordSpaceDescriptor (
1444     ASL_RESOURCE_INFO       *Info);
1445
1446
1447 /*
1448  * aslrestype2e - Extended address descriptors
1449  */
1450 ASL_RESOURCE_NODE *
1451 RsDoExtendedIoDescriptor (
1452     ASL_RESOURCE_INFO       *Info);
1453
1454 ASL_RESOURCE_NODE *
1455 RsDoExtendedMemoryDescriptor (
1456     ASL_RESOURCE_INFO       *Info);
1457
1458 ASL_RESOURCE_NODE *
1459 RsDoExtendedSpaceDescriptor (
1460     ASL_RESOURCE_INFO       *Info);
1461
1462
1463 /*
1464  * aslrestype2q - QWord address descriptors
1465  */
1466 ASL_RESOURCE_NODE *
1467 RsDoQwordIoDescriptor (
1468     ASL_RESOURCE_INFO       *Info);
1469
1470 ASL_RESOURCE_NODE *
1471 RsDoQwordMemoryDescriptor (
1472     ASL_RESOURCE_INFO       *Info);
1473
1474 ASL_RESOURCE_NODE *
1475 RsDoQwordSpaceDescriptor (
1476     ASL_RESOURCE_INFO       *Info);
1477
1478
1479 /*
1480  * aslrestype2w - Word address descriptors
1481  */
1482 ASL_RESOURCE_NODE *
1483 RsDoWordIoDescriptor (
1484     ASL_RESOURCE_INFO       *Info);
1485
1486 ASL_RESOURCE_NODE *
1487 RsDoWordSpaceDescriptor (
1488     ASL_RESOURCE_INFO       *Info);
1489
1490 ASL_RESOURCE_NODE *
1491 RsDoWordBusNumberDescriptor (
1492     ASL_RESOURCE_INFO       *Info);
1493
1494
1495 /*
1496  * Entry to data table compiler subsystem
1497  */
1498 ACPI_STATUS
1499 DtDoCompile(
1500     void);
1501
1502 ACPI_STATUS
1503 DtCreateTemplates (
1504     char                    **argv);
1505
1506
1507 /*
1508  * ASL/ASL+ converter debug
1509  */
1510 void
1511 CvDbgPrint (
1512     char                    *Fmt,
1513     ...);
1514
1515
1516 #endif /*  __ASLCOMPILER_H */