apdump.c revision 1.1.1.1.10.2 1 1.1.1.1.10.2 tls /******************************************************************************
2 1.1.1.1.10.2 tls *
3 1.1.1.1.10.2 tls * Module Name: apdump - Dump routines for ACPI tables (acpidump)
4 1.1.1.1.10.2 tls *
5 1.1.1.1.10.2 tls *****************************************************************************/
6 1.1.1.1.10.2 tls
7 1.1.1.1.10.2 tls /*
8 1.1.1.1.10.2 tls * Copyright (C) 2000 - 2013, Intel Corp.
9 1.1.1.1.10.2 tls * All rights reserved.
10 1.1.1.1.10.2 tls *
11 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
13 1.1.1.1.10.2 tls * are met:
14 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.10.2 tls * without modification.
17 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.10.2 tls * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.10.2 tls * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.10.2 tls * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.10.2 tls * binary redistribution.
22 1.1.1.1.10.2 tls * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.10.2 tls * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.10.2 tls * from this software without specific prior written permission.
25 1.1.1.1.10.2 tls *
26 1.1.1.1.10.2 tls * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.10.2 tls * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.10.2 tls * Software Foundation.
29 1.1.1.1.10.2 tls *
30 1.1.1.1.10.2 tls * NO WARRANTY
31 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.10.2 tls * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.10.2 tls * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.10.2 tls * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.10.2 tls * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.10.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.10.2 tls * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.10.2 tls * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.10.2 tls */
43 1.1.1.1.10.2 tls
44 1.1.1.1.10.2 tls #include "acpidump.h"
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls
47 1.1.1.1.10.2 tls /* Local prototypes */
48 1.1.1.1.10.2 tls
49 1.1.1.1.10.2 tls static int
50 1.1.1.1.10.2 tls ApDumpTableBuffer (
51 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table,
52 1.1.1.1.10.2 tls UINT32 Instance,
53 1.1.1.1.10.2 tls ACPI_PHYSICAL_ADDRESS Address);
54 1.1.1.1.10.2 tls
55 1.1.1.1.10.2 tls
56 1.1.1.1.10.2 tls /******************************************************************************
57 1.1.1.1.10.2 tls *
58 1.1.1.1.10.2 tls * FUNCTION: ApIsValidHeader
59 1.1.1.1.10.2 tls *
60 1.1.1.1.10.2 tls * PARAMETERS: Table - Pointer to table to be validated
61 1.1.1.1.10.2 tls *
62 1.1.1.1.10.2 tls * RETURN: TRUE if the header appears to be valid. FALSE otherwise
63 1.1.1.1.10.2 tls *
64 1.1.1.1.10.2 tls * DESCRIPTION: Check for a valid ACPI table header
65 1.1.1.1.10.2 tls *
66 1.1.1.1.10.2 tls ******************************************************************************/
67 1.1.1.1.10.2 tls
68 1.1.1.1.10.2 tls BOOLEAN
69 1.1.1.1.10.2 tls ApIsValidHeader (
70 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table)
71 1.1.1.1.10.2 tls {
72 1.1.1.1.10.2 tls if (!ACPI_VALIDATE_RSDP_SIG (Table->Signature))
73 1.1.1.1.10.2 tls {
74 1.1.1.1.10.2 tls /* Make sure signature is all ASCII and a valid ACPI name */
75 1.1.1.1.10.2 tls
76 1.1.1.1.10.2 tls if (!AcpiUtValidAcpiName (Table->Signature))
77 1.1.1.1.10.2 tls {
78 1.1.1.1.10.2 tls fprintf (stderr, "Table signature (0x%8.8X) is invalid\n",
79 1.1.1.1.10.2 tls *(UINT32 *) Table->Signature);
80 1.1.1.1.10.2 tls return (FALSE);
81 1.1.1.1.10.2 tls }
82 1.1.1.1.10.2 tls
83 1.1.1.1.10.2 tls /* Check for minimum table length */
84 1.1.1.1.10.2 tls
85 1.1.1.1.10.2 tls if (Table->Length < sizeof (ACPI_TABLE_HEADER))
86 1.1.1.1.10.2 tls {
87 1.1.1.1.10.2 tls fprintf (stderr, "Table length (0x%8.8X) is invalid\n",
88 1.1.1.1.10.2 tls Table->Length);
89 1.1.1.1.10.2 tls return (FALSE);
90 1.1.1.1.10.2 tls }
91 1.1.1.1.10.2 tls }
92 1.1.1.1.10.2 tls
93 1.1.1.1.10.2 tls return (TRUE);
94 1.1.1.1.10.2 tls }
95 1.1.1.1.10.2 tls
96 1.1.1.1.10.2 tls
97 1.1.1.1.10.2 tls /******************************************************************************
98 1.1.1.1.10.2 tls *
99 1.1.1.1.10.2 tls * FUNCTION: ApIsValidChecksum
100 1.1.1.1.10.2 tls *
101 1.1.1.1.10.2 tls * PARAMETERS: Table - Pointer to table to be validated
102 1.1.1.1.10.2 tls *
103 1.1.1.1.10.2 tls * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise
104 1.1.1.1.10.2 tls *
105 1.1.1.1.10.2 tls * DESCRIPTION: Check for a valid ACPI table checksum
106 1.1.1.1.10.2 tls *
107 1.1.1.1.10.2 tls ******************************************************************************/
108 1.1.1.1.10.2 tls
109 1.1.1.1.10.2 tls BOOLEAN
110 1.1.1.1.10.2 tls ApIsValidChecksum (
111 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table)
112 1.1.1.1.10.2 tls {
113 1.1.1.1.10.2 tls ACPI_STATUS Status;
114 1.1.1.1.10.2 tls ACPI_TABLE_RSDP *Rsdp;
115 1.1.1.1.10.2 tls
116 1.1.1.1.10.2 tls
117 1.1.1.1.10.2 tls if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
118 1.1.1.1.10.2 tls {
119 1.1.1.1.10.2 tls /*
120 1.1.1.1.10.2 tls * Checksum for RSDP.
121 1.1.1.1.10.2 tls * Note: Other checksums are computed during the table dump.
122 1.1.1.1.10.2 tls */
123 1.1.1.1.10.2 tls
124 1.1.1.1.10.2 tls Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
125 1.1.1.1.10.2 tls Status = AcpiTbValidateRsdp (Rsdp);
126 1.1.1.1.10.2 tls }
127 1.1.1.1.10.2 tls else
128 1.1.1.1.10.2 tls {
129 1.1.1.1.10.2 tls Status = AcpiTbVerifyChecksum (Table, Table->Length);
130 1.1.1.1.10.2 tls }
131 1.1.1.1.10.2 tls
132 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
133 1.1.1.1.10.2 tls {
134 1.1.1.1.10.2 tls fprintf (stderr, "%4.4s: Warning: wrong checksum\n",
135 1.1.1.1.10.2 tls Table->Signature);
136 1.1.1.1.10.2 tls }
137 1.1.1.1.10.2 tls
138 1.1.1.1.10.2 tls return (AE_OK);
139 1.1.1.1.10.2 tls }
140 1.1.1.1.10.2 tls
141 1.1.1.1.10.2 tls
142 1.1.1.1.10.2 tls /******************************************************************************
143 1.1.1.1.10.2 tls *
144 1.1.1.1.10.2 tls * FUNCTION: ApGetTableLength
145 1.1.1.1.10.2 tls *
146 1.1.1.1.10.2 tls * PARAMETERS: Table - Pointer to the table
147 1.1.1.1.10.2 tls *
148 1.1.1.1.10.2 tls * RETURN: Table length
149 1.1.1.1.10.2 tls *
150 1.1.1.1.10.2 tls * DESCRIPTION: Obtain table length according to table signature
151 1.1.1.1.10.2 tls *
152 1.1.1.1.10.2 tls ******************************************************************************/
153 1.1.1.1.10.2 tls
154 1.1.1.1.10.2 tls UINT32
155 1.1.1.1.10.2 tls ApGetTableLength (
156 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table)
157 1.1.1.1.10.2 tls {
158 1.1.1.1.10.2 tls ACPI_TABLE_RSDP *Rsdp;
159 1.1.1.1.10.2 tls
160 1.1.1.1.10.2 tls
161 1.1.1.1.10.2 tls /* Check if table is valid */
162 1.1.1.1.10.2 tls
163 1.1.1.1.10.2 tls if (!ApIsValidHeader (Table))
164 1.1.1.1.10.2 tls {
165 1.1.1.1.10.2 tls return (0);
166 1.1.1.1.10.2 tls }
167 1.1.1.1.10.2 tls
168 1.1.1.1.10.2 tls if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
169 1.1.1.1.10.2 tls {
170 1.1.1.1.10.2 tls Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
171 1.1.1.1.10.2 tls return (Rsdp->Length);
172 1.1.1.1.10.2 tls }
173 1.1.1.1.10.2 tls else
174 1.1.1.1.10.2 tls {
175 1.1.1.1.10.2 tls return (Table->Length);
176 1.1.1.1.10.2 tls }
177 1.1.1.1.10.2 tls }
178 1.1.1.1.10.2 tls
179 1.1.1.1.10.2 tls
180 1.1.1.1.10.2 tls /******************************************************************************
181 1.1.1.1.10.2 tls *
182 1.1.1.1.10.2 tls * FUNCTION: ApDumpTableBuffer
183 1.1.1.1.10.2 tls *
184 1.1.1.1.10.2 tls * PARAMETERS: Table - ACPI table to be dumped
185 1.1.1.1.10.2 tls * Instance - ACPI table instance no. to be dumped
186 1.1.1.1.10.2 tls * Address - Physical address of the table
187 1.1.1.1.10.2 tls *
188 1.1.1.1.10.2 tls * RETURN: None
189 1.1.1.1.10.2 tls *
190 1.1.1.1.10.2 tls * DESCRIPTION: Dump an ACPI table in standard ASCII hex format, with a
191 1.1.1.1.10.2 tls * header that is compatible with the AcpiXtract utility.
192 1.1.1.1.10.2 tls *
193 1.1.1.1.10.2 tls ******************************************************************************/
194 1.1.1.1.10.2 tls
195 1.1.1.1.10.2 tls static int
196 1.1.1.1.10.2 tls ApDumpTableBuffer (
197 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table,
198 1.1.1.1.10.2 tls UINT32 Instance,
199 1.1.1.1.10.2 tls ACPI_PHYSICAL_ADDRESS Address)
200 1.1.1.1.10.2 tls {
201 1.1.1.1.10.2 tls UINT32 TableLength;
202 1.1.1.1.10.2 tls
203 1.1.1.1.10.2 tls
204 1.1.1.1.10.2 tls TableLength = ApGetTableLength (Table);
205 1.1.1.1.10.2 tls
206 1.1.1.1.10.2 tls /* Print only the header if requested */
207 1.1.1.1.10.2 tls
208 1.1.1.1.10.2 tls if (Gbl_SummaryMode)
209 1.1.1.1.10.2 tls {
210 1.1.1.1.10.2 tls AcpiTbPrintTableHeader (Address, Table);
211 1.1.1.1.10.2 tls return (0);
212 1.1.1.1.10.2 tls }
213 1.1.1.1.10.2 tls
214 1.1.1.1.10.2 tls /* Dump to binary file if requested */
215 1.1.1.1.10.2 tls
216 1.1.1.1.10.2 tls if (Gbl_BinaryMode)
217 1.1.1.1.10.2 tls {
218 1.1.1.1.10.2 tls return (ApWriteToBinaryFile (Table, Instance));
219 1.1.1.1.10.2 tls }
220 1.1.1.1.10.2 tls
221 1.1.1.1.10.2 tls /*
222 1.1.1.1.10.2 tls * Dump the table with header for use with acpixtract utility
223 1.1.1.1.10.2 tls * Note: simplest to just always emit a 64-bit address. AcpiXtract
224 1.1.1.1.10.2 tls * utility can handle this.
225 1.1.1.1.10.2 tls */
226 1.1.1.1.10.2 tls printf ("%4.4s @ 0x%8.8X%8.8X\n", Table->Signature,
227 1.1.1.1.10.2 tls ACPI_FORMAT_UINT64 (Address));
228 1.1.1.1.10.2 tls
229 1.1.1.1.10.2 tls AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), TableLength,
230 1.1.1.1.10.2 tls DB_BYTE_DISPLAY, 0);
231 1.1.1.1.10.2 tls printf ("\n");
232 1.1.1.1.10.2 tls return (0);
233 1.1.1.1.10.2 tls }
234 1.1.1.1.10.2 tls
235 1.1.1.1.10.2 tls
236 1.1.1.1.10.2 tls /******************************************************************************
237 1.1.1.1.10.2 tls *
238 1.1.1.1.10.2 tls * FUNCTION: ApDumpAllTables
239 1.1.1.1.10.2 tls *
240 1.1.1.1.10.2 tls * PARAMETERS: None
241 1.1.1.1.10.2 tls *
242 1.1.1.1.10.2 tls * RETURN: Status
243 1.1.1.1.10.2 tls *
244 1.1.1.1.10.2 tls * DESCRIPTION: Get all tables from the RSDT/XSDT (or at least all of the
245 1.1.1.1.10.2 tls * tables that we can possibly get).
246 1.1.1.1.10.2 tls *
247 1.1.1.1.10.2 tls ******************************************************************************/
248 1.1.1.1.10.2 tls
249 1.1.1.1.10.2 tls int
250 1.1.1.1.10.2 tls ApDumpAllTables (
251 1.1.1.1.10.2 tls void)
252 1.1.1.1.10.2 tls {
253 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table;
254 1.1.1.1.10.2 tls UINT32 Instance = 0;
255 1.1.1.1.10.2 tls ACPI_PHYSICAL_ADDRESS Address;
256 1.1.1.1.10.2 tls ACPI_STATUS Status;
257 1.1.1.1.10.2 tls UINT32 i;
258 1.1.1.1.10.2 tls
259 1.1.1.1.10.2 tls
260 1.1.1.1.10.2 tls /* Get and dump all available ACPI tables */
261 1.1.1.1.10.2 tls
262 1.1.1.1.10.2 tls for (i = 0; i < AP_MAX_ACPI_FILES; i++)
263 1.1.1.1.10.2 tls {
264 1.1.1.1.10.2 tls Status = AcpiOsGetTableByIndex (i, &Table, &Instance, &Address);
265 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
266 1.1.1.1.10.2 tls {
267 1.1.1.1.10.2 tls /* AE_LIMIT means that no more tables are available */
268 1.1.1.1.10.2 tls
269 1.1.1.1.10.2 tls if (Status == AE_LIMIT)
270 1.1.1.1.10.2 tls {
271 1.1.1.1.10.2 tls return (0);
272 1.1.1.1.10.2 tls }
273 1.1.1.1.10.2 tls else if (i == 0)
274 1.1.1.1.10.2 tls {
275 1.1.1.1.10.2 tls fprintf (stderr, "Could not get ACPI tables, %s\n",
276 1.1.1.1.10.2 tls AcpiFormatException (Status));
277 1.1.1.1.10.2 tls return (-1);
278 1.1.1.1.10.2 tls }
279 1.1.1.1.10.2 tls else
280 1.1.1.1.10.2 tls {
281 1.1.1.1.10.2 tls fprintf (stderr, "Could not get ACPI table at index %u, %s\n",
282 1.1.1.1.10.2 tls i, AcpiFormatException (Status));
283 1.1.1.1.10.2 tls continue;
284 1.1.1.1.10.2 tls }
285 1.1.1.1.10.2 tls }
286 1.1.1.1.10.2 tls
287 1.1.1.1.10.2 tls if (ApDumpTableBuffer (Table, Instance, Address))
288 1.1.1.1.10.2 tls {
289 1.1.1.1.10.2 tls return (-1);
290 1.1.1.1.10.2 tls }
291 1.1.1.1.10.2 tls free (Table);
292 1.1.1.1.10.2 tls }
293 1.1.1.1.10.2 tls
294 1.1.1.1.10.2 tls /* Something seriously bad happened if the loop terminates here */
295 1.1.1.1.10.2 tls
296 1.1.1.1.10.2 tls return (-1);
297 1.1.1.1.10.2 tls }
298 1.1.1.1.10.2 tls
299 1.1.1.1.10.2 tls
300 1.1.1.1.10.2 tls /******************************************************************************
301 1.1.1.1.10.2 tls *
302 1.1.1.1.10.2 tls * FUNCTION: ApDumpTableByAddress
303 1.1.1.1.10.2 tls *
304 1.1.1.1.10.2 tls * PARAMETERS: AsciiAddress - Address for requested ACPI table
305 1.1.1.1.10.2 tls *
306 1.1.1.1.10.2 tls * RETURN: Status
307 1.1.1.1.10.2 tls *
308 1.1.1.1.10.2 tls * DESCRIPTION: Get an ACPI table via a physical address and dump it.
309 1.1.1.1.10.2 tls *
310 1.1.1.1.10.2 tls ******************************************************************************/
311 1.1.1.1.10.2 tls
312 1.1.1.1.10.2 tls int
313 1.1.1.1.10.2 tls ApDumpTableByAddress (
314 1.1.1.1.10.2 tls char *AsciiAddress)
315 1.1.1.1.10.2 tls {
316 1.1.1.1.10.2 tls ACPI_PHYSICAL_ADDRESS Address;
317 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table;
318 1.1.1.1.10.2 tls ACPI_STATUS Status;
319 1.1.1.1.10.2 tls int TableStatus;
320 1.1.1.1.10.2 tls UINT64 LongAddress;
321 1.1.1.1.10.2 tls
322 1.1.1.1.10.2 tls
323 1.1.1.1.10.2 tls /* Convert argument to an integer physical address */
324 1.1.1.1.10.2 tls
325 1.1.1.1.10.2 tls Status = AcpiUtStrtoul64 (AsciiAddress, 0, &LongAddress);
326 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
327 1.1.1.1.10.2 tls {
328 1.1.1.1.10.2 tls fprintf (stderr, "%s: Could not convert to a physical address\n",
329 1.1.1.1.10.2 tls AsciiAddress);
330 1.1.1.1.10.2 tls return (-1);
331 1.1.1.1.10.2 tls }
332 1.1.1.1.10.2 tls
333 1.1.1.1.10.2 tls Address = (ACPI_PHYSICAL_ADDRESS) LongAddress;
334 1.1.1.1.10.2 tls Status = AcpiOsGetTableByAddress (Address, &Table);
335 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
336 1.1.1.1.10.2 tls {
337 1.1.1.1.10.2 tls fprintf (stderr, "Could not get table at 0x%8.8X%8.8X, %s\n",
338 1.1.1.1.10.2 tls ACPI_FORMAT_UINT64 (Address),
339 1.1.1.1.10.2 tls AcpiFormatException (Status));
340 1.1.1.1.10.2 tls return (-1);
341 1.1.1.1.10.2 tls }
342 1.1.1.1.10.2 tls
343 1.1.1.1.10.2 tls TableStatus = ApDumpTableBuffer (Table, 0, Address);
344 1.1.1.1.10.2 tls free (Table);
345 1.1.1.1.10.2 tls return (TableStatus);
346 1.1.1.1.10.2 tls }
347 1.1.1.1.10.2 tls
348 1.1.1.1.10.2 tls
349 1.1.1.1.10.2 tls /******************************************************************************
350 1.1.1.1.10.2 tls *
351 1.1.1.1.10.2 tls * FUNCTION: ApDumpTableByName
352 1.1.1.1.10.2 tls *
353 1.1.1.1.10.2 tls * PARAMETERS: Signature - Requested ACPI table signature
354 1.1.1.1.10.2 tls *
355 1.1.1.1.10.2 tls * RETURN: Status
356 1.1.1.1.10.2 tls *
357 1.1.1.1.10.2 tls * DESCRIPTION: Get an ACPI table via a signature and dump it. Handles
358 1.1.1.1.10.2 tls * multiple tables with the same signature (SSDTs).
359 1.1.1.1.10.2 tls *
360 1.1.1.1.10.2 tls ******************************************************************************/
361 1.1.1.1.10.2 tls
362 1.1.1.1.10.2 tls int
363 1.1.1.1.10.2 tls ApDumpTableByName (
364 1.1.1.1.10.2 tls char *Signature)
365 1.1.1.1.10.2 tls {
366 1.1.1.1.10.2 tls char LocalSignature [ACPI_NAME_SIZE + 1];
367 1.1.1.1.10.2 tls UINT32 Instance;
368 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table;
369 1.1.1.1.10.2 tls ACPI_PHYSICAL_ADDRESS Address;
370 1.1.1.1.10.2 tls ACPI_STATUS Status;
371 1.1.1.1.10.2 tls
372 1.1.1.1.10.2 tls
373 1.1.1.1.10.2 tls if (strlen (Signature) != ACPI_NAME_SIZE)
374 1.1.1.1.10.2 tls {
375 1.1.1.1.10.2 tls fprintf (stderr,
376 1.1.1.1.10.2 tls "Invalid table signature [%s]: must be exactly 4 characters\n",
377 1.1.1.1.10.2 tls Signature);
378 1.1.1.1.10.2 tls return (-1);
379 1.1.1.1.10.2 tls }
380 1.1.1.1.10.2 tls
381 1.1.1.1.10.2 tls /* Table signatures are expected to be uppercase */
382 1.1.1.1.10.2 tls
383 1.1.1.1.10.2 tls strcpy (LocalSignature, Signature);
384 1.1.1.1.10.2 tls AcpiUtStrupr (LocalSignature);
385 1.1.1.1.10.2 tls
386 1.1.1.1.10.2 tls /* To be friendly, handle tables whose signatures do not match the name */
387 1.1.1.1.10.2 tls
388 1.1.1.1.10.2 tls if (ACPI_COMPARE_NAME (LocalSignature, AP_DUMP_SIG_RSDP))
389 1.1.1.1.10.2 tls {
390 1.1.1.1.10.2 tls strcpy (LocalSignature, AP_DUMP_SIG_RSDP);
391 1.1.1.1.10.2 tls }
392 1.1.1.1.10.2 tls else if (ACPI_COMPARE_NAME (LocalSignature, "FADT"))
393 1.1.1.1.10.2 tls {
394 1.1.1.1.10.2 tls strcpy (LocalSignature, ACPI_SIG_FADT);
395 1.1.1.1.10.2 tls }
396 1.1.1.1.10.2 tls else if (ACPI_COMPARE_NAME (LocalSignature, "MADT"))
397 1.1.1.1.10.2 tls {
398 1.1.1.1.10.2 tls strcpy (LocalSignature, ACPI_SIG_MADT);
399 1.1.1.1.10.2 tls }
400 1.1.1.1.10.2 tls
401 1.1.1.1.10.2 tls /* Dump all instances of this signature (to handle multiple SSDTs) */
402 1.1.1.1.10.2 tls
403 1.1.1.1.10.2 tls for (Instance = 0; Instance < AP_MAX_ACPI_FILES; Instance++)
404 1.1.1.1.10.2 tls {
405 1.1.1.1.10.2 tls Status = AcpiOsGetTableByName (LocalSignature, Instance,
406 1.1.1.1.10.2 tls &Table, &Address);
407 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
408 1.1.1.1.10.2 tls {
409 1.1.1.1.10.2 tls /* AE_LIMIT means that no more tables are available */
410 1.1.1.1.10.2 tls
411 1.1.1.1.10.2 tls if (Status == AE_LIMIT)
412 1.1.1.1.10.2 tls {
413 1.1.1.1.10.2 tls return (0);
414 1.1.1.1.10.2 tls }
415 1.1.1.1.10.2 tls
416 1.1.1.1.10.2 tls fprintf (stderr,
417 1.1.1.1.10.2 tls "Could not get ACPI table with signature [%s], %s\n",
418 1.1.1.1.10.2 tls LocalSignature, AcpiFormatException (Status));
419 1.1.1.1.10.2 tls return (-1);
420 1.1.1.1.10.2 tls }
421 1.1.1.1.10.2 tls
422 1.1.1.1.10.2 tls if (ApDumpTableBuffer (Table, Instance, Address))
423 1.1.1.1.10.2 tls {
424 1.1.1.1.10.2 tls return (-1);
425 1.1.1.1.10.2 tls }
426 1.1.1.1.10.2 tls free (Table);
427 1.1.1.1.10.2 tls }
428 1.1.1.1.10.2 tls
429 1.1.1.1.10.2 tls /* Something seriously bad happened if the loop terminates here */
430 1.1.1.1.10.2 tls
431 1.1.1.1.10.2 tls return (-1);
432 1.1.1.1.10.2 tls }
433 1.1.1.1.10.2 tls
434 1.1.1.1.10.2 tls
435 1.1.1.1.10.2 tls /******************************************************************************
436 1.1.1.1.10.2 tls *
437 1.1.1.1.10.2 tls * FUNCTION: ApDumpTableFromFile
438 1.1.1.1.10.2 tls *
439 1.1.1.1.10.2 tls * PARAMETERS: Pathname - File containing the binary ACPI table
440 1.1.1.1.10.2 tls *
441 1.1.1.1.10.2 tls * RETURN: Status
442 1.1.1.1.10.2 tls *
443 1.1.1.1.10.2 tls * DESCRIPTION: Dump an ACPI table from a binary file
444 1.1.1.1.10.2 tls *
445 1.1.1.1.10.2 tls ******************************************************************************/
446 1.1.1.1.10.2 tls
447 1.1.1.1.10.2 tls int
448 1.1.1.1.10.2 tls ApDumpTableFromFile (
449 1.1.1.1.10.2 tls char *Pathname)
450 1.1.1.1.10.2 tls {
451 1.1.1.1.10.2 tls ACPI_TABLE_HEADER *Table;
452 1.1.1.1.10.2 tls UINT32 FileSize = 0;
453 1.1.1.1.10.2 tls int TableStatus;
454 1.1.1.1.10.2 tls
455 1.1.1.1.10.2 tls
456 1.1.1.1.10.2 tls /* Get the entire ACPI table from the file */
457 1.1.1.1.10.2 tls
458 1.1.1.1.10.2 tls Table = ApGetTableFromFile (Pathname, &FileSize);
459 1.1.1.1.10.2 tls if (!Table)
460 1.1.1.1.10.2 tls {
461 1.1.1.1.10.2 tls return (-1);
462 1.1.1.1.10.2 tls }
463 1.1.1.1.10.2 tls
464 1.1.1.1.10.2 tls /* File must be at least as long as the table length */
465 1.1.1.1.10.2 tls
466 1.1.1.1.10.2 tls if (Table->Length > FileSize)
467 1.1.1.1.10.2 tls {
468 1.1.1.1.10.2 tls fprintf (stderr,
469 1.1.1.1.10.2 tls "Table length (0x%X) is too large for input file (0x%X) %s\n",
470 1.1.1.1.10.2 tls Table->Length, FileSize, Pathname);
471 1.1.1.1.10.2 tls return (-1);
472 1.1.1.1.10.2 tls }
473 1.1.1.1.10.2 tls
474 1.1.1.1.10.2 tls if (Gbl_VerboseMode)
475 1.1.1.1.10.2 tls {
476 1.1.1.1.10.2 tls fprintf (stderr,
477 1.1.1.1.10.2 tls "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
478 1.1.1.1.10.2 tls Pathname, Table->Signature, FileSize, FileSize);
479 1.1.1.1.10.2 tls }
480 1.1.1.1.10.2 tls
481 1.1.1.1.10.2 tls TableStatus = ApDumpTableBuffer (Table, 0, 0);
482 1.1.1.1.10.2 tls free (Table);
483 1.1.1.1.10.2 tls return (TableStatus);
484 1.1.1.1.10.2 tls }
485 1.1.1.1.10.2 tls
486 1.1.1.1.10.2 tls
487 1.1.1.1.10.2 tls /******************************************************************************
488 1.1.1.1.10.2 tls *
489 1.1.1.1.10.2 tls * FUNCTION: AcpiOs* print functions
490 1.1.1.1.10.2 tls *
491 1.1.1.1.10.2 tls * DESCRIPTION: Used for linkage with ACPICA modules
492 1.1.1.1.10.2 tls *
493 1.1.1.1.10.2 tls ******************************************************************************/
494 1.1.1.1.10.2 tls
495 1.1.1.1.10.2 tls void ACPI_INTERNAL_VAR_XFACE
496 1.1.1.1.10.2 tls AcpiOsPrintf (
497 1.1.1.1.10.2 tls const char *Fmt,
498 1.1.1.1.10.2 tls ...)
499 1.1.1.1.10.2 tls {
500 1.1.1.1.10.2 tls va_list Args;
501 1.1.1.1.10.2 tls
502 1.1.1.1.10.2 tls va_start (Args, Fmt);
503 1.1.1.1.10.2 tls vfprintf (stdout, Fmt, Args);
504 1.1.1.1.10.2 tls va_end (Args);
505 1.1.1.1.10.2 tls }
506 1.1.1.1.10.2 tls
507 1.1.1.1.10.2 tls void
508 1.1.1.1.10.2 tls AcpiOsVprintf (
509 1.1.1.1.10.2 tls const char *Fmt,
510 1.1.1.1.10.2 tls va_list Args)
511 1.1.1.1.10.2 tls {
512 1.1.1.1.10.2 tls vfprintf (stdout, Fmt, Args);
513 1.1.1.1.10.2 tls }
514