1 /******************************************************************************
3 * Module Name: acpisrc.h - Include file for AcpiSrc utility
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
56 #define mkdir(x) mkdir(x, 0770)
62 #define LINES_IN_LEGAL_HEADER 105 /* See above */
63 #define LEGAL_HEADER_SIGNATURE " * 2.1. This is your license from Intel Corp. under its intellectual property"
64 #define LINES_IN_LINUX_HEADER 34
65 #define LINUX_HEADER_SIGNATURE " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
66 #define LINES_IN_ASL_HEADER 29 /* Header as output from disassembler */
68 #define ASRC_MAX_FILE_SIZE (1024 * 100)
70 #define FILE_TYPE_SOURCE 1
71 #define FILE_TYPE_HEADER 2
72 #define FILE_TYPE_DIRECTORY 3
74 #define CVT_COUNT_TABS 0x00000001
75 #define CVT_COUNT_NON_ANSI_COMMENTS 0x00000002
76 #define CVT_TRIM_LINES 0x00000004
77 #define CVT_CHECK_BRACES 0x00000008
78 #define CVT_COUNT_LINES 0x00000010
79 #define CVT_BRACES_ON_SAME_LINE 0x00000020
80 #define CVT_MIXED_CASE_TO_UNDERSCORES 0x00000040
81 #define CVT_LOWER_CASE_IDENTIFIERS 0x00000080
82 #define CVT_REMOVE_DEBUG_MACROS 0x00000100
83 #define CVT_TRIM_WHITESPACE 0x00000200 /* Should be after all line removal */
84 #define CVT_REMOVE_EMPTY_BLOCKS 0x00000400 /* Should be after trimming lines */
85 #define CVT_REDUCE_TYPEDEFS 0x00000800
86 #define CVT_COUNT_SHORTMULTILINE_COMMENTS 0x00001000
87 #define CVT_SPACES_TO_TABS4 0x40000000 /* Tab conversion should be last */
88 #define CVT_SPACES_TO_TABS8 0x80000000 /* Tab conversion should be last */
90 #define FLG_DEFAULT_FLAGS 0x00000000
91 #define FLG_NO_CARRIAGE_RETURNS 0x00000001
92 #define FLG_NO_FILE_OUTPUT 0x00000002
93 #define FLG_LOWERCASE_DIRNAMES 0x00000004
95 #define AS_START_IGNORE "/*!"
96 #define AS_STOP_IGNORE "!*/"
101 extern UINT32 Gbl_Files
;
102 extern UINT32 Gbl_MissingBraces
;
103 extern UINT32 Gbl_Tabs
;
104 extern UINT32 Gbl_NonAnsiComments
;
105 extern UINT32 Gbl_SourceLines
;
106 extern UINT32 Gbl_WhiteLines
;
107 extern UINT32 Gbl_CommentLines
;
108 extern UINT32 Gbl_LongLines
;
109 extern UINT32 Gbl_TotalLines
;
110 extern UINT32 Gbl_HeaderSize
;
111 extern UINT32 Gbl_HeaderLines
;
112 extern struct stat Gbl_StatBuf
;
113 extern char *Gbl_FileBuffer
;
114 extern UINT32 Gbl_TotalSize
;
115 extern UINT32 Gbl_FileSize
;
116 extern UINT32 Gbl_FileType
;
117 extern BOOLEAN Gbl_VerboseMode
;
118 extern BOOLEAN Gbl_QuietMode
;
119 extern BOOLEAN Gbl_BatchMode
;
120 extern BOOLEAN Gbl_MadeChanges
;
121 extern BOOLEAN Gbl_Overwrite
;
122 extern BOOLEAN Gbl_WidenDeclarations
;
123 extern BOOLEAN Gbl_IgnoreLoneLineFeeds
;
124 extern BOOLEAN Gbl_HasLoneLineFeeds
;
125 extern BOOLEAN Gbl_Cleanup
;
126 extern BOOLEAN Gbl_IgnoreTranslationEscapes
;
127 extern void *Gbl_StructDefs
;
129 #define PARAM_LIST(pl) pl
130 #define TERSE_PRINT(a) if (!Gbl_VerboseMode) printf PARAM_LIST(a)
131 #define VERBOSE_PRINT(a) if (Gbl_VerboseMode) printf PARAM_LIST(a)
133 #define REPLACE_WHOLE_WORD 0x00
134 #define REPLACE_SUBSTRINGS 0x01
135 #define REPLACE_MASK 0x01
137 #define EXTRA_INDENT_C 0x02
140 /* Conversion table structs */
142 typedef struct acpi_string_table
151 typedef struct acpi_typed_identifier_table
156 } ACPI_TYPED_IDENTIFIER_TABLE
;
158 #define SRC_TYPE_SIMPLE 0
159 #define SRC_TYPE_STRUCT 1
160 #define SRC_TYPE_UNION 2
163 typedef struct acpi_identifier_table
167 } ACPI_IDENTIFIER_TABLE
;
169 typedef struct acpi_conversion_table
174 ACPI_TYPED_IDENTIFIER_TABLE
*LowerCaseTable
;
176 ACPI_STRING_TABLE
*SourceStringTable
;
177 ACPI_IDENTIFIER_TABLE
*SourceLineTable
;
178 ACPI_IDENTIFIER_TABLE
*SourceConditionalTable
;
179 ACPI_IDENTIFIER_TABLE
*SourceMacroTable
;
180 ACPI_TYPED_IDENTIFIER_TABLE
*SourceStructTable
;
181 ACPI_IDENTIFIER_TABLE
*SourceSpecialMacroTable
;
182 UINT32 SourceFunctions
;
184 ACPI_STRING_TABLE
*HeaderStringTable
;
185 ACPI_IDENTIFIER_TABLE
*HeaderLineTable
;
186 ACPI_IDENTIFIER_TABLE
*HeaderConditionalTable
;
187 ACPI_IDENTIFIER_TABLE
*HeaderMacroTable
;
188 ACPI_TYPED_IDENTIFIER_TABLE
*HeaderStructTable
;
189 ACPI_IDENTIFIER_TABLE
*HeaderSpecialMacroTable
;
190 UINT32 HeaderFunctions
;
192 } ACPI_CONVERSION_TABLE
;
195 /* Conversion tables */
197 extern ACPI_CONVERSION_TABLE LinuxConversionTable
;
198 extern ACPI_CONVERSION_TABLE CleanupConversionTable
;
199 extern ACPI_CONVERSION_TABLE StatsConversionTable
;
200 extern ACPI_CONVERSION_TABLE CustomConversionTable
;
201 extern ACPI_CONVERSION_TABLE LicenseConversionTable
;
202 extern ACPI_CONVERSION_TABLE IndentConversionTable
;
220 UINT32 LengthToRemove
,
257 AsMixedCaseToUnderscores (
271 AsLowerCaseIdentifiers (
280 AsRemoveDebugMacros (
284 AsRemoveEmptyBlocks (
289 AsCleanupSpecialMacro (
299 AsCountNonAnsiComments (
316 AsRemoveConditionalCompile (
322 ACPI_CONVERSION_TABLE
*ConversionTable
,
345 ACPI_CONVERSION_TABLE
*ConversionTable
,
348 ACPI_NATIVE_INT FileType
);
352 ACPI_CONVERSION_TABLE
*ConversionTable
,
357 ACPI_NATIVE_INT FileType
);
360 AsCheckForDirectory (
373 AsRemoveSpacesAfterPeriod (
406 AsInsertCarriageReturns (
410 AsConvertToLineFeeds (