1 /******************************************************************************
3 * Module Name: evregion - Operation Region support
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 #include "accommon.h"
118 #include "acevents.h"
119 #include "acnamesp.h"
120 #include "acinterp.h"
122 #define _COMPONENT ACPI_EVENTS
123 ACPI_MODULE_NAME ("evregion")
126 extern UINT8 AcpiGbl_DefaultAddressSpaces
[];
128 /* Local prototypes */
131 AcpiEvOrphanEcRegMethod (
132 ACPI_NAMESPACE_NODE
*EcDeviceNode
);
136 ACPI_HANDLE ObjHandle
,
142 /*******************************************************************************
144 * FUNCTION: AcpiEvInitializeOpRegions
150 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
151 * an installed default region handler.
153 ******************************************************************************/
156 AcpiEvInitializeOpRegions (
163 ACPI_FUNCTION_TRACE (EvInitializeOpRegions
);
166 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
167 if (ACPI_FAILURE (Status
))
169 return_ACPI_STATUS (Status
);
172 /* Run the _REG methods for OpRegions in each default address space */
174 for (i
= 0; i
< ACPI_NUM_DEFAULT_SPACES
; i
++)
177 * Make sure the installed handler is the DEFAULT handler. If not the
178 * default, the _REG methods will have already been run (when the
179 * handler was installed)
181 if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode
,
182 AcpiGbl_DefaultAddressSpaces
[i
]))
184 Status
= AcpiEvExecuteRegMethods (AcpiGbl_RootNode
,
185 AcpiGbl_DefaultAddressSpaces
[i
]);
189 AcpiGbl_RegMethodsExecuted
= TRUE
;
191 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
192 return_ACPI_STATUS (Status
);
196 /*******************************************************************************
198 * FUNCTION: AcpiEvAddressSpaceDispatch
200 * PARAMETERS: RegionObj - Internal region object
201 * FieldObj - Corresponding field. Can be NULL.
202 * Function - Read or Write operation
203 * RegionOffset - Where in the region to read or write
204 * BitWidth - Field width in bits (8, 16, 32, or 64)
205 * Value - Pointer to in or out value, must be
206 * a full 64-bit integer
210 * DESCRIPTION: Dispatch an address space or operation region access to
211 * a previously installed handler.
213 ******************************************************************************/
216 AcpiEvAddressSpaceDispatch (
217 ACPI_OPERAND_OBJECT
*RegionObj
,
218 ACPI_OPERAND_OBJECT
*FieldObj
,
225 ACPI_ADR_SPACE_HANDLER Handler
;
226 ACPI_ADR_SPACE_SETUP RegionSetup
;
227 ACPI_OPERAND_OBJECT
*HandlerDesc
;
228 ACPI_OPERAND_OBJECT
*RegionObj2
;
229 void *RegionContext
= NULL
;
230 ACPI_CONNECTION_INFO
*Context
;
231 ACPI_PHYSICAL_ADDRESS Address
;
234 ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch
);
237 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
240 return_ACPI_STATUS (AE_NOT_EXIST
);
243 /* Ensure that there is a handler associated with this region */
245 HandlerDesc
= RegionObj
->Region
.Handler
;
248 ACPI_ERROR ((AE_INFO
,
249 "No handler for Region [%4.4s] (%p) [%s]",
250 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
251 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
253 return_ACPI_STATUS (AE_NOT_EXIST
);
256 Context
= HandlerDesc
->AddressSpace
.Context
;
259 * It may be the case that the region has never been initialized.
260 * Some types of regions require special init code
262 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
264 /* This region has not been initialized yet, do it */
266 RegionSetup
= HandlerDesc
->AddressSpace
.Setup
;
269 /* No initialization routine, exit with error */
271 ACPI_ERROR ((AE_INFO
,
272 "No init routine for region(%p) [%s]",
273 RegionObj
, AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
274 return_ACPI_STATUS (AE_NOT_EXIST
);
278 * We must exit the interpreter because the region setup will
279 * potentially execute control methods (for example, the _REG method
282 AcpiExExitInterpreter ();
284 Status
= RegionSetup (RegionObj
, ACPI_REGION_ACTIVATE
,
285 Context
, &RegionContext
);
287 /* Re-enter the interpreter */
289 AcpiExEnterInterpreter ();
291 /* Check for failure of the Region Setup */
293 if (ACPI_FAILURE (Status
))
295 ACPI_EXCEPTION ((AE_INFO
, Status
,
296 "During region initialization: [%s]",
297 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
298 return_ACPI_STATUS (Status
);
301 /* Region initialization may have been completed by RegionSetup */
303 if (!(RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
))
305 RegionObj
->Region
.Flags
|= AOPOBJ_SETUP_COMPLETE
;
308 * Save the returned context for use in all accesses to
309 * the handler for this particular region
311 if (!(RegionObj2
->Extra
.RegionContext
))
313 RegionObj2
->Extra
.RegionContext
= RegionContext
;
318 /* We have everything we need, we can invoke the address space handler */
320 Handler
= HandlerDesc
->AddressSpace
.Handler
;
321 Address
= (RegionObj
->Region
.Address
+ RegionOffset
);
324 * Special handling for GenericSerialBus and GeneralPurposeIo:
325 * There are three extra parameters that must be passed to the
326 * handler via the context:
327 * 1) Connection buffer, a resource template from Connection() op
328 * 2) Length of the above buffer
329 * 3) Actual access length from the AccessAs() op
331 * In addition, for GeneralPurposeIo, the Address and BitWidth fields
332 * are defined as follows:
333 * 1) Address is the pin number index of the field (bit offset from
334 * the previous Connection)
335 * 2) BitWidth is the actual bit length of the field (number of pins)
337 if ((RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GSBUS
) &&
341 /* Get the Connection (ResourceTemplate) buffer */
343 Context
->Connection
= FieldObj
->Field
.ResourceBuffer
;
344 Context
->Length
= FieldObj
->Field
.ResourceLength
;
345 Context
->AccessLength
= FieldObj
->Field
.AccessLength
;
347 if ((RegionObj
->Region
.SpaceId
== ACPI_ADR_SPACE_GPIO
) &&
351 /* Get the Connection (ResourceTemplate) buffer */
353 Context
->Connection
= FieldObj
->Field
.ResourceBuffer
;
354 Context
->Length
= FieldObj
->Field
.ResourceLength
;
355 Context
->AccessLength
= FieldObj
->Field
.AccessLength
;
356 Address
= FieldObj
->Field
.PinNumberIndex
;
357 BitWidth
= FieldObj
->Field
.BitLength
;
360 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
361 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
362 &RegionObj
->Region
.Handler
->AddressSpace
, Handler
,
363 ACPI_FORMAT_UINT64 (Address
),
364 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
366 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
367 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
370 * For handlers other than the default (supplied) handlers, we must
371 * exit the interpreter because the handler *might* block -- we don't
372 * know what it will do, so we can't hold the lock on the intepreter.
374 AcpiExExitInterpreter();
377 /* Call the handler */
379 Status
= Handler (Function
, Address
, BitWidth
, Value
, Context
,
380 RegionObj2
->Extra
.RegionContext
);
382 if (ACPI_FAILURE (Status
))
384 ACPI_EXCEPTION ((AE_INFO
, Status
, "Returned by Handler for [%s]",
385 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
388 if (!(HandlerDesc
->AddressSpace
.HandlerFlags
&
389 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
))
392 * We just returned from a non-default handler, we must re-enter the
395 AcpiExEnterInterpreter ();
398 return_ACPI_STATUS (Status
);
402 /*******************************************************************************
404 * FUNCTION: AcpiEvDetachRegion
406 * PARAMETERS: RegionObj - Region Object
407 * AcpiNsIsLocked - Namespace Region Already Locked?
411 * DESCRIPTION: Break the association between the handler and the region
412 * this is a two way association.
414 ******************************************************************************/
418 ACPI_OPERAND_OBJECT
*RegionObj
,
419 BOOLEAN AcpiNsIsLocked
)
421 ACPI_OPERAND_OBJECT
*HandlerObj
;
422 ACPI_OPERAND_OBJECT
*ObjDesc
;
423 ACPI_OPERAND_OBJECT
*StartDesc
;
424 ACPI_OPERAND_OBJECT
**LastObjPtr
;
425 ACPI_ADR_SPACE_SETUP RegionSetup
;
426 void **RegionContext
;
427 ACPI_OPERAND_OBJECT
*RegionObj2
;
431 ACPI_FUNCTION_TRACE (EvDetachRegion
);
434 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
439 RegionContext
= &RegionObj2
->Extra
.RegionContext
;
441 /* Get the address handler from the region object */
443 HandlerObj
= RegionObj
->Region
.Handler
;
446 /* This region has no handler, all done */
451 /* Find this region in the handler's list */
453 ObjDesc
= HandlerObj
->AddressSpace
.RegionList
;
455 LastObjPtr
= &HandlerObj
->AddressSpace
.RegionList
;
459 /* Is this the correct Region? */
461 if (ObjDesc
== RegionObj
)
463 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
464 "Removing Region %p from address handler %p\n",
465 RegionObj
, HandlerObj
));
467 /* This is it, remove it from the handler's list */
469 *LastObjPtr
= ObjDesc
->Region
.Next
;
470 ObjDesc
->Region
.Next
= NULL
; /* Must clear field */
474 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
475 if (ACPI_FAILURE (Status
))
481 /* Now stop region accesses by executing the _REG method */
483 Status
= AcpiEvExecuteRegMethod (RegionObj
, ACPI_REG_DISCONNECT
);
484 if (ACPI_FAILURE (Status
))
486 ACPI_EXCEPTION ((AE_INFO
, Status
, "from region _REG, [%s]",
487 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
492 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
493 if (ACPI_FAILURE (Status
))
500 * If the region has been activated, call the setup handler with
501 * the deactivate notification
503 if (RegionObj
->Region
.Flags
& AOPOBJ_SETUP_COMPLETE
)
505 RegionSetup
= HandlerObj
->AddressSpace
.Setup
;
506 Status
= RegionSetup (RegionObj
, ACPI_REGION_DEACTIVATE
,
507 HandlerObj
->AddressSpace
.Context
, RegionContext
);
510 * RegionContext should have been released by the deactivate
511 * operation. We don't need access to it anymore here.
515 *RegionContext
= NULL
;
518 /* Init routine may fail, Just ignore errors */
520 if (ACPI_FAILURE (Status
))
522 ACPI_EXCEPTION ((AE_INFO
, Status
,
523 "from region handler - deactivate, [%s]",
524 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
527 RegionObj
->Region
.Flags
&= ~(AOPOBJ_SETUP_COMPLETE
);
531 * Remove handler reference in the region
533 * NOTE: this doesn't mean that the region goes away, the region
534 * is just inaccessible as indicated to the _REG method
536 * If the region is on the handler's list, this must be the
539 RegionObj
->Region
.Handler
= NULL
;
540 AcpiUtRemoveReference (HandlerObj
);
545 /* Walk the linked list of handlers */
547 LastObjPtr
= &ObjDesc
->Region
.Next
;
548 ObjDesc
= ObjDesc
->Region
.Next
;
550 /* Prevent infinite loop if list is corrupted */
552 if (ObjDesc
== StartDesc
)
554 ACPI_ERROR ((AE_INFO
,
555 "Circular handler list in region object %p",
561 /* If we get here, the region was not in the handler's region list */
563 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
564 "Cannot remove region %p from address handler %p\n",
565 RegionObj
, HandlerObj
));
571 /*******************************************************************************
573 * FUNCTION: AcpiEvAttachRegion
575 * PARAMETERS: HandlerObj - Handler Object
576 * RegionObj - Region Object
577 * AcpiNsIsLocked - Namespace Region Already Locked?
581 * DESCRIPTION: Create the association between the handler and the region
582 * this is a two way association.
584 ******************************************************************************/
588 ACPI_OPERAND_OBJECT
*HandlerObj
,
589 ACPI_OPERAND_OBJECT
*RegionObj
,
590 BOOLEAN AcpiNsIsLocked
)
593 ACPI_FUNCTION_TRACE (EvAttachRegion
);
596 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
,
597 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
598 AcpiUtGetNodeName (RegionObj
->Region
.Node
),
599 RegionObj
, HandlerObj
,
600 AcpiUtGetRegionName (RegionObj
->Region
.SpaceId
)));
602 /* Link this region to the front of the handler's list */
604 RegionObj
->Region
.Next
= HandlerObj
->AddressSpace
.RegionList
;
605 HandlerObj
->AddressSpace
.RegionList
= RegionObj
;
607 /* Install the region's handler */
609 if (RegionObj
->Region
.Handler
)
611 return_ACPI_STATUS (AE_ALREADY_EXISTS
);
614 RegionObj
->Region
.Handler
= HandlerObj
;
615 AcpiUtAddReference (HandlerObj
);
617 return_ACPI_STATUS (AE_OK
);
621 /*******************************************************************************
623 * FUNCTION: AcpiEvExecuteRegMethod
625 * PARAMETERS: RegionObj - Region object
626 * Function - Passed to _REG: On (1) or Off (0)
630 * DESCRIPTION: Execute _REG method for a region
632 ******************************************************************************/
635 AcpiEvExecuteRegMethod (
636 ACPI_OPERAND_OBJECT
*RegionObj
,
639 ACPI_EVALUATE_INFO
*Info
;
640 ACPI_OPERAND_OBJECT
*Args
[3];
641 ACPI_OPERAND_OBJECT
*RegionObj2
;
645 ACPI_FUNCTION_TRACE (EvExecuteRegMethod
);
648 RegionObj2
= AcpiNsGetSecondaryObject (RegionObj
);
651 return_ACPI_STATUS (AE_NOT_EXIST
);
654 if (RegionObj2
->Extra
.Method_REG
== NULL
)
656 return_ACPI_STATUS (AE_OK
);
659 /* Allocate and initialize the evaluation information block */
661 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
664 return_ACPI_STATUS (AE_NO_MEMORY
);
667 Info
->PrefixNode
= RegionObj2
->Extra
.Method_REG
;
668 Info
->RelativePathname
= NULL
;
669 Info
->Parameters
= Args
;
670 Info
->Flags
= ACPI_IGNORE_RETURN_VALUE
;
673 * The _REG method has two arguments:
676 * Operation region space ID Same value as RegionObj->Region.SpaceId
679 * connection status 1 for connecting the handler, 0 for disconnecting
680 * the handler (Passed as a parameter)
682 Args
[0] = AcpiUtCreateIntegerObject ((UINT64
) RegionObj
->Region
.SpaceId
);
685 Status
= AE_NO_MEMORY
;
689 Args
[1] = AcpiUtCreateIntegerObject ((UINT64
) Function
);
692 Status
= AE_NO_MEMORY
;
696 Args
[2] = NULL
; /* Terminate list */
698 /* Execute the method, no return value */
701 AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD
, Info
->PrefixNode
, NULL
));
703 Status
= AcpiNsEvaluate (Info
);
704 AcpiUtRemoveReference (Args
[1]);
707 AcpiUtRemoveReference (Args
[0]);
711 return_ACPI_STATUS (Status
);
715 /*******************************************************************************
717 * FUNCTION: AcpiEvExecuteRegMethods
719 * PARAMETERS: Node - Namespace node for the device
720 * SpaceId - The address space ID
724 * DESCRIPTION: Run all _REG methods for the input Space ID;
725 * Note: assumes namespace is locked, or system init time.
727 ******************************************************************************/
730 AcpiEvExecuteRegMethods (
731 ACPI_NAMESPACE_NODE
*Node
,
732 ACPI_ADR_SPACE_TYPE SpaceId
)
737 ACPI_FUNCTION_TRACE (EvExecuteRegMethods
);
741 * Run all _REG methods for all Operation Regions for this space ID. This
742 * is a separate walk in order to handle any interdependencies between
743 * regions and _REG methods. (i.e. handlers must be installed for all
744 * regions of this Space ID before we can run any _REG methods)
746 Status
= AcpiNsWalkNamespace (ACPI_TYPE_ANY
, Node
, ACPI_UINT32_MAX
,
747 ACPI_NS_WALK_UNLOCK
, AcpiEvRegRun
, NULL
,
750 /* Special case for EC: handle "orphan" _REG methods with no region */
752 if (SpaceId
== ACPI_ADR_SPACE_EC
)
754 AcpiEvOrphanEcRegMethod (Node
);
757 return_ACPI_STATUS (Status
);
761 /*******************************************************************************
763 * FUNCTION: AcpiEvRegRun
765 * PARAMETERS: WalkNamespace callback
767 * DESCRIPTION: Run _REG method for region objects of the requested spaceID
769 ******************************************************************************/
773 ACPI_HANDLE ObjHandle
,
778 ACPI_OPERAND_OBJECT
*ObjDesc
;
779 ACPI_NAMESPACE_NODE
*Node
;
780 ACPI_ADR_SPACE_TYPE SpaceId
;
784 SpaceId
= *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE
, Context
);
786 /* Convert and validate the device handle */
788 Node
= AcpiNsValidateHandle (ObjHandle
);
791 return (AE_BAD_PARAMETER
);
795 * We only care about regions.and objects that are allowed to have address
798 if ((Node
->Type
!= ACPI_TYPE_REGION
) &&
799 (Node
!= AcpiGbl_RootNode
))
804 /* Check for an existing internal object */
806 ObjDesc
= AcpiNsGetAttachedObject (Node
);
809 /* No object, just exit */
814 /* Object is a Region */
816 if (ObjDesc
->Region
.SpaceId
!= SpaceId
)
818 /* This region is for a different address space, just ignore it */
823 Status
= AcpiEvExecuteRegMethod (ObjDesc
, ACPI_REG_CONNECT
);
828 /*******************************************************************************
830 * FUNCTION: AcpiEvOrphanEcRegMethod
832 * PARAMETERS: EcDeviceNode - Namespace node for an EC device
836 * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
837 * device. This is a _REG method that has no corresponding region
838 * within the EC device scope. The orphan _REG method appears to
839 * have been enabled by the description of the ECDT in the ACPI
840 * specification: "The availability of the region space can be
841 * detected by providing a _REG method object underneath the
842 * Embedded Controller device."
844 * To quickly access the EC device, we use the EcDeviceNode used
845 * during EC handler installation. Otherwise, we would need to
846 * perform a time consuming namespace walk, executing _HID
847 * methods to find the EC device.
849 * MUTEX: Assumes the namespace is locked
851 ******************************************************************************/
854 AcpiEvOrphanEcRegMethod (
855 ACPI_NAMESPACE_NODE
*EcDeviceNode
)
857 ACPI_HANDLE RegMethod
;
858 ACPI_NAMESPACE_NODE
*NextNode
;
860 ACPI_OBJECT_LIST Args
;
861 ACPI_OBJECT Objects
[2];
864 ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod
);
872 /* Namespace is currently locked, must release */
874 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
876 /* Get a handle to a _REG method immediately under the EC device */
878 Status
= AcpiGetHandle (EcDeviceNode
, METHOD_NAME__REG
, &RegMethod
);
879 if (ACPI_FAILURE (Status
))
881 goto Exit
; /* There is no _REG method present */
885 * Execute the _REG method only if there is no Operation Region in
886 * this scope with the Embedded Controller space ID. Otherwise, it
887 * will already have been executed. Note, this allows for Regions
888 * with other space IDs to be present; but the code below will then
889 * execute the _REG method with the EmbeddedControl SpaceID argument.
891 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NULL
);
894 if ((NextNode
->Type
== ACPI_TYPE_REGION
) &&
895 (NextNode
->Object
) &&
896 (NextNode
->Object
->Region
.SpaceId
== ACPI_ADR_SPACE_EC
))
898 goto Exit
; /* Do not execute the _REG */
901 NextNode
= AcpiNsGetNextNode (EcDeviceNode
, NextNode
);
904 /* Evaluate the _REG(EmbeddedControl,Connect) method */
907 Args
.Pointer
= Objects
;
908 Objects
[0].Type
= ACPI_TYPE_INTEGER
;
909 Objects
[0].Integer
.Value
= ACPI_ADR_SPACE_EC
;
910 Objects
[1].Type
= ACPI_TYPE_INTEGER
;
911 Objects
[1].Integer
.Value
= ACPI_REG_CONNECT
;
913 Status
= AcpiEvaluateObject (RegMethod
, NULL
, &Args
, NULL
);
916 /* We ignore all errors from above, don't care */
918 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);