aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables')
-rw-r--r--drivers/acpi/tables/tbconvrt.c46
-rw-r--r--drivers/acpi/tables/tbget.c65
-rw-r--r--drivers/acpi/tables/tbgetall.c11
-rw-r--r--drivers/acpi/tables/tbinstal.c50
-rw-r--r--drivers/acpi/tables/tbrsdt.c46
-rw-r--r--drivers/acpi/tables/tbutils.c149
-rw-r--r--drivers/acpi/tables/tbxface.c42
-rw-r--r--drivers/acpi/tables/tbxfroot.c82
8 files changed, 265 insertions, 226 deletions
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 03b37d2223bc..d697fcb35d52 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -41,8 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/module.h>
45
46#include <acpi/acpi.h> 44#include <acpi/acpi.h>
47#include <acpi/actables.h> 45#include <acpi/actables.h>
48 46
@@ -56,15 +54,15 @@ acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
56 acpi_physical_address address); 54 acpi_physical_address address);
57 55
58static void 56static void
59acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, 57acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
60 struct fadt_descriptor_rev1 *original_fadt); 58 struct fadt_descriptor_rev1 *original_fadt);
61 59
62static void 60static void
63acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, 61acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
64 struct fadt_descriptor_rev2 *original_fadt); 62 struct fadt_descriptor *original_fadt);
65 63
66u8 acpi_fadt_is_v1; 64u8 acpi_fadt_is_v1;
67EXPORT_SYMBOL(acpi_fadt_is_v1); 65ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1)
68 66
69/******************************************************************************* 67/*******************************************************************************
70 * 68 *
@@ -122,7 +120,7 @@ acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
122{ 120{
123 acpi_size table_size; 121 acpi_size table_size;
124 u32 i; 122 u32 i;
125 XSDT_DESCRIPTOR *new_table; 123 struct xsdt_descriptor *new_table;
126 124
127 ACPI_FUNCTION_ENTRY(); 125 ACPI_FUNCTION_ENTRY();
128 126
@@ -133,7 +131,7 @@ acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
133 131
134 /* Allocate an XSDT */ 132 /* Allocate an XSDT */
135 133
136 new_table = ACPI_MEM_CALLOCATE(table_size); 134 new_table = ACPI_ALLOCATE_ZEROED(table_size);
137 if (!new_table) { 135 if (!new_table) {
138 return (AE_NO_MEMORY); 136 return (AE_NO_MEMORY);
139 } 137 }
@@ -147,17 +145,18 @@ acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
147 /* Copy the table pointers */ 145 /* Copy the table pointers */
148 146
149 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 147 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
148
150 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ 149 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
151 150
152 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 151 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
153 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i], 152 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
154 (ACPI_CAST_PTR 153 (ACPI_CAST_PTR
155 (struct rsdt_descriptor_rev1, 154 (struct rsdt_descriptor,
156 table_info->pointer))-> 155 table_info->pointer))->
157 table_offset_entry[i]); 156 table_offset_entry[i]);
158 } else { 157 } else {
159 new_table->table_offset_entry[i] = 158 new_table->table_offset_entry[i] =
160 (ACPI_CAST_PTR(XSDT_DESCRIPTOR, 159 (ACPI_CAST_PTR(struct xsdt_descriptor,
161 table_info->pointer))-> 160 table_info->pointer))->
162 table_offset_entry[i]; 161 table_offset_entry[i];
163 } 162 }
@@ -219,7 +218,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
219 ******************************************************************************/ 218 ******************************************************************************/
220 219
221static void 220static void
222acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt, 221acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
223 struct fadt_descriptor_rev1 *original_fadt) 222 struct fadt_descriptor_rev1 *original_fadt)
224{ 223{
225 224
@@ -365,14 +364,13 @@ acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
365 ******************************************************************************/ 364 ******************************************************************************/
366 365
367static void 366static void
368acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt, 367acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
369 struct fadt_descriptor_rev2 *original_fadt) 368 struct fadt_descriptor *original_fadt)
370{ 369{
371 370
372 /* 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 */
373 372
374 ACPI_MEMCPY(local_fadt, original_fadt, 373 ACPI_MEMCPY(local_fadt, original_fadt, sizeof(struct fadt_descriptor));
375 sizeof(struct fadt_descriptor_rev2));
376 374
377 /* 375 /*
378 * "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
@@ -491,10 +489,10 @@ acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
491 489
492acpi_status acpi_tb_convert_table_fadt(void) 490acpi_status acpi_tb_convert_table_fadt(void)
493{ 491{
494 struct fadt_descriptor_rev2 *local_fadt; 492 struct fadt_descriptor *local_fadt;
495 struct acpi_table_desc *table_desc; 493 struct acpi_table_desc *table_desc;
496 494
497 ACPI_FUNCTION_TRACE("tb_convert_table_fadt"); 495 ACPI_FUNCTION_TRACE(tb_convert_table_fadt);
498 496
499 /* 497 /*
500 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be 498 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
@@ -508,13 +506,14 @@ acpi_status acpi_tb_convert_table_fadt(void)
508 506
509 /* Allocate buffer for the ACPI 2.0(+) FADT */ 507 /* Allocate buffer for the ACPI 2.0(+) FADT */
510 508
511 local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2)); 509 local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor));
512 if (!local_fadt) { 510 if (!local_fadt) {
513 return_ACPI_STATUS(AE_NO_MEMORY); 511 return_ACPI_STATUS(AE_NO_MEMORY);
514 } 512 }
515 513
516 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { 514 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { 515 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor)) {
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
520 ACPI_WARNING((AE_INFO, 519 ACPI_WARNING((AE_INFO,
@@ -538,11 +537,11 @@ 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
545 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; 544 table_desc = acpi_gbl_table_lists[ACPI_TABLE_ID_FADT].next;
546 acpi_tb_delete_single_table(table_desc); 545 acpi_tb_delete_single_table(table_desc);
547 546
548 /* Install the new table */ 547 /* Install the new table */
@@ -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
@@ -580,7 +579,7 @@ acpi_status acpi_tb_convert_table_fadt(void)
580acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info) 579acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
581{ 580{
582 581
583 ACPI_FUNCTION_TRACE("tb_build_common_facs"); 582 ACPI_FUNCTION_TRACE(tb_build_common_facs);
584 583
585 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 584 /* Absolute minimum length is 24, but the ACPI spec says 64 */
586 585
@@ -603,6 +602,7 @@ acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
603 if ((acpi_gbl_RSDP->revision < 2) || 602 if ((acpi_gbl_RSDP->revision < 2) ||
604 (acpi_gbl_FACS->length < 32) || 603 (acpi_gbl_FACS->length < 32) ||
605 (!(acpi_gbl_FACS->xfirmware_waking_vector))) { 604 (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
605
606 /* ACPI 1.0 FACS or short table or optional X_ field is zero */ 606 /* ACPI 1.0 FACS or short table or optional X_ field is zero */
607 607
608 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64, 608 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 09b4ee6dfd60..99eacceff563 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -78,7 +78,7 @@ acpi_tb_get_table(struct acpi_pointer *address,
78 acpi_status status; 78 acpi_status status;
79 struct acpi_table_header header; 79 struct acpi_table_header header;
80 80
81 ACPI_FUNCTION_TRACE("tb_get_table"); 81 ACPI_FUNCTION_TRACE(tb_get_table);
82 82
83 /* Get the header in order to get signature and table size */ 83 /* Get the header in order to get signature and table size */
84 84
@@ -124,7 +124,7 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
124 acpi_status status = AE_OK; 124 acpi_status status = AE_OK;
125 struct acpi_table_header *header = NULL; 125 struct acpi_table_header *header = NULL;
126 126
127 ACPI_FUNCTION_TRACE("tb_get_table_header"); 127 ACPI_FUNCTION_TRACE(tb_get_table_header);
128 128
129 /* 129 /*
130 * Flags contains the current processor mode (Virtual or Physical 130 * Flags contains the current processor mode (Virtual or Physical
@@ -148,6 +148,10 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
148 sizeof(struct acpi_table_header), 148 sizeof(struct acpi_table_header),
149 (void *)&header); 149 (void *)&header);
150 if (ACPI_FAILURE(status)) { 150 if (ACPI_FAILURE(status)) {
151 ACPI_ERROR((AE_INFO,
152 "Could not map memory at %8.8X%8.8X for table header",
153 ACPI_FORMAT_UINT64(address->pointer.
154 physical)));
151 return_ACPI_STATUS(status); 155 return_ACPI_STATUS(status);
152 } 156 }
153 157
@@ -198,7 +202,7 @@ acpi_tb_get_table_body(struct acpi_pointer *address,
198{ 202{
199 acpi_status status; 203 acpi_status status;
200 204
201 ACPI_FUNCTION_TRACE("tb_get_table_body"); 205 ACPI_FUNCTION_TRACE(tb_get_table_body);
202 206
203 if (!table_info || !address) { 207 if (!table_info || !address) {
204 return_ACPI_STATUS(AE_BAD_PARAMETER); 208 return_ACPI_STATUS(AE_BAD_PARAMETER);
@@ -208,6 +212,7 @@ acpi_tb_get_table_body(struct acpi_pointer *address,
208 212
209 status = acpi_tb_table_override(header, table_info); 213 status = acpi_tb_table_override(header, table_info);
210 if (ACPI_SUCCESS(status)) { 214 if (ACPI_SUCCESS(status)) {
215
211 /* Table was overridden by the host OS */ 216 /* Table was overridden by the host OS */
212 217
213 return_ACPI_STATUS(status); 218 return_ACPI_STATUS(status);
@@ -241,7 +246,7 @@ acpi_tb_table_override(struct acpi_table_header *header,
241 acpi_status status; 246 acpi_status status;
242 struct acpi_pointer address; 247 struct acpi_pointer address;
243 248
244 ACPI_FUNCTION_TRACE("tb_table_override"); 249 ACPI_FUNCTION_TRACE(tb_table_override);
245 250
246 /* 251 /*
247 * The OSL will examine the header and decide whether to override this 252 * The OSL will examine the header and decide whether to override this
@@ -250,6 +255,7 @@ acpi_tb_table_override(struct acpi_table_header *header,
250 */ 255 */
251 status = acpi_os_table_override(header, &new_table); 256 status = acpi_os_table_override(header, &new_table);
252 if (ACPI_FAILURE(status)) { 257 if (ACPI_FAILURE(status)) {
258
253 /* Some severe error from the OSL, but we basically ignore it */ 259 /* Some severe error from the OSL, but we basically ignore it */
254 260
255 ACPI_EXCEPTION((AE_INFO, status, 261 ACPI_EXCEPTION((AE_INFO, status,
@@ -258,6 +264,7 @@ acpi_tb_table_override(struct acpi_table_header *header,
258 } 264 }
259 265
260 if (!new_table) { 266 if (!new_table) {
267
261 /* No table override */ 268 /* No table override */
262 269
263 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 270 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
@@ -311,7 +318,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
311 u8 allocation; 318 u8 allocation;
312 acpi_status status = AE_OK; 319 acpi_status status = AE_OK;
313 320
314 ACPI_FUNCTION_TRACE("tb_get_this_table"); 321 ACPI_FUNCTION_TRACE(tb_get_this_table);
315 322
316 /* 323 /*
317 * Flags contains the current processor mode (Virtual or Physical 324 * Flags contains the current processor mode (Virtual or Physical
@@ -323,7 +330,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
323 330
324 /* Pointer matches processor mode, copy the table to a new buffer */ 331 /* Pointer matches processor mode, copy the table to a new buffer */
325 332
326 full_table = ACPI_MEM_ALLOCATE(header->length); 333 full_table = ACPI_ALLOCATE(header->length);
327 if (!full_table) { 334 if (!full_table) {
328 ACPI_ERROR((AE_INFO, 335 ACPI_ERROR((AE_INFO,
329 "Could not allocate table memory for [%4.4s] length %X", 336 "Could not allocate table memory for [%4.4s] length %X",
@@ -376,11 +383,12 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
376 * Validate checksum for _most_ tables, 383 * Validate checksum for _most_ tables,
377 * even the ones whose signature we don't recognize 384 * even the ones whose signature we don't recognize
378 */ 385 */
379 if (table_info->type != ACPI_TABLE_FACS) { 386 if (table_info->type != ACPI_TABLE_ID_FACS) {
380 status = acpi_tb_verify_table_checksum(full_table); 387 status = acpi_tb_verify_table_checksum(full_table);
381 388
382#if (!ACPI_CHECKSUM_ABORT) 389#if (!ACPI_CHECKSUM_ABORT)
383 if (ACPI_FAILURE(status)) { 390 if (ACPI_FAILURE(status)) {
391
384 /* Ignore the error if configuration says so */ 392 /* Ignore the error if configuration says so */
385 393
386 status = AE_OK; 394 status = AE_OK;
@@ -409,7 +417,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
409 * 417 *
410 * PARAMETERS: table_type - one of the defined table types 418 * PARAMETERS: table_type - one of the defined table types
411 * Instance - Which table of this type 419 * Instance - Which table of this type
412 * table_ptr_loc - pointer to location to place the pointer for 420 * return_table - pointer to location to place the pointer for
413 * return 421 * return
414 * 422 *
415 * RETURN: Status 423 * RETURN: Status
@@ -420,57 +428,34 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
420 428
421acpi_status 429acpi_status
422acpi_tb_get_table_ptr(acpi_table_type table_type, 430acpi_tb_get_table_ptr(acpi_table_type table_type,
423 u32 instance, struct acpi_table_header **table_ptr_loc) 431 u32 instance, struct acpi_table_header **return_table)
424{ 432{
425 struct acpi_table_desc *table_desc; 433 struct acpi_table_desc *table_desc;
426 u32 i; 434 u32 i;
427 435
428 ACPI_FUNCTION_TRACE("tb_get_table_ptr"); 436 ACPI_FUNCTION_TRACE(tb_get_table_ptr);
429
430 if (!acpi_gbl_DSDT) {
431 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
432 }
433 437
434 if (table_type > ACPI_TABLE_MAX) { 438 if (table_type > ACPI_TABLE_ID_MAX) {
435 return_ACPI_STATUS(AE_BAD_PARAMETER); 439 return_ACPI_STATUS(AE_BAD_PARAMETER);
436 } 440 }
437 441
438 /* 442 /* Check for instance out of range of the current table count */
439 * For all table types (Single/Multiple), the first
440 * instance is always in the list head.
441 */
442 if (instance == 1) {
443 /* Get the first */
444
445 *table_ptr_loc = NULL;
446 if (acpi_gbl_table_lists[table_type].next) {
447 *table_ptr_loc =
448 acpi_gbl_table_lists[table_type].next->pointer;
449 }
450 return_ACPI_STATUS(AE_OK);
451 }
452
453 /* Check for instance out of range */
454 443
455 if (instance > acpi_gbl_table_lists[table_type].count) { 444 if (instance > acpi_gbl_table_lists[table_type].count) {
456 return_ACPI_STATUS(AE_NOT_EXIST); 445 return_ACPI_STATUS(AE_NOT_EXIST);
457 } 446 }
458 447
459 /* Walk the list to get the desired table 448 /*
460 * Since the if (Instance == 1) check above checked for the 449 * Walk the list to get the desired table
461 * first table, setting table_desc equal to the .Next member 450 * Note: Instance is one-based
462 * is actually pointing to the second table. Therefore, we
463 * need to walk from the 2nd table until we reach the Instance
464 * that the user is looking for and return its table pointer.
465 */ 451 */
466 table_desc = acpi_gbl_table_lists[table_type].next; 452 table_desc = acpi_gbl_table_lists[table_type].next;
467 for (i = 2; i < instance; i++) { 453 for (i = 1; i < instance; i++) {
468 table_desc = table_desc->next; 454 table_desc = table_desc->next;
469 } 455 }
470 456
471 /* We are now pointing to the requested table's descriptor */ 457 /* We are now pointing to the requested table's descriptor */
472 458
473 *table_ptr_loc = table_desc->pointer; 459 *return_table = table_desc->pointer;
474
475 return_ACPI_STATUS(AE_OK); 460 return_ACPI_STATUS(AE_OK);
476} 461}
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index 134e5dce0bc1..ad982112e4c6 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -77,7 +77,7 @@ acpi_tb_get_primary_table(struct acpi_pointer *address,
77 acpi_status status; 77 acpi_status status;
78 struct acpi_table_header header; 78 struct acpi_table_header header;
79 79
80 ACPI_FUNCTION_TRACE("tb_get_primary_table"); 80 ACPI_FUNCTION_TRACE(tb_get_primary_table);
81 81
82 /* Ignore a NULL address in the RSDT */ 82 /* Ignore a NULL address in the RSDT */
83 83
@@ -140,7 +140,7 @@ acpi_tb_get_secondary_table(struct acpi_pointer *address,
140 acpi_status status; 140 acpi_status status;
141 struct acpi_table_header header; 141 struct acpi_table_header header;
142 142
143 ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature); 143 ACPI_FUNCTION_TRACE_STR(tb_get_secondary_table, signature);
144 144
145 /* Get the header in order to match the signature */ 145 /* Get the header in order to match the signature */
146 146
@@ -151,7 +151,7 @@ acpi_tb_get_secondary_table(struct acpi_pointer *address,
151 151
152 /* Signature must match request */ 152 /* Signature must match request */
153 153
154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { 154 if (!ACPI_COMPARE_NAME(header.signature, signature)) {
155 ACPI_ERROR((AE_INFO, 155 ACPI_ERROR((AE_INFO,
156 "Incorrect table signature - wanted [%s] found [%4.4s]", 156 "Incorrect table signature - wanted [%s] found [%4.4s]",
157 signature, header.signature)); 157 signature, header.signature));
@@ -207,7 +207,7 @@ acpi_status acpi_tb_get_required_tables(void)
207 struct acpi_table_desc table_info; 207 struct acpi_table_desc table_info;
208 struct acpi_pointer address; 208 struct acpi_pointer address;
209 209
210 ACPI_FUNCTION_TRACE("tb_get_required_tables"); 210 ACPI_FUNCTION_TRACE(tb_get_required_tables);
211 211
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", 212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
213 acpi_gbl_rsdt_table_count)); 213 acpi_gbl_rsdt_table_count));
@@ -223,6 +223,7 @@ acpi_status acpi_tb_get_required_tables(void)
223 * any SSDTs. 223 * any SSDTs.
224 */ 224 */
225 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 225 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
226
226 /* Get the table address from the common internal XSDT */ 227 /* Get the table address from the common internal XSDT */
227 228
228 address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i]; 229 address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
@@ -305,6 +306,6 @@ acpi_status acpi_tb_get_required_tables(void)
305 306
306 /* Always delete the RSDP mapping, we are done with it */ 307 /* Always delete the RSDP mapping, we are done with it */
307 308
308 acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP); 309 acpi_tb_delete_tables_by_type(ACPI_TABLE_ID_RSDP);
309 return_ACPI_STATUS(status); 310 return_ACPI_STATUS(status);
310} 311}
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 7ffd0fddb4e5..7ca2df75bb11 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -73,17 +73,18 @@ acpi_tb_match_signature(char *signature,
73{ 73{
74 acpi_native_uint i; 74 acpi_native_uint i;
75 75
76 ACPI_FUNCTION_TRACE("tb_match_signature"); 76 ACPI_FUNCTION_TRACE(tb_match_signature);
77 77
78 /* Search for a signature match among the known table types */ 78 /* Search for a signature match among the known table types */
79 79
80 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { 80 for (i = 0; i < (ACPI_TABLE_ID_MAX + 1); i++) {
81 if (!(acpi_gbl_table_data[i].flags & search_type)) { 81 if (!(acpi_gbl_table_data[i].flags & search_type)) {
82 continue; 82 continue;
83 } 83 }
84 84
85 if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature, 85 if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature,
86 acpi_gbl_table_data[i].sig_length)) { 86 acpi_gbl_table_data[i].sig_length)) {
87
87 /* Found a signature match, return index if requested */ 88 /* Found a signature match, return index if requested */
88 89
89 if (table_info) { 90 if (table_info) {
@@ -122,7 +123,7 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
122{ 123{
123 acpi_status status; 124 acpi_status status;
124 125
125 ACPI_FUNCTION_TRACE("tb_install_table"); 126 ACPI_FUNCTION_TRACE(tb_install_table);
126 127
127 /* Lock tables while installing */ 128 /* Lock tables while installing */
128 129
@@ -187,7 +188,7 @@ acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
187 struct acpi_table_header *table_header; 188 struct acpi_table_header *table_header;
188 acpi_status status; 189 acpi_status status;
189 190
190 ACPI_FUNCTION_TRACE("tb_recognize_table"); 191 ACPI_FUNCTION_TRACE(tb_recognize_table);
191 192
192 /* Ensure that we have a valid table pointer */ 193 /* Ensure that we have a valid table pointer */
193 194
@@ -218,7 +219,6 @@ acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
218 /* Return the table type and length via the info struct */ 219 /* Return the table type and length via the info struct */
219 220
220 table_info->length = (acpi_size) table_header->length; 221 table_info->length = (acpi_size) table_header->length;
221
222 return_ACPI_STATUS(status); 222 return_ACPI_STATUS(status);
223} 223}
224 224
@@ -243,11 +243,11 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
243 struct acpi_table_desc *table_desc; 243 struct acpi_table_desc *table_desc;
244 acpi_status status; 244 acpi_status status;
245 245
246 ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type); 246 ACPI_FUNCTION_TRACE_U32(tb_init_table_descriptor, table_type);
247 247
248 /* Allocate a descriptor for this table */ 248 /* Allocate a descriptor for this table */
249 249
250 table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); 250 table_desc = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_table_desc));
251 if (!table_desc) { 251 if (!table_desc) {
252 return_ACPI_STATUS(AE_NO_MEMORY); 252 return_ACPI_STATUS(AE_NO_MEMORY);
253 } 253 }
@@ -274,7 +274,7 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
274 * at this location, so return an error. 274 * at this location, so return an error.
275 */ 275 */
276 if (list_head->next) { 276 if (list_head->next) {
277 ACPI_MEM_FREE(table_desc); 277 ACPI_FREE(table_desc);
278 return_ACPI_STATUS(AE_ALREADY_EXISTS); 278 return_ACPI_STATUS(AE_ALREADY_EXISTS);
279 } 279 }
280 280
@@ -312,15 +312,14 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
312 312
313 /* Finish initialization of the table descriptor */ 313 /* Finish initialization of the table descriptor */
314 314
315 table_desc->loaded_into_namespace = FALSE;
315 table_desc->type = (u8) table_type; 316 table_desc->type = (u8) table_type;
316 table_desc->pointer = table_info->pointer; 317 table_desc->pointer = table_info->pointer;
317 table_desc->length = table_info->length; 318 table_desc->length = table_info->length;
318 table_desc->allocation = table_info->allocation; 319 table_desc->allocation = table_info->allocation;
319 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 320 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
320 table_desc->aml_length = (u32) (table_desc->length - 321 table_desc->aml_length = (u32)
321 (u32) sizeof(struct 322 (table_desc->length - (u32) sizeof(struct acpi_table_header));
322 acpi_table_header));
323 table_desc->loaded_into_namespace = FALSE;
324 323
325 /* 324 /*
326 * Set the appropriate global pointer (if there is one) to point to the 325 * Set the appropriate global pointer (if there is one) to point to the
@@ -335,7 +334,6 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
335 334
336 table_info->owner_id = table_desc->owner_id; 335 table_info->owner_id = table_desc->owner_id;
337 table_info->installed_desc = table_desc; 336 table_info->installed_desc = table_desc;
338
339 return_ACPI_STATUS(AE_OK); 337 return_ACPI_STATUS(AE_OK);
340} 338}
341 339
@@ -359,7 +357,7 @@ void acpi_tb_delete_all_tables(void)
359 * Free memory allocated for ACPI tables 357 * Free memory allocated for ACPI tables
360 * Memory can either be mapped or allocated 358 * Memory can either be mapped or allocated
361 */ 359 */
362 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { 360 for (type = 0; type < (ACPI_TABLE_ID_MAX + 1); type++) {
363 acpi_tb_delete_tables_by_type(type); 361 acpi_tb_delete_tables_by_type(type);
364 } 362 }
365} 363}
@@ -383,9 +381,9 @@ void acpi_tb_delete_tables_by_type(acpi_table_type type)
383 u32 count; 381 u32 count;
384 u32 i; 382 u32 i;
385 383
386 ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type); 384 ACPI_FUNCTION_TRACE_U32(tb_delete_tables_by_type, type);
387 385
388 if (type > ACPI_TABLE_MAX) { 386 if (type > ACPI_TABLE_ID_MAX) {
389 return_VOID; 387 return_VOID;
390 } 388 }
391 389
@@ -396,28 +394,28 @@ void acpi_tb_delete_tables_by_type(acpi_table_type type)
396 /* Clear the appropriate "typed" global table pointer */ 394 /* Clear the appropriate "typed" global table pointer */
397 395
398 switch (type) { 396 switch (type) {
399 case ACPI_TABLE_RSDP: 397 case ACPI_TABLE_ID_RSDP:
400 acpi_gbl_RSDP = NULL; 398 acpi_gbl_RSDP = NULL;
401 break; 399 break;
402 400
403 case ACPI_TABLE_DSDT: 401 case ACPI_TABLE_ID_DSDT:
404 acpi_gbl_DSDT = NULL; 402 acpi_gbl_DSDT = NULL;
405 break; 403 break;
406 404
407 case ACPI_TABLE_FADT: 405 case ACPI_TABLE_ID_FADT:
408 acpi_gbl_FADT = NULL; 406 acpi_gbl_FADT = NULL;
409 break; 407 break;
410 408
411 case ACPI_TABLE_FACS: 409 case ACPI_TABLE_ID_FACS:
412 acpi_gbl_FACS = NULL; 410 acpi_gbl_FACS = NULL;
413 break; 411 break;
414 412
415 case ACPI_TABLE_XSDT: 413 case ACPI_TABLE_ID_XSDT:
416 acpi_gbl_XSDT = NULL; 414 acpi_gbl_XSDT = NULL;
417 break; 415 break;
418 416
419 case ACPI_TABLE_SSDT: 417 case ACPI_TABLE_ID_SSDT:
420 case ACPI_TABLE_PSDT: 418 case ACPI_TABLE_ID_PSDT:
421 default: 419 default:
422 break; 420 break;
423 } 421 }
@@ -471,7 +469,7 @@ void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc)
471 469
472 case ACPI_MEM_ALLOCATED: 470 case ACPI_MEM_ALLOCATED:
473 471
474 ACPI_MEM_FREE(table_desc->pointer); 472 ACPI_FREE(table_desc->pointer);
475 break; 473 break;
476 474
477 case ACPI_MEM_MAPPED: 475 case ACPI_MEM_MAPPED:
@@ -503,7 +501,7 @@ struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
503{ 501{
504 struct acpi_table_desc *next_desc; 502 struct acpi_table_desc *next_desc;
505 503
506 ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc); 504 ACPI_FUNCTION_TRACE_PTR(tb_uninstall_table, table_desc);
507 505
508 if (!table_desc) { 506 if (!table_desc) {
509 return_PTR(NULL); 507 return_PTR(NULL);
@@ -530,7 +528,7 @@ struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
530 /* Free the table descriptor */ 528 /* Free the table descriptor */
531 529
532 next_desc = table_desc->next; 530 next_desc = table_desc->next;
533 ACPI_MEM_FREE(table_desc); 531 ACPI_FREE(table_desc);
534 532
535 /* Return pointer to the next descriptor */ 533 /* Return pointer to the next descriptor */
536 534
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 4d308220225d..abcb08c2592a 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -64,7 +64,7 @@ acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
64 acpi_status status; 64 acpi_status status;
65 struct rsdp_descriptor *rsdp; 65 struct rsdp_descriptor *rsdp;
66 66
67 ACPI_FUNCTION_TRACE("tb_verify_rsdp"); 67 ACPI_FUNCTION_TRACE(tb_verify_rsdp);
68 68
69 switch (address->pointer_type) { 69 switch (address->pointer_type) {
70 case ACPI_LOGICAL_POINTER: 70 case ACPI_LOGICAL_POINTER:
@@ -78,7 +78,7 @@ acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
78 */ 78 */
79 status = acpi_os_map_memory(address->pointer.physical, 79 status = acpi_os_map_memory(address->pointer.physical,
80 sizeof(struct rsdp_descriptor), 80 sizeof(struct rsdp_descriptor),
81 (void *)&rsdp); 81 ACPI_CAST_PTR(void, &rsdp));
82 if (ACPI_FAILURE(status)) { 82 if (ACPI_FAILURE(status)) {
83 return_ACPI_STATUS(status); 83 return_ACPI_STATUS(status);
84 } 84 }
@@ -95,15 +95,20 @@ acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
95 goto cleanup; 95 goto cleanup;
96 } 96 }
97 97
98 /* The RSDP supplied is OK */ 98 /* RSDP is ok. Init the table info */
99 99
100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp); 100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp);
101 table_info.length = sizeof(struct rsdp_descriptor); 101 table_info.length = sizeof(struct rsdp_descriptor);
102 table_info.allocation = ACPI_MEM_MAPPED; 102
103 if (address->pointer_type == ACPI_PHYSICAL_POINTER) {
104 table_info.allocation = ACPI_MEM_MAPPED;
105 } else {
106 table_info.allocation = ACPI_MEM_NOT_ALLOCATED;
107 }
103 108
104 /* Save the table pointers and allocation info */ 109 /* Save the table pointers and allocation info */
105 110
106 status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info); 111 status = acpi_tb_init_table_descriptor(ACPI_TABLE_ID_RSDP, &table_info);
107 if (ACPI_FAILURE(status)) { 112 if (ACPI_FAILURE(status)) {
108 goto cleanup; 113 goto cleanup;
109 } 114 }
@@ -174,22 +179,20 @@ void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address)
174 179
175acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) 180acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
176{ 181{
177 int no_match; 182 char *signature;
178 183
179 ACPI_FUNCTION_ENTRY(); 184 ACPI_FUNCTION_ENTRY();
180 185
181 /* 186 /* Search for appropriate signature, RSDT or XSDT */
182 * Search for appropriate signature, RSDT or XSDT 187
183 */
184 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 188 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
185 no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG, 189 signature = RSDT_SIG;
186 sizeof(RSDT_SIG) - 1);
187 } else { 190 } else {
188 no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG, 191 signature = XSDT_SIG;
189 sizeof(XSDT_SIG) - 1);
190 } 192 }
191 193
192 if (no_match) { 194 if (!ACPI_COMPARE_NAME(table_ptr->signature, signature)) {
195
193 /* Invalid RSDT or XSDT signature */ 196 /* Invalid RSDT or XSDT signature */
194 197
195 ACPI_ERROR((AE_INFO, 198 ACPI_ERROR((AE_INFO,
@@ -198,10 +201,8 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
198 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); 201 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
199 202
200 ACPI_ERROR((AE_INFO, 203 ACPI_ERROR((AE_INFO,
201 "RSDT/XSDT signature at %X (%p) is invalid", 204 "RSDT/XSDT signature at %X is invalid",
202 acpi_gbl_RSDP->rsdt_physical_address, 205 acpi_gbl_RSDP->rsdt_physical_address));
203 (void *)(acpi_native_uint) acpi_gbl_RSDP->
204 rsdt_physical_address));
205 206
206 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 207 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
207 ACPI_ERROR((AE_INFO, "Looking for RSDT")); 208 ACPI_ERROR((AE_INFO, "Looking for RSDT"));
@@ -234,13 +235,13 @@ acpi_status acpi_tb_get_table_rsdt(void)
234 acpi_status status; 235 acpi_status status;
235 struct acpi_pointer address; 236 struct acpi_pointer address;
236 237
237 ACPI_FUNCTION_TRACE("tb_get_table_rsdt"); 238 ACPI_FUNCTION_TRACE(tb_get_table_rsdt);
238 239
239 /* Get the RSDT/XSDT via the RSDP */ 240 /* Get the RSDT/XSDT via the RSDP */
240 241
241 acpi_tb_get_rsdt_address(&address); 242 acpi_tb_get_rsdt_address(&address);
242 243
243 table_info.type = ACPI_TABLE_XSDT; 244 table_info.type = ACPI_TABLE_ID_XSDT;
244 status = acpi_tb_get_table(&address, &table_info); 245 status = acpi_tb_get_table(&address, &table_info);
245 if (ACPI_FAILURE(status)) { 246 if (ACPI_FAILURE(status)) {
246 ACPI_EXCEPTION((AE_INFO, status, 247 ACPI_EXCEPTION((AE_INFO, status,
@@ -274,12 +275,13 @@ acpi_status acpi_tb_get_table_rsdt(void)
274 275
275 /* Save the table pointers and allocation info */ 276 /* Save the table pointers and allocation info */
276 277
277 status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info); 278 status = acpi_tb_init_table_descriptor(ACPI_TABLE_ID_XSDT, &table_info);
278 if (ACPI_FAILURE(status)) { 279 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS(status); 280 return_ACPI_STATUS(status);
280 } 281 }
281 282
282 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);
283 285
284 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));
285 return_ACPI_STATUS(status); 287 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index bc571592f087..209a401801e3 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -71,7 +71,7 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
71{ 71{
72 struct acpi_table_desc *table_desc; 72 struct acpi_table_desc *table_desc;
73 73
74 ACPI_FUNCTION_TRACE("tb_is_table_installed"); 74 ACPI_FUNCTION_TRACE(tb_is_table_installed);
75 75
76 /* Get the list descriptor and first table descriptor */ 76 /* Get the list descriptor and first table descriptor */
77 77
@@ -96,10 +96,11 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
96 (!ACPI_MEMCMP 96 (!ACPI_MEMCMP
97 (table_desc->pointer, new_table_desc->pointer, 97 (table_desc->pointer, new_table_desc->pointer,
98 new_table_desc->pointer->length))) { 98 new_table_desc->pointer->length))) {
99
99 /* Match: this table is already installed */ 100 /* Match: this table is already installed */
100 101
101 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
102 "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n", 103 "Table [%4.4s] already installed: Rev %X OemTableId [%8.8s]\n",
103 new_table_desc->pointer->signature, 104 new_table_desc->pointer->signature,
104 new_table_desc->pointer->revision, 105 new_table_desc->pointer->revision,
105 new_table_desc->pointer-> 106 new_table_desc->pointer->
@@ -159,12 +160,8 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
159 160
160 ACPI_MOVE_32_TO_32(&signature, table_header->signature); 161 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
161 if (!acpi_ut_valid_acpi_name(signature)) { 162 if (!acpi_ut_valid_acpi_name(signature)) {
162 ACPI_ERROR((AE_INFO, 163 ACPI_ERROR((AE_INFO, "Invalid table signature 0x%8.8X",
163 "Table signature at %p [%p] has invalid characters", 164 signature));
164 table_header, &signature));
165
166 ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]",
167 ACPI_CAST_PTR(char, &signature)));
168 165
169 ACPI_DUMP_BUFFER(table_header, 166 ACPI_DUMP_BUFFER(table_header,
170 sizeof(struct acpi_table_header)); 167 sizeof(struct acpi_table_header));
@@ -175,12 +172,9 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
175 172
176 if (table_header->length < sizeof(struct acpi_table_header)) { 173 if (table_header->length < sizeof(struct acpi_table_header)) {
177 ACPI_ERROR((AE_INFO, 174 ACPI_ERROR((AE_INFO,
178 "Invalid length in table header %p name %4.4s", 175 "Invalid length 0x%X in table with signature %4.4s",
179 table_header, (char *)&signature)); 176 (u32) table_header->length,
180 177 ACPI_CAST_PTR(char, &signature)));
181 ACPI_WARNING((AE_INFO,
182 "Invalid table header length (0x%X) found",
183 (u32) table_header->length));
184 178
185 ACPI_DUMP_BUFFER(table_header, 179 ACPI_DUMP_BUFFER(table_header,
186 sizeof(struct acpi_table_header)); 180 sizeof(struct acpi_table_header));
@@ -192,72 +186,119 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
192 186
193/******************************************************************************* 187/*******************************************************************************
194 * 188 *
195 * FUNCTION: acpi_tb_verify_table_checksum 189 * FUNCTION: acpi_tb_sum_table
196 * 190 *
197 * PARAMETERS: *table_header - ACPI table to verify 191 * PARAMETERS: Buffer - Buffer to sum
192 * Length - Size of the buffer
198 * 193 *
199 * RETURN: 8 bit checksum of table 194 * RETURN: 8 bit sum of buffer
200 * 195 *
201 * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct 196 * DESCRIPTION: Computes an 8 bit sum of the buffer(length) and returns it.
202 * table should have a checksum of 0.
203 * 197 *
204 ******************************************************************************/ 198 ******************************************************************************/
205 199
206acpi_status 200u8 acpi_tb_sum_table(void *buffer, u32 length)
207acpi_tb_verify_table_checksum(struct acpi_table_header * table_header) 201{
202 acpi_native_uint i;
203 u8 sum = 0;
204
205 if (!buffer || !length) {
206 return (0);
207 }
208
209 for (i = 0; i < length; i++) {
210 sum = (u8) (sum + ((u8 *) buffer)[i]);
211 }
212 return (sum);
213}
214
215/*******************************************************************************
216 *
217 * FUNCTION: acpi_tb_generate_checksum
218 *
219 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
220 * standard ACPI header)
221 *
222 * RETURN: 8 bit checksum of buffer
223 *
224 * DESCRIPTION: Computes an 8 bit checksum of the table.
225 *
226 ******************************************************************************/
227
228u8 acpi_tb_generate_checksum(struct acpi_table_header * table)
208{ 229{
209 u8 checksum; 230 u8 checksum;
210 acpi_status status = AE_OK;
211 231
212 ACPI_FUNCTION_TRACE("tb_verify_table_checksum"); 232 /* Sum the entire table as-is */
213 233
214 /* Compute the checksum on the table */ 234 checksum = acpi_tb_sum_table(table, table->length);
215 235
216 checksum = 236 /* Subtract off the existing checksum value in the table */
217 acpi_tb_generate_checksum(table_header, table_header->length);
218 237
219 /* Return the appropriate exception */ 238 checksum = (u8) (checksum - table->checksum);
220 239
221 if (checksum) { 240 /* Compute the final checksum */
222 ACPI_WARNING((AE_INFO,
223 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)",
224 table_header->signature,
225 (u32) table_header->checksum, (u32) checksum));
226 241
227 status = AE_BAD_CHECKSUM; 242 checksum = (u8) (0 - checksum);
228 } 243 return (checksum);
229 return_ACPI_STATUS(status);
230} 244}
231 245
232/******************************************************************************* 246/*******************************************************************************
233 * 247 *
234 * FUNCTION: acpi_tb_generate_checksum 248 * FUNCTION: acpi_tb_set_checksum
235 * 249 *
236 * PARAMETERS: Buffer - Buffer to checksum 250 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
237 * Length - Size of the buffer 251 * standard ACPI header)
238 * 252 *
239 * RETURN: 8 bit checksum of buffer 253 * RETURN: None. Sets the table checksum field
240 * 254 *
241 * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. 255 * DESCRIPTION: Computes an 8 bit checksum of the table and inserts the
256 * checksum into the table header.
242 * 257 *
243 ******************************************************************************/ 258 ******************************************************************************/
244 259
245u8 acpi_tb_generate_checksum(void *buffer, u32 length) 260void acpi_tb_set_checksum(struct acpi_table_header *table)
246{ 261{
247 u8 *end_buffer;
248 u8 *rover;
249 u8 sum = 0;
250 262
251 if (buffer && length) { 263 table->checksum = acpi_tb_generate_checksum(table);
252 /* Buffer and Length are valid */ 264}
253 265
254 end_buffer = ACPI_ADD_PTR(u8, buffer, length); 266/*******************************************************************************
267 *
268 * FUNCTION: acpi_tb_verify_table_checksum
269 *
270 * PARAMETERS: *table_header - ACPI table to verify
271 *
272 * RETURN: 8 bit checksum of table
273 *
274 * DESCRIPTION: Generates an 8 bit checksum of table and returns and compares
275 * it to the existing checksum value.
276 *
277 ******************************************************************************/
255 278
256 for (rover = buffer; rover < end_buffer; rover++) { 279acpi_status
257 sum = (u8) (sum + *rover); 280acpi_tb_verify_table_checksum(struct acpi_table_header *table_header)
258 } 281{
282 u8 checksum;
283
284 ACPI_FUNCTION_TRACE(tb_verify_table_checksum);
285
286 /* Compute the checksum on the table */
287
288 checksum = acpi_tb_generate_checksum(table_header);
289
290 /* Checksum ok? */
291
292 if (checksum == table_header->checksum) {
293 return_ACPI_STATUS(AE_OK);
259 } 294 }
260 return (sum); 295
296 ACPI_WARNING((AE_INFO,
297 "Incorrect checksum in table [%4.4s] - is %2.2X, should be %2.2X",
298 table_header->signature, table_header->checksum,
299 checksum));
300
301 return_ACPI_STATUS(AE_BAD_CHECKSUM);
261} 302}
262 303
263#ifdef ACPI_OBSOLETE_FUNCTIONS 304#ifdef ACPI_OBSOLETE_FUNCTIONS
@@ -276,12 +317,12 @@ u8 acpi_tb_generate_checksum(void *buffer, u32 length)
276 317
277acpi_status 318acpi_status
278acpi_tb_handle_to_object(u16 table_id, 319acpi_tb_handle_to_object(u16 table_id,
279 struct acpi_table_desc ** return_table_desc) 320 struct acpi_table_desc **return_table_desc)
280{ 321{
281 u32 i; 322 u32 i;
282 struct acpi_table_desc *table_desc; 323 struct acpi_table_desc *table_desc;
283 324
284 ACPI_FUNCTION_NAME("tb_handle_to_object"); 325 ACPI_FUNCTION_NAME(tb_handle_to_object);
285 326
286 for (i = 0; i < ACPI_TABLE_MAX; i++) { 327 for (i = 0; i < ACPI_TABLE_MAX; i++) {
287 table_desc = acpi_gbl_table_lists[i].next; 328 table_desc = acpi_gbl_table_lists[i].next;
@@ -295,7 +336,7 @@ acpi_tb_handle_to_object(u16 table_id,
295 } 336 }
296 } 337 }
297 338
298 ACPI_ERROR((AE_INFO, "table_id=%X does not exist", table_id)); 339 ACPI_ERROR((AE_INFO, "TableId=%X does not exist", table_id));
299 return (AE_BAD_PARAMETER); 340 return (AE_BAD_PARAMETER);
300} 341}
301#endif 342#endif
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 9fe53c9d5b9a..4e91f2984815 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -42,8 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/module.h>
46
47#include <acpi/acpi.h> 45#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
49#include <acpi/actables.h> 47#include <acpi/actables.h>
@@ -68,7 +66,7 @@ acpi_status acpi_load_tables(void)
68 struct acpi_pointer rsdp_address; 66 struct acpi_pointer rsdp_address;
69 acpi_status status; 67 acpi_status status;
70 68
71 ACPI_FUNCTION_TRACE("acpi_load_tables"); 69 ACPI_FUNCTION_TRACE(acpi_load_tables);
72 70
73 /* Get the RSDP */ 71 /* Get the RSDP */
74 72
@@ -123,6 +121,8 @@ acpi_status acpi_load_tables(void)
123 return_ACPI_STATUS(status); 121 return_ACPI_STATUS(status);
124} 122}
125 123
124ACPI_EXPORT_SYMBOL(acpi_load_tables)
125
126#ifdef ACPI_FUTURE_USAGE 126#ifdef ACPI_FUTURE_USAGE
127/******************************************************************************* 127/*******************************************************************************
128 * 128 *
@@ -139,14 +139,13 @@ acpi_status acpi_load_tables(void)
139 * is determined that the table is invalid, the call will fail. 139 * is determined that the table is invalid, the call will fail.
140 * 140 *
141 ******************************************************************************/ 141 ******************************************************************************/
142
143acpi_status acpi_load_table(struct acpi_table_header *table_ptr) 142acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
144{ 143{
145 acpi_status status; 144 acpi_status status;
146 struct acpi_table_desc table_info; 145 struct acpi_table_desc table_info;
147 struct acpi_pointer address; 146 struct acpi_pointer address;
148 147
149 ACPI_FUNCTION_TRACE("acpi_load_table"); 148 ACPI_FUNCTION_TRACE(acpi_load_table);
150 149
151 if (!table_ptr) { 150 if (!table_ptr) {
152 return_ACPI_STATUS(AE_BAD_PARAMETER); 151 return_ACPI_STATUS(AE_BAD_PARAMETER);
@@ -174,6 +173,7 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
174 status = acpi_tb_install_table(&table_info); 173 status = acpi_tb_install_table(&table_info);
175 if (ACPI_FAILURE(status)) { 174 if (ACPI_FAILURE(status)) {
176 if (status == AE_ALREADY_EXISTS) { 175 if (status == AE_ALREADY_EXISTS) {
176
177 /* Table already exists, no error */ 177 /* Table already exists, no error */
178 178
179 status = AE_OK; 179 status = AE_OK;
@@ -188,12 +188,12 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
188 /* Convert the table to common format if necessary */ 188 /* Convert the table to common format if necessary */
189 189
190 switch (table_info.type) { 190 switch (table_info.type) {
191 case ACPI_TABLE_FADT: 191 case ACPI_TABLE_ID_FADT:
192 192
193 status = acpi_tb_convert_table_fadt(); 193 status = acpi_tb_convert_table_fadt();
194 break; 194 break;
195 195
196 case ACPI_TABLE_FACS: 196 case ACPI_TABLE_ID_FACS:
197 197
198 status = acpi_tb_build_common_facs(&table_info); 198 status = acpi_tb_build_common_facs(&table_info);
199 break; 199 break;
@@ -208,6 +208,7 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
208 } 208 }
209 209
210 if (ACPI_FAILURE(status)) { 210 if (ACPI_FAILURE(status)) {
211
211 /* Uninstall table and free the buffer */ 212 /* Uninstall table and free the buffer */
212 213
213 (void)acpi_tb_uninstall_table(table_info.installed_desc); 214 (void)acpi_tb_uninstall_table(table_info.installed_desc);
@@ -216,6 +217,8 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
216 return_ACPI_STATUS(status); 217 return_ACPI_STATUS(status);
217} 218}
218 219
220ACPI_EXPORT_SYMBOL(acpi_load_table)
221
219/******************************************************************************* 222/*******************************************************************************
220 * 223 *
221 * FUNCTION: acpi_unload_table 224 * FUNCTION: acpi_unload_table
@@ -227,16 +230,15 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
227 * DESCRIPTION: This routine is used to force the unload of a table 230 * DESCRIPTION: This routine is used to force the unload of a table
228 * 231 *
229 ******************************************************************************/ 232 ******************************************************************************/
230
231acpi_status acpi_unload_table(acpi_table_type table_type) 233acpi_status acpi_unload_table(acpi_table_type table_type)
232{ 234{
233 struct acpi_table_desc *table_desc; 235 struct acpi_table_desc *table_desc;
234 236
235 ACPI_FUNCTION_TRACE("acpi_unload_table"); 237 ACPI_FUNCTION_TRACE(acpi_unload_table);
236 238
237 /* Parameter validation */ 239 /* Parameter validation */
238 240
239 if (table_type > ACPI_TABLE_MAX) { 241 if (table_type > ACPI_TABLE_ID_MAX) {
240 return_ACPI_STATUS(AE_BAD_PARAMETER); 242 return_ACPI_STATUS(AE_BAD_PARAMETER);
241 } 243 }
242 244
@@ -261,6 +263,8 @@ acpi_status acpi_unload_table(acpi_table_type table_type)
261 return_ACPI_STATUS(AE_OK); 263 return_ACPI_STATUS(AE_OK);
262} 264}
263 265
266ACPI_EXPORT_SYMBOL(acpi_unload_table)
267
264/******************************************************************************* 268/*******************************************************************************
265 * 269 *
266 * FUNCTION: acpi_get_table_header 270 * FUNCTION: acpi_get_table_header
@@ -281,7 +285,6 @@ acpi_status acpi_unload_table(acpi_table_type table_type)
281 * have a standard header and is fixed length. 285 * have a standard header and is fixed length.
282 * 286 *
283 ******************************************************************************/ 287 ******************************************************************************/
284
285acpi_status 288acpi_status
286acpi_get_table_header(acpi_table_type table_type, 289acpi_get_table_header(acpi_table_type table_type,
287 u32 instance, struct acpi_table_header *out_table_header) 290 u32 instance, struct acpi_table_header *out_table_header)
@@ -289,16 +292,16 @@ acpi_get_table_header(acpi_table_type table_type,
289 struct acpi_table_header *tbl_ptr; 292 struct acpi_table_header *tbl_ptr;
290 acpi_status status; 293 acpi_status status;
291 294
292 ACPI_FUNCTION_TRACE("acpi_get_table_header"); 295 ACPI_FUNCTION_TRACE(acpi_get_table_header);
293 296
294 if ((instance == 0) || 297 if ((instance == 0) ||
295 (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) { 298 (table_type == ACPI_TABLE_ID_RSDP) || (!out_table_header)) {
296 return_ACPI_STATUS(AE_BAD_PARAMETER); 299 return_ACPI_STATUS(AE_BAD_PARAMETER);
297 } 300 }
298 301
299 /* Check the table type and instance */ 302 /* Check the table type and instance */
300 303
301 if ((table_type > ACPI_TABLE_MAX) || 304 if ((table_type > ACPI_TABLE_ID_MAX) ||
302 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) && 305 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
303 instance > 1)) { 306 instance > 1)) {
304 return_ACPI_STATUS(AE_BAD_PARAMETER); 307 return_ACPI_STATUS(AE_BAD_PARAMETER);
@@ -325,6 +328,7 @@ acpi_get_table_header(acpi_table_type table_type,
325 return_ACPI_STATUS(status); 328 return_ACPI_STATUS(status);
326} 329}
327 330
331ACPI_EXPORT_SYMBOL(acpi_get_table_header)
328#endif /* ACPI_FUTURE_USAGE */ 332#endif /* ACPI_FUTURE_USAGE */
329 333
330/******************************************************************************* 334/*******************************************************************************
@@ -349,7 +353,6 @@ acpi_get_table_header(acpi_table_type table_type,
349 * a complete table including the header. 353 * a complete table including the header.
350 * 354 *
351 ******************************************************************************/ 355 ******************************************************************************/
352
353acpi_status 356acpi_status
354acpi_get_table(acpi_table_type table_type, 357acpi_get_table(acpi_table_type table_type,
355 u32 instance, struct acpi_buffer *ret_buffer) 358 u32 instance, struct acpi_buffer *ret_buffer)
@@ -358,7 +361,7 @@ acpi_get_table(acpi_table_type table_type,
358 acpi_status status; 361 acpi_status status;
359 acpi_size table_length; 362 acpi_size table_length;
360 363
361 ACPI_FUNCTION_TRACE("acpi_get_table"); 364 ACPI_FUNCTION_TRACE(acpi_get_table);
362 365
363 /* Parameter validation */ 366 /* Parameter validation */
364 367
@@ -373,7 +376,7 @@ acpi_get_table(acpi_table_type table_type,
373 376
374 /* Check the table type and instance */ 377 /* Check the table type and instance */
375 378
376 if ((table_type > ACPI_TABLE_MAX) || 379 if ((table_type > ACPI_TABLE_ID_MAX) ||
377 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) && 380 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
378 instance > 1)) { 381 instance > 1)) {
379 return_ACPI_STATUS(AE_BAD_PARAMETER); 382 return_ACPI_STATUS(AE_BAD_PARAMETER);
@@ -396,7 +399,8 @@ acpi_get_table(acpi_table_type table_type,
396 399
397 /* Get the table length */ 400 /* Get the table length */
398 401
399 if (table_type == ACPI_TABLE_RSDP) { 402 if (table_type == ACPI_TABLE_ID_RSDP) {
403
400 /* RSD PTR is the only "table" without a header */ 404 /* RSD PTR is the only "table" without a header */
401 405
402 table_length = sizeof(struct rsdp_descriptor); 406 table_length = sizeof(struct rsdp_descriptor);
@@ -417,4 +421,4 @@ acpi_get_table(acpi_table_type table_type,
417 return_ACPI_STATUS(AE_OK); 421 return_ACPI_STATUS(AE_OK);
418} 422}
419 423
420EXPORT_SYMBOL(acpi_get_table); 424ACPI_EXPORT_SYMBOL(acpi_get_table)
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index a62db6af83c9..da2648bbdbc0 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -41,8 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/module.h>
45
46#include <acpi/acpi.h> 44#include <acpi/acpi.h>
47#include <acpi/actables.h> 45#include <acpi/actables.h>
48 46
@@ -75,6 +73,7 @@ acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
75 * The signature and checksum must both be correct 73 * The signature and checksum must both be correct
76 */ 74 */
77 if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) { 75 if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) {
76
78 /* Nope, BAD Signature */ 77 /* Nope, BAD Signature */
79 78
80 return (AE_BAD_SIGNATURE); 79 return (AE_BAD_SIGNATURE);
@@ -82,15 +81,14 @@ acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
82 81
83 /* Check the standard checksum */ 82 /* Check the standard checksum */
84 83
85 if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { 84 if (acpi_tb_sum_table(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
86 return (AE_BAD_CHECKSUM); 85 return (AE_BAD_CHECKSUM);
87 } 86 }
88 87
89 /* Check extended checksum if table version >= 2 */ 88 /* Check extended checksum if table version >= 2 */
90 89
91 if ((rsdp->revision >= 2) && 90 if ((rsdp->revision >= 2) &&
92 (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 91 (acpi_tb_sum_table(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
93 0)) {
94 return (AE_BAD_CHECKSUM); 92 return (AE_BAD_CHECKSUM);
95 } 93 }
96 94
@@ -121,7 +119,7 @@ acpi_tb_find_table(char *signature,
121 acpi_status status; 119 acpi_status status;
122 struct acpi_table_header *table; 120 struct acpi_table_header *table;
123 121
124 ACPI_FUNCTION_TRACE("tb_find_table"); 122 ACPI_FUNCTION_TRACE(tb_find_table);
125 123
126 /* Validate string lengths */ 124 /* Validate string lengths */
127 125
@@ -131,7 +129,7 @@ acpi_tb_find_table(char *signature,
131 return_ACPI_STATUS(AE_AML_STRING_LIMIT); 129 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
132 } 130 }
133 131
134 if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) { 132 if (ACPI_COMPARE_NAME(signature, DSDT_SIG)) {
135 /* 133 /*
136 * The DSDT pointer is contained in the FADT, not the RSDT. 134 * The DSDT pointer is contained in the FADT, not the RSDT.
137 * This code should suffice, because the only code that would perform 135 * This code should suffice, because the only code that would perform
@@ -156,10 +154,12 @@ acpi_tb_find_table(char *signature,
156 154
157 /* Check oem_id and oem_table_id */ 155 /* Check oem_id and oem_table_id */
158 156
159 if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id, 157 if ((oem_id[0] &&
160 sizeof(table->oem_id))) || 158 ACPI_STRNCMP(oem_id, table->oem_id,
161 (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id, 159 sizeof(table->oem_id))) ||
162 sizeof(table->oem_table_id)))) { 160 (oem_table_id[0] &&
161 ACPI_STRNCMP(oem_table_id, table->oem_table_id,
162 sizeof(table->oem_table_id)))) {
163 return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND); 163 return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
164 } 164 }
165 165
@@ -203,7 +203,7 @@ acpi_get_firmware_table(acpi_string signature,
203 u32 i; 203 u32 i;
204 u32 j; 204 u32 j;
205 205
206 ACPI_FUNCTION_TRACE("acpi_get_firmware_table"); 206 ACPI_FUNCTION_TRACE(acpi_get_firmware_table);
207 207
208 /* 208 /*
209 * Ensure that at least the table manager is initialized. We don't 209 * Ensure that at least the table manager is initialized. We don't
@@ -217,6 +217,7 @@ acpi_get_firmware_table(acpi_string signature,
217 /* Ensure that we have a RSDP */ 217 /* Ensure that we have a RSDP */
218 218
219 if (!acpi_gbl_RSDP) { 219 if (!acpi_gbl_RSDP) {
220
220 /* Get the RSDP */ 221 /* Get the RSDP */
221 222
222 status = acpi_os_get_root_pointer(flags, &address); 223 status = acpi_os_get_root_pointer(flags, &address);
@@ -261,7 +262,7 @@ acpi_get_firmware_table(acpi_string signature,
261 262
262 /* Get and validate the RSDT */ 263 /* Get and validate the RSDT */
263 264
264 rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); 265 rsdt_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_table_desc));
265 if (!rsdt_info) { 266 if (!rsdt_info) {
266 return_ACPI_STATUS(AE_NO_MEMORY); 267 return_ACPI_STATUS(AE_NO_MEMORY);
267 } 268 }
@@ -278,13 +279,13 @@ acpi_get_firmware_table(acpi_string signature,
278 279
279 /* Allocate a scratch table header and table descriptor */ 280 /* Allocate a scratch table header and table descriptor */
280 281
281 header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header)); 282 header = ACPI_ALLOCATE(sizeof(struct acpi_table_header));
282 if (!header) { 283 if (!header) {
283 status = AE_NO_MEMORY; 284 status = AE_NO_MEMORY;
284 goto cleanup; 285 goto cleanup;
285 } 286 }
286 287
287 table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc)); 288 table_info = ACPI_ALLOCATE(sizeof(struct acpi_table_desc));
288 if (!table_info) { 289 if (!table_info) {
289 status = AE_NO_MEMORY; 290 status = AE_NO_MEMORY;
290 goto cleanup; 291 goto cleanup;
@@ -308,12 +309,12 @@ acpi_get_firmware_table(acpi_string signature,
308 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 309 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
309 address.pointer.value = 310 address.pointer.value =
310 (ACPI_CAST_PTR 311 (ACPI_CAST_PTR
311 (RSDT_DESCRIPTOR, 312 (struct rsdt_descriptor,
312 rsdt_info->pointer))->table_offset_entry[i]; 313 rsdt_info->pointer))->table_offset_entry[i];
313 } else { 314 } else {
314 address.pointer.value = 315 address.pointer.value =
315 (ACPI_CAST_PTR 316 (ACPI_CAST_PTR
316 (XSDT_DESCRIPTOR, 317 (struct xsdt_descriptor,
317 rsdt_info->pointer))->table_offset_entry[i]; 318 rsdt_info->pointer))->table_offset_entry[i];
318 } 319 }
319 320
@@ -326,11 +327,13 @@ acpi_get_firmware_table(acpi_string signature,
326 327
327 /* Compare table signatures and table instance */ 328 /* Compare table signatures and table instance */
328 329
329 if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) { 330 if (ACPI_COMPARE_NAME(header->signature, signature)) {
331
330 /* An instance of the table was found */ 332 /* An instance of the table was found */
331 333
332 j++; 334 j++;
333 if (j >= instance) { 335 if (j >= instance) {
336
334 /* Found the correct instance, get the entire table */ 337 /* Found the correct instance, get the entire table */
335 338
336 status = 339 status =
@@ -355,23 +358,21 @@ acpi_get_firmware_table(acpi_string signature,
355 acpi_os_unmap_memory(rsdt_info->pointer, 358 acpi_os_unmap_memory(rsdt_info->pointer,
356 (acpi_size) rsdt_info->pointer->length); 359 (acpi_size) rsdt_info->pointer->length);
357 } 360 }
358 ACPI_MEM_FREE(rsdt_info); 361 ACPI_FREE(rsdt_info);
359 362
360 if (header) { 363 if (header) {
361 ACPI_MEM_FREE(header); 364 ACPI_FREE(header);
362 } 365 }
363 if (table_info) { 366 if (table_info) {
364 ACPI_MEM_FREE(table_info); 367 ACPI_FREE(table_info);
365 } 368 }
366 return_ACPI_STATUS(status); 369 return_ACPI_STATUS(status);
367} 370}
368 371
369EXPORT_SYMBOL(acpi_get_firmware_table); 372ACPI_EXPORT_SYMBOL(acpi_get_firmware_table)
370 373
371/* TBD: Move to a new file */ 374/* TBD: Move to a new file */
372
373#if ACPI_MACHINE_WIDTH != 16 375#if ACPI_MACHINE_WIDTH != 16
374
375/******************************************************************************* 376/*******************************************************************************
376 * 377 *
377 * FUNCTION: acpi_find_root_pointer 378 * FUNCTION: acpi_find_root_pointer
@@ -384,13 +385,12 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
384 * DESCRIPTION: Find the RSDP 385 * DESCRIPTION: Find the RSDP
385 * 386 *
386 ******************************************************************************/ 387 ******************************************************************************/
387
388acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) 388acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
389{ 389{
390 struct acpi_table_desc table_info; 390 struct acpi_table_desc table_info;
391 acpi_status status; 391 acpi_status status;
392 392
393 ACPI_FUNCTION_TRACE("acpi_find_root_pointer"); 393 ACPI_FUNCTION_TRACE(acpi_find_root_pointer);
394 394
395 /* Get the RSDP */ 395 /* Get the RSDP */
396 396
@@ -407,6 +407,8 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
407 return_ACPI_STATUS(AE_OK); 407 return_ACPI_STATUS(AE_OK);
408} 408}
409 409
410ACPI_EXPORT_SYMBOL(acpi_find_root_pointer)
411
410/******************************************************************************* 412/*******************************************************************************
411 * 413 *
412 * FUNCTION: acpi_tb_scan_memory_for_rsdp 414 * FUNCTION: acpi_tb_scan_memory_for_rsdp
@@ -419,14 +421,13 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
419 * DESCRIPTION: Search a block of memory for the RSDP signature 421 * DESCRIPTION: Search a block of memory for the RSDP signature
420 * 422 *
421 ******************************************************************************/ 423 ******************************************************************************/
422
423static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) 424static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
424{ 425{
425 acpi_status status; 426 acpi_status status;
426 u8 *mem_rover; 427 u8 *mem_rover;
427 u8 *end_address; 428 u8 *end_address;
428 429
429 ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp"); 430 ACPI_FUNCTION_TRACE(tb_scan_memory_for_rsdp);
430 431
431 end_address = start_address + length; 432 end_address = start_address + length;
432 433
@@ -434,12 +435,14 @@ static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
434 435
435 for (mem_rover = start_address; mem_rover < end_address; 436 for (mem_rover = start_address; mem_rover < end_address;
436 mem_rover += ACPI_RSDP_SCAN_STEP) { 437 mem_rover += ACPI_RSDP_SCAN_STEP) {
438
437 /* The RSDP signature and checksum must both be correct */ 439 /* The RSDP signature and checksum must both be correct */
438 440
439 status = 441 status =
440 acpi_tb_validate_rsdp(ACPI_CAST_PTR 442 acpi_tb_validate_rsdp(ACPI_CAST_PTR
441 (struct rsdp_descriptor, mem_rover)); 443 (struct rsdp_descriptor, mem_rover));
442 if (ACPI_SUCCESS(status)) { 444 if (ACPI_SUCCESS(status)) {
445
443 /* Sig and checksum valid, we have found a real RSDP */ 446 /* Sig and checksum valid, we have found a real RSDP */
444 447
445 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 448 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -469,10 +472,10 @@ static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
469 * 472 *
470 * RETURN: Status, RSDP physical address 473 * RETURN: Status, RSDP physical address
471 * 474 *
472 * DESCRIPTION: search lower 1_mbyte of memory for the root system descriptor 475 * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
473 * pointer structure. If it is found, set *RSDP to point to it. 476 * pointer structure. If it is found, set *RSDP to point to it.
474 * 477 *
475 * NOTE1: The RSDp must be either in the first 1_k of the Extended 478 * NOTE1: The RSDP must be either in the first 1_k of the Extended
476 * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) 479 * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
477 * Only a 32-bit physical address is necessary. 480 * Only a 32-bit physical address is necessary.
478 * 481 *
@@ -489,12 +492,13 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
489 u32 physical_address; 492 u32 physical_address;
490 acpi_status status; 493 acpi_status status;
491 494
492 ACPI_FUNCTION_TRACE("tb_find_rsdp"); 495 ACPI_FUNCTION_TRACE(tb_find_rsdp);
493 496
494 /* 497 /*
495 * Scan supports either logical addressing or physical addressing 498 * Scan supports either logical addressing or physical addressing
496 */ 499 */
497 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 500 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
501
498 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ 502 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
499 503
500 status = acpi_os_map_memory((acpi_physical_address) 504 status = acpi_os_map_memory((acpi_physical_address)
@@ -521,7 +525,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
521 525
522 if (physical_address > 0x400) { 526 if (physical_address > 0x400) {
523 /* 527 /*
524 * 1b) Search EBDA paragraphs (EBDa is required to be a 528 * 1b) Search EBDA paragraphs (EBDA is required to be a
525 * minimum of 1_k length) 529 * minimum of 1_k length)
526 */ 530 */
527 status = acpi_os_map_memory((acpi_physical_address) 531 status = acpi_os_map_memory((acpi_physical_address)
@@ -542,10 +546,11 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
542 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); 546 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
543 547
544 if (mem_rover) { 548 if (mem_rover) {
549
545 /* Return the physical address */ 550 /* Return the physical address */
546 551
547 physical_address += 552 physical_address +=
548 ACPI_PTR_DIFF(mem_rover, table_ptr); 553 (u32) ACPI_PTR_DIFF(mem_rover, table_ptr);
549 554
550 table_info->physical_address = 555 table_info->physical_address =
551 (acpi_physical_address) physical_address; 556 (acpi_physical_address) physical_address;
@@ -576,11 +581,12 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
576 acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 581 acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
577 582
578 if (mem_rover) { 583 if (mem_rover) {
584
579 /* Return the physical address */ 585 /* Return the physical address */
580 586
581 physical_address = 587 physical_address = (u32)
582 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover, 588 (ACPI_HI_RSDP_WINDOW_BASE +
583 table_ptr); 589 ACPI_PTR_DIFF(mem_rover, table_ptr));
584 590
585 table_info->physical_address = 591 table_info->physical_address =
586 (acpi_physical_address) physical_address; 592 (acpi_physical_address) physical_address;
@@ -601,7 +607,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
601 607
602 if (physical_address > 0x400) { 608 if (physical_address > 0x400) {
603 /* 609 /*
604 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 610 * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of
605 * 1_k length) 611 * 1_k length)
606 */ 612 */
607 mem_rover = 613 mem_rover =
@@ -609,6 +615,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
609 (physical_address), 615 (physical_address),
610 ACPI_EBDA_WINDOW_SIZE); 616 ACPI_EBDA_WINDOW_SIZE);
611 if (mem_rover) { 617 if (mem_rover) {
618
612 /* Return the physical address */ 619 /* Return the physical address */
613 620
614 table_info->physical_address = 621 table_info->physical_address =
@@ -624,6 +631,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
624 (ACPI_HI_RSDP_WINDOW_BASE), 631 (ACPI_HI_RSDP_WINDOW_BASE),
625 ACPI_HI_RSDP_WINDOW_SIZE); 632 ACPI_HI_RSDP_WINDOW_SIZE);
626 if (mem_rover) { 633 if (mem_rover) {
634
627 /* Found it, return the physical address */ 635 /* Found it, return the physical address */
628 636
629 table_info->physical_address = 637 table_info->physical_address =