aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables')
-rw-r--r--drivers/acpi/tables/tbconvrt.c408
-rw-r--r--drivers/acpi/tables/tbget.c275
-rw-r--r--drivers/acpi/tables/tbgetall.c189
-rw-r--r--drivers/acpi/tables/tbinstal.c264
-rw-r--r--drivers/acpi/tables/tbrsdt.c231
-rw-r--r--drivers/acpi/tables/tbutils.c178
-rw-r--r--drivers/acpi/tables/tbxface.c253
-rw-r--r--drivers/acpi/tables/tbxfroot.c513
8 files changed, 1110 insertions, 1201 deletions
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 92e0c31539be..a03939399fa9 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -46,28 +46,22 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/actables.h> 47#include <acpi/actables.h>
48 48
49
50#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbconvrt") 50ACPI_MODULE_NAME("tbconvrt")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static void 53static void
56acpi_tb_init_generic_address ( 54acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
57 struct acpi_generic_address *new_gas_struct, 55 u8 register_bit_width,
58 u8 register_bit_width, 56 acpi_physical_address address);
59 acpi_physical_address address);
60 57
61static void 58static void
62acpi_tb_convert_fadt1 ( 59acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
63 struct fadt_descriptor_rev2 *local_fadt, 60 struct fadt_descriptor_rev1 *original_fadt);
64 struct fadt_descriptor_rev1 *original_fadt);
65 61
66static void 62static void
67acpi_tb_convert_fadt2 ( 63acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
68 struct fadt_descriptor_rev2 *local_fadt, 64 struct fadt_descriptor_rev2 *original_fadt);
69 struct fadt_descriptor_rev2 *original_fadt);
70
71 65
72u8 acpi_fadt_is_v1; 66u8 acpi_fadt_is_v1;
73EXPORT_SYMBOL(acpi_fadt_is_v1); 67EXPORT_SYMBOL(acpi_fadt_is_v1);
@@ -87,21 +81,19 @@ EXPORT_SYMBOL(acpi_fadt_is_v1);
87 ******************************************************************************/ 81 ******************************************************************************/
88 82
89u32 83u32
90acpi_tb_get_table_count ( 84acpi_tb_get_table_count(struct rsdp_descriptor *RSDP,
91 struct rsdp_descriptor *RSDP, 85 struct acpi_table_header *RSDT)
92 struct acpi_table_header *RSDT)
93{ 86{
94 u32 pointer_size; 87 u32 pointer_size;
95 88
89 ACPI_FUNCTION_ENTRY();
96 90
97 ACPI_FUNCTION_ENTRY (); 91 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
98 92
99 93 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
100 if (RSDP->revision < 2) { 94 pointer_size = sizeof(u32);
101 pointer_size = sizeof (u32); 95 } else {
102 } 96 pointer_size = sizeof(u64);
103 else {
104 pointer_size = sizeof (u64);
105 } 97 }
106 98
107 /* 99 /*
@@ -110,10 +102,10 @@ acpi_tb_get_table_count (
110 * pointers contained within the RSDT/XSDT. The size of the pointers 102 * pointers contained within the RSDT/XSDT. The size of the pointers
111 * is architecture-dependent. 103 * is architecture-dependent.
112 */ 104 */
113 return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size); 105 return ((RSDT->length -
106 sizeof(struct acpi_table_header)) / pointer_size);
114} 107}
115 108
116
117/******************************************************************************* 109/*******************************************************************************
118 * 110 *
119 * FUNCTION: acpi_tb_convert_to_xsdt 111 * FUNCTION: acpi_tb_convert_to_xsdt
@@ -126,64 +118,65 @@ acpi_tb_get_table_count (
126 * 118 *
127 ******************************************************************************/ 119 ******************************************************************************/
128 120
129acpi_status 121acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
130acpi_tb_convert_to_xsdt (
131 struct acpi_table_desc *table_info)
132{ 122{
133 acpi_size table_size; 123 acpi_size table_size;
134 u32 i; 124 u32 i;
135 XSDT_DESCRIPTOR *new_table; 125 XSDT_DESCRIPTOR *new_table;
136
137
138 ACPI_FUNCTION_ENTRY ();
139 126
127 ACPI_FUNCTION_ENTRY();
140 128
141 /* Compute size of the converted XSDT */ 129 /* Compute size of the converted XSDT */
142 130
143 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) + 131 table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) +
144 sizeof (struct acpi_table_header); 132 sizeof(struct acpi_table_header);
145 133
146 /* Allocate an XSDT */ 134 /* Allocate an XSDT */
147 135
148 new_table = ACPI_MEM_CALLOCATE (table_size); 136 new_table = ACPI_MEM_CALLOCATE(table_size);
149 if (!new_table) { 137 if (!new_table) {
150 return (AE_NO_MEMORY); 138 return (AE_NO_MEMORY);
151 } 139 }
152 140
153 /* Copy the header and set the length */ 141 /* Copy the header and set the length */
154 142
155 ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header)); 143 ACPI_MEMCPY(new_table, table_info->pointer,
144 sizeof(struct acpi_table_header));
156 new_table->length = (u32) table_size; 145 new_table->length = (u32) table_size;
157 146
158 /* Copy the table pointers */ 147 /* Copy the table pointers */
159 148
160 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 149 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
161 if (acpi_gbl_RSDP->revision < 2) { 150 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
162 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], 151
163 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, 152 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
164 table_info->pointer))->table_offset_entry[i]); 153 ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
165 } 154 (ACPI_CAST_PTR
166 else { 155 (struct rsdt_descriptor_rev1,
156 table_info->pointer))->
157 table_offset_entry[i]);
158 } else {
167 new_table->table_offset_entry[i] = 159 new_table->table_offset_entry[i] =
168 (ACPI_CAST_PTR (XSDT_DESCRIPTOR, 160 (ACPI_CAST_PTR(XSDT_DESCRIPTOR,
169 table_info->pointer))->table_offset_entry[i]; 161 table_info->pointer))->
162 table_offset_entry[i];
170 } 163 }
171 } 164 }
172 165
173 /* Delete the original table (either mapped or in a buffer) */ 166 /* Delete the original table (either mapped or in a buffer) */
174 167
175 acpi_tb_delete_single_table (table_info); 168 acpi_tb_delete_single_table(table_info);
176 169
177 /* Point the table descriptor to the new table */ 170 /* Point the table descriptor to the new table */
178 171
179 table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table); 172 table_info->pointer =
180 table_info->length = table_size; 173 ACPI_CAST_PTR(struct acpi_table_header, new_table);
181 table_info->allocation = ACPI_MEM_ALLOCATED; 174 table_info->length = table_size;
175 table_info->allocation = ACPI_MEM_ALLOCATED;
182 176
183 return (AE_OK); 177 return (AE_OK);
184} 178}
185 179
186
187/******************************************************************************* 180/*******************************************************************************
188 * 181 *
189 * FUNCTION: acpi_tb_init_generic_address 182 * FUNCTION: acpi_tb_init_generic_address
@@ -199,21 +192,19 @@ acpi_tb_convert_to_xsdt (
199 ******************************************************************************/ 192 ******************************************************************************/
200 193
201static void 194static void
202acpi_tb_init_generic_address ( 195acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
203 struct acpi_generic_address *new_gas_struct, 196 u8 register_bit_width,
204 u8 register_bit_width, 197 acpi_physical_address address)
205 acpi_physical_address address)
206{ 198{
207 199
208 ACPI_STORE_ADDRESS (new_gas_struct->address, address); 200 ACPI_STORE_ADDRESS(new_gas_struct->address, address);
209 201
210 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 202 new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
211 new_gas_struct->register_bit_width = register_bit_width; 203 new_gas_struct->register_bit_width = register_bit_width;
212 new_gas_struct->register_bit_offset = 0; 204 new_gas_struct->register_bit_offset = 0;
213 new_gas_struct->access_width = 0; 205 new_gas_struct->access_width = 0;
214} 206}
215 207
216
217/******************************************************************************* 208/*******************************************************************************
218 * 209 *
219 * FUNCTION: acpi_tb_convert_fadt1 210 * FUNCTION: acpi_tb_convert_fadt1
@@ -228,9 +219,8 @@ acpi_tb_init_generic_address (
228 ******************************************************************************/ 219 ******************************************************************************/
229 220
230static void 221static void
231acpi_tb_convert_fadt1 ( 222acpi_tb_convert_fadt1(struct fadt_descriptor_rev2 *local_fadt,
232 struct fadt_descriptor_rev2 *local_fadt, 223 struct fadt_descriptor_rev1 *original_fadt)
233 struct fadt_descriptor_rev1 *original_fadt)
234{ 224{
235 225
236 /* ACPI 1.0 FACS */ 226 /* ACPI 1.0 FACS */
@@ -243,12 +233,14 @@ acpi_tb_convert_fadt1 (
243 * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 233 * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
244 * table can be copied first, then expand some fields to 64 bits. 234 * table can be copied first, then expand some fields to 64 bits.
245 */ 235 */
246 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1)); 236 ACPI_MEMCPY(local_fadt, original_fadt,
237 sizeof(struct fadt_descriptor_rev1));
247 238
248 /* Convert table pointers to 64-bit fields */ 239 /* Convert table pointers to 64-bit fields */
249 240
250 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); 241 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
251 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 242 local_fadt->V1_firmware_ctrl);
243 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
252 244
253 /* 245 /*
254 * System Interrupt Model isn't used in ACPI 2.0 246 * System Interrupt Model isn't used in ACPI 2.0
@@ -283,17 +275,17 @@ acpi_tb_convert_fadt1 (
283 * It primarily adds the FADT reset mechanism. 275 * It primarily adds the FADT reset mechanism.
284 */ 276 */
285 if ((original_fadt->revision == 2) && 277 if ((original_fadt->revision == 2) &&
286 (original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) { 278 (original_fadt->length ==
279 sizeof(struct fadt_descriptor_rev2_minus))) {
287 /* 280 /*
288 * Grab the entire generic address struct, plus the 1-byte reset value 281 * Grab the entire generic address struct, plus the 1-byte reset value
289 * that immediately follows. 282 * that immediately follows.
290 */ 283 */
291 ACPI_MEMCPY (&local_fadt->reset_register, 284 ACPI_MEMCPY(&local_fadt->reset_register,
292 &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, 285 &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus,
293 original_fadt))->reset_register, 286 original_fadt))->reset_register,
294 sizeof (struct acpi_generic_address) + 1); 287 sizeof(struct acpi_generic_address) + 1);
295 } 288 } else {
296 else {
297 /* 289 /*
298 * Since there isn't any equivalence in 1.0 and since it is highly 290 * Since there isn't any equivalence in 1.0 and since it is highly
299 * likely that a 1.0 system has legacy support. 291 * likely that a 1.0 system has legacy support.
@@ -304,43 +296,60 @@ acpi_tb_convert_fadt1 (
304 /* 296 /*
305 * Convert the V1.0 block addresses to V2.0 GAS structures 297 * Convert the V1.0 block addresses to V2.0 GAS structures
306 */ 298 */
307 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len, 299 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
308 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 300 local_fadt->pm1_evt_len,
309 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len, 301 (acpi_physical_address) local_fadt->
310 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 302 V1_pm1a_evt_blk);
311 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len, 303 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
312 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 304 local_fadt->pm1_evt_len,
313 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len, 305 (acpi_physical_address) local_fadt->
314 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 306 V1_pm1b_evt_blk);
315 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len, 307 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
316 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 308 local_fadt->pm1_cnt_len,
317 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len, 309 (acpi_physical_address) local_fadt->
318 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 310 V1_pm1a_cnt_blk);
319 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0, 311 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
320 (acpi_physical_address) local_fadt->V1_gpe0_blk); 312 local_fadt->pm1_cnt_len,
321 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0, 313 (acpi_physical_address) local_fadt->
322 (acpi_physical_address) local_fadt->V1_gpe1_blk); 314 V1_pm1b_cnt_blk);
315 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
316 local_fadt->pm2_cnt_len,
317 (acpi_physical_address) local_fadt->
318 V1_pm2_cnt_blk);
319 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
320 local_fadt->pm_tm_len,
321 (acpi_physical_address) local_fadt->
322 V1_pm_tmr_blk);
323 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, 0,
324 (acpi_physical_address) local_fadt->
325 V1_gpe0_blk);
326 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, 0,
327 (acpi_physical_address) local_fadt->
328 V1_gpe1_blk);
323 329
324 /* Create separate GAS structs for the PM1 Enable registers */ 330 /* Create separate GAS structs for the PM1 Enable registers */
325 331
326 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 332 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
327 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 333 (u8) ACPI_DIV_2(acpi_gbl_FADT->
328 (acpi_physical_address) 334 pm1_evt_len),
329 (local_fadt->xpm1a_evt_blk.address + 335 (acpi_physical_address)
330 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 336 (local_fadt->xpm1a_evt_blk.address +
337 ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
331 338
332 /* PM1B is optional; leave null if not present */ 339 /* PM1B is optional; leave null if not present */
333 340
334 if (local_fadt->xpm1b_evt_blk.address) { 341 if (local_fadt->xpm1b_evt_blk.address) {
335 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 342 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
336 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 343 (u8) ACPI_DIV_2(acpi_gbl_FADT->
337 (acpi_physical_address) 344 pm1_evt_len),
338 (local_fadt->xpm1b_evt_blk.address + 345 (acpi_physical_address)
339 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 346 (local_fadt->xpm1b_evt_blk.
347 address +
348 ACPI_DIV_2(acpi_gbl_FADT->
349 pm1_evt_len)));
340 } 350 }
341} 351}
342 352
343
344/******************************************************************************* 353/*******************************************************************************
345 * 354 *
346 * FUNCTION: acpi_tb_convert_fadt2 355 * FUNCTION: acpi_tb_convert_fadt2
@@ -356,14 +365,14 @@ acpi_tb_convert_fadt1 (
356 ******************************************************************************/ 365 ******************************************************************************/
357 366
358static void 367static void
359acpi_tb_convert_fadt2 ( 368acpi_tb_convert_fadt2(struct fadt_descriptor_rev2 *local_fadt,
360 struct fadt_descriptor_rev2 *local_fadt, 369 struct fadt_descriptor_rev2 *original_fadt)
361 struct fadt_descriptor_rev2 *original_fadt)
362{ 370{
363 371
364 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ 372 /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
365 373
366 ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2)); 374 ACPI_MEMCPY(local_fadt, original_fadt,
375 sizeof(struct fadt_descriptor_rev2));
367 376
368 /* 377 /*
369 * "X" fields are optional extensions to the original V1.0 fields, so 378 * "X" fields are optional extensions to the original V1.0 fields, so
@@ -371,86 +380,99 @@ acpi_tb_convert_fadt2 (
371 * is zero. 380 * is zero.
372 */ 381 */
373 if (!(local_fadt->xfirmware_ctrl)) { 382 if (!(local_fadt->xfirmware_ctrl)) {
374 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, 383 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
375 local_fadt->V1_firmware_ctrl); 384 local_fadt->V1_firmware_ctrl);
376 } 385 }
377 386
378 if (!(local_fadt->Xdsdt)) { 387 if (!(local_fadt->Xdsdt)) {
379 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 388 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
380 } 389 }
381 390
382 if (!(local_fadt->xpm1a_evt_blk.address)) { 391 if (!(local_fadt->xpm1a_evt_blk.address)) {
383 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, 392 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
384 local_fadt->pm1_evt_len, 393 local_fadt->pm1_evt_len,
385 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 394 (acpi_physical_address)
395 local_fadt->V1_pm1a_evt_blk);
386 } 396 }
387 397
388 if (!(local_fadt->xpm1b_evt_blk.address)) { 398 if (!(local_fadt->xpm1b_evt_blk.address)) {
389 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, 399 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
390 local_fadt->pm1_evt_len, 400 local_fadt->pm1_evt_len,
391 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 401 (acpi_physical_address)
402 local_fadt->V1_pm1b_evt_blk);
392 } 403 }
393 404
394 if (!(local_fadt->xpm1a_cnt_blk.address)) { 405 if (!(local_fadt->xpm1a_cnt_blk.address)) {
395 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, 406 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
396 local_fadt->pm1_cnt_len, 407 local_fadt->pm1_cnt_len,
397 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 408 (acpi_physical_address)
409 local_fadt->V1_pm1a_cnt_blk);
398 } 410 }
399 411
400 if (!(local_fadt->xpm1b_cnt_blk.address)) { 412 if (!(local_fadt->xpm1b_cnt_blk.address)) {
401 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, 413 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
402 local_fadt->pm1_cnt_len, 414 local_fadt->pm1_cnt_len,
403 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 415 (acpi_physical_address)
416 local_fadt->V1_pm1b_cnt_blk);
404 } 417 }
405 418
406 if (!(local_fadt->xpm2_cnt_blk.address)) { 419 if (!(local_fadt->xpm2_cnt_blk.address)) {
407 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, 420 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
408 local_fadt->pm2_cnt_len, 421 local_fadt->pm2_cnt_len,
409 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 422 (acpi_physical_address)
423 local_fadt->V1_pm2_cnt_blk);
410 } 424 }
411 425
412 if (!(local_fadt->xpm_tmr_blk.address)) { 426 if (!(local_fadt->xpm_tmr_blk.address)) {
413 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, 427 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
414 local_fadt->pm_tm_len, 428 local_fadt->pm_tm_len,
415 (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 429 (acpi_physical_address)
430 local_fadt->V1_pm_tmr_blk);
416 } 431 }
417 432
418 if (!(local_fadt->xgpe0_blk.address)) { 433 if (!(local_fadt->xgpe0_blk.address)) {
419 acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 434 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk,
420 0, (acpi_physical_address) local_fadt->V1_gpe0_blk); 435 0,
436 (acpi_physical_address)
437 local_fadt->V1_gpe0_blk);
421 } 438 }
422 439
423 if (!(local_fadt->xgpe1_blk.address)) { 440 if (!(local_fadt->xgpe1_blk.address)) {
424 acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 441 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk,
425 0, (acpi_physical_address) local_fadt->V1_gpe1_blk); 442 0,
443 (acpi_physical_address)
444 local_fadt->V1_gpe1_blk);
426 } 445 }
427 446
428 /* Create separate GAS structs for the PM1 Enable registers */ 447 /* Create separate GAS structs for the PM1 Enable registers */
429 448
430 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 449 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
431 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 450 (u8) ACPI_DIV_2(acpi_gbl_FADT->
432 (acpi_physical_address) 451 pm1_evt_len),
433 (local_fadt->xpm1a_evt_blk.address + 452 (acpi_physical_address)
434 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 453 (local_fadt->xpm1a_evt_blk.address +
454 ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
435 455
436 acpi_gbl_xpm1a_enable.address_space_id = 456 acpi_gbl_xpm1a_enable.address_space_id =
437 local_fadt->xpm1a_evt_blk.address_space_id; 457 local_fadt->xpm1a_evt_blk.address_space_id;
438 458
439 /* PM1B is optional; leave null if not present */ 459 /* PM1B is optional; leave null if not present */
440 460
441 if (local_fadt->xpm1b_evt_blk.address) { 461 if (local_fadt->xpm1b_evt_blk.address) {
442 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 462 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
443 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 463 (u8) ACPI_DIV_2(acpi_gbl_FADT->
444 (acpi_physical_address) 464 pm1_evt_len),
445 (local_fadt->xpm1b_evt_blk.address + 465 (acpi_physical_address)
446 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 466 (local_fadt->xpm1b_evt_blk.
467 address +
468 ACPI_DIV_2(acpi_gbl_FADT->
469 pm1_evt_len)));
447 470
448 acpi_gbl_xpm1b_enable.address_space_id = 471 acpi_gbl_xpm1b_enable.address_space_id =
449 local_fadt->xpm1b_evt_blk.address_space_id; 472 local_fadt->xpm1b_evt_blk.address_space_id;
450 } 473 }
451} 474}
452 475
453
454/******************************************************************************* 476/*******************************************************************************
455 * 477 *
456 * FUNCTION: acpi_tb_convert_table_fadt 478 * FUNCTION: acpi_tb_convert_table_fadt
@@ -467,83 +489,76 @@ acpi_tb_convert_fadt2 (
467 * 489 *
468 ******************************************************************************/ 490 ******************************************************************************/
469 491
470acpi_status 492acpi_status acpi_tb_convert_table_fadt(void)
471acpi_tb_convert_table_fadt (
472 void)
473{ 493{
474 struct fadt_descriptor_rev2 *local_fadt; 494 struct fadt_descriptor_rev2 *local_fadt;
475 struct acpi_table_desc *table_desc; 495 struct acpi_table_desc *table_desc;
476
477
478 ACPI_FUNCTION_TRACE ("tb_convert_table_fadt");
479 496
497 ACPI_FUNCTION_TRACE("tb_convert_table_fadt");
480 498
481 /* 499 /*
482 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be 500 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
483 * at least as long as the version 1.0 FADT 501 * at least as long as the version 1.0 FADT
484 */ 502 */
485 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { 503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
486 ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", 504 ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n",
487 acpi_gbl_FADT->length)); 505 acpi_gbl_FADT->length));
488 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
489 } 507 }
490 508
491 /* Allocate buffer for the ACPI 2.0(+) FADT */ 509 /* Allocate buffer for the ACPI 2.0(+) FADT */
492 510
493 local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2)); 511 local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2));
494 if (!local_fadt) { 512 if (!local_fadt) {
495 return_ACPI_STATUS (AE_NO_MEMORY); 513 return_ACPI_STATUS(AE_NO_MEMORY);
496 } 514 }
497 515
498 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { 516 if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
499 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { 517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) {
500 /* Length is too short to be a V2.0 table */ 518 /* Length is too short to be a V2.0 table */
501 519
502 ACPI_REPORT_WARNING (( 520 ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
503 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
504 acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
505 521
506 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 522 acpi_tb_convert_fadt1(local_fadt,
507 } 523 (void *)acpi_gbl_FADT);
508 else { 524 } else {
509 /* Valid V2.0 table */ 525 /* Valid V2.0 table */
510 526
511 acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT); 527 acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT);
512 } 528 }
513 } 529 } else {
514 else {
515 /* Valid V1.0 table */ 530 /* Valid V1.0 table */
516 531
517 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 532 acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT);
518 } 533 }
519 534
520 /* Global FADT pointer will point to the new common V2.0 FADT */ 535 /* Global FADT pointer will point to the new common V2.0 FADT */
521 536
522 acpi_gbl_FADT = local_fadt; 537 acpi_gbl_FADT = local_fadt;
523 acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); 538 acpi_gbl_FADT->length = sizeof(FADT_DESCRIPTOR);
524 539
525 /* Free the original table */ 540 /* Free the original table */
526 541
527 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; 542 table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next;
528 acpi_tb_delete_single_table (table_desc); 543 acpi_tb_delete_single_table(table_desc);
529 544
530 /* Install the new table */ 545 /* Install the new table */
531 546
532 table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT); 547 table_desc->pointer =
533 table_desc->allocation = ACPI_MEM_ALLOCATED; 548 ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
534 table_desc->length = sizeof (struct fadt_descriptor_rev2); 549 table_desc->allocation = ACPI_MEM_ALLOCATED;
550 table_desc->length = sizeof(struct fadt_descriptor_rev2);
535 551
536 /* Dump the entire FADT */ 552 /* Dump the entire FADT */
537 553
538 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
539 "Hex dump of common internal FADT, size %d (%X)\n", 555 "Hex dump of common internal FADT, size %d (%X)\n",
540 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 556 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
541 ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length);
542 558
543 return_ACPI_STATUS (AE_OK); 559 return_ACPI_STATUS(AE_OK);
544} 560}
545 561
546
547/******************************************************************************* 562/*******************************************************************************
548 * 563 *
549 * FUNCTION: acpi_tb_build_common_facs 564 * FUNCTION: acpi_tb_build_common_facs
@@ -557,26 +572,21 @@ acpi_tb_convert_table_fadt (
557 * 572 *
558 ******************************************************************************/ 573 ******************************************************************************/
559 574
560acpi_status 575acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
561acpi_tb_build_common_facs (
562 struct acpi_table_desc *table_info)
563{ 576{
564 577
565 ACPI_FUNCTION_TRACE ("tb_build_common_facs"); 578 ACPI_FUNCTION_TRACE("tb_build_common_facs");
566
567 579
568 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 580 /* Absolute minimum length is 24, but the ACPI spec says 64 */
569 581
570 if (acpi_gbl_FACS->length < 24) { 582 if (acpi_gbl_FACS->length < 24) {
571 ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", 583 ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n",
572 acpi_gbl_FACS->length)); 584 acpi_gbl_FACS->length));
573 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 585 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
574 } 586 }
575 587
576 if (acpi_gbl_FACS->length < 64) { 588 if (acpi_gbl_FACS->length < 64) {
577 ACPI_REPORT_WARNING (( 589 ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length));
578 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
579 acpi_gbl_FACS->length));
580 } 590 }
581 591
582 /* Copy fields to the new FACS */ 592 /* Copy fields to the new FACS */
@@ -584,22 +594,22 @@ acpi_tb_build_common_facs (
584 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock); 594 acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
585 595
586 if ((acpi_gbl_RSDP->revision < 2) || 596 if ((acpi_gbl_RSDP->revision < 2) ||
587 (acpi_gbl_FACS->length < 32) || 597 (acpi_gbl_FACS->length < 32) ||
588 (!(acpi_gbl_FACS->xfirmware_waking_vector))) { 598 (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
589 /* ACPI 1.0 FACS or short table or optional X_ field is zero */ 599 /* ACPI 1.0 FACS or short table or optional X_ field is zero */
590 600
591 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, 601 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
592 &(acpi_gbl_FACS->firmware_waking_vector)); 602 &
603 (acpi_gbl_FACS->
604 firmware_waking_vector));
593 acpi_gbl_common_fACS.vector_width = 32; 605 acpi_gbl_common_fACS.vector_width = 32;
594 } 606 } else {
595 else {
596 /* ACPI 2.0 FACS with valid X_ field */ 607 /* ACPI 2.0 FACS with valid X_ field */
597 608
598 acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector; 609 acpi_gbl_common_fACS.firmware_waking_vector =
610 &acpi_gbl_FACS->xfirmware_waking_vector;
599 acpi_gbl_common_fACS.vector_width = 64; 611 acpi_gbl_common_fACS.vector_width = 64;
600 } 612 }
601 613
602 return_ACPI_STATUS (AE_OK); 614 return_ACPI_STATUS(AE_OK);
603} 615}
604
605
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 4ab2aadc6133..6acd5aeb093e 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -41,27 +41,21 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbget") 48ACPI_MODULE_NAME("tbget")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_get_this_table ( 52acpi_tb_get_this_table(struct acpi_pointer *address,
56 struct acpi_pointer *address, 53 struct acpi_table_header *header,
57 struct acpi_table_header *header, 54 struct acpi_table_desc *table_info);
58 struct acpi_table_desc *table_info);
59 55
60static acpi_status 56static acpi_status
61acpi_tb_table_override ( 57acpi_tb_table_override(struct acpi_table_header *header,
62 struct acpi_table_header *header, 58 struct acpi_table_desc *table_info);
63 struct acpi_table_desc *table_info);
64
65 59
66/******************************************************************************* 60/*******************************************************************************
67 * 61 *
@@ -78,37 +72,34 @@ acpi_tb_table_override (
78 ******************************************************************************/ 72 ******************************************************************************/
79 73
80acpi_status 74acpi_status
81acpi_tb_get_table ( 75acpi_tb_get_table(struct acpi_pointer *address,
82 struct acpi_pointer *address, 76 struct acpi_table_desc *table_info)
83 struct acpi_table_desc *table_info)
84{ 77{
85 acpi_status status; 78 acpi_status status;
86 struct acpi_table_header header; 79 struct acpi_table_header header;
87
88
89 ACPI_FUNCTION_TRACE ("tb_get_table");
90 80
81 ACPI_FUNCTION_TRACE("tb_get_table");
91 82
92 /* Get the header in order to get signature and table size */ 83 /* Get the header in order to get signature and table size */
93 84
94 status = acpi_tb_get_table_header (address, &header); 85 status = acpi_tb_get_table_header(address, &header);
95 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
96 return_ACPI_STATUS (status); 87 return_ACPI_STATUS(status);
97 } 88 }
98 89
99 /* Get the entire table */ 90 /* Get the entire table */
100 91
101 status = acpi_tb_get_table_body (address, &header, table_info); 92 status = acpi_tb_get_table_body(address, &header, table_info);
102 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n", 94 ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n",
104 header.length, acpi_format_exception (status))); 95 header.length,
105 return_ACPI_STATUS (status); 96 acpi_format_exception(status)));
97 return_ACPI_STATUS(status);
106 } 98 }
107 99
108 return_ACPI_STATUS (AE_OK); 100 return_ACPI_STATUS(AE_OK);
109} 101}
110 102
111
112/******************************************************************************* 103/*******************************************************************************
113 * 104 *
114 * FUNCTION: acpi_tb_get_table_header 105 * FUNCTION: acpi_tb_get_table_header
@@ -127,16 +118,13 @@ acpi_tb_get_table (
127 ******************************************************************************/ 118 ******************************************************************************/
128 119
129acpi_status 120acpi_status
130acpi_tb_get_table_header ( 121acpi_tb_get_table_header(struct acpi_pointer *address,
131 struct acpi_pointer *address, 122 struct acpi_table_header *return_header)
132 struct acpi_table_header *return_header)
133{ 123{
134 acpi_status status = AE_OK; 124 acpi_status status = AE_OK;
135 struct acpi_table_header *header = NULL; 125 struct acpi_table_header *header = NULL;
136
137
138 ACPI_FUNCTION_TRACE ("tb_get_table_header");
139 126
127 ACPI_FUNCTION_TRACE("tb_get_table_header");
140 128
141 /* 129 /*
142 * Flags contains the current processor mode (Virtual or Physical 130 * Flags contains the current processor mode (Virtual or Physical
@@ -148,46 +136,42 @@ acpi_tb_get_table_header (
148 136
149 /* Pointer matches processor mode, copy the header */ 137 /* Pointer matches processor mode, copy the header */
150 138
151 ACPI_MEMCPY (return_header, address->pointer.logical, 139 ACPI_MEMCPY(return_header, address->pointer.logical,
152 sizeof (struct acpi_table_header)); 140 sizeof(struct acpi_table_header));
153 break; 141 break;
154 142
155
156 case ACPI_LOGMODE_PHYSPTR: 143 case ACPI_LOGMODE_PHYSPTR:
157 144
158 /* Create a logical address for the physical pointer*/ 145 /* Create a logical address for the physical pointer */
159 146
160 status = acpi_os_map_memory (address->pointer.physical, 147 status = acpi_os_map_memory(address->pointer.physical,
161 sizeof (struct acpi_table_header), (void *) &header); 148 sizeof(struct acpi_table_header),
162 if (ACPI_FAILURE (status)) { 149 (void *)&header);
163 ACPI_REPORT_ERROR (( 150 if (ACPI_FAILURE(status)) {
164 "Could not map memory at %8.8X%8.8X for length %X\n", 151 ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header)));
165 ACPI_FORMAT_UINT64 (address->pointer.physical), 152 return_ACPI_STATUS(status);
166 sizeof (struct acpi_table_header)));
167 return_ACPI_STATUS (status);
168 } 153 }
169 154
170 /* Copy header and delete mapping */ 155 /* Copy header and delete mapping */
171 156
172 ACPI_MEMCPY (return_header, header, sizeof (struct acpi_table_header)); 157 ACPI_MEMCPY(return_header, header,
173 acpi_os_unmap_memory (header, sizeof (struct acpi_table_header)); 158 sizeof(struct acpi_table_header));
159 acpi_os_unmap_memory(header, sizeof(struct acpi_table_header));
174 break; 160 break;
175 161
176
177 default: 162 default:
178 163
179 ACPI_REPORT_ERROR (("Invalid address flags %X\n", 164 ACPI_REPORT_ERROR(("Invalid address flags %X\n",
180 address->pointer_type)); 165 address->pointer_type));
181 return_ACPI_STATUS (AE_BAD_PARAMETER); 166 return_ACPI_STATUS(AE_BAD_PARAMETER);
182 } 167 }
183 168
184 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n",
185 return_header->signature)); 170 return_header->signature));
186 171
187 return_ACPI_STATUS (AE_OK); 172 return_ACPI_STATUS(AE_OK);
188} 173}
189 174
190
191/******************************************************************************* 175/*******************************************************************************
192 * 176 *
193 * FUNCTION: acpi_tb_get_table_body 177 * FUNCTION: acpi_tb_get_table_body
@@ -209,37 +193,33 @@ acpi_tb_get_table_header (
209 ******************************************************************************/ 193 ******************************************************************************/
210 194
211acpi_status 195acpi_status
212acpi_tb_get_table_body ( 196acpi_tb_get_table_body(struct acpi_pointer *address,
213 struct acpi_pointer *address, 197 struct acpi_table_header *header,
214 struct acpi_table_header *header, 198 struct acpi_table_desc *table_info)
215 struct acpi_table_desc *table_info)
216{ 199{
217 acpi_status status; 200 acpi_status status;
218
219
220 ACPI_FUNCTION_TRACE ("tb_get_table_body");
221 201
202 ACPI_FUNCTION_TRACE("tb_get_table_body");
222 203
223 if (!table_info || !address) { 204 if (!table_info || !address) {
224 return_ACPI_STATUS (AE_BAD_PARAMETER); 205 return_ACPI_STATUS(AE_BAD_PARAMETER);
225 } 206 }
226 207
227 /* Attempt table override. */ 208 /* Attempt table override. */
228 209
229 status = acpi_tb_table_override (header, table_info); 210 status = acpi_tb_table_override(header, table_info);
230 if (ACPI_SUCCESS (status)) { 211 if (ACPI_SUCCESS(status)) {
231 /* Table was overridden by the host OS */ 212 /* Table was overridden by the host OS */
232 213
233 return_ACPI_STATUS (status); 214 return_ACPI_STATUS(status);
234 } 215 }
235 216
236 /* No override, get the original table */ 217 /* No override, get the original table */
237 218
238 status = acpi_tb_get_this_table (address, header, table_info); 219 status = acpi_tb_get_this_table(address, header, table_info);
239 return_ACPI_STATUS (status); 220 return_ACPI_STATUS(status);
240} 221}
241 222
242
243/******************************************************************************* 223/*******************************************************************************
244 * 224 *
245 * FUNCTION: acpi_tb_table_override 225 * FUNCTION: acpi_tb_table_override
@@ -255,61 +235,57 @@ acpi_tb_get_table_body (
255 ******************************************************************************/ 235 ******************************************************************************/
256 236
257static acpi_status 237static acpi_status
258acpi_tb_table_override ( 238acpi_tb_table_override(struct acpi_table_header *header,
259 struct acpi_table_header *header, 239 struct acpi_table_desc *table_info)
260 struct acpi_table_desc *table_info)
261{ 240{
262 struct acpi_table_header *new_table; 241 struct acpi_table_header *new_table;
263 acpi_status status; 242 acpi_status status;
264 struct acpi_pointer address; 243 struct acpi_pointer address;
265
266
267 ACPI_FUNCTION_TRACE ("tb_table_override");
268 244
245 ACPI_FUNCTION_TRACE("tb_table_override");
269 246
270 /* 247 /*
271 * The OSL will examine the header and decide whether to override this 248 * The OSL will examine the header and decide whether to override this
272 * table. If it decides to override, a table will be returned in new_table, 249 * table. If it decides to override, a table will be returned in new_table,
273 * which we will then copy. 250 * which we will then copy.
274 */ 251 */
275 status = acpi_os_table_override (header, &new_table); 252 status = acpi_os_table_override(header, &new_table);
276 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
277 /* Some severe error from the OSL, but we basically ignore it */ 254 /* Some severe error from the OSL, but we basically ignore it */
278 255
279 ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n", 256 ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n",
280 acpi_format_exception (status))); 257 acpi_format_exception(status)));
281 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
282 } 259 }
283 260
284 if (!new_table) { 261 if (!new_table) {
285 /* No table override */ 262 /* No table override */
286 263
287 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 264 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
288 } 265 }
289 266
290 /* 267 /*
291 * We have a new table to override the old one. Get a copy of 268 * We have a new table to override the old one. Get a copy of
292 * the new one. We know that the new table has a logical pointer. 269 * the new one. We know that the new table has a logical pointer.
293 */ 270 */
294 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; 271 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
295 address.pointer.logical = new_table; 272 address.pointer.logical = new_table;
296 273
297 status = acpi_tb_get_this_table (&address, new_table, table_info); 274 status = acpi_tb_get_this_table(&address, new_table, table_info);
298 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
299 ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n", 276 ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n",
300 acpi_format_exception (status))); 277 acpi_format_exception(status)));
301 return_ACPI_STATUS (status); 278 return_ACPI_STATUS(status);
302 } 279 }
303 280
304 /* Copy the table info */ 281 /* Copy the table info */
305 282
306 ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n", 283 ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n",
307 table_info->pointer->signature)); 284 table_info->pointer->signature));
308 285
309 return_ACPI_STATUS (AE_OK); 286 return_ACPI_STATUS(AE_OK);
310} 287}
311 288
312
313/******************************************************************************* 289/*******************************************************************************
314 * 290 *
315 * FUNCTION: acpi_tb_get_this_table 291 * FUNCTION: acpi_tb_get_this_table
@@ -329,18 +305,15 @@ acpi_tb_table_override (
329 ******************************************************************************/ 305 ******************************************************************************/
330 306
331static acpi_status 307static acpi_status
332acpi_tb_get_this_table ( 308acpi_tb_get_this_table(struct acpi_pointer *address,
333 struct acpi_pointer *address, 309 struct acpi_table_header *header,
334 struct acpi_table_header *header, 310 struct acpi_table_desc *table_info)
335 struct acpi_table_desc *table_info)
336{ 311{
337 struct acpi_table_header *full_table = NULL; 312 struct acpi_table_header *full_table = NULL;
338 u8 allocation; 313 u8 allocation;
339 acpi_status status = AE_OK; 314 acpi_status status = AE_OK;
340
341
342 ACPI_FUNCTION_TRACE ("tb_get_this_table");
343 315
316 ACPI_FUNCTION_TRACE("tb_get_this_table");
344 317
345 /* 318 /*
346 * Flags contains the current processor mode (Virtual or Physical 319 * Flags contains the current processor mode (Virtual or Physical
@@ -352,38 +325,33 @@ acpi_tb_get_this_table (
352 325
353 /* Pointer matches processor mode, copy the table to a new buffer */ 326 /* Pointer matches processor mode, copy the table to a new buffer */
354 327
355 full_table = ACPI_MEM_ALLOCATE (header->length); 328 full_table = ACPI_MEM_ALLOCATE(header->length);
356 if (!full_table) { 329 if (!full_table) {
357 ACPI_REPORT_ERROR (( 330 ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length));
358 "Could not allocate table memory for [%4.4s] length %X\n", 331 return_ACPI_STATUS(AE_NO_MEMORY);
359 header->signature, header->length));
360 return_ACPI_STATUS (AE_NO_MEMORY);
361 } 332 }
362 333
363 /* Copy the entire table (including header) to the local buffer */ 334 /* Copy the entire table (including header) to the local buffer */
364 335
365 ACPI_MEMCPY (full_table, address->pointer.logical, header->length); 336 ACPI_MEMCPY(full_table, address->pointer.logical,
337 header->length);
366 338
367 /* Save allocation type */ 339 /* Save allocation type */
368 340
369 allocation = ACPI_MEM_ALLOCATED; 341 allocation = ACPI_MEM_ALLOCATED;
370 break; 342 break;
371 343
372
373 case ACPI_LOGMODE_PHYSPTR: 344 case ACPI_LOGMODE_PHYSPTR:
374 345
375 /* 346 /*
376 * Just map the table's physical memory 347 * Just map the table's physical memory
377 * into our address space. 348 * into our address space.
378 */ 349 */
379 status = acpi_os_map_memory (address->pointer.physical, 350 status = acpi_os_map_memory(address->pointer.physical,
380 (acpi_size) header->length, (void *) &full_table); 351 (acpi_size) header->length,
381 if (ACPI_FAILURE (status)) { 352 (void *)&full_table);
382 ACPI_REPORT_ERROR (( 353 if (ACPI_FAILURE(status)) {
383 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", 354 ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length));
384 header->signature,
385 ACPI_FORMAT_UINT64 (address->pointer.physical),
386 header->length));
387 return (status); 355 return (status);
388 } 356 }
389 357
@@ -392,12 +360,11 @@ acpi_tb_get_this_table (
392 allocation = ACPI_MEM_MAPPED; 360 allocation = ACPI_MEM_MAPPED;
393 break; 361 break;
394 362
395
396 default: 363 default:
397 364
398 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n", 365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n",
399 address->pointer_type)); 366 address->pointer_type));
400 return_ACPI_STATUS (AE_BAD_PARAMETER); 367 return_ACPI_STATUS(AE_BAD_PARAMETER);
401 } 368 }
402 369
403 /* 370 /*
@@ -405,10 +372,10 @@ acpi_tb_get_this_table (
405 * even the ones whose signature we don't recognize 372 * even the ones whose signature we don't recognize
406 */ 373 */
407 if (table_info->type != ACPI_TABLE_FACS) { 374 if (table_info->type != ACPI_TABLE_FACS) {
408 status = acpi_tb_verify_table_checksum (full_table); 375 status = acpi_tb_verify_table_checksum(full_table);
409 376
410#if (!ACPI_CHECKSUM_ABORT) 377#if (!ACPI_CHECKSUM_ABORT)
411 if (ACPI_FAILURE (status)) { 378 if (ACPI_FAILURE(status)) {
412 /* Ignore the error if configuration says so */ 379 /* Ignore the error if configuration says so */
413 380
414 status = AE_OK; 381 status = AE_OK;
@@ -418,19 +385,19 @@ acpi_tb_get_this_table (
418 385
419 /* Return values */ 386 /* Return values */
420 387
421 table_info->pointer = full_table; 388 table_info->pointer = full_table;
422 table_info->length = (acpi_size) header->length; 389 table_info->length = (acpi_size) header->length;
423 table_info->allocation = allocation; 390 table_info->allocation = allocation;
424 391
425 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 392 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
426 "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n", 393 "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n",
427 full_table->signature, 394 full_table->signature,
428 ACPI_FORMAT_UINT64 (address->pointer.physical), full_table)); 395 ACPI_FORMAT_UINT64(address->pointer.physical),
396 full_table));
429 397
430 return_ACPI_STATUS (status); 398 return_ACPI_STATUS(status);
431} 399}
432 400
433
434/******************************************************************************* 401/*******************************************************************************
435 * 402 *
436 * FUNCTION: acpi_tb_get_table_ptr 403 * FUNCTION: acpi_tb_get_table_ptr
@@ -447,24 +414,20 @@ acpi_tb_get_this_table (
447 ******************************************************************************/ 414 ******************************************************************************/
448 415
449acpi_status 416acpi_status
450acpi_tb_get_table_ptr ( 417acpi_tb_get_table_ptr(acpi_table_type table_type,
451 acpi_table_type table_type, 418 u32 instance, struct acpi_table_header **table_ptr_loc)
452 u32 instance,
453 struct acpi_table_header **table_ptr_loc)
454{ 419{
455 struct acpi_table_desc *table_desc; 420 struct acpi_table_desc *table_desc;
456 u32 i; 421 u32 i;
457
458
459 ACPI_FUNCTION_TRACE ("tb_get_table_ptr");
460 422
423 ACPI_FUNCTION_TRACE("tb_get_table_ptr");
461 424
462 if (!acpi_gbl_DSDT) { 425 if (!acpi_gbl_DSDT) {
463 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 426 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
464 } 427 }
465 428
466 if (table_type > ACPI_TABLE_MAX) { 429 if (table_type > ACPI_TABLE_MAX) {
467 return_ACPI_STATUS (AE_BAD_PARAMETER); 430 return_ACPI_STATUS(AE_BAD_PARAMETER);
468 } 431 }
469 432
470 /* 433 /*
@@ -476,15 +439,16 @@ acpi_tb_get_table_ptr (
476 439
477 *table_ptr_loc = NULL; 440 *table_ptr_loc = NULL;
478 if (acpi_gbl_table_lists[table_type].next) { 441 if (acpi_gbl_table_lists[table_type].next) {
479 *table_ptr_loc = acpi_gbl_table_lists[table_type].next->pointer; 442 *table_ptr_loc =
443 acpi_gbl_table_lists[table_type].next->pointer;
480 } 444 }
481 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS(AE_OK);
482 } 446 }
483 447
484 /* Check for instance out of range */ 448 /* Check for instance out of range */
485 449
486 if (instance > acpi_gbl_table_lists[table_type].count) { 450 if (instance > acpi_gbl_table_lists[table_type].count) {
487 return_ACPI_STATUS (AE_NOT_EXIST); 451 return_ACPI_STATUS(AE_NOT_EXIST);
488 } 452 }
489 453
490 /* Walk the list to get the desired table 454 /* Walk the list to get the desired table
@@ -503,6 +467,5 @@ acpi_tb_get_table_ptr (
503 467
504 *table_ptr_loc = table_desc->pointer; 468 *table_ptr_loc = table_desc->pointer;
505 469
506 return_ACPI_STATUS (AE_OK); 470 return_ACPI_STATUS(AE_OK);
507} 471}
508
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index eea5b8cb5ebb..8d72343537e7 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -41,27 +41,21 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbgetall") 48ACPI_MODULE_NAME("tbgetall")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_get_primary_table ( 52acpi_tb_get_primary_table(struct acpi_pointer *address,
56 struct acpi_pointer *address, 53 struct acpi_table_desc *table_info);
57 struct acpi_table_desc *table_info);
58 54
59static acpi_status 55static acpi_status
60acpi_tb_get_secondary_table ( 56acpi_tb_get_secondary_table(struct acpi_pointer *address,
61 struct acpi_pointer *address, 57 acpi_string signature,
62 acpi_string signature, 58 struct acpi_table_desc *table_info);
63 struct acpi_table_desc *table_info);
64
65 59
66/******************************************************************************* 60/*******************************************************************************
67 * 61 *
@@ -77,58 +71,54 @@ acpi_tb_get_secondary_table (
77 ******************************************************************************/ 71 ******************************************************************************/
78 72
79static acpi_status 73static acpi_status
80acpi_tb_get_primary_table ( 74acpi_tb_get_primary_table(struct acpi_pointer *address,
81 struct acpi_pointer *address, 75 struct acpi_table_desc *table_info)
82 struct acpi_table_desc *table_info)
83{ 76{
84 acpi_status status; 77 acpi_status status;
85 struct acpi_table_header header; 78 struct acpi_table_header header;
86
87
88 ACPI_FUNCTION_TRACE ("tb_get_primary_table");
89 79
80 ACPI_FUNCTION_TRACE("tb_get_primary_table");
90 81
91 /* Ignore a NULL address in the RSDT */ 82 /* Ignore a NULL address in the RSDT */
92 83
93 if (!address->pointer.value) { 84 if (!address->pointer.value) {
94 return_ACPI_STATUS (AE_OK); 85 return_ACPI_STATUS(AE_OK);
95 } 86 }
96 87
97 /* Get the header in order to get signature and table size */ 88 /* Get the header in order to get signature and table size */
98 89
99 status = acpi_tb_get_table_header (address, &header); 90 status = acpi_tb_get_table_header(address, &header);
100 if (ACPI_FAILURE (status)) { 91 if (ACPI_FAILURE(status)) {
101 return_ACPI_STATUS (status); 92 return_ACPI_STATUS(status);
102 } 93 }
103 94
104 /* Clear the table_info */ 95 /* Clear the table_info */
105 96
106 ACPI_MEMSET (table_info, 0, sizeof (struct acpi_table_desc)); 97 ACPI_MEMSET(table_info, 0, sizeof(struct acpi_table_desc));
107 98
108 /* 99 /*
109 * Check the table signature and make sure it is recognized. 100 * Check the table signature and make sure it is recognized.
110 * Also checks the header checksum 101 * Also checks the header checksum
111 */ 102 */
112 table_info->pointer = &header; 103 table_info->pointer = &header;
113 status = acpi_tb_recognize_table (table_info, ACPI_TABLE_PRIMARY); 104 status = acpi_tb_recognize_table(table_info, ACPI_TABLE_PRIMARY);
114 if (ACPI_FAILURE (status)) { 105 if (ACPI_FAILURE(status)) {
115 return_ACPI_STATUS (status); 106 return_ACPI_STATUS(status);
116 } 107 }
117 108
118 /* Get the entire table */ 109 /* Get the entire table */
119 110
120 status = acpi_tb_get_table_body (address, &header, table_info); 111 status = acpi_tb_get_table_body(address, &header, table_info);
121 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS (status); 113 return_ACPI_STATUS(status);
123 } 114 }
124 115
125 /* Install the table */ 116 /* Install the table */
126 117
127 status = acpi_tb_install_table (table_info); 118 status = acpi_tb_install_table(table_info);
128 return_ACPI_STATUS (status); 119 return_ACPI_STATUS(status);
129} 120}
130 121
131
132/******************************************************************************* 122/*******************************************************************************
133 * 123 *
134 * FUNCTION: acpi_tb_get_secondary_table 124 * FUNCTION: acpi_tb_get_secondary_table
@@ -143,32 +133,27 @@ acpi_tb_get_primary_table (
143 ******************************************************************************/ 133 ******************************************************************************/
144 134
145static acpi_status 135static acpi_status
146acpi_tb_get_secondary_table ( 136acpi_tb_get_secondary_table(struct acpi_pointer *address,
147 struct acpi_pointer *address, 137 acpi_string signature,
148 acpi_string signature, 138 struct acpi_table_desc *table_info)
149 struct acpi_table_desc *table_info)
150{ 139{
151 acpi_status status; 140 acpi_status status;
152 struct acpi_table_header header; 141 struct acpi_table_header header;
153
154
155 ACPI_FUNCTION_TRACE_STR ("tb_get_secondary_table", signature);
156 142
143 ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature);
157 144
158 /* Get the header in order to match the signature */ 145 /* Get the header in order to match the signature */
159 146
160 status = acpi_tb_get_table_header (address, &header); 147 status = acpi_tb_get_table_header(address, &header);
161 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
162 return_ACPI_STATUS (status); 149 return_ACPI_STATUS(status);
163 } 150 }
164 151
165 /* Signature must match request */ 152 /* Signature must match request */
166 153
167 if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) { 154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) {
168 ACPI_REPORT_ERROR (( 155 ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature));
169 "Incorrect table signature - wanted [%s] found [%4.4s]\n", 156 return_ACPI_STATUS(AE_BAD_SIGNATURE);
170 signature, header.signature));
171 return_ACPI_STATUS (AE_BAD_SIGNATURE);
172 } 157 }
173 158
174 /* 159 /*
@@ -176,25 +161,24 @@ acpi_tb_get_secondary_table (
176 * Also checks the header checksum 161 * Also checks the header checksum
177 */ 162 */
178 table_info->pointer = &header; 163 table_info->pointer = &header;
179 status = acpi_tb_recognize_table (table_info, ACPI_TABLE_SECONDARY); 164 status = acpi_tb_recognize_table(table_info, ACPI_TABLE_SECONDARY);
180 if (ACPI_FAILURE (status)) { 165 if (ACPI_FAILURE(status)) {
181 return_ACPI_STATUS (status); 166 return_ACPI_STATUS(status);
182 } 167 }
183 168
184 /* Get the entire table */ 169 /* Get the entire table */
185 170
186 status = acpi_tb_get_table_body (address, &header, table_info); 171 status = acpi_tb_get_table_body(address, &header, table_info);
187 if (ACPI_FAILURE (status)) { 172 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
189 } 174 }
190 175
191 /* Install the table */ 176 /* Install the table */
192 177
193 status = acpi_tb_install_table (table_info); 178 status = acpi_tb_install_table(table_info);
194 return_ACPI_STATUS (status); 179 return_ACPI_STATUS(status);
195} 180}
196 181
197
198/******************************************************************************* 182/*******************************************************************************
199 * 183 *
200 * FUNCTION: acpi_tb_get_required_tables 184 * FUNCTION: acpi_tb_get_required_tables
@@ -214,23 +198,19 @@ acpi_tb_get_secondary_table (
214 * 198 *
215 ******************************************************************************/ 199 ******************************************************************************/
216 200
217acpi_status 201acpi_status acpi_tb_get_required_tables(void)
218acpi_tb_get_required_tables (
219 void)
220{ 202{
221 acpi_status status = AE_OK; 203 acpi_status status = AE_OK;
222 u32 i; 204 u32 i;
223 struct acpi_table_desc table_info; 205 struct acpi_table_desc table_info;
224 struct acpi_pointer address; 206 struct acpi_pointer address;
225
226 207
227 ACPI_FUNCTION_TRACE ("tb_get_required_tables"); 208 ACPI_FUNCTION_TRACE("tb_get_required_tables");
228 209
229 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
230 acpi_gbl_rsdt_table_count)); 211 acpi_gbl_rsdt_table_count));
231 212
232 213 address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
233 address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
234 214
235 /* 215 /*
236 * Loop through all table pointers found in RSDT. 216 * Loop through all table pointers found in RSDT.
@@ -243,84 +223,79 @@ acpi_tb_get_required_tables (
243 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 223 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
244 /* Get the table address from the common internal XSDT */ 224 /* Get the table address from the common internal XSDT */
245 225
246 address.pointer.value = 226 address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
247 acpi_gbl_XSDT->table_offset_entry[i];
248 227
249 /* 228 /*
250 * Get the tables needed by this subsystem (FADT and any SSDTs). 229 * Get the tables needed by this subsystem (FADT and any SSDTs).
251 * NOTE: All other tables are completely ignored at this time. 230 * NOTE: All other tables are completely ignored at this time.
252 */ 231 */
253 status = acpi_tb_get_primary_table (&address, &table_info); 232 status = acpi_tb_get_primary_table(&address, &table_info);
254 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { 233 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
255 ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n", 234 ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value)));
256 acpi_format_exception (status),
257 ACPI_FORMAT_UINT64 (address.pointer.value)));
258 } 235 }
259 } 236 }
260 237
261 /* We must have a FADT to continue */ 238 /* We must have a FADT to continue */
262 239
263 if (!acpi_gbl_FADT) { 240 if (!acpi_gbl_FADT) {
264 ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n")); 241 ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n"));
265 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 242 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
266 } 243 }
267 244
268 /* 245 /*
269 * Convert the FADT to a common format. This allows earlier revisions of 246 * Convert the FADT to a common format. This allows earlier revisions of
270 * the table to coexist with newer versions, using common access code. 247 * the table to coexist with newer versions, using common access code.
271 */ 248 */
272 status = acpi_tb_convert_table_fadt (); 249 status = acpi_tb_convert_table_fadt();
273 if (ACPI_FAILURE (status)) { 250 if (ACPI_FAILURE(status)) {
274 ACPI_REPORT_ERROR (( 251 ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n"));
275 "Could not convert FADT to internal common format\n")); 252 return_ACPI_STATUS(status);
276 return_ACPI_STATUS (status);
277 } 253 }
278 254
279 /* Get the FACS (Pointed to by the FADT) */ 255 /* Get the FACS (Pointed to by the FADT) */
280 256
281 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl; 257 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
282 258
283 status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info); 259 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info);
284 if (ACPI_FAILURE (status)) { 260 if (ACPI_FAILURE(status)) {
285 ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n", 261 ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n",
286 acpi_format_exception (status))); 262 acpi_format_exception(status)));
287 return_ACPI_STATUS (status); 263 return_ACPI_STATUS(status);
288 } 264 }
289 265
290 /* 266 /*
291 * Create the common FACS pointer table 267 * Create the common FACS pointer table
292 * (Contains pointers to the original table) 268 * (Contains pointers to the original table)
293 */ 269 */
294 status = acpi_tb_build_common_facs (&table_info); 270 status = acpi_tb_build_common_facs(&table_info);
295 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
296 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
297 } 273 }
298 274
299 /* Get/install the DSDT (Pointed to by the FADT) */ 275 /* Get/install the DSDT (Pointed to by the FADT) */
300 276
301 address.pointer.value = acpi_gbl_FADT->Xdsdt; 277 address.pointer.value = acpi_gbl_FADT->Xdsdt;
302 278
303 status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info); 279 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info);
304 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
305 ACPI_REPORT_ERROR (("Could not get/install the DSDT\n")); 281 ACPI_REPORT_ERROR(("Could not get/install the DSDT\n"));
306 return_ACPI_STATUS (status); 282 return_ACPI_STATUS(status);
307 } 283 }
308 284
309 /* Set Integer Width (32/64) based upon DSDT revision */ 285 /* Set Integer Width (32/64) based upon DSDT revision */
310 286
311 acpi_ut_set_integer_width (acpi_gbl_DSDT->revision); 287 acpi_ut_set_integer_width(acpi_gbl_DSDT->revision);
312 288
313 /* Dump the entire DSDT */ 289 /* Dump the entire DSDT */
314 290
315 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 291 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
316 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", 292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
317 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width)); 293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
318 ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); 294 acpi_gbl_integer_bit_width));
295 ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
319 296
320 /* Always delete the RSDP mapping, we are done with it */ 297 /* Always delete the RSDP mapping, we are done with it */
321 298
322 acpi_tb_delete_tables_by_type (ACPI_TABLE_RSDP); 299 acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP);
323 return_ACPI_STATUS (status); 300 return_ACPI_STATUS(status);
324} 301}
325
326
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 629b64c8193d..10db8484e462 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -41,22 +41,16 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbinstal") 48ACPI_MODULE_NAME("tbinstal")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_match_signature ( 52acpi_tb_match_signature(char *signature,
56 char *signature, 53 struct acpi_table_desc *table_info, u8 search_type);
57 struct acpi_table_desc *table_info,
58 u8 search_type);
59
60 54
61/******************************************************************************* 55/*******************************************************************************
62 * 56 *
@@ -74,16 +68,12 @@ acpi_tb_match_signature (
74 ******************************************************************************/ 68 ******************************************************************************/
75 69
76static acpi_status 70static acpi_status
77acpi_tb_match_signature ( 71acpi_tb_match_signature(char *signature,
78 char *signature, 72 struct acpi_table_desc *table_info, u8 search_type)
79 struct acpi_table_desc *table_info,
80 u8 search_type)
81{ 73{
82 acpi_native_uint i; 74 acpi_native_uint i;
83
84
85 ACPI_FUNCTION_TRACE ("tb_match_signature");
86 75
76 ACPI_FUNCTION_TRACE("tb_match_signature");
87 77
88 /* Search for a signature match among the known table types */ 78 /* Search for a signature match among the known table types */
89 79
@@ -92,30 +82,30 @@ acpi_tb_match_signature (
92 continue; 82 continue;
93 } 83 }
94 84
95 if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature, 85 if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature,
96 acpi_gbl_table_data[i].sig_length)) { 86 acpi_gbl_table_data[i].sig_length)) {
97 /* Found a signature match, return index if requested */ 87 /* Found a signature match, return index if requested */
98 88
99 if (table_info) { 89 if (table_info) {
100 table_info->type = (u8) i; 90 table_info->type = (u8) i;
101 } 91 }
102 92
103 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 93 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
104 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", 94 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n",
105 (char *) acpi_gbl_table_data[i].signature)); 95 (char *)acpi_gbl_table_data[i].
96 signature));
106 97
107 return_ACPI_STATUS (AE_OK); 98 return_ACPI_STATUS(AE_OK);
108 } 99 }
109 } 100 }
110 101
111 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 102 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
112 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", 103 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n",
113 (char *) signature)); 104 (char *)signature));
114 105
115 return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); 106 return_ACPI_STATUS(AE_TABLE_NOT_SUPPORTED);
116} 107}
117 108
118
119/******************************************************************************* 109/*******************************************************************************
120 * 110 *
121 * FUNCTION: acpi_tb_install_table 111 * FUNCTION: acpi_tb_install_table
@@ -124,46 +114,52 @@ acpi_tb_match_signature (
124 * 114 *
125 * RETURN: Status 115 * RETURN: Status
126 * 116 *
127 * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must 117 * DESCRIPTION: Install the table into the global data structures.
128 * already be loaded and validated.
129 * Install the table into the global data structs.
130 * 118 *
131 ******************************************************************************/ 119 ******************************************************************************/
132 120
133acpi_status 121acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
134acpi_tb_install_table (
135 struct acpi_table_desc *table_info)
136{ 122{
137 acpi_status status; 123 acpi_status status;
138
139 ACPI_FUNCTION_TRACE ("tb_install_table");
140 124
125 ACPI_FUNCTION_TRACE("tb_install_table");
141 126
142 /* Lock tables while installing */ 127 /* Lock tables while installing */
143 128
144 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
145 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
146 ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", 131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n",
147 table_info->pointer->signature, acpi_format_exception (status))); 132 acpi_format_exception(status)));
148 return_ACPI_STATUS (status); 133 return_ACPI_STATUS(status);
134 }
135
136 /*
137 * Ignore a table that is already installed. For example, some BIOS
138 * ASL code will repeatedly attempt to load the same SSDT.
139 */
140 status = acpi_tb_is_table_installed(table_info);
141 if (ACPI_FAILURE(status)) {
142 goto unlock_and_exit;
149 } 143 }
150 144
151 /* Install the table into the global data structure */ 145 /* Install the table into the global data structure */
152 146
153 status = acpi_tb_init_table_descriptor (table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
154 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
155 ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", 149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n",
156 table_info->pointer->signature, acpi_format_exception (status))); 150 table_info->pointer->signature,
151 acpi_format_exception(status)));
157 } 152 }
158 153
159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
160 acpi_gbl_table_data[table_info->type].name, table_info->pointer)); 155 acpi_gbl_table_data[table_info->type].name,
156 table_info->pointer));
161 157
162 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 158 unlock_and_exit:
163 return_ACPI_STATUS (status); 159 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
160 return_ACPI_STATUS(status);
164} 161}
165 162
166
167/******************************************************************************* 163/*******************************************************************************
168 * 164 *
169 * FUNCTION: acpi_tb_recognize_table 165 * FUNCTION: acpi_tb_recognize_table
@@ -186,22 +182,18 @@ acpi_tb_install_table (
186 ******************************************************************************/ 182 ******************************************************************************/
187 183
188acpi_status 184acpi_status
189acpi_tb_recognize_table ( 185acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
190 struct acpi_table_desc *table_info,
191 u8 search_type)
192{ 186{
193 struct acpi_table_header *table_header; 187 struct acpi_table_header *table_header;
194 acpi_status status; 188 acpi_status status;
195
196
197 ACPI_FUNCTION_TRACE ("tb_recognize_table");
198 189
190 ACPI_FUNCTION_TRACE("tb_recognize_table");
199 191
200 /* Ensure that we have a valid table pointer */ 192 /* Ensure that we have a valid table pointer */
201 193
202 table_header = (struct acpi_table_header *) table_info->pointer; 194 table_header = (struct acpi_table_header *)table_info->pointer;
203 if (!table_header) { 195 if (!table_header) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 196 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 197 }
206 198
207 /* 199 /*
@@ -212,25 +204,24 @@ acpi_tb_recognize_table (
212 * This can be any one of many valid ACPI tables, it just isn't one of 204 * This can be any one of many valid ACPI tables, it just isn't one of
213 * the tables that is consumed by the core subsystem 205 * the tables that is consumed by the core subsystem
214 */ 206 */
215 status = acpi_tb_match_signature (table_header->signature, 207 status = acpi_tb_match_signature(table_header->signature,
216 table_info, search_type); 208 table_info, search_type);
217 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
219 } 211 }
220 212
221 status = acpi_tb_validate_table_header (table_header); 213 status = acpi_tb_validate_table_header(table_header);
222 if (ACPI_FAILURE (status)) { 214 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
224 } 216 }
225 217
226 /* Return the table type and length via the info struct */ 218 /* Return the table type and length via the info struct */
227 219
228 table_info->length = (acpi_size) table_header->length; 220 table_info->length = (acpi_size) table_header->length;
229 221
230 return_ACPI_STATUS (status); 222 return_ACPI_STATUS(status);
231} 223}
232 224
233
234/******************************************************************************* 225/*******************************************************************************
235 * 226 *
236 * FUNCTION: acpi_tb_init_table_descriptor 227 * FUNCTION: acpi_tb_init_table_descriptor
@@ -245,22 +236,27 @@ acpi_tb_recognize_table (
245 ******************************************************************************/ 236 ******************************************************************************/
246 237
247acpi_status 238acpi_status
248acpi_tb_init_table_descriptor ( 239acpi_tb_init_table_descriptor(acpi_table_type table_type,
249 acpi_table_type table_type, 240 struct acpi_table_desc *table_info)
250 struct acpi_table_desc *table_info)
251{ 241{
252 struct acpi_table_list *list_head; 242 struct acpi_table_list *list_head;
253 struct acpi_table_desc *table_desc; 243 struct acpi_table_desc *table_desc;
254 244 acpi_status status;
255
256 ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type);
257 245
246 ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type);
258 247
259 /* Allocate a descriptor for this table */ 248 /* Allocate a descriptor for this table */
260 249
261 table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 250 table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
262 if (!table_desc) { 251 if (!table_desc) {
263 return_ACPI_STATUS (AE_NO_MEMORY); 252 return_ACPI_STATUS(AE_NO_MEMORY);
253 }
254
255 /* Get a new owner ID for the table */
256
257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id);
258 if (ACPI_FAILURE(status)) {
259 return_ACPI_STATUS(status);
264 } 260 }
265 261
266 /* Install the table into the global data structure */ 262 /* Install the table into the global data structure */
@@ -272,14 +268,14 @@ acpi_tb_init_table_descriptor (
272 * includes most ACPI tables such as the DSDT. 2) Multiple instances of 268 * includes most ACPI tables such as the DSDT. 2) Multiple instances of
273 * the table are allowed. This includes SSDT and PSDTs. 269 * the table are allowed. This includes SSDT and PSDTs.
274 */ 270 */
275 if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) { 271 if (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags)) {
276 /* 272 /*
277 * Only one table allowed, and a table has alread been installed 273 * Only one table allowed, and a table has alread been installed
278 * at this location, so return an error. 274 * at this location, so return an error.
279 */ 275 */
280 if (list_head->next) { 276 if (list_head->next) {
281 ACPI_MEM_FREE (table_desc); 277 ACPI_MEM_FREE(table_desc);
282 return_ACPI_STATUS (AE_ALREADY_EXISTS); 278 return_ACPI_STATUS(AE_ALREADY_EXISTS);
283 } 279 }
284 280
285 table_desc->next = list_head->next; 281 table_desc->next = list_head->next;
@@ -290,8 +286,7 @@ acpi_tb_init_table_descriptor (
290 } 286 }
291 287
292 list_head->count++; 288 list_head->count++;
293 } 289 } else {
294 else {
295 /* 290 /*
296 * Link the new table in to the list of tables of this type. 291 * Link the new table in to the list of tables of this type.
297 * Insert at the end of the list, order IS IMPORTANT. 292 * Insert at the end of the list, order IS IMPORTANT.
@@ -302,8 +297,7 @@ acpi_tb_init_table_descriptor (
302 297
303 if (!list_head->next) { 298 if (!list_head->next) {
304 list_head->next = table_desc; 299 list_head->next = table_desc;
305 } 300 } else {
306 else {
307 table_desc->next = list_head->next; 301 table_desc->next = list_head->next;
308 302
309 while (table_desc->next->next) { 303 while (table_desc->next->next) {
@@ -318,15 +312,14 @@ acpi_tb_init_table_descriptor (
318 312
319 /* Finish initialization of the table descriptor */ 313 /* Finish initialization of the table descriptor */
320 314
321 table_desc->type = (u8) table_type; 315 table_desc->type = (u8) table_type;
322 table_desc->pointer = table_info->pointer; 316 table_desc->pointer = table_info->pointer;
323 table_desc->length = table_info->length; 317 table_desc->length = table_info->length;
324 table_desc->allocation = table_info->allocation; 318 table_desc->allocation = table_info->allocation;
325 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 319 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
326 table_desc->aml_length = (u32) (table_desc->length - 320 table_desc->aml_length = (u32) (table_desc->length -
327 (u32) sizeof (struct acpi_table_header)); 321 (u32) sizeof(struct
328 table_desc->table_id = acpi_ut_allocate_owner_id ( 322 acpi_table_header));
329 ACPI_OWNER_TYPE_TABLE);
330 table_desc->loaded_into_namespace = FALSE; 323 table_desc->loaded_into_namespace = FALSE;
331 324
332 /* 325 /*
@@ -334,18 +327,18 @@ acpi_tb_init_table_descriptor (
334 * newly installed table 327 * newly installed table
335 */ 328 */
336 if (acpi_gbl_table_data[table_type].global_ptr) { 329 if (acpi_gbl_table_data[table_type].global_ptr) {
337 *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; 330 *(acpi_gbl_table_data[table_type].global_ptr) =
331 table_info->pointer;
338 } 332 }
339 333
340 /* Return Data */ 334 /* Return Data */
341 335
342 table_info->table_id = table_desc->table_id; 336 table_info->owner_id = table_desc->owner_id;
343 table_info->installed_desc = table_desc; 337 table_info->installed_desc = table_desc;
344 338
345 return_ACPI_STATUS (AE_OK); 339 return_ACPI_STATUS(AE_OK);
346} 340}
347 341
348
349/******************************************************************************* 342/*******************************************************************************
350 * 343 *
351 * FUNCTION: acpi_tb_delete_all_tables 344 * FUNCTION: acpi_tb_delete_all_tables
@@ -358,23 +351,19 @@ acpi_tb_init_table_descriptor (
358 * 351 *
359 ******************************************************************************/ 352 ******************************************************************************/
360 353
361void 354void acpi_tb_delete_all_tables(void)
362acpi_tb_delete_all_tables (
363 void)
364{ 355{
365 acpi_table_type type; 356 acpi_table_type type;
366
367 357
368 /* 358 /*
369 * Free memory allocated for ACPI tables 359 * Free memory allocated for ACPI tables
370 * Memory can either be mapped or allocated 360 * Memory can either be mapped or allocated
371 */ 361 */
372 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { 362 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) {
373 acpi_tb_delete_tables_by_type (type); 363 acpi_tb_delete_tables_by_type(type);
374 } 364 }
375} 365}
376 366
377
378/******************************************************************************* 367/*******************************************************************************
379 * 368 *
380 * FUNCTION: acpi_tb_delete_tables_by_type 369 * FUNCTION: acpi_tb_delete_tables_by_type
@@ -388,23 +377,19 @@ acpi_tb_delete_all_tables (
388 * 377 *
389 ******************************************************************************/ 378 ******************************************************************************/
390 379
391void 380void acpi_tb_delete_tables_by_type(acpi_table_type type)
392acpi_tb_delete_tables_by_type (
393 acpi_table_type type)
394{ 381{
395 struct acpi_table_desc *table_desc; 382 struct acpi_table_desc *table_desc;
396 u32 count; 383 u32 count;
397 u32 i; 384 u32 i;
398
399
400 ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type);
401 385
386 ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type);
402 387
403 if (type > ACPI_TABLE_MAX) { 388 if (type > ACPI_TABLE_MAX) {
404 return_VOID; 389 return_VOID;
405 } 390 }
406 391
407 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { 392 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) {
408 return; 393 return;
409 } 394 }
410 395
@@ -442,21 +427,20 @@ acpi_tb_delete_tables_by_type (
442 * 1) Get the head of the list 427 * 1) Get the head of the list
443 */ 428 */
444 table_desc = acpi_gbl_table_lists[type].next; 429 table_desc = acpi_gbl_table_lists[type].next;
445 count = acpi_gbl_table_lists[type].count; 430 count = acpi_gbl_table_lists[type].count;
446 431
447 /* 432 /*
448 * 2) Walk the entire list, deleting both the allocated tables 433 * 2) Walk the entire list, deleting both the allocated tables
449 * and the table descriptors 434 * and the table descriptors
450 */ 435 */
451 for (i = 0; i < count; i++) { 436 for (i = 0; i < count; i++) {
452 table_desc = acpi_tb_uninstall_table (table_desc); 437 table_desc = acpi_tb_uninstall_table(table_desc);
453 } 438 }
454 439
455 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 440 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
456 return_VOID; 441 return_VOID;
457} 442}
458 443
459
460/******************************************************************************* 444/*******************************************************************************
461 * 445 *
462 * FUNCTION: acpi_tb_delete_single_table 446 * FUNCTION: acpi_tb_delete_single_table
@@ -470,15 +454,12 @@ acpi_tb_delete_tables_by_type (
470 * 454 *
471 ******************************************************************************/ 455 ******************************************************************************/
472 456
473void 457void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc)
474acpi_tb_delete_single_table (
475 struct acpi_table_desc *table_desc)
476{ 458{
477 459
478 /* Must have a valid table descriptor and pointer */ 460 /* Must have a valid table descriptor and pointer */
479 461
480 if ((!table_desc) || 462 if ((!table_desc) || (!table_desc->pointer)) {
481 (!table_desc->pointer)) {
482 return; 463 return;
483 } 464 }
484 465
@@ -490,12 +471,12 @@ acpi_tb_delete_single_table (
490 471
491 case ACPI_MEM_ALLOCATED: 472 case ACPI_MEM_ALLOCATED:
492 473
493 ACPI_MEM_FREE (table_desc->pointer); 474 ACPI_MEM_FREE(table_desc->pointer);
494 break; 475 break;
495 476
496 case ACPI_MEM_MAPPED: 477 case ACPI_MEM_MAPPED:
497 478
498 acpi_os_unmap_memory (table_desc->pointer, table_desc->length); 479 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
499 break; 480 break;
500 481
501 default: 482 default:
@@ -503,7 +484,6 @@ acpi_tb_delete_single_table (
503 } 484 }
504} 485}
505 486
506
507/******************************************************************************* 487/*******************************************************************************
508 * 488 *
509 * FUNCTION: acpi_tb_uninstall_table 489 * FUNCTION: acpi_tb_uninstall_table
@@ -518,26 +498,22 @@ acpi_tb_delete_single_table (
518 * 498 *
519 ******************************************************************************/ 499 ******************************************************************************/
520 500
521struct acpi_table_desc * 501struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
522acpi_tb_uninstall_table ( 502 *table_desc)
523 struct acpi_table_desc *table_desc)
524{ 503{
525 struct acpi_table_desc *next_desc; 504 struct acpi_table_desc *next_desc;
526
527
528 ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc);
529 505
506 ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc);
530 507
531 if (!table_desc) { 508 if (!table_desc) {
532 return_PTR (NULL); 509 return_PTR(NULL);
533 } 510 }
534 511
535 /* Unlink the descriptor from the doubly linked list */ 512 /* Unlink the descriptor from the doubly linked list */
536 513
537 if (table_desc->prev) { 514 if (table_desc->prev) {
538 table_desc->prev->next = table_desc->next; 515 table_desc->prev->next = table_desc->next;
539 } 516 } else {
540 else {
541 /* Is first on list, update list head */ 517 /* Is first on list, update list head */
542 518
543 acpi_gbl_table_lists[table_desc->type].next = table_desc->next; 519 acpi_gbl_table_lists[table_desc->type].next = table_desc->next;
@@ -549,16 +525,14 @@ acpi_tb_uninstall_table (
549 525
550 /* Free the memory allocated for the table itself */ 526 /* Free the memory allocated for the table itself */
551 527
552 acpi_tb_delete_single_table (table_desc); 528 acpi_tb_delete_single_table(table_desc);
553 529
554 /* Free the table descriptor */ 530 /* Free the table descriptor */
555 531
556 next_desc = table_desc->next; 532 next_desc = table_desc->next;
557 ACPI_MEM_FREE (table_desc); 533 ACPI_MEM_FREE(table_desc);
558 534
559 /* Return pointer to the next descriptor */ 535 /* Return pointer to the next descriptor */
560 536
561 return_PTR (next_desc); 537 return_PTR(next_desc);
562} 538}
563
564
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index b7ffe39c3626..ad0252c2f7db 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbrsdt") 48ACPI_MODULE_NAME("tbrsdt")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -61,18 +58,13 @@
61 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) 58 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
62 * 59 *
63 ******************************************************************************/ 60 ******************************************************************************/
64 61acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
65acpi_status
66acpi_tb_verify_rsdp (
67 struct acpi_pointer *address)
68{ 62{
69 struct acpi_table_desc table_info; 63 struct acpi_table_desc table_info;
70 acpi_status status; 64 acpi_status status;
71 struct rsdp_descriptor *rsdp; 65 struct rsdp_descriptor *rsdp;
72
73
74 ACPI_FUNCTION_TRACE ("tb_verify_rsdp");
75 66
67 ACPI_FUNCTION_TRACE("tb_verify_rsdp");
76 68
77 switch (address->pointer_type) { 69 switch (address->pointer_type) {
78 case ACPI_LOGICAL_POINTER: 70 case ACPI_LOGICAL_POINTER:
@@ -84,73 +76,53 @@ acpi_tb_verify_rsdp (
84 /* 76 /*
85 * Obtain access to the RSDP structure 77 * Obtain access to the RSDP structure
86 */ 78 */
87 status = acpi_os_map_memory (address->pointer.physical, 79 status = acpi_os_map_memory(address->pointer.physical,
88 sizeof (struct rsdp_descriptor), 80 sizeof(struct rsdp_descriptor),
89 (void *) &rsdp); 81 (void *)&rsdp);
90 if (ACPI_FAILURE (status)) { 82 if (ACPI_FAILURE(status)) {
91 return_ACPI_STATUS (status); 83 return_ACPI_STATUS(status);
92 } 84 }
93 break; 85 break;
94 86
95 default: 87 default:
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 /* 91 /* Verify RSDP signature and checksum */
100 * The signature and checksum must both be correct
101 */
102 if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
103 /* Nope, BAD Signature */
104 92
105 status = AE_BAD_SIGNATURE; 93 status = acpi_tb_validate_rsdp(rsdp);
94 if (ACPI_FAILURE(status)) {
106 goto cleanup; 95 goto cleanup;
107 } 96 }
108 97
109 /* Check the standard checksum */
110
111 if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
112 status = AE_BAD_CHECKSUM;
113 goto cleanup;
114 }
115
116 /* Check extended checksum if table version >= 2 */
117
118 if (rsdp->revision >= 2) {
119 if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) {
120 status = AE_BAD_CHECKSUM;
121 goto cleanup;
122 }
123 }
124
125 /* The RSDP supplied is OK */ 98 /* The RSDP supplied is OK */
126 99
127 table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); 100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp);
128 table_info.length = sizeof (struct rsdp_descriptor); 101 table_info.length = sizeof(struct rsdp_descriptor);
129 table_info.allocation = ACPI_MEM_MAPPED; 102 table_info.allocation = ACPI_MEM_MAPPED;
130 103
131 /* Save the table pointers and allocation info */ 104 /* Save the table pointers and allocation info */
132 105
133 status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); 106 status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info);
134 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
135 goto cleanup; 108 goto cleanup;
136 } 109 }
137 110
138 /* Save the RSDP in a global for easy access */ 111 /* Save the RSDP in a global for easy access */
139 112
140 acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer); 113 acpi_gbl_RSDP =
141 return_ACPI_STATUS (status); 114 ACPI_CAST_PTR(struct rsdp_descriptor, table_info.pointer);
142 115 return_ACPI_STATUS(status);
143 116
144 /* Error exit */ 117 /* Error exit */
145cleanup: 118 cleanup:
146 119
147 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) { 120 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) {
148 acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor)); 121 acpi_os_unmap_memory(rsdp, sizeof(struct rsdp_descriptor));
149 } 122 }
150 return_ACPI_STATUS (status); 123 return_ACPI_STATUS(status);
151} 124}
152 125
153
154/******************************************************************************* 126/*******************************************************************************
155 * 127 *
156 * FUNCTION: acpi_tb_get_rsdt_address 128 * FUNCTION: acpi_tb_get_rsdt_address
@@ -159,35 +131,35 @@ cleanup:
159 * 131 *
160 * RETURN: None, Address 132 * RETURN: None, Address
161 * 133 *
162 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the 134 * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the
163 * version of the RSDP 135 * version of the RSDP and whether the XSDT pointer is valid
164 * 136 *
165 ******************************************************************************/ 137 ******************************************************************************/
166 138
167void 139void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address)
168acpi_tb_get_rsdt_address (
169 struct acpi_pointer *out_address)
170{ 140{
171 141
172 ACPI_FUNCTION_ENTRY (); 142 ACPI_FUNCTION_ENTRY();
173 143
144 out_address->pointer_type =
145 acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
174 146
175 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; 147 /* Use XSDT if it is present */
176 148
177 /* 149 if ((acpi_gbl_RSDP->revision >= 2) &&
178 * For RSDP revision 0 or 1, we use the RSDT. 150 acpi_gbl_RSDP->xsdt_physical_address) {
179 * For RSDP revision 2 (and above), we use the XSDT
180 */
181 if (acpi_gbl_RSDP->revision < 2) {
182 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
183 }
184 else {
185 out_address->pointer.value = 151 out_address->pointer.value =
186 acpi_gbl_RSDP->xsdt_physical_address; 152 acpi_gbl_RSDP->xsdt_physical_address;
153 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
154 } else {
155 /* No XSDT, use the RSDT */
156
157 out_address->pointer.value =
158 acpi_gbl_RSDP->rsdt_physical_address;
159 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
187 } 160 }
188} 161}
189 162
190
191/******************************************************************************* 163/*******************************************************************************
192 * 164 *
193 * FUNCTION: acpi_tb_validate_rsdt 165 * FUNCTION: acpi_tb_validate_rsdt
@@ -200,50 +172,43 @@ acpi_tb_get_rsdt_address (
200 * 172 *
201 ******************************************************************************/ 173 ******************************************************************************/
202 174
203acpi_status 175acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
204acpi_tb_validate_rsdt (
205 struct acpi_table_header *table_ptr)
206{ 176{
207 int no_match; 177 int no_match;
208
209
210 ACPI_FUNCTION_NAME ("tb_validate_rsdt");
211 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt");
212 180
213 /* 181 /*
214 * For RSDP revision 0 or 1, we use the RSDT. 182 * Search for appropriate signature, RSDT or XSDT
215 * For RSDP revision 2 and above, we use the XSDT
216 */ 183 */
217 if (acpi_gbl_RSDP->revision < 2) { 184 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
218 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, 185 no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG,
219 sizeof (RSDT_SIG) -1); 186 sizeof(RSDT_SIG) - 1);
220 } 187 } else {
221 else { 188 no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG,
222 no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG, 189 sizeof(XSDT_SIG) - 1);
223 sizeof (XSDT_SIG) -1);
224 } 190 }
225 191
226 if (no_match) { 192 if (no_match) {
227 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
228 194
229 ACPI_REPORT_ERROR (( 195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
230 "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
231 196
232 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); 197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
233 198
234 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, 199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR,
235 "RSDT/XSDT signature at %X (%p) is invalid\n", 200 "RSDT/XSDT signature at %X (%p) is invalid\n",
236 acpi_gbl_RSDP->rsdt_physical_address, 201 acpi_gbl_RSDP->rsdt_physical_address,
237 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); 202 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address));
238 204
239 if (acpi_gbl_RSDP->revision < 2) { 205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
240 ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) 206 ACPI_REPORT_ERROR(("Looking for RSDT\n"))
241 } 207 } else {
242 else { 208 ACPI_REPORT_ERROR(("Looking for XSDT\n"))
243 ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n"))
244 } 209 }
245 210
246 ACPI_DUMP_BUFFER ((char *) table_ptr, 48); 211 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
247 212
248 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
249 } 214 }
@@ -251,7 +216,6 @@ acpi_tb_validate_rsdt (
251 return (AE_OK); 216 return (AE_OK);
252} 217}
253 218
254
255/******************************************************************************* 219/*******************************************************************************
256 * 220 *
257 * FUNCTION: acpi_tb_get_table_rsdt 221 * FUNCTION: acpi_tb_get_table_rsdt
@@ -264,66 +228,61 @@ acpi_tb_validate_rsdt (
264 * 228 *
265 ******************************************************************************/ 229 ******************************************************************************/
266 230
267acpi_status 231acpi_status acpi_tb_get_table_rsdt(void)
268acpi_tb_get_table_rsdt (
269 void)
270{ 232{
271 struct acpi_table_desc table_info; 233 struct acpi_table_desc table_info;
272 acpi_status status; 234 acpi_status status;
273 struct acpi_pointer address; 235 struct acpi_pointer address;
274
275
276 ACPI_FUNCTION_TRACE ("tb_get_table_rsdt");
277 236
237 ACPI_FUNCTION_TRACE("tb_get_table_rsdt");
278 238
279 /* Get the RSDT/XSDT via the RSDP */ 239 /* Get the RSDT/XSDT via the RSDP */
280 240
281 acpi_tb_get_rsdt_address (&address); 241 acpi_tb_get_rsdt_address(&address);
282 242
283 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
284 status = acpi_tb_get_table (&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
285 if (ACPI_FAILURE (status)) { 245 if (ACPI_FAILURE(status)) {
286 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", 246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
287 acpi_format_exception (status))); 247 "Could not get the RSDT/XSDT, %s\n",
248 acpi_format_exception(status)));
288 249
289 return_ACPI_STATUS (status); 250 return_ACPI_STATUS(status);
290 } 251 }
291 252
292 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
293 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n",
294 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
295 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
296 257
297 /* Check the RSDT or XSDT signature */ 258 /* Check the RSDT or XSDT signature */
298 259
299 status = acpi_tb_validate_rsdt (table_info.pointer); 260 status = acpi_tb_validate_rsdt(table_info.pointer);
300 if (ACPI_FAILURE (status)) { 261 if (ACPI_FAILURE(status)) {
301 return_ACPI_STATUS (status); 262 return_ACPI_STATUS(status);
302 } 263 }
303 264
304 /* Get the number of tables defined in the RSDT or XSDT */ 265 /* Get the number of tables defined in the RSDT or XSDT */
305 266
306 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, 267 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count(acpi_gbl_RSDP,
307 table_info.pointer); 268 table_info.pointer);
308 269
309 /* Convert and/or copy to an XSDT structure */ 270 /* Convert and/or copy to an XSDT structure */
310 271
311 status = acpi_tb_convert_to_xsdt (&table_info); 272 status = acpi_tb_convert_to_xsdt(&table_info);
312 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE(status)) {
313 return_ACPI_STATUS (status); 274 return_ACPI_STATUS(status);
314 } 275 }
315 276
316 /* Save the table pointers and allocation info */ 277 /* Save the table pointers and allocation info */
317 278
318 status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); 279 status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info);
319 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
320 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
321 } 282 }
322 283
323 acpi_gbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info.pointer); 284 acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer);
324 285
325 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));
326 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
327} 288}
328
329
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index e69d01d443d2..4b2fbb592f49 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -41,23 +41,84 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbutils") 48ACPI_MODULE_NAME("tbutils")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54#ifdef ACPI_OBSOLETE_FUNCTIONS 51#ifdef ACPI_OBSOLETE_FUNCTIONS
55acpi_status 52acpi_status
56acpi_tb_handle_to_object ( 53acpi_tb_handle_to_object(u16 table_id, struct acpi_table_desc **table_desc);
57 u16 table_id,
58 struct acpi_table_desc **table_desc);
59#endif 54#endif
60 55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_tb_is_table_installed
59 *
60 * PARAMETERS: new_table_desc - Descriptor for new table being installed
61 *
62 * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed
63 *
64 * DESCRIPTION: Determine if an ACPI table is already installed
65 *
66 * MUTEX: Table data structures should be locked
67 *
68 ******************************************************************************/
69
70acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
71{
72 struct acpi_table_desc *table_desc;
73
74 ACPI_FUNCTION_TRACE("tb_is_table_installed");
75
76 /* Get the list descriptor and first table descriptor */
77
78 table_desc = acpi_gbl_table_lists[new_table_desc->type].next;
79
80 /* Examine all installed tables of this type */
81
82 while (table_desc) {
83 /*
84 * If the table lengths match, perform a full bytewise compare. This
85 * means that we will allow tables with duplicate oem_table_id(s), as
86 * long as the tables are different in some way.
87 *
88 * Checking if the table has been loaded into the namespace means that
89 * we don't check for duplicate tables during the initial installation
90 * of tables within the RSDT/XSDT.
91 */
92 if ((table_desc->loaded_into_namespace) &&
93 (table_desc->pointer->length ==
94 new_table_desc->pointer->length)
95 &&
96 (!ACPI_MEMCMP
97 ((const char *)table_desc->pointer,
98 (const char *)new_table_desc->pointer,
99 (acpi_size) new_table_desc->pointer->length))) {
100 /* Match: this table is already installed */
101
102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
103 "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n",
104 new_table_desc->pointer->signature,
105 new_table_desc->pointer->revision,
106 new_table_desc->pointer->
107 oem_table_id));
108
109 new_table_desc->owner_id = table_desc->owner_id;
110 new_table_desc->installed_desc = table_desc;
111
112 return_ACPI_STATUS(AE_ALREADY_EXISTS);
113 }
114
115 /* Get next table on the list */
116
117 table_desc = table_desc->next;
118 }
119
120 return_ACPI_STATUS(AE_OK);
121}
61 122
62/******************************************************************************* 123/*******************************************************************************
63 * 124 *
@@ -80,57 +141,55 @@ acpi_tb_handle_to_object (
80 ******************************************************************************/ 141 ******************************************************************************/
81 142
82acpi_status 143acpi_status
83acpi_tb_validate_table_header ( 144acpi_tb_validate_table_header(struct acpi_table_header *table_header)
84 struct acpi_table_header *table_header)
85{ 145{
86 acpi_name signature; 146 acpi_name signature;
87
88
89 ACPI_FUNCTION_NAME ("tb_validate_table_header");
90 147
148 ACPI_FUNCTION_NAME("tb_validate_table_header");
91 149
92 /* Verify that this is a valid address */ 150 /* Verify that this is a valid address */
93 151
94 if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) { 152 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
95 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
96 "Cannot read table header at %p\n", table_header)); 154 "Cannot read table header at %p\n",
155 table_header));
97 156
98 return (AE_BAD_ADDRESS); 157 return (AE_BAD_ADDRESS);
99 } 158 }
100 159
101 /* Ensure that the signature is 4 ASCII characters */ 160 /* Ensure that the signature is 4 ASCII characters */
102 161
103 ACPI_MOVE_32_TO_32 (&signature, table_header->signature); 162 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
104 if (!acpi_ut_valid_acpi_name (signature)) { 163 if (!acpi_ut_valid_acpi_name(signature)) {
105 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
106 "Table signature at %p [%p] has invalid characters\n", 165 "Table signature at %p [%p] has invalid characters\n",
107 table_header, &signature)); 166 table_header, &signature));
108 167
109 ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", 168 ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n",
110 (char *) &signature)); 169 (char *)&signature));
111 170
112 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 171 ACPI_DUMP_BUFFER(table_header,
172 sizeof(struct acpi_table_header));
113 return (AE_BAD_SIGNATURE); 173 return (AE_BAD_SIGNATURE);
114 } 174 }
115 175
116 /* Validate the table length */ 176 /* Validate the table length */
117 177
118 if (table_header->length < sizeof (struct acpi_table_header)) { 178 if (table_header->length < sizeof(struct acpi_table_header)) {
119 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
120 "Invalid length in table header %p name %4.4s\n", 180 "Invalid length in table header %p name %4.4s\n",
121 table_header, (char *) &signature)); 181 table_header, (char *)&signature));
122 182
123 ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", 183 ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length));
124 (u32) table_header->length));
125 184
126 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 185 ACPI_DUMP_BUFFER(table_header,
186 sizeof(struct acpi_table_header));
127 return (AE_BAD_HEADER); 187 return (AE_BAD_HEADER);
128 } 188 }
129 189
130 return (AE_OK); 190 return (AE_OK);
131} 191}
132 192
133
134/******************************************************************************* 193/*******************************************************************************
135 * 194 *
136 * FUNCTION: acpi_tb_verify_table_checksum 195 * FUNCTION: acpi_tb_verify_table_checksum
@@ -145,37 +204,31 @@ acpi_tb_validate_table_header (
145 ******************************************************************************/ 204 ******************************************************************************/
146 205
147acpi_status 206acpi_status
148acpi_tb_verify_table_checksum ( 207acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
149 struct acpi_table_header *table_header)
150{ 208{
151 u8 checksum; 209 u8 checksum;
152 acpi_status status = AE_OK; 210 acpi_status status = AE_OK;
153
154
155 ACPI_FUNCTION_TRACE ("tb_verify_table_checksum");
156 211
212 ACPI_FUNCTION_TRACE("tb_verify_table_checksum");
157 213
158 /* Compute the checksum on the table */ 214 /* Compute the checksum on the table */
159 215
160 checksum = acpi_tb_checksum (table_header, table_header->length); 216 checksum =
217 acpi_tb_generate_checksum(table_header, table_header->length);
161 218
162 /* Return the appropriate exception */ 219 /* Return the appropriate exception */
163 220
164 if (checksum) { 221 if (checksum) {
165 ACPI_REPORT_WARNING (( 222 ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum));
166 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
167 table_header->signature, (u32) table_header->checksum,
168 (u32) checksum));
169 223
170 status = AE_BAD_CHECKSUM; 224 status = AE_BAD_CHECKSUM;
171 } 225 }
172 return_ACPI_STATUS (status); 226 return_ACPI_STATUS(status);
173} 227}
174 228
175
176/******************************************************************************* 229/*******************************************************************************
177 * 230 *
178 * FUNCTION: acpi_tb_checksum 231 * FUNCTION: acpi_tb_generate_checksum
179 * 232 *
180 * PARAMETERS: Buffer - Buffer to checksum 233 * PARAMETERS: Buffer - Buffer to checksum
181 * Length - Size of the buffer 234 * Length - Size of the buffer
@@ -186,15 +239,11 @@ acpi_tb_verify_table_checksum (
186 * 239 *
187 ******************************************************************************/ 240 ******************************************************************************/
188 241
189u8 242u8 acpi_tb_generate_checksum(void *buffer, u32 length)
190acpi_tb_checksum (
191 void *buffer,
192 u32 length)
193{ 243{
194 const u8 *limit; 244 const u8 *limit;
195 const u8 *rover; 245 const u8 *rover;
196 u8 sum = 0; 246 u8 sum = 0;
197
198 247
199 if (buffer && length) { 248 if (buffer && length) {
200 /* Buffer and Length are valid */ 249 /* Buffer and Length are valid */
@@ -208,7 +257,6 @@ acpi_tb_checksum (
208 return (sum); 257 return (sum);
209} 258}
210 259
211
212#ifdef ACPI_OBSOLETE_FUNCTIONS 260#ifdef ACPI_OBSOLETE_FUNCTIONS
213/******************************************************************************* 261/*******************************************************************************
214 * 262 *
@@ -224,16 +272,13 @@ acpi_tb_checksum (
224 ******************************************************************************/ 272 ******************************************************************************/
225 273
226acpi_status 274acpi_status
227acpi_tb_handle_to_object ( 275acpi_tb_handle_to_object(u16 table_id,
228 u16 table_id, 276 struct acpi_table_desc ** return_table_desc)
229 struct acpi_table_desc **return_table_desc)
230{ 277{
231 u32 i; 278 u32 i;
232 struct acpi_table_desc *table_desc; 279 struct acpi_table_desc *table_desc;
233
234
235 ACPI_FUNCTION_NAME ("tb_handle_to_object");
236 280
281 ACPI_FUNCTION_NAME("tb_handle_to_object");
237 282
238 for (i = 0; i < ACPI_TABLE_MAX; i++) { 283 for (i = 0; i < ACPI_TABLE_MAX; i++) {
239 table_desc = acpi_gbl_table_lists[i].next; 284 table_desc = acpi_gbl_table_lists[i].next;
@@ -247,9 +292,8 @@ acpi_tb_handle_to_object (
247 } 292 }
248 } 293 }
249 294
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id)); 295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n",
296 table_id));
251 return (AE_BAD_PARAMETER); 297 return (AE_BAD_PARAMETER);
252} 298}
253#endif 299#endif
254
255
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 0c0b9085dbeb..3f96a4909aad 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -48,10 +48,8 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/actables.h> 49#include <acpi/actables.h>
50 50
51
52#define _COMPONENT ACPI_TABLES 51#define _COMPONENT ACPI_TABLES
53 ACPI_MODULE_NAME ("tbxface") 52ACPI_MODULE_NAME("tbxface")
54
55 53
56/******************************************************************************* 54/*******************************************************************************
57 * 55 *
@@ -65,25 +63,20 @@
65 * provided RSDT 63 * provided RSDT
66 * 64 *
67 ******************************************************************************/ 65 ******************************************************************************/
68 66acpi_status acpi_load_tables(void)
69acpi_status
70acpi_load_tables (
71 void)
72{ 67{
73 struct acpi_pointer rsdp_address; 68 struct acpi_pointer rsdp_address;
74 acpi_status status; 69 acpi_status status;
75
76
77 ACPI_FUNCTION_TRACE ("acpi_load_tables");
78 70
71 ACPI_FUNCTION_TRACE("acpi_load_tables");
79 72
80 /* Get the RSDP */ 73 /* Get the RSDP */
81 74
82 status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING, 75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING,
83 &rsdp_address); 76 &rsdp_address);
84 if (ACPI_FAILURE (status)) { 77 if (ACPI_FAILURE(status)) {
85 ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n", 78 ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n",
86 acpi_format_exception (status))); 79 acpi_format_exception(status)));
87 goto error_exit; 80 goto error_exit;
88 } 81 }
89 82
@@ -91,54 +84,47 @@ acpi_load_tables (
91 84
92 acpi_gbl_table_flags = rsdp_address.pointer_type; 85 acpi_gbl_table_flags = rsdp_address.pointer_type;
93 86
94 status = acpi_tb_verify_rsdp (&rsdp_address); 87 status = acpi_tb_verify_rsdp(&rsdp_address);
95 if (ACPI_FAILURE (status)) { 88 if (ACPI_FAILURE(status)) {
96 ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n", 89 ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status)));
97 acpi_format_exception (status)));
98 goto error_exit; 90 goto error_exit;
99 } 91 }
100 92
101 /* Get the RSDT via the RSDP */ 93 /* Get the RSDT via the RSDP */
102 94
103 status = acpi_tb_get_table_rsdt (); 95 status = acpi_tb_get_table_rsdt();
104 if (ACPI_FAILURE (status)) { 96 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n", 97 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status)));
106 acpi_format_exception (status)));
107 goto error_exit; 98 goto error_exit;
108 } 99 }
109 100
110 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */ 101 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
111 102
112 status = acpi_tb_get_required_tables (); 103 status = acpi_tb_get_required_tables();
113 if (ACPI_FAILURE (status)) { 104 if (ACPI_FAILURE(status)) {
114 ACPI_REPORT_ERROR (( 105 ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status)));
115 "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
116 acpi_format_exception (status)));
117 goto error_exit; 106 goto error_exit;
118 } 107 }
119 108
120 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 109 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
121 110
122 /* Load the namespace from the tables */ 111 /* Load the namespace from the tables */
123 112
124 status = acpi_ns_load_namespace (); 113 status = acpi_ns_load_namespace();
125 if (ACPI_FAILURE (status)) { 114 if (ACPI_FAILURE(status)) {
126 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n", 115 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status)));
127 acpi_format_exception (status)));
128 goto error_exit; 116 goto error_exit;
129 } 117 }
130 118
131 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
132 120
121 error_exit:
122 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n",
123 acpi_format_exception(status)));
133 124
134error_exit: 125 return_ACPI_STATUS(status);
135 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load tables: %s\n",
136 acpi_format_exception (status)));
137
138 return_ACPI_STATUS (status);
139} 126}
140 127
141
142#ifdef ACPI_FUTURE_USAGE 128#ifdef ACPI_FUTURE_USAGE
143/******************************************************************************* 129/*******************************************************************************
144 * 130 *
@@ -156,40 +142,49 @@ error_exit:
156 * 142 *
157 ******************************************************************************/ 143 ******************************************************************************/
158 144
159acpi_status 145acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
160acpi_load_table (
161 struct acpi_table_header *table_ptr)
162{ 146{
163 acpi_status status; 147 acpi_status status;
164 struct acpi_table_desc table_info; 148 struct acpi_table_desc table_info;
165 struct acpi_pointer address; 149 struct acpi_pointer address;
166
167
168 ACPI_FUNCTION_TRACE ("acpi_load_table");
169 150
151 ACPI_FUNCTION_TRACE("acpi_load_table");
170 152
171 if (!table_ptr) { 153 if (!table_ptr) {
172 return_ACPI_STATUS (AE_BAD_PARAMETER); 154 return_ACPI_STATUS(AE_BAD_PARAMETER);
173 } 155 }
174 156
175 /* Copy the table to a local buffer */ 157 /* Copy the table to a local buffer */
176 158
177 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; 159 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
178 address.pointer.logical = table_ptr; 160 address.pointer.logical = table_ptr;
179 161
180 status = acpi_tb_get_table_body (&address, table_ptr, &table_info); 162 status = acpi_tb_get_table_body(&address, table_ptr, &table_info);
181 if (ACPI_FAILURE (status)) { 163 if (ACPI_FAILURE(status)) {
182 return_ACPI_STATUS (status); 164 return_ACPI_STATUS(status);
165 }
166
167 /* Check signature for a valid table type */
168
169 status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL);
170 if (ACPI_FAILURE(status)) {
171 return_ACPI_STATUS(status);
183 } 172 }
184 173
185 /* Install the new table into the local data structures */ 174 /* Install the new table into the local data structures */
186 175
187 status = acpi_tb_install_table (&table_info); 176 status = acpi_tb_install_table(&table_info);
188 if (ACPI_FAILURE (status)) { 177 if (ACPI_FAILURE(status)) {
178 if (status == AE_ALREADY_EXISTS) {
179 /* Table already exists, no error */
180
181 status = AE_OK;
182 }
183
189 /* Free table allocated by acpi_tb_get_table_body */ 184 /* Free table allocated by acpi_tb_get_table_body */
190 185
191 acpi_tb_delete_single_table (&table_info); 186 acpi_tb_delete_single_table(&table_info);
192 return_ACPI_STATUS (status); 187 return_ACPI_STATUS(status);
193 } 188 }
194 189
195 /* Convert the table to common format if necessary */ 190 /* Convert the table to common format if necessary */
@@ -197,31 +192,32 @@ acpi_load_table (
197 switch (table_info.type) { 192 switch (table_info.type) {
198 case ACPI_TABLE_FADT: 193 case ACPI_TABLE_FADT:
199 194
200 status = acpi_tb_convert_table_fadt (); 195 status = acpi_tb_convert_table_fadt();
201 break; 196 break;
202 197
203 case ACPI_TABLE_FACS: 198 case ACPI_TABLE_FACS:
204 199
205 status = acpi_tb_build_common_facs (&table_info); 200 status = acpi_tb_build_common_facs(&table_info);
206 break; 201 break;
207 202
208 default: 203 default:
209 /* Load table into namespace if it contains executable AML */ 204 /* Load table into namespace if it contains executable AML */
210 205
211 status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node); 206 status =
207 acpi_ns_load_table(table_info.installed_desc,
208 acpi_gbl_root_node);
212 break; 209 break;
213 } 210 }
214 211
215 if (ACPI_FAILURE (status)) { 212 if (ACPI_FAILURE(status)) {
216 /* Uninstall table and free the buffer */ 213 /* Uninstall table and free the buffer */
217 214
218 (void) acpi_tb_uninstall_table (table_info.installed_desc); 215 (void)acpi_tb_uninstall_table(table_info.installed_desc);
219 } 216 }
220 217
221 return_ACPI_STATUS (status); 218 return_ACPI_STATUS(status);
222} 219}
223 220
224
225/******************************************************************************* 221/*******************************************************************************
226 * 222 *
227 * FUNCTION: acpi_unload_table 223 * FUNCTION: acpi_unload_table
@@ -234,20 +230,16 @@ acpi_load_table (
234 * 230 *
235 ******************************************************************************/ 231 ******************************************************************************/
236 232
237acpi_status 233acpi_status acpi_unload_table(acpi_table_type table_type)
238acpi_unload_table (
239 acpi_table_type table_type)
240{ 234{
241 struct acpi_table_desc *table_desc; 235 struct acpi_table_desc *table_desc;
242
243
244 ACPI_FUNCTION_TRACE ("acpi_unload_table");
245 236
237 ACPI_FUNCTION_TRACE("acpi_unload_table");
246 238
247 /* Parameter validation */ 239 /* Parameter validation */
248 240
249 if (table_type > ACPI_TABLE_MAX) { 241 if (table_type > ACPI_TABLE_MAX) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 242 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 243 }
252 244
253 /* Find all tables of the requested type */ 245 /* Find all tables of the requested type */
@@ -260,18 +252,17 @@ acpi_unload_table (
260 * "Scope" operator. Thus, we need to track ownership by an ID, not 252 * "Scope" operator. Thus, we need to track ownership by an ID, not
261 * simply a position within the hierarchy 253 * simply a position within the hierarchy
262 */ 254 */
263 acpi_ns_delete_namespace_by_owner (table_desc->table_id); 255 acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
264 256 acpi_ut_release_owner_id(&table_desc->owner_id);
265 table_desc = table_desc->next; 257 table_desc = table_desc->next;
266 } 258 }
267 259
268 /* Delete (or unmap) all tables of this type */ 260 /* Delete (or unmap) all tables of this type */
269 261
270 acpi_tb_delete_tables_by_type (table_type); 262 acpi_tb_delete_tables_by_type(table_type);
271 return_ACPI_STATUS (AE_OK); 263 return_ACPI_STATUS(AE_OK);
272} 264}
273 265
274
275/******************************************************************************* 266/*******************************************************************************
276 * 267 *
277 * FUNCTION: acpi_get_table_header 268 * FUNCTION: acpi_get_table_header
@@ -294,54 +285,49 @@ acpi_unload_table (
294 ******************************************************************************/ 285 ******************************************************************************/
295 286
296acpi_status 287acpi_status
297acpi_get_table_header ( 288acpi_get_table_header(acpi_table_type table_type,
298 acpi_table_type table_type, 289 u32 instance, struct acpi_table_header *out_table_header)
299 u32 instance,
300 struct acpi_table_header *out_table_header)
301{ 290{
302 struct acpi_table_header *tbl_ptr; 291 struct acpi_table_header *tbl_ptr;
303 acpi_status status; 292 acpi_status status;
304 293
294 ACPI_FUNCTION_TRACE("acpi_get_table_header");
305 295
306 ACPI_FUNCTION_TRACE ("acpi_get_table_header"); 296 if ((instance == 0) ||
307 297 (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) {
308 298 return_ACPI_STATUS(AE_BAD_PARAMETER);
309 if ((instance == 0) ||
310 (table_type == ACPI_TABLE_RSDP) ||
311 (!out_table_header)) {
312 return_ACPI_STATUS (AE_BAD_PARAMETER);
313 } 299 }
314 300
315 /* Check the table type and instance */ 301 /* Check the table type and instance */
316 302
317 if ((table_type > ACPI_TABLE_MAX) || 303 if ((table_type > ACPI_TABLE_MAX) ||
318 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 304 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
319 instance > 1)) { 305 instance > 1)) {
320 return_ACPI_STATUS (AE_BAD_PARAMETER); 306 return_ACPI_STATUS(AE_BAD_PARAMETER);
321 } 307 }
322 308
323 /* Get a pointer to the entire table */ 309 /* Get a pointer to the entire table */
324 310
325 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 311 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
326 if (ACPI_FAILURE (status)) { 312 if (ACPI_FAILURE(status)) {
327 return_ACPI_STATUS (status); 313 return_ACPI_STATUS(status);
328 } 314 }
329 315
330 /* The function will return a NULL pointer if the table is not loaded */ 316 /* The function will return a NULL pointer if the table is not loaded */
331 317
332 if (tbl_ptr == NULL) { 318 if (tbl_ptr == NULL) {
333 return_ACPI_STATUS (AE_NOT_EXIST); 319 return_ACPI_STATUS(AE_NOT_EXIST);
334 } 320 }
335 321
336 /* Copy the header to the caller's buffer */ 322 /* Copy the header to the caller's buffer */
337 323
338 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, 324 ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr,
339 sizeof (struct acpi_table_header)); 325 sizeof(struct acpi_table_header));
340 326
341 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
342} 328}
343 329
344#endif /* ACPI_FUTURE_USAGE */ 330#endif /* ACPI_FUTURE_USAGE */
345 331
346/******************************************************************************* 332/*******************************************************************************
347 * 333 *
@@ -367,43 +353,39 @@ acpi_get_table_header (
367 ******************************************************************************/ 353 ******************************************************************************/
368 354
369acpi_status 355acpi_status
370acpi_get_table ( 356acpi_get_table(acpi_table_type table_type,
371 acpi_table_type table_type, 357 u32 instance, struct acpi_buffer *ret_buffer)
372 u32 instance,
373 struct acpi_buffer *ret_buffer)
374{ 358{
375 struct acpi_table_header *tbl_ptr; 359 struct acpi_table_header *tbl_ptr;
376 acpi_status status; 360 acpi_status status;
377 acpi_size table_length; 361 acpi_size table_length;
378
379
380 ACPI_FUNCTION_TRACE ("acpi_get_table");
381 362
363 ACPI_FUNCTION_TRACE("acpi_get_table");
382 364
383 /* Parameter validation */ 365 /* Parameter validation */
384 366
385 if (instance == 0) { 367 if (instance == 0) {
386 return_ACPI_STATUS (AE_BAD_PARAMETER); 368 return_ACPI_STATUS(AE_BAD_PARAMETER);
387 } 369 }
388 370
389 status = acpi_ut_validate_buffer (ret_buffer); 371 status = acpi_ut_validate_buffer(ret_buffer);
390 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
391 return_ACPI_STATUS (status); 373 return_ACPI_STATUS(status);
392 } 374 }
393 375
394 /* Check the table type and instance */ 376 /* Check the table type and instance */
395 377
396 if ((table_type > ACPI_TABLE_MAX) || 378 if ((table_type > ACPI_TABLE_MAX) ||
397 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 379 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
398 instance > 1)) { 380 instance > 1)) {
399 return_ACPI_STATUS (AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
400 } 382 }
401 383
402 /* Get a pointer to the entire table */ 384 /* Get a pointer to the entire table */
403 385
404 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 386 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
405 if (ACPI_FAILURE (status)) { 387 if (ACPI_FAILURE(status)) {
406 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
407 } 389 }
408 390
409 /* 391 /*
@@ -411,7 +393,7 @@ acpi_get_table (
411 * table is not loaded. 393 * table is not loaded.
412 */ 394 */
413 if (tbl_ptr == NULL) { 395 if (tbl_ptr == NULL) {
414 return_ACPI_STATUS (AE_NOT_EXIST); 396 return_ACPI_STATUS(AE_NOT_EXIST);
415 } 397 }
416 398
417 /* Get the table length */ 399 /* Get the table length */
@@ -419,23 +401,22 @@ acpi_get_table (
419 if (table_type == ACPI_TABLE_RSDP) { 401 if (table_type == ACPI_TABLE_RSDP) {
420 /* RSD PTR is the only "table" without a header */ 402 /* RSD PTR is the only "table" without a header */
421 403
422 table_length = sizeof (struct rsdp_descriptor); 404 table_length = sizeof(struct rsdp_descriptor);
423 } 405 } else {
424 else {
425 table_length = (acpi_size) tbl_ptr->length; 406 table_length = (acpi_size) tbl_ptr->length;
426 } 407 }
427 408
428 /* Validate/Allocate/Clear caller buffer */ 409 /* Validate/Allocate/Clear caller buffer */
429 410
430 status = acpi_ut_initialize_buffer (ret_buffer, table_length); 411 status = acpi_ut_initialize_buffer(ret_buffer, table_length);
431 if (ACPI_FAILURE (status)) { 412 if (ACPI_FAILURE(status)) {
432 return_ACPI_STATUS (status); 413 return_ACPI_STATUS(status);
433 } 414 }
434 415
435 /* Copy the table to the buffer */ 416 /* Copy the table to the buffer */
436 417
437 ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); 418 ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length);
438 return_ACPI_STATUS (AE_OK); 419 return_ACPI_STATUS(AE_OK);
439} 420}
440EXPORT_SYMBOL(acpi_get_table);
441 421
422EXPORT_SYMBOL(acpi_get_table);
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index dc3c3f6a9f62..3b8a7e063e8a 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -46,22 +46,56 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/actables.h> 47#include <acpi/actables.h>
48 48
49
50#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbxfroot") 50ACPI_MODULE_NAME("tbxfroot")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static acpi_status 53static acpi_status
56acpi_tb_find_rsdp ( 54acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags);
57 struct acpi_table_desc *table_info,
58 u32 flags);
59 55
60static u8 * 56static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
61acpi_tb_scan_memory_for_rsdp (
62 u8 *start_address,
63 u32 length);
64 57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_tb_validate_rsdp
61 *
62 * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
63 *
64 * RETURN: Status
65 *
66 * DESCRIPTION: Validate the RSDP (ptr)
67 *
68 ******************************************************************************/
69
70acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
71{
72 ACPI_FUNCTION_ENTRY();
73
74 /*
75 * The signature and checksum must both be correct
76 */
77 if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) {
78 /* Nope, BAD Signature */
79
80 return (AE_BAD_SIGNATURE);
81 }
82
83 /* Check the standard checksum */
84
85 if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
86 return (AE_BAD_CHECKSUM);
87 }
88
89 /* Check extended checksum if table version >= 2 */
90
91 if ((rsdp->revision >= 2) &&
92 (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) !=
93 0)) {
94 return (AE_BAD_CHECKSUM);
95 }
96
97 return (AE_OK);
98}
65 99
66/******************************************************************************* 100/*******************************************************************************
67 * 101 *
@@ -80,28 +114,24 @@ acpi_tb_scan_memory_for_rsdp (
80 ******************************************************************************/ 114 ******************************************************************************/
81 115
82acpi_status 116acpi_status
83acpi_tb_find_table ( 117acpi_tb_find_table(char *signature,
84 char *signature, 118 char *oem_id,
85 char *oem_id, 119 char *oem_table_id, struct acpi_table_header ** table_ptr)
86 char *oem_table_id,
87 struct acpi_table_header **table_ptr)
88{ 120{
89 acpi_status status; 121 acpi_status status;
90 struct acpi_table_header *table; 122 struct acpi_table_header *table;
91
92
93 ACPI_FUNCTION_TRACE ("tb_find_table");
94 123
124 ACPI_FUNCTION_TRACE("tb_find_table");
95 125
96 /* Validate string lengths */ 126 /* Validate string lengths */
97 127
98 if ((ACPI_STRLEN (signature) > ACPI_NAME_SIZE) || 128 if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) ||
99 (ACPI_STRLEN (oem_id) > sizeof (table->oem_id)) || 129 (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) ||
100 (ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) { 130 (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) {
101 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 131 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
102 } 132 }
103 133
104 if (!ACPI_STRNCMP (signature, DSDT_SIG, ACPI_NAME_SIZE)) { 134 if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) {
105 /* 135 /*
106 * The DSDT pointer is contained in the FADT, not the RSDT. 136 * The DSDT pointer is contained in the FADT, not the RSDT.
107 * This code should suffice, because the only code that would perform 137 * This code should suffice, because the only code that would perform
@@ -110,40 +140,36 @@ acpi_tb_find_table (
110 * If this becomes insufficient, the FADT will have to be found first. 140 * If this becomes insufficient, the FADT will have to be found first.
111 */ 141 */
112 if (!acpi_gbl_DSDT) { 142 if (!acpi_gbl_DSDT) {
113 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 143 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
114 } 144 }
115 table = acpi_gbl_DSDT; 145 table = acpi_gbl_DSDT;
116 } 146 } else {
117 else {
118 /* Find the table */ 147 /* Find the table */
119 148
120 status = acpi_get_firmware_table (signature, 1, 149 status = acpi_get_firmware_table(signature, 1,
121 ACPI_LOGICAL_ADDRESSING, &table); 150 ACPI_LOGICAL_ADDRESSING,
122 if (ACPI_FAILURE (status)) { 151 &table);
123 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
124 } 154 }
125 } 155 }
126 156
127 /* Check oem_id and oem_table_id */ 157 /* Check oem_id and oem_table_id */
128 158
129 if ((oem_id[0] && ACPI_STRNCMP ( 159 if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id,
130 oem_id, table->oem_id, 160 sizeof(table->oem_id))) ||
131 sizeof (table->oem_id))) || 161 (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id,
132 162 sizeof(table->oem_table_id)))) {
133 (oem_table_id[0] && ACPI_STRNCMP ( 163 return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
134 oem_table_id, table->oem_table_id,
135 sizeof (table->oem_table_id)))) {
136 return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
137 } 164 }
138 165
139 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", 166 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n",
140 table->signature)); 167 table->signature));
141 168
142 *table_ptr = table; 169 *table_ptr = table;
143 return_ACPI_STATUS (AE_OK); 170 return_ACPI_STATUS(AE_OK);
144} 171}
145 172
146
147/******************************************************************************* 173/*******************************************************************************
148 * 174 *
149 * FUNCTION: acpi_get_firmware_table 175 * FUNCTION: acpi_get_firmware_table
@@ -164,34 +190,28 @@ acpi_tb_find_table (
164 ******************************************************************************/ 190 ******************************************************************************/
165 191
166acpi_status 192acpi_status
167acpi_get_firmware_table ( 193acpi_get_firmware_table(acpi_string signature,
168 acpi_string signature, 194 u32 instance,
169 u32 instance, 195 u32 flags, struct acpi_table_header **table_pointer)
170 u32 flags,
171 struct acpi_table_header **table_pointer)
172{ 196{
173 acpi_status status; 197 acpi_status status;
174 struct acpi_pointer address; 198 struct acpi_pointer address;
175 struct acpi_table_header *header = NULL; 199 struct acpi_table_header *header = NULL;
176 struct acpi_table_desc *table_info = NULL; 200 struct acpi_table_desc *table_info = NULL;
177 struct acpi_table_desc *rsdt_info; 201 struct acpi_table_desc *rsdt_info;
178 u32 table_count; 202 u32 table_count;
179 u32 i; 203 u32 i;
180 u32 j; 204 u32 j;
181
182
183 ACPI_FUNCTION_TRACE ("acpi_get_firmware_table");
184 205
206 ACPI_FUNCTION_TRACE("acpi_get_firmware_table");
185 207
186 /* 208 /*
187 * 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
188 * require that the entire ACPI subsystem is up for this interface. 210 * require that the entire ACPI subsystem is up for this interface.
189 * If we have a buffer, we must have a length too 211 * If we have a buffer, we must have a length too
190 */ 212 */
191 if ((instance == 0) || 213 if ((instance == 0) || (!signature) || (!table_pointer)) {
192 (!signature) || 214 return_ACPI_STATUS(AE_BAD_PARAMETER);
193 (!table_pointer)) {
194 return_ACPI_STATUS (AE_BAD_PARAMETER);
195 } 215 }
196 216
197 /* Ensure that we have a RSDP */ 217 /* Ensure that we have a RSDP */
@@ -199,48 +219,41 @@ acpi_get_firmware_table (
199 if (!acpi_gbl_RSDP) { 219 if (!acpi_gbl_RSDP) {
200 /* Get the RSDP */ 220 /* Get the RSDP */
201 221
202 status = acpi_os_get_root_pointer (flags, &address); 222 status = acpi_os_get_root_pointer(flags, &address);
203 if (ACPI_FAILURE (status)) { 223 if (ACPI_FAILURE(status)) {
204 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n"));
205 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 225 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
206 } 226 }
207 227
208 /* Map and validate the RSDP */ 228 /* Map and validate the RSDP */
209 229
210 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 230 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
211 status = acpi_os_map_memory (address.pointer.physical, 231 status = acpi_os_map_memory(address.pointer.physical,
212 sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP); 232 sizeof(struct
213 if (ACPI_FAILURE (status)) { 233 rsdp_descriptor),
214 return_ACPI_STATUS (status); 234 (void *)&acpi_gbl_RSDP);
235 if (ACPI_FAILURE(status)) {
236 return_ACPI_STATUS(status);
215 } 237 }
216 } 238 } else {
217 else {
218 acpi_gbl_RSDP = address.pointer.logical; 239 acpi_gbl_RSDP = address.pointer.logical;
219 } 240 }
220 241
221 /* The signature and checksum must both be correct */ 242 /* The RDSP signature and checksum must both be correct */
222
223 if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG,
224 sizeof (RSDP_SIG)-1) != 0) {
225 /* Nope, BAD Signature */
226 243
227 return_ACPI_STATUS (AE_BAD_SIGNATURE); 244 status = acpi_tb_validate_rsdp(acpi_gbl_RSDP);
228 } 245 if (ACPI_FAILURE(status)) {
229 246 return_ACPI_STATUS(status);
230 if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
231 /* Nope, BAD Checksum */
232
233 return_ACPI_STATUS (AE_BAD_CHECKSUM);
234 } 247 }
235 } 248 }
236 249
237 /* Get the RSDT address via the RSDP */ 250 /* Get the RSDT address via the RSDP */
238 251
239 acpi_tb_get_rsdt_address (&address); 252 acpi_tb_get_rsdt_address(&address);
240 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
241 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
242 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
243 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
244 257
245 /* Insert processor_mode flags */ 258 /* Insert processor_mode flags */
246 259
@@ -248,30 +261,30 @@ acpi_get_firmware_table (
248 261
249 /* Get and validate the RSDT */ 262 /* Get and validate the RSDT */
250 263
251 rsdt_info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 264 rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
252 if (!rsdt_info) { 265 if (!rsdt_info) {
253 return_ACPI_STATUS (AE_NO_MEMORY); 266 return_ACPI_STATUS(AE_NO_MEMORY);
254 } 267 }
255 268
256 status = acpi_tb_get_table (&address, rsdt_info); 269 status = acpi_tb_get_table(&address, rsdt_info);
257 if (ACPI_FAILURE (status)) { 270 if (ACPI_FAILURE(status)) {
258 goto cleanup; 271 goto cleanup;
259 } 272 }
260 273
261 status = acpi_tb_validate_rsdt (rsdt_info->pointer); 274 status = acpi_tb_validate_rsdt(rsdt_info->pointer);
262 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
263 goto cleanup; 276 goto cleanup;
264 } 277 }
265 278
266 /* Allocate a scratch table header and table descriptor */ 279 /* Allocate a scratch table header and table descriptor */
267 280
268 header = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_header)); 281 header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header));
269 if (!header) { 282 if (!header) {
270 status = AE_NO_MEMORY; 283 status = AE_NO_MEMORY;
271 goto cleanup; 284 goto cleanup;
272 } 285 }
273 286
274 table_info = ACPI_MEM_ALLOCATE (sizeof (struct acpi_table_desc)); 287 table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc));
275 if (!table_info) { 288 if (!table_info) {
276 status = AE_NO_MEMORY; 289 status = AE_NO_MEMORY;
277 goto cleanup; 290 goto cleanup;
@@ -279,7 +292,8 @@ acpi_get_firmware_table (
279 292
280 /* Get the number of table pointers within the RSDT */ 293 /* Get the number of table pointers within the RSDT */
281 294
282 table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_info->pointer); 295 table_count =
296 acpi_tb_get_table_count(acpi_gbl_RSDP, rsdt_info->pointer);
283 address.pointer_type = acpi_gbl_table_flags | flags; 297 address.pointer_type = acpi_gbl_table_flags | flags;
284 298
285 /* 299 /*
@@ -287,35 +301,42 @@ acpi_get_firmware_table (
287 * requested table 301 * requested table
288 */ 302 */
289 for (i = 0, j = 0; i < table_count; i++) { 303 for (i = 0, j = 0; i < table_count; i++) {
290 /* Get the next table pointer, handle RSDT vs. XSDT */ 304 /*
291 305 * Get the next table pointer, handle RSDT vs. XSDT
292 if (acpi_gbl_RSDP->revision < 2) { 306 * RSDT pointers are 32 bits, XSDT pointers are 64 bits
293 address.pointer.value = (ACPI_CAST_PTR ( 307 */
294 RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 308 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
295 } 309 address.pointer.value =
296 else { 310 (ACPI_CAST_PTR
297 address.pointer.value = (ACPI_CAST_PTR ( 311 (RSDT_DESCRIPTOR,
298 XSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 312 rsdt_info->pointer))->table_offset_entry[i];
313 } else {
314 address.pointer.value =
315 (ACPI_CAST_PTR
316 (XSDT_DESCRIPTOR,
317 rsdt_info->pointer))->table_offset_entry[i];
299 } 318 }
300 319
301 /* Get the table header */ 320 /* Get the table header */
302 321
303 status = acpi_tb_get_table_header (&address, header); 322 status = acpi_tb_get_table_header(&address, header);
304 if (ACPI_FAILURE (status)) { 323 if (ACPI_FAILURE(status)) {
305 goto cleanup; 324 goto cleanup;
306 } 325 }
307 326
308 /* Compare table signatures and table instance */ 327 /* Compare table signatures and table instance */
309 328
310 if (!ACPI_STRNCMP (header->signature, signature, ACPI_NAME_SIZE)) { 329 if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) {
311 /* An instance of the table was found */ 330 /* An instance of the table was found */
312 331
313 j++; 332 j++;
314 if (j >= instance) { 333 if (j >= instance) {
315 /* Found the correct instance, get the entire table */ 334 /* Found the correct instance, get the entire table */
316 335
317 status = acpi_tb_get_table_body (&address, header, table_info); 336 status =
318 if (ACPI_FAILURE (status)) { 337 acpi_tb_get_table_body(&address, header,
338 table_info);
339 if (ACPI_FAILURE(status)) {
319 goto cleanup; 340 goto cleanup;
320 } 341 }
321 342
@@ -329,22 +350,23 @@ acpi_get_firmware_table (
329 350
330 status = AE_NOT_EXIST; 351 status = AE_NOT_EXIST;
331 352
332 353 cleanup:
333cleanup: 354 if (rsdt_info->pointer) {
334 acpi_os_unmap_memory (rsdt_info->pointer, 355 acpi_os_unmap_memory(rsdt_info->pointer,
335 (acpi_size) rsdt_info->pointer->length); 356 (acpi_size) rsdt_info->pointer->length);
336 ACPI_MEM_FREE (rsdt_info); 357 }
358 ACPI_MEM_FREE(rsdt_info);
337 359
338 if (header) { 360 if (header) {
339 ACPI_MEM_FREE (header); 361 ACPI_MEM_FREE(header);
340 } 362 }
341 if (table_info) { 363 if (table_info) {
342 ACPI_MEM_FREE (table_info); 364 ACPI_MEM_FREE(table_info);
343 } 365 }
344 return_ACPI_STATUS (status); 366 return_ACPI_STATUS(status);
345} 367}
346EXPORT_SYMBOL(acpi_get_firmware_table);
347 368
369EXPORT_SYMBOL(acpi_get_firmware_table);
348 370
349/* TBD: Move to a new file */ 371/* TBD: Move to a new file */
350 372
@@ -363,35 +385,29 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
363 * 385 *
364 ******************************************************************************/ 386 ******************************************************************************/
365 387
366acpi_status 388acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
367acpi_find_root_pointer (
368 u32 flags,
369 struct acpi_pointer *rsdp_address)
370{ 389{
371 struct acpi_table_desc table_info; 390 struct acpi_table_desc table_info;
372 acpi_status status; 391 acpi_status status;
373
374
375 ACPI_FUNCTION_TRACE ("acpi_find_root_pointer");
376 392
393 ACPI_FUNCTION_TRACE("acpi_find_root_pointer");
377 394
378 /* Get the RSDP */ 395 /* Get the RSDP */
379 396
380 status = acpi_tb_find_rsdp (&table_info, flags); 397 status = acpi_tb_find_rsdp(&table_info, flags);
381 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 399 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
383 "RSDP structure not found, %s Flags=%X\n", 400 "RSDP structure not found, %s Flags=%X\n",
384 acpi_format_exception (status), flags)); 401 acpi_format_exception(status), flags));
385 402
386 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 403 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
387 } 404 }
388 405
389 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER; 406 rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER;
390 rsdp_address->pointer.physical = table_info.physical_address; 407 rsdp_address->pointer.physical = table_info.physical_address;
391 return_ACPI_STATUS (AE_OK); 408 return_ACPI_STATUS(AE_OK);
392} 409}
393 410
394
395/******************************************************************************* 411/*******************************************************************************
396 * 412 *
397 * FUNCTION: acpi_tb_scan_memory_for_rsdp 413 * FUNCTION: acpi_tb_scan_memory_for_rsdp
@@ -405,68 +421,45 @@ acpi_find_root_pointer (
405 * 421 *
406 ******************************************************************************/ 422 ******************************************************************************/
407 423
408static u8 * 424static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
409acpi_tb_scan_memory_for_rsdp (
410 u8 *start_address,
411 u32 length)
412{ 425{
413 u8 *mem_rover; 426 acpi_status status;
414 u8 *end_address; 427 u8 *mem_rover;
415 u8 checksum; 428 u8 *end_address;
416
417
418 ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp");
419 429
430 ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp");
420 431
421 end_address = start_address + length; 432 end_address = start_address + length;
422 433
423 /* Search from given start address for the requested length */ 434 /* Search from given start address for the requested length */
424 435
425 for (mem_rover = start_address; mem_rover < end_address; 436 for (mem_rover = start_address; mem_rover < end_address;
426 mem_rover += ACPI_RSDP_SCAN_STEP) { 437 mem_rover += ACPI_RSDP_SCAN_STEP) {
427 /* The signature and checksum must both be correct */ 438 /* The RSDP signature and checksum must both be correct */
428 439
429 if (ACPI_STRNCMP ((char *) mem_rover, 440 status =
430 RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) { 441 acpi_tb_validate_rsdp(ACPI_CAST_PTR
431 /* No signature match, keep looking */ 442 (struct rsdp_descriptor, mem_rover));
432 443 if (ACPI_SUCCESS(status)) {
433 continue; 444 /* Sig and checksum valid, we have found a real RSDP */
434 } 445
435 446 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
436 /* Signature matches, check the appropriate checksum */ 447 "RSDP located at physical address %p\n",
437 448 mem_rover));
438 if ((ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover))->revision < 2) { 449 return_PTR(mem_rover);
439 /* ACPI version 1.0 */
440
441 checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH);
442 }
443 else {
444 /* Post ACPI 1.0, use extended_checksum */
445
446 checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_XCHECKSUM_LENGTH);
447 } 450 }
448 451
449 if (checksum == 0) { 452 /* No sig match or bad checksum, keep searching */
450 /* Checksum valid, we have found a valid RSDP */
451
452 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
453 "RSDP located at physical address %p\n", mem_rover));
454 return_PTR (mem_rover);
455 }
456
457 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
458 "Found an RSDP at physical address %p, but it has a bad checksum\n",
459 mem_rover));
460 } 453 }
461 454
462 /* Searched entire block, no RSDP was found */ 455 /* Searched entire block, no RSDP was found */
463 456
464 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 457 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
465 "Searched entire block, no valid RSDP was found.\n")); 458 "Searched entire block from %p, valid RSDP was not found\n",
466 return_PTR (NULL); 459 start_address));
460 return_PTR(NULL);
467} 461}
468 462
469
470/******************************************************************************* 463/*******************************************************************************
471 * 464 *
472 * FUNCTION: acpi_tb_find_rsdp 465 * FUNCTION: acpi_tb_find_rsdp
@@ -490,18 +483,14 @@ acpi_tb_scan_memory_for_rsdp (
490 ******************************************************************************/ 483 ******************************************************************************/
491 484
492static acpi_status 485static acpi_status
493acpi_tb_find_rsdp ( 486acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
494 struct acpi_table_desc *table_info,
495 u32 flags)
496{ 487{
497 u8 *table_ptr; 488 u8 *table_ptr;
498 u8 *mem_rover; 489 u8 *mem_rover;
499 u32 physical_address; 490 u32 physical_address;
500 acpi_status status; 491 acpi_status status;
501
502
503 ACPI_FUNCTION_TRACE ("tb_find_rsdp");
504 492
493 ACPI_FUNCTION_TRACE("tb_find_rsdp");
505 494
506 /* 495 /*
507 * Scan supports either logical addressing or physical addressing 496 * Scan supports either logical addressing or physical addressing
@@ -509,23 +498,25 @@ acpi_tb_find_rsdp (
509 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 498 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
510 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ 499 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
511 500
512 status = acpi_os_map_memory ( 501 status = acpi_os_map_memory((acpi_physical_address)
513 (acpi_physical_address) ACPI_EBDA_PTR_LOCATION, 502 ACPI_EBDA_PTR_LOCATION,
514 ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr); 503 ACPI_EBDA_PTR_LENGTH,
515 if (ACPI_FAILURE (status)) { 504 (void *)&table_ptr);
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 505 if (ACPI_FAILURE(status)) {
517 "Could not map memory at %8.8X for length %X\n", 506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
518 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); 507 "Could not map memory at %8.8X for length %X\n",
519 508 ACPI_EBDA_PTR_LOCATION,
520 return_ACPI_STATUS (status); 509 ACPI_EBDA_PTR_LENGTH));
510
511 return_ACPI_STATUS(status);
521 } 512 }
522 513
523 ACPI_MOVE_16_TO_32 (&physical_address, table_ptr); 514 ACPI_MOVE_16_TO_32(&physical_address, table_ptr);
524 515
525 /* Convert segment part to physical address */ 516 /* Convert segment part to physical address */
526 517
527 physical_address <<= 4; 518 physical_address <<= 4;
528 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH); 519 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH);
529 520
530 /* EBDA present? */ 521 /* EBDA present? */
531 522
@@ -534,59 +525,67 @@ acpi_tb_find_rsdp (
534 * 1b) Search EBDA paragraphs (EBDa is required to be a 525 * 1b) Search EBDA paragraphs (EBDa is required to be a
535 * minimum of 1_k length) 526 * minimum of 1_k length)
536 */ 527 */
537 status = acpi_os_map_memory ( 528 status = acpi_os_map_memory((acpi_physical_address)
538 (acpi_physical_address) physical_address, 529 physical_address,
539 ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr); 530 ACPI_EBDA_WINDOW_SIZE,
540 if (ACPI_FAILURE (status)) { 531 (void *)&table_ptr);
541 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 532 if (ACPI_FAILURE(status)) {
542 "Could not map memory at %8.8X for length %X\n", 533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
543 physical_address, ACPI_EBDA_WINDOW_SIZE)); 534 "Could not map memory at %8.8X for length %X\n",
544 535 physical_address,
545 return_ACPI_STATUS (status); 536 ACPI_EBDA_WINDOW_SIZE));
537
538 return_ACPI_STATUS(status);
546 } 539 }
547 540
548 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, 541 mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr,
549 ACPI_EBDA_WINDOW_SIZE); 542 ACPI_EBDA_WINDOW_SIZE);
550 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); 543 acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
551 544
552 if (mem_rover) { 545 if (mem_rover) {
553 /* Found it, return the physical address */ 546 /* Return the physical address */
554 547
555 physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); 548 physical_address +=
549 ACPI_PTR_DIFF(mem_rover, table_ptr);
556 550
557 table_info->physical_address = 551 table_info->physical_address =
558 (acpi_physical_address) physical_address; 552 (acpi_physical_address) physical_address;
559 return_ACPI_STATUS (AE_OK); 553 return_ACPI_STATUS(AE_OK);
560 } 554 }
561 } 555 }
562 556
563 /* 557 /*
564 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 558 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
565 */ 559 */
566 status = acpi_os_map_memory ( 560 status = acpi_os_map_memory((acpi_physical_address)
567 (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE, 561 ACPI_HI_RSDP_WINDOW_BASE,
568 ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr); 562 ACPI_HI_RSDP_WINDOW_SIZE,
569 563 (void *)&table_ptr);
570 if (ACPI_FAILURE (status)) { 564
571 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 565 if (ACPI_FAILURE(status)) {
572 "Could not map memory at %8.8X for length %X\n", 566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
573 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); 567 "Could not map memory at %8.8X for length %X\n",
574 568 ACPI_HI_RSDP_WINDOW_BASE,
575 return_ACPI_STATUS (status); 569 ACPI_HI_RSDP_WINDOW_SIZE));
570
571 return_ACPI_STATUS(status);
576 } 572 }
577 573
578 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 574 mem_rover =
579 acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); 575 acpi_tb_scan_memory_for_rsdp(table_ptr,
576 ACPI_HI_RSDP_WINDOW_SIZE);
577 acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
580 578
581 if (mem_rover) { 579 if (mem_rover) {
582 /* Found it, return the physical address */ 580 /* Return the physical address */
583 581
584 physical_address = 582 physical_address =
585 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); 583 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover,
584 table_ptr);
586 585
587 table_info->physical_address = 586 table_info->physical_address =
588 (acpi_physical_address) physical_address; 587 (acpi_physical_address) physical_address;
589 return_ACPI_STATUS (AE_OK); 588 return_ACPI_STATUS(AE_OK);
590 } 589 }
591 } 590 }
592 591
@@ -596,8 +595,8 @@ acpi_tb_find_rsdp (
596 else { 595 else {
597 /* 1a) Get the location of the EBDA */ 596 /* 1a) Get the location of the EBDA */
598 597
599 ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION); 598 ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION);
600 physical_address <<= 4; /* Convert segment to physical address */ 599 physical_address <<= 4; /* Convert segment to physical address */
601 600
602 /* EBDA present? */ 601 /* EBDA present? */
603 602
@@ -606,34 +605,38 @@ acpi_tb_find_rsdp (
606 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 605 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of
607 * 1_k length) 606 * 1_k length)
608 */ 607 */
609 mem_rover = acpi_tb_scan_memory_for_rsdp ( 608 mem_rover =
610 ACPI_PHYSADDR_TO_PTR (physical_address), 609 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
611 ACPI_EBDA_WINDOW_SIZE); 610 (physical_address),
611 ACPI_EBDA_WINDOW_SIZE);
612 if (mem_rover) { 612 if (mem_rover) {
613 /* Found it, return the physical address */ 613 /* Return the physical address */
614 614
615 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 615 table_info->physical_address =
616 return_ACPI_STATUS (AE_OK); 616 ACPI_TO_INTEGER(mem_rover);
617 return_ACPI_STATUS(AE_OK);
617 } 618 }
618 } 619 }
619 620
620 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ 621 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
621 622
622 mem_rover = acpi_tb_scan_memory_for_rsdp ( 623 mem_rover =
623 ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), 624 acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
624 ACPI_HI_RSDP_WINDOW_SIZE); 625 (ACPI_HI_RSDP_WINDOW_BASE),
626 ACPI_HI_RSDP_WINDOW_SIZE);
625 if (mem_rover) { 627 if (mem_rover) {
626 /* Found it, return the physical address */ 628 /* Found it, return the physical address */
627 629
628 table_info->physical_address = ACPI_TO_INTEGER (mem_rover); 630 table_info->physical_address =
629 return_ACPI_STATUS (AE_OK); 631 ACPI_TO_INTEGER(mem_rover);
632 return_ACPI_STATUS(AE_OK);
630 } 633 }
631 } 634 }
632 635
633 /* RSDP signature was not found */ 636 /* A valid RSDP was not found */
634 637
635 return_ACPI_STATUS (AE_NOT_FOUND); 638 ACPI_REPORT_ERROR(("No valid RSDP was found\n"));
639 return_ACPI_STATUS(AE_NOT_FOUND);
636} 640}
637 641
638#endif 642#endif
639