acapps.h revision 1.14 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: acapps - common include for ACPI applications/tools
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.2 christos /*
8 1.13 christos * Copyright (C) 2000 - 2018, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.2 christos * Redistribution and use in source and binary forms, with or without
12 1.2 christos * modification, are permitted provided that the following conditions
13 1.2 christos * are met:
14 1.2 christos * 1. Redistributions of source code must retain the above copyright
15 1.2 christos * notice, this list of conditions, and the following disclaimer,
16 1.2 christos * without modification.
17 1.2 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.2 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.2 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.2 christos * including a substantially similar Disclaimer requirement for further
21 1.2 christos * binary redistribution.
22 1.2 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.2 christos * of any contributors may be used to endorse or promote products derived
24 1.2 christos * from this software without specific prior written permission.
25 1.2 christos *
26 1.2 christos * Alternatively, this software may be distributed under the terms of the
27 1.2 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.2 christos * Software Foundation.
29 1.2 christos *
30 1.2 christos * NO WARRANTY
31 1.2 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.2 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.2 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.2 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.2 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.2 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.2 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.2 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.2 christos */
43 1.1 jruoho
44 1.1 jruoho #ifndef _ACAPPS
45 1.1 jruoho #define _ACAPPS
46 1.1 jruoho
47 1.9 christos #ifdef ACPI_USE_STANDARD_HEADERS
48 1.9 christos #include <sys/stat.h>
49 1.9 christos #endif /* ACPI_USE_STANDARD_HEADERS */
50 1.1 jruoho
51 1.2 christos /* Common info for tool signons */
52 1.2 christos
53 1.2 christos #define ACPICA_NAME "Intel ACPI Component Architecture"
54 1.13 christos #define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2018 Intel Corporation"
55 1.2 christos
56 1.2 christos #if ACPI_MACHINE_WIDTH == 64
57 1.10 christos #define ACPI_WIDTH " (64-bit version)"
58 1.2 christos
59 1.2 christos #elif ACPI_MACHINE_WIDTH == 32
60 1.10 christos #define ACPI_WIDTH " (32-bit version)"
61 1.2 christos
62 1.2 christos #else
63 1.2 christos #error unknown ACPI_MACHINE_WIDTH
64 1.10 christos #define ACPI_WIDTH " (unknown bit width, not 32 or 64)"
65 1.2 christos
66 1.2 christos #endif
67 1.2 christos
68 1.2 christos /* Macros for signons and file headers */
69 1.2 christos #ifdef ACPI_REPRO
70 1.5 apb #define ACPI_DATE "18 Dec 2013"
71 1.12 christos #define ACPI_TIME "00:00:00"
72 1.2 christos #else
73 1.2 christos #define ACPI_DATE __DATE__
74 1.12 christos #define ACPI_TIME __TIME__
75 1.2 christos #endif
76 1.2 christos
77 1.2 christos #define ACPI_COMMON_SIGNON(UtilityName) \
78 1.10 christos "\n%s\n%s version %8.8X\n%s\n\n", \
79 1.2 christos ACPICA_NAME, \
80 1.10 christos UtilityName, ((UINT32) ACPI_CA_VERSION), \
81 1.2 christos ACPICA_COPYRIGHT
82 1.2 christos
83 1.2 christos #define ACPI_COMMON_HEADER(UtilityName, Prefix) \
84 1.7 christos "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
85 1.2 christos Prefix, ACPICA_NAME, \
86 1.7 christos Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
87 1.2 christos Prefix, ACPICA_COPYRIGHT, \
88 1.2 christos Prefix
89 1.2 christos
90 1.12 christos #define ACPI_COMMON_BUILD_TIME \
91 1.12 christos "Build date/time: %s %s\n", ACPI_DATE, ACPI_TIME
92 1.12 christos
93 1.4 christos /* Macros for usage messages */
94 1.4 christos
95 1.4 christos #define ACPI_USAGE_HEADER(Usage) \
96 1.9 christos printf ("Usage: %s\nOptions:\n", Usage);
97 1.6 christos
98 1.6 christos #define ACPI_USAGE_TEXT(Description) \
99 1.9 christos printf (Description);
100 1.4 christos
101 1.4 christos #define ACPI_OPTION(Name, Description) \
102 1.9 christos printf (" %-20s%s\n", Name, Description);
103 1.4 christos
104 1.4 christos
105 1.8 christos /* Check for unexpected exceptions */
106 1.8 christos
107 1.8 christos #define ACPI_CHECK_STATUS(Name, Status, Expected) \
108 1.8 christos if (Status != Expected) \
109 1.8 christos { \
110 1.8 christos AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
111 1.8 christos AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
112 1.8 christos }
113 1.8 christos
114 1.8 christos /* Check for unexpected non-AE_OK errors */
115 1.8 christos
116 1.8 christos
117 1.8 christos #define ACPI_CHECK_OK(Name, Status) ACPI_CHECK_STATUS (Name, Status, AE_OK);
118 1.8 christos
119 1.1 jruoho #define FILE_SUFFIX_DISASSEMBLY "dsl"
120 1.8 christos #define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
121 1.8 christos
122 1.8 christos
123 1.8 christos /* acfileio */
124 1.8 christos
125 1.8 christos ACPI_STATUS
126 1.8 christos AcGetAllTablesFromFile (
127 1.8 christos char *Filename,
128 1.8 christos UINT8 GetOnlyAmlTables,
129 1.8 christos ACPI_NEW_TABLE_DESC **ReturnListHead);
130 1.8 christos
131 1.11 christos void
132 1.11 christos AcDeleteTableList (
133 1.11 christos ACPI_NEW_TABLE_DESC *ListHead);
134 1.11 christos
135 1.8 christos BOOLEAN
136 1.8 christos AcIsFileBinary (
137 1.8 christos FILE *File);
138 1.8 christos
139 1.8 christos ACPI_STATUS
140 1.8 christos AcValidateTableHeader (
141 1.8 christos FILE *File,
142 1.8 christos long TableOffset);
143 1.8 christos
144 1.8 christos
145 1.8 christos /* Values for GetOnlyAmlTables */
146 1.8 christos
147 1.8 christos #define ACPI_GET_ONLY_AML_TABLES TRUE
148 1.8 christos #define ACPI_GET_ALL_TABLES FALSE
149 1.1 jruoho
150 1.1 jruoho
151 1.1 jruoho /*
152 1.1 jruoho * getopt
153 1.1 jruoho */
154 1.1 jruoho int
155 1.1 jruoho AcpiGetopt(
156 1.1 jruoho int argc,
157 1.1 jruoho char **argv,
158 1.1 jruoho char *opts);
159 1.1 jruoho
160 1.4 christos int
161 1.4 christos AcpiGetoptArgument (
162 1.4 christos int argc,
163 1.4 christos char **argv);
164 1.4 christos
165 1.1 jruoho extern int AcpiGbl_Optind;
166 1.1 jruoho extern int AcpiGbl_Opterr;
167 1.4 christos extern int AcpiGbl_SubOptChar;
168 1.1 jruoho extern char *AcpiGbl_Optarg;
169 1.1 jruoho
170 1.1 jruoho
171 1.6 christos /*
172 1.6 christos * cmfsize - Common get file size function
173 1.6 christos */
174 1.6 christos UINT32
175 1.6 christos CmGetFileSize (
176 1.6 christos ACPI_FILE File);
177 1.6 christos
178 1.6 christos
179 1.1 jruoho /*
180 1.1 jruoho * adwalk
181 1.1 jruoho */
182 1.1 jruoho void
183 1.1 jruoho AcpiDmCrossReferenceNamespace (
184 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
185 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot,
186 1.1 jruoho ACPI_OWNER_ID OwnerId);
187 1.1 jruoho
188 1.1 jruoho void
189 1.1 jruoho AcpiDmDumpTree (
190 1.1 jruoho ACPI_PARSE_OBJECT *Origin);
191 1.1 jruoho
192 1.1 jruoho void
193 1.1 jruoho AcpiDmFindOrphanMethods (
194 1.1 jruoho ACPI_PARSE_OBJECT *Origin);
195 1.1 jruoho
196 1.1 jruoho void
197 1.1 jruoho AcpiDmFinishNamespaceLoad (
198 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
199 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot,
200 1.1 jruoho ACPI_OWNER_ID OwnerId);
201 1.1 jruoho
202 1.1 jruoho void
203 1.11 christos AcpiDmConvertParseObjects (
204 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
205 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot);
206 1.1 jruoho
207 1.1 jruoho
208 1.1 jruoho /*
209 1.1 jruoho * adfile
210 1.1 jruoho */
211 1.1 jruoho ACPI_STATUS
212 1.1 jruoho AdInitialize (
213 1.1 jruoho void);
214 1.1 jruoho
215 1.1 jruoho char *
216 1.1 jruoho FlGenerateFilename (
217 1.1 jruoho char *InputFilename,
218 1.1 jruoho char *Suffix);
219 1.1 jruoho
220 1.1 jruoho ACPI_STATUS
221 1.1 jruoho FlSplitInputPathname (
222 1.1 jruoho char *InputPath,
223 1.1 jruoho char **OutDirectoryPath,
224 1.1 jruoho char **OutFilename);
225 1.1 jruoho
226 1.1 jruoho char *
227 1.14 christos FlGetFileBasename (
228 1.14 christos char *FilePathname);
229 1.14 christos
230 1.14 christos char *
231 1.1 jruoho AdGenerateFilename (
232 1.1 jruoho char *Prefix,
233 1.1 jruoho char *TableId);
234 1.1 jruoho
235 1.1 jruoho void
236 1.1 jruoho AdWriteTable (
237 1.1 jruoho ACPI_TABLE_HEADER *Table,
238 1.1 jruoho UINT32 Length,
239 1.1 jruoho char *TableName,
240 1.1 jruoho char *OemTableId);
241 1.1 jruoho
242 1.1 jruoho #endif /* _ACAPPS */
243