Sync ACPICA with Intel's version 20170303.
[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  * asltree - parse tree support
794  */
795 ACPI_STATUS
796 TrWalkParseTree (
797     ACPI_PARSE_OBJECT       *Op,
798     UINT32                  Visitation,
799     ASL_WALK_CALLBACK       DescendingCallback,
800     ASL_WALK_CALLBACK       AscendingCallback,
801     void                    *Context);
802
803 /*
804  * aslexternal - External opcode support
805  */
806 ACPI_STATUS
807 ExAmlExternalWalkBegin (
808     ACPI_PARSE_OBJECT       *Op,
809     UINT32                  Level,
810     void                    *Context);
811
812 ACPI_STATUS
813 ExAmlExternalWalkEnd (
814     ACPI_PARSE_OBJECT       *Op,
815     UINT32                  Level,
816     void                    *Context);
817
818 void
819 ExDoExternal (
820     ACPI_PARSE_OBJECT       *Op);
821
822 /* Values for "Visitation" parameter above */
823
824 #define ASL_WALK_VISIT_DOWNWARD     0x01
825 #define ASL_WALK_VISIT_UPWARD       0x02
826 #define ASL_WALK_VISIT_TWICE        (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
827
828
829 void
830 TrSetParent (
831     ACPI_PARSE_OBJECT       *Op,
832     ACPI_PARSE_OBJECT       *ParentOp);
833
834 ACPI_PARSE_OBJECT *
835 TrAllocateNode (
836     UINT32                  ParseOpcode);
837
838 void
839 TrPrintNodeCompileFlags (
840     UINT32                  Flags);
841
842 void
843 TrReleaseNode (
844     ACPI_PARSE_OBJECT       *Op);
845
846 ACPI_PARSE_OBJECT *
847 TrUpdateNode (
848     UINT32                  ParseOpcode,
849     ACPI_PARSE_OBJECT       *Op);
850
851 ACPI_PARSE_OBJECT *
852 TrCreateNode (
853     UINT32                  ParseOpcode,
854     UINT32                  NumChildren,
855     ...);
856
857 ACPI_PARSE_OBJECT *
858 TrCreateLeafNode (
859     UINT32                  ParseOpcode);
860
861 ACPI_PARSE_OBJECT *
862 TrCreateNullTarget (
863     void);
864
865 ACPI_PARSE_OBJECT *
866 TrCreateAssignmentNode (
867     ACPI_PARSE_OBJECT       *Target,
868     ACPI_PARSE_OBJECT       *Source);
869
870 ACPI_PARSE_OBJECT *
871 TrCreateTargetOperand (
872     ACPI_PARSE_OBJECT       *OriginalOp,
873     ACPI_PARSE_OBJECT       *ParentOp);
874
875 ACPI_PARSE_OBJECT *
876 TrCreateValuedLeafNode (
877     UINT32                  ParseOpcode,
878     UINT64                  Value);
879
880 ACPI_PARSE_OBJECT *
881 TrCreateConstantLeafNode (
882     UINT32                  ParseOpcode);
883
884 ACPI_PARSE_OBJECT *
885 TrLinkChildren (
886     ACPI_PARSE_OBJECT       *Op,
887     UINT32                  NumChildren,
888     ...);
889
890 void
891 TrSetEndLineNumber (
892     ACPI_PARSE_OBJECT       *Op);
893
894 void
895 TrSetCurrentFilename (
896     ACPI_PARSE_OBJECT       *Op);
897
898 void
899 TrWalkTree (
900     void);
901
902 ACPI_PARSE_OBJECT *
903 TrLinkPeerNode (
904     ACPI_PARSE_OBJECT       *Op1,
905     ACPI_PARSE_OBJECT       *Op2);
906
907 ACPI_PARSE_OBJECT *
908 TrLinkChildNode (
909     ACPI_PARSE_OBJECT       *Op1,
910     ACPI_PARSE_OBJECT       *Op2);
911
912 ACPI_PARSE_OBJECT *
913 TrSetNodeFlags (
914     ACPI_PARSE_OBJECT       *Op,
915     UINT32                  Flags);
916
917 ACPI_PARSE_OBJECT *
918 TrSetNodeAmlLength (
919     ACPI_PARSE_OBJECT       *Op,
920     UINT32                  Length);
921
922 ACPI_PARSE_OBJECT *
923 TrLinkPeerNodes (
924     UINT32                  NumPeers,
925     ...);
926
927
928 /*
929  * aslfiles - File I/O support
930  */
931 void
932 FlAddIncludeDirectory (
933     char                    *Dir);
934
935 char *
936 FlMergePathnames (
937     char                    *PrefixDir,
938     char                    *FilePathname);
939
940 void
941 FlOpenIncludeFile (
942     ACPI_PARSE_OBJECT       *Op);
943
944 void
945 FlFileError (
946     UINT32                  FileId,
947     UINT8                   ErrorId);
948
949 UINT32
950 FlGetFileSize (
951     UINT32                  FileId);
952
953 ACPI_STATUS
954 FlReadFile (
955     UINT32                  FileId,
956     void                    *Buffer,
957     UINT32                  Length);
958
959 void
960 FlWriteFile (
961     UINT32                  FileId,
962     void                    *Buffer,
963     UINT32                  Length);
964
965 void
966 FlSeekFile (
967     UINT32                  FileId,
968     long                    Offset);
969
970 void
971 FlCloseFile (
972     UINT32                  FileId);
973
974 void
975 FlPrintFile (
976     UINT32                  FileId,
977     char                    *Format,
978     ...);
979
980 void
981 FlDeleteFile (
982     UINT32                  FileId);
983
984 void
985 FlSetLineNumber (
986     UINT32                  LineNumber);
987
988 void
989 FlSetFilename (
990     char                    *Filename);
991
992 ACPI_STATUS
993 FlOpenInputFile (
994     char                    *InputFilename);
995
996 ACPI_STATUS
997 FlOpenAmlOutputFile (
998     char                    *InputFilename);
999
1000 ACPI_STATUS
1001 FlOpenMiscOutputFiles (
1002     char                    *InputFilename);
1003
1004 /*
1005  * aslhwmap - hardware map summary
1006  */
1007 void
1008 MpEmitMappingInfo (
1009     void);
1010
1011
1012 /*
1013  * asload - load namespace in prep for cross reference
1014  */
1015 ACPI_STATUS
1016 LdLoadNamespace (
1017     ACPI_PARSE_OBJECT       *RootOp);
1018
1019
1020 /*
1021  * asllookup - namespace lookup functions
1022  */
1023 void
1024 LkFindUnreferencedObjects (
1025     void);
1026
1027 /*
1028  * aslhelp - help screens
1029  */
1030 void
1031 Usage (
1032     void);
1033
1034 void
1035 AslFilenameHelp (
1036     void);
1037
1038 void
1039 AslDisassemblyHelp (
1040     void);
1041
1042
1043 /*
1044  * aslnamesp - namespace output file generation
1045  */
1046 ACPI_STATUS
1047 NsDisplayNamespace (
1048     void);
1049
1050 void
1051 NsSetupNamespaceListing (
1052     void                    *Handle);
1053
1054 /*
1055  * asloptions - command line processing
1056  */
1057 int
1058 AslCommandLine (
1059     int                     argc,
1060     char                    **argv);
1061
1062 /*
1063  * aslxref - namespace cross reference
1064  */
1065 ACPI_STATUS
1066 XfCrossReferenceNamespace (
1067     void);
1068
1069
1070 /*
1071  * aslxrefout
1072  */
1073 void
1074 OtPrintHeaders (
1075     char                    *Message);
1076
1077 void
1078 OtCreateXrefFile (
1079     void);
1080
1081 void
1082 OtXrefWalkPart1 (
1083     ACPI_PARSE_OBJECT       *Op,
1084     UINT32                  Level,
1085     ASL_METHOD_INFO         *MethodInfo);
1086
1087
1088 /*
1089  * aslutils - common compiler utilites
1090  */
1091 void
1092 DbgPrint (
1093     UINT32                  Type,
1094     char                    *Format,
1095     ...);
1096
1097 /* Type values for above */
1098
1099 #define ASL_DEBUG_OUTPUT    0
1100 #define ASL_PARSE_OUTPUT    1
1101 #define ASL_TREE_OUTPUT     2
1102
1103 UINT8
1104 UtIsBigEndianMachine (
1105     void);
1106
1107 BOOLEAN
1108 UtQueryForOverwrite (
1109     char                    *Pathname);
1110
1111 void
1112 UtDumpStringOp (
1113     ACPI_PARSE_OBJECT       *Op,
1114     UINT32                  Level);
1115
1116 void
1117 UtDumpIntegerOp (
1118     ACPI_PARSE_OBJECT       *Op,
1119     UINT32                  Level,
1120     UINT32                  IntegerLength);
1121
1122 void
1123 UtDumpBasicOp (
1124     ACPI_PARSE_OBJECT       *Op,
1125     UINT32                  Level);
1126
1127 void
1128 UtDisplaySupportedTables (
1129     void);
1130
1131 void
1132 UtDisplayConstantOpcodes (
1133     void);
1134
1135 UINT8
1136 UtBeginEvent (
1137     char                    *Name);
1138
1139 void
1140 UtEndEvent (
1141     UINT8                   Event);
1142
1143 void *
1144 UtLocalCalloc (
1145     UINT32                  Size);
1146
1147 void
1148 UtDisplaySummary (
1149     UINT32                  FileId);
1150
1151 void
1152 UtConvertByteToHex (
1153     UINT8                   RawByte,
1154     UINT8                   *Buffer);
1155
1156 void
1157 UtConvertByteToAsmHex (
1158     UINT8                   RawByte,
1159     UINT8                   *Buffer);
1160
1161 char *
1162 UtGetOpName (
1163     UINT32                  ParseOpcode);
1164
1165 void
1166 UtSetParseOpName (
1167     ACPI_PARSE_OBJECT       *Op);
1168
1169 char *
1170 UtStringCacheCalloc (
1171     UINT32                  Length);
1172
1173 void
1174 UtExpandLineBuffers (
1175     void);
1176
1177 void
1178 UtFreeLineBuffers (
1179     void);
1180
1181 ACPI_STATUS
1182 UtInternalizeName (
1183     char                    *ExternalName,
1184     char                    **ConvertedName);
1185
1186 void
1187 UtAttachNamepathToOwner (
1188     ACPI_PARSE_OBJECT       *Op,
1189     ACPI_PARSE_OBJECT       *NameNode);
1190
1191 ACPI_PARSE_OBJECT *
1192 UtCheckIntegerRange (
1193     ACPI_PARSE_OBJECT       *Op,
1194     UINT32                  LowValue,
1195     UINT32                  HighValue);
1196
1197 UINT64
1198 UtDoConstant (
1199     char                    *String);
1200
1201
1202 /*
1203  * asluuid - UUID support
1204  */
1205 ACPI_STATUS
1206 AuValidateUuid (
1207     char                    *InString);
1208
1209 ACPI_STATUS
1210 AuConvertUuidToString (
1211     char                    *UuIdBuffer,
1212     char                    *OutString);
1213
1214 /*
1215  * aslresource - Resource template generation utilities
1216  */
1217 void
1218 RsSmallAddressCheck (
1219     UINT8                   Type,
1220     UINT32                  Minimum,
1221     UINT32                  Maximum,
1222     UINT32                  Length,
1223     UINT32                  Alignment,
1224     ACPI_PARSE_OBJECT       *MinOp,
1225     ACPI_PARSE_OBJECT       *MaxOp,
1226     ACPI_PARSE_OBJECT       *LengthOp,
1227     ACPI_PARSE_OBJECT       *AlignOp,
1228     ACPI_PARSE_OBJECT       *Op);
1229
1230 void
1231 RsLargeAddressCheck (
1232     UINT64                  Minimum,
1233     UINT64                  Maximum,
1234     UINT64                  Length,
1235     UINT64                  Granularity,
1236     UINT8                   Flags,
1237     ACPI_PARSE_OBJECT       *MinOp,
1238     ACPI_PARSE_OBJECT       *MaxOp,
1239     ACPI_PARSE_OBJECT       *LengthOp,
1240     ACPI_PARSE_OBJECT       *GranOp,
1241     ACPI_PARSE_OBJECT       *Op);
1242
1243 UINT16
1244 RsGetStringDataLength (
1245     ACPI_PARSE_OBJECT       *InitializerOp);
1246
1247 ASL_RESOURCE_NODE *
1248 RsAllocateResourceNode (
1249     UINT32                  Size);
1250
1251 void
1252 RsCreateResourceField (
1253     ACPI_PARSE_OBJECT       *Op,
1254     char                    *Name,
1255     UINT32                  ByteOffset,
1256     UINT32                  BitOffset,
1257     UINT32                  BitLength);
1258
1259 void
1260 RsSetFlagBits (
1261     UINT8                   *Flags,
1262     ACPI_PARSE_OBJECT       *Op,
1263     UINT8                   Position,
1264     UINT8                   DefaultBit);
1265
1266 void
1267 RsSetFlagBits16 (
1268     UINT16                  *Flags,
1269     ACPI_PARSE_OBJECT       *Op,
1270     UINT8                   Position,
1271     UINT8                   DefaultBit);
1272
1273 ACPI_PARSE_OBJECT *
1274 RsCompleteNodeAndGetNext (
1275     ACPI_PARSE_OBJECT       *Op);
1276
1277 void
1278 RsCheckListForDuplicates (
1279     ACPI_PARSE_OBJECT       *Op);
1280
1281 ASL_RESOURCE_NODE *
1282 RsDoOneResourceDescriptor (
1283     ASL_RESOURCE_INFO       *Info,
1284     UINT8                   *State);
1285
1286 /* Values for State above */
1287
1288 #define ACPI_RSTATE_NORMAL              0
1289 #define ACPI_RSTATE_START_DEPENDENT     1
1290 #define ACPI_RSTATE_DEPENDENT_LIST      2
1291
1292 UINT32
1293 RsLinkDescriptorChain (
1294     ASL_RESOURCE_NODE       **PreviousRnode,
1295     ASL_RESOURCE_NODE       *Rnode);
1296
1297 void
1298 RsDoResourceTemplate (
1299     ACPI_PARSE_OBJECT       *Op);
1300
1301
1302 /*
1303  * aslrestype1 - Miscellaneous Small descriptors
1304  */
1305 ASL_RESOURCE_NODE *
1306 RsDoEndTagDescriptor (
1307     ASL_RESOURCE_INFO       *Info);
1308
1309 ASL_RESOURCE_NODE *
1310 RsDoEndDependentDescriptor (
1311     ASL_RESOURCE_INFO       *Info);
1312
1313 ASL_RESOURCE_NODE *
1314 RsDoMemory24Descriptor (
1315     ASL_RESOURCE_INFO       *Info);
1316
1317 ASL_RESOURCE_NODE *
1318 RsDoMemory32Descriptor (
1319     ASL_RESOURCE_INFO       *Info);
1320
1321 ASL_RESOURCE_NODE *
1322 RsDoMemory32FixedDescriptor (
1323     ASL_RESOURCE_INFO       *Info);
1324
1325 ASL_RESOURCE_NODE *
1326 RsDoStartDependentDescriptor (
1327     ASL_RESOURCE_INFO       *Info);
1328
1329 ASL_RESOURCE_NODE *
1330 RsDoStartDependentNoPriDescriptor (
1331     ASL_RESOURCE_INFO       *Info);
1332
1333 ASL_RESOURCE_NODE *
1334 RsDoVendorSmallDescriptor (
1335     ASL_RESOURCE_INFO       *Info);
1336
1337
1338 /*
1339  * aslrestype1i - I/O-related Small descriptors
1340  */
1341 ASL_RESOURCE_NODE *
1342 RsDoDmaDescriptor (
1343     ASL_RESOURCE_INFO       *Info);
1344
1345 ASL_RESOURCE_NODE *
1346 RsDoFixedDmaDescriptor (
1347     ASL_RESOURCE_INFO       *Info);
1348
1349 ASL_RESOURCE_NODE *
1350 RsDoFixedIoDescriptor (
1351     ASL_RESOURCE_INFO       *Info);
1352
1353 ASL_RESOURCE_NODE *
1354 RsDoIoDescriptor (
1355     ASL_RESOURCE_INFO       *Info);
1356
1357 ASL_RESOURCE_NODE *
1358 RsDoIrqDescriptor (
1359     ASL_RESOURCE_INFO       *Info);
1360
1361 ASL_RESOURCE_NODE *
1362 RsDoIrqNoFlagsDescriptor (
1363     ASL_RESOURCE_INFO       *Info);
1364
1365
1366 /*
1367  * aslrestype2 - Large resource descriptors
1368  */
1369 ASL_RESOURCE_NODE *
1370 RsDoInterruptDescriptor (
1371     ASL_RESOURCE_INFO       *Info);
1372
1373 ASL_RESOURCE_NODE *
1374 RsDoVendorLargeDescriptor (
1375     ASL_RESOURCE_INFO       *Info);
1376
1377 ASL_RESOURCE_NODE *
1378 RsDoGeneralRegisterDescriptor (
1379     ASL_RESOURCE_INFO       *Info);
1380
1381 ASL_RESOURCE_NODE *
1382 RsDoGpioIntDescriptor (
1383     ASL_RESOURCE_INFO       *Info);
1384
1385 ASL_RESOURCE_NODE *
1386 RsDoGpioIoDescriptor (
1387     ASL_RESOURCE_INFO       *Info);
1388
1389 ASL_RESOURCE_NODE *
1390 RsDoI2cSerialBusDescriptor (
1391     ASL_RESOURCE_INFO       *Info);
1392
1393 ASL_RESOURCE_NODE *
1394 RsDoSpiSerialBusDescriptor (
1395     ASL_RESOURCE_INFO       *Info);
1396
1397 ASL_RESOURCE_NODE *
1398 RsDoUartSerialBusDescriptor (
1399     ASL_RESOURCE_INFO       *Info);
1400
1401 /*
1402  * aslrestype2d - DWord address descriptors
1403  */
1404 ASL_RESOURCE_NODE *
1405 RsDoDwordIoDescriptor (
1406     ASL_RESOURCE_INFO       *Info);
1407
1408 ASL_RESOURCE_NODE *
1409 RsDoDwordMemoryDescriptor (
1410     ASL_RESOURCE_INFO       *Info);
1411
1412 ASL_RESOURCE_NODE *
1413 RsDoDwordSpaceDescriptor (
1414     ASL_RESOURCE_INFO       *Info);
1415
1416
1417 /*
1418  * aslrestype2e - Extended address descriptors
1419  */
1420 ASL_RESOURCE_NODE *
1421 RsDoExtendedIoDescriptor (
1422     ASL_RESOURCE_INFO       *Info);
1423
1424 ASL_RESOURCE_NODE *
1425 RsDoExtendedMemoryDescriptor (
1426     ASL_RESOURCE_INFO       *Info);
1427
1428 ASL_RESOURCE_NODE *
1429 RsDoExtendedSpaceDescriptor (
1430     ASL_RESOURCE_INFO       *Info);
1431
1432
1433 /*
1434  * aslrestype2q - QWord address descriptors
1435  */
1436 ASL_RESOURCE_NODE *
1437 RsDoQwordIoDescriptor (
1438     ASL_RESOURCE_INFO       *Info);
1439
1440 ASL_RESOURCE_NODE *
1441 RsDoQwordMemoryDescriptor (
1442     ASL_RESOURCE_INFO       *Info);
1443
1444 ASL_RESOURCE_NODE *
1445 RsDoQwordSpaceDescriptor (
1446     ASL_RESOURCE_INFO       *Info);
1447
1448
1449 /*
1450  * aslrestype2w - Word address descriptors
1451  */
1452 ASL_RESOURCE_NODE *
1453 RsDoWordIoDescriptor (
1454     ASL_RESOURCE_INFO       *Info);
1455
1456 ASL_RESOURCE_NODE *
1457 RsDoWordSpaceDescriptor (
1458     ASL_RESOURCE_INFO       *Info);
1459
1460 ASL_RESOURCE_NODE *
1461 RsDoWordBusNumberDescriptor (
1462     ASL_RESOURCE_INFO       *Info);
1463
1464
1465 /*
1466  * Entry to data table compiler subsystem
1467  */
1468 ACPI_STATUS
1469 DtDoCompile(
1470     void);
1471
1472 ACPI_STATUS
1473 DtCreateTemplates (
1474     char                    **argv);
1475
1476
1477 /*
1478  * ASL/ASL+ converter debug
1479  */
1480 void
1481 CvDbgPrint (
1482     char                    *Fmt,
1483     ...);
1484
1485
1486 #endif /*  __ASLCOMPILER_H */