Skip to content

Commit 51aad1a

Browse files
acpibobrafaeljw
authored andcommitted
ACPICA: Finish support for the CDAT table
ACPICA commit 8ac4e5116f59d6f9ba2fbeb9ce22ab58237a278f Finish support for the CDAT table, in both the data table compiler and the disassembler. Link: acpica/acpica@8ac4e511 Signed-off-by: Bob Moore <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 3f062a5 commit 51aad1a

File tree

13 files changed

+311
-88
lines changed

13 files changed

+311
-88
lines changed

drivers/acpi/acpica/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ acpi-y += \
155155
utalloc.o \
156156
utascii.o \
157157
utbuffer.o \
158+
utcksum.o \
158159
utcopy.o \
159160
utexcep.o \
160161
utdebug.o \

drivers/acpi/acpica/acglobal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ ACPI_GLOBAL(struct acpi_table_list, acpi_gbl_root_table_list);
2424

2525
ACPI_GLOBAL(struct acpi_table_header *, acpi_gbl_DSDT);
2626
ACPI_GLOBAL(struct acpi_table_header, acpi_gbl_original_dsdt_header);
27+
ACPI_INIT_GLOBAL(char *, acpi_gbl_CDAT, NULL);
2728
ACPI_INIT_GLOBAL(u32, acpi_gbl_dsdt_index, ACPI_INVALID_TABLE_INDEX);
2829
ACPI_INIT_GLOBAL(u32, acpi_gbl_facs_index, ACPI_INVALID_TABLE_INDEX);
2930
ACPI_INIT_GLOBAL(u32, acpi_gbl_xfacs_index, ACPI_INVALID_TABLE_INDEX);

drivers/acpi/acpica/actables.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ void
124124
acpi_tb_print_table_header(acpi_physical_address address,
125125
struct acpi_table_header *header);
126126

127-
u8 acpi_tb_checksum(u8 *buffer, u32 length);
128-
129-
acpi_status
130-
acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
131-
132127
void acpi_tb_check_dsdt_header(void);
133128

134129
struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);

drivers/acpi/acpica/acutils.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ u8 acpi_ut_valid_name_char(char character, u32 position);
158158

159159
void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count);
160160

161+
/*
162+
* utcksum - Checksum utilities
163+
*/
164+
u8 acpi_ut_generate_checksum(void *table, u32 length, u8 original_checksum);
165+
166+
u8 acpi_ut_checksum(u8 *buffer, u32 length);
167+
168+
acpi_status
169+
acpi_ut_verify_cdat_checksum(struct acpi_table_cdat *cdat_table, u32 length);
170+
171+
acpi_status
172+
acpi_ut_verify_checksum(struct acpi_table_header *table, u32 length);
173+
161174
/*
162175
* utnonansi - Non-ANSI C library functions
163176
*/

drivers/acpi/acpica/tbdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc,
522522
/* Verify the checksum */
523523

