1 /****************************************************************************** 2 * 3 * Module Name: tbdata - Table manager data structure functions 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #include <contrib/dev/acpica/include/acpi.h> 45 #include <contrib/dev/acpica/include/accommon.h> 46 #include <contrib/dev/acpica/include/acnamesp.h> 47 #include <contrib/dev/acpica/include/actables.h> 48 49 #define _COMPONENT ACPI_TABLES 50 ACPI_MODULE_NAME ("tbdata") 51 52 53 /******************************************************************************* 54 * 55 * FUNCTION: AcpiTbInitTableDescriptor 56 * 57 * PARAMETERS: TableDesc - Table descriptor 58 * Address - Physical address of the table 59 * Flags - Allocation flags of the table 60 * Table - Pointer to the table 61 * 62 * RETURN: None 63 * 64 * DESCRIPTION: Initialize a new table descriptor 65 * 66 ******************************************************************************/ 67 68 void 69 AcpiTbInitTableDescriptor ( 70 ACPI_TABLE_DESC *TableDesc, 71 ACPI_PHYSICAL_ADDRESS Address, 72 UINT8 Flags, 73 ACPI_TABLE_HEADER *Table) 74 { 75 76 /* 77 * Initialize the table descriptor. Set the pointer to NULL, since the 78 * table is not fully mapped at this time. 79 */ 80 ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC)); 81 TableDesc->Address = Address; 82 TableDesc->Length = Table->Length; 83 TableDesc->Flags = Flags; 84 ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature); 85 } 86 87 88 /******************************************************************************* 89 * 90 * FUNCTION: AcpiTbAcquireTable 91 * 92 * PARAMETERS: TableDesc - Table descriptor 93 * TablePtr - Where table is returned 94 * TableLength - Where table length is returned 95 * TableFlags - Where table allocation flags are returned 96 * 97 * RETURN: Status 98 * 99 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not 100 * maintained in the AcpiGbl_RootTableList. 101 * 102 ******************************************************************************/ 103 104 ACPI_STATUS 105 AcpiTbAcquireTable ( 106 ACPI_TABLE_DESC *TableDesc, 107 ACPI_TABLE_HEADER **TablePtr, 108 UINT32 *TableLength, 109 UINT8 *TableFlags) 110 { 111 ACPI_TABLE_HEADER *Table = NULL; 112 113 114 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) 115 { 116 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: 117 118 Table = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length); 119 break; 120 121 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: 122 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: 123 124 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, TableDesc->Address); 125 break; 126 127 default: 128 129 break; 130 } 131 132 /* Table is not valid yet */ 133 134 if (!Table) 135 { 136 return (AE_NO_MEMORY); 137 } 138 139 /* Fill the return values */ 140 141 *TablePtr = Table; 142 *TableLength = TableDesc->Length; 143 *TableFlags = TableDesc->Flags; 144 return (AE_OK); 145 } 146 147 148 /******************************************************************************* 149 * 150 * FUNCTION: AcpiTbReleaseTable 151 * 152 * PARAMETERS: Table - Pointer for the table 153 * TableLength - Length for the table 154 * TableFlags - Allocation flags for the table 155 * 156 * RETURN: None 157 * 158 * DESCRIPTION: Release a table. The inverse of AcpiTbAcquireTable(). 159 * 160 ******************************************************************************/ 161 162 void 163 AcpiTbReleaseTable ( 164 ACPI_TABLE_HEADER *Table, 165 UINT32 TableLength, 166 UINT8 TableFlags) 167 { 168 169 switch (TableFlags & ACPI_TABLE_ORIGIN_MASK) 170 { 171 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: 172 173 AcpiOsUnmapMemory (Table, TableLength); 174 break; 175 176 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: 177 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: 178 default: 179 180 break; 181 } 182 } 183 184 185 /******************************************************************************* 186 * 187 * FUNCTION: AcpiTbAcquireTempTable 188 * 189 * PARAMETERS: TableDesc - Table descriptor to be acquired 190 * Address - Address of the table 191 * Flags - Allocation flags of the table 192 * 193 * RETURN: Status 194 * 195 * DESCRIPTION: This function validates the table header to obtain the length 196 * of a table and fills the table descriptor to make its state as 197 * "INSTALLED". Such a table descriptor is only used for verified 198 * installation. 199 * 200 ******************************************************************************/ 201 202 ACPI_STATUS 203 AcpiTbAcquireTempTable ( 204 ACPI_TABLE_DESC *TableDesc, 205 ACPI_PHYSICAL_ADDRESS Address, 206 UINT8 Flags) 207 { 208 ACPI_TABLE_HEADER *TableHeader; 209 210 211 switch (Flags & ACPI_TABLE_ORIGIN_MASK) 212 { 213 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: 214 215 /* Get the length of the full table from the header */ 216 217 TableHeader = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); 218 if (!TableHeader) 219 { 220 return (AE_NO_MEMORY); 221 } 222 223 AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); 224 AcpiOsUnmapMemory (TableHeader, sizeof (ACPI_TABLE_HEADER)); 225 return (AE_OK); 226 227 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: 228 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: 229 230 TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Address); 231 if (!TableHeader) 232 { 233 return (AE_NO_MEMORY); 234 } 235 236 AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); 237 return (AE_OK); 238 239 default: 240 241 break; 242 } 243 244 /* Table is not valid yet */ 245 246 return (AE_NO_MEMORY); 247 } 248 249 250 /******************************************************************************* 251 * 252 * FUNCTION: AcpiTbReleaseTempTable 253 * 254 * PARAMETERS: TableDesc - Table descriptor to be released 255 * 256 * RETURN: Status 257 * 258 * DESCRIPTION: The inverse of AcpiTbAcquireTempTable(). 259 * 260 *****************************************************************************/ 261 262 void 263 AcpiTbReleaseTempTable ( 264 ACPI_TABLE_DESC *TableDesc) 265 { 266 267 /* 268 * Note that the .Address is maintained by the callers of 269 * AcpiTbAcquireTempTable(), thus do not invoke AcpiTbUninstallTable() 270 * where .Address will be freed. 271 */ 272 AcpiTbInvalidateTable (TableDesc); 273 } 274 275 276 /****************************************************************************** 277 * 278 * FUNCTION: AcpiTbValidateTable 279 * 280 * PARAMETERS: TableDesc - Table descriptor 281 * 282 * RETURN: Status 283 * 284 * DESCRIPTION: This function is called to validate the table, the returned 285 * table descriptor is in "VALIDATED" state. 286 * 287 *****************************************************************************/ 288 289 ACPI_STATUS 290 AcpiTbValidateTable ( 291 ACPI_TABLE_DESC *TableDesc) 292 { 293 ACPI_STATUS Status = AE_OK; 294 295 296 ACPI_FUNCTION_TRACE (TbValidateTable); 297 298 299 /* Validate the table if necessary */ 300 301 if (!TableDesc->Pointer) 302 { 303 Status = AcpiTbAcquireTable (TableDesc, &TableDesc->Pointer, 304 &TableDesc->Length, &TableDesc->Flags); 305 if (!TableDesc->Pointer) 306 { 307 Status = AE_NO_MEMORY; 308 } 309 } 310 311 return_ACPI_STATUS (Status); 312 } 313 314 315 /******************************************************************************* 316 * 317 * FUNCTION: AcpiTbInvalidateTable 318 * 319 * PARAMETERS: TableDesc - Table descriptor 320 * 321 * RETURN: None 322 * 323 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of 324 * AcpiTbValidateTable(). 325 * 326 ******************************************************************************/ 327 328 void 329 AcpiTbInvalidateTable ( 330 ACPI_TABLE_DESC *TableDesc) 331 { 332 333 ACPI_FUNCTION_TRACE (TbInvalidateTable); 334 335 336 /* Table must be validated */ 337 338 if (!TableDesc->Pointer) 339 { 340 return_VOID; 341 } 342 343 AcpiTbReleaseTable (TableDesc->Pointer, TableDesc->Length, 344 TableDesc->Flags); 345 TableDesc->Pointer = NULL; 346 347 return_VOID; 348 } 349 350 351 /****************************************************************************** 352 * 353 * FUNCTION: AcpiTbValidateTempTable 354 * 355 * PARAMETERS: TableDesc - Table descriptor 356 * 357 * RETURN: Status 358 * 359 * DESCRIPTION: This function is called to validate the table, the returned 360 * table descriptor is in "VALIDATED" state. 361 * 362 *****************************************************************************/ 363 364 ACPI_STATUS 365 AcpiTbValidateTempTable ( 366 ACPI_TABLE_DESC *TableDesc) 367 { 368 369 if (!TableDesc->Pointer && !AcpiGbl_VerifyTableChecksum) 370 { 371 /* 372 * Only validates the header of the table. 373 * Note that Length contains the size of the mapping after invoking 374 * this work around, this value is required by 375 * AcpiTbReleaseTempTable(). 376 * We can do this because in AcpiInitTableDescriptor(), the Length 377 * field of the installed descriptor is filled with the actual 378 * table length obtaining from the table header. 379 */ 380 TableDesc->Length = sizeof (ACPI_TABLE_HEADER); 381 } 382 383 return (AcpiTbValidateTable (TableDesc)); 384 } 385 386 387 /****************************************************************************** 388 * 389 * FUNCTION: AcpiTbVerifyTempTable 390 * 391 * PARAMETERS: TableDesc - Table descriptor 392 * Signature - Table signature to verify 393 * 394 * RETURN: Status 395 * 396 * DESCRIPTION: This function is called to validate and verify the table, the 397 * returned table descriptor is in "VALIDATED" state. 398 * 399 *****************************************************************************/ 400 401 ACPI_STATUS 402 AcpiTbVerifyTempTable ( 403 ACPI_TABLE_DESC *TableDesc, 404 char *Signature) 405 { 406 ACPI_STATUS Status = AE_OK; 407 408 409 ACPI_FUNCTION_TRACE (TbVerifyTempTable); 410 411 412 /* Validate the table */ 413 414 Status = AcpiTbValidateTempTable (TableDesc); 415 if (ACPI_FAILURE (Status)) 416 { 417 return_ACPI_STATUS (AE_NO_MEMORY); 418 } 419 420 /* If a particular signature is expected (DSDT/FACS), it must match */ 421 422 if (Signature && 423 !ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) 424 { 425 ACPI_BIOS_ERROR ((AE_INFO, 426 "Invalid signature 0x%X for ACPI table, expected [%s]", 427 TableDesc->Signature.Integer, Signature)); 428 Status = AE_BAD_SIGNATURE; 429 goto InvalidateAndExit; 430 } 431 432 /* Verify the checksum */ 433 434 if (AcpiGbl_VerifyTableChecksum) 435 { 436 Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); 437 if (ACPI_FAILURE (Status)) 438 { 439 ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, 440 "%4.4s " ACPI_PRINTF_UINT 441 " Attempted table install failed", 442 AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? 443 TableDesc->Signature.Ascii : "????", 444 ACPI_FORMAT_TO_UINT (TableDesc->Address))); 445 goto InvalidateAndExit; 446 } 447 } 448 449 return_ACPI_STATUS (AE_OK); 450 451 InvalidateAndExit: 452 AcpiTbInvalidateTable (TableDesc); 453 return_ACPI_STATUS (Status); 454 } 455 456 457 /******************************************************************************* 458 * 459 * FUNCTION: AcpiTbResizeRootTableList 460 * 461 * PARAMETERS: None 462 * 463 * RETURN: Status 464 * 465 * DESCRIPTION: Expand the size of global table array 466 * 467 ******************************************************************************/ 468 469 ACPI_STATUS 470 AcpiTbResizeRootTableList ( 471 void) 472 { 473 ACPI_TABLE_DESC *Tables; 474 UINT32 TableCount; 475 476 477 ACPI_FUNCTION_TRACE (TbResizeRootTableList); 478 479 480 /* AllowResize flag is a parameter to AcpiInitializeTables */ 481 482 if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) 483 { 484 ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); 485 return_ACPI_STATUS (AE_SUPPORT); 486 } 487 488 /* Increase the Table Array size */ 489 490 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 491 { 492 TableCount = AcpiGbl_RootTableList.MaxTableCount; 493 } 494 else 495 { 496 TableCount = AcpiGbl_RootTableList.CurrentTableCount; 497 } 498 499 Tables = ACPI_ALLOCATE_ZEROED ( 500 ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * 501 sizeof (ACPI_TABLE_DESC)); 502 if (!Tables) 503 { 504 ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); 505 return_ACPI_STATUS (AE_NO_MEMORY); 506 } 507 508 /* Copy and free the previous table array */ 509 510 if (AcpiGbl_RootTableList.Tables) 511 { 512 ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, 513 (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); 514 515 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 516 { 517 ACPI_FREE (AcpiGbl_RootTableList.Tables); 518 } 519 } 520 521 AcpiGbl_RootTableList.Tables = Tables; 522 AcpiGbl_RootTableList.MaxTableCount = 523 TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; 524 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 525 526 return_ACPI_STATUS (AE_OK); 527 } 528 529 530 /******************************************************************************* 531 * 532 * FUNCTION: AcpiTbGetNextRootIndex 533 * 534 * PARAMETERS: TableIndex - Where table index is returned 535 * 536 * RETURN: Status and table index. 537 * 538 * DESCRIPTION: Allocate a new ACPI table entry to the global table list 539 * 540 ******************************************************************************/ 541 542 ACPI_STATUS 543 AcpiTbGetNextRootIndex ( 544 UINT32 *TableIndex) 545 { 546 ACPI_STATUS Status; 547 548 549 /* Ensure that there is room for the table in the Root Table List */ 550 551 if (AcpiGbl_RootTableList.CurrentTableCount >= 552 AcpiGbl_RootTableList.MaxTableCount) 553 { 554 Status = AcpiTbResizeRootTableList(); 555 if (ACPI_FAILURE (Status)) 556 { 557 return (Status); 558 } 559 } 560 561 *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; 562 AcpiGbl_RootTableList.CurrentTableCount++; 563 return (AE_OK); 564 } 565 566 567 /******************************************************************************* 568 * 569 * FUNCTION: AcpiTbTerminate 570 * 571 * PARAMETERS: None 572 * 573 * RETURN: None 574 * 575 * DESCRIPTION: Delete all internal ACPI tables 576 * 577 ******************************************************************************/ 578 579 void 580 AcpiTbTerminate ( 581 void) 582 { 583 UINT32 i; 584 585 586 ACPI_FUNCTION_TRACE (TbTerminate); 587 588 589 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 590 591 /* Delete the individual tables */ 592 593 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 594 { 595 AcpiTbUninstallTable (&AcpiGbl_RootTableList.Tables[i]); 596 } 597 598 /* 599 * Delete the root table array if allocated locally. Array cannot be 600 * mapped, so we don't need to check for that flag. 601 */ 602 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 603 { 604 ACPI_FREE (AcpiGbl_RootTableList.Tables); 605 } 606 607 AcpiGbl_RootTableList.Tables = NULL; 608 AcpiGbl_RootTableList.Flags = 0; 609 AcpiGbl_RootTableList.CurrentTableCount = 0; 610 611 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); 612 613 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 614 return_VOID; 615 } 616 617 618 /******************************************************************************* 619 * 620 * FUNCTION: AcpiTbDeleteNamespaceByOwner 621 * 622 * PARAMETERS: TableIndex - Table index 623 * 624 * RETURN: Status 625 * 626 * DESCRIPTION: Delete all namespace objects created when this table was loaded. 627 * 628 ******************************************************************************/ 629 630 ACPI_STATUS 631 AcpiTbDeleteNamespaceByOwner ( 632 UINT32 TableIndex) 633 { 634 ACPI_OWNER_ID OwnerId; 635 ACPI_STATUS Status; 636 637 638 ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); 639 640 641 Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); 642 if (ACPI_FAILURE (Status)) 643 { 644 return_ACPI_STATUS (Status); 645 } 646 647 if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) 648 { 649 /* The table index does not exist */ 650 651 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 652 return_ACPI_STATUS (AE_NOT_EXIST); 653 } 654 655 /* Get the owner ID for this table, used to delete namespace nodes */ 656 657 OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; 658 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 659 660 /* 661 * Need to acquire the namespace writer lock to prevent interference 662 * with any concurrent namespace walks. The interpreter must be 663 * released during the deletion since the acquisition of the deletion 664 * lock may block, and also since the execution of a namespace walk 665 * must be allowed to use the interpreter. 666 */ 667 (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); 668 Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); 669 670 AcpiNsDeleteNamespaceByOwner (OwnerId); 671 if (ACPI_FAILURE (Status)) 672 { 673 return_ACPI_STATUS (Status); 674 } 675 676 AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); 677 678 Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); 679 return_ACPI_STATUS (Status); 680 } 681 682 683 /******************************************************************************* 684 * 685 * FUNCTION: AcpiTbAllocateOwnerId 686 * 687 * PARAMETERS: TableIndex - Table index 688 * 689 * RETURN: Status 690 * 691 * DESCRIPTION: Allocates OwnerId in TableDesc 692 * 693 ******************************************************************************/ 694 695 ACPI_STATUS 696 AcpiTbAllocateOwnerId ( 697 UINT32 TableIndex) 698 { 699 ACPI_STATUS Status = AE_BAD_PARAMETER; 700 701 702 ACPI_FUNCTION_TRACE (TbAllocateOwnerId); 703 704 705 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 706 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 707 { 708 Status = AcpiUtAllocateOwnerId ( 709 &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); 710 } 711 712 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 713 return_ACPI_STATUS (Status); 714 } 715 716 717 /******************************************************************************* 718 * 719 * FUNCTION: AcpiTbReleaseOwnerId 720 * 721 * PARAMETERS: TableIndex - Table index 722 * 723 * RETURN: Status 724 * 725 * DESCRIPTION: Releases OwnerId in TableDesc 726 * 727 ******************************************************************************/ 728 729 ACPI_STATUS 730 AcpiTbReleaseOwnerId ( 731 UINT32 TableIndex) 732 { 733 ACPI_STATUS Status = AE_BAD_PARAMETER; 734 735 736 ACPI_FUNCTION_TRACE (TbReleaseOwnerId); 737 738 739 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 740 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 741 { 742 AcpiUtReleaseOwnerId ( 743 &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); 744 Status = AE_OK; 745 } 746 747 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 748 return_ACPI_STATUS (Status); 749 } 750 751 752 /******************************************************************************* 753 * 754 * FUNCTION: AcpiTbGetOwnerId 755 * 756 * PARAMETERS: TableIndex - Table index 757 * OwnerId - Where the table OwnerId is returned 758 * 759 * RETURN: Status 760 * 761 * DESCRIPTION: returns OwnerId for the ACPI table 762 * 763 ******************************************************************************/ 764 765 ACPI_STATUS 766 AcpiTbGetOwnerId ( 767 UINT32 TableIndex, 768 ACPI_OWNER_ID *OwnerId) 769 { 770 ACPI_STATUS Status = AE_BAD_PARAMETER; 771 772 773 ACPI_FUNCTION_TRACE (TbGetOwnerId); 774 775 776 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 777 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 778 { 779 *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; 780 Status = AE_OK; 781 } 782 783 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 784 return_ACPI_STATUS (Status); 785 } 786 787 788 /******************************************************************************* 789 * 790 * FUNCTION: AcpiTbIsTableLoaded 791 * 792 * PARAMETERS: TableIndex - Index into the root table 793 * 794 * RETURN: Table Loaded Flag 795 * 796 ******************************************************************************/ 797 798 BOOLEAN 799 AcpiTbIsTableLoaded ( 800 UINT32 TableIndex) 801 { 802 BOOLEAN IsLoaded = FALSE; 803 804 805 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 806 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 807 { 808 IsLoaded = (BOOLEAN) 809 (AcpiGbl_RootTableList.Tables[TableIndex].Flags & 810 ACPI_TABLE_IS_LOADED); 811 } 812 813 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 814 return (IsLoaded); 815 } 816 817 818 /******************************************************************************* 819 * 820 * FUNCTION: AcpiTbSetTableLoadedFlag 821 * 822 * PARAMETERS: TableIndex - Table index 823 * IsLoaded - TRUE if table is loaded, FALSE otherwise 824 * 825 * RETURN: None 826 * 827 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. 828 * 829 ******************************************************************************/ 830 831 void 832 AcpiTbSetTableLoadedFlag ( 833 UINT32 TableIndex, 834 BOOLEAN IsLoaded) 835 { 836 837 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 838 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) 839 { 840 if (IsLoaded) 841 { 842 AcpiGbl_RootTableList.Tables[TableIndex].Flags |= 843 ACPI_TABLE_IS_LOADED; 844 } 845 else 846 { 847 AcpiGbl_RootTableList.Tables[TableIndex].Flags &= 848 ~ACPI_TABLE_IS_LOADED; 849 } 850 } 851 852 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 853 } 854