Import acpica-unix-20061109 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / events / evxfevnt.c
blobfd52ccbb0a36323f1c215a86df6641dc7aee69da
1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
4 * $Revision: 1.92 $
6 *****************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
15 * 2. License
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.
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
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;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion 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.
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.
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.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
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.
81 * 4. Disclaimer and Export Compliance
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.
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.
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.
115 *****************************************************************************/
118 #define __EVXFEVNT_C__
120 #include "acpi.h"
121 #include "acevents.h"
122 #include "acnamesp.h"
123 #include "actables.h"
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evxfevnt")
129 /*******************************************************************************
131 * FUNCTION: AcpiEnable
133 * PARAMETERS: None
135 * RETURN: Status
137 * DESCRIPTION: Transfers the system into ACPI mode.
139 ******************************************************************************/
141 ACPI_STATUS
142 AcpiEnable (
143 void)
145 ACPI_STATUS Status = AE_OK;
148 ACPI_FUNCTION_TRACE (AcpiEnable);
151 /* ACPI tables must be present */
153 if (!AcpiTbTablesLoaded ())
155 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
158 /* Check current mode */
160 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
162 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
164 else
166 /* Transition to ACPI mode */
168 Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
169 if (ACPI_FAILURE (Status))
171 ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
172 return_ACPI_STATUS (Status);
175 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
176 "Transition to ACPI mode successful\n"));
179 return_ACPI_STATUS (Status);
182 ACPI_EXPORT_SYMBOL (AcpiEnable)
185 /*******************************************************************************
187 * FUNCTION: AcpiDisable
189 * PARAMETERS: None
191 * RETURN: Status
193 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
195 ******************************************************************************/
197 ACPI_STATUS
198 AcpiDisable (
199 void)
201 ACPI_STATUS Status = AE_OK;
204 ACPI_FUNCTION_TRACE (AcpiDisable);
207 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
209 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
210 "System is already in legacy (non-ACPI) mode\n"));
212 else
214 /* Transition to LEGACY mode */
216 Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
218 if (ACPI_FAILURE (Status))
220 ACPI_ERROR ((AE_INFO,
221 "Could not exit ACPI mode to legacy mode"));
222 return_ACPI_STATUS (Status);
225 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
228 return_ACPI_STATUS (Status);
231 ACPI_EXPORT_SYMBOL (AcpiDisable)
234 /*******************************************************************************
236 * FUNCTION: AcpiEnableEvent
238 * PARAMETERS: Event - The fixed eventto be enabled
239 * Flags - Reserved
241 * RETURN: Status
243 * DESCRIPTION: Enable an ACPI event (fixed)
245 ******************************************************************************/
247 ACPI_STATUS
248 AcpiEnableEvent (
249 UINT32 Event,
250 UINT32 Flags)
252 ACPI_STATUS Status = AE_OK;
253 UINT32 Value;
256 ACPI_FUNCTION_TRACE (AcpiEnableEvent);
259 /* Decode the Fixed Event */
261 if (Event > ACPI_EVENT_MAX)
263 return_ACPI_STATUS (AE_BAD_PARAMETER);
267 * Enable the requested fixed event (by writing a one to the
268 * enable register bit)
270 Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 1);
271 if (ACPI_FAILURE (Status))
273 return_ACPI_STATUS (Status);
276 /* Make sure that the hardware responded */
278 Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
279 &Value);
280 if (ACPI_FAILURE (Status))
282 return_ACPI_STATUS (Status);
285 if (Value != 1)
287 ACPI_ERROR ((AE_INFO,
288 "Could not enable %s event", AcpiUtGetEventName (Event)));
289 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
292 return_ACPI_STATUS (Status);
295 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
298 /*******************************************************************************
300 * FUNCTION: AcpiSetGpeType
302 * PARAMETERS: GpeDevice - Parent GPE Device
303 * GpeNumber - GPE level within the GPE block
304 * Type - New GPE type
306 * RETURN: Status
308 * DESCRIPTION: Set the type of an individual GPE
310 ******************************************************************************/
312 ACPI_STATUS
313 AcpiSetGpeType (
314 ACPI_HANDLE GpeDevice,
315 UINT32 GpeNumber,
316 UINT8 Type)
318 ACPI_STATUS Status = AE_OK;
319 ACPI_GPE_EVENT_INFO *GpeEventInfo;
322 ACPI_FUNCTION_TRACE (AcpiSetGpeType);
325 /* Ensure that we have a valid GPE number */
327 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
328 if (!GpeEventInfo)
330 Status = AE_BAD_PARAMETER;
331 goto UnlockAndExit;
334 if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type)
336 return_ACPI_STATUS (AE_OK);
339 /* Set the new type (will disable GPE if currently enabled) */
341 Status = AcpiEvSetGpeType (GpeEventInfo, Type);
343 UnlockAndExit:
344 return_ACPI_STATUS (Status);
347 ACPI_EXPORT_SYMBOL (AcpiSetGpeType)
350 /*******************************************************************************
352 * FUNCTION: AcpiEnableGpe
354 * PARAMETERS: GpeDevice - Parent GPE Device
355 * GpeNumber - GPE level within the GPE block
356 * Flags - Just enable, or also wake enable?
357 * Called from ISR or not
359 * RETURN: Status
361 * DESCRIPTION: Enable an ACPI event (general purpose)
363 ******************************************************************************/
365 ACPI_STATUS
366 AcpiEnableGpe (
367 ACPI_HANDLE GpeDevice,
368 UINT32 GpeNumber,
369 UINT32 Flags)
371 ACPI_STATUS Status = AE_OK;
372 ACPI_GPE_EVENT_INFO *GpeEventInfo;
375 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
378 /* Use semaphore lock if not executing at interrupt level */
380 if (Flags & ACPI_NOT_ISR)
382 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
383 if (ACPI_FAILURE (Status))
385 return_ACPI_STATUS (Status);
389 /* Ensure that we have a valid GPE number */
391 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
392 if (!GpeEventInfo)
394 Status = AE_BAD_PARAMETER;
395 goto UnlockAndExit;
398 /* Perform the enable */
400 Status = AcpiEvEnableGpe (GpeEventInfo, TRUE);
402 UnlockAndExit:
403 if (Flags & ACPI_NOT_ISR)
405 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
407 return_ACPI_STATUS (Status);
410 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
413 /*******************************************************************************
415 * FUNCTION: AcpiDisableGpe
417 * PARAMETERS: GpeDevice - Parent GPE Device
418 * GpeNumber - GPE level within the GPE block
419 * Flags - Just disable, or also wake disable?
420 * Called from ISR or not
422 * RETURN: Status
424 * DESCRIPTION: Disable an ACPI event (general purpose)
426 ******************************************************************************/
428 ACPI_STATUS
429 AcpiDisableGpe (
430 ACPI_HANDLE GpeDevice,
431 UINT32 GpeNumber,
432 UINT32 Flags)
434 ACPI_STATUS Status = AE_OK;
435 ACPI_GPE_EVENT_INFO *GpeEventInfo;
438 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
441 /* Use semaphore lock if not executing at interrupt level */
443 if (Flags & ACPI_NOT_ISR)
445 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
446 if (ACPI_FAILURE (Status))
448 return_ACPI_STATUS (Status);
452 /* Ensure that we have a valid GPE number */
454 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
455 if (!GpeEventInfo)
457 Status = AE_BAD_PARAMETER;
458 goto UnlockAndExit;
461 Status = AcpiEvDisableGpe (GpeEventInfo);
463 UnlockAndExit:
464 if (Flags & ACPI_NOT_ISR)
466 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
468 return_ACPI_STATUS (Status);
471 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
474 /*******************************************************************************
476 * FUNCTION: AcpiDisableEvent
478 * PARAMETERS: Event - The fixed eventto be enabled
479 * Flags - Reserved
481 * RETURN: Status
483 * DESCRIPTION: Disable an ACPI event (fixed)
485 ******************************************************************************/
487 ACPI_STATUS
488 AcpiDisableEvent (
489 UINT32 Event,
490 UINT32 Flags)
492 ACPI_STATUS Status = AE_OK;
493 UINT32 Value;
496 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
499 /* Decode the Fixed Event */
501 if (Event > ACPI_EVENT_MAX)
503 return_ACPI_STATUS (AE_BAD_PARAMETER);
507 * Disable the requested fixed event (by writing a zero to the
508 * enable register bit)
510 Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0);
511 if (ACPI_FAILURE (Status))
513 return_ACPI_STATUS (Status);
516 Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
517 &Value);
518 if (ACPI_FAILURE (Status))
520 return_ACPI_STATUS (Status);
523 if (Value != 0)
525 ACPI_ERROR ((AE_INFO,
526 "Could not disable %s events", AcpiUtGetEventName (Event)));
527 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
530 return_ACPI_STATUS (Status);
533 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
536 /*******************************************************************************
538 * FUNCTION: AcpiClearEvent
540 * PARAMETERS: Event - The fixed event to be cleared
542 * RETURN: Status
544 * DESCRIPTION: Clear an ACPI event (fixed)
546 ******************************************************************************/
548 ACPI_STATUS
549 AcpiClearEvent (
550 UINT32 Event)
552 ACPI_STATUS Status = AE_OK;
555 ACPI_FUNCTION_TRACE (AcpiClearEvent);
558 /* Decode the Fixed Event */
560 if (Event > ACPI_EVENT_MAX)
562 return_ACPI_STATUS (AE_BAD_PARAMETER);
566 * Clear the requested fixed event (By writing a one to the
567 * status register bit)
569 Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1);
571 return_ACPI_STATUS (Status);
574 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
577 /*******************************************************************************
579 * FUNCTION: AcpiClearGpe
581 * PARAMETERS: GpeDevice - Parent GPE Device
582 * GpeNumber - GPE level within the GPE block
583 * Flags - Called from an ISR or not
585 * RETURN: Status
587 * DESCRIPTION: Clear an ACPI event (general purpose)
589 ******************************************************************************/
591 ACPI_STATUS
592 AcpiClearGpe (
593 ACPI_HANDLE GpeDevice,
594 UINT32 GpeNumber,
595 UINT32 Flags)
597 ACPI_STATUS Status = AE_OK;
598 ACPI_GPE_EVENT_INFO *GpeEventInfo;
601 ACPI_FUNCTION_TRACE (AcpiClearGpe);
604 /* Use semaphore lock if not executing at interrupt level */
606 if (Flags & ACPI_NOT_ISR)
608 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
609 if (ACPI_FAILURE (Status))
611 return_ACPI_STATUS (Status);
615 /* Ensure that we have a valid GPE number */
617 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
618 if (!GpeEventInfo)
620 Status = AE_BAD_PARAMETER;
621 goto UnlockAndExit;
624 Status = AcpiHwClearGpe (GpeEventInfo);
626 UnlockAndExit:
627 if (Flags & ACPI_NOT_ISR)
629 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
631 return_ACPI_STATUS (Status);
634 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
637 /*******************************************************************************
639 * FUNCTION: AcpiGetEventStatus
641 * PARAMETERS: Event - The fixed event
642 * EventStatus - Where the current status of the event will
643 * be returned
645 * RETURN: Status
647 * DESCRIPTION: Obtains and returns the current status of the event
649 ******************************************************************************/
651 ACPI_STATUS
652 AcpiGetEventStatus (
653 UINT32 Event,
654 ACPI_EVENT_STATUS *EventStatus)
656 ACPI_STATUS Status = AE_OK;
659 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
662 if (!EventStatus)
664 return_ACPI_STATUS (AE_BAD_PARAMETER);
667 /* Decode the Fixed Event */
669 if (Event > ACPI_EVENT_MAX)
671 return_ACPI_STATUS (AE_BAD_PARAMETER);
674 /* Get the status of the requested fixed event */
676 Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
677 EventStatus);
679 return_ACPI_STATUS (Status);
682 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
685 /*******************************************************************************
687 * FUNCTION: AcpiGetGpeStatus
689 * PARAMETERS: GpeDevice - Parent GPE Device
690 * GpeNumber - GPE level within the GPE block
691 * Flags - Called from an ISR or not
692 * EventStatus - Where the current status of the event will
693 * be returned
695 * RETURN: Status
697 * DESCRIPTION: Get status of an event (general purpose)
699 ******************************************************************************/
701 ACPI_STATUS
702 AcpiGetGpeStatus (
703 ACPI_HANDLE GpeDevice,
704 UINT32 GpeNumber,
705 UINT32 Flags,
706 ACPI_EVENT_STATUS *EventStatus)
708 ACPI_STATUS Status = AE_OK;
709 ACPI_GPE_EVENT_INFO *GpeEventInfo;
712 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
715 /* Use semaphore lock if not executing at interrupt level */
717 if (Flags & ACPI_NOT_ISR)
719 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
720 if (ACPI_FAILURE (Status))
722 return_ACPI_STATUS (Status);
726 /* Ensure that we have a valid GPE number */
728 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
729 if (!GpeEventInfo)
731 Status = AE_BAD_PARAMETER;
732 goto UnlockAndExit;
735 /* Obtain status on the requested GPE number */
737 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
739 UnlockAndExit:
740 if (Flags & ACPI_NOT_ISR)
742 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
744 return_ACPI_STATUS (Status);
747 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
750 /*******************************************************************************
752 * FUNCTION: AcpiInstallGpeBlock
754 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
755 * GpeBlockAddress - Address and SpaceID
756 * RegisterCount - Number of GPE register pairs in the block
757 * InterruptNumber - H/W interrupt for the block
759 * RETURN: Status
761 * DESCRIPTION: Create and Install a block of GPE registers
763 ******************************************************************************/
765 ACPI_STATUS
766 AcpiInstallGpeBlock (
767 ACPI_HANDLE GpeDevice,
768 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
769 UINT32 RegisterCount,
770 UINT32 InterruptNumber)
772 ACPI_STATUS Status;
773 ACPI_OPERAND_OBJECT *ObjDesc;
774 ACPI_NAMESPACE_NODE *Node;
775 ACPI_GPE_BLOCK_INFO *GpeBlock;
778 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
781 if ((!GpeDevice) ||
782 (!GpeBlockAddress) ||
783 (!RegisterCount))
785 return_ACPI_STATUS (AE_BAD_PARAMETER);
788 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
789 if (ACPI_FAILURE (Status))
791 return (Status);
794 Node = AcpiNsMapHandleToNode (GpeDevice);
795 if (!Node)
797 Status = AE_BAD_PARAMETER;
798 goto UnlockAndExit;
802 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
803 * is always zero
805 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
806 0, InterruptNumber, &GpeBlock);
807 if (ACPI_FAILURE (Status))
809 goto UnlockAndExit;
812 /* Run the _PRW methods and enable the GPEs */
814 Status = AcpiEvInitializeGpeBlock (Node, GpeBlock);
815 if (ACPI_FAILURE (Status))
817 goto UnlockAndExit;
820 /* Get the DeviceObject attached to the node */
822 ObjDesc = AcpiNsGetAttachedObject (Node);
823 if (!ObjDesc)
825 /* No object, create a new one */
827 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
828 if (!ObjDesc)
830 Status = AE_NO_MEMORY;
831 goto UnlockAndExit;
834 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
836 /* Remove local reference to the object */
838 AcpiUtRemoveReference (ObjDesc);
840 if (ACPI_FAILURE (Status))
842 goto UnlockAndExit;
846 /* Install the GPE block in the DeviceObject */
848 ObjDesc->Device.GpeBlock = GpeBlock;
851 UnlockAndExit:
852 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
853 return_ACPI_STATUS (Status);
856 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
859 /*******************************************************************************
861 * FUNCTION: AcpiRemoveGpeBlock
863 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
865 * RETURN: Status
867 * DESCRIPTION: Remove a previously installed block of GPE registers
869 ******************************************************************************/
871 ACPI_STATUS
872 AcpiRemoveGpeBlock (
873 ACPI_HANDLE GpeDevice)
875 ACPI_OPERAND_OBJECT *ObjDesc;
876 ACPI_STATUS Status;
877 ACPI_NAMESPACE_NODE *Node;
880 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
883 if (!GpeDevice)
885 return_ACPI_STATUS (AE_BAD_PARAMETER);
888 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
889 if (ACPI_FAILURE (Status))
891 return (Status);
894 Node = AcpiNsMapHandleToNode (GpeDevice);
895 if (!Node)
897 Status = AE_BAD_PARAMETER;
898 goto UnlockAndExit;
901 /* Get the DeviceObject attached to the node */
903 ObjDesc = AcpiNsGetAttachedObject (Node);
904 if (!ObjDesc ||
905 !ObjDesc->Device.GpeBlock)
907 return_ACPI_STATUS (AE_NULL_OBJECT);
910 /* Delete the GPE block (but not the DeviceObject) */
912 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
913 if (ACPI_SUCCESS (Status))
915 ObjDesc->Device.GpeBlock = NULL;
918 UnlockAndExit:
919 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
920 return_ACPI_STATUS (Status);
923 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)