524524
status =
525-
acpi_tb_verify_checksum(table_desc->pointer,
525+
acpi_ut_verify_checksum(table_desc->pointer,
526526
table_desc->length);
527527
if (ACPI_FAILURE(status)) {
528528
ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,

drivers/acpi/acpica/tbfadt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void acpi_tb_parse_fadt(void)
298298
* Validate the FADT checksum before we copy the table. Ignore
299299
* checksum error as we want to try to get the DSDT and FACS.
300300
*/
301-
(void)acpi_tb_verify_checksum(table, length);
301+
(void)acpi_ut_verify_checksum(table, length);
302302

303303
/* Create a local copy of the FADT in common ACPI 2.0+ format */
304304

drivers/acpi/acpica/tbprint.c

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <acpi/acpi.h>
1111
#include "accommon.h"
1212
#include "actables.h"
13+
#include "acutils.h"
1314

1415
#define _COMPONENT ACPI_TABLES
1516
ACPI_MODULE_NAME("tbprint")
@@ -39,7 +40,7 @@ static void acpi_tb_fix_string(char *string, acpi_size length)
3940
{
4041

4142
while (length && *string) {
42-
if (!isprint((int)*string)) {
43+
if (!isprint((int)(u8)*string)) {
4344
*string = '?';
4445
}
4546

@@ -135,77 +136,3 @@ acpi_tb_print_table_header(acpi_physical_address address,
135136
local_header.asl_compiler_revision));
136137
}
137138
}
138-
139-
/*******************************************************************************
140-
*
141-
* FUNCTION: acpi_tb_validate_checksum
142-
*
143-
* PARAMETERS: table - ACPI table to verify
144-
* length - Length of entire table
145-
*
146-
* RETURN: Status
147-
*
148-
* DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
149-
* exception on bad checksum.
150-
*
151-
******************************************************************************/
152-
153-
acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
154-
{
155-
u8 checksum;
156-
157-
/*
158-
* FACS/S3PT:
159-
* They are the odd tables, have no standard ACPI header and no checksum
160-
*/
161-
162-
if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_S3PT) ||
163-
ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
164-
return (AE_OK);
165-
}
166-
167-
/* Compute the checksum on the table */
168-
169-
checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
170-
171-
/* Checksum ok? (should be zero) */
172-
173-
if (checksum) {
174-
ACPI_BIOS_WARNING((AE_INFO,
175-
"Incorrect checksum in table [%4.4s] - 0x%2.2X, "
176-
"should be 0x%2.2X",
177-
table->signature, table->checksum,
178-
(u8)(table->checksum - checksum)));
179-
180-
#if (ACPI_CHECKSUM_ABORT)
181-
return (AE_BAD_CHECKSUM);
182-
#endif
183-
}
184-
185-
return (AE_OK);
186-
}
187-
188-
/*******************************************************************************
189-
*
190-
* FUNCTION: acpi_tb_checksum
191-
*
192-
* PARAMETERS: buffer - Pointer to memory region to be checked
193-
* length - Length of this memory region
194-
*
195-
* RETURN: Checksum (u8)
196-
*
197-
* DESCRIPTION: Calculates circular checksum of memory region.
198-
*
199-
******************************************************************************/
200-
201-
u8 acpi_tb_checksum(u8 *buffer, u32 length)
202-
{
203-
u8 sum = 0;
204-
u8 *end = buffer + length;
205-
206-
while (buffer < end) {
207-
sum = (u8)(sum + *(buffer++));
208-
}
209-
210-
return (sum);
211-
}

drivers/acpi/acpica/tbutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
299299

300300
/* Validate the root table checksum */
301301

