mm/hmm.c: remove superfluous RCU protection around radix tree lookup
[linux/fpc-iii.git] / drivers / acpi / acpica / tbprint.c
blobe303418a895b2b37872fc441a8e11c6c44ac88cb
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: tbprint - Table output utilities
6 * Copyright (C) 2000 - 2018, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "actables.h"
14 #define _COMPONENT ACPI_TABLES
15 ACPI_MODULE_NAME("tbprint")
17 /* Local prototypes */
18 static void acpi_tb_fix_string(char *string, acpi_size length);
20 static void
21 acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
22 struct acpi_table_header *header);
24 /*******************************************************************************
26 * FUNCTION: acpi_tb_fix_string
28 * PARAMETERS: string - String to be repaired
29 * length - Maximum length
31 * RETURN: None
33 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
34 * with a question mark '?'.
36 ******************************************************************************/
38 static void acpi_tb_fix_string(char *string, acpi_size length)
41 while (length && *string) {
42 if (!isprint((int)*string)) {
43 *string = '?';
46 string++;
47 length--;
51 /*******************************************************************************
53 * FUNCTION: acpi_tb_cleanup_table_header
55 * PARAMETERS: out_header - Where the cleaned header is returned
56 * header - Input ACPI table header
58 * RETURN: Returns the cleaned header in out_header
60 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
61 * the header consist of printable characters.
63 ******************************************************************************/
65 static void
66 acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
67 struct acpi_table_header *header)
70 memcpy(out_header, header, sizeof(struct acpi_table_header));
72 acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE);
73 acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
74 acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
75 acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE);
78 /*******************************************************************************
80 * FUNCTION: acpi_tb_print_table_header
82 * PARAMETERS: address - Table physical address
83 * header - Table header
85 * RETURN: None
87 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
89 ******************************************************************************/
91 void
92 acpi_tb_print_table_header(acpi_physical_address address,
93 struct acpi_table_header *header)
95 struct acpi_table_header local_header;
97 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
99 /* FACS only has signature and length fields */
101 ACPI_INFO(("%-4.4s 0x%8.8X%8.8X %06X",
102 header->signature, ACPI_FORMAT_UINT64(address),
103 header->length));
104 } else if (ACPI_VALIDATE_RSDP_SIG(header->signature)) {
106 /* RSDP has no common fields */
108 memcpy(local_header.oem_id,
109 ACPI_CAST_PTR(struct acpi_table_rsdp, header)->oem_id,
110 ACPI_OEM_ID_SIZE);
111 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
113 ACPI_INFO(("RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)",
114 ACPI_FORMAT_UINT64(address),
115 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
116 revision >
117 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
118 header)->length : 20,
119 ACPI_CAST_PTR(struct acpi_table_rsdp,
120 header)->revision,
121 local_header.oem_id));
122 } else {
123 /* Standard ACPI table with full common header */
125 acpi_tb_cleanup_table_header(&local_header, header);
127 ACPI_INFO(("%-4.4s 0x%8.8X%8.8X"
128 " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
129 local_header.signature, ACPI_FORMAT_UINT64(address),
130 local_header.length, local_header.revision,
131 local_header.oem_id, local_header.oem_table_id,
132 local_header.oem_revision,
133 local_header.asl_compiler_id,
134 local_header.asl_compiler_revision));
138 /*******************************************************************************
140 * FUNCTION: acpi_tb_validate_checksum
142 * PARAMETERS: table - ACPI table to verify
143 * length - Length of entire table
145 * RETURN: Status
147 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
148 * exception on bad checksum.
150 ******************************************************************************/
152 acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
154 u8 checksum;
157 * FACS/S3PT:
158 * They are the odd tables, have no standard ACPI header and no checksum
161 if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_S3PT) ||
162 ACPI_COMPARE_NAME(table->signature, ACPI_SIG_FACS)) {
163 return (AE_OK);
166 /* Compute the checksum on the table */
168 checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
170 /* Checksum ok? (should be zero) */
172 if (checksum) {
173 ACPI_BIOS_WARNING((AE_INFO,
174 "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
175 "should be 0x%2.2X",
176 table->signature, table->checksum,
177 (u8)(table->checksum - checksum)));
179 #if (ACPI_CHECKSUM_ABORT)
180 return (AE_BAD_CHECKSUM);
181 #endif
184 return (AE_OK);
187 /*******************************************************************************
189 * FUNCTION: acpi_tb_checksum
191 * PARAMETERS: buffer - Pointer to memory region to be checked
192 * length - Length of this memory region
194 * RETURN: Checksum (u8)
196 * DESCRIPTION: Calculates circular checksum of memory region.
198 ******************************************************************************/
200 u8 acpi_tb_checksum(u8 *buffer, u32 length)
202 u8 sum = 0;
203 u8 *end = buffer + length;
205 while (buffer < end) {
206 sum = (u8)(sum + *(buffer++));
209 return (sum);