1 /******************************************************************************
3 * Module Name: evregion - Operation Region support
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evregion")
54 extern UINT8 AcpiGbl_DefaultAddressSpaces
[];
56 /* Local prototypes */
59 AcpiEvOrphanEcRegMethod (
60 ACPI_NAMESPACE_NODE
*EcDeviceNode
);
64 ACPI_HANDLE ObjHandle
,
70 /*******************************************************************************
72 * FUNCTION: AcpiEvInitializeOpRegions
78 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
79 * an installed default region handler.
81 ******************************************************************************/
84 AcpiEvInitializeOpRegions (
91 ACPI_FUNCTION_TRACE (EvInitializeOpRegions
);
94 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
95 if (ACPI_FAILURE (Status
))
97 return_ACPI_STATUS (Status
);
100 /* Run the _REG methods for OpRegions in each default address space */
102 AcpiGbl_RegMethodsEnabled
= TRUE
;
103 for (i
= 0; i
< ACPI_NUM_DEFAULT_SPACES
; i
++)
106 * Make sure the installed handler is the DEFAULT handler. If not the
107 * default, the _REG methods will have already been run (when the
108 * handler was installed)
110 if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode
,
111 AcpiGbl_DefaultAddressSpaces
[i
]))
113 AcpiEvExecuteRegMethods (AcpiGbl_RootNode
,
114 AcpiGbl_DefaultAddressSpaces
[i
], ACPI_REG_CONNECT
);
118 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
119 return_ACPI_STATUS (Status
);
123 /*******************************************************************************
125 * FUNCTION: AcpiEvAddressSpaceDispatch
127 * PARAMETERS: RegionObj - Internal region object
128 * FieldObj - Corresponding field. Can be NULL.
129 * Function - Read or Write operation
130 * RegionOffset - Where in the region to read or write
131 * BitWidth - Field width in bits (8, 16, 32, or 64)
132 * Value - Pointer to in or out value, must be
133 * a full 64-bit integer
137 * DESCRIPTION: Dispatch an address space or operation region access to
138 * a previously installed handler.
140 * NOTE: During early initialization, we always install the default region
141 * handlers for Memory, I/O and PCI_Config. This ensures that these operation
142 * region address spaces are always available as per the ACPI specification.
143 * This is especially needed in order to support the execution of
144 * module-level AML code during loading of the ACPI tables.
146 ******************************************************************************/
149 AcpiEvAddressSpaceDispatch (
150 ACPI_OPERAND_OBJECT
*RegionObj
,
151 ACPI_OPERAND_OBJECT
*FieldObj
,
158 ACPI_ADR_SPACE_HANDLER Handler
;
159 ACPI_ADR_SPACE_SETUP RegionSetup
;
160 ACPI_OPERAND_OBJECT
*HandlerDesc
;
161 ACPI_OPERAND_OBJECT
*RegionObj2
;
162 void *RegionContext
= NULL
;
163 ACPI_CONNECTION_INFO
*Context
;
164 ACPI_PHYSICAL_ADDRESS Address
;
167 ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch
);
170 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
173 return_ACPI_STATUS (AE_NOT_EXIST
);
176 /* Ensure that there is a handler associated with this region */
178 HandlerDesc
= RegionObj
->Region
.Handler
;
181 ACPI_ERROR ((AE_INFO
,
182 "No handler for Region [%4.4s] (%p) [%s]",
183 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
184 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
186 return_ACPI_STATUS (AE_NOT_EXIST
);
189 Context
= HandlerDesc
->AddressSpace
.Context
;
192 * It may be the case that the region has never been initialized.
193 * Some types of regions require special init code
195 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
197 /* This region has not been initialized yet, do it */
199 RegionSetup
= HandlerDesc
->AddressSpace
.Setup
;
202 /* No initialization routine, exit with error */
204 ACPI_ERROR ((AE_INFO
,
205 "No init routine for region(%p) [%s]",
206 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
207 return_ACPI_STATUS (AE_NOT_EXIST
);
211 * We must exit the interpreter because the region setup will
212 * potentially execute control methods (for example, the _REG method
215 AcpiExExitInterpreter ();
217 Status
= RegionSetup (RegionObj
, ACPI_REGION_ACTIVATE
,
218 Context
, &RegionContext
);
220 /* Re-enter the interpreter */
222 AcpiExEnterInterpreter ();
224 /* Check for failure of the Region Setup */
226 if (ACPI_FAILURE (Status
))
228 ACPI_EXCEPTION ((AE_INFO
, Status
,
229 "During region initialization: [%s]",
230 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
231 return_ACPI_STATUS (Status
);
234 /* Region initialization may have been completed by RegionSetup */
236 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
238 RegionObj
->Region
.Flags
|= AOPOBJ_SETUP_COMPLETE
;
241 * Save the returned context for use in all accesses to
242 * the handler for this particular region
244 if (!(RegionObj2
->Extra
.RegionContext
))
246 RegionObj2
->Extra
.RegionContext
= RegionContext
;
251 /* We have everything we need, we can invoke the address space handler */
253 Handler
= HandlerDesc
->AddressSpace
.Handler
;
254 Address
= (RegionObj
->Region
.Address
+ RegionOffset
);
257 * Special handling for GenericSerialBus and GeneralPurposeIo:
258 * There are three extra parameters that must be passed to the
259 * handler via the context:
260 * 1) Connection buffer, a resource template from Connection() op
261 * 2) Length of the above buffer
262 * 3) Actual access length from the AccessAs() op
264 * In addition, for GeneralPurposeIo, the Address and BitWidth fields
265 * are defined as follows:
266 * 1) Address is the pin number index of the field (bit offset from
267 * the previous Connection)
268 * 2) BitWidth is the actual bit length of the field (number of pins)
270 if ((RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GSBUS
) &&
274 /* Get the Connection (ResourceTemplate) buffer */
276 Context
->Connection
= FieldObj
->Field
.ResourceBuffer
;
277 Context
->Length
= FieldObj
->Field
.ResourceLength
;
278 Context
->AccessLength
= FieldObj
->Field
.AccessLength
;
280 if ((RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GPIO
) &&
284 /* Get the Connection (ResourceTemplate) buffer */
286 Context
->Connection
= FieldObj
->Field
.ResourceBuffer
;
287 Context
->Length
= FieldObj
->Field
.ResourceLength
;
288 Context
->AccessLength
= FieldObj
->Field
.AccessLength
;
289 Address
= FieldObj
->Field
.PinNumberIndex
;
290 BitWidth
= FieldObj
->Field
.BitLength
;
293 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
294 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
295 &RegionObj
->Region
.Handler
->AddressSpace
, Handler
,
296 ACPI_FORMAT_UINT64 (Address
),
297 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
299 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
300 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
303 * For handlers other than the default (supplied) handlers, we must
304 * exit the interpreter because the handler *might* block -- we don't
305 * know what it will do, so we can't hold the lock on the intepreter.
307 AcpiExExitInterpreter();
310 /* Call the handler */
312 Status
= Handler (Function
, Address
, BitWidth
, Value
, Context
,
313 RegionObj2
->Extra
.RegionContext
);
315 if (ACPI_FAILURE (Status
))
317 ACPI_EXCEPTION ((AE_INFO
, Status
, "Returned by Handler for [%s]",
318 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
321 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
322 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
325 * We just returned from a non-default handler, we must re-enter the
328 AcpiExEnterInterpreter ();
331 return_ACPI_STATUS (Status
);
335 /*******************************************************************************
337 * FUNCTION: AcpiEvDetachRegion
339 * PARAMETERS: RegionObj - Region Object
340 * AcpiNsIsLocked - Namespace Region Already Locked?
344 * DESCRIPTION: Break the association between the handler and the region
345 * this is a two way association.
347 ******************************************************************************/
351 ACPI_OPERAND_OBJECT
*RegionObj
,
352 BOOLEAN AcpiNsIsLocked
)
354 ACPI_OPERAND_OBJECT
*HandlerObj
;
355 ACPI_OPERAND_OBJECT
*ObjDesc
;
356 ACPI_OPERAND_OBJECT
*StartDesc
;
357 ACPI_OPERAND_OBJECT
**LastObjPtr
;
358 ACPI_ADR_SPACE_SETUP RegionSetup
;
359 void **RegionContext
;
360 ACPI_OPERAND_OBJECT
*RegionObj2
;
364 ACPI_FUNCTION_TRACE (EvDetachRegion
);
367 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
372 RegionContext
= &RegionObj2
->Extra
.RegionContext
;
374 /* Get the address handler from the region object */
376 HandlerObj
= RegionObj
->Region
.Handler
;
379 /* This region has no handler, all done */
384 /* Find this region in the handler's list */
386 ObjDesc
= HandlerObj
->AddressSpace
.RegionList
;
388 LastObjPtr
= &HandlerObj
->AddressSpace
.RegionList
;
392 /* Is this the correct Region? */
394 if (ObjDesc
== RegionObj
)
396 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
397 "Removing Region %p from address handler %p\n",
398 RegionObj
, HandlerObj
));
400 /* This is it, remove it from the handler's list */
402 *LastObjPtr
= ObjDesc
->Region
.Next
;
403 ObjDesc
->Region
.Next
= NULL
; /* Must clear field */
407 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
408 if (ACPI_FAILURE (Status
))
414 /* Now stop region accesses by executing the _REG method */
416 Status
= AcpiEvExecuteRegMethod (RegionObj
, ACPI_REG_DISCONNECT
);
417 if (ACPI_FAILURE (Status
))
419 ACPI_EXCEPTION ((AE_INFO
, Status
, "from region _REG, [%s]",
420 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
425 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
426 if (ACPI_FAILURE (Status
))
433 * If the region has been activated, call the setup handler with
434 * the deactivate notification
436 if (RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
)
438 RegionSetup
= HandlerObj
->AddressSpace
.Setup
;
439 Status
= RegionSetup (RegionObj
, ACPI_REGION_DEACTIVATE
,
440 HandlerObj
->AddressSpace
.Context
, RegionContext
);
443 * RegionContext should have been released by the deactivate
444 * operation. We don't need access to it anymore here.
448 *RegionContext
= NULL
;
451 /* Init routine may fail, Just ignore errors */
453 if (ACPI_FAILURE (Status
))
455 ACPI_EXCEPTION ((AE_INFO
, Status
,
456 "from region handler - deactivate, [%s]",
457 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
460 RegionObj
->Region
.Flags
&= ~(AOPOBJ_SETUP_COMPLETE
);
464 * Remove handler reference in the region
466 * NOTE: this doesn't mean that the region goes away, the region
467 * is just inaccessible as indicated to the _REG method
469 * If the region is on the handler's list, this must be the
472 RegionObj
->Region
.Handler
= NULL
;
473 AcpiUtRemoveReference (HandlerObj
);
478 /* Walk the linked list of handlers */
480 LastObjPtr
= &ObjDesc
->Region
.Next
;
481 ObjDesc
= ObjDesc
->Region
.Next
;
483 /* Prevent infinite loop if list is corrupted */
485 if (ObjDesc
== StartDesc
)
487 ACPI_ERROR ((AE_INFO
,
488 "Circular handler list in region object %p",
494 /* If we get here, the region was not in the handler's region list */
496 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
497 "Cannot remove region %p from address handler %p\n",
498 RegionObj
, HandlerObj
));
504 /*******************************************************************************
506 * FUNCTION: AcpiEvAttachRegion
508 * PARAMETERS: HandlerObj - Handler Object
509 * RegionObj - Region Object
510 * AcpiNsIsLocked - Namespace Region Already Locked?
514 * DESCRIPTION: Create the association between the handler and the region
515 * this is a two way association.
517 ******************************************************************************/
521 ACPI_OPERAND_OBJECT
*HandlerObj
,
522 ACPI_OPERAND_OBJECT
*RegionObj
,
523 BOOLEAN AcpiNsIsLocked
)
526 ACPI_FUNCTION_TRACE (EvAttachRegion
);
529 /* Install the region's handler */
531 if (RegionObj
->Region
.Handler
)
533 return_ACPI_STATUS (AE_ALREADY_EXISTS
);
536 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
537 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
538 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
539 RegionObj
, HandlerObj
,
540 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
542 /* Link this region to the front of the handler's list */
544 RegionObj
->Region
.Next
= HandlerObj
->AddressSpace
.RegionList
;
545 HandlerObj
->AddressSpace
.RegionList
= RegionObj
;
546 RegionObj
->Region
.Handler
= HandlerObj
;
547 AcpiUtAddReference (HandlerObj
);
549 return_ACPI_STATUS (AE_OK
);
553 /*******************************************************************************
555 * FUNCTION: AcpiEvAssociateRegMethod
557 * PARAMETERS: RegionObj - Region object
561 * DESCRIPTION: Find and associate _REG method to a region
563 ******************************************************************************/
566 AcpiEvAssociateRegMethod (
567 ACPI_OPERAND_OBJECT
*RegionObj
)
569 ACPI_NAME
*RegNamePtr
= (ACPI_NAME
*) METHOD_NAME__REG
;
570 ACPI_NAMESPACE_NODE
*MethodNode
;
571 ACPI_NAMESPACE_NODE
*Node
;
572 ACPI_OPERAND_OBJECT
*RegionObj2
;
576 ACPI_FUNCTION_TRACE (EvAssociateRegMethod
);
579 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
585 Node
= RegionObj
->Region
.Node
->Parent
;
587 /* Find any "_REG" method associated with this region definition */
589 Status
= AcpiNsSearchOneScope (
590 *RegNamePtr
, Node
, ACPI_TYPE_METHOD
, &MethodNode
);
591 if (ACPI_SUCCESS (Status
))
594 * The _REG method is optional and there can be only one per region
595 * definition. This will be executed when the handler is attached
598 RegionObj2
->Extra
.Method_REG
= MethodNode
;
605 /*******************************************************************************
607 * FUNCTION: AcpiEvExecuteRegMethod
609 * PARAMETERS: RegionObj - Region object
610 * Function - Passed to _REG: On (1) or Off (0)
614 * DESCRIPTION: Execute _REG method for a region
616 ******************************************************************************/
619 AcpiEvExecuteRegMethod (
620 ACPI_OPERAND_OBJECT
*RegionObj
,
623 ACPI_EVALUATE_INFO
*Info
;
624 ACPI_OPERAND_OBJECT
*Args
[3];
625 ACPI_OPERAND_OBJECT
*RegionObj2
;
629 ACPI_FUNCTION_TRACE (EvExecuteRegMethod
);
632 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
635 return_ACPI_STATUS (AE_NOT_EXIST
);
638 if (RegionObj2
->Extra
.Method_REG
== NULL
||
639 RegionObj
->Region
.Handler
== NULL
||
640 !AcpiGbl_RegMethodsEnabled
)
642 return_ACPI_STATUS (AE_OK
);
645 /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
647 if ((Function
== ACPI_REG_CONNECT
&&
648 RegionObj
->Common
.Flags
& AOPOBJ_REG_CONNECTED
) ||
649 (Function
== ACPI_REG_DISCONNECT
&&
650 !(RegionObj
->Common
.Flags
& AOPOBJ_REG_CONNECTED
)))
652 return_ACPI_STATUS (AE_OK
);
655 /* Allocate and initialize the evaluation information block */
657 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
660 return_ACPI_STATUS (AE_NO_MEMORY
);
663 Info
->PrefixNode
= RegionObj2
->Extra
.Method_REG
;
664 Info
->RelativePathname
= NULL
;
665 Info
->Parameters
= Args
;
666 Info
->Flags
= ACPI_IGNORE_RETURN_VALUE
;
669 * The _REG method has two arguments:
672 * Operation region space ID Same value as RegionObj->Region.SpaceId
675 * connection status 1 for connecting the handler, 0 for disconnecting
676 * the handler (Passed as a parameter)
678 Args
[0] = AcpiUtCreateIntegerObject ((UINT64
) RegionObj
->Region
.SpaceId
);
681 Status
= AE_NO_MEMORY
;
685 Args
[1] = AcpiUtCreateIntegerObject ((UINT64
) Function
);
688 Status
= AE_NO_MEMORY
;
692 Args
[2] = NULL
; /* Terminate list */
694 /* Execute the method, no return value */
697 AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD
, Info
->PrefixNode
, NULL
));
699 Status
= AcpiNsEvaluate (Info
);
700 AcpiUtRemoveReference (Args
[1]);
702 if (ACPI_FAILURE (Status
))
707 if (Function
== ACPI_REG_CONNECT
)
709 RegionObj
->Common
.Flags
|= AOPOBJ_REG_CONNECTED
;
713 RegionObj
->Common
.Flags
&= ~AOPOBJ_REG_CONNECTED
;
717 AcpiUtRemoveReference (Args
[0]);
721 return_ACPI_STATUS (Status
);
725 /*******************************************************************************
727 * FUNCTION: AcpiEvExecuteRegMethods
729 * PARAMETERS: Node - Namespace node for the device
730 * SpaceId - The address space ID
731 * Function - Passed to _REG: On (1) or Off (0)
735 * DESCRIPTION: Run all _REG methods for the input Space ID;
736 * Note: assumes namespace is locked, or system init time.
738 ******************************************************************************/
741 AcpiEvExecuteRegMethods (
742 ACPI_NAMESPACE_NODE
*Node
,
743 ACPI_ADR_SPACE_TYPE SpaceId
,
746 ACPI_REG_WALK_INFO Info
;
749 ACPI_FUNCTION_TRACE (EvExecuteRegMethods
);
751 Info
.SpaceId
= SpaceId
;
752 Info
.Function
= Function
;
753 Info
.RegRunCount
= 0;
755 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES
,
756 " Running _REG methods for SpaceId %s\n",
757 AcpiUtGetRegionName (Info
.SpaceId
)));
760 * Run all _REG methods for all Operation Regions for this space ID. This
761 * is a separate walk in order to handle any interdependencies between
762 * regions and _REG methods. (i.e. handlers must be installed for all
763 * regions of this Space ID before we can run any _REG methods)
765 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY
, Node
, ACPI_UINT32_MAX
,
766 ACPI_NS_WALK_UNLOCK
, AcpiEvRegRun
, NULL
, &Info
, NULL
);
768 /* Special case for EC: handle "orphan" _REG methods with no region */
770 if (SpaceId
== ACPI_ADR_SPACE_EC
)
772 AcpiEvOrphanEcRegMethod (Node
);
775 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES
,
776 " Executed %u _REG methods for SpaceId %s\n",
777 Info
.RegRunCount
, AcpiUtGetRegionName (Info
.SpaceId
)));
783 /*******************************************************************************
785 * FUNCTION: AcpiEvRegRun
787 * PARAMETERS: WalkNamespace callback
789 * DESCRIPTION: Run _REG method for region objects of the requested spaceID
791 ******************************************************************************/
795 ACPI_HANDLE ObjHandle
,
800 ACPI_OPERAND_OBJECT
*ObjDesc
;
801 ACPI_NAMESPACE_NODE
*Node
;
803 ACPI_REG_WALK_INFO
*Info
;
806 Info
= ACPI_CAST_PTR (ACPI_REG_WALK_INFO
, Context
);
808 /* Convert and validate the device handle */
810 Node
= AcpiNsValidateHandle (ObjHandle
);
813 return (AE_BAD_PARAMETER
);
817 * We only care about regions.and objects that are allowed to have address
820 if ((Node
->Type
!= ACPI_TYPE_REGION
) &&
821 (Node
!= AcpiGbl_RootNode
))
826 /* Check for an existing internal object */
828 ObjDesc
= AcpiNsGetAttachedObject (Node
);
831 /* No object, just exit */
836 /* Object is a Region */
838 if (ObjDesc
->Region
.SpaceId
!= Info
->SpaceId
)
840 /* This region is for a different address space, just ignore it */
846 Status
= AcpiEvExecuteRegMethod (ObjDesc
, Info
->Function
);
851 /*******************************************************************************
853 * FUNCTION: AcpiEvOrphanEcRegMethod
855 * PARAMETERS: EcDeviceNode - Namespace node for an EC device
859 * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
860 * device. This is a _REG method that has no corresponding region
861 * within the EC device scope. The orphan _REG method appears to
862 * have been enabled by the description of the ECDT in the ACPI
863 * specification: "The availability of the region space can be
864 * detected by providing a _REG method object underneath the
865 * Embedded Controller device."
867 * To quickly access the EC device, we use the EcDeviceNode used
868 * during EC handler installation. Otherwise, we would need to
869 * perform a time consuming namespace walk, executing _HID
870 * methods to find the EC device.
872 * MUTEX: Assumes the namespace is locked
874 ******************************************************************************/
877 AcpiEvOrphanEcRegMethod (
878 ACPI_NAMESPACE_NODE
*EcDeviceNode
)
880 ACPI_HANDLE RegMethod
;
881 ACPI_NAMESPACE_NODE
*NextNode
;
883 ACPI_OBJECT_LIST Args
;
884 ACPI_OBJECT Objects
[2];
887 ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod
);
895 /* Namespace is currently locked, must release */
897 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
899 /* Get a handle to a _REG method immediately under the EC device */
901 Status
= AcpiGetHandle (EcDeviceNode
, METHOD_NAME__REG
, &RegMethod
);
902 if (ACPI_FAILURE (Status
))
904 goto Exit
; /* There is no _REG method present */
908 * Execute the _REG method only if there is no Operation Region in
909 * this scope with the Embedded Controller space ID. Otherwise, it
910 * will already have been executed. Note, this allows for Regions
911 * with other space IDs to be present; but the code below will then
912 * execute the _REG method with the EmbeddedControl SpaceID argument.
914 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NULL
);
917 if ((NextNode
->Type
== ACPI_TYPE_REGION
) &&
918 (NextNode
->Object
) &&
919 (NextNode
->Object
->Region
.SpaceId
== ACPI_ADR_SPACE_EC
))
921 goto Exit
; /* Do not execute the _REG */
924 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NextNode
);
927 /* Evaluate the _REG(EmbeddedControl,Connect) method */
930 Args
.Pointer
= Objects
;
931 Objects
[0].Type
= ACPI_TYPE_INTEGER
;
932 Objects
[0].Integer
.Value
= ACPI_ADR_SPACE_EC
;
933 Objects
[1].Type
= ACPI_TYPE_INTEGER
;
934 Objects
[1].Integer
.Value
= ACPI_REG_CONNECT
;
936 Status
= AcpiEvaluateObject (RegMethod
, NULL
, &Args
, NULL
);
939 /* We ignore all errors from above, don't care */
941 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);