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