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