acpixtract.h revision 1.1.1.6 1 /******************************************************************************
2 *
3 * Module Name: acpixtract.h - Include for acpixtract utility
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2018, 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 #include "acpi.h"
45 #include "accommon.h"
46 #include "acapps.h"
47 #include <stdio.h>
48
49
50 #undef ACPI_GLOBAL
51
52 #ifdef DEFINE_ACPIXTRACT_GLOBALS
53 #define ACPI_GLOBAL(type,name) \
54 extern type name; \
55 type name
56
57 #else
58 #define ACPI_GLOBAL(type,name) \
59 extern type name
60 #endif
61
62
63 /* Options */
64
65 #define AX_EXTRACT_ALL 0
66 #define AX_LIST_ALL 1
67 #define AX_EXTRACT_SIGNATURE 2
68 #define AX_EXTRACT_AML_TABLES 3
69 #define AX_EXTRACT_MULTI_TABLE 4
70
71 #define AX_OPTIONAL_TABLES 0
72 #define AX_REQUIRED_TABLE 1
73
74 #define AX_UTILITY_NAME "ACPI Binary Table Extraction Utility"
75 #define AX_SUPPORTED_OPTIONS "afhlms:v^"
76 #define AX_MULTI_TABLE_FILENAME "amltables.dat"
77 #define AX_TABLE_INFO_FORMAT " %4.4s - %7u bytes written (0x%8.8X) - %s\n"
78
79 /* Extraction states */
80
81 #define AX_STATE_FIND_HEADER 0
82 #define AX_STATE_EXTRACT_DATA 1
83
84 /* Miscellaneous constants */
85
86 #define AX_LINE_BUFFER_SIZE 256
87 #define AX_MIN_BLOCK_HEADER_LENGTH 6 /* strlen ("DSDT @") */
88 #define AX_HEX_DATA_LENGTH 49 /* (3 * 16) + 1 for the colon delimiter */
89 #define AX_IS_TABLE_BLOCK_HEADER (strlen (Gbl_LineBuffer) < AX_HEX_DATA_LENGTH) && \
90 (strstr (Gbl_LineBuffer, " @ "))
91
92
93 typedef struct AxTableInfo
94 {
95 UINT32 Signature;
96 unsigned int Instances;
97 unsigned int NextInstance;
98 struct AxTableInfo *Next;
99
100 } AX_TABLE_INFO;
101
102
103 /* Globals */
104
105 ACPI_GLOBAL (char, Gbl_LineBuffer[AX_LINE_BUFFER_SIZE]);
106 ACPI_GLOBAL (char, Gbl_HeaderBuffer[AX_LINE_BUFFER_SIZE]);
107 ACPI_GLOBAL (char, Gbl_InstanceBuffer[AX_LINE_BUFFER_SIZE]);
108 ACPI_GLOBAL (AX_TABLE_INFO, *Gbl_TableListHead);
109 ACPI_GLOBAL (char, Gbl_OutputFilename[32]);
110 ACPI_GLOBAL (unsigned char, Gbl_BinaryData[16]);
111 ACPI_GLOBAL (unsigned int, Gbl_TableCount);
112 ACPI_GLOBAL (BOOLEAN, Gbl_ForceExtraction);
113
114
115 /*
116 * acpixtract.c
117 */
118 int
119 AxExtractTables (
120 char *InputPathname,
121 char *Signature,
122 unsigned int MinimumInstances);
123
124 int
125 AxExtractToMultiAmlFile (
126 char *InputPathname);
127
128 int
129 AxListAllTables (
130 char *InputPathname);
131
132
133 /*
134 * axutils.c
135 */
136 unsigned int
137 AxCountTableInstances (
138 char *InputPathname,
139 char *Signature);
140
141 unsigned int
142 AxGetNextInstance (
143 char *InputPathname,
144 char *Signature);
145
146 void
147 AxNormalizeSignature (
148 char *Signature);
149
150 void
151 AxCheckAscii (
152 char *Name,
153 int Count);
154
155 BOOLEAN
156 AxIsFileAscii (
157 FILE *Handle);
158
159 BOOLEAN
160 AxIsHexDataLine (
161 void);
162
163 BOOLEAN
164 AxIsEmptyLine (
165 char *Buffer);
166
167 BOOLEAN
168 AxIsDataBlockHeader (
169 void);
170
171 int
172 AxConvertAndWrite (
173 FILE *OutputFile,
174 char *ThisSignature);
175
176 int
177 AxConvertToBinary (
178 char *InputLine,
179 unsigned char *OutputData);
180
181 void
182 AxDumpTableHeader (
183 unsigned char *Header);
184