evxface.c revision 82367
1/****************************************************************************** 2 * 3 * Module Name: evxface - External interfaces for ACPI events 4 * $Revision: 111 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 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 FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); 157 158 159 /* Ensure that ACPI has been initialized */ 160 161 ACPI_IS_INITIALIZATION_COMPLETE (Status); 162 if (ACPI_FAILURE (Status)) 163 { 164 return_ACPI_STATUS (Status); 165 } 166 167 /* Parameter validation */ 168 169 if (Event > ACPI_EVENT_MAX) 170 { 171 return_ACPI_STATUS (AE_BAD_PARAMETER); 172 } 173 174 AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 175 176 /* Don't allow two handlers. */ 177 178 if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) 179 { 180 Status = AE_EXIST; 181 goto Cleanup; 182 } 183 184 185 /* Install the handler before enabling the event - just in case... */ 186 187 AcpiGbl_FixedEventHandlers[Event].Handler = Handler; 188 AcpiGbl_FixedEventHandlers[Event].Context = Context; 189 190 Status = AcpiEnableEvent (Event, ACPI_EVENT_FIXED); 191 if (!ACPI_SUCCESS (Status)) 192 { 193 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); 194 195 /* Remove the handler */ 196 197 AcpiGbl_FixedEventHandlers[Event].Handler = NULL; 198 AcpiGbl_FixedEventHandlers[Event].Context = NULL; 199 } 200 201 else 202 { 203 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 204 "Enabled fixed event %X, Handler=%p\n", Event, Handler)); 205 } 206 207 208Cleanup: 209 AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 210 return_ACPI_STATUS (Status); 211} 212 213 214/******************************************************************************* 215 * 216 * FUNCTION: AcpiRemoveFixedEventHandler 217 * 218 * PARAMETERS: Event - Event type to disable. 219 * Handler - Address of the handler 220 * 221 * RETURN: Status 222 * 223 * DESCRIPTION: Disables the event and unregisters the event handler. 224 * 225 ******************************************************************************/ 226 227ACPI_STATUS 228AcpiRemoveFixedEventHandler ( 229 UINT32 Event, 230 ACPI_EVENT_HANDLER Handler) 231{ 232 ACPI_STATUS Status = AE_OK; 233 234 235 FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); 236 237 238 /* Ensure that ACPI has been initialized */ 239 240 ACPI_IS_INITIALIZATION_COMPLETE (Status); 241 if (ACPI_FAILURE (Status)) 242 { 243 return_ACPI_STATUS (Status); 244 } 245 246 /* Parameter validation */ 247 248 if (Event > ACPI_EVENT_MAX) 249 { 250 return_ACPI_STATUS (AE_BAD_PARAMETER); 251 } 252 253 AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 254 255 /* Disable the event before removing the handler - just in case... */ 256 257 Status = AcpiDisableEvent(Event, ACPI_EVENT_FIXED); 258 259 /* Always Remove the handler */ 260 261 AcpiGbl_FixedEventHandlers[Event].Handler = NULL; 262 AcpiGbl_FixedEventHandlers[Event].Context = NULL; 263 264 265 if (!ACPI_SUCCESS(Status)) 266 { 267 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 268 "Could not write to fixed event enable register.\n")); 269 } 270 271 else 272 { 273 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", Event)); 274 } 275 276 AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 277 return_ACPI_STATUS (Status); 278} 279 280 281/******************************************************************************* 282 * 283 * FUNCTION: AcpiInstallNotifyHandler 284 * 285 * PARAMETERS: Device - The device for which notifies will be handled 286 * HandlerType - The type of handler: 287 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 288 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 289 * Handler - Address of the handler 290 * Context - Value passed to the handler on each GPE 291 * 292 * RETURN: Status 293 * 294 * DESCRIPTION: Install a handler for notifies on an ACPI device 295 * 296 ******************************************************************************/ 297 298ACPI_STATUS 299AcpiInstallNotifyHandler ( 300 ACPI_HANDLE Device, 301 UINT32 HandlerType, 302 ACPI_NOTIFY_HANDLER Handler, 303 void *Context) 304{ 305 ACPI_OPERAND_OBJECT *ObjDesc; 306 ACPI_OPERAND_OBJECT *NotifyObj; 307 ACPI_NAMESPACE_NODE *DeviceNode; 308 ACPI_STATUS Status = AE_OK; 309 310 311 FUNCTION_TRACE ("AcpiInstallNotifyHandler"); 312 313 314 /* Ensure that ACPI has been initialized */ 315 316 ACPI_IS_INITIALIZATION_COMPLETE (Status); 317 if (ACPI_FAILURE (Status)) 318 { 319 return_ACPI_STATUS (Status); 320 } 321 322 /* Parameter validation */ 323 324 if ((!Handler) || 325 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 326 { 327 return_ACPI_STATUS (AE_BAD_PARAMETER); 328 } 329 330 AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 331 332 /* Convert and validate the device handle */ 333 334 DeviceNode = AcpiNsConvertHandleToEntry (Device); 335 if (!DeviceNode) 336 { 337 Status = AE_BAD_PARAMETER; 338 goto UnlockAndExit; 339 } 340 341 /* 342 * Root Object: 343 * ------------ 344 * Registering a notify handler on the root object indicates that the 345 * caller wishes to receive notifications for all objects. Note that 346 * only one <external> global handler can be regsitered (per notify type). 347 */ 348 if (Device == ACPI_ROOT_OBJECT) 349 { 350 /* Make sure the handler is not already installed */ 351 352 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 353 AcpiGbl_SysNotify.Handler) || 354 ((HandlerType == ACPI_DEVICE_NOTIFY) && 355 AcpiGbl_DrvNotify.Handler)) 356 { 357 Status = AE_EXIST; 358 goto UnlockAndExit; 359 } 360 361 if (HandlerType == ACPI_SYSTEM_NOTIFY) 362 { 363 AcpiGbl_SysNotify.Node = DeviceNode; 364 AcpiGbl_SysNotify.Handler = Handler; 365 AcpiGbl_SysNotify.Context = Context; 366 } 367 else /* ACPI_DEVICE_NOTIFY */ 368 { 369 AcpiGbl_DrvNotify.Node = DeviceNode; 370 AcpiGbl_DrvNotify.Handler = Handler; 371 AcpiGbl_DrvNotify.Context = Context; 372 } 373 374 /* Global notify handler installed */ 375 } 376 377 /* 378 * Other Objects: 379 * -------------- 380 * Caller will only receive notifications specific to the target object. 381 * Note that only certain object types can receive notifications. 382 */ 383 else { 384 /* 385 * These are the ONLY objects that can receive ACPI notifications 386 */ 387 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 388 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 389 (DeviceNode->Type != ACPI_TYPE_POWER) && 390 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 391 { 392 Status = AE_BAD_PARAMETER; 393 goto UnlockAndExit; 394 } 395 396 /* Check for an existing internal object */ 397 398 ObjDesc = AcpiNsGetAttachedObject (DeviceNode); 399 if (ObjDesc) 400 { 401 402 /* Object exists - make sure there's no handler */ 403 404 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 405 ObjDesc->Device.SysHandler) || 406 ((HandlerType == ACPI_DEVICE_NOTIFY) && 407 ObjDesc->Device.DrvHandler)) 408 { 409 Status = AE_EXIST; 410 goto UnlockAndExit; 411 } 412 } 413 414 else 415 { 416 /* Create a new object */ 417 418 ObjDesc = AcpiUtCreateInternalObject (DeviceNode->Type); 419 if (!ObjDesc) 420 { 421 Status = AE_NO_MEMORY; 422 goto UnlockAndExit; 423 } 424 425 /* Attach new object to the Node */ 426 427 Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); 428 if (ACPI_FAILURE (Status)) 429 { 430 goto UnlockAndExit; 431 } 432 } 433 434 /* Install the handler */ 435 436 NotifyObj = AcpiUtCreateInternalObject (INTERNAL_TYPE_NOTIFY); 437 if (!NotifyObj) 438 { 439 Status = AE_NO_MEMORY; 440 goto UnlockAndExit; 441 } 442 443 NotifyObj->NotifyHandler.Node = DeviceNode; 444 NotifyObj->NotifyHandler.Handler = Handler; 445 NotifyObj->NotifyHandler.Context = Context; 446 447 448 if (HandlerType == ACPI_SYSTEM_NOTIFY) 449 { 450 ObjDesc->Device.SysHandler = NotifyObj; 451 } 452 453 else /* ACPI_DEVICE_NOTIFY */ 454 { 455 ObjDesc->Device.DrvHandler = NotifyObj; 456 } 457 } 458 459UnlockAndExit: 460 AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 461 return_ACPI_STATUS (Status); 462} 463 464 465/******************************************************************************* 466 * 467 * FUNCTION: AcpiRemoveNotifyHandler 468 * 469 * PARAMETERS: Device - The device for which notifies will be handled 470 * HandlerType - The type of handler: 471 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 472 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 473 * Handler - Address of the handler 474 * RETURN: Status 475 * 476 * DESCRIPTION: Remove a handler for notifies on an ACPI device 477 * 478 ******************************************************************************/ 479 480ACPI_STATUS 481AcpiRemoveNotifyHandler ( 482 ACPI_HANDLE Device, 483 UINT32 HandlerType, 484 ACPI_NOTIFY_HANDLER Handler) 485{ 486 ACPI_OPERAND_OBJECT *NotifyObj; 487 ACPI_OPERAND_OBJECT *ObjDesc; 488 ACPI_NAMESPACE_NODE *DeviceNode; 489 ACPI_STATUS Status = AE_OK; 490 491 492 FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); 493 494 495 /* Ensure that ACPI has been initialized */ 496 497 ACPI_IS_INITIALIZATION_COMPLETE (Status); 498 if (ACPI_FAILURE (Status)) 499 { 500 return_ACPI_STATUS (Status); 501 } 502 503 /* Parameter validation */ 504 505 if ((!Handler) || 506 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 507 { 508 return_ACPI_STATUS (AE_BAD_PARAMETER); 509 } 510 511 AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 512 513 /* Convert and validate the device handle */ 514 515 DeviceNode = AcpiNsConvertHandleToEntry (Device); 516 if (!DeviceNode) 517 { 518 Status = AE_BAD_PARAMETER; 519 goto UnlockAndExit; 520 } 521 522 /* 523 * Root Object: 524 * ------------ 525 */ 526 if (Device == ACPI_ROOT_OBJECT) { 527 528 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); 529 530 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 531 !AcpiGbl_SysNotify.Handler) || 532 ((HandlerType == ACPI_DEVICE_NOTIFY) && 533 !AcpiGbl_DrvNotify.Handler)) 534 { 535 Status = AE_NOT_EXIST; 536 goto UnlockAndExit; 537 } 538 539 if (HandlerType == ACPI_SYSTEM_NOTIFY) { 540 AcpiGbl_SysNotify.Node = NULL; 541 AcpiGbl_SysNotify.Handler = NULL; 542 AcpiGbl_SysNotify.Context = NULL; 543 } 544 else { 545 AcpiGbl_DrvNotify.Node = NULL; 546 AcpiGbl_DrvNotify.Handler = NULL; 547 AcpiGbl_DrvNotify.Context = NULL; 548 } 549 } 550 551 /* 552 * Other Objects: 553 * -------------- 554 */ 555 else { 556 /* 557 * These are the ONLY objects that can receive ACPI notifications 558 */ 559 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 560 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 561 (DeviceNode->Type != ACPI_TYPE_POWER) && 562 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 563 { 564 Status = AE_BAD_PARAMETER; 565 goto UnlockAndExit; 566 } 567 568 /* Check for an existing internal object */ 569 570 ObjDesc = AcpiNsGetAttachedObject (DeviceNode); 571 if (!ObjDesc) 572 { 573 Status = AE_NOT_EXIST; 574 goto UnlockAndExit; 575 } 576 577 /* Object exists - make sure there's an existing handler */ 578 579 if (HandlerType == ACPI_SYSTEM_NOTIFY) 580 { 581 NotifyObj = ObjDesc->Device.SysHandler; 582 } 583 else 584 { 585 NotifyObj = ObjDesc->Device.DrvHandler; 586 } 587 588 if ((!NotifyObj) || 589 (NotifyObj->NotifyHandler.Handler != Handler)) 590 { 591 Status = AE_BAD_PARAMETER; 592 goto UnlockAndExit; 593 } 594 595 /* Remove the handler */ 596 597 if (HandlerType == ACPI_SYSTEM_NOTIFY) 598 { 599 ObjDesc->Device.SysHandler = NULL; 600 } 601 else 602 { 603 ObjDesc->Device.DrvHandler = NULL; 604 } 605 606 AcpiUtRemoveReference (NotifyObj); 607 } 608 609 610UnlockAndExit: 611 AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 612 return_ACPI_STATUS (Status); 613} 614 615 616/******************************************************************************* 617 * 618 * FUNCTION: AcpiInstallGpeHandler 619 * 620 * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is 621 * bank 0 first, then bank 1. 622 * Type - Whether this GPE should be treated as an 623 * edge- or level-triggered interrupt. 624 * Handler - Address of the handler 625 * Context - Value passed to the handler on each GPE 626 * 627 * RETURN: Status 628 * 629 * DESCRIPTION: Install a handler for a General Purpose Event. 630 * 631 ******************************************************************************/ 632 633ACPI_STATUS 634AcpiInstallGpeHandler ( 635 UINT32 GpeNumber, 636 UINT32 Type, 637 ACPI_GPE_HANDLER Handler, 638 void *Context) 639{ 640 ACPI_STATUS Status = AE_OK; 641 642 643 FUNCTION_TRACE ("AcpiInstallGpeHandler"); 644 645 646 /* Ensure that ACPI has been initialized */ 647 648 ACPI_IS_INITIALIZATION_COMPLETE (Status); 649 if (ACPI_FAILURE (Status)) 650 { 651 return_ACPI_STATUS (Status); 652 } 653 654 /* Parameter validation */ 655 656 if (!Handler || (GpeNumber > ACPI_GPE_MAX)) 657 { 658 return_ACPI_STATUS (AE_BAD_PARAMETER); 659 } 660 661 /* Ensure that we have a valid GPE number */ 662 663 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 664 { 665 return_ACPI_STATUS (AE_BAD_PARAMETER); 666 } 667 668 AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 669 670 /* Make sure that there isn't a handler there already */ 671 672 if (AcpiGbl_GpeInfo[GpeNumber].Handler) 673 { 674 Status = AE_EXIST; 675 goto Cleanup; 676 } 677 678 /* Install the handler */ 679 680 AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; 681 AcpiGbl_GpeInfo[GpeNumber].Context = Context; 682 AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; 683 684 /* Clear the GPE (of stale events), the enable it */ 685 686 AcpiHwClearGpe (GpeNumber); 687 AcpiHwEnableGpe (GpeNumber); 688 689Cleanup: 690 AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 691 return_ACPI_STATUS (Status); 692} 693 694 695/******************************************************************************* 696 * 697 * FUNCTION: AcpiRemoveGpeHandler 698 * 699 * PARAMETERS: GpeNumber - The event to remove a handler 700 * Handler - Address of the handler 701 * 702 * RETURN: Status 703 * 704 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. 705 * 706 ******************************************************************************/ 707 708ACPI_STATUS 709AcpiRemoveGpeHandler ( 710 UINT32 GpeNumber, 711 ACPI_GPE_HANDLER Handler) 712{ 713 ACPI_STATUS Status = AE_OK; 714 715 716 FUNCTION_TRACE ("AcpiRemoveGpeHandler"); 717 718 719 /* Ensure that ACPI has been initialized */ 720 721 ACPI_IS_INITIALIZATION_COMPLETE (Status); 722 if (ACPI_FAILURE (Status)) 723 { 724 return_ACPI_STATUS (Status); 725 } 726 727 /* Parameter validation */ 728 729 if (!Handler || (GpeNumber > ACPI_GPE_MAX)) 730 { 731 return_ACPI_STATUS (AE_BAD_PARAMETER); 732 } 733 734 /* Ensure that we have a valid GPE number */ 735 736 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 737 { 738 return_ACPI_STATUS (AE_BAD_PARAMETER); 739 } 740 741 /* Disable the GPE before removing the handler */ 742 743 AcpiHwDisableGpe (GpeNumber); 744 745 AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 746 747 /* Make sure that the installed handler is the same */ 748 749 if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) 750 { 751 AcpiHwEnableGpe (GpeNumber); 752 Status = AE_BAD_PARAMETER; 753 goto Cleanup; 754 } 755 756 /* Remove the handler */ 757 758 AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; 759 AcpiGbl_GpeInfo[GpeNumber].Context = NULL; 760 761Cleanup: 762 AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 763 return_ACPI_STATUS (Status); 764} 765 766 767/******************************************************************************* 768 * 769 * FUNCTION: AcpiAcquireGlobalLock 770 * 771 * PARAMETERS: Timeout - How long the caller is willing to wait 772 * OutHandle - A handle to the lock if acquired 773 * 774 * RETURN: Status 775 * 776 * DESCRIPTION: Acquire the ACPI Global Lock 777 * 778 ******************************************************************************/ 779ACPI_STATUS 780AcpiAcquireGlobalLock ( 781 void) 782{ 783 ACPI_STATUS Status; 784 785 786 /* Ensure that ACPI has been initialized */ 787 788 ACPI_IS_INITIALIZATION_COMPLETE (Status); 789 if (ACPI_FAILURE (Status)) 790 { 791 return (Status); 792 } 793 794 Status = AcpiExEnterInterpreter (); 795 if (ACPI_FAILURE (Status)) 796 { 797 return (Status); 798 } 799 800 /* 801 * TBD: [Restructure] add timeout param to internal interface, and 802 * perhaps INTERPRETER_LOCKED 803 */ 804 805 Status = AcpiEvAcquireGlobalLock (); 806 AcpiExExitInterpreter (); 807 808 return (Status); 809} 810 811 812/******************************************************************************* 813 * 814 * FUNCTION: AcpiReleaseGlobalLock 815 * 816 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock 817 * 818 * RETURN: Status 819 * 820 * DESCRIPTION: Release the ACPI Global Lock 821 * 822 ******************************************************************************/ 823 824ACPI_STATUS 825AcpiReleaseGlobalLock ( 826 void) 827{ 828 ACPI_STATUS Status; 829 830 831 /* Ensure that ACPI has been initialized */ 832 833 ACPI_IS_INITIALIZATION_COMPLETE (Status); 834 if (ACPI_FAILURE (Status)) 835 { 836 return (Status); 837 } 838 839 AcpiEvReleaseGlobalLock (); 840 return (AE_OK); 841} 842 843 844