aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables/tbinstal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables/tbinstal.c')
-rw-r--r--drivers/acpi/tables/tbinstal.c264
1 files changed, 119 insertions, 145 deletions
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 629b64c8193d..10db8484e462 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -41,22 +41,16 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbinstal") 48ACPI_MODULE_NAME("tbinstal")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_tb_match_signature ( 52acpi_tb_match_signature(char *signature,
56 char *signature, 53 struct acpi_table_desc *table_info, u8 search_type);
57 struct acpi_table_desc *table_info,
58 u8 search_type);
59
60 54
61/******************************************************************************* 55/*******************************************************************************
62 * 56 *
@@ -74,16 +68,12 @@ acpi_tb_match_signature (
74 ******************************************************************************/ 68 ******************************************************************************/
75 69
76static acpi_status 70static acpi_status
77acpi_tb_match_signature ( 71acpi_tb_match_signature(char *signature,
78 char *signature, 72 struct acpi_table_desc *table_info, u8 search_type)
79 struct acpi_table_desc *table_info,
80 u8 search_type)
81{ 73{
82 acpi_native_uint i; 74 acpi_native_uint i;
83
84
85 ACPI_FUNCTION_TRACE ("tb_match_signature");
86 75
76 ACPI_FUNCTION_TRACE("tb_match_signature");
87 77
88 /* Search for a signature match among the known table types */ 78 /* Search for a signature match among the known table types */
89 79
@@ -92,30 +82,30 @@ acpi_tb_match_signature (
92 continue; 82 continue;
93 } 83 }
94 84
95 if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature, 85 if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature,
96 acpi_gbl_table_data[i].sig_length)) { 86 acpi_gbl_table_data[i].sig_length)) {
97 /* Found a signature match, return index if requested */ 87 /* Found a signature match, return index if requested */
98 88
99 if (table_info) { 89 if (table_info) {
100 table_info->type = (u8) i; 90 table_info->type = (u8) i;
101 } 91 }
102 92
103 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 93 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
104 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", 94 "Table [%4.4s] is an ACPI table consumed by the core subsystem\n",
105 (char *) acpi_gbl_table_data[i].signature)); 95 (char *)acpi_gbl_table_data[i].
96 signature));
106 97
107 return_ACPI_STATUS (AE_OK); 98 return_ACPI_STATUS(AE_OK);
108 } 99 }
109 } 100 }
110 101
111 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 102 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
112 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", 103 "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n",
113 (char *) signature)); 104 (char *)signature));
114 105
115 return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); 106 return_ACPI_STATUS(AE_TABLE_NOT_SUPPORTED);
116} 107}
117 108
118
119/******************************************************************************* 109/*******************************************************************************
120 * 110 *
121 * FUNCTION: acpi_tb_install_table 111 * FUNCTION: acpi_tb_install_table
@@ -124,46 +114,52 @@ acpi_tb_match_signature (
124 * 114 *
125 * RETURN: Status 115 * RETURN: Status
126 * 116 *
127 * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must 117 * DESCRIPTION: Install the table into the global data structures.
128 * already be loaded and validated.
129 * Install the table into the global data structs.
130 * 118 *
131 ******************************************************************************/ 119 ******************************************************************************/
132 120
133acpi_status 121acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
134acpi_tb_install_table (
135 struct acpi_table_desc *table_info)
136{ 122{
137 acpi_status status; 123 acpi_status status;
138
139 ACPI_FUNCTION_TRACE ("tb_install_table");
140 124
125 ACPI_FUNCTION_TRACE("tb_install_table");
141 126
142 /* Lock tables while installing */ 127 /* Lock tables while installing */
143 128
144 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
145 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
146 ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", 131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n",
147 table_info->pointer->signature, acpi_format_exception (status))); 132 acpi_format_exception(status)));
148 return_ACPI_STATUS (status); 133 return_ACPI_STATUS(status);
134 }
135
136 /*
137 * Ignore a table that is already installed. For example, some BIOS
138 * ASL code will repeatedly attempt to load the same SSDT.
139 */
140 status = acpi_tb_is_table_installed(table_info);
141 if (ACPI_FAILURE(status)) {
142 goto unlock_and_exit;
149 } 143 }
150 144
151 /* Install the table into the global data structure */ 145 /* Install the table into the global data structure */
152 146
153 status = acpi_tb_init_table_descriptor (table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
154 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
155 ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", 149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n",
156 table_info->pointer->signature, acpi_format_exception (status))); 150 table_info->pointer->signature,
151 acpi_format_exception(status)));
157 } 152 }
158 153
159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
160 acpi_gbl_table_data[table_info->type].name, table_info->pointer)); 155 acpi_gbl_table_data[table_info->type].name,
156 table_info->pointer));
161 157
162 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 158 unlock_and_exit:
163 return_ACPI_STATUS (status); 159 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
160 return_ACPI_STATUS(status);
164} 161}
165 162
166
167/******************************************************************************* 163/*******************************************************************************
168 * 164 *
169 * FUNCTION: acpi_tb_recognize_table 165 * FUNCTION: acpi_tb_recognize_table
@@ -186,22 +182,18 @@ acpi_tb_install_table (
186 ******************************************************************************/ 182 ******************************************************************************/
187 183
188acpi_status 184acpi_status
189acpi_tb_recognize_table ( 185acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type)
190 struct acpi_table_desc *table_info,
191 u8 search_type)
192{ 186{
193 struct acpi_table_header *table_header; 187 struct acpi_table_header *table_header;
194 acpi_status status; 188 acpi_status status;
195
196
197 ACPI_FUNCTION_TRACE ("tb_recognize_table");
198 189
190 ACPI_FUNCTION_TRACE("tb_recognize_table");
199 191
200 /* Ensure that we have a valid table pointer */ 192 /* Ensure that we have a valid table pointer */
201 193
202 table_header = (struct acpi_table_header *) table_info->pointer; 194 table_header = (struct acpi_table_header *)table_info->pointer;
203 if (!table_header) { 195 if (!table_header) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 196 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 197 }
206 198
207 /* 199 /*
@@ -212,25 +204,24 @@ acpi_tb_recognize_table (
212 * This can be any one of many valid ACPI tables, it just isn't one of 204 * This can be any one of many valid ACPI tables, it just isn't one of
213 * the tables that is consumed by the core subsystem 205 * the tables that is consumed by the core subsystem
214 */ 206 */
215 status = acpi_tb_match_signature (table_header->signature, 207 status = acpi_tb_match_signature(table_header->signature,
216 table_info, search_type); 208 table_info, search_type);
217 if (ACPI_FAILURE (status)) { 209 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
219 } 211 }
220 212
221 status = acpi_tb_validate_table_header (table_header); 213 status = acpi_tb_validate_table_header(table_header);
222 if (ACPI_FAILURE (status)) { 214 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
224 } 216 }
225 217
226 /* Return the table type and length via the info struct */ 218 /* Return the table type and length via the info struct */
227 219
228 table_info->length = (acpi_size) table_header->length; 220 table_info->length = (acpi_size) table_header->length;
229 221
230 return_ACPI_STATUS (status); 222 return_ACPI_STATUS(status);
231} 223}
232 224
233
234/******************************************************************************* 225/*******************************************************************************
235 * 226 *
236 * FUNCTION: acpi_tb_init_table_descriptor 227 * FUNCTION: acpi_tb_init_table_descriptor
@@ -245,22 +236,27 @@ acpi_tb_recognize_table (
245 ******************************************************************************/ 236 ******************************************************************************/
246 237
247acpi_status 238acpi_status
248acpi_tb_init_table_descriptor ( 239acpi_tb_init_table_descriptor(acpi_table_type table_type,
249 acpi_table_type table_type, 240 struct acpi_table_desc *table_info)
250 struct acpi_table_desc *table_info)
251{ 241{
252 struct acpi_table_list *list_head; 242 struct acpi_table_list *list_head;
253 struct acpi_table_desc *table_desc; 243 struct acpi_table_desc *table_desc;
254 244 acpi_status status;
255
256 ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type);
257 245
246 ACPI_FUNCTION_TRACE_U32("tb_init_table_descriptor", table_type);
258 247
259 /* Allocate a descriptor for this table */ 248 /* Allocate a descriptor for this table */
260 249
261 table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); 250 table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
262 if (!table_desc) { 251 if (!table_desc) {
263 return_ACPI_STATUS (AE_NO_MEMORY); 252 return_ACPI_STATUS(AE_NO_MEMORY);
253 }
254
255 /* Get a new owner ID for the table */
256
257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id);
258 if (ACPI_FAILURE(status)) {
259 return_ACPI_STATUS(status);
264 } 260 }
265 261
266 /* Install the table into the global data structure */ 262 /* Install the table into the global data structure */
@@ -272,14 +268,14 @@ acpi_tb_init_table_descriptor (
272 * includes most ACPI tables such as the DSDT. 2) Multiple instances of 268 * includes most ACPI tables such as the DSDT. 2) Multiple instances of
273 * the table are allowed. This includes SSDT and PSDTs. 269 * the table are allowed. This includes SSDT and PSDTs.
274 */ 270 */
275 if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) { 271 if (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags)) {
276 /* 272 /*
277 * Only one table allowed, and a table has alread been installed 273 * Only one table allowed, and a table has alread been installed
278 * at this location, so return an error. 274 * at this location, so return an error.
279 */ 275 */
280 if (list_head->next) { 276 if (list_head->next) {
281 ACPI_MEM_FREE (table_desc); 277 ACPI_MEM_FREE(table_desc);
282 return_ACPI_STATUS (AE_ALREADY_EXISTS); 278 return_ACPI_STATUS(AE_ALREADY_EXISTS);
283 } 279 }
284 280
285 table_desc->next = list_head->next; 281 table_desc->next = list_head->next;
@@ -290,8 +286,7 @@ acpi_tb_init_table_descriptor (
290 } 286 }
291 287
292 list_head->count++; 288 list_head->count++;
293 } 289 } else {
294 else {
295 /* 290 /*
296 * Link the new table in to the list of tables of this type. 291 * Link the new table in to the list of tables of this type.
297 * Insert at the end of the list, order IS IMPORTANT. 292 * Insert at the end of the list, order IS IMPORTANT.
@@ -302,8 +297,7 @@ acpi_tb_init_table_descriptor (
302 297
303 if (!list_head->next) { 298 if (!list_head->next) {
304 list_head->next = table_desc; 299 list_head->next = table_desc;
305 } 300 } else {
306 else {
307 table_desc->next = list_head->next; 301 table_desc->next = list_head->next;
308 302
309 while (table_desc->next->next) { 303 while (table_desc->next->next) {
@@ -318,15 +312,14 @@ acpi_tb_init_table_descriptor (
318 312
319 /* Finish initialization of the table descriptor */ 313 /* Finish initialization of the table descriptor */
320 314
321 table_desc->type = (u8) table_type; 315 table_desc->type = (u8) table_type;
322 table_desc->pointer = table_info->pointer; 316 table_desc->pointer = table_info->pointer;
323 table_desc->length = table_info->length; 317 table_desc->length = table_info->length;
324 table_desc->allocation = table_info->allocation; 318 table_desc->allocation = table_info->allocation;
325 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 319 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
326 table_desc->aml_length = (u32) (table_desc->length - 320 table_desc->aml_length = (u32) (table_desc->length -
327 (u32) sizeof (struct acpi_table_header)); 321 (u32) sizeof(struct
328 table_desc->table_id = acpi_ut_allocate_owner_id ( 322 acpi_table_header));
329 ACPI_OWNER_TYPE_TABLE);
330 table_desc->loaded_into_namespace = FALSE; 323 table_desc->loaded_into_namespace = FALSE;
331 324
332 /* 325 /*
@@ -334,18 +327,18 @@ acpi_tb_init_table_descriptor (
334 * newly installed table 327 * newly installed table
335 */ 328 */
336 if (acpi_gbl_table_data[table_type].global_ptr) { 329 if (acpi_gbl_table_data[table_type].global_ptr) {
337 *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; 330 *(acpi_gbl_table_data[table_type].global_ptr) =
331 table_info->pointer;
338 } 332 }
339 333
340 /* Return Data */ 334 /* Return Data */
341 335
342 table_info->table_id = table_desc->table_id; 336 table_info->owner_id = table_desc->owner_id;
343 table_info->installed_desc = table_desc; 337 table_info->installed_desc = table_desc;
344 338
345 return_ACPI_STATUS (AE_OK); 339 return_ACPI_STATUS(AE_OK);
346} 340}
347 341
348
349/******************************************************************************* 342/*******************************************************************************
350 * 343 *
351 * FUNCTION: acpi_tb_delete_all_tables 344 * FUNCTION: acpi_tb_delete_all_tables
@@ -358,23 +351,19 @@ acpi_tb_init_table_descriptor (
358 * 351 *
359 ******************************************************************************/ 352 ******************************************************************************/
360 353
361void 354void acpi_tb_delete_all_tables(void)
362acpi_tb_delete_all_tables (
363 void)
364{ 355{
365 acpi_table_type type; 356 acpi_table_type type;
366
367 357
368 /* 358 /*
369 * Free memory allocated for ACPI tables 359 * Free memory allocated for ACPI tables
370 * Memory can either be mapped or allocated 360 * Memory can either be mapped or allocated
371 */ 361 */
372 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { 362 for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) {
373 acpi_tb_delete_tables_by_type (type); 363 acpi_tb_delete_tables_by_type(type);
374 } 364 }
375} 365}
376 366
377
378/******************************************************************************* 367/*******************************************************************************
379 * 368 *
380 * FUNCTION: acpi_tb_delete_tables_by_type 369 * FUNCTION: acpi_tb_delete_tables_by_type
@@ -388,23 +377,19 @@ acpi_tb_delete_all_tables (
388 * 377 *
389 ******************************************************************************/ 378 ******************************************************************************/
390 379
391void 380void acpi_tb_delete_tables_by_type(acpi_table_type type)
392acpi_tb_delete_tables_by_type (
393 acpi_table_type type)
394{ 381{
395 struct acpi_table_desc *table_desc; 382 struct acpi_table_desc *table_desc;
396 u32 count; 383 u32 count;
397 u32 i; 384 u32 i;
398
399
400 ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type);
401 385
386 ACPI_FUNCTION_TRACE_U32("tb_delete_tables_by_type", type);
402 387
403 if (type > ACPI_TABLE_MAX) { 388 if (type > ACPI_TABLE_MAX) {
404 return_VOID; 389 return_VOID;
405 } 390 }
406 391
407 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { 392 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) {
408 return; 393 return;
409 } 394 }
410 395
@@ -442,21 +427,20 @@ acpi_tb_delete_tables_by_type (
442 * 1) Get the head of the list 427 * 1) Get the head of the list
443 */ 428 */
444 table_desc = acpi_gbl_table_lists[type].next; 429 table_desc = acpi_gbl_table_lists[type].next;
445 count = acpi_gbl_table_lists[type].count; 430 count = acpi_gbl_table_lists[type].count;
446 431
447 /* 432 /*
448 * 2) Walk the entire list, deleting both the allocated tables 433 * 2) Walk the entire list, deleting both the allocated tables
449 * and the table descriptors 434 * and the table descriptors
450 */ 435 */
451 for (i = 0; i < count; i++) { 436 for (i = 0; i < count; i++) {
452 table_desc = acpi_tb_uninstall_table (table_desc); 437 table_desc = acpi_tb_uninstall_table(table_desc);
453 } 438 }
454 439
455 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 440 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
456 return_VOID; 441 return_VOID;
457} 442}
458 443
459
460/******************************************************************************* 444/*******************************************************************************
461 * 445 *
462 * FUNCTION: acpi_tb_delete_single_table 446 * FUNCTION: acpi_tb_delete_single_table
@@ -470,15 +454,12 @@ acpi_tb_delete_tables_by_type (
470 * 454 *
471 ******************************************************************************/ 455 ******************************************************************************/
472 456
473void 457void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc)
474acpi_tb_delete_single_table (
475 struct acpi_table_desc *table_desc)
476{ 458{
477 459
478 /* Must have a valid table descriptor and pointer */ 460 /* Must have a valid table descriptor and pointer */
479 461
480 if ((!table_desc) || 462 if ((!table_desc) || (!table_desc->pointer)) {
481 (!table_desc->pointer)) {
482 return; 463 return;
483 } 464 }
484 465
@@ -490,12 +471,12 @@ acpi_tb_delete_single_table (
490 471
491 case ACPI_MEM_ALLOCATED: 472 case ACPI_MEM_ALLOCATED:
492 473
493 ACPI_MEM_FREE (table_desc->pointer); 474 ACPI_MEM_FREE(table_desc->pointer);
494 break; 475 break;
495 476
496 case ACPI_MEM_MAPPED: 477 case ACPI_MEM_MAPPED:
497 478
498 acpi_os_unmap_memory (table_desc->pointer, table_desc->length); 479 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
499 break; 480 break;
500 481
501 default: 482 default:
@@ -503,7 +484,6 @@ acpi_tb_delete_single_table (
503 } 484 }
504} 485}
505 486
506
507/******************************************************************************* 487/*******************************************************************************
508 * 488 *
509 * FUNCTION: acpi_tb_uninstall_table 489 * FUNCTION: acpi_tb_uninstall_table
@@ -518,26 +498,22 @@ acpi_tb_delete_single_table (
518 * 498 *
519 ******************************************************************************/ 499 ******************************************************************************/
520 500
521struct acpi_table_desc * 501struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
522acpi_tb_uninstall_table ( 502 *table_desc)
523 struct acpi_table_desc *table_desc)
524{ 503{
525 struct acpi_table_desc *next_desc; 504 struct acpi_table_desc *next_desc;
526
527
528 ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc);
529 505
506 ACPI_FUNCTION_TRACE_PTR("tb_uninstall_table", table_desc);
530 507
531 if (!table_desc) { 508 if (!table_desc) {
532 return_PTR (NULL); 509 return_PTR(NULL);
533 } 510 }
534 511
535 /* Unlink the descriptor from the doubly linked list */ 512 /* Unlink the descriptor from the doubly linked list */
536 513
537 if (table_desc->prev) { 514 if (table_desc->prev) {
538 table_desc->prev->next = table_desc->next; 515 table_desc->prev->next = table_desc->next;
539 } 516 } else {
540 else {
541 /* Is first on list, update list head */ 517 /* Is first on list, update list head */
542 518
543 acpi_gbl_table_lists[table_desc->type].next = table_desc->next; 519 acpi_gbl_table_lists[table_desc->type].next = table_desc->next;
@@ -549,16 +525,14 @@ acpi_tb_uninstall_table (
549 525
550 /* Free the memory allocated for the table itself */ 526 /* Free the memory allocated for the table itself */
551 527
552 acpi_tb_delete_single_table (table_desc); 528 acpi_tb_delete_single_table(table_desc);
553 529
554 /* Free the table descriptor */ 530 /* Free the table descriptor */
555 531
556 next_desc = table_desc->next; 532 next_desc = table_desc->next;
557 ACPI_MEM_FREE (table_desc); 533 ACPI_MEM_FREE(table_desc);
558 534
559 /* Return pointer to the next descriptor */ 535 /* Return pointer to the next descriptor */
560 536
561 return_PTR (next_desc); 537 return_PTR(next_desc);
562} 538}
563
564