aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables')
-rw-r--r--drivers/acpi/tables/tbconvrt.c31
-rw-r--r--drivers/acpi/tables/tbrsdt.c3
-rw-r--r--drivers/acpi/tables/tbutils.c122
-rw-r--r--drivers/acpi/tables/tbxfroot.c9
4 files changed, 105 insertions, 60 deletions
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 5155b27cf032..a913a927d321 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -54,12 +54,12 @@ acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
54 acpi_physical_address address); 54 acpi_physical_address address);
55 55
56static void 56static void
57acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, 57acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
58 struct fadt_descriptor_rev1 *original_fadt); 58 struct fadt_descriptor_rev1 *original_fadt);
59 59
60static void 60static void
61acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, 61acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
62 struct fadt_descriptor_rev2 *original_fadt); 62 struct fadt_descriptor *original_fadt);
63 63
64u8 acpi_fadt_is_v1; 64u8 acpi_fadt_is_v1;
65ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1) 65ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1)
@@ -120,7 +120,7 @@ acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
120{ 120{
121 acpi_size table_size; 121 acpi_size table_size;
122 u32 i; 122 u32 i;
123 XSDT_DESCRIPTOR *new_table; 123 struct xsdt_descriptor *new_table;
124 124
125 ACPI_FUNCTION_ENTRY(); 125 ACPI_FUNCTION_ENTRY();
126 126
@@ -151,12 +151,12 @@ acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
151 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 151 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
152 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i], 152 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
153 (ACPI_CAST_PTR 153 (ACPI_CAST_PTR
154 (struct rsdt_descriptor_rev1, 154 (struct rsdt_descriptor,
155 table_info->pointer))-> 155 table_info->pointer))->
156 table_offset_entry[i]); 156 table_offset_entry[i]);
157 } else { 157 } else {
158 new_table->table_offset_entry[i] = 158 new_table->table_offset_entry[i] =
159 (ACPI_CAST_PTR(XSDT_DESCRIPTOR, 159 (ACPI_CAST_PTR(struct xsdt_descriptor,
160 table_info->pointer))-> 160 table_info->pointer))->
161 table_offset_entry[i]; 161 table_offset_entry[i];
162 } 162 }
@@ -218,7 +218,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
218 ******************************************************************************/ 218 ******************************************************************************/
219 219
220static void 220static void
221acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, 221acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
222 struct fadt_descriptor_rev1 *original_fadt) 222 struct fadt_descriptor_rev1 *original_fadt)
223{ 223{
224 224
@@ -364,14 +364,13 @@ acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
364 ******************************************************************************/ 364 ******************************************************************************/
365 365
366static void 366static void
367acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, 367acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
368 struct fadt_descriptor_rev2 *original_fadt) 368 struct fadt_descriptor *original_fadt)
369{ 369{
370 370
371 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ 371 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
372 372
373 ACPI_MEMCPY(local_fadt, original_fadt, 373 ACPI_MEMCPY(local_fadt, original_fadt, sizeof(struct fadt_descriptor));
374 sizeof(struct fadt_descriptor_rev2));
375 374
376 /* 375 /*
377 * "X" fields are optional extensions to the original V1.0 fields, so 376 * "X" fields are optional extensions to the original V1.0 fields, so
@@ -490,7 +489,7 @@ acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
490 489
491acpi_status acpi_tb_convert_table_fadt(void) 490acpi_status acpi_tb_convert_table_fadt(void)
492{ 491{
493 struct fadt_descriptor_rev2 *local_fadt; 492 struct fadt_descriptor *local_fadt;
494 struct acpi_table_desc *table_desc; 493 struct acpi_table_desc *table_desc;
495 494
496 ACPI_FUNCTION_TRACE("tb_convert_table_fadt"); 495 ACPI_FUNCTION_TRACE("tb_convert_table_fadt");
@@ -507,13 +506,13 @@ acpi_status acpi_tb_convert_table_fadt(void)
507 506
508 /* Allocate buffer for the ACPI 2.0(+) FADT */ 507 /* Allocate buffer for the ACPI 2.0(+) FADT */
509 508
510 local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor_rev2)); 509 local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor));
511 if (!local_fadt) { 510 if (!local_fadt) {
512 return_ACPI_STATUS(AE_NO_MEMORY); 511 return_ACPI_STATUS(AE_NO_MEMORY);
513 } 512 }
514 513
515 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { 514 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
516 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { 515 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor)) {
517 516
518 /* Length is too short to be a V2.0 table */ 517 /* Length is too short to be a V2.0 table */
519 518
@@ -538,7 +537,7 @@ acpi_status acpi_tb_convert_table_fadt(void)
538 /* Global FADT pointer will point to the new common V2.0 FADT */ 537 /* Global FADT pointer will point to the new common V2.0 FADT */
539 538
540 acpi_gbl_FADT = local_fadt; 539 acpi_gbl_FADT = local_fadt;
541 acpi_gbl_FADT->length = sizeof(FADT_DESCRIPTOR); 540 acpi_gbl_FADT->length = sizeof(struct fadt_descriptor);
542 541
543 /* Free the original table */ 542 /* Free the original table */
544 543
@@ -550,7 +549,7 @@ acpi_status acpi_tb_convert_table_fadt(void)
550 table_desc->pointer = 549 table_desc->pointer =
551 ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT); 550 ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
552 table_desc->allocation = ACPI_MEM_ALLOCATED; 551 table_desc->allocation = ACPI_MEM_ALLOCATED;
553 table_desc->length = sizeof(struct fadt_descriptor_rev2); 552 table_desc->length = sizeof(struct fadt_descriptor);
554 553
555 /* Dump the entire FADT */ 554 /* Dump the entire FADT */
556 555
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 946d2f2d611d..9e0ebe625ed9 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -280,7 +280,8 @@ acpi_status acpi_tb_get_table_rsdt(void)
280 return_ACPI_STATUS(status); 280 return_ACPI_STATUS(status);
281 } 281 }
282 282
283 acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer); 283 acpi_gbl_XSDT =
284 ACPI_CAST_PTR(struct xsdt_descriptor, table_info.pointer);
284 285
285 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); 286 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
286 return_ACPI_STATUS(status); 287 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index b463d4b88823..f8d28ae8811d 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -193,73 +193,119 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
193 193
194/******************************************************************************* 194/*******************************************************************************
195 * 195 *
196 * FUNCTION: acpi_tb_verify_table_checksum 196 * FUNCTION: acpi_tb_sum_table
197 * 197 *
198 * PARAMETERS: *table_header - ACPI table to verify 198 * PARAMETERS: Buffer - Buffer to sum
199 * Length - Size of the buffer
199 * 200 *
200 * RETURN: 8 bit checksum of table 201 * RETURN: 8 bit sum of buffer
201 * 202 *
202 * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct 203 * DESCRIPTION: Computes an 8 bit sum of the buffer(length) and returns it.
203 * table should have a checksum of 0.
204 * 204 *
205 ******************************************************************************/ 205 ******************************************************************************/
206 206
207acpi_status 207u8 acpi_tb_sum_table(void *buffer, u32 length)
208acpi_tb_verify_table_checksum(struct acpi_table_header * table_header) 208{
209 acpi_native_uint i;
210 u8 sum = 0;
211
212 if (!buffer || !length) {
213 return (0);
214 }
215
216 for (i = 0; i < length; i++) {
217 sum = (u8) (sum + ((u8 *) buffer)[i]);
218 }
219 return (sum);
220}
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_tb_generate_checksum
225 *
226 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
227 * standard ACPI header)
228 *
229 * RETURN: 8 bit checksum of buffer
230 *
231 * DESCRIPTION: Computes an 8 bit checksum of the table.
232 *
233 ******************************************************************************/
234
235u8 acpi_tb_generate_checksum(struct acpi_table_header * table)
209{ 236{
210 u8 checksum; 237 u8 checksum;
211 acpi_status status = AE_OK;
212 238
213 ACPI_FUNCTION_TRACE("tb_verify_table_checksum"); 239 /* Sum the entire table as-is */
214 240
215 /* Compute the checksum on the table */ 241 checksum = acpi_tb_sum_table(table, table->length);
216 242
217 checksum = 243 /* Subtract off the existing checksum value in the table */
218 acpi_tb_generate_checksum(table_header, table_header->length);
219 244
220 /* Return the appropriate exception */ 245 checksum = (u8) (checksum - table->checksum);
221 246
222 if (checksum) { 247 /* Compute the final checksum */
223 ACPI_WARNING((AE_INFO,
224 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)",
225 table_header->signature,
226 (u32) table_header->checksum, (u32) checksum));
227 248
228 status = AE_BAD_CHECKSUM; 249 checksum = (u8) (0 - checksum);
229 } 250 return (checksum);
230 return_ACPI_STATUS(status);
231} 251}
232 252
233/******************************************************************************* 253/*******************************************************************************
234 * 254 *
235 * FUNCTION: acpi_tb_generate_checksum 255 * FUNCTION: acpi_tb_set_checksum
236 * 256 *
237 * PARAMETERS: Buffer - Buffer to checksum 257 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
238 * Length - Size of the buffer 258 * standard ACPI header)
239 * 259 *
240 * RETURN: 8 bit checksum of buffer 260 * RETURN: None. Sets the table checksum field
241 * 261 *
242 * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. 262 * DESCRIPTION: Computes an 8 bit checksum of the table and inserts the
263 * checksum into the table header.
243 * 264 *
244 ******************************************************************************/ 265 ******************************************************************************/
245 266
246u8 acpi_tb_generate_checksum(void *buffer, u32 length) 267void acpi_tb_set_checksum(struct acpi_table_header *table)
247{ 268{
248 u8 *end_buffer;
249 u8 *rover;
250 u8 sum = 0;
251 269
252 if (buffer && length) { 270 table->checksum = acpi_tb_generate_checksum(table);
271}
272
273/*******************************************************************************
274 *
275 * FUNCTION: acpi_tb_verify_table_checksum
276 *
277 * PARAMETERS: *table_header - ACPI table to verify
278 *
279 * RETURN: 8 bit checksum of table
280 *
281 * DESCRIPTION: Generates an 8 bit checksum of table and returns and compares
282 * it to the existing checksum value.
283 *
284 ******************************************************************************/
285
286acpi_status
287acpi_tb_verify_table_checksum(struct acpi_table_header *table_header)
288{
289 u8 checksum;
290
291 ACPI_FUNCTION_TRACE("tb_verify_table_checksum");
292
293 /* Compute the checksum on the table */
253 294
254 /* Buffer and Length are valid */ 295 checksum = acpi_tb_generate_checksum(table_header);
255 296
256 end_buffer = ACPI_ADD_PTR(u8, buffer, length); 297 /* Checksum ok? */
257 298
258 for (rover = buffer; rover < end_buffer; rover++) { 299 if (checksum == table_header->checksum) {
259 sum = (u8) (sum + *rover); 300 return_ACPI_STATUS(AE_OK);
260 }
261 } 301 }
262 return (sum); 302
303 ACPI_WARNING((AE_INFO,
304 "Incorrect checksum in table [%4.4s] - is %2.2X, should be %2.2X",
305 table_header->signature, table_header->checksum,
306 checksum));
307
308 return_ACPI_STATUS(AE_BAD_CHECKSUM);
263} 309}
264 310
265#ifdef ACPI_OBSOLETE_FUNCTIONS 311#ifdef ACPI_OBSOLETE_FUNCTIONS
@@ -278,7 +324,7 @@ u8 acpi_tb_generate_checksum(void *buffer, u32 length)
278 324
279acpi_status 325acpi_status
280acpi_tb_handle_to_object(u16 table_id, 326acpi_tb_handle_to_object(u16 table_id,
281 struct acpi_table_desc ** return_table_desc) 327 struct acpi_table_desc **return_table_desc)
282{ 328{
283 u32 i; 329 u32 i;
284 struct acpi_table_desc *table_desc; 330 struct acpi_table_desc *table_desc;
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 1b6d8c510e95..550284f5d1ed 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -81,15 +81,14 @@ acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
81 81
82 /* Check the standard checksum */ 82 /* Check the standard checksum */
83 83
84 if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { 84 if (acpi_tb_sum_table(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
85 return (AE_BAD_CHECKSUM); 85 return (AE_BAD_CHECKSUM);
86 } 86 }
87 87
88 /* Check extended checksum if table version >= 2 */ 88 /* Check extended checksum if table version >= 2 */
89 89
90 if ((rsdp->revision >= 2) && 90 if ((rsdp->revision >= 2) &&
91 (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 91 (acpi_tb_sum_table(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
92 0)) {
93 return (AE_BAD_CHECKSUM); 92 return (AE_BAD_CHECKSUM);
94 } 93 }
95 94
@@ -308,12 +307,12 @@ acpi_get_firmware_table(acpi_string signature,
308 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 307 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
309 address.pointer.value = 308 address.pointer.value =
310 (ACPI_CAST_PTR 309 (ACPI_CAST_PTR
311 (RSDT_DESCRIPTOR, 310 (struct rsdt_descriptor,
312 rsdt_info->pointer))->table_offset_entry[i]; 311 rsdt_info->pointer))->table_offset_entry[i];
313 } else { 312 } else {
314 address.pointer.value = 313 address.pointer.value =
315 (ACPI_CAST_PTR 314 (ACPI_CAST_PTR
316 (XSDT_DESCRIPTOR, 315 (struct xsdt_descriptor,
317 rsdt_info->pointer))->table_offset_entry[i]; 316 rsdt_info->pointer))->table_offset_entry[i];
318 } 317 }
319 318