acapps.h revision 281075
1/******************************************************************************
2 *
3 * Module Name: acapps - common include for ACPI applications/tools
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2015, 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
48#ifdef _MSC_VER                 /* disable some level-4 warnings */
49#pragma warning(disable:4100)   /* warning C4100: unreferenced formal parameter */
50#endif
51
52/* Common info for tool signons */
53
54#define ACPICA_NAME                 "Intel ACPI Component Architecture"
55#define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2015 Intel Corporation"
56
57#if ACPI_MACHINE_WIDTH == 64
58#define ACPI_WIDTH          "-64"
59
60#elif ACPI_MACHINE_WIDTH == 32
61#define ACPI_WIDTH          "-32"
62
63#else
64#error unknown ACPI_MACHINE_WIDTH
65#define ACPI_WIDTH          "-??"
66
67#endif
68
69/* Macros for signons and file headers */
70
71#define ACPI_COMMON_SIGNON(UtilityName) \
72    "\n%s\n%s version %8.8X%s\n%s\n\n", \
73    ACPICA_NAME, \
74    UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
75    ACPICA_COPYRIGHT
76
77#define ACPI_COMMON_HEADER(UtilityName, Prefix) \
78    "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
79    Prefix, ACPICA_NAME, \
80    Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
81    Prefix, ACPICA_COPYRIGHT, \
82    Prefix
83
84/* Macros for usage messages */
85
86#define ACPI_USAGE_HEADER(Usage) \
87    AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage);
88
89#define ACPI_USAGE_TEXT(Description) \
90    AcpiOsPrintf (Description);
91
92#define ACPI_OPTION(Name, Description) \
93    AcpiOsPrintf ("  %-18s%s\n", Name, Description);
94
95
96#define FILE_SUFFIX_DISASSEMBLY     "dsl"
97#define ACPI_TABLE_FILE_SUFFIX      ".dat"
98
99
100/*
101 * getopt
102 */
103int
104AcpiGetopt(
105    int                     argc,
106    char                    **argv,
107    char                    *opts);
108
109int
110AcpiGetoptArgument (
111    int                     argc,
112    char                    **argv);
113
114extern int                  AcpiGbl_Optind;
115extern int                  AcpiGbl_Opterr;
116extern int                  AcpiGbl_SubOptChar;
117extern char                 *AcpiGbl_Optarg;
118
119
120/*
121 * cmfsize - Common get file size function
122 */
123UINT32
124CmGetFileSize (
125    ACPI_FILE               File);
126
127
128#ifndef ACPI_DUMP_APP
129/*
130 * adisasm
131 */
132ACPI_STATUS
133AdAmlDisassemble (
134    BOOLEAN                 OutToFile,
135    char                    *Filename,
136    char                    *Prefix,
137    char                    **OutFilename);
138
139void
140AdPrintStatistics (
141    void);
142
143ACPI_STATUS
144AdFindDsdt(
145    UINT8                   **DsdtPtr,
146    UINT32                  *DsdtLength);
147
148void
149AdDumpTables (
150    void);
151
152ACPI_STATUS
153AdGetLocalTables (
154    void);
155
156ACPI_STATUS
157AdParseTable (
158    ACPI_TABLE_HEADER       *Table,
159    ACPI_OWNER_ID           *OwnerId,
160    BOOLEAN                 LoadTable,
161    BOOLEAN                 External);
162
163ACPI_STATUS
164AdDisplayTables (
165    char                    *Filename,
166    ACPI_TABLE_HEADER       *Table);
167
168ACPI_STATUS
169AdDisplayStatistics (
170    void);
171
172
173/*
174 * adwalk
175 */
176void
177AcpiDmCrossReferenceNamespace (
178    ACPI_PARSE_OBJECT       *ParseTreeRoot,
179    ACPI_NAMESPACE_NODE     *NamespaceRoot,
180    ACPI_OWNER_ID           OwnerId);
181
182void
183AcpiDmDumpTree (
184    ACPI_PARSE_OBJECT       *Origin);
185
186void
187AcpiDmFindOrphanMethods (
188    ACPI_PARSE_OBJECT       *Origin);
189
190void
191AcpiDmFinishNamespaceLoad (
192    ACPI_PARSE_OBJECT       *ParseTreeRoot,
193    ACPI_NAMESPACE_NODE     *NamespaceRoot,
194    ACPI_OWNER_ID           OwnerId);
195
196void
197AcpiDmConvertResourceIndexes (
198    ACPI_PARSE_OBJECT       *ParseTreeRoot,
199    ACPI_NAMESPACE_NODE     *NamespaceRoot);
200
201
202/*
203 * adfile
204 */
205ACPI_STATUS
206AdInitialize (
207    void);
208
209char *
210FlGenerateFilename (
211    char                    *InputFilename,
212    char                    *Suffix);
213
214ACPI_STATUS
215FlSplitInputPathname (
216    char                    *InputPath,
217    char                    **OutDirectoryPath,
218    char                    **OutFilename);
219
220char *
221AdGenerateFilename (
222    char                    *Prefix,
223    char                    *TableId);
224
225void
226AdWriteTable (
227    ACPI_TABLE_HEADER       *Table,
228    UINT32                  Length,
229    char                    *TableName,
230    char                    *OemTableId);
231#endif
232
233#endif /* _ACAPPS */
234