5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13 * 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 EVENT_HANDLING 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 FIXED_EVENT_HANDLER Handler, 151 void *Context) 152{ 153 ACPI_STATUS Status = AE_OK; 154 155 156 FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); 157 158 159 /* Sanity check the parameters. */ 160 161 if (Event >= NUM_FIXED_EVENTS) 162 { 163 return_ACPI_STATUS (AE_BAD_PARAMETER); 164 } 165 166 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 167 168 /* Don't allow two handlers. */ 169 170 if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) 171 { 172 Status = AE_EXIST; 173 goto Cleanup; 174 } 175 176 177 /* Install the handler before enabling the event - just in case... */ 178 179 AcpiGbl_FixedEventHandlers[Event].Handler = Handler; 180 AcpiGbl_FixedEventHandlers[Event].Context = Context; 181
| 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13 * 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 EVENT_HANDLING 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 FIXED_EVENT_HANDLER Handler, 151 void *Context) 152{ 153 ACPI_STATUS Status = AE_OK; 154 155 156 FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); 157 158 159 /* Sanity check the parameters. */ 160 161 if (Event >= NUM_FIXED_EVENTS) 162 { 163 return_ACPI_STATUS (AE_BAD_PARAMETER); 164 } 165 166 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 167 168 /* Don't allow two handlers. */ 169 170 if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) 171 { 172 Status = AE_EXIST; 173 goto Cleanup; 174 } 175 176 177 /* Install the handler before enabling the event - just in case... */ 178 179 AcpiGbl_FixedEventHandlers[Event].Handler = Handler; 180 AcpiGbl_FixedEventHandlers[Event].Context = Context; 181
|
259 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 260 return_ACPI_STATUS (Status); 261} 262 263 264/****************************************************************************** 265 * 266 * FUNCTION: AcpiInstallNotifyHandler 267 * 268 * PARAMETERS: Device - The device for which notifies will be handled 269 * HandlerType - The type of handler: 270 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 271 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 272 * Handler - Address of the handler 273 * Context - Value passed to the handler on each GPE 274 * 275 * RETURN: Status 276 * 277 * DESCRIPTION: Install a handler for notifies on an ACPI device 278 * 279 ******************************************************************************/ 280 281ACPI_STATUS 282AcpiInstallNotifyHandler ( 283 ACPI_HANDLE Device, 284 UINT32 HandlerType, 285 NOTIFY_HANDLER Handler, 286 void *Context) 287{ 288 ACPI_OPERAND_OBJECT *ObjDesc; 289 ACPI_OPERAND_OBJECT *NotifyObj; 290 ACPI_NAMESPACE_NODE *DeviceNode; 291 ACPI_STATUS Status = AE_OK; 292 293 294 FUNCTION_TRACE ("AcpiInstallNotifyHandler"); 295 296 297 /* Parameter validation */ 298 299 if ((!Handler) || 300 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 301 { 302 return_ACPI_STATUS (AE_BAD_PARAMETER); 303 } 304 305 /* Convert and validate the device handle */ 306 307 AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 308 309 DeviceNode = AcpiNsConvertHandleToEntry (Device); 310 if (!DeviceNode) 311 { 312 Status = AE_BAD_PARAMETER; 313 goto UnlockAndExit; 314 } 315 316 317 /* 318 * Support for global notify handlers. These handlers are invoked for 319 * every notifiy of the type specifiec 320 */ 321 322 if (Device == ACPI_ROOT_OBJECT) 323 { 324 /* 325 * Make sure the handler is not already installed. 326 */ 327 328 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 329 AcpiGbl_SysNotify.Handler) || 330 ((HandlerType == ACPI_DEVICE_NOTIFY) && 331 AcpiGbl_DrvNotify.Handler)) 332 { 333 Status = AE_EXIST; 334 goto UnlockAndExit; 335 } 336 337 if (HandlerType == ACPI_SYSTEM_NOTIFY) 338 { 339 AcpiGbl_SysNotify.Node = DeviceNode; 340 AcpiGbl_SysNotify.Handler = Handler; 341 AcpiGbl_SysNotify.Context = Context; 342 } 343 344 else 345 { 346 AcpiGbl_DrvNotify.Node = DeviceNode; 347 AcpiGbl_DrvNotify.Handler = Handler; 348 AcpiGbl_DrvNotify.Context = Context; 349 } 350 351 352 /* Global notify handler installed */ 353 354 goto UnlockAndExit; 355 } 356 357 358 /* 359 * These are the ONLY objects that can receive ACPI notifications 360 */ 361 362 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 363 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 364 (DeviceNode->Type != ACPI_TYPE_POWER) && 365 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 366 { 367 Status = AE_BAD_PARAMETER; 368 goto UnlockAndExit; 369 } 370 371 /* Check for an existing internal object */ 372 373 ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); 374 if (ObjDesc) 375 { 376 /* 377 * The object exists. 378 * Make sure the handler is not already installed. 379 */ 380 381 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 382 ObjDesc->Device.SysHandler) || 383 ((HandlerType == ACPI_DEVICE_NOTIFY) && 384 ObjDesc->Device.DrvHandler)) 385 { 386 Status = AE_EXIST; 387 goto UnlockAndExit; 388 } 389 } 390 391 else 392 { 393 /* Create a new object */ 394 395 ObjDesc = AcpiCmCreateInternalObject (DeviceNode->Type); 396 if (!ObjDesc) 397 { 398 Status = AE_NO_MEMORY; 399 goto UnlockAndExit; 400 } 401 402 /* Attach new object to the Node */ 403 404 Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); 405 406 if (ACPI_FAILURE (Status)) 407 { 408 goto UnlockAndExit; 409 } 410 } 411 412 413 /* 414 * If we get here, we know that there is no handler installed 415 * so let's party 416 */ 417 NotifyObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_NOTIFY); 418 if (!NotifyObj) 419 { 420 Status = AE_NO_MEMORY; 421 goto UnlockAndExit; 422 } 423 424 NotifyObj->NotifyHandler.Node = DeviceNode; 425 NotifyObj->NotifyHandler.Handler = Handler; 426 NotifyObj->NotifyHandler.Context = Context; 427 428 429 if (HandlerType == ACPI_SYSTEM_NOTIFY) 430 { 431 ObjDesc->Device.SysHandler = NotifyObj; 432 } 433 434 else 435 { 436 ObjDesc->Device.DrvHandler = NotifyObj; 437 } 438 439 440UnlockAndExit: 441 AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 442 return_ACPI_STATUS (Status); 443} 444 445 446/***************************************************************************** 447 * 448 * FUNCTION: AcpiRemoveNotifyHandler 449 * 450 * PARAMETERS: Device - The device for which notifies will be handled 451 * HandlerType - The type of handler: 452 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 453 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 454 * Handler - Address of the handler 455 * RETURN: Status 456 * 457 * DESCRIPTION: Remove a handler for notifies on an ACPI device 458 * 459 ******************************************************************************/ 460 461ACPI_STATUS 462AcpiRemoveNotifyHandler ( 463 ACPI_HANDLE Device, 464 UINT32 HandlerType, 465 NOTIFY_HANDLER Handler) 466{ 467 ACPI_OPERAND_OBJECT *NotifyObj; 468 ACPI_OPERAND_OBJECT *ObjDesc; 469 ACPI_NAMESPACE_NODE *DeviceNode; 470 ACPI_STATUS Status = AE_OK; 471 472 473 FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); 474 475 476 /* Parameter validation */ 477 478 if ((!Handler) || 479 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 480 { 481 return_ACPI_STATUS (AE_BAD_PARAMETER); 482 } 483 484 AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 485 486 /* Convert and validate the device handle */ 487 488 DeviceNode = AcpiNsConvertHandleToEntry (Device); 489 if (!DeviceNode) 490 { 491 Status = AE_BAD_PARAMETER; 492 goto UnlockAndExit; 493 } 494 495 /* 496 * These are the ONLY objects that can receive ACPI notifications 497 */ 498 499 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 500 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 501 (DeviceNode->Type != ACPI_TYPE_POWER) && 502 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 503 { 504 Status = AE_BAD_PARAMETER; 505 goto UnlockAndExit; 506 } 507 508 /* Check for an existing internal object */ 509 510 ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); 511 if (!ObjDesc) 512 { 513 Status = AE_NOT_EXIST; 514 goto UnlockAndExit; 515 } 516 517 /* 518 * The object exists. 519 * 520 * Make sure the handler is installed. 521 */ 522 523 if (HandlerType == ACPI_SYSTEM_NOTIFY) 524 { 525 NotifyObj = ObjDesc->Device.SysHandler; 526 } 527 else 528 { 529 NotifyObj = ObjDesc->Device.DrvHandler; 530 } 531 532 if ((!NotifyObj) || 533 (NotifyObj->NotifyHandler.Handler != Handler)) 534 { 535 Status = AE_BAD_PARAMETER; 536 goto UnlockAndExit; 537 } 538 539 /* 540 * Now we can remove the handler 541 */ 542 if (HandlerType == ACPI_SYSTEM_NOTIFY) 543 { 544 ObjDesc->Device.SysHandler = NULL; 545 } 546 else 547 { 548 ObjDesc->Device.DrvHandler = NULL; 549 } 550 551 AcpiCmRemoveReference (NotifyObj); 552 553UnlockAndExit: 554 AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 555 return_ACPI_STATUS (Status); 556} 557 558/****************************************************************************** 559 * 560 * FUNCTION: AcpiInstallGpeHandler 561 * 562 * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is 563 * bank 0 first, then bank 1. 564 * Type - Whether this GPE should be treated as an 565 * edge- or level-triggered interrupt. 566 * Handler - Address of the handler 567 * Context - Value passed to the handler on each GPE 568 * 569 * RETURN: Status 570 * 571 * DESCRIPTION: Install a handler for a General Purpose Event. 572 * 573 ******************************************************************************/ 574 575ACPI_STATUS 576AcpiInstallGpeHandler ( 577 UINT32 GpeNumber, 578 UINT32 Type, 579 GPE_HANDLER Handler, 580 void *Context) 581{ 582 ACPI_STATUS Status = AE_OK; 583 584 FUNCTION_TRACE ("AcpiInstallGpeHandler"); 585 586 /* Parameter validation */ 587 588 if (!Handler || (GpeNumber > NUM_GPE)) 589 { 590 return_ACPI_STATUS (AE_BAD_PARAMETER); 591 } 592 593 /* Ensure that we have a valid GPE number */ 594 595 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 596 { 597 return_ACPI_STATUS (AE_BAD_PARAMETER); 598 } 599 600 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 601 602 /* Make sure that there isn't a handler there already */ 603 604 if (AcpiGbl_GpeInfo[GpeNumber].Handler) 605 { 606 Status = AE_EXIST; 607 goto Cleanup; 608 } 609 610 /* Install the handler */ 611 612 AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; 613 AcpiGbl_GpeInfo[GpeNumber].Context = Context; 614 AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; 615 616 /* Clear the GPE (of stale events), the enable it */ 617 618 AcpiHwClearGpe (GpeNumber); 619 AcpiHwEnableGpe (GpeNumber); 620 621Cleanup: 622 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 623 return_ACPI_STATUS (Status); 624} 625 626 627/****************************************************************************** 628 * 629 * FUNCTION: AcpiRemoveGpeHandler 630 * 631 * PARAMETERS: GpeNumber - The event to remove a handler 632 * Handler - Address of the handler 633 * 634 * RETURN: Status 635 * 636 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. 637 * 638 ******************************************************************************/ 639 640ACPI_STATUS 641AcpiRemoveGpeHandler ( 642 UINT32 GpeNumber, 643 GPE_HANDLER Handler) 644{ 645 ACPI_STATUS Status = AE_OK; 646 647 648 FUNCTION_TRACE ("AcpiRemoveGpeHandler"); 649 650 651 /* Parameter validation */ 652 653 if (!Handler || (GpeNumber > NUM_GPE)) 654 { 655 return_ACPI_STATUS (AE_BAD_PARAMETER); 656 } 657 658 /* Ensure that we have a valid GPE number */ 659 660 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 661 { 662 return_ACPI_STATUS (AE_BAD_PARAMETER); 663 } 664 665 /* Disable the GPE before removing the handler */ 666 667 AcpiHwDisableGpe (GpeNumber); 668 669 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 670 671 /* Make sure that the installed handler is the same */ 672 673 if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) 674 { 675 AcpiHwEnableGpe (GpeNumber); 676 Status = AE_BAD_PARAMETER; 677 goto Cleanup; 678 } 679 680 /* Remove the handler */ 681 682 AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; 683 AcpiGbl_GpeInfo[GpeNumber].Context = NULL; 684 685Cleanup: 686 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 687 return_ACPI_STATUS (Status); 688} 689 690 691/****************************************************************************** 692 * 693 * FUNCTION: AcpiAcquireGlobalLock 694 * 695 * PARAMETERS: Timeout - How long the caller is willing to wait 696 * OutHandle - A handle to the lock if acquired 697 * 698 * RETURN: Status 699 * 700 * DESCRIPTION: Acquire the ACPI Global Lock 701 * 702 ******************************************************************************/ 703ACPI_STATUS 704AcpiAcquireGlobalLock ( 705 void) 706{ 707 ACPI_STATUS Status; 708 709 710 AcpiAmlEnterInterpreter (); 711 712 /* 713 * TBD: [Restructure] add timeout param to internal interface, and 714 * perhaps INTERPRETER_LOCKED 715 */ 716 717 Status = AcpiEvAcquireGlobalLock (); 718 AcpiAmlExitInterpreter (); 719 720 return (Status); 721} 722 723 724/****************************************************************************** 725 * 726 * FUNCTION: AcpiReleaseGlobalLock 727 * 728 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock 729 * 730 * RETURN: Status 731 * 732 * DESCRIPTION: Release the ACPI Global Lock 733 * 734 ******************************************************************************/ 735 736ACPI_STATUS 737AcpiReleaseGlobalLock ( 738 void) 739{ 740 AcpiEvReleaseGlobalLock (); 741 return (AE_OK); 742} 743 744
| 261 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 262 return_ACPI_STATUS (Status); 263} 264 265 266/****************************************************************************** 267 * 268 * FUNCTION: AcpiInstallNotifyHandler 269 * 270 * PARAMETERS: Device - The device for which notifies will be handled 271 * HandlerType - The type of handler: 272 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) 273 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) 274 * Handler - Address of the handler 275 * Context - Value passed to the handler on each GPE 276 * 277 * RETURN: Status 278 * 279 * DESCRIPTION: Install a handler for notifies on an ACPI device 280 * 281 ******************************************************************************/ 282 283ACPI_STATUS 284AcpiInstallNotifyHandler ( 285 ACPI_HANDLE Device, 286 UINT32 HandlerType, 287 NOTIFY_HANDLER Handler, 288 void *Context) 289{ 290 ACPI_OPERAND_OBJECT *ObjDesc; 291 ACPI_OPERAND_OBJECT *NotifyObj; 292 ACPI_NAMESPACE_NODE *DeviceNode; 293 ACPI_STATUS Status = AE_OK; 294 295 296 FUNCTION_TRACE ("AcpiInstallNotifyHandler"); 297 298 299 /* Parameter validation */ 300 301 if ((!Handler) || 302 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) 303 { 304 return_ACPI_STATUS (AE_BAD_PARAMETER); 305 } 306 307 /* Convert and validate the device handle */ 308 309 AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 310 311 DeviceNode = AcpiNsConvertHandleToEntry (Device); 312 if (!DeviceNode) 313 { 314 Status = AE_BAD_PARAMETER; 315 goto UnlockAndExit; 316 } 317 318 319 /* 320 * Support for global notify handlers. These handlers are invoked for 321 * every notifiy of the type specifiec 322 */ 323 324 if (Device == ACPI_ROOT_OBJECT) 325 { 326 /* 327 * Make sure the handler is not already installed. 328 */ 329 330 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 331 AcpiGbl_SysNotify.Handler) || 332 ((HandlerType == ACPI_DEVICE_NOTIFY) && 333 AcpiGbl_DrvNotify.Handler)) 334 { 335 Status = AE_EXIST; 336 goto UnlockAndExit; 337 } 338 339 if (HandlerType == ACPI_SYSTEM_NOTIFY) 340 { 341 AcpiGbl_SysNotify.Node = DeviceNode; 342 AcpiGbl_SysNotify.Handler = Handler; 343 AcpiGbl_SysNotify.Context = Context; 344 } 345 346 else 347 { 348 AcpiGbl_DrvNotify.Node = DeviceNode; 349 AcpiGbl_DrvNotify.Handler = Handler; 350 AcpiGbl_DrvNotify.Context = Context; 351 } 352 353 354 /* Global notify handler installed */ 355 356 goto UnlockAndExit; 357 } 358 359 360 /* 361 * These are the ONLY objects that can receive ACPI notifications 362 */ 363 364 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 365 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 366 (DeviceNode->Type != ACPI_TYPE_POWER) && 367 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 368 { 369 Status = AE_BAD_PARAMETER; 370 goto UnlockAndExit; 371 } 372 373 /* Check for an existing internal object */ 374 375 ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); 376 if (ObjDesc) 377 { 378 /* 379 * The object exists. 380 * Make sure the handler is not already installed. 381 */ 382 383 if (((HandlerType == ACPI_SYSTEM_NOTIFY) && 384 ObjDesc->Device.SysHandler) || 385 ((HandlerType == ACPI_DEVICE_NOTIFY) && 386 ObjDesc->Device.DrvHandler)) 387 { 388 Status = AE_EXIST; 389 goto UnlockAndExit; 390 } 391 } 392 393 else 394 { 395 /* Create a new object */ 396 397 ObjDesc = AcpiCmCreateInternalObject (DeviceNode->Type); 398 if (!ObjDesc) 399 { 400 Status = AE_NO_MEMORY; 401 goto UnlockAndExit; 402 } 403 404 /* Attach new object to the Node */ 405 406 Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); 407 408 if (ACPI_FAILURE (Status)) 409 { 410 goto UnlockAndExit; 411 } 412 } 413 414 415 /* 416 * If we get here, we know that there is no handler installed 417 * so let's party 418 */ 419 NotifyObj = AcpiCmCreateInternalObject (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 436 else 437 { 438 ObjDesc->Device.DrvHandler = NotifyObj; 439 } 440 441 442UnlockAndExit: 443 AcpiCmReleaseMutex (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 NOTIFY_HANDLER Handler) 468{ 469 ACPI_OPERAND_OBJECT *NotifyObj; 470 ACPI_OPERAND_OBJECT *ObjDesc; 471 ACPI_NAMESPACE_NODE *DeviceNode; 472 ACPI_STATUS Status = AE_OK; 473 474 475 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 AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 487 488 /* Convert and validate the device handle */ 489 490 DeviceNode = AcpiNsConvertHandleToEntry (Device); 491 if (!DeviceNode) 492 { 493 Status = AE_BAD_PARAMETER; 494 goto UnlockAndExit; 495 } 496 497 /* 498 * These are the ONLY objects that can receive ACPI notifications 499 */ 500 501 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 502 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 503 (DeviceNode->Type != ACPI_TYPE_POWER) && 504 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 505 { 506 Status = AE_BAD_PARAMETER; 507 goto UnlockAndExit; 508 } 509 510 /* Check for an existing internal object */ 511 512 ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); 513 if (!ObjDesc) 514 { 515 Status = AE_NOT_EXIST; 516 goto UnlockAndExit; 517 } 518 519 /* 520 * The object exists. 521 * 522 * Make sure the handler is installed. 523 */ 524 525 if (HandlerType == ACPI_SYSTEM_NOTIFY) 526 { 527 NotifyObj = ObjDesc->Device.SysHandler; 528 } 529 else 530 { 531 NotifyObj = ObjDesc->Device.DrvHandler; 532 } 533 534 if ((!NotifyObj) || 535 (NotifyObj->NotifyHandler.Handler != Handler)) 536 { 537 Status = AE_BAD_PARAMETER; 538 goto UnlockAndExit; 539 } 540 541 /* 542 * Now we can remove the handler 543 */ 544 if (HandlerType == ACPI_SYSTEM_NOTIFY) 545 { 546 ObjDesc->Device.SysHandler = NULL; 547 } 548 else 549 { 550 ObjDesc->Device.DrvHandler = NULL; 551 } 552 553 AcpiCmRemoveReference (NotifyObj); 554 555UnlockAndExit: 556 AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 557 return_ACPI_STATUS (Status); 558} 559 560/****************************************************************************** 561 * 562 * FUNCTION: AcpiInstallGpeHandler 563 * 564 * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is 565 * bank 0 first, then bank 1. 566 * Type - Whether this GPE should be treated as an 567 * edge- or level-triggered interrupt. 568 * Handler - Address of the handler 569 * Context - Value passed to the handler on each GPE 570 * 571 * RETURN: Status 572 * 573 * DESCRIPTION: Install a handler for a General Purpose Event. 574 * 575 ******************************************************************************/ 576 577ACPI_STATUS 578AcpiInstallGpeHandler ( 579 UINT32 GpeNumber, 580 UINT32 Type, 581 GPE_HANDLER Handler, 582 void *Context) 583{ 584 ACPI_STATUS Status = AE_OK; 585 586 FUNCTION_TRACE ("AcpiInstallGpeHandler"); 587 588 /* Parameter validation */ 589 590 if (!Handler || (GpeNumber > NUM_GPE)) 591 { 592 return_ACPI_STATUS (AE_BAD_PARAMETER); 593 } 594 595 /* Ensure that we have a valid GPE number */ 596 597 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 598 { 599 return_ACPI_STATUS (AE_BAD_PARAMETER); 600 } 601 602 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 603 604 /* Make sure that there isn't a handler there already */ 605 606 if (AcpiGbl_GpeInfo[GpeNumber].Handler) 607 { 608 Status = AE_EXIST; 609 goto Cleanup; 610 } 611 612 /* Install the handler */ 613 614 AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; 615 AcpiGbl_GpeInfo[GpeNumber].Context = Context; 616 AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; 617 618 /* Clear the GPE (of stale events), the enable it */ 619 620 AcpiHwClearGpe (GpeNumber); 621 AcpiHwEnableGpe (GpeNumber); 622 623Cleanup: 624 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 625 return_ACPI_STATUS (Status); 626} 627 628 629/****************************************************************************** 630 * 631 * FUNCTION: AcpiRemoveGpeHandler 632 * 633 * PARAMETERS: GpeNumber - The event to remove a handler 634 * Handler - Address of the handler 635 * 636 * RETURN: Status 637 * 638 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. 639 * 640 ******************************************************************************/ 641 642ACPI_STATUS 643AcpiRemoveGpeHandler ( 644 UINT32 GpeNumber, 645 GPE_HANDLER Handler) 646{ 647 ACPI_STATUS Status = AE_OK; 648 649 650 FUNCTION_TRACE ("AcpiRemoveGpeHandler"); 651 652 653 /* Parameter validation */ 654 655 if (!Handler || (GpeNumber > NUM_GPE)) 656 { 657 return_ACPI_STATUS (AE_BAD_PARAMETER); 658 } 659 660 /* Ensure that we have a valid GPE number */ 661 662 if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) 663 { 664 return_ACPI_STATUS (AE_BAD_PARAMETER); 665 } 666 667 /* Disable the GPE before removing the handler */ 668 669 AcpiHwDisableGpe (GpeNumber); 670 671 AcpiCmAcquireMutex (ACPI_MTX_EVENTS); 672 673 /* Make sure that the installed handler is the same */ 674 675 if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) 676 { 677 AcpiHwEnableGpe (GpeNumber); 678 Status = AE_BAD_PARAMETER; 679 goto Cleanup; 680 } 681 682 /* Remove the handler */ 683 684 AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; 685 AcpiGbl_GpeInfo[GpeNumber].Context = NULL; 686 687Cleanup: 688 AcpiCmReleaseMutex (ACPI_MTX_EVENTS); 689 return_ACPI_STATUS (Status); 690} 691 692 693/****************************************************************************** 694 * 695 * FUNCTION: AcpiAcquireGlobalLock 696 * 697 * PARAMETERS: Timeout - How long the caller is willing to wait 698 * OutHandle - A handle to the lock if acquired 699 * 700 * RETURN: Status 701 * 702 * DESCRIPTION: Acquire the ACPI Global Lock 703 * 704 ******************************************************************************/ 705ACPI_STATUS 706AcpiAcquireGlobalLock ( 707 void) 708{ 709 ACPI_STATUS Status; 710 711 712 AcpiAmlEnterInterpreter (); 713 714 /* 715 * TBD: [Restructure] add timeout param to internal interface, and 716 * perhaps INTERPRETER_LOCKED 717 */ 718 719 Status = AcpiEvAcquireGlobalLock (); 720 AcpiAmlExitInterpreter (); 721 722 return (Status); 723} 724 725 726/****************************************************************************** 727 * 728 * FUNCTION: AcpiReleaseGlobalLock 729 * 730 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock 731 * 732 * RETURN: Status 733 * 734 * DESCRIPTION: Release the ACPI Global Lock 735 * 736 ******************************************************************************/ 737 738ACPI_STATUS 739AcpiReleaseGlobalLock ( 740 void) 741{ 742 AcpiEvReleaseGlobalLock (); 743 return (AE_OK); 744} 745 746
|