1 /******************************************************************************
3 * Module Name: evregion - Operation Region support
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
117 #define __EVREGION_C__
120 #include "accommon.h"
121 #include "acevents.h"
122 #include "acnamesp.h"
123 #include "acinterp.h"
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evregion")
129 extern UINT8 AcpiGbl_DefaultAddressSpaces
[];
131 /* Local prototypes */
134 AcpiEvOrphanEcRegMethod (
135 ACPI_NAMESPACE_NODE
*EcDeviceNode
);
139 ACPI_HANDLE ObjHandle
,
145 /*******************************************************************************
147 * FUNCTION: AcpiEvInitializeOpRegions
153 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
154 * an installed default region handler.
156 ******************************************************************************/
159 AcpiEvInitializeOpRegions (
166 ACPI_FUNCTION_TRACE (EvInitializeOpRegions
);
169 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
170 if (ACPI_FAILURE (Status
))
172 return_ACPI_STATUS (Status
);
175 /* Run the _REG methods for OpRegions in each default address space */
177 for (i
= 0; i
< ACPI_NUM_DEFAULT_SPACES
; i
++)
180 * Make sure the installed handler is the DEFAULT handler. If not the
181 * default, the _REG methods will have already been run (when the
182 * handler was installed)
184 if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode
,
185 AcpiGbl_DefaultAddressSpaces
[i
]))
187 Status
= AcpiEvExecuteRegMethods (AcpiGbl_RootNode
,
188 AcpiGbl_DefaultAddressSpaces
[i
]);
192 AcpiGbl_RegMethodsExecuted
= TRUE
;
194 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
195 return_ACPI_STATUS (Status
);
199 /*******************************************************************************
201 * FUNCTION: AcpiEvAddressSpaceDispatch
203 * PARAMETERS: RegionObj - Internal region object
204 * FieldObj - Corresponding field. Can be NULL.
205 * Function - Read or Write operation
206 * RegionOffset - Where in the region to read or write
207 * BitWidth - Field width in bits (8, 16, 32, or 64)
208 * Value - Pointer to in or out value, must be
209 * a full 64-bit integer
213 * DESCRIPTION: Dispatch an address space or operation region access to
214 * a previously installed handler.
216 ******************************************************************************/
219 AcpiEvAddressSpaceDispatch (
220 ACPI_OPERAND_OBJECT
*RegionObj
,
221 ACPI_OPERAND_OBJECT
*FieldObj
,
228 ACPI_ADR_SPACE_HANDLER Handler
;
229 ACPI_ADR_SPACE_SETUP RegionSetup
;
230 ACPI_OPERAND_OBJECT
*HandlerDesc
;
231 ACPI_OPERAND_OBJECT
*RegionObj2
;
232 void *RegionContext
= NULL
;
233 ACPI_CONNECTION_INFO
*Context
;
236 ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch
);
239 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
242 return_ACPI_STATUS (AE_NOT_EXIST
);
245 /* Ensure that there is a handler associated with this region */
247 HandlerDesc
= RegionObj
->Region
.Handler
;
250 ACPI_ERROR ((AE_INFO
,
251 "No handler for Region [%4.4s] (%p) [%s]",
252 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
253 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
255 return_ACPI_STATUS (AE_NOT_EXIST
);
258 Context
= HandlerDesc
->AddressSpace
.Context
;
261 * It may be the case that the region has never been initialized.
262 * Some types of regions require special init code
264 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
266 /* This region has not been initialized yet, do it */
268 RegionSetup
= HandlerDesc
->AddressSpace
.Setup
;
271 /* No initialization routine, exit with error */
273 ACPI_ERROR ((AE_INFO
,
274 "No init routine for region(%p) [%s]",
275 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
276 return_ACPI_STATUS (AE_NOT_EXIST
);
280 * We must exit the interpreter because the region setup will
281 * potentially execute control methods (for example, the _REG method
284 AcpiExExitInterpreter ();
286 Status
= RegionSetup (RegionObj
, ACPI_REGION_ACTIVATE
,
287 Context
, &RegionContext
);
289 /* Re-enter the interpreter */
291 AcpiExEnterInterpreter ();
293 /* Check for failure of the Region Setup */
295 if (ACPI_FAILURE (Status
))
297 ACPI_EXCEPTION ((AE_INFO
, Status
,
298 "During region initialization: [%s]",
299 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
300 return_ACPI_STATUS (Status
);
303 /* Region initialization may have been completed by RegionSetup */
305 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
307 RegionObj
->Region
.Flags
|= AOPOBJ_SETUP_COMPLETE
;
310 * Save the returned context for use in all accesses to
311 * the handler for this particular region
313 if (!(RegionObj2
->Extra
.RegionContext
))
315 RegionObj2
->Extra
.RegionContext
= RegionContext
;
320 /* We have everything we need, we can invoke the address space handler */
322 Handler
= HandlerDesc
->AddressSpace
.Handler
;
324 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
325 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
326 &RegionObj
->Region
.Handler
->AddressSpace
, Handler
,
327 ACPI_FORMAT_NATIVE_UINT (RegionObj
->Region
.Address
+ RegionOffset
),
328 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
331 * Special handling for GenericSerialBus and GeneralPurposeIo:
332 * There are three extra parameters that must be passed to the
333 * handler via the context:
334 * 1) Connection buffer, a resource template from Connection() op.
335 * 2) Length of the above buffer.
336 * 3) Actual access length from the AccessAs() op.
338 if (((RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GSBUS
) ||
339 (RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GPIO
)) &&
343 /* Get the Connection (ResourceTemplate) buffer */
345 Context
->Connection
= FieldObj
->Field
.ResourceBuffer
;
346 Context
->Length
= FieldObj
->Field
.ResourceLength
;
347 Context
->AccessLength
= FieldObj
->Field
.AccessLength
;
350 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
351 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
354 * For handlers other than the default (supplied) handlers, we must
355 * exit the interpreter because the handler *might* block -- we don't
356 * know what it will do, so we can't hold the lock on the intepreter.
358 AcpiExExitInterpreter();
361 /* Call the handler */
363 Status
= Handler (Function
,
364 (RegionObj
->Region
.Address
+ RegionOffset
), BitWidth
, Value
,
365 Context
, RegionObj2
->Extra
.RegionContext
);
367 if (ACPI_FAILURE (Status
))
369 ACPI_EXCEPTION ((AE_INFO
, Status
, "Returned by Handler for [%s]",
370 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
373 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
374 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
377 * We just returned from a non-default handler, we must re-enter the
380 AcpiExEnterInterpreter ();
383 return_ACPI_STATUS (Status
);
387 /*******************************************************************************
389 * FUNCTION: AcpiEvDetachRegion
391 * PARAMETERS: RegionObj - Region Object
392 * AcpiNsIsLocked - Namespace Region Already Locked?
396 * DESCRIPTION: Break the association between the handler and the region
397 * this is a two way association.
399 ******************************************************************************/
403 ACPI_OPERAND_OBJECT
*RegionObj
,
404 BOOLEAN AcpiNsIsLocked
)
406 ACPI_OPERAND_OBJECT
*HandlerObj
;
407 ACPI_OPERAND_OBJECT
*ObjDesc
;
408 ACPI_OPERAND_OBJECT
*StartDesc
;
409 ACPI_OPERAND_OBJECT
**LastObjPtr
;
410 ACPI_ADR_SPACE_SETUP RegionSetup
;
411 void **RegionContext
;
412 ACPI_OPERAND_OBJECT
*RegionObj2
;
416 ACPI_FUNCTION_TRACE (EvDetachRegion
);
419 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
424 RegionContext
= &RegionObj2
->Extra
.RegionContext
;
426 /* Get the address handler from the region object */
428 HandlerObj
= RegionObj
->Region
.Handler
;
431 /* This region has no handler, all done */
436 /* Find this region in the handler's list */
438 ObjDesc
= HandlerObj
->AddressSpace
.RegionList
;
440 LastObjPtr
= &HandlerObj
->AddressSpace
.RegionList
;
444 /* Is this the correct Region? */
446 if (ObjDesc
== RegionObj
)
448 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
449 "Removing Region %p from address handler %p\n",
450 RegionObj
, HandlerObj
));
452 /* This is it, remove it from the handler's list */
454 *LastObjPtr
= ObjDesc
->Region
.Next
;
455 ObjDesc
->Region
.Next
= NULL
; /* Must clear field */
459 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
460 if (ACPI_FAILURE (Status
))
466 /* Now stop region accesses by executing the _REG method */
468 Status
= AcpiEvExecuteRegMethod (RegionObj
, ACPI_REG_DISCONNECT
);
469 if (ACPI_FAILURE (Status
))
471 ACPI_EXCEPTION ((AE_INFO
, Status
, "from region _REG, [%s]",
472 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
477 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
478 if (ACPI_FAILURE (Status
))
485 * If the region has been activated, call the setup handler with
486 * the deactivate notification
488 if (RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
)
490 RegionSetup
= HandlerObj
->AddressSpace
.Setup
;
491 Status
= RegionSetup (RegionObj
, ACPI_REGION_DEACTIVATE
,
492 HandlerObj
->AddressSpace
.Context
, RegionContext
);
495 * RegionContext should have been released by the deactivate
496 * operation. We don't need access to it anymore here.
500 *RegionContext
= NULL
;
503 /* Init routine may fail, Just ignore errors */
505 if (ACPI_FAILURE (Status
))
507 ACPI_EXCEPTION ((AE_INFO
, Status
,
508 "from region handler - deactivate, [%s]",
509 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
512 RegionObj
->Region
.Flags
&= ~(AOPOBJ_SETUP_COMPLETE
);
516 * Remove handler reference in the region
518 * NOTE: this doesn't mean that the region goes away, the region
519 * is just inaccessible as indicated to the _REG method
521 * If the region is on the handler's list, this must be the
524 RegionObj
->Region
.Handler
= NULL
;
525 AcpiUtRemoveReference (HandlerObj
);
530 /* Walk the linked list of handlers */
532 LastObjPtr
= &ObjDesc
->Region
.Next
;
533 ObjDesc
= ObjDesc
->Region
.Next
;
535 /* Prevent infinite loop if list is corrupted */
537 if (ObjDesc
== StartDesc
)
539 ACPI_ERROR ((AE_INFO
,
540 "Circular handler list in region object %p",
546 /* If we get here, the region was not in the handler's region list */
548 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
549 "Cannot remove region %p from address handler %p\n",
550 RegionObj
, HandlerObj
));
556 /*******************************************************************************
558 * FUNCTION: AcpiEvAttachRegion
560 * PARAMETERS: HandlerObj - Handler Object
561 * RegionObj - Region Object
562 * AcpiNsIsLocked - Namespace Region Already Locked?
566 * DESCRIPTION: Create the association between the handler and the region
567 * this is a two way association.
569 ******************************************************************************/
573 ACPI_OPERAND_OBJECT
*HandlerObj
,
574 ACPI_OPERAND_OBJECT
*RegionObj
,
575 BOOLEAN AcpiNsIsLocked
)
578 ACPI_FUNCTION_TRACE (EvAttachRegion
);
581 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
582 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
583 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
584 RegionObj
, HandlerObj
,
585 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
587 /* Link this region to the front of the handler's list */
589 RegionObj
->Region
.Next
= HandlerObj
->AddressSpace
.RegionList
;
590 HandlerObj
->AddressSpace
.RegionList
= RegionObj
;
592 /* Install the region's handler */
594 if (RegionObj
->Region
.Handler
)
596 return_ACPI_STATUS (AE_ALREADY_EXISTS
);
599 RegionObj
->Region
.Handler
= HandlerObj
;
600 AcpiUtAddReference (HandlerObj
);
602 return_ACPI_STATUS (AE_OK
);
606 /*******************************************************************************
608 * FUNCTION: AcpiEvExecuteRegMethod
610 * PARAMETERS: RegionObj - Region object
611 * Function - Passed to _REG: On (1) or Off (0)
615 * DESCRIPTION: Execute _REG method for a region
617 ******************************************************************************/
620 AcpiEvExecuteRegMethod (
621 ACPI_OPERAND_OBJECT
*RegionObj
,
624 ACPI_EVALUATE_INFO
*Info
;
625 ACPI_OPERAND_OBJECT
*Args
[3];
626 ACPI_OPERAND_OBJECT
*RegionObj2
;
630 ACPI_FUNCTION_TRACE (EvExecuteRegMethod
);
633 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
636 return_ACPI_STATUS (AE_NOT_EXIST
);
639 if (RegionObj2
->Extra
.Method_REG
== NULL
)
641 return_ACPI_STATUS (AE_OK
);
644 /* Allocate and initialize the evaluation information block */
646 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
649 return_ACPI_STATUS (AE_NO_MEMORY
);
652 Info
->PrefixNode
= RegionObj2
->Extra
.Method_REG
;
653 Info
->RelativePathname
= NULL
;
654 Info
->Parameters
= Args
;
655 Info
->Flags
= ACPI_IGNORE_RETURN_VALUE
;
658 * The _REG method has two arguments:
661 * Operation region space ID Same value as RegionObj->Region.SpaceId
664 * connection status 1 for connecting the handler, 0 for disconnecting
665 * the handler (Passed as a parameter)
667 Args
[0] = AcpiUtCreateIntegerObject ((UINT64
) RegionObj
->Region
.SpaceId
);
670 Status
= AE_NO_MEMORY
;
674 Args
[1] = AcpiUtCreateIntegerObject ((UINT64
) Function
);
677 Status
= AE_NO_MEMORY
;
681 Args
[2] = NULL
; /* Terminate list */
683 /* Execute the method, no return value */
686 AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD
, Info
->PrefixNode
, NULL
));
688 Status
= AcpiNsEvaluate (Info
);
689 AcpiUtRemoveReference (Args
[1]);
692 AcpiUtRemoveReference (Args
[0]);
696 return_ACPI_STATUS (Status
);
700 /*******************************************************************************
702 * FUNCTION: AcpiEvExecuteRegMethods
704 * PARAMETERS: Node - Namespace node for the device
705 * SpaceId - The address space ID
709 * DESCRIPTION: Run all _REG methods for the input Space ID;
710 * Note: assumes namespace is locked, or system init time.
712 ******************************************************************************/
715 AcpiEvExecuteRegMethods (
716 ACPI_NAMESPACE_NODE
*Node
,
717 ACPI_ADR_SPACE_TYPE SpaceId
)
722 ACPI_FUNCTION_TRACE (EvExecuteRegMethods
);
726 * Run all _REG methods for all Operation Regions for this space ID. This
727 * is a separate walk in order to handle any interdependencies between
728 * regions and _REG methods. (i.e. handlers must be installed for all
729 * regions of this Space ID before we can run any _REG methods)
731 Status
= AcpiNsWalkNamespace (ACPI_TYPE_ANY
, Node
, ACPI_UINT32_MAX
,
732 ACPI_NS_WALK_UNLOCK
, AcpiEvRegRun
, NULL
,
735 /* Special case for EC: handle "orphan" _REG methods with no region */
737 if (SpaceId
== ACPI_ADR_SPACE_EC
)
739 AcpiEvOrphanEcRegMethod (Node
);
742 return_ACPI_STATUS (Status
);
746 /*******************************************************************************
748 * FUNCTION: AcpiEvRegRun
750 * PARAMETERS: WalkNamespace callback
752 * DESCRIPTION: Run _REG method for region objects of the requested spaceID
754 ******************************************************************************/
758 ACPI_HANDLE ObjHandle
,
763 ACPI_OPERAND_OBJECT
*ObjDesc
;
764 ACPI_NAMESPACE_NODE
*Node
;
765 ACPI_ADR_SPACE_TYPE SpaceId
;
769 SpaceId
= *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE
, Context
);
771 /* Convert and validate the device handle */
773 Node
= AcpiNsValidateHandle (ObjHandle
);
776 return (AE_BAD_PARAMETER
);
780 * We only care about regions.and objects that are allowed to have address
783 if ((Node
->Type
!= ACPI_TYPE_REGION
) &&
784 (Node
!= AcpiGbl_RootNode
))
789 /* Check for an existing internal object */
791 ObjDesc
= AcpiNsGetAttachedObject (Node
);
794 /* No object, just exit */
799 /* Object is a Region */
801 if (ObjDesc
->Region
.SpaceId
!= SpaceId
)
803 /* This region is for a different address space, just ignore it */
808 Status
= AcpiEvExecuteRegMethod (ObjDesc
, ACPI_REG_CONNECT
);
813 /*******************************************************************************
815 * FUNCTION: AcpiEvOrphanEcRegMethod
817 * PARAMETERS: EcDeviceNode - Namespace node for an EC device
821 * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
822 * device. This is a _REG method that has no corresponding region
823 * within the EC device scope. The orphan _REG method appears to
824 * have been enabled by the description of the ECDT in the ACPI
825 * specification: "The availability of the region space can be
826 * detected by providing a _REG method object underneath the
827 * Embedded Controller device."
829 * To quickly access the EC device, we use the EcDeviceNode used
830 * during EC handler installation. Otherwise, we would need to
831 * perform a time consuming namespace walk, executing _HID
832 * methods to find the EC device.
834 * MUTEX: Assumes the namespace is locked
836 ******************************************************************************/
839 AcpiEvOrphanEcRegMethod (
840 ACPI_NAMESPACE_NODE
*EcDeviceNode
)
842 ACPI_HANDLE RegMethod
;
843 ACPI_NAMESPACE_NODE
*NextNode
;
845 ACPI_OBJECT_LIST Args
;
846 ACPI_OBJECT Objects
[2];
849 ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod
);
857 /* Namespace is currently locked, must release */
859 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
861 /* Get a handle to a _REG method immediately under the EC device */
863 Status
= AcpiGetHandle (EcDeviceNode
, METHOD_NAME__REG
, &RegMethod
);
864 if (ACPI_FAILURE (Status
))
866 goto Exit
; /* There is no _REG method present */
870 * Execute the _REG method only if there is no Operation Region in
871 * this scope with the Embedded Controller space ID. Otherwise, it
872 * will already have been executed. Note, this allows for Regions
873 * with other space IDs to be present; but the code below will then
874 * execute the _REG method with the EmbeddedControl SpaceID argument.
876 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NULL
);
879 if ((NextNode
->Type
== ACPI_TYPE_REGION
) &&
880 (NextNode
->Object
) &&
881 (NextNode
->Object
->Region
.SpaceId
== ACPI_ADR_SPACE_EC
))
883 goto Exit
; /* Do not execute the _REG */
886 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NextNode
);
889 /* Evaluate the _REG(EmbeddedControl,Connect) method */
892 Args
.Pointer
= Objects
;
893 Objects
[0].Type
= ACPI_TYPE_INTEGER
;
894 Objects
[0].Integer
.Value
= ACPI_ADR_SPACE_EC
;
895 Objects
[1].Type
= ACPI_TYPE_INTEGER
;
896 Objects
[1].Integer
.Value
= ACPI_REG_CONNECT
;
898 Status
= AcpiEvaluateObject (RegMethod
, NULL
, &Args
, NULL
);
901 /* We ignore all errors from above, don't care */
903 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);