1 /****************************************************************************** 2 * 3 * Module Name: tbinstal - ACPI table installation and removal 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2013, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 117 #define __TBINSTAL_C__ 118 119 #include "acpi.h" 120 #include "accommon.h" 121 #include "acnamesp.h" 122 #include "actables.h" 123 124 125 #define _COMPONENT ACPI_TABLES 126 ACPI_MODULE_NAME ("tbinstal") 127 128 129 /****************************************************************************** 130 * 131 * FUNCTION: AcpiTbVerifyTable 132 * 133 * PARAMETERS: TableDesc - table 134 * 135 * RETURN: Status 136 * 137 * DESCRIPTION: this function is called to verify and map table 138 * 139 *****************************************************************************/ 140 141 ACPI_STATUS 142 AcpiTbVerifyTable ( 143 ACPI_TABLE_DESC *TableDesc) 144 { 145 ACPI_STATUS Status = AE_OK; 146 147 148 ACPI_FUNCTION_TRACE (TbVerifyTable); 149 150 151 /* Map the table if necessary */ 152 153 if (!TableDesc->Pointer) 154 { 155 if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == 156 ACPI_TABLE_ORIGIN_MAPPED) 157 { 158 TableDesc->Pointer = AcpiOsMapMemory ( 159 TableDesc->Address, TableDesc->Length); 160 } 161 162 if (!TableDesc->Pointer) 163 { 164 return_ACPI_STATUS (AE_NO_MEMORY); 165 } 166 } 167 168 /* Always calculate checksum, ignore bad checksum if requested */ 169 170 Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); 171 172 return_ACPI_STATUS (Status); 173 } 174 175 176 /******************************************************************************* 177 * 178 * FUNCTION: AcpiTbAddTable 179 * 180 * PARAMETERS: TableDesc - Table descriptor 181 * TableIndex - Where the table index is returned 182 * 183 * RETURN: Status 184 * 185 * DESCRIPTION: This function is called to add an ACPI table. It is used to 186 * dynamically load tables via the Load and LoadTable AML 187 * operators. 188 * 189 ******************************************************************************/ 190 191 ACPI_STATUS 192 AcpiTbAddTable ( 193 ACPI_TABLE_DESC *TableDesc, 194 UINT32 *TableIndex) 195 { 196 UINT32 i; 197 ACPI_STATUS Status = AE_OK; 198 199 200 ACPI_FUNCTION_TRACE (TbAddTable); 201 202 203 if (!TableDesc->Pointer) 204 { 205 Status = AcpiTbVerifyTable (TableDesc); 206 if (ACPI_FAILURE (Status) || !TableDesc->Pointer) 207 { 208 return_ACPI_STATUS (Status); 209 } 210 } 211 212 /* 213 * Validate the incoming table signature. 214 * 215 * 1) Originally, we checked the table signature for "SSDT" or "PSDT". 216 * 2) We added support for OEMx tables, signature "OEM". 217 * 3) Valid tables were encountered with a null signature, so we just 218 * gave up on validating the signature, (05/2008). 219 * 4) We encountered non-AML tables such as the MADT, which caused 220 * interpreter errors and kernel faults. So now, we once again allow 221 * only "SSDT", "OEMx", and now, also a null signature. (05/2011). 222 */ 223 if ((TableDesc->Pointer->Signature[0] != 0x00) && 224 (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) && 225 (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3))) 226 { 227 ACPI_BIOS_ERROR ((AE_INFO, 228 "Table has invalid signature [%4.4s] (0x%8.8X), " 229 "must be SSDT or OEMx", 230 AcpiUtValidAcpiName (TableDesc->Pointer->Signature) ? 231 TableDesc->Pointer->Signature : "????", 232 *(UINT32 *) TableDesc->Pointer->Signature)); 233 234 return_ACPI_STATUS (AE_BAD_SIGNATURE); 235 } 236 237 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 238 239 /* Check if table is already registered */ 240 241 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) 242 { 243 if (!AcpiGbl_RootTableList.Tables[i].Pointer) 244 { 245 Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); 246 if (ACPI_FAILURE (Status) || 247 !AcpiGbl_RootTableList.Tables[i].Pointer) 248 { 249 continue; 250 } 251 } 252 253 /* 254 * Check for a table match on the entire table length, 255 * not just the header. 256 */ 257 if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) 258 { 259 continue; 260 } 261 262 if (ACPI_MEMCMP (TableDesc->Pointer, 263 AcpiGbl_RootTableList.Tables[i].Pointer, 264 AcpiGbl_RootTableList.Tables[i].Length)) 265 { 266 continue; 267 } 268 269 /* 270 * Note: the current mechanism does not unregister a table if it is 271 * dynamically unloaded. The related namespace entries are deleted, 272 * but the table remains in the root table list. 273 * 274 * The assumption here is that the number of different tables that 275 * will be loaded is actually small, and there is minimal overhead 276 * in just keeping the table in case it is needed again. 277 * 278 * If this assumption changes in the future (perhaps on large 279 * machines with many table load/unload operations), tables will 280 * need to be unregistered when they are unloaded, and slots in the 281 * root table list should be reused when empty. 282 */ 283 284 /* 285 * Table is already registered. 286 * We can delete the table that was passed as a parameter. 287 */ 288 AcpiTbDeleteTable (TableDesc); 289 *TableIndex = i; 290 291 if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) 292 { 293 /* Table is still loaded, this is an error */ 294 295 Status = AE_ALREADY_EXISTS; 296 goto Release; 297 } 298 else 299 { 300 /* Table was unloaded, allow it to be reloaded */ 301 302 TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; 303 TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; 304 Status = AE_OK; 305 goto PrintHeader; 306 } 307 } 308 309 /* 310 * ACPI Table Override: 311 * Allow the host to override dynamically loaded tables. 312 * NOTE: the table is fully mapped at this point, and the mapping will 313 * be deleted by TbTableOverride if the table is actually overridden. 314 */ 315 (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc); 316 317 /* Add the table to the global root table list */ 318 319 Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, 320 TableDesc->Length, TableDesc->Flags, TableIndex); 321 if (ACPI_FAILURE (Status)) 322 { 323 goto Release; 324 } 325 326 PrintHeader: 327 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); 328 329 Release: 330 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 331 return_ACPI_STATUS (Status); 332 } 333 334 335 /******************************************************************************* 336 * 337 * FUNCTION: AcpiTbTableOverride 338 * 339 * PARAMETERS: TableHeader - Header for the original table 340 * TableDesc - Table descriptor initialized for the 341 * original table. May or may not be mapped. 342 * 343 * RETURN: Pointer to the entire new table. NULL if table not overridden. 344 * If overridden, installs the new table within the input table 345 * descriptor. 346 * 347 * DESCRIPTION: Attempt table override by calling the OSL override functions. 348 * Note: If the table is overridden, then the entire new table 349 * is mapped and returned by this function. 350 * 351 ******************************************************************************/ 352 353 ACPI_TABLE_HEADER * 354 AcpiTbTableOverride ( 355 ACPI_TABLE_HEADER *TableHeader, 356 ACPI_TABLE_DESC *TableDesc) 357 { 358 ACPI_STATUS Status; 359 ACPI_TABLE_HEADER *NewTable = NULL; 360 ACPI_PHYSICAL_ADDRESS NewAddress = 0; 361 UINT32 NewTableLength = 0; 362 UINT8 NewFlags; 363 char *OverrideType; 364 365 366 /* (1) Attempt logical override (returns a logical address) */ 367 368 Status = AcpiOsTableOverride (TableHeader, &NewTable); 369 if (ACPI_SUCCESS (Status) && NewTable) 370 { 371 NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable); 372 NewTableLength = NewTable->Length; 373 NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE; 374 OverrideType = "Logical"; 375 goto FinishOverride; 376 } 377 378 /* (2) Attempt physical override (returns a physical address) */ 379 380 Status = AcpiOsPhysicalTableOverride (TableHeader, 381 &NewAddress, &NewTableLength); 382 if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength) 383 { 384 /* Map the entire new table */ 385 386 NewTable = AcpiOsMapMemory (NewAddress, NewTableLength); 387 if (!NewTable) 388 { 389 ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, 390 "%4.4s %p Attempted physical table override failed", 391 TableHeader->Signature, 392 ACPI_CAST_PTR (void, TableDesc->Address))); 393 return (NULL); 394 } 395 396 OverrideType = "Physical"; 397 NewFlags = ACPI_TABLE_ORIGIN_MAPPED; 398 goto FinishOverride; 399 } 400 401 return (NULL); /* There was no override */ 402 403 404 FinishOverride: 405 406 ACPI_INFO ((AE_INFO, 407 "%4.4s %p %s table override, new table: %p", 408 TableHeader->Signature, 409 ACPI_CAST_PTR (void, TableDesc->Address), 410 OverrideType, NewTable)); 411 412 /* We can now unmap/delete the original table (if fully mapped) */ 413 414 AcpiTbDeleteTable (TableDesc); 415 416 /* Setup descriptor for the new table */ 417 418 TableDesc->Address = NewAddress; 419 TableDesc->Pointer = NewTable; 420 TableDesc->Length = NewTableLength; 421 TableDesc->Flags = NewFlags; 422 423 return (NewTable); 424 } 425 426 427 /******************************************************************************* 428 * 429 * FUNCTION: AcpiTbResizeRootTableList 430 * 431 * PARAMETERS: None 432 * 433 * RETURN: Status 434 * 435 * DESCRIPTION: Expand the size of global table array 436 * 437 ******************************************************************************/ 438 439 ACPI_STATUS 440 AcpiTbResizeRootTableList ( 441 void) 442 { 443 ACPI_TABLE_DESC *Tables; 444 UINT32 TableCount; 445 446 447 ACPI_FUNCTION_TRACE (TbResizeRootTableList); 448 449 450 /* AllowResize flag is a parameter to AcpiInitializeTables */ 451 452 if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) 453 { 454 ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); 455 return_ACPI_STATUS (AE_SUPPORT); 456 } 457 458 /* Increase the Table Array size */ 459 460 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 461 { 462 TableCount = AcpiGbl_RootTableList.MaxTableCount; 463 } 464 else 465 { 466 TableCount = AcpiGbl_RootTableList.CurrentTableCount; 467 } 468 469 Tables = ACPI_ALLOCATE_ZEROED ( 470 ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * 471 sizeof (ACPI_TABLE_DESC)); 472 if (!Tables) 473 { 474 ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); 475 return_ACPI_STATUS (AE_NO_MEMORY); 476 } 477 478 /* Copy and free the previous table array */ 479 480 if (AcpiGbl_RootTableList.Tables) 481 { 482 ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, 483 (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); 484 485 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 486 { 487 ACPI_FREE (AcpiGbl_RootTableList.Tables); 488 } 489 } 490 491 AcpiGbl_RootTableList.Tables = Tables; 492 AcpiGbl_RootTableList.MaxTableCount = 493 TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; 494 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 495 496 return_ACPI_STATUS (AE_OK); 497 } 498 499 500 /******************************************************************************* 501 * 502 * FUNCTION: AcpiTbStoreTable 503 * 504 * PARAMETERS: Address - Table address 505 * Table - Table header 506 * Length - Table length 507 * Flags - flags 508 * 509 * RETURN: Status and table index. 510 * 511 * DESCRIPTION: Add an ACPI table to the global table list 512 * 513 ******************************************************************************/ 514 515 ACPI_STATUS 516 AcpiTbStoreTable ( 517 ACPI_PHYSICAL_ADDRESS Address, 518 ACPI_TABLE_HEADER *Table, 519 UINT32 Length, 520 UINT8 Flags, 521 UINT32 *TableIndex) 522 { 523 ACPI_STATUS Status; 524 ACPI_TABLE_DESC *NewTable; 525 526 527 /* Ensure that there is room for the table in the Root Table List */ 528 529 if (AcpiGbl_RootTableList.CurrentTableCount >= 530 AcpiGbl_RootTableList.MaxTableCount) 531 { 532 Status = AcpiTbResizeRootTableList(); 533 if (ACPI_FAILURE (Status)) 534 { 535 return (Status); 536 } 537 } 538 539 NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount]; 540 541 /* Initialize added table */ 542 543 NewTable->Address = Address; 544 NewTable->Pointer = Table; 545 NewTable->Length = Length; 546 NewTable->OwnerId = 0; 547 NewTable->Flags = Flags; 548 549 ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature); 550 551 *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; 552 AcpiGbl_RootTableList.CurrentTableCount++; 553 return (AE_OK); 554 } 555 556 557 /******************************************************************************* 558 * 559 * FUNCTION: AcpiTbDeleteTable 560 * 561 * PARAMETERS: TableIndex - Table index 562 * 563 * RETURN: None 564 * 565 * DESCRIPTION: Delete one internal ACPI table 566 * 567 ******************************************************************************/ 568 569 void 570 AcpiTbDeleteTable ( 571 ACPI_TABLE_DESC *TableDesc) 572 { 573 574 /* Table must be mapped or allocated */ 575 576 if (!TableDesc->Pointer) 577 { 578 return; 579 } 580 581 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) 582 { 583 case ACPI_TABLE_ORIGIN_MAPPED: 584 585 AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); 586 break; 587 588 case ACPI_TABLE_ORIGIN_ALLOCATED: 589 590 ACPI_FREE (TableDesc->Pointer); 591 break; 592 593 /* Not mapped or allocated, there is nothing we can do */ 594 595 default: 596 597 return; 598 } 599 600 TableDesc->Pointer = NULL; 601 } 602 603 604 /******************************************************************************* 605 * 606 * FUNCTION: AcpiTbTerminate 607 * 608 * PARAMETERS: None 609 * 610 * RETURN: None 611 * 612 * DESCRIPTION: Delete all internal ACPI tables 613 * 614 ******************************************************************************/ 615 616 void 617 AcpiTbTerminate ( 618 void) 619 { 620 UINT32 i; 621 622 623 ACPI_FUNCTION_TRACE (TbTerminate); 624 625 626 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 627 628 /* Delete the individual tables */ 629 630 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 631 { 632 AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); 633 } 634 635 /* 636 * Delete the root table array if allocated locally. Array cannot be 637 * mapped, so we don't need to check for that flag. 638 */ 639 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 640 { 641 ACPI_FREE (AcpiGbl_RootTableList.Tables); 642 } 643 644 AcpiGbl_RootTableList.Tables = NULL; 645 AcpiGbl_RootTableList.Flags = 0; 646 AcpiGbl_RootTableList.CurrentTableCount = 0; 647 648 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); 649 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 650 651 return_VOID; 652 } 653 654 655 /******************************************************************************* 656 * 657 * FUNCTION: AcpiTbDeleteNamespaceByOwner 658 * 659 * PARAMETERS: TableIndex - Table index 660 * 661 * RETURN: Status 662 * 663 * DESCRIPTION: Delete all namespace objects created when this table was loaded. 664 * 665 ******************************************************************************/ 666 667 ACPI_STATUS 668 AcpiTbDeleteNamespaceByOwner ( 669 UINT32 TableIndex) 670 { 671 ACPI_OWNER_ID OwnerId; 672 ACPI_STATUS Status; 673 674 675 ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); 676 677 678 Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); 679 if (ACPI_FAILURE (Status)) 680 { 681 return_ACPI_STATUS (Status); 682 } 683 684 if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) 685 { 686 /* The table index does not exist */ 687 688 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 689 return_ACPI_STATUS (AE_NOT_EXIST); 690 } 691 692 /* Get the owner ID for this table, used to delete namespace nodes */ 693 694 OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; 695 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 696 697 /* 698 * Need to acquire the namespace writer lock to prevent interference 699 * with any concurrent namespace walks. The interpreter must be 700 * released during the deletion since the acquisition of the deletion 701 * lock may block, and also since the execution of a namespace walk 702 * must be allowed to use the interpreter. 703 */ 704 (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); 705 Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); 706 707 AcpiNsDeleteNamespaceByOwner (OwnerId); 708 if (ACPI_FAILURE (Status)) 709 { 710 return_ACPI_STATUS (Status); 711 } 712 713 AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); 714 715 Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); 716 return_ACPI_STATUS (Status); 717 } 718 719 720 /******************************************************************************* 721 * 722 * FUNCTION: AcpiTbAllocateOwnerId 723 * 724 * PARAMETERS: TableIndex - Table index 725 * 726 * RETURN: Status 727 * 728 * DESCRIPTION: Allocates OwnerId in TableDesc 729 * 730 ******************************************************************************/ 731 732 ACPI_STATUS 733 AcpiTbAllocateOwnerId ( 734 UINT32 TableIndex) 735 { 736 ACPI_STATUS Status = AE_BAD_PARAMETER; 737 738 739 ACPI_FUNCTION_TRACE (TbAllocateOwnerId); 740 741 742 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 743 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 744 { 745 Status = AcpiUtAllocateOwnerId 746 (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); 747 } 748 749 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 750 return_ACPI_STATUS (Status); 751 } 752 753 754 /******************************************************************************* 755 * 756 * FUNCTION: AcpiTbReleaseOwnerId 757 * 758 * PARAMETERS: TableIndex - Table index 759 * 760 * RETURN: Status 761 * 762 * DESCRIPTION: Releases OwnerId in TableDesc 763 * 764 ******************************************************************************/ 765 766 ACPI_STATUS 767 AcpiTbReleaseOwnerId ( 768 UINT32 TableIndex) 769 { 770 ACPI_STATUS Status = AE_BAD_PARAMETER; 771 772 773 ACPI_FUNCTION_TRACE (TbReleaseOwnerId); 774 775 776 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 777 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 778 { 779 AcpiUtReleaseOwnerId ( 780 &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); 781 Status = AE_OK; 782 } 783 784 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 785 return_ACPI_STATUS (Status); 786 } 787 788 789 /******************************************************************************* 790 * 791 * FUNCTION: AcpiTbGetOwnerId 792 * 793 * PARAMETERS: TableIndex - Table index 794 * OwnerId - Where the table OwnerId is returned 795 * 796 * RETURN: Status 797 * 798 * DESCRIPTION: returns OwnerId for the ACPI table 799 * 800 ******************************************************************************/ 801 802 ACPI_STATUS 803 AcpiTbGetOwnerId ( 804 UINT32 TableIndex, 805 ACPI_OWNER_ID *OwnerId) 806 { 807 ACPI_STATUS Status = AE_BAD_PARAMETER; 808 809 810 ACPI_FUNCTION_TRACE (TbGetOwnerId); 811 812 813 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 814 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 815 { 816 *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; 817 Status = AE_OK; 818 } 819 820 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 821 return_ACPI_STATUS (Status); 822 } 823 824 825 /******************************************************************************* 826 * 827 * FUNCTION: AcpiTbIsTableLoaded 828 * 829 * PARAMETERS: TableIndex - Table index 830 * 831 * RETURN: Table Loaded Flag 832 * 833 ******************************************************************************/ 834 835 BOOLEAN 836 AcpiTbIsTableLoaded ( 837 UINT32 TableIndex) 838 { 839 BOOLEAN IsLoaded = FALSE; 840 841 842 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 843 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 844 { 845 IsLoaded = (BOOLEAN) 846 (AcpiGbl_RootTableList.Tables[TableIndex].Flags & 847 ACPI_TABLE_IS_LOADED); 848 } 849 850 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 851 return (IsLoaded); 852 } 853 854 855 /******************************************************************************* 856 * 857 * FUNCTION: AcpiTbSetTableLoadedFlag 858 * 859 * PARAMETERS: TableIndex - Table index 860 * IsLoaded - TRUE if table is loaded, FALSE otherwise 861 * 862 * RETURN: None 863 * 864 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. 865 * 866 ******************************************************************************/ 867 868 void 869 AcpiTbSetTableLoadedFlag ( 870 UINT32 TableIndex, 871 BOOLEAN IsLoaded) 872 { 873 874 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 875 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 876 { 877 if (IsLoaded) 878 { 879 AcpiGbl_RootTableList.Tables[TableIndex].Flags |= 880 ACPI_TABLE_IS_LOADED; 881 } 882 else 883 { 884 AcpiGbl_RootTableList.Tables[TableIndex].Flags &= 885 ~ACPI_TABLE_IS_LOADED; 886 } 887 } 888 889 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 890 } 891