diff options
author | Bob Moore <robert.moore@intel.com> | 2013-06-07 20:59:02 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-15 18:55:56 -0400 |
commit | 42f47869c6a73a6893c998725365b587b0311f9a (patch) | |
tree | ba644377ca39ec47c5d63452bfadc5742c17f902 | |
parent | b75dd2977fc3c5848f739681fc799f27b1322e44 (diff) |
ACPICA: Split table print utilities to a new a separate file
Improves configurability of ACPICA.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/Makefile | 1 | ||||
-rw-r--r-- | drivers/acpi/acpica/tbprint.c | 237 | ||||
-rw-r--r-- | drivers/acpi/acpica/tbutils.c | 191 |
3 files changed, 239 insertions, 190 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 987bf41ec903..438304086ff1 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -138,6 +138,7 @@ acpi-y += \ | |||
138 | tbfadt.o \ | 138 | tbfadt.o \ |
139 | tbfind.o \ | 139 | tbfind.o \ |
140 | tbinstal.o \ | 140 | tbinstal.o \ |
141 | tbprint.o \ | ||
141 | tbutils.o \ | 142 | tbutils.o \ |
142 | tbxface.o \ | 143 | tbxface.o \ |
143 | tbxfload.o \ | 144 | tbxfload.o \ |
diff --git a/drivers/acpi/acpica/tbprint.c b/drivers/acpi/acpica/tbprint.c new file mode 100644 index 000000000000..dc963f823d2c --- /dev/null +++ b/drivers/acpi/acpica/tbprint.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: tbprint - Table output utilities | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, 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/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "actables.h" | ||
47 | |||
48 | #define _COMPONENT ACPI_TABLES | ||
49 | ACPI_MODULE_NAME("tbprint") | ||
50 | |||
51 | /* Local prototypes */ | ||
52 | static void acpi_tb_fix_string(char *string, acpi_size length); | ||
53 | |||
54 | static void | ||
55 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
56 | struct acpi_table_header *header); | ||
57 | |||
58 | /******************************************************************************* | ||
59 | * | ||
60 | * FUNCTION: acpi_tb_fix_string | ||
61 | * | ||
62 | * PARAMETERS: string - String to be repaired | ||
63 | * length - Maximum length | ||
64 | * | ||
65 | * RETURN: None | ||
66 | * | ||
67 | * DESCRIPTION: Replace every non-printable or non-ascii byte in the string | ||
68 | * with a question mark '?'. | ||
69 | * | ||
70 | ******************************************************************************/ | ||
71 | |||
72 | static void acpi_tb_fix_string(char *string, acpi_size length) | ||
73 | { | ||
74 | |||
75 | while (length && *string) { | ||
76 | if (!ACPI_IS_PRINT(*string)) { | ||
77 | *string = '?'; | ||
78 | } | ||
79 | string++; | ||
80 | length--; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /******************************************************************************* | ||
85 | * | ||
86 | * FUNCTION: acpi_tb_cleanup_table_header | ||
87 | * | ||
88 | * PARAMETERS: out_header - Where the cleaned header is returned | ||
89 | * header - Input ACPI table header | ||
90 | * | ||
91 | * RETURN: Returns the cleaned header in out_header | ||
92 | * | ||
93 | * DESCRIPTION: Copy the table header and ensure that all "string" fields in | ||
94 | * the header consist of printable characters. | ||
95 | * | ||
96 | ******************************************************************************/ | ||
97 | |||
98 | static void | ||
99 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
100 | struct acpi_table_header *header) | ||
101 | { | ||
102 | |||
103 | ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header)); | ||
104 | |||
105 | acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE); | ||
106 | acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE); | ||
107 | acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | ||
108 | acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE); | ||
109 | } | ||
110 | |||
111 | /******************************************************************************* | ||
112 | * | ||
113 | * FUNCTION: acpi_tb_print_table_header | ||
114 | * | ||
115 | * PARAMETERS: address - Table physical address | ||
116 | * header - Table header | ||
117 | * | ||
118 | * RETURN: None | ||
119 | * | ||
120 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. | ||
121 | * | ||
122 | ******************************************************************************/ | ||
123 | |||
124 | void | ||
125 | acpi_tb_print_table_header(acpi_physical_address address, | ||
126 | struct acpi_table_header *header) | ||
127 | { | ||
128 | struct acpi_table_header local_header; | ||
129 | |||
130 | /* | ||
131 | * The reason that the Address is cast to a void pointer is so that we | ||
132 | * can use %p which will work properly on both 32-bit and 64-bit hosts. | ||
133 | */ | ||
134 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { | ||
135 | |||
136 | /* FACS only has signature and length fields */ | ||
137 | |||
138 | ACPI_INFO((AE_INFO, "%4.4s %p %05X", | ||
139 | header->signature, ACPI_CAST_PTR(void, address), | ||
140 | header->length)); | ||
141 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | ||
142 | |||
143 | /* RSDP has no common fields */ | ||
144 | |||
145 | ACPI_MEMCPY(local_header.oem_id, | ||
146 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
147 | header)->oem_id, ACPI_OEM_ID_SIZE); | ||
148 | acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE); | ||
149 | |||
150 | ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", | ||
151 | ACPI_CAST_PTR(void, address), | ||
152 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> | ||
153 | revision > | ||
154 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
155 | header)->length : 20, | ||
156 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
157 | header)->revision, | ||
158 | local_header.oem_id)); | ||
159 | } else { | ||
160 | /* Standard ACPI table with full common header */ | ||
161 | |||
162 | acpi_tb_cleanup_table_header(&local_header, header); | ||
163 | |||
164 | ACPI_INFO((AE_INFO, | ||
165 | "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", | ||
166 | local_header.signature, ACPI_CAST_PTR(void, address), | ||
167 | local_header.length, local_header.revision, | ||
168 | local_header.oem_id, local_header.oem_table_id, | ||
169 | local_header.oem_revision, | ||
170 | local_header.asl_compiler_id, | ||
171 | local_header.asl_compiler_revision)); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /******************************************************************************* | ||
176 | * | ||
177 | * FUNCTION: acpi_tb_validate_checksum | ||
178 | * | ||
179 | * PARAMETERS: table - ACPI table to verify | ||
180 | * length - Length of entire table | ||
181 | * | ||
182 | * RETURN: Status | ||
183 | * | ||
184 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | ||
185 | * exception on bad checksum. | ||
186 | * | ||
187 | ******************************************************************************/ | ||
188 | |||
189 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | ||
190 | { | ||
191 | u8 checksum; | ||
192 | |||
193 | /* Compute the checksum on the table */ | ||
194 | |||
195 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | ||
196 | |||
197 | /* Checksum ok? (should be zero) */ | ||
198 | |||
199 | if (checksum) { | ||
200 | ACPI_BIOS_WARNING((AE_INFO, | ||
201 | "Incorrect checksum in table [%4.4s] - 0x%2.2X, " | ||
202 | "should be 0x%2.2X", | ||
203 | table->signature, table->checksum, | ||
204 | (u8)(table->checksum - checksum))); | ||
205 | |||
206 | #if (ACPI_CHECKSUM_ABORT) | ||
207 | return (AE_BAD_CHECKSUM); | ||
208 | #endif | ||
209 | } | ||
210 | |||
211 | return (AE_OK); | ||
212 | } | ||
213 | |||
214 | /******************************************************************************* | ||
215 | * | ||
216 | * FUNCTION: acpi_tb_checksum | ||
217 | * | ||
218 | * PARAMETERS: buffer - Pointer to memory region to be checked | ||
219 | * length - Length of this memory region | ||
220 | * | ||
221 | * RETURN: Checksum (u8) | ||
222 | * | ||
223 | * DESCRIPTION: Calculates circular checksum of memory region. | ||
224 | * | ||
225 | ******************************************************************************/ | ||
226 | |||
227 | u8 acpi_tb_checksum(u8 *buffer, u32 length) | ||
228 | { | ||
229 | u8 sum = 0; | ||
230 | u8 *end = buffer + length; | ||
231 | |||
232 | while (buffer < end) { | ||
233 | sum = (u8)(sum + *(buffer++)); | ||
234 | } | ||
235 | |||
236 | return (sum); | ||
237 | } | ||
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index ce3d5db39a9c..bffdfc7b8322 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: tbutils - table utilities | 3 | * Module Name: tbutils - ACPI Table utilities |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -49,12 +49,6 @@ | |||
49 | ACPI_MODULE_NAME("tbutils") | 49 | ACPI_MODULE_NAME("tbutils") |
50 | 50 | ||
51 | /* Local prototypes */ | 51 | /* Local prototypes */ |
52 | static void acpi_tb_fix_string(char *string, acpi_size length); | ||
53 | |||
54 | static void | ||
55 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
56 | struct acpi_table_header *header); | ||
57 | |||
58 | static acpi_physical_address | 52 | static acpi_physical_address |
59 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); | 53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); |
60 | 54 | ||
@@ -176,189 +170,6 @@ u8 acpi_tb_tables_loaded(void) | |||
176 | 170 | ||
177 | /******************************************************************************* | 171 | /******************************************************************************* |
178 | * | 172 | * |
179 | * FUNCTION: acpi_tb_fix_string | ||
180 | * | ||
181 | * PARAMETERS: string - String to be repaired | ||
182 | * length - Maximum length | ||
183 | * | ||
184 | * RETURN: None | ||
185 | * | ||
186 | * DESCRIPTION: Replace every non-printable or non-ascii byte in the string | ||
187 | * with a question mark '?'. | ||
188 | * | ||
189 | ******************************************************************************/ | ||
190 | |||
191 | static void acpi_tb_fix_string(char *string, acpi_size length) | ||
192 | { | ||
193 | |||
194 | while (length && *string) { | ||
195 | if (!ACPI_IS_PRINT(*string)) { | ||
196 | *string = '?'; | ||
197 | } | ||
198 | string++; | ||
199 | length--; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | /******************************************************************************* | ||
204 | * | ||
205 | * FUNCTION: acpi_tb_cleanup_table_header | ||
206 | * | ||
207 | * PARAMETERS: out_header - Where the cleaned header is returned | ||
208 | * header - Input ACPI table header | ||
209 | * | ||
210 | * RETURN: Returns the cleaned header in out_header | ||
211 | * | ||
212 | * DESCRIPTION: Copy the table header and ensure that all "string" fields in | ||
213 | * the header consist of printable characters. | ||
214 | * | ||
215 | ******************************************************************************/ | ||
216 | |||
217 | static void | ||
218 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
219 | struct acpi_table_header *header) | ||
220 | { | ||
221 | |||
222 | ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header)); | ||
223 | |||
224 | acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE); | ||
225 | acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE); | ||
226 | acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | ||
227 | acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE); | ||
228 | } | ||
229 | |||
230 | /******************************************************************************* | ||
231 | * | ||
232 | * FUNCTION: acpi_tb_print_table_header | ||
233 | * | ||
234 | * PARAMETERS: address - Table physical address | ||
235 | * header - Table header | ||
236 | * | ||
237 | * RETURN: None | ||
238 | * | ||
239 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. | ||
240 | * | ||
241 | ******************************************************************************/ | ||
242 | |||
243 | void | ||
244 | acpi_tb_print_table_header(acpi_physical_address address, | ||
245 | struct acpi_table_header *header) | ||
246 | { | ||
247 | struct acpi_table_header local_header; | ||
248 | |||
249 | /* | ||
250 | * The reason that the Address is cast to a void pointer is so that we | ||
251 | * can use %p which will work properly on both 32-bit and 64-bit hosts. | ||
252 | */ | ||
253 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { | ||
254 | |||
255 | /* FACS only has signature and length fields */ | ||
256 | |||
257 | ACPI_INFO((AE_INFO, "%4.4s %p %05X", | ||
258 | header->signature, ACPI_CAST_PTR(void, address), | ||
259 | header->length)); | ||
260 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | ||
261 | |||
262 | /* RSDP has no common fields */ | ||
263 | |||
264 | ACPI_MEMCPY(local_header.oem_id, | ||
265 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
266 | header)->oem_id, ACPI_OEM_ID_SIZE); | ||
267 | acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE); | ||
268 | |||
269 | ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", | ||
270 | ACPI_CAST_PTR (void, address), | ||
271 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> | ||
272 | revision > | ||
273 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
274 | header)->length : 20, | ||
275 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
276 | header)->revision, | ||
277 | local_header.oem_id)); | ||
278 | } else { | ||
279 | /* Standard ACPI table with full common header */ | ||
280 | |||
281 | acpi_tb_cleanup_table_header(&local_header, header); | ||
282 | |||
283 | ACPI_INFO((AE_INFO, | ||
284 | "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", | ||
285 | local_header.signature, ACPI_CAST_PTR(void, address), | ||
286 | local_header.length, local_header.revision, | ||
287 | local_header.oem_id, local_header.oem_table_id, | ||
288 | local_header.oem_revision, | ||
289 | local_header.asl_compiler_id, | ||
290 | local_header.asl_compiler_revision)); | ||
291 | |||
292 | } | ||
293 | } | ||
294 | |||
295 | /******************************************************************************* | ||
296 | * | ||
297 | * FUNCTION: acpi_tb_validate_checksum | ||
298 | * | ||
299 | * PARAMETERS: table - ACPI table to verify | ||
300 | * length - Length of entire table | ||
301 | * | ||
302 | * RETURN: Status | ||
303 | * | ||
304 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | ||
305 | * exception on bad checksum. | ||
306 | * | ||
307 | ******************************************************************************/ | ||
308 | |||
309 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | ||
310 | { | ||
311 | u8 checksum; | ||
312 | |||
313 | /* Compute the checksum on the table */ | ||
314 | |||
315 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | ||
316 | |||
317 | /* Checksum ok? (should be zero) */ | ||
318 | |||
319 | if (checksum) { | ||
320 | ACPI_BIOS_WARNING((AE_INFO, | ||
321 | "Incorrect checksum in table [%4.4s] - 0x%2.2X, " | ||
322 | "should be 0x%2.2X", | ||
323 | table->signature, table->checksum, | ||
324 | (u8)(table->checksum - checksum))); | ||
325 | |||
326 | #if (ACPI_CHECKSUM_ABORT) | ||
327 | |||
328 | return (AE_BAD_CHECKSUM); | ||
329 | #endif | ||
330 | } | ||
331 | |||
332 | return (AE_OK); | ||
333 | } | ||
334 | |||
335 | /******************************************************************************* | ||
336 | * | ||
337 | * FUNCTION: acpi_tb_checksum | ||
338 | * | ||
339 | * PARAMETERS: buffer - Pointer to memory region to be checked | ||
340 | * length - Length of this memory region | ||
341 | * | ||
342 | * RETURN: Checksum (u8) | ||
343 | * | ||
344 | * DESCRIPTION: Calculates circular checksum of memory region. | ||
345 | * | ||
346 | ******************************************************************************/ | ||
347 | |||
348 | u8 acpi_tb_checksum(u8 *buffer, u32 length) | ||
349 | { | ||
350 | u8 sum = 0; | ||
351 | u8 *end = buffer + length; | ||
352 | |||
353 | while (buffer < end) { | ||
354 | sum = (u8) (sum + *(buffer++)); | ||
355 | } | ||
356 | |||
357 | return (sum); | ||
358 | } | ||
359 | |||
360 | /******************************************************************************* | ||
361 | * | ||
362 | * FUNCTION: acpi_tb_check_dsdt_header | 173 | * FUNCTION: acpi_tb_check_dsdt_header |
363 | * | 174 | * |
364 | * PARAMETERS: None | 175 | * PARAMETERS: None |