evxface.c revision 91116
1/****************************************************************************** 2 * 3 * Module Name: evxface - External interfaces for ACPI events 4 * $Revision: 125 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial prton of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118#define __EVXFACE_C__ 119 120#include "acpi.h" 121#include "achware.h" 122#include "acnamesp.h" 123#include "acevents.h" 124#include "amlcode.h" 125#include "acinterp.h" 126 127#define _COMPONENT ACPI_EVENTS 128 ACPI_MODULE_NAME ("evxface") 129 130 131/******************************************************************************* 132 * 133 * FUNCTION: AcpiInstallFixedEventHandler 134 * 135 * PARAMETERS: Event - Event type to enable. 136 * Handler - Pointer to the handler function for the 137 * event 138 * Context - Value passed to the handler on each GPE 139 * 140 * RETURN: Status 141 * 142 * DESCRIPTION: Saves the pointer to the handler function and then enables the 143 * event. 144 * 145 ******************************************************************************/ 146 147ACPI_STATUS 148AcpiInstallFixedEventHandler ( 149 UINT32 Event, 150 ACPI_EVENT_HANDLER Handler, 151 void *Context) 152{ 153 ACPI_STATUS Status; 154 155 156 ACPI_FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); 157 158 159 /* Parameter validation */ 160 161 if (Event > ACPI_EVENT_MAX) 162 { 163 return_ACPI_STATUS (AE_BAD_PARAMETER); 164 } 165 166 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 167 if (ACPI_FAILURE (Status)) 168 { 169 return_ACPI_STATUS (Status); 170 } 171 172 /* Don't allow two handlers. */ 173 174 if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) 175 { 176 Status = AE_ALREADY_EXISTS; 177 goto Cleanup; 178 } 179 180 181 /* Install the handler before enabling the event */ 182 183 AcpiGbl_FixedEventHandlers[Event].Handler = Handler; 184 AcpiGbl_FixedEventHandlers[Event].Context = Context; 185 186 Status = AcpiEnableEvent (Event, ACPI_EVENT_FIXED, 0); 187 if (ACPI_FAILURE (Status)) 188 { 189 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); 190 191 /* Remove the handler */ 192 193 AcpiGbl_FixedEventHandlers[Event].Handler = NULL; 194 AcpiGbl_FixedEventHandlers[Event].Context = NULL; 195 } 196 else 197 { 198 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 199 "Enabled fixed event %X, Handler=%p\n", Event, Handler)); 200 } 201 202 203Cleanup: 204 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 205 return_ACPI_STATUS (Status); 206} 207 208 209/******************************************************************************* 210 * 211 * FUNCTION: AcpiRemoveFixedEventHandler 212 * 213 * PARAMETERS: Event - Event type to disable. 214 * Handler - Address of the handler 215 * 216 * RETURN: Status 217 * 218 * DESCRIPTION: Disables the event and unregisters the event handler. 219 * 220 ******************************************************************************/ 221 222ACPI_STATUS 223AcpiRemoveFixedEventHandler ( 224 UINT32 Event, 225 ACPI_EVENT_HANDLER Handler) 226{ 227 ACPI_STATUS Status = AE_OK; 228 229 230 ACPI_FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); 231 232 233 /* Parameter validation */ 234 235 if (Event > ACPI_EVENT_MAX) 236 { 237 return_ACPI_STATUS (AE_BAD_PARAMETER); 238 } 239 240 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 241 if (ACPI_FAILURE (Status)) 242 { 243 return_ACPI_STATUS (Status); 244 } 245 246 /* Disable the event before removing the handler */ 247 248 Status = AcpiDisableEvent(Event, ACPI_EVENT_FIXED, 0); 249 250 /* Always Remove the handler */ 251 252 AcpiGbl_FixedEventHandlers[Event].Handler = NULL; 253 AcpiGbl_FixedEventHandlers[Event].Context = NULL; 254 255 if (ACPI_FAILURE (Status)) 256 { 257 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 258 "Could not write to fixed event enable register.\n")); 259 } 260 else 261 { 262 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", Event)); 263 } 264 265 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 266 return_ACPI_STATUS (Status); 267} 268 269 270/******************************************************************************* 271 * 272 * FUNCTION: AcpiInstallNotifyHandler 273 * 274 * PARAMETERS: Device - The device for which notifies will be handled 275 * HandlerType - The type of handler: 276 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 277 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 278 * Handler - Address of the handler 279 * Context - Value passed to the handler on each GPE 280 * 281 * RETURN: Status 282 * 283 * DESCRIPTION: Install a handler for notifies on an ACPI device 284 * 285 ******************************************************************************/ 286 287ACPI_STATUS 288AcpiInstallNotifyHandler ( 289 ACPI_HANDLE Device, 290 UINT32 HandlerType, 291 ACPI_NOTIFY_HANDLER Handler, 292 void *Context) 293{ 294 ACPI_OPERAND_OBJECT *ObjDesc; 295 ACPI_OPERAND_OBJECT *NotifyObj; 296 ACPI_NAMESPACE_NODE *DeviceNode; 297 ACPI_STATUS Status; 298 299 300 ACPI_FUNCTION_TRACE ("AcpiInstallNotifyHandler"); 301 302 303 /* Parameter validation */ 304 305 if ((!Handler) || 306 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 307 { 308 return_ACPI_STATUS (AE_BAD_PARAMETER); 309 } 310 311 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 312 if (ACPI_FAILURE (Status)) 313 { 314 return_ACPI_STATUS (Status); 315 } 316 317 /* Convert and validate the device handle */ 318 319 DeviceNode = AcpiNsMapHandleToNode (Device); 320 if (!DeviceNode) 321 { 322 Status = AE_BAD_PARAMETER; 323 goto UnlockAndExit; 324 } 325 326 /* 327 * Root Object: 328 * Registering a notify handler on the root object indicates that the 329 * caller wishes to receive notifications for all objects. Note that 330 * only one <external> global handler can be regsitered (per notify type). 331 */ 332 if (Device == ACPI_ROOT_OBJECT) 333 { 334 /* Make sure the handler is not already installed */ 335 336 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 337 AcpiGbl_SysNotify.Handler) || 338 ((HandlerType == ACPI_DEVICE_NOTIFY) && 339 AcpiGbl_DrvNotify.Handler)) 340 { 341 Status = AE_ALREADY_EXISTS; 342 goto UnlockAndExit; 343 } 344 345 if (HandlerType == ACPI_SYSTEM_NOTIFY) 346 { 347 AcpiGbl_SysNotify.Node = DeviceNode; 348 AcpiGbl_SysNotify.Handler = Handler; 349 AcpiGbl_SysNotify.Context = Context; 350 } 351 else /* ACPI_DEVICE_NOTIFY */ 352 { 353 AcpiGbl_DrvNotify.Node = DeviceNode; 354 AcpiGbl_DrvNotify.Handler = Handler; 355 AcpiGbl_DrvNotify.Context = Context; 356 } 357 358 /* Global notify handler installed */ 359 } 360 361 /* 362 * All Other Objects: 363 * Caller will only receive notifications specific to the target object. 364 * Note that only certain object types can receive notifications. 365 */ 366 else 367 { 368 /* 369 * These are the ONLY objects that can receive ACPI notifications 370 */ 371 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 372 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 373 (DeviceNode->Type != ACPI_TYPE_POWER) && 374 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 375 { 376 Status = AE_BAD_PARAMETER; 377 goto UnlockAndExit; 378 } 379 380 /* Check for an existing internal object */ 381 382 ObjDesc = AcpiNsGetAttachedObject (DeviceNode); 383 if (ObjDesc) 384 { 385 386 /* Object exists - make sure there's no handler */ 387 388 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 389 ObjDesc->Device.SysHandler) || 390 ((HandlerType == ACPI_DEVICE_NOTIFY) && 391 ObjDesc->Device.DrvHandler)) 392 { 393 Status = AE_ALREADY_EXISTS; 394 goto UnlockAndExit; 395 } 396 } 397 else 398 { 399 /* Create a new object */ 400 401 ObjDesc = AcpiUtCreateInternalObject (DeviceNode->Type); 402 if (!ObjDesc) 403 { 404 Status = AE_NO_MEMORY; 405 goto UnlockAndExit; 406 } 407 408 /* Attach new object to the Node */ 409 410 Status = AcpiNsAttachObject (Device, ObjDesc, DeviceNode->Type); 411 if (ACPI_FAILURE (Status)) 412 { 413 goto UnlockAndExit; 414 } 415 } 416 417 /* Install the handler */ 418 419 NotifyObj = AcpiUtCreateInternalObject (INTERNAL_TYPE_NOTIFY); 420 if (!NotifyObj) 421 { 422 Status = AE_NO_MEMORY; 423 goto UnlockAndExit; 424 } 425 426 NotifyObj->NotifyHandler.Node = DeviceNode; 427 NotifyObj->NotifyHandler.Handler = Handler; 428 NotifyObj->NotifyHandler.Context = Context; 429 430 431 if (HandlerType == ACPI_SYSTEM_NOTIFY) 432 { 433 ObjDesc->Device.SysHandler = NotifyObj; 434 } 435 else /* ACPI_DEVICE_NOTIFY */ 436 { 437 ObjDesc->Device.DrvHandler = NotifyObj; 438 } 439 } 440 441 442UnlockAndExit: 443 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 444 return_ACPI_STATUS (Status); 445} 446 447 448/******************************************************************************* 449 * 450 * FUNCTION: AcpiRemoveNotifyHandler 451 * 452 * PARAMETERS: Device - The device for which notifies will be handled 453 * HandlerType - The type of handler: 454 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 455 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 456 * Handler - Address of the handler 457 * RETURN: Status 458 * 459 * DESCRIPTION: Remove a handler for notifies on an ACPI device 460 * 461 ******************************************************************************/ 462 463ACPI_STATUS 464AcpiRemoveNotifyHandler ( 465 ACPI_HANDLE Device, 466 UINT32 HandlerType, 467 ACPI_NOTIFY_HANDLER Handler) 468{ 469 ACPI_OPERAND_OBJECT *NotifyObj; 470 ACPI_OPERAND_OBJECT *ObjDesc; 471 ACPI_NAMESPACE_NODE *DeviceNode; 472 ACPI_STATUS Status; 473 474 475 ACPI_FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); 476 477 478 /* Parameter validation */ 479 480 if ((!Handler) || 481 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 482 { 483 return_ACPI_STATUS (AE_BAD_PARAMETER); 484 } 485 486 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 487 if (ACPI_FAILURE (Status)) 488 { 489 return_ACPI_STATUS (Status); 490 } 491 492 /* Convert and validate the device handle */ 493 494 DeviceNode = AcpiNsMapHandleToNode (Device); 495 if (!DeviceNode) 496 { 497 Status = AE_BAD_PARAMETER; 498 goto UnlockAndExit; 499 } 500 501 /* 502 * Root Object 503 */ 504 if (Device == ACPI_ROOT_OBJECT) 505 { 506 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); 507 508 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 509 !AcpiGbl_SysNotify.Handler) || 510 ((HandlerType == ACPI_DEVICE_NOTIFY) && 511 !AcpiGbl_DrvNotify.Handler)) 512 { 513 Status = AE_NOT_EXIST; 514 goto UnlockAndExit; 515 } 516 517 if (HandlerType == ACPI_SYSTEM_NOTIFY) 518 { 519 AcpiGbl_SysNotify.Node = NULL; 520 AcpiGbl_SysNotify.Handler = NULL; 521 AcpiGbl_SysNotify.Context = NULL; 522 } 523 else 524 { 525 AcpiGbl_DrvNotify.Node = NULL; 526 AcpiGbl_DrvNotify.Handler = NULL; 527 AcpiGbl_DrvNotify.Context = NULL; 528 } 529 } 530 531 /* 532 * All Other Objects 533 */ 534 else 535 { 536 /* 537 * These are the ONLY objects that can receive ACPI notifications 538 */ 539 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 540 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 541 (DeviceNode->Type != ACPI_TYPE_POWER) && 542 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 543 { 544 Status = AE_BAD_PARAMETER; 545 goto UnlockAndExit; 546 } 547 548 /* Check for an existing internal object */ 549 550 ObjDesc = AcpiNsGetAttachedObject (DeviceNode); 551 if (!ObjDesc) 552 { 553 Status = AE_NOT_EXIST; 554 goto UnlockAndExit; 555 } 556 557 /* Object exists - make sure there's an existing handler */ 558 559 if (HandlerType == ACPI_SYSTEM_NOTIFY) 560 { 561 NotifyObj = ObjDesc->Device.SysHandler; 562 } 563 else 564 { 565 NotifyObj = ObjDesc->Device.DrvHandler; 566 } 567 568 if ((!NotifyObj) || 569 (NotifyObj->NotifyHandler.Handler != Handler)) 570 { 571 Status = AE_BAD_PARAMETER; 572 goto UnlockAndExit; 573 } 574 575 /* Remove the handler */ 576 577 if (HandlerType == ACPI_SYSTEM_NOTIFY) 578 { 579 ObjDesc->Device.SysHandler = NULL; 580 } 581 else 582 { 583 ObjDesc->Device.DrvHandler = NULL; 584 } 585 586 AcpiUtRemoveReference (NotifyObj); 587 } 588 589 590UnlockAndExit: 591 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 592 return_ACPI_STATUS (Status); 593} 594 595 596/******************************************************************************* 597 * 598 * FUNCTION: AcpiInstallGpeHandler 599 * 600 * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is 601 * bank 0 first, then bank 1. 602 * Type - Whether this GPE should be treated as an 603 * edge- or level-triggered interrupt. 604 * Handler - Address of the handler 605 * Context - Value passed to the handler on each GPE 606 * 607 * RETURN: Status 608 * 609 * DESCRIPTION: Install a handler for a General Purpose Event. 610 * 611 ******************************************************************************/ 612 613ACPI_STATUS 614AcpiInstallGpeHandler ( 615 UINT32 GpeNumber, 616 UINT32 Type, 617 ACPI_GPE_HANDLER Handler, 618 void *Context) 619{ 620 ACPI_STATUS Status; 621 UINT32 GpeNumberIndex; 622 623 624 ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); 625 626 627 /* Parameter validation */ 628 629 if (!Handler) 630 { 631 return_ACPI_STATUS (AE_BAD_PARAMETER); 632 } 633 634 /* Ensure that we have a valid GPE number */ 635 636 GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); 637 if (GpeNumberIndex == ACPI_GPE_INVALID) 638 { 639 return_ACPI_STATUS (AE_BAD_PARAMETER); 640 } 641 642 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 643 if (ACPI_FAILURE (Status)) 644 { 645 return_ACPI_STATUS (Status); 646 } 647 648 /* Make sure that there isn't a handler there already */ 649 650 if (AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler) 651 { 652 Status = AE_ALREADY_EXISTS; 653 goto Cleanup; 654 } 655 656 /* Install the handler */ 657 658 AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler = Handler; 659 AcpiGbl_GpeNumberInfo[GpeNumberIndex].Context = Context; 660 AcpiGbl_GpeNumberInfo[GpeNumberIndex].Type = (UINT8) Type; 661 662 /* Clear the GPE (of stale events), the enable it */ 663 664 AcpiHwClearGpe (GpeNumber); 665 AcpiHwEnableGpe (GpeNumber); 666 667 668Cleanup: 669 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 670 return_ACPI_STATUS (Status); 671} 672 673 674/******************************************************************************* 675 * 676 * FUNCTION: AcpiRemoveGpeHandler 677 * 678 * PARAMETERS: GpeNumber - The event to remove a handler 679 * Handler - Address of the handler 680 * 681 * RETURN: Status 682 * 683 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. 684 * 685 ******************************************************************************/ 686 687ACPI_STATUS 688AcpiRemoveGpeHandler ( 689 UINT32 GpeNumber, 690 ACPI_GPE_HANDLER Handler) 691{ 692 ACPI_STATUS Status; 693 UINT32 GpeNumberIndex; 694 695 696 ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); 697 698 699 /* Parameter validation */ 700 701 if (!Handler) 702 { 703 return_ACPI_STATUS (AE_BAD_PARAMETER); 704 } 705 706 /* Ensure that we have a valid GPE number */ 707 708 GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); 709 if (GpeNumberIndex == ACPI_GPE_INVALID) 710 { 711 return_ACPI_STATUS (AE_BAD_PARAMETER); 712 } 713 714 /* Disable the GPE before removing the handler */ 715 716 AcpiHwDisableGpe (GpeNumber); 717 718 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 719 if (ACPI_FAILURE (Status)) 720 { 721 return_ACPI_STATUS (Status); 722 } 723 724 /* Make sure that the installed handler is the same */ 725 726 if (AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler != Handler) 727 { 728 AcpiHwEnableGpe (GpeNumber); 729 Status = AE_BAD_PARAMETER; 730 goto Cleanup; 731 } 732 733 /* Remove the handler */ 734 735 AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler = NULL; 736 AcpiGbl_GpeNumberInfo[GpeNumberIndex].Context = NULL; 737 738 739Cleanup: 740 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 741 return_ACPI_STATUS (Status); 742} 743 744 745/******************************************************************************* 746 * 747 * FUNCTION: AcpiAcquireGlobalLock 748 * 749 * PARAMETERS: Timeout - How long the caller is willing to wait 750 * OutHandle - A handle to the lock if acquired 751 * 752 * RETURN: Status 753 * 754 * DESCRIPTION: Acquire the ACPI Global Lock 755 * 756 ******************************************************************************/ 757 758ACPI_STATUS 759AcpiAcquireGlobalLock ( 760 UINT32 Timeout, 761 UINT32 *Handle) 762{ 763 ACPI_STATUS Status; 764 765 766 if (!Handle) 767 { 768 return (AE_BAD_PARAMETER); 769 } 770 771 Status = AcpiExEnterInterpreter (); 772 if (ACPI_FAILURE (Status)) 773 { 774 return (Status); 775 } 776 777 Status = AcpiEvAcquireGlobalLock (Timeout); 778 AcpiExExitInterpreter (); 779 780 if (ACPI_SUCCESS (Status)) 781 { 782 AcpiGbl_GlobalLockHandle++; 783 *Handle = AcpiGbl_GlobalLockHandle; 784 } 785 786 return (Status); 787} 788 789 790/******************************************************************************* 791 * 792 * FUNCTION: AcpiReleaseGlobalLock 793 * 794 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock 795 * 796 * RETURN: Status 797 * 798 * DESCRIPTION: Release the ACPI Global Lock 799 * 800 ******************************************************************************/ 801 802ACPI_STATUS 803AcpiReleaseGlobalLock ( 804 UINT32 Handle) 805{ 806 807 if (Handle != AcpiGbl_GlobalLockHandle) 808 { 809 return (AE_NOT_ACQUIRED); 810 } 811 812 AcpiEvReleaseGlobalLock (); 813 return (AE_OK); 814} 815 816 817