1 /******************************************************************************
3 * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13 * All rights reserved.
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
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
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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
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
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 __EVREGION_C__
121 #include "acevents.h"
122 #include "acnamesp.h"
123 #include "acinterp.h"
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evregion")
128 #define ACPI_NUM_DEFAULT_SPACES 4
130 static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = {
131 ACPI_ADR_SPACE_SYSTEM_MEMORY,
132 ACPI_ADR_SPACE_SYSTEM_IO,
133 ACPI_ADR_SPACE_PCI_CONFIG,
134 ACPI_ADR_SPACE_DATA_TABLE};
137 /*******************************************************************************
139 * FUNCTION: AcpiEvInstallRegionHandlers
145 * DESCRIPTION: Installs the core subsystem default address space handlers.
147 ******************************************************************************/
150 AcpiEvInstallRegionHandlers (
157 ACPI_FUNCTION_TRACE ("EvInstallRegionHandlers");
160 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
161 if (ACPI_FAILURE (Status))
163 return_ACPI_STATUS (Status);
167 * All address spaces (PCI Config, EC, SMBus) are scope dependent
168 * and registration must occur for a specific device.
170 * In the case of the system memory and IO address spaces there is currently
171 * no device associated with the address space. For these we use the root.
173 * We install the default PCI config space handler at the root so
174 * that this space is immediately available even though the we have
175 * not enumerated all the PCI Root Buses yet. This is to conform
176 * to the ACPI specification which states that the PCI config
177 * space must be always available -- even though we are nowhere
178 * near ready to find the PCI root buses at this point.
180 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
181 * has already been installed (via AcpiInstallAddressSpaceHandler).
182 * Similar for AE_SAME_HANDLER.
184 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
186 Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode,
187 AcpiGbl_DefaultAddressSpaces[i],
188 ACPI_DEFAULT_HANDLER, NULL, NULL);
192 case AE_SAME_HANDLER:
193 case AE_ALREADY_EXISTS:
195 /* These exceptions are all OK */
207 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
208 return_ACPI_STATUS (Status);
212 /*******************************************************************************
214 * FUNCTION: AcpiEvInitializeOpRegions
220 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
221 * an installed default region handler.
223 ******************************************************************************/
226 AcpiEvInitializeOpRegions (
233 ACPI_FUNCTION_TRACE ("EvInitializeOpRegions");
236 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
237 if (ACPI_FAILURE (Status))
239 return_ACPI_STATUS (Status);
243 * Run the _REG methods for OpRegions in each default address space
245 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
247 /* TBD: Make sure handler is the DEFAULT handler, otherwise
248 * _REG will have already been run.
250 Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
251 AcpiGbl_DefaultAddressSpaces[i]);
254 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
255 return_ACPI_STATUS (Status);
259 /*******************************************************************************
261 * FUNCTION: AcpiEvExecuteRegMethod
263 * PARAMETERS: RegionObj - Object structure
264 * Function - Passed to _REG: On (1) or Off (0)
268 * DESCRIPTION: Execute _REG method for a region
270 ******************************************************************************/
273 AcpiEvExecuteRegMethod (
274 ACPI_OPERAND_OBJECT *RegionObj,
277 ACPI_PARAMETER_INFO Info;
278 ACPI_OPERAND_OBJECT *Params[3];
279 ACPI_OPERAND_OBJECT *RegionObj2;
283 ACPI_FUNCTION_TRACE ("EvExecuteRegMethod");
286 RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
289 return_ACPI_STATUS (AE_NOT_EXIST);
292 if (RegionObj2->Extra.Method_REG == NULL)
294 return_ACPI_STATUS (AE_OK);
298 * The _REG method has two arguments:
300 * Arg0, Integer: Operation region space ID
301 * Same value as RegionObj->Region.SpaceId
302 * Arg1, Integer: connection status
303 * 1 for connecting the handler,
304 * 0 for disconnecting the handler
305 * Passed as a parameter
307 Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
310 return_ACPI_STATUS (AE_NO_MEMORY);
313 Params[1] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
316 Status = AE_NO_MEMORY;
320 /* Setup the parameter objects */
322 Params[0]->Integer.Value = RegionObj->Region.SpaceId;
323 Params[1]->Integer.Value = Function;
326 Info.Node = RegionObj2->Extra.Method_REG;
327 Info.Parameters = Params;
328 Info.ParameterType = ACPI_PARAM_ARGS;
330 /* Execute the method, no return value */
332 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
333 ACPI_TYPE_METHOD, Info.Node, NULL));
334 Status = AcpiNsEvaluateByHandle (&Info);
336 AcpiUtRemoveReference (Params[1]);
339 AcpiUtRemoveReference (Params[0]);
341 return_ACPI_STATUS (Status);
345 /*******************************************************************************
347 * FUNCTION: AcpiEvAddressSpaceDispatch
349 * PARAMETERS: RegionObj - Internal region object
350 * Function - Read or Write operation
351 * Address - Where in the space to read or write
352 * BitWidth - Field width in bits (8, 16, 32, or 64)
353 * Value - Pointer to in or out value
357 * DESCRIPTION: Dispatch an address space or operation region access to
358 * a previously installed handler.
360 ******************************************************************************/
363 AcpiEvAddressSpaceDispatch (
364 ACPI_OPERAND_OBJECT *RegionObj,
366 ACPI_PHYSICAL_ADDRESS Address,
372 ACPI_ADR_SPACE_HANDLER Handler;
373 ACPI_ADR_SPACE_SETUP RegionSetup;
374 ACPI_OPERAND_OBJECT *HandlerDesc;
375 ACPI_OPERAND_OBJECT *RegionObj2;
376 void *RegionContext = NULL;
379 ACPI_FUNCTION_TRACE ("EvAddressSpaceDispatch");
382 RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
385 return_ACPI_STATUS (AE_NOT_EXIST);
388 /* Ensure that there is a handler associated with this region */
390 HandlerDesc = RegionObj->Region.Handler;
393 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
394 "No handler for Region [%4.4s] (%p) [%s]\n",
395 AcpiUtGetNodeName (RegionObj->Region.Node),
396 RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
398 return_ACPI_STATUS (AE_NOT_EXIST);
402 * It may be the case that the region has never been initialized
403 * Some types of regions require special init code
405 if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
408 * This region has not been initialized yet, do it
410 RegionSetup = HandlerDesc->AddressSpace.Setup;
413 /* No initialization routine, exit with error */
415 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n",
416 RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
417 return_ACPI_STATUS (AE_NOT_EXIST);
421 * We must exit the interpreter because the region setup will potentially
422 * execute control methods (e.g., _REG method for this region)
424 AcpiExExitInterpreter ();
426 Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE,
427 HandlerDesc->AddressSpace.Context, &RegionContext);
429 /* Re-enter the interpreter */
431 Status2 = AcpiExEnterInterpreter ();
432 if (ACPI_FAILURE (Status2))
434 return_ACPI_STATUS (Status2);
437 /* Check for failure of the Region Setup */
439 if (ACPI_FAILURE (Status))
441 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n",
442 AcpiFormatException (Status),
443 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
444 return_ACPI_STATUS (Status);
448 * Region initialization may have been completed by RegionSetup
450 if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
452 RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
454 if (RegionObj2->Extra.RegionContext)
456 /* The handler for this region was already installed */
458 ACPI_MEM_FREE (RegionContext);
463 * Save the returned context for use in all accesses to
464 * this particular region
466 RegionObj2->Extra.RegionContext = RegionContext;
471 /* We have everything we need, we can invoke the address space handler */
473 Handler = HandlerDesc->AddressSpace.Handler;
475 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
476 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
477 &RegionObj->Region.Handler->AddressSpace, Handler,
478 ACPI_FORMAT_UINT64 (Address),
479 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
481 if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
484 * For handlers other than the default (supplied) handlers, we must
485 * exit the interpreter because the handler *might* block -- we don't
486 * know what it will do, so we can't hold the lock on the intepreter.
488 AcpiExExitInterpreter();
491 /* Call the handler */
493 Status = Handler (Function, Address, BitWidth, Value,
494 HandlerDesc->AddressSpace.Context,
495 RegionObj2->Extra.RegionContext);
497 if (ACPI_FAILURE (Status))
499 ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n",
500 AcpiUtGetRegionName (RegionObj->Region.SpaceId),
501 AcpiFormatException (Status)));
504 if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
507 * We just returned from a non-default handler, we must re-enter the
510 Status2 = AcpiExEnterInterpreter ();
511 if (ACPI_FAILURE (Status2))
513 return_ACPI_STATUS (Status2);
517 return_ACPI_STATUS (Status);
521 /*******************************************************************************
523 * FUNCTION: AcpiEvDetachRegion
525 * PARAMETERS: RegionObj - Region Object
526 * AcpiNsIsLocked - Namespace Region Already Locked?
530 * DESCRIPTION: Break the association between the handler and the region
531 * this is a two way association.
533 ******************************************************************************/
537 ACPI_OPERAND_OBJECT *RegionObj,
538 BOOLEAN AcpiNsIsLocked)
540 ACPI_OPERAND_OBJECT *HandlerObj;
541 ACPI_OPERAND_OBJECT *ObjDesc;
542 ACPI_OPERAND_OBJECT **LastObjPtr;
543 ACPI_ADR_SPACE_SETUP RegionSetup;
544 void **RegionContext;
545 ACPI_OPERAND_OBJECT *RegionObj2;
549 ACPI_FUNCTION_TRACE ("EvDetachRegion");
552 RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
557 RegionContext = &RegionObj2->Extra.RegionContext;
559 /* Get the address handler from the region object */
561 HandlerObj = RegionObj->Region.Handler;
564 /* This region has no handler, all done */
569 /* Find this region in the handler's list */
571 ObjDesc = HandlerObj->AddressSpace.RegionList;
572 LastObjPtr = &HandlerObj->AddressSpace.RegionList;
576 /* Is this the correct Region? */
578 if (ObjDesc == RegionObj)
580 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
581 "Removing Region %p from address handler %p\n",
582 RegionObj, HandlerObj));
584 /* This is it, remove it from the handler's list */
586 *LastObjPtr = ObjDesc->Region.Next;
587 ObjDesc->Region.Next = NULL; /* Must clear field */
591 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
592 if (ACPI_FAILURE (Status))
598 /* Now stop region accesses by executing the _REG method */
600 Status = AcpiEvExecuteRegMethod (RegionObj, 0);
601 if (ACPI_FAILURE (Status))
603 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n",
604 AcpiFormatException (Status),
605 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
610 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
611 if (ACPI_FAILURE (Status))
617 /* Call the setup handler with the deactivate notification */
619 RegionSetup = HandlerObj->AddressSpace.Setup;
620 Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE,
621 HandlerObj->AddressSpace.Context, RegionContext);
623 /* Init routine may fail, Just ignore errors */
625 if (ACPI_FAILURE (Status))
627 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n",
628 AcpiFormatException (Status),
629 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
632 RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
635 * Remove handler reference in the region
637 * NOTE: this doesn't mean that the region goes away
638 * The region is just inaccessible as indicated to
641 * If the region is on the handler's list
642 * this better be the region's handler
644 RegionObj->Region.Handler = NULL;
645 AcpiUtRemoveReference (HandlerObj);
650 /* Walk the linked list of handlers */
652 LastObjPtr = &ObjDesc->Region.Next;
653 ObjDesc = ObjDesc->Region.Next;
656 /* If we get here, the region was not in the handler's region list */
658 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
659 "Cannot remove region %p from address handler %p\n",
660 RegionObj, HandlerObj));
666 /*******************************************************************************
668 * FUNCTION: AcpiEvAttachRegion
670 * PARAMETERS: HandlerObj - Handler Object
671 * RegionObj - Region Object
672 * AcpiNsIsLocked - Namespace Region Already Locked?
676 * DESCRIPTION: Create the association between the handler and the region
677 * this is a two way association.
679 ******************************************************************************/
683 ACPI_OPERAND_OBJECT *HandlerObj,
684 ACPI_OPERAND_OBJECT *RegionObj,
685 BOOLEAN AcpiNsIsLocked)
688 ACPI_FUNCTION_TRACE ("EvAttachRegion");
691 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
692 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
693 AcpiUtGetNodeName (RegionObj->Region.Node),
694 RegionObj, HandlerObj,
695 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
697 /* Link this region to the front of the handler's list */
699 RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
700 HandlerObj->AddressSpace.RegionList = RegionObj;
702 /* Install the region's handler */
704 if (RegionObj->Region.Handler)
706 return_ACPI_STATUS (AE_ALREADY_EXISTS);
709 RegionObj->Region.Handler = HandlerObj;
710 AcpiUtAddReference (HandlerObj);
712 return_ACPI_STATUS (AE_OK);
716 /*******************************************************************************
718 * FUNCTION: AcpiEvInstallHandler
720 * PARAMETERS: WalkNamespace callback
722 * DESCRIPTION: This routine installs an address handler into objects that are
723 * of type Region or Device.
725 * If the Object is a Device, and the device has a handler of
726 * the same type then the search is terminated in that branch.
728 * This is because the existing handler is closer in proximity
729 * to any more regions than the one we are trying to install.
731 ******************************************************************************/
734 AcpiEvInstallHandler (
735 ACPI_HANDLE ObjHandle,
740 ACPI_OPERAND_OBJECT *HandlerObj;
741 ACPI_OPERAND_OBJECT *NextHandlerObj;
742 ACPI_OPERAND_OBJECT *ObjDesc;
743 ACPI_NAMESPACE_NODE *Node;
747 ACPI_FUNCTION_NAME ("EvInstallHandler");
750 HandlerObj = (ACPI_OPERAND_OBJECT *) Context;
752 /* Parameter validation */
759 /* Convert and validate the device handle */
761 Node = AcpiNsMapHandleToNode (ObjHandle);
764 return (AE_BAD_PARAMETER);
768 * We only care about regions.and objects
769 * that are allowed to have address space handlers
771 if ((Node->Type != ACPI_TYPE_DEVICE) &&
772 (Node->Type != ACPI_TYPE_REGION) &&
773 (Node != AcpiGbl_RootNode))
778 /* Check for an existing internal object */
780 ObjDesc = AcpiNsGetAttachedObject (Node);
783 /* No object, just exit */
788 /* Devices are handled different than regions */
790 if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_DEVICE)
792 /* Check if this Device already has a handler for this address space */
794 NextHandlerObj = ObjDesc->Device.Handler;
795 while (NextHandlerObj)
797 /* Found a handler, is it for the same address space? */
799 if (NextHandlerObj->AddressSpace.SpaceId == HandlerObj->AddressSpace.SpaceId)
801 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
802 "Found handler for region [%s] in device %p(%p) handler %p\n",
803 AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
804 ObjDesc, NextHandlerObj, HandlerObj));
807 * Since the object we found it on was a device, then it
808 * means that someone has already installed a handler for
809 * the branch of the namespace from this device on. Just
810 * bail out telling the walk routine to not traverse this
811 * branch. This preserves the scoping rule for handlers.
813 return (AE_CTRL_DEPTH);
816 /* Walk the linked list of handlers attached to this device */
818 NextHandlerObj = NextHandlerObj->AddressSpace.Next;
822 * As long as the device didn't have a handler for this
823 * space we don't care about it. We just ignore it and
829 /* Object is a Region */
831 if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId)
834 * This region is for a different address space
841 * Now we have a region and it is for the handler's address
844 * First disconnect region for any previous handler (if any)
846 AcpiEvDetachRegion (ObjDesc, FALSE);
848 /* Connect the region to the new handler */
850 Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE);
855 /*******************************************************************************
857 * FUNCTION: AcpiEvInstallSpaceHandler
859 * PARAMETERS: Node - Namespace node for the device
860 * SpaceId - The address space ID
861 * Handler - Address of the handler
862 * Setup - Address of the setup function
863 * Context - Value passed to the handler on each access
867 * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId.
868 * Assumes namespace is locked
870 ******************************************************************************/
873 AcpiEvInstallSpaceHandler (
874 ACPI_NAMESPACE_NODE *Node,
875 ACPI_ADR_SPACE_TYPE SpaceId,
876 ACPI_ADR_SPACE_HANDLER Handler,
877 ACPI_ADR_SPACE_SETUP Setup,
880 ACPI_OPERAND_OBJECT *ObjDesc;
881 ACPI_OPERAND_OBJECT *HandlerObj;
883 ACPI_OBJECT_TYPE Type;
887 ACPI_FUNCTION_TRACE ("EvInstallSpaceHandler");
891 * This registration is valid for only the types below
892 * and the root. This is where the default handlers
895 if ((Node->Type != ACPI_TYPE_DEVICE) &&
896 (Node->Type != ACPI_TYPE_PROCESSOR) &&
897 (Node->Type != ACPI_TYPE_THERMAL) &&
898 (Node != AcpiGbl_RootNode))
900 Status = AE_BAD_PARAMETER;
904 if (Handler == ACPI_DEFAULT_HANDLER)
906 Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
910 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
911 Handler = AcpiExSystemMemorySpaceHandler;
912 Setup = AcpiEvSystemMemoryRegionSetup;
915 case ACPI_ADR_SPACE_SYSTEM_IO:
916 Handler = AcpiExSystemIoSpaceHandler;
917 Setup = AcpiEvIoSpaceRegionSetup;
920 case ACPI_ADR_SPACE_PCI_CONFIG:
921 Handler = AcpiExPciConfigSpaceHandler;
922 Setup = AcpiEvPciConfigRegionSetup;
925 case ACPI_ADR_SPACE_CMOS:
926 Handler = AcpiExCmosSpaceHandler;
927 Setup = AcpiEvCmosRegionSetup;
930 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
931 Handler = AcpiExPciBarSpaceHandler;
932 Setup = AcpiEvPciBarRegionSetup;
935 case ACPI_ADR_SPACE_DATA_TABLE:
936 Handler = AcpiExDataTableSpaceHandler;
941 Status = AE_BAD_PARAMETER;
946 /* If the caller hasn't specified a setup routine, use the default */
950 Setup = AcpiEvDefaultRegionSetup;
953 /* Check for an existing internal object */
955 ObjDesc = AcpiNsGetAttachedObject (Node);
959 * The attached device object already exists.
960 * Make sure the handler is not already installed.
962 HandlerObj = ObjDesc->Device.Handler;
964 /* Walk the handler list for this device */
968 /* Same SpaceId indicates a handler already installed */
970 if (HandlerObj->AddressSpace.SpaceId == SpaceId)
972 if (HandlerObj->AddressSpace.Handler == Handler)
975 * It is (relatively) OK to attempt to install the SAME
976 * handler twice. This can easily happen with PCI_Config space.
978 Status = AE_SAME_HANDLER;
983 /* A handler is already installed */
985 Status = AE_ALREADY_EXISTS;
990 /* Walk the linked list of handlers */
992 HandlerObj = HandlerObj->AddressSpace.Next;
997 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
998 "Creating object on Device %p while installing handler\n", Node));
1000 /* ObjDesc does not exist, create one */
1002 if (Node->Type == ACPI_TYPE_ANY)
1004 Type = ACPI_TYPE_DEVICE;
1011 ObjDesc = AcpiUtCreateInternalObject (Type);
1014 Status = AE_NO_MEMORY;
1018 /* Init new descriptor */
1020 ObjDesc->Common.Type = (UINT8) Type;
1022 /* Attach the new object to the Node */
1024 Status = AcpiNsAttachObject (Node, ObjDesc, Type);
1026 /* Remove local reference to the object */
1028 AcpiUtRemoveReference (ObjDesc);
1030 if (ACPI_FAILURE (Status))
1036 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
1037 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
1038 AcpiUtGetRegionName (SpaceId), SpaceId,
1039 AcpiUtGetNodeName (Node), Node, ObjDesc));
1042 * Install the handler
1044 * At this point there is no existing handler.
1045 * Just allocate the object for the handler and link it
1048 HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
1051 Status = AE_NO_MEMORY;
1055 /* Init handler obj */
1057 HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId;
1058 HandlerObj->AddressSpace.Hflags = Flags;
1059 HandlerObj->AddressSpace.RegionList = NULL;
1060 HandlerObj->AddressSpace.Node = Node;
1061 HandlerObj->AddressSpace.Handler = Handler;
1062 HandlerObj->AddressSpace.Context = Context;
1063 HandlerObj->AddressSpace.Setup = Setup;
1065 /* Install at head of Device.AddressSpace list */
1067 HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler;
1070 * The Device object is the first reference on the HandlerObj.
1071 * Each region that uses the handler adds a reference.
1073 ObjDesc->Device.Handler = HandlerObj;
1076 * Walk the namespace finding all of the regions this
1077 * handler will manage.
1079 * Start at the device and search the branch toward
1080 * the leaf nodes until either the leaf is encountered or
1081 * a device is detected that has an address handler of the
1084 * In either case, back up and search down the remainder
1087 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
1088 ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler,
1092 return_ACPI_STATUS (Status);
1096 /*******************************************************************************
1098 * FUNCTION: AcpiEvExecuteRegMethods
1100 * PARAMETERS: Node - Namespace node for the device
1101 * SpaceId - The address space ID
1105 * DESCRIPTION: Run all _REG methods for the input Space ID;
1106 * Note: assumes namespace is locked, or system init time.
1108 ******************************************************************************/
1111 AcpiEvExecuteRegMethods (
1112 ACPI_NAMESPACE_NODE *Node,
1113 ACPI_ADR_SPACE_TYPE SpaceId)
1118 ACPI_FUNCTION_TRACE ("EvExecuteRegMethods");
1122 * Run all _REG methods for all Operation Regions for this
1123 * space ID. This is a separate walk in order to handle any
1124 * interdependencies between regions and _REG methods. (i.e. handlers
1125 * must be installed for all regions of this Space ID before we
1126 * can run any _REG methods)
1128 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
1129 ACPI_NS_WALK_UNLOCK, AcpiEvRegRun,
1132 return_ACPI_STATUS (Status);
1136 /*******************************************************************************
1138 * FUNCTION: AcpiEvRegRun
1140 * PARAMETERS: WalkNamespace callback
1142 * DESCRIPTION: Run _REG method for region objects of the requested spaceID
1144 ******************************************************************************/
1148 ACPI_HANDLE ObjHandle,
1153 ACPI_OPERAND_OBJECT *ObjDesc;
1154 ACPI_NAMESPACE_NODE *Node;
1155 ACPI_ADR_SPACE_TYPE SpaceId;
1159 SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context);
1161 /* Convert and validate the device handle */
1163 Node = AcpiNsMapHandleToNode (ObjHandle);
1166 return (AE_BAD_PARAMETER);
1170 * We only care about regions.and objects
1171 * that are allowed to have address space handlers
1173 if ((Node->Type != ACPI_TYPE_REGION) &&
1174 (Node != AcpiGbl_RootNode))
1179 /* Check for an existing internal object */
1181 ObjDesc = AcpiNsGetAttachedObject (Node);
1184 /* No object, just exit */
1189 /* Object is a Region */
1191 if (ObjDesc->Region.SpaceId != SpaceId)
1194 * This region is for a different address space
1200 Status = AcpiEvExecuteRegMethod (ObjDesc, 1);