PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / acpi / acpica / tbprint.c
blob6866e767ba90947359ca432bcba8643a92c0069d
1 /******************************************************************************
3 * Module Name: tbprint - Table output utilities
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "actables.h"
48 #define _COMPONENT ACPI_TABLES
49 ACPI_MODULE_NAME("tbprint")
51 /* Local prototypes */
52 static void acpi_tb_fix_string(char *string, acpi_size length);
54 static void
55 acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
56 struct acpi_table_header *header);
58 /*******************************************************************************
60 * FUNCTION: acpi_tb_fix_string
62 * PARAMETERS: string - String to be repaired
63 * length - Maximum length
65 * RETURN: None
67 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
68 * with a question mark '?'.
70 ******************************************************************************/
72 static void acpi_tb_fix_string(char *string, acpi_size length)
75 while (length && *string) {
76 if (!ACPI_IS_PRINT(*string)) {
77 *string = '?';
79 string++;
80 length--;
84 /*******************************************************************************
86 * FUNCTION: acpi_tb_cleanup_table_header
88 * PARAMETERS: out_header - Where the cleaned header is returned
89 * header - Input ACPI table header
91 * RETURN: Returns the cleaned header in out_header
93 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
94 * the header consist of printable characters.
96 ******************************************************************************/
98 static void
99 acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
100 struct acpi_table_header *header)
103 ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header));
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);
111 /*******************************************************************************
113 * FUNCTION: acpi_tb_print_table_header
115 * PARAMETERS: address - Table physical address
116 * header - Table header
118 * RETURN: None
120 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
122 ******************************************************************************/
124 void
125 acpi_tb_print_table_header(acpi_physical_address address,
126 struct acpi_table_header *header)
128 struct acpi_table_header local_header;
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.
134 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
136 /* FACS only has signature and length fields */
138 ACPI_INFO((AE_INFO, "%4.4s %p %06X",
139 header->signature, ACPI_CAST_PTR(void, address),
140 header->length));
141 } else if (ACPI_VALIDATE_RSDP_SIG(header->signature)) {
143 /* RSDP has no common fields */
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);
150 ACPI_INFO((AE_INFO, "RSDP %p %06X (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 */
162 acpi_tb_cleanup_table_header(&local_header, header);
164 ACPI_INFO((AE_INFO,
165 "%4.4s %p %06X (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));
175 /*******************************************************************************
177 * FUNCTION: acpi_tb_validate_checksum
179 * PARAMETERS: table - ACPI table to verify
180 * length - Length of entire table
182 * RETURN: Status
184 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
185 * exception on bad checksum.
187 ******************************************************************************/
189 acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
191 u8 checksum;
194 * FACS/S3PT:
195 * They are the odd tables, have no standard ACPI header and no checksum
198 if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_S3PT) ||
199 ACPI_COMPARE_NAME(table->signature, ACPI_SIG_FACS)) {
200 return (AE_OK);
203 /* Compute the checksum on the table */
205 checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
207 /* Checksum ok? (should be zero) */
209 if (checksum) {
210 ACPI_BIOS_WARNING((AE_INFO,
211 "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
212 "should be 0x%2.2X",
213 table->signature, table->checksum,
214 (u8)(table->checksum - checksum)));
216 #if (ACPI_CHECKSUM_ABORT)
217 return (AE_BAD_CHECKSUM);
218 #endif
221 return (AE_OK);
224 /*******************************************************************************
226 * FUNCTION: acpi_tb_checksum
228 * PARAMETERS: buffer - Pointer to memory region to be checked
229 * length - Length of this memory region
231 * RETURN: Checksum (u8)
233 * DESCRIPTION: Calculates circular checksum of memory region.
235 ******************************************************************************/
237 u8 acpi_tb_checksum(u8 *buffer, u32 length)
239 u8 sum = 0;
240 u8 *end = buffer + length;
242 while (buffer < end) {
243 sum = (u8)(sum + *(buffer++));
246 return (sum);