1 /******************************************************************************
3 * Module Name: tbprint - Table output utilities
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
50 #define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbprint")
54 /* Local prototypes */
62 AcpiTbCleanupTableHeader (
63 ACPI_TABLE_HEADER
*OutHeader
,
64 ACPI_TABLE_HEADER
*Header
);
67 /*******************************************************************************
69 * FUNCTION: AcpiTbFixString
71 * PARAMETERS: String - String to be repaired
72 * Length - Maximum length
76 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
77 * with a question mark '?'.
79 ******************************************************************************/
87 while (Length
&& *String
)
89 if (!ACPI_IS_PRINT (*String
))
99 /*******************************************************************************
101 * FUNCTION: AcpiTbCleanupTableHeader
103 * PARAMETERS: OutHeader - Where the cleaned header is returned
104 * Header - Input ACPI table header
106 * RETURN: Returns the cleaned header in OutHeader
108 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
109 * the header consist of printable characters.
111 ******************************************************************************/
114 AcpiTbCleanupTableHeader (
115 ACPI_TABLE_HEADER
*OutHeader
,
116 ACPI_TABLE_HEADER
*Header
)
119 ACPI_MEMCPY (OutHeader
, Header
, sizeof (ACPI_TABLE_HEADER
));
121 AcpiTbFixString (OutHeader
->Signature
, ACPI_NAME_SIZE
);
122 AcpiTbFixString (OutHeader
->OemId
, ACPI_OEM_ID_SIZE
);
123 AcpiTbFixString (OutHeader
->OemTableId
, ACPI_OEM_TABLE_ID_SIZE
);
124 AcpiTbFixString (OutHeader
->AslCompilerId
, ACPI_NAME_SIZE
);
128 /*******************************************************************************
130 * FUNCTION: AcpiTbPrintTableHeader
132 * PARAMETERS: Address - Table physical address
133 * Header - Table header
137 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
139 ******************************************************************************/
142 AcpiTbPrintTableHeader (
143 ACPI_PHYSICAL_ADDRESS Address
,
144 ACPI_TABLE_HEADER
*Header
)
146 ACPI_TABLE_HEADER LocalHeader
;
150 * The reason that the Address is cast to a void pointer is so that we
151 * can use %p which will work properly on both 32-bit and 64-bit hosts.
153 if (ACPI_COMPARE_NAME (Header
->Signature
, ACPI_SIG_FACS
))
155 /* FACS only has signature and length fields */
157 ACPI_INFO ((AE_INFO
, "%4.4s %p %06X",
158 Header
->Signature
, ACPI_CAST_PTR (void, Address
),
161 else if (ACPI_VALIDATE_RSDP_SIG (Header
->Signature
))
163 /* RSDP has no common fields */
165 ACPI_MEMCPY (LocalHeader
.OemId
,
166 ACPI_CAST_PTR (ACPI_TABLE_RSDP
, Header
)->OemId
, ACPI_OEM_ID_SIZE
);
167 AcpiTbFixString (LocalHeader
.OemId
, ACPI_OEM_ID_SIZE
);
169 ACPI_INFO ((AE_INFO
, "RSDP %p %06X (v%.2d %6.6s)",
170 ACPI_CAST_PTR (void, Address
),
171 (ACPI_CAST_PTR (ACPI_TABLE_RSDP
, Header
)->Revision
> 0) ?
172 ACPI_CAST_PTR (ACPI_TABLE_RSDP
, Header
)->Length
: 20,
173 ACPI_CAST_PTR (ACPI_TABLE_RSDP
, Header
)->Revision
,
178 /* Standard ACPI table with full common header */
180 AcpiTbCleanupTableHeader (&LocalHeader
, Header
);
183 "%4.4s %p %06X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
184 LocalHeader
.Signature
, ACPI_CAST_PTR (void, Address
),
185 LocalHeader
.Length
, LocalHeader
.Revision
, LocalHeader
.OemId
,
186 LocalHeader
.OemTableId
, LocalHeader
.OemRevision
,
187 LocalHeader
.AslCompilerId
, LocalHeader
.AslCompilerRevision
));
192 /*******************************************************************************
194 * FUNCTION: AcpiTbValidateChecksum
196 * PARAMETERS: Table - ACPI table to verify
197 * Length - Length of entire table
201 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
202 * exception on bad checksum.
204 ******************************************************************************/
207 AcpiTbVerifyChecksum (
208 ACPI_TABLE_HEADER
*Table
,
216 * They are the odd tables, have no standard ACPI header and no checksum
219 if (ACPI_COMPARE_NAME (Table
->Signature
, ACPI_SIG_S3PT
) ||
220 ACPI_COMPARE_NAME (Table
->Signature
, ACPI_SIG_FACS
))
225 /* Compute the checksum on the table */
227 Checksum
= AcpiTbChecksum (ACPI_CAST_PTR (UINT8
, Table
), Length
);
229 /* Checksum ok? (should be zero) */
233 ACPI_BIOS_WARNING ((AE_INFO
,
234 "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
236 Table
->Signature
, Table
->Checksum
,
237 (UINT8
) (Table
->Checksum
- Checksum
)));
239 #if (ACPI_CHECKSUM_ABORT)
240 return (AE_BAD_CHECKSUM
);
248 /*******************************************************************************
250 * FUNCTION: AcpiTbChecksum
252 * PARAMETERS: Buffer - Pointer to memory region to be checked
253 * Length - Length of this memory region
255 * RETURN: Checksum (UINT8)
257 * DESCRIPTION: Calculates circular checksum of memory region.
259 ******************************************************************************/
267 UINT8
*End
= Buffer
+ Length
;
272 Sum
= (UINT8
) (Sum
+ *(Buffer
++));