1 /****************************************************************************** 2 * 3 * Module Name: tbxface - ACPI table-oriented external interfaces 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2017, 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 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #define EXPORT_ACPI_INTERFACES 153 154 #include <contrib/dev/acpica/include/acpi.h> 155 #include <contrib/dev/acpica/include/accommon.h> 156 #include <contrib/dev/acpica/include/actables.h> 157 158 #define _COMPONENT ACPI_TABLES 159 ACPI_MODULE_NAME ("tbxface") 160 161 162 /******************************************************************************* 163 * 164 * FUNCTION: AcpiAllocateRootTable 165 * 166 * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of 167 * ACPI_TABLE_DESC structures 168 * 169 * RETURN: Status 170 * 171 * DESCRIPTION: Allocate a root table array. Used by iASL compiler and 172 * AcpiInitializeTables. 173 * 174 ******************************************************************************/ 175 176 ACPI_STATUS 177 AcpiAllocateRootTable ( 178 UINT32 InitialTableCount) 179 { 180 181 AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; 182 AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; 183 184 return (AcpiTbResizeRootTableList ()); 185 } 186 187 188 /******************************************************************************* 189 * 190 * FUNCTION: AcpiInitializeTables 191 * 192 * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated 193 * ACPI_TABLE_DESC structures. If NULL, the 194 * array is dynamically allocated. 195 * InitialTableCount - Size of InitialTableArray, in number of 196 * ACPI_TABLE_DESC structures 197 * AllowResize - Flag to tell Table Manager if resize of 198 * pre-allocated array is allowed. Ignored 199 * if InitialTableArray is NULL. 200 * 201 * RETURN: Status 202 * 203 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. 204 * 205 * NOTE: Allows static allocation of the initial table array in order 206 * to avoid the use of dynamic memory in confined environments 207 * such as the kernel boot sequence where it may not be available. 208 * 209 * If the host OS memory managers are initialized, use NULL for 210 * InitialTableArray, and the table will be dynamically allocated. 211 * 212 ******************************************************************************/ 213 214 ACPI_STATUS ACPI_INIT_FUNCTION 215 AcpiInitializeTables ( 216 ACPI_TABLE_DESC *InitialTableArray, 217 UINT32 InitialTableCount, 218 BOOLEAN AllowResize) 219 { 220 ACPI_PHYSICAL_ADDRESS RsdpAddress; 221 ACPI_STATUS Status; 222 223 224 ACPI_FUNCTION_TRACE (AcpiInitializeTables); 225 226 227 /* 228 * Setup the Root Table Array and allocate the table array 229 * if requested 230 */ 231 if (!InitialTableArray) 232 { 233 Status = AcpiAllocateRootTable (InitialTableCount); 234 if (ACPI_FAILURE (Status)) 235 { 236 return_ACPI_STATUS (Status); 237 } 238 } 239 else 240 { 241 /* Root Table Array has been statically allocated by the host */ 242 243 memset (InitialTableArray, 0, 244 (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); 245 246 AcpiGbl_RootTableList.Tables = InitialTableArray; 247 AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; 248 AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; 249 if (AllowResize) 250 { 251 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; 252 } 253 } 254 255 /* Get the address of the RSDP */ 256 257 RsdpAddress = AcpiOsGetRootPointer (); 258 if (!RsdpAddress) 259 { 260 return_ACPI_STATUS (AE_NOT_FOUND); 261 } 262 263 /* 264 * Get the root table (RSDT or XSDT) and extract all entries to the local 265 * Root Table Array. This array contains the information of the RSDT/XSDT 266 * in a common, more useable format. 267 */ 268 Status = AcpiTbParseRootTable (RsdpAddress); 269 return_ACPI_STATUS (Status); 270 } 271 272 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeTables) 273 274 275 /******************************************************************************* 276 * 277 * FUNCTION: AcpiReallocateRootTable 278 * 279 * PARAMETERS: None 280 * 281 * RETURN: Status 282 * 283 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 284 * root list from the previously provided scratch area. Should 285 * be called once dynamic memory allocation is available in the 286 * kernel. 287 * 288 ******************************************************************************/ 289 290 ACPI_STATUS ACPI_INIT_FUNCTION 291 AcpiReallocateRootTable ( 292 void) 293 { 294 ACPI_STATUS Status; 295 ACPI_TABLE_DESC *TableDesc; 296 UINT32 i, j; 297 298 299 ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); 300 301 302 /* 303 * Only reallocate the root table if the host provided a static buffer 304 * for the table array in the call to AcpiInitializeTables. 305 */ 306 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 307 { 308 return_ACPI_STATUS (AE_SUPPORT); 309 } 310 311 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 312 313 /* 314 * Ensure OS early boot logic, which is required by some hosts. If the 315 * table state is reported to be wrong, developers should fix the 316 * issue by invoking AcpiPutTable() for the reported table during the 317 * early stage. 318 */ 319 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) 320 { 321 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 322 if (TableDesc->Pointer) 323 { 324 ACPI_ERROR ((AE_INFO, 325 "Table [%4.4s] is not invalidated during early boot stage", 326 TableDesc->Signature.Ascii)); 327 } 328 } 329 330 if (!AcpiGbl_EnableTableValidation) 331 { 332 /* 333 * Now it's safe to do full table validation. We can do deferred 334 * table initilization here once the flag is set. 335 */ 336 AcpiGbl_EnableTableValidation = TRUE; 337 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) 338 { 339 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 340 if (!(TableDesc->Flags & ACPI_TABLE_IS_VERIFIED)) 341 { 342 Status = AcpiTbVerifyTempTable (TableDesc, NULL, &j); 343 if (ACPI_FAILURE (Status)) 344 { 345 AcpiTbUninstallTable (TableDesc); 346 } 347 } 348 } 349 } 350 351 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; 352 Status = AcpiTbResizeRootTableList (); 353 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 354 355 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 356 return_ACPI_STATUS (Status); 357 } 358 359 ACPI_EXPORT_SYMBOL_INIT (AcpiReallocateRootTable) 360 361 362 /******************************************************************************* 363 * 364 * FUNCTION: AcpiGetTableHeader 365 * 366 * PARAMETERS: Signature - ACPI signature of needed table 367 * Instance - Which instance (for SSDTs) 368 * OutTableHeader - The pointer to the table header to fill 369 * 370 * RETURN: Status and pointer to mapped table header 371 * 372 * DESCRIPTION: Finds an ACPI table header. 373 * 374 * NOTE: Caller is responsible in unmapping the header with 375 * AcpiOsUnmapMemory 376 * 377 ******************************************************************************/ 378 379 ACPI_STATUS 380 AcpiGetTableHeader ( 381 char *Signature, 382 UINT32 Instance, 383 ACPI_TABLE_HEADER *OutTableHeader) 384 { 385 UINT32 i; 386 UINT32 j; 387 ACPI_TABLE_HEADER *Header; 388 389 390 /* Parameter validation */ 391 392 if (!Signature || !OutTableHeader) 393 { 394 return (AE_BAD_PARAMETER); 395 } 396 397 /* Walk the root table list */ 398 399 for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 400 { 401 if (!ACPI_COMPARE_NAME ( 402 &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) 403 { 404 continue; 405 } 406 407 if (++j < Instance) 408 { 409 continue; 410 } 411 412 if (!AcpiGbl_RootTableList.Tables[i].Pointer) 413 { 414 if ((AcpiGbl_RootTableList.Tables[i].Flags & 415 ACPI_TABLE_ORIGIN_MASK) == 416 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) 417 { 418 Header = AcpiOsMapMemory ( 419 AcpiGbl_RootTableList.Tables[i].Address, 420 sizeof (ACPI_TABLE_HEADER)); 421 if (!Header) 422 { 423 return (AE_NO_MEMORY); 424 } 425 426 memcpy (OutTableHeader, Header, sizeof (ACPI_TABLE_HEADER)); 427 AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER)); 428 } 429 else 430 { 431 return (AE_NOT_FOUND); 432 } 433 } 434 else 435 { 436 memcpy (OutTableHeader, 437 AcpiGbl_RootTableList.Tables[i].Pointer, 438 sizeof (ACPI_TABLE_HEADER)); 439 } 440 441 return (AE_OK); 442 } 443 444 return (AE_NOT_FOUND); 445 } 446 447 ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) 448 449 450 /******************************************************************************* 451 * 452 * FUNCTION: AcpiGetTable 453 * 454 * PARAMETERS: Signature - ACPI signature of needed table 455 * Instance - Which instance (for SSDTs) 456 * OutTable - Where the pointer to the table is returned 457 * 458 * RETURN: Status and pointer to the requested table 459 * 460 * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the 461 * RSDT/XSDT. 462 * Note that an early stage AcpiGetTable() call must be paired 463 * with an early stage AcpiPutTable() call. otherwise the table 464 * pointer mapped by the early stage mapping implementation may be 465 * erroneously unmapped by the late stage unmapping implementation 466 * in an AcpiPutTable() invoked during the late stage. 467 * 468 ******************************************************************************/ 469 470 ACPI_STATUS 471 AcpiGetTable ( 472 char *Signature, 473 UINT32 Instance, 474 ACPI_TABLE_HEADER **OutTable) 475 { 476 UINT32 i; 477 UINT32 j; 478 ACPI_STATUS Status = AE_NOT_FOUND; 479 ACPI_TABLE_DESC *TableDesc; 480 481 482 /* Parameter validation */ 483 484 if (!Signature || !OutTable) 485 { 486 return (AE_BAD_PARAMETER); 487 } 488 489 /* 490 * Note that the following line is required by some OSPMs, they only 491 * check if the returned table is NULL instead of the returned status 492 * to determined if this function is succeeded. 493 */ 494 *OutTable = NULL; 495 496 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 497 498 /* Walk the root table list */ 499 500 for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 501 { 502 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 503 504 if (!ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) 505 { 506 continue; 507 } 508 509 if (++j < Instance) 510 { 511 continue; 512 } 513 514 Status = AcpiTbGetTable (TableDesc, OutTable); 515 break; 516 } 517 518 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 519 return (Status); 520 } 521 522 ACPI_EXPORT_SYMBOL (AcpiGetTable) 523 524 525 /******************************************************************************* 526 * 527 * FUNCTION: AcpiPutTable 528 * 529 * PARAMETERS: Table - The pointer to the table 530 * 531 * RETURN: None 532 * 533 * DESCRIPTION: Release a table returned by AcpiGetTable() and its clones. 534 * Note that it is not safe if this function was invoked after an 535 * uninstallation happened to the original table descriptor. 536 * Currently there is no OSPMs' requirement to handle such 537 * situations. 538 * 539 ******************************************************************************/ 540 541 void 542 AcpiPutTable ( 543 ACPI_TABLE_HEADER *Table) 544 { 545 UINT32 i; 546 ACPI_TABLE_DESC *TableDesc; 547 548 549 ACPI_FUNCTION_TRACE (AcpiPutTable); 550 551 552 if (!Table) 553 { 554 return_VOID; 555 } 556 557 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 558 559 /* Walk the root table list */ 560 561 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 562 { 563 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 564 565 if (TableDesc->Pointer != Table) 566 { 567 continue; 568 } 569 570 AcpiTbPutTable (TableDesc); 571 break; 572 } 573 574 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 575 return_VOID; 576 } 577 578 ACPI_EXPORT_SYMBOL (AcpiPutTable) 579 580 581 /******************************************************************************* 582 * 583 * FUNCTION: AcpiGetTableByIndex 584 * 585 * PARAMETERS: TableIndex - Table index 586 * OutTable - Where the pointer to the table is returned 587 * 588 * RETURN: Status and pointer to the requested table 589 * 590 * DESCRIPTION: Obtain a table by an index into the global table list. Used 591 * internally also. 592 * 593 ******************************************************************************/ 594 595 ACPI_STATUS 596 AcpiGetTableByIndex ( 597 UINT32 TableIndex, 598 ACPI_TABLE_HEADER **OutTable) 599 { 600 ACPI_STATUS Status; 601 602 603 ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); 604 605 606 /* Parameter validation */ 607 608 if (!OutTable) 609 { 610 return_ACPI_STATUS (AE_BAD_PARAMETER); 611 } 612 613 /* 614 * Note that the following line is required by some OSPMs, they only 615 * check if the returned table is NULL instead of the returned status 616 * to determined if this function is succeeded. 617 */ 618 *OutTable = NULL; 619 620 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 621 622 /* Validate index */ 623 624 if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) 625 { 626 Status = AE_BAD_PARAMETER; 627 goto UnlockAndExit; 628 } 629 630 Status = AcpiTbGetTable ( 631 &AcpiGbl_RootTableList.Tables[TableIndex], OutTable); 632 633 UnlockAndExit: 634 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 635 return_ACPI_STATUS (Status); 636 } 637 638 ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) 639 640 641 /******************************************************************************* 642 * 643 * FUNCTION: AcpiInstallTableHandler 644 * 645 * PARAMETERS: Handler - Table event handler 646 * Context - Value passed to the handler on each event 647 * 648 * RETURN: Status 649 * 650 * DESCRIPTION: Install a global table event handler. 651 * 652 ******************************************************************************/ 653 654 ACPI_STATUS 655 AcpiInstallTableHandler ( 656 ACPI_TABLE_HANDLER Handler, 657 void *Context) 658 { 659 ACPI_STATUS Status; 660 661 662 ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); 663 664 665 if (!Handler) 666 { 667 return_ACPI_STATUS (AE_BAD_PARAMETER); 668 } 669 670 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 671 if (ACPI_FAILURE (Status)) 672 { 673 return_ACPI_STATUS (Status); 674 } 675 676 /* Don't allow more than one handler */ 677 678 if (AcpiGbl_TableHandler) 679 { 680 Status = AE_ALREADY_EXISTS; 681 goto Cleanup; 682 } 683 684 /* Install the handler */ 685 686 AcpiGbl_TableHandler = Handler; 687 AcpiGbl_TableHandlerContext = Context; 688 689 Cleanup: 690 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 691 return_ACPI_STATUS (Status); 692 } 693 694 ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) 695 696 697 /******************************************************************************* 698 * 699 * FUNCTION: AcpiRemoveTableHandler 700 * 701 * PARAMETERS: Handler - Table event handler that was installed 702 * previously. 703 * 704 * RETURN: Status 705 * 706 * DESCRIPTION: Remove a table event handler 707 * 708 ******************************************************************************/ 709 710 ACPI_STATUS 711 AcpiRemoveTableHandler ( 712 ACPI_TABLE_HANDLER Handler) 713 { 714 ACPI_STATUS Status; 715 716 717 ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); 718 719 720 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 721 if (ACPI_FAILURE (Status)) 722 { 723 return_ACPI_STATUS (Status); 724 } 725 726 /* Make sure that the installed handler is the same */ 727 728 if (!Handler || 729 Handler != AcpiGbl_TableHandler) 730 { 731 Status = AE_BAD_PARAMETER; 732 goto Cleanup; 733 } 734 735 /* Remove the handler */ 736 737 AcpiGbl_TableHandler = NULL; 738 739 Cleanup: 740 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 741 return_ACPI_STATUS (Status); 742 } 743 744 ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler) 745