Sync ACPICA with Intel's version 20170629.
[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 ACPI_STATUS
417 AslDisableException (
418     char                    *MessageIdString);
419
420 BOOLEAN
421 AslIsExceptionDisabled (
422     UINT8                   Level,
423     UINT16                  MessageId);
424
425 void
426 AslCoreSubsystemError (
427     ACPI_PARSE_OBJECT       *Op,
428     ACPI_STATUS             Status,
429     char                    *ExtraMessage,
430     BOOLEAN                 Abort);
431
432 int
433 AslCompilererror(
434     const char              *s);
435
436 void
437 AslCommonError (
438     UINT8                   Level,
439     UINT16                  MessageId,
440     UINT32                  CurrentLineNumber,
441     UINT32                  LogicalLineNumber,
442     UINT32                  LogicalByteOffset,
443     UINT32                  Column,
444     char                    *Filename,
445     char                    *ExtraMessage);
446
447 void
448 AslCommonError2 (
449     UINT8                   Level,
450     UINT16                  MessageId,
451     UINT32                  LineNumber,
452     UINT32                  Column,
453     char                    *SourceLine,
454     char                    *Filename,
455     char                    *ExtraMessage);
456
457 void
458 AePrintException (
459     UINT32                  FileId,
460     ASL_ERROR_MSG           *Enode,
461     char                    *Header);
462
463 void
464 AePrintErrorLog (
465     UINT32                  FileId);
466
467 void
468 AeClearErrorLog (
469     void);
470
471
472 /*
473  * asllisting - generate all "listing" type files
474  */
475 void
476 LsDoListings (
477     void);
478
479 void
480 LsWriteNodeToAsmListing (
481     ACPI_PARSE_OBJECT       *Op);
482
483 void
484 LsWriteNode (
485     ACPI_PARSE_OBJECT       *Op,
486     UINT32                  FileId);
487
488 void
489 LsDumpParseTree (
490     void);
491
492
493 /*
494  * asllistsup - Listing file support utilities
495  */
496 void
497 LsDumpAscii (
498     UINT32                  FileId,
499     UINT32                  Count,
500     UINT8                   *Buffer);
501
502 void
503 LsDumpAsciiInComment (
504     UINT32                  FileId,
505     UINT32                  Count,
506     UINT8                   *Buffer);
507
508 void
509 LsCheckException (
510     UINT32                  LineNumber,
511     UINT32                  FileId);
512
513 void
514 LsFlushListingBuffer (
515     UINT32                  FileId);
516
517 void
518 LsWriteListingHexBytes (
519     UINT8                   *Buffer,
520     UINT32                  Length,
521     UINT32                  FileId);
522
523 void
524 LsWriteSourceLines (
525     UINT32                  ToLineNumber,
526     UINT32                  ToLogicalLineNumber,
527     UINT32                  FileId);
528
529 UINT32
530 LsWriteOneSourceLine (
531     UINT32                  FileId);
532
533 void
534 LsPushNode (
535     char                    *Filename);
536
537 ASL_LISTING_NODE *
538 LsPopNode (
539     void);
540
541
542 /*
543  * aslhex - generate all "hex" output files (C, ASM, ASL)
544  */
545 void
546 HxDoHexOutput (
547     void);
548
549
550 /*
551  * aslfold - constant folding
552  */
553 ACPI_STATUS
554 OpcAmlConstantWalk (
555     ACPI_PARSE_OBJECT       *Op,
556     UINT32                  Level,
557     void                    *Context);
558
559
560 /*
561  * aslmessages - exception strings
562  */
563 const char *
564 AeDecodeMessageId (
565     UINT16                  MessageId);
566
567 const char *
568 AeDecodeExceptionLevel (
569     UINT8                   Level);
570
571 UINT16
572 AeBuildFullExceptionCode (
573     UINT8                   Level,
574     UINT16                  MessageId);
575
576 /*
577  * asloffset - generate C offset file for BIOS support
578  */
579 ACPI_STATUS
580 LsAmlOffsetWalk (
581     ACPI_PARSE_OBJECT       *Op,
582     UINT32                  Level,
583     void                    *Context);
584
585 void
586 LsDoOffsetTableHeader (
587     UINT32                  FileId);
588
589 void
590 LsDoOffsetTableFooter (
591     UINT32                  FileId);
592
593
594 /*
595  * aslopcodes - generate AML opcodes
596  */
597 ACPI_STATUS
598 OpcAmlOpcodeWalk (
599     ACPI_PARSE_OBJECT       *Op,
600     UINT32                  Level,
601     void                    *Context);
602
603 ACPI_STATUS
604 OpcAmlOpcodeUpdateWalk (
605     ACPI_PARSE_OBJECT       *Op,
606     UINT32                  Level,
607     void                    *Context);
608
609 void
610 OpcGenerateAmlOpcode (
611     ACPI_PARSE_OBJECT       *Op);
612
613 UINT32
614 OpcSetOptimalIntegerSize (
615     ACPI_PARSE_OBJECT       *Op);
616
617 void
618 OpcGetIntegerWidth (
619     ACPI_PARSE_OBJECT       *Op);
620
621
622 /*
623  * asloperands - generate AML operands for the AML opcodes
624  */
625 ACPI_PARSE_OBJECT  *
626 UtGetArg (
627     ACPI_PARSE_OBJECT       *Op,
628     UINT32                  Argn);
629
630 void
631 OpnGenerateAmlOperands (
632     ACPI_PARSE_OBJECT       *Op);
633
634 void
635 OpnDoPackage (
636     ACPI_PARSE_OBJECT       *Op);
637
638
639 /*
640  * aslopt - optmization
641  */
642 void
643 OptOptimizeNamePath (
644     ACPI_PARSE_OBJECT       *Op,
645     UINT32                  Flags,
646     ACPI_WALK_STATE         *WalkState,
647     char                    *AmlNameString,
648     ACPI_NAMESPACE_NODE     *TargetNode);
649
650
651 /*
652  * aslpld - ToPLD macro support
653  */
654 void
655 OpcDoPld (
656     ACPI_PARSE_OBJECT       *Op);
657
658
659 /*
660  * aslprintf - Printf/Fprintf macros
661  */
662 void
663 OpcDoPrintf (
664     ACPI_PARSE_OBJECT       *Op);
665
666 void
667 OpcDoFprintf (
668     ACPI_PARSE_OBJECT       *Op);
669
670
671 /*
672  * aslprune - parse tree pruner
673  */
674 void
675 AslPruneParseTree (
676     UINT32                  PruneDepth,
677     UINT32                  Type);
678
679
680 /*
681  * aslcodegen - code generation
682  */
683 void
684 CgGenerateAmlOutput (
685     void);
686
687 void
688 CgLocalWriteAmlData (
689     ACPI_PARSE_OBJECT       *Op,
690     void                    *Buffer,
691     UINT32                  Length);
692
693
694 /*
695  * aslfile
696  */
697 void
698 FlOpenFile (
699     UINT32                  FileId,
700     char                    *Filename,
701     char                    *Mode);
702
703
704 /*
705  * asllength - calculate/adjust AML package lengths
706  */
707 ACPI_STATUS
708 LnPackageLengthWalk (
709     ACPI_PARSE_OBJECT       *Op,
710     UINT32                  Level,
711     void                    *Context);
712
713 ACPI_STATUS
714 LnInitLengthsWalk (
715     ACPI_PARSE_OBJECT       *Op,
716     UINT32                  Level,
717     void                    *Context);
718
719 void
720 CgGenerateAmlLengths (
721     ACPI_PARSE_OBJECT       *Op);
722
723
724 /*
725  * aslmap - opcode mappings and reserved method names
726  */
727 ACPI_OBJECT_TYPE
728 AslMapNamedOpcodeToDataType (
729     UINT16                  Opcode);
730
731
732 /*
733  * aslpredef - ACPI predefined names support
734  */
735 BOOLEAN
736 ApCheckForPredefinedMethod (
737     ACPI_PARSE_OBJECT       *Op,
738     ASL_METHOD_INFO         *MethodInfo);
739
740 void
741 ApCheckPredefinedReturnValue (
742     ACPI_PARSE_OBJECT       *Op,
743     ASL_METHOD_INFO         *MethodInfo);
744
745 UINT32
746 ApCheckForPredefinedName (
747     ACPI_PARSE_OBJECT       *Op,
748     char                    *Name);
749
750 void
751 ApCheckForPredefinedObject (
752     ACPI_PARSE_OBJECT       *Op,
753     char                    *Name);
754
755 ACPI_STATUS
756 ApCheckObjectType (
757     const char              *PredefinedName,
758     ACPI_PARSE_OBJECT       *Op,
759     UINT32                  ExpectedBtypes,
760     UINT32                  PackageIndex);
761
762 void
763 ApDisplayReservedNames (
764     void);
765
766
767 /*
768  * aslprepkg - ACPI predefined names support for packages
769  */
770 void
771 ApCheckPackage (
772     ACPI_PARSE_OBJECT           *ParentOp,
773     const ACPI_PREDEFINED_INFO  *Predefined);
774
775
776 /*
777  * asltransform - parse tree transformations
778  */
779 ACPI_STATUS
780 TrAmlTransformWalkBegin (
781     ACPI_PARSE_OBJECT       *Op,
782     UINT32                  Level,
783     void                    *Context);
784
785 ACPI_STATUS
786 TrAmlTransformWalkEnd (
787     ACPI_PARSE_OBJECT       *Op,
788     UINT32                  Level,
789     void                    *Context);
790
791
792 /*
793  * aslexternal - External opcode support
794  */
795 ACPI_STATUS
796 ExAmlExternalWalkBegin (
797     ACPI_PARSE_OBJECT       *Op,
798     UINT32                  Level,
799     void                    *Context);
800
801 ACPI_STATUS
802 ExAmlExternalWalkEnd (
803     ACPI_PARSE_OBJECT       *Op,
804     UINT32                  Level,
805     void                    *Context);
806
807 void
808 ExDoExternal (
809     ACPI_PARSE_OBJECT       *Op);
810
811 /* Values for "Visitation" parameter above */
812
813 #define ASL_WALK_VISIT_DOWNWARD     0x01
814 #define ASL_WALK_VISIT_UPWARD       0x02
815 #define ASL_WALK_VISIT_TWICE        (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
816
817
818 /*
819  * aslparseop.c - Parse op create/allocate/cache
820  */
821 ACPI_PARSE_OBJECT *
822 TrCreateOp (
823     UINT32                  ParseOpcode,
824     UINT32                  NumChildren,
825     ...);
826
827 ACPI_PARSE_OBJECT *
828 TrCreateLeafOp (
829     UINT32                  ParseOpcode);
830
831 ACPI_PARSE_OBJECT *
832 TrCreateNullTargetOp (
833     void);
834
835 ACPI_PARSE_OBJECT *
836 TrCreateAssignmentOp (
837     ACPI_PARSE_OBJECT       *Target,
838     ACPI_PARSE_OBJECT       *Source);
839
840 ACPI_PARSE_OBJECT *
841 TrCreateTargetOp (
842     ACPI_PARSE_OBJECT       *OriginalOp,
843     ACPI_PARSE_OBJECT       *ParentOp);
844
845 ACPI_PARSE_OBJECT *
846 TrCreateValuedLeafOp (
847     UINT32                  ParseOpcode,
848     UINT64                  Value);
849
850 ACPI_PARSE_OBJECT *
851 TrCreateConstantLeafOp (
852     UINT32                  ParseOpcode);
853
854 ACPI_PARSE_OBJECT *
855 TrAllocateOp (
856     UINT32                  ParseOpcode);
857
858 void
859 TrPrintOpFlags (
860     UINT32                  Flags,
861     UINT32                  OutputLevel);
862
863
864 /*
865  * asltree.c - Parse tree management
866  */
867 void
868 TrSetOpParent (
869     ACPI_PARSE_OBJECT       *Op,
870     ACPI_PARSE_OBJECT       *ParentOp);
871
872 ACPI_PARSE_OBJECT *
873 TrSetOpIntegerValue (
874     UINT32                  ParseOpcode,
875     ACPI_PARSE_OBJECT       *Op);
876
877 void
878 TrSetOpEndLineNumber (
879     ACPI_PARSE_OBJECT       *Op);
880
881 void
882 TrSetOpCurrentFilename (
883     ACPI_PARSE_OBJECT       *Op);
884
885 ACPI_PARSE_OBJECT *
886 TrLinkOpChildren (
887     ACPI_PARSE_OBJECT       *Op,
888     UINT32                  NumChildren,
889     ...);
890
891 ACPI_PARSE_OBJECT *
892 TrLinkPeerOp (
893     ACPI_PARSE_OBJECT       *Op1,
894     ACPI_PARSE_OBJECT       *Op2);
895
896 ACPI_PARSE_OBJECT *
897 TrLinkChildOp (
898     ACPI_PARSE_OBJECT       *Op1,
899     ACPI_PARSE_OBJECT       *Op2);
900
901 ACPI_PARSE_OBJECT *
902 TrSetOpFlags (
903     ACPI_PARSE_OBJECT       *Op,
904     UINT32                  Flags);
905
906 ACPI_PARSE_OBJECT *
907 TrSetOpAmlLength (
908     ACPI_PARSE_OBJECT       *Op,
909     UINT32                  Length);
910
911 ACPI_PARSE_OBJECT *
912 TrLinkPeerOps (
913     UINT32                  NumPeers,
914     ...);
915
916 ACPI_STATUS
917 TrWalkParseTree (
918     ACPI_PARSE_OBJECT       *Op,
919     UINT32                  Visitation,
920     ASL_WALK_CALLBACK       DescendingCallback,
921     ASL_WALK_CALLBACK       AscendingCallback,
922     void                    *Context);
923
924
925 /*
926  * aslfiles - File I/O support
927  */
928 void
929 FlAddIncludeDirectory (
930     char                    *Dir);
931
932 char *
933 FlMergePathnames (
934     char                    *PrefixDir,
935     char                    *FilePathname);
936
937 void
938 FlOpenIncludeFile (
939     ACPI_PARSE_OBJECT       *Op);
940
941 void
942 FlFileError (
943     UINT32                  FileId,
944     UINT8                   ErrorId);
945
946 UINT32
947 FlGetFileSize (
948     UINT32                  FileId);
949
950 ACPI_STATUS
951 FlReadFile (
952     UINT32                  FileId,
953     void                    *Buffer,
954     UINT32                  Length);
955
956 void
957 FlWriteFile (
958     UINT32                  FileId,
959     void                    *Buffer,
960     UINT32                  Length);
961
962 void
963 FlSeekFile (
964     UINT32                  FileId,
965     long                    Offset);
966
967 void
968 FlCloseFile (
969     UINT32                  FileId);
970
971 void
972 FlPrintFile (
973     UINT32                  FileId,
974     char                    *Format,
975     ...);
976
977 void
978 FlDeleteFile (
979     UINT32                  FileId);
980
981 void
982 FlSetLineNumber (
983     UINT32                  LineNumber);
984
985 void
986 FlSetFilename (
987     char                    *Filename);
988
989 ACPI_STATUS
990 FlOpenInputFile (
991     char                    *InputFilename);
992
993 ACPI_STATUS
994 FlOpenAmlOutputFile (
995     char                    *InputFilename);
996
997 ACPI_STATUS
998 FlOpenMiscOutputFiles (
999     char                    *InputFilename);
1000
1001 /*
1002  * aslhwmap - hardware map summary
1003  */
1004 void
1005 MpEmitMappingInfo (
1006     void);
1007
1008
1009 /*
1010  * asload - load namespace in prep for cross reference
1011  */
1012 ACPI_STATUS
1013 LdLoadNamespace (
1014     ACPI_PARSE_OBJECT       *RootOp);
1015
1016
1017 /*
1018  * asllookup - namespace lookup functions
1019  */
1020 void
1021 LkFindUnreferencedObjects (
1022     void);
1023
1024 /*
1025  * aslhelp - help screens
1026  */
1027 void
1028 Usage (
1029     void);
1030
1031 void
1032 AslFilenameHelp (
1033     void);
1034
1035 void
1036 AslDisassemblyHelp (
1037     void);
1038
1039
1040 /*
1041  * aslnamesp - namespace output file generation
1042  */
1043 ACPI_STATUS
1044 NsDisplayNamespace (
1045     void);
1046
1047 void
1048 NsSetupNamespaceListing (
1049     void                    *Handle);
1050
1051 /*
1052  * asloptions - command line processing
1053  */
1054 int
1055 AslCommandLine (
1056     int                     argc,
1057     char                    **argv);
1058
1059 /*
1060  * aslxref - namespace cross reference
1061  */
1062 ACPI_STATUS
1063 XfCrossReferenceNamespace (
1064     void);
1065
1066
1067 /*
1068  * aslxrefout
1069  */
1070 void
1071 OtPrintHeaders (
1072     char                    *Message);
1073
1074 void
1075 OtCreateXrefFile (
1076     void);
1077
1078 void
1079 OtXrefWalkPart1 (
1080     ACPI_PARSE_OBJECT       *Op,
1081     UINT32                  Level,
1082     ASL_METHOD_INFO         *MethodInfo);
1083
1084
1085 /*
1086  * aslutils - common compiler utilites
1087  */
1088 void
1089 DbgPrint (
1090     UINT32                  Type,
1091     char                    *Format,
1092     ...);
1093
1094 /* Type values for above */
1095
1096 #define ASL_DEBUG_OUTPUT    0
1097 #define ASL_PARSE_OUTPUT    1
1098 #define ASL_TREE_OUTPUT     2
1099
1100 UINT8
1101 UtIsBigEndianMachine (
1102     void);
1103
1104 BOOLEAN
1105 UtQueryForOverwrite (
1106     char                    *Pathname);
1107
1108 void
1109 UtDumpStringOp (
1110     ACPI_PARSE_OBJECT       *Op,
1111     UINT32                  Level);
1112
1113 void
1114 UtDumpIntegerOp (
1115     ACPI_PARSE_OBJECT       *Op,
1116     UINT32                  Level,
1117     UINT32                  IntegerLength);
1118
1119 void
1120 UtDumpBasicOp (
1121     ACPI_PARSE_OBJECT       *Op,
1122     UINT32                  Level);
1123
1124 void
1125 UtDisplaySupportedTables (
1126     void);
1127
1128 void
1129 UtDisplayConstantOpcodes (
1130     void);
1131
1132 UINT8
1133 UtBeginEvent (
1134     char                    *Name);
1135
1136 void
1137 UtEndEvent (
1138     UINT8                   Event);
1139
1140 void *
1141 UtLocalCalloc (
1142     UINT32                  Size);
1143
1144 void
1145 UtDisplaySummary (
1146     UINT32                  FileId);
1147
1148 void
1149 UtConvertByteToHex (
1150     UINT8                   RawByte,
1151     UINT8                   *Buffer);
1152
1153 void
1154 UtConvertByteToAsmHex (
1155     UINT8                   RawByte,
1156     UINT8                   *Buffer);
1157
1158 char *
1159 UtGetOpName (
1160     UINT32                  ParseOpcode);
1161
1162 void
1163 UtSetParseOpName (
1164     ACPI_PARSE_OBJECT       *Op);
1165
1166 char *
1167 UtStringCacheCalloc (
1168     UINT32                  Length);
1169
1170 void
1171 UtExpandLineBuffers (
1172     void);
1173
1174 void
1175 UtFreeLineBuffers (
1176     void);
1177
1178 ACPI_STATUS
1179 UtInternalizeName (
1180     char                    *ExternalName,
1181     char                    **ConvertedName);
1182
1183 void
1184 UtAttachNamepathToOwner (
1185     ACPI_PARSE_OBJECT       *Op,
1186     ACPI_PARSE_OBJECT       *NameNode);
1187
1188 ACPI_PARSE_OBJECT *
1189 UtCheckIntegerRange (
1190     ACPI_PARSE_OBJECT       *Op,
1191     UINT32                  LowValue,
1192     UINT32                  HighValue);
1193
1194 UINT64
1195 UtDoConstant (
1196     char                    *String);
1197
1198
1199 /*
1200  * asluuid - UUID support
1201  */
1202 ACPI_STATUS
1203 AuValidateUuid (
1204     char                    *InString);
1205
1206 ACPI_STATUS
1207 AuConvertUuidToString (
1208     char                    *UuIdBuffer,
1209     char                    *OutString);
1210
1211 /*
1212  * aslresource - Resource template generation utilities
1213  */
1214 void
1215 RsSmallAddressCheck (
1216     UINT8                   Type,
1217     UINT32                  Minimum,
1218     UINT32                  Maximum,
1219     UINT32                  Length,
1220     UINT32                  Alignment,
1221     ACPI_PARSE_OBJECT       *MinOp,
1222     ACPI_PARSE_OBJECT       *MaxOp,
1223     ACPI_PARSE_OBJECT       *LengthOp,
1224     ACPI_PARSE_OBJECT       *AlignOp,
1225     ACPI_PARSE_OBJECT       *Op);
1226
1227 void
1228 RsLargeAddressCheck (
1229     UINT64                  Minimum,
1230     UINT64                  Maximum,
1231     UINT64                  Length,
1232     UINT64                  Granularity,
1233     UINT8                   Flags,
1234     ACPI_PARSE_OBJECT       *MinOp,
1235     ACPI_PARSE_OBJECT       *MaxOp,
1236     ACPI_PARSE_OBJECT       *LengthOp,
1237     ACPI_PARSE_OBJECT       *GranOp,
1238     ACPI_PARSE_OBJECT       *Op);
1239
1240 UINT16
1241 RsGetStringDataLength (
1242     ACPI_PARSE_OBJECT       *InitializerOp);
1243
1244 ASL_RESOURCE_NODE *
1245 RsAllocateResourceNode (
1246     UINT32                  Size);
1247
1248 void
1249 RsCreateResourceField (
1250     ACPI_PARSE_OBJECT       *Op,
1251     char                    *Name,
1252     UINT32                  ByteOffset,
1253     UINT32                  BitOffset,
1254     UINT32                  BitLength);
1255
1256 void
1257 RsSetFlagBits (
1258     UINT8                   *Flags,
1259     ACPI_PARSE_OBJECT       *Op,
1260     UINT8                   Position,
1261     UINT8                   DefaultBit);
1262
1263 void
1264 RsSetFlagBits16 (
1265     UINT16                  *Flags,
1266     ACPI_PARSE_OBJECT       *Op,
1267     UINT8                   Position,
1268     UINT8                   DefaultBit);
1269
1270 ACPI_PARSE_OBJECT *
1271 RsCompleteNodeAndGetNext (
1272     ACPI_PARSE_OBJECT       *Op);
1273
1274 void
1275 RsCheckListForDuplicates (
1276     ACPI_PARSE_OBJECT       *Op);
1277
1278 ASL_RESOURCE_NODE *
1279 RsDoOneResourceDescriptor (
1280     ASL_RESOURCE_INFO       *Info,
1281     UINT8                   *State);
1282
1283 /* Values for State above */
1284
1285 #define ACPI_RSTATE_NORMAL              0
1286 #define ACPI_RSTATE_START_DEPENDENT     1
1287 #define ACPI_RSTATE_DEPENDENT_LIST      2
1288
1289 UINT32
1290 RsLinkDescriptorChain (
1291     ASL_RESOURCE_NODE       **PreviousRnode,
1292     ASL_RESOURCE_NODE       *Rnode);
1293
1294 void
1295 RsDoResourceTemplate (
1296     ACPI_PARSE_OBJECT       *Op);
1297
1298
1299 /*
1300  * aslrestype1 - Miscellaneous Small descriptors
1301  */
1302 ASL_RESOURCE_NODE *
1303 RsDoEndTagDescriptor (
1304     ASL_RESOURCE_INFO       *Info);
1305
1306 ASL_RESOURCE_NODE *
1307 RsDoEndDependentDescriptor (
1308     ASL_RESOURCE_INFO       *Info);
1309
1310 ASL_RESOURCE_NODE *
1311 RsDoMemory24Descriptor (
1312     ASL_RESOURCE_INFO       *Info);
1313
1314 ASL_RESOURCE_NODE *
1315 RsDoMemory32Descriptor (
1316     ASL_RESOURCE_INFO       *Info);
1317
1318 ASL_RESOURCE_NODE *
1319 RsDoMemory32FixedDescriptor (
1320     ASL_RESOURCE_INFO       *Info);
1321
1322 ASL_RESOURCE_NODE *
1323 RsDoStartDependentDescriptor (
1324     ASL_RESOURCE_INFO       *Info);
1325
1326 ASL_RESOURCE_NODE *
1327 RsDoStartDependentNoPriDescriptor (
1328     ASL_RESOURCE_INFO       *Info);
1329
1330 ASL_RESOURCE_NODE *
1331 RsDoVendorSmallDescriptor (
1332     ASL_RESOURCE_INFO       *Info);
1333
1334
1335 /*
1336  * aslrestype1i - I/O-related Small descriptors
1337  */
1338 ASL_RESOURCE_NODE *
1339 RsDoDmaDescriptor (
1340     ASL_RESOURCE_INFO       *Info);
1341
1342 ASL_RESOURCE_NODE *
1343 RsDoFixedDmaDescriptor (
1344     ASL_RESOURCE_INFO       *Info);
1345
1346 ASL_RESOURCE_NODE *
1347 RsDoFixedIoDescriptor (
1348     ASL_RESOURCE_INFO       *Info);
1349
1350 ASL_RESOURCE_NODE *
1351 RsDoIoDescriptor (
1352     ASL_RESOURCE_INFO       *Info);
1353
1354 ASL_RESOURCE_NODE *
1355 RsDoIrqDescriptor (
1356     ASL_RESOURCE_INFO       *Info);
1357
1358 ASL_RESOURCE_NODE *
1359 RsDoIrqNoFlagsDescriptor (
1360     ASL_RESOURCE_INFO       *Info);
1361
1362
1363 /*
1364  * aslrestype2 - Large resource descriptors
1365  */
1366 ASL_RESOURCE_NODE *
1367 RsDoInterruptDescriptor (
1368     ASL_RESOURCE_INFO       *Info);
1369
1370 ASL_RESOURCE_NODE *
1371 RsDoVendorLargeDescriptor (
1372     ASL_RESOURCE_INFO       *Info);
1373
1374 ASL_RESOURCE_NODE *
1375 RsDoGeneralRegisterDescriptor (
1376     ASL_RESOURCE_INFO       *Info);
1377
1378 ASL_RESOURCE_NODE *
1379 RsDoGpioIntDescriptor (
1380     ASL_RESOURCE_INFO       *Info);
1381
1382 ASL_RESOURCE_NODE *
1383 RsDoGpioIoDescriptor (
1384     ASL_RESOURCE_INFO       *Info);
1385
1386 ASL_RESOURCE_NODE *
1387 RsDoI2cSerialBusDescriptor (
1388     ASL_RESOURCE_INFO       *Info);
1389
1390 ASL_RESOURCE_NODE *
1391 RsDoSpiSerialBusDescriptor (
1392     ASL_RESOURCE_INFO       *Info);
1393
1394 ASL_RESOURCE_NODE *
1395 RsDoUartSerialBusDescriptor (
1396     ASL_RESOURCE_INFO       *Info);
1397
1398 ASL_RESOURCE_NODE *
1399 RsDoPinFunctionDescriptor (
1400     ASL_RESOURCE_INFO       *Info);
1401
1402 ASL_RESOURCE_NODE *
1403 RsDoPinConfigDescriptor (
1404     ASL_RESOURCE_INFO       *Info);
1405
1406 ASL_RESOURCE_NODE *
1407 RsDoPinGroupDescriptor (
1408     ASL_RESOURCE_INFO       *Info);
1409
1410 ASL_RESOURCE_NODE *
1411 RsDoPinGroupFunctionDescriptor (
1412     ASL_RESOURCE_INFO       *Info);
1413
1414 ASL_RESOURCE_NODE *
1415 RsDoPinGroupConfigDescriptor (
1416     ASL_RESOURCE_INFO       *Info);
1417
1418 /*
1419  * aslrestype2d - DWord address descriptors
1420  */
1421 ASL_RESOURCE_NODE *
1422 RsDoDwordIoDescriptor (
1423     ASL_RESOURCE_INFO       *Info);
1424
1425 ASL_RESOURCE_NODE *
1426 RsDoDwordMemoryDescriptor (
1427     ASL_RESOURCE_INFO       *Info);
1428
1429 ASL_RESOURCE_NODE *
1430 RsDoDwordSpaceDescriptor (
1431     ASL_RESOURCE_INFO       *Info);
1432
1433
1434 /*
1435  * aslrestype2e - Extended address descriptors
1436  */
1437 ASL_RESOURCE_NODE *
1438 RsDoExtendedIoDescriptor (
1439     ASL_RESOURCE_INFO       *Info);
1440
1441 ASL_RESOURCE_NODE *
1442 RsDoExtendedMemoryDescriptor (
1443     ASL_RESOURCE_INFO       *Info);
1444
1445 ASL_RESOURCE_NODE *
1446 RsDoExtendedSpaceDescriptor (
1447     ASL_RESOURCE_INFO       *Info);
1448
1449
1450 /*
1451  * aslrestype2q - QWord address descriptors
1452  */
1453 ASL_RESOURCE_NODE *
1454 RsDoQwordIoDescriptor (
1455     ASL_RESOURCE_INFO       *Info);
1456
1457 ASL_RESOURCE_NODE *
1458 RsDoQwordMemoryDescriptor (
1459     ASL_RESOURCE_INFO       *Info);
1460
1461 ASL_RESOURCE_NODE *
1462 RsDoQwordSpaceDescriptor (
1463     ASL_RESOURCE_INFO       *Info);
1464
1465
1466 /*
1467  * aslrestype2w - Word address descriptors
1468  */
1469 ASL_RESOURCE_NODE *
1470 RsDoWordIoDescriptor (
1471     ASL_RESOURCE_INFO       *Info);
1472
1473 ASL_RESOURCE_NODE *
1474 RsDoWordSpaceDescriptor (
1475     ASL_RESOURCE_INFO       *Info);
1476
1477 ASL_RESOURCE_NODE *
1478 RsDoWordBusNumberDescriptor (
1479     ASL_RESOURCE_INFO       *Info);
1480
1481
1482 /*
1483  * Entry to data table compiler subsystem
1484  */
1485 ACPI_STATUS
1486 DtDoCompile(
1487     void);
1488
1489 ACPI_STATUS
1490 DtCreateTemplates (
1491     char                    **argv);
1492
1493
1494 /*
1495  * ASL/ASL+ converter debug
1496  */
1497 void
1498 CvDbgPrint (
1499     char                    *Fmt,
1500     ...);
1501
1502
1503 #endif /*  __ASLCOMPILER_H */