acapps.h revision 1.11 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.10 christos * Copyright (C) 2000 - 2017, 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.10 christos #define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2017 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.2 christos #else
72 1.2 christos #define ACPI_DATE __DATE__
73 1.2 christos #endif
74 1.2 christos
75 1.2 christos #define ACPI_COMMON_SIGNON(UtilityName) \
76 1.10 christos "\n%s\n%s version %8.8X\n%s\n\n", \
77 1.2 christos ACPICA_NAME, \
78 1.10 christos UtilityName, ((UINT32) ACPI_CA_VERSION), \
79 1.2 christos ACPICA_COPYRIGHT
80 1.2 christos
81 1.2 christos #define ACPI_COMMON_HEADER(UtilityName, Prefix) \
82 1.7 christos "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
83 1.2 christos Prefix, ACPICA_NAME, \
84 1.7 christos Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
85 1.2 christos Prefix, ACPICA_COPYRIGHT, \
86 1.2 christos Prefix
87 1.2 christos
88 1.4 christos /* Macros for usage messages */
89 1.4 christos
90 1.4 christos #define ACPI_USAGE_HEADER(Usage) \
91 1.9 christos printf ("Usage: %s\nOptions:\n", Usage);
92 1.6 christos
93 1.6 christos #define ACPI_USAGE_TEXT(Description) \
94 1.9 christos printf (Description);
95 1.4 christos
96 1.4 christos #define ACPI_OPTION(Name, Description) \
97 1.9 christos printf (" %-20s%s\n", Name, Description);
98 1.4 christos
99 1.4 christos
100 1.8 christos /* Check for unexpected exceptions */
101 1.8 christos
102 1.8 christos #define ACPI_CHECK_STATUS(Name, Status, Expected) \
103 1.8 christos if (Status != Expected) \
104 1.8 christos { \
105 1.8 christos AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
106 1.8 christos AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
107 1.8 christos }
108 1.8 christos
109 1.8 christos /* Check for unexpected non-AE_OK errors */
110 1.8 christos
111 1.8 christos
112 1.8 christos #define ACPI_CHECK_OK(Name, Status) ACPI_CHECK_STATUS (Name, Status, AE_OK);
113 1.8 christos
114 1.1 jruoho #define FILE_SUFFIX_DISASSEMBLY "dsl"
115 1.8 christos #define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
116 1.8 christos
117 1.8 christos
118 1.8 christos /* acfileio */
119 1.8 christos
120 1.8 christos ACPI_STATUS
121 1.8 christos AcGetAllTablesFromFile (
122 1.8 christos char *Filename,
123 1.8 christos UINT8 GetOnlyAmlTables,
124 1.8 christos ACPI_NEW_TABLE_DESC **ReturnListHead);
125 1.8 christos
126 1.11 christos void
127 1.11 christos AcDeleteTableList (
128 1.11 christos ACPI_NEW_TABLE_DESC *ListHead);
129 1.11 christos
130 1.8 christos BOOLEAN
131 1.8 christos AcIsFileBinary (
132 1.8 christos FILE *File);
133 1.8 christos
134 1.8 christos ACPI_STATUS
135 1.8 christos AcValidateTableHeader (
136 1.8 christos FILE *File,
137 1.8 christos long TableOffset);
138 1.8 christos
139 1.8 christos
140 1.8 christos /* Values for GetOnlyAmlTables */
141 1.8 christos
142 1.8 christos #define ACPI_GET_ONLY_AML_TABLES TRUE
143 1.8 christos #define ACPI_GET_ALL_TABLES FALSE
144 1.1 jruoho
145 1.1 jruoho
146 1.1 jruoho /*
147 1.1 jruoho * getopt
148 1.1 jruoho */
149 1.1 jruoho int
150 1.1 jruoho AcpiGetopt(
151 1.1 jruoho int argc,
152 1.1 jruoho char **argv,
153 1.1 jruoho char *opts);
154 1.1 jruoho
155 1.4 christos int
156 1.4 christos AcpiGetoptArgument (
157 1.4 christos int argc,
158 1.4 christos char **argv);
159 1.4 christos
160 1.1 jruoho extern int AcpiGbl_Optind;
161 1.1 jruoho extern int AcpiGbl_Opterr;
162 1.4 christos extern int AcpiGbl_SubOptChar;
163 1.1 jruoho extern char *AcpiGbl_Optarg;
164 1.1 jruoho
165 1.1 jruoho
166 1.6 christos /*
167 1.6 christos * cmfsize - Common get file size function
168 1.6 christos */
169 1.6 christos UINT32
170 1.6 christos CmGetFileSize (
171 1.6 christos ACPI_FILE File);
172 1.6 christos
173 1.6 christos
174 1.1 jruoho /*
175 1.1 jruoho * adwalk
176 1.1 jruoho */
177 1.1 jruoho void
178 1.1 jruoho AcpiDmCrossReferenceNamespace (
179 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
180 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot,
181 1.1 jruoho ACPI_OWNER_ID OwnerId);
182 1.1 jruoho
183 1.1 jruoho void
184 1.1 jruoho AcpiDmDumpTree (
185 1.1 jruoho ACPI_PARSE_OBJECT *Origin);
186 1.1 jruoho
187 1.1 jruoho void
188 1.1 jruoho AcpiDmFindOrphanMethods (
189 1.1 jruoho ACPI_PARSE_OBJECT *Origin);
190 1.1 jruoho
191 1.1 jruoho void
192 1.1 jruoho AcpiDmFinishNamespaceLoad (
193 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
194 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot,
195 1.1 jruoho ACPI_OWNER_ID OwnerId);
196 1.1 jruoho
197 1.1 jruoho void
198 1.11 christos AcpiDmConvertParseObjects (
199 1.1 jruoho ACPI_PARSE_OBJECT *ParseTreeRoot,
200 1.1 jruoho ACPI_NAMESPACE_NODE *NamespaceRoot);
201 1.1 jruoho
202 1.1 jruoho
203 1.1 jruoho /*
204 1.1 jruoho * adfile
205 1.1 jruoho */
206 1.1 jruoho ACPI_STATUS
207 1.1 jruoho AdInitialize (
208 1.1 jruoho void);
209 1.1 jruoho
210 1.1 jruoho char *
211 1.1 jruoho FlGenerateFilename (
212 1.1 jruoho char *InputFilename,
213 1.1 jruoho char *Suffix);
214 1.1 jruoho
215 1.1 jruoho ACPI_STATUS
216 1.1 jruoho FlSplitInputPathname (
217 1.1 jruoho char *InputPath,
218 1.1 jruoho char **OutDirectoryPath,
219 1.1 jruoho char **OutFilename);
220 1.1 jruoho
221 1.1 jruoho char *
222 1.1 jruoho AdGenerateFilename (
223 1.1 jruoho char *Prefix,
224 1.1 jruoho char *TableId);
225 1.1 jruoho
226 1.1 jruoho void
227 1.1 jruoho AdWriteTable (
228 1.1 jruoho ACPI_TABLE_HEADER *Table,
229 1.1 jruoho UINT32 Length,
230 1.1 jruoho char *TableName,
231 1.1 jruoho char *OemTableId);
232 1.1 jruoho
233 1.1 jruoho #endif /* _ACAPPS */
234