acapps.h revision 1.11 1 /******************************************************************************
2 *
3 * Module Name: acapps - common include for ACPI applications/tools
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2017, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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.
42 */
43
44 #ifndef _ACAPPS
45 #define _ACAPPS
46
47 #ifdef ACPI_USE_STANDARD_HEADERS
48 #include <sys/stat.h>
49 #endif /* ACPI_USE_STANDARD_HEADERS */
50
51 /* Common info for tool signons */
52
53 #define ACPICA_NAME "Intel ACPI Component Architecture"
54 #define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2017 Intel Corporation"
55
56 #if ACPI_MACHINE_WIDTH == 64
57 #define ACPI_WIDTH " (64-bit version)"
58
59 #elif ACPI_MACHINE_WIDTH == 32
60 #define ACPI_WIDTH " (32-bit version)"
61
62 #else
63 #error unknown ACPI_MACHINE_WIDTH
64 #define ACPI_WIDTH " (unknown bit width, not 32 or 64)"
65
66 #endif
67
68 /* Macros for signons and file headers */
69 #ifdef ACPI_REPRO
70 #define ACPI_DATE "18 Dec 2013"
71 #else
72 #define ACPI_DATE __DATE__
73 #endif
74
75 #define ACPI_COMMON_SIGNON(UtilityName) \
76 "\n%s\n%s version %8.8X\n%s\n\n", \
77 ACPICA_NAME, \
78 UtilityName, ((UINT32) ACPI_CA_VERSION), \
79 ACPICA_COPYRIGHT
80
81 #define ACPI_COMMON_HEADER(UtilityName, Prefix) \
82 "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
83 Prefix, ACPICA_NAME, \
84 Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
85 Prefix, ACPICA_COPYRIGHT, \
86 Prefix
87
88 /* Macros for usage messages */
89
90 #define ACPI_USAGE_HEADER(Usage) \
91 printf ("Usage: %s\nOptions:\n", Usage);
92
93 #define ACPI_USAGE_TEXT(Description) \
94 printf (Description);
95
96 #define ACPI_OPTION(Name, Description) \
97 printf (" %-20s%s\n", Name, Description);
98
99
100 /* Check for unexpected exceptions */
101
102 #define ACPI_CHECK_STATUS(Name, Status, Expected) \
103 if (Status != Expected) \
104 { \
105 AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
106 AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
107 }
108
109 /* Check for unexpected non-AE_OK errors */
110
111
112 #define ACPI_CHECK_OK(Name, Status) ACPI_CHECK_STATUS (Name, Status, AE_OK);
113
114 #define FILE_SUFFIX_DISASSEMBLY "dsl"
115 #define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
116
117
118 /* acfileio */
119
120 ACPI_STATUS
121 AcGetAllTablesFromFile (
122 char *Filename,
123 UINT8 GetOnlyAmlTables,
124 ACPI_NEW_TABLE_DESC **ReturnListHead);
125
126 void
127 AcDeleteTableList (
128 ACPI_NEW_TABLE_DESC *ListHead);
129
130 BOOLEAN
131 AcIsFileBinary (
132 FILE *File);
133
134 ACPI_STATUS
135 AcValidateTableHeader (
136 FILE *File,
137 long TableOffset);
138
139
140 /* Values for GetOnlyAmlTables */
141
142 #define ACPI_GET_ONLY_AML_TABLES TRUE
143 #define ACPI_GET_ALL_TABLES FALSE
144
145
146 /*
147 * getopt
148 */
149 int
150 AcpiGetopt(
151 int argc,
152 char **argv,
153 char *opts);
154
155 int
156 AcpiGetoptArgument (
157 int argc,
158 char **argv);
159
160 extern int AcpiGbl_Optind;
161 extern int AcpiGbl_Opterr;
162 extern int AcpiGbl_SubOptChar;
163 extern char *AcpiGbl_Optarg;
164
165
166 /*
167 * cmfsize - Common get file size function
168 */
169 UINT32
170 CmGetFileSize (
171 ACPI_FILE File);
172
173
174 /*
175 * adwalk
176 */
177 void
178 AcpiDmCrossReferenceNamespace (
179 ACPI_PARSE_OBJECT *ParseTreeRoot,
180 ACPI_NAMESPACE_NODE *NamespaceRoot,
181 ACPI_OWNER_ID OwnerId);
182
183 void
184 AcpiDmDumpTree (
185 ACPI_PARSE_OBJECT *Origin);
186
187 void
188 AcpiDmFindOrphanMethods (
189 ACPI_PARSE_OBJECT *Origin);
190
191 void
192 AcpiDmFinishNamespaceLoad (
193 ACPI_PARSE_OBJECT *ParseTreeRoot,
194 ACPI_NAMESPACE_NODE *NamespaceRoot,
195 ACPI_OWNER_ID OwnerId);
196
197 void
198 AcpiDmConvertParseObjects (
199 ACPI_PARSE_OBJECT *ParseTreeRoot,
200 ACPI_NAMESPACE_NODE *NamespaceRoot);
201
202
203 /*
204 * adfile
205 */
206 ACPI_STATUS
207 AdInitialize (
208 void);
209
210 char *
211 FlGenerateFilename (
212 char *InputFilename,
213 char *Suffix);
214
215 ACPI_STATUS
216 FlSplitInputPathname (
217 char *InputPath,
218 char **OutDirectoryPath,
219 char **OutFilename);
220
221 char *
222 AdGenerateFilename (
223 char *Prefix,
224 char *TableId);
225
226 void
227 AdWriteTable (
228 ACPI_TABLE_HEADER *Table,
229 UINT32 Length,
230 char *TableName,
231 char *OemTableId);
232
233 #endif /* _ACAPPS */
234