302-
status = acpi_tb_verify_checksum(table, length);
302+
status = acpi_ut_verify_checksum(table, length);
303303
if (ACPI_FAILURE(status)) {
304304
acpi_os_unmap_memory(table, length);
305305
return_ACPI_STATUS(status);

drivers/acpi/acpica/tbxfroot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
7474

7575
/* Check the standard checksum */
7676

77-
if (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
77+
if (acpi_ut_checksum((u8 *)rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
7878
return (AE_BAD_CHECKSUM);
7979
}
8080

8181
/* Check extended checksum if table version >= 2 */
8282

8383
if ((rsdp->revision >= 2) &&
84-
(acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
84+
(acpi_ut_checksum((u8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
8585
return (AE_BAD_CHECKSUM);
8686
}
8787

drivers/acpi/acpica/utcksum.c

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2+
/******************************************************************************
3+
*
4+
* Module Name: utcksum - Support generating table checksums
5+
*
6+
* Copyright (C) 2000 - 2022, Intel Corp.
7+
*
8+
*****************************************************************************/
9+
10+
#include <acpi/acpi.h>
11+
#include "accommon.h"
12+
#include "acutils.h"
13+
14+
/* This module used for application-level code only */
15+
16+
#define _COMPONENT ACPI_CA_DISASSEMBLER
17+
ACPI_MODULE_NAME("utcksum")
18+
19+
/*******************************************************************************
20+
*
21+
* FUNCTION: acpi_ut_verify_checksum
22+
*
23+
* PARAMETERS: table - ACPI table to verify
24+
* length - Length of entire table
25+
*
26+
* RETURN: Status
27+
*
28+
* DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
29+
* exception on bad checksum.
30+
* Note: We don't have to check for a CDAT here, since CDAT is
31+
* not in the RSDT/XSDT, and the CDAT table is never installed
32+
* via ACPICA.
33+
*
34+
******************************************************************************/
35+
acpi_status acpi_ut_verify_checksum(struct acpi_table_header *table, u32 length)
36+
{
37+
u8 checksum;
38+
39+
/*
40+
* FACS/S3PT:
41+
* They are the odd tables, have no standard ACPI header and no checksum
42+
*/
43+
if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_S3PT) ||
44+
ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
45+
return (AE_OK);
46+
}
47+
48+
/* Compute the checksum on the table */
49+
50+
length = table->length;
51+
checksum =
52+
acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, table), length,
53+
table->checksum);
54+
55+
/* Computed checksum matches table? */
56+
57+
if (checksum != table->checksum) {
58+
ACPI_BIOS_WARNING((AE_INFO,
59+
"Incorrect checksum in table [%4.4s] - 0x%2.2X, "
60+
"should be 0x%2.2X",
61+
table->signature, table->checksum,
62+
table->checksum - checksum));
63+
64+
#if (ACPI_CHECKSUM_ABORT)
65+
return (AE_BAD_CHECKSUM);
66+
#endif
67+
}
68+
69+
return (AE_OK);
70+
}
71+
72+
/*******************************************************************************
73+
*
74+
* FUNCTION: acpi_ut_verify_cdat_checksum
75+
*
76+
* PARAMETERS: table - CDAT ACPI table to verify
77+
* length - Length of entire table
78+
*
79+
* RETURN: Status
80+
*
81+
* DESCRIPTION: Verifies that the CDAT table checksums to zero. Optionally
82+
* returns an exception on bad checksum.
83+
*
84+
******************************************************************************/
85+
86+
acpi_status
87+
acpi_ut_verify_cdat_checksum(struct acpi_table_cdat *cdat_table, u32 length)
88+
{
89+
u8 checksum;
90+
91+
/* Compute the checksum on the table */
92+
93+
checksum = acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, cdat_table),
94+
cdat_table->length,
95+
cdat_table->checksum);
96+
97+
/* Computed checksum matches table? */
98+
99+
if (checksum != cdat_table->checksum) {
100+
ACPI_BIOS_WARNING((AE_INFO,
101+
"Incorrect checksum in table [%4.4s] - 0x%2.2X, "
102+
"should be 0x%2.2X",
103+
acpi_gbl_CDAT, cdat_table->checksum,
104+
checksum));
105+
106+
#if (ACPI_CHECKSUM_ABORT)
107+
return (AE_BAD_CHECKSUM);
108+
#endif
109+
}
110+
111+
cdat_table->checksum = checksum;
112+
return (AE_OK);
113+
}
114+
115+
/*******************************************************************************
116+
*
117+
* FUNCTION: acpi_ut_generate_checksum
118+
*
119+
* PARAMETERS: table - Pointer to table to be checksummed
120+
* length - Length of the table
121+
* original_checksum - Value of the checksum field
122+
*
123+
* RETURN: 8 bit checksum of buffer
124+
*
125+
* DESCRIPTION: Computes an 8 bit checksum of the table.
126+
*
127+
******************************************************************************/
128+
129+
u8 acpi_ut_generate_checksum(void *table, u32 length, u8 original_checksum)
130+
{
131+
u8 checksum;
132+
133+
/* Sum the entire table as-is */
134+
135+
checksum = acpi_ut_checksum((u8 *)table, length);
136+
137+
/* Subtract off the existing checksum value in the table */
138+
139+
checksum = (u8)(checksum - original_checksum);
140+
141+
/* Compute and return the final checksum */
142+
143+
checksum = (u8)(0 - checksum);
144+
return (checksum);
145+
}
146+
147+
/*******************************************************************************
148+
*
149+
* FUNCTION: acpi_ut_checksum
150+
*
151+
* PARAMETERS: buffer - Pointer to memory region to be checked
152+
* length - Length of this memory region
153+
*
154+
* RETURN: Checksum (u8)
155+
*
156+
* DESCRIPTION: Calculates circular checksum of memory region.
157+
*
158+
******************************************************************************/
159+
160+
u8 acpi_ut_checksum(u8 *buffer, u32 length)
161+
{
162+
u8 sum = 0;
163+
u8 *end = buffer + length;
164+
165+
while (buffer < end) {
166+
sum = (u8)(sum + *(buffer++));
167+
}
168+
169+
return (sum);
170+
}

0 commit comments

Comments
 (0)