|
||||
Warning, cross-references for /kernel/drivers/acpica/evrgnini.c need to be fixed.
0001 /****************************************************************************** 0002 * 0003 * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init 0004 * 0005 *****************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 0117 #define __EVRGNINI_C__ 0118 0119 #include "acpi.h" 0120 #include "accommon.h" 0121 #include "acevents.h" 0122 #include "acnamesp.h" 0123 0124 #define _COMPONENT ACPI_EVENTS 0125 ACPI_MODULE_NAME ("evrgnini") 0126 0127 /* Local prototypes */ 0128 0129 static BOOLEAN 0130 AcpiEvIsPciRootBridge ( 0131 ACPI_NAMESPACE_NODE *Node); 0132 0133 0134 /******************************************************************************* 0135 * 0136 * FUNCTION: AcpiEvSystemMemoryRegionSetup 0137 * 0138 * PARAMETERS: Handle - Region we are interested in 0139 * Function - Start or stop 0140 * HandlerContext - Address space handler context 0141 * RegionContext - Region specific context 0142 * 0143 * RETURN: Status 0144 * 0145 * DESCRIPTION: Setup a SystemMemory operation region 0146 * 0147 ******************************************************************************/ 0148 0149 ACPI_STATUS 0150 AcpiEvSystemMemoryRegionSetup ( 0151 ACPI_HANDLE Handle, 0152 UINT32 Function, 0153 void *HandlerContext, 0154 void **RegionContext) 0155 { 0156 ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; 0157 ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; 0158 0159 0160 ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); 0161 0162 0163 if (Function == ACPI_REGION_DEACTIVATE) 0164 { 0165 if (*RegionContext) 0166 { 0167 LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; 0168 0169 /* Delete a cached mapping if present */ 0170 0171 if (LocalRegionContext->MappedLength) 0172 { 0173 AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, 0174 LocalRegionContext->MappedLength); 0175 } 0176 ACPI_FREE (LocalRegionContext); 0177 *RegionContext = NULL; 0178 } 0179 return_ACPI_STATUS (AE_OK); 0180 } 0181 0182 /* Create a new context */ 0183 0184 LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); 0185 if (!(LocalRegionContext)) 0186 { 0187 return_ACPI_STATUS (AE_NO_MEMORY); 0188 } 0189 0190 /* Save the region length and address for use in the handler */ 0191 0192 LocalRegionContext->Length = RegionDesc->Region.Length; 0193 LocalRegionContext->Address = RegionDesc->Region.Address; 0194 0195 *RegionContext = LocalRegionContext; 0196 return_ACPI_STATUS (AE_OK); 0197 } 0198 0199 0200 /******************************************************************************* 0201 * 0202 * FUNCTION: AcpiEvIoSpaceRegionSetup 0203 * 0204 * PARAMETERS: Handle - Region we are interested in 0205 * Function - Start or stop 0206 * HandlerContext - Address space handler context 0207 * RegionContext - Region specific context 0208 * 0209 * RETURN: Status 0210 * 0211 * DESCRIPTION: Setup a IO operation region 0212 * 0213 ******************************************************************************/ 0214 0215 ACPI_STATUS 0216 AcpiEvIoSpaceRegionSetup ( 0217 ACPI_HANDLE Handle, 0218 UINT32 Function, 0219 void *HandlerContext, 0220 void **RegionContext) 0221 { 0222 ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); 0223 0224 0225 if (Function == ACPI_REGION_DEACTIVATE) 0226 { 0227 *RegionContext = NULL; 0228 } 0229 else 0230 { 0231 *RegionContext = HandlerContext; 0232 } 0233 0234 return_ACPI_STATUS (AE_OK); 0235 } 0236 0237 0238 /******************************************************************************* 0239 * 0240 * FUNCTION: AcpiEvPciConfigRegionSetup 0241 * 0242 * PARAMETERS: Handle - Region we are interested in 0243 * Function - Start or stop 0244 * HandlerContext - Address space handler context 0245 * RegionContext - Region specific context 0246 * 0247 * RETURN: Status 0248 * 0249 * DESCRIPTION: Setup a PCI_Config operation region 0250 * 0251 * MUTEX: Assumes namespace is not locked 0252 * 0253 ******************************************************************************/ 0254 0255 ACPI_STATUS 0256 AcpiEvPciConfigRegionSetup ( 0257 ACPI_HANDLE Handle, 0258 UINT32 Function, 0259 void *HandlerContext, 0260 void **RegionContext) 0261 { 0262 ACPI_STATUS Status = AE_OK; 0263 ACPI_INTEGER PciValue; 0264 ACPI_PCI_ID *PciId = *RegionContext; 0265 ACPI_OPERAND_OBJECT *HandlerObj; 0266 ACPI_NAMESPACE_NODE *ParentNode; 0267 ACPI_NAMESPACE_NODE *PciRootNode; 0268 ACPI_NAMESPACE_NODE *PciDeviceNode; 0269 ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; 0270 0271 0272 ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); 0273 0274 0275 HandlerObj = RegionObj->Region.Handler; 0276 if (!HandlerObj) 0277 { 0278 /* 0279 * No installed handler. This shouldn't happen because the dispatch 0280 * routine checks before we get here, but we check again just in case. 0281 */ 0282 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 0283 "Attempting to init a region %p, with no handler\n", RegionObj)); 0284 return_ACPI_STATUS (AE_NOT_EXIST); 0285 } 0286 0287 *RegionContext = NULL; 0288 if (Function == ACPI_REGION_DEACTIVATE) 0289 { 0290 if (PciId) 0291 { 0292 ACPI_FREE (PciId); 0293 } 0294 return_ACPI_STATUS (Status); 0295 } 0296 0297 ParentNode = AcpiNsGetParentNode (RegionObj->Region.Node); 0298 0299 /* 0300 * Get the _SEG and _BBN values from the device upon which the handler 0301 * is installed. 0302 * 0303 * We need to get the _SEG and _BBN objects relative to the PCI BUS device. 0304 * This is the device the handler has been registered to handle. 0305 */ 0306 0307 /* 0308 * If the AddressSpace.Node is still pointing to the root, we need 0309 * to scan upward for a PCI Root bridge and re-associate the OpRegion 0310 * handlers with that device. 0311 */ 0312 if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) 0313 { 0314 /* Start search from the parent object */ 0315 0316 PciRootNode = ParentNode; 0317 while (PciRootNode != AcpiGbl_RootNode) 0318 { 0319 /* Get the _HID/_CID in order to detect a RootBridge */ 0320 0321 if (AcpiEvIsPciRootBridge (PciRootNode)) 0322 { 0323 /* Install a handler for this PCI root bridge */ 0324 0325 Status = AcpiInstallAddressSpaceHandler ( 0326 (ACPI_HANDLE) PciRootNode, 0327 ACPI_ADR_SPACE_PCI_CONFIG, 0328 ACPI_DEFAULT_HANDLER, NULL, NULL); 0329 if (ACPI_FAILURE (Status)) 0330 { 0331 if (Status == AE_SAME_HANDLER) 0332 { 0333 /* 0334 * It is OK if the handler is already installed on the 0335 * root bridge. Still need to return a context object 0336 * for the new PCI_Config operation region, however. 0337 */ 0338 Status = AE_OK; 0339 } 0340 else 0341 { 0342 ACPI_EXCEPTION ((AE_INFO, Status, 0343 "Could not install PciConfig handler " 0344 "for Root Bridge %4.4s", 0345 AcpiUtGetNodeName (PciRootNode))); 0346 } 0347 } 0348 break; 0349 } 0350 0351 PciRootNode = AcpiNsGetParentNode (PciRootNode); 0352 } 0353 0354 /* PCI root bridge not found, use namespace root node */ 0355 } 0356 else 0357 { 0358 PciRootNode = HandlerObj->AddressSpace.Node; 0359 } 0360 0361 /* 0362 * If this region is now initialized, we are done. 0363 * (InstallAddressSpaceHandler could have initialized it) 0364 */ 0365 if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) 0366 { 0367 return_ACPI_STATUS (AE_OK); 0368 } 0369 0370 /* Region is still not initialized. Create a new context */ 0371 0372 PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); 0373 if (!PciId) 0374 { 0375 return_ACPI_STATUS (AE_NO_MEMORY); 0376 } 0377 0378 /* 0379 * For PCI_Config space access, we need the segment, bus, device and 0380 * function numbers. Acquire them here. 0381 * 0382 * Find the parent device object. (This allows the operation region to be 0383 * within a subscope under the device, such as a control method.) 0384 */ 0385 PciDeviceNode = RegionObj->Region.Node; 0386 while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) 0387 { 0388 PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); 0389 } 0390 0391 if (!PciDeviceNode) 0392 { 0393 ACPI_FREE (PciId); 0394 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 0395 } 0396 0397 /* 0398 * Get the PCI device and function numbers from the _ADR object contained 0399 * in the parent's scope. 0400 */ 0401 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, 0402 PciDeviceNode, &PciValue); 0403 0404 /* 0405 * The default is zero, and since the allocation above zeroed the data, 0406 * just do nothing on failure. 0407 */ 0408 if (ACPI_SUCCESS (Status)) 0409 { 0410 PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); 0411 PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); 0412 } 0413 0414 /* The PCI segment number comes from the _SEG method */ 0415 0416 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, 0417 PciRootNode, &PciValue); 0418 if (ACPI_SUCCESS (Status)) 0419 { 0420 PciId->Segment = ACPI_LOWORD (PciValue); 0421 } 0422 0423 /* The PCI bus number comes from the _BBN method */ 0424 0425 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, 0426 PciRootNode, &PciValue); 0427 if (ACPI_SUCCESS (Status)) 0428 { 0429 PciId->Bus = ACPI_LOWORD (PciValue); 0430 } 0431 0432 /* Complete this device's PciId */ 0433 0434 AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); 0435 0436 *RegionContext = PciId; 0437 return_ACPI_STATUS (AE_OK); 0438 } 0439 0440 0441 /******************************************************************************* 0442 * 0443 * FUNCTION: AcpiEvIsPciRootBridge 0444 * 0445 * PARAMETERS: Node - Device node being examined 0446 * 0447 * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge 0448 * 0449 * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by 0450 * examining the _HID and _CID for the device. 0451 * 0452 ******************************************************************************/ 0453 0454 static BOOLEAN 0455 AcpiEvIsPciRootBridge ( 0456 ACPI_NAMESPACE_NODE *Node) 0457 { 0458 ACPI_STATUS Status; 0459 ACPI_DEVICE_ID *Hid; 0460 ACPI_DEVICE_ID_LIST *Cid; 0461 UINT32 i; 0462 BOOLEAN Match; 0463 0464 0465 /* Get the _HID and check for a PCI Root Bridge */ 0466 0467 Status = AcpiUtExecute_HID (Node, &Hid); 0468 if (ACPI_FAILURE (Status)) 0469 { 0470 return (FALSE); 0471 } 0472 0473 Match = AcpiUtIsPciRootBridge (Hid->String); 0474 ACPI_FREE (Hid); 0475 0476 if (Match) 0477 { 0478 return (TRUE); 0479 } 0480 0481 /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ 0482 0483 Status = AcpiUtExecute_CID (Node, &Cid); 0484 if (ACPI_FAILURE (Status)) 0485 { 0486 return (FALSE); 0487 } 0488 0489 /* Check all _CIDs in the returned list */ 0490 0491 for (i = 0; i < Cid->Count; i++) 0492 { 0493 if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) 0494 { 0495 ACPI_FREE (Cid); 0496 return (TRUE); 0497 } 0498 } 0499 0500 ACPI_FREE (Cid); 0501 return (FALSE); 0502 } 0503 0504 0505 /******************************************************************************* 0506 * 0507 * FUNCTION: AcpiEvPciBarRegionSetup 0508 * 0509 * PARAMETERS: Handle - Region we are interested in 0510 * Function - Start or stop 0511 * HandlerContext - Address space handler context 0512 * RegionContext - Region specific context 0513 * 0514 * RETURN: Status 0515 * 0516 * DESCRIPTION: Setup a PciBAR operation region 0517 * 0518 * MUTEX: Assumes namespace is not locked 0519 * 0520 ******************************************************************************/ 0521 0522 ACPI_STATUS 0523 AcpiEvPciBarRegionSetup ( 0524 ACPI_HANDLE Handle, 0525 UINT32 Function, 0526 void *HandlerContext, 0527 void **RegionContext) 0528 { 0529 ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); 0530 0531 0532 return_ACPI_STATUS (AE_OK); 0533 } 0534 0535 0536 /******************************************************************************* 0537 * 0538 * FUNCTION: AcpiEvCmosRegionSetup 0539 * 0540 * PARAMETERS: Handle - Region we are interested in 0541 * Function - Start or stop 0542 * HandlerContext - Address space handler context 0543 * RegionContext - Region specific context 0544 * 0545 * RETURN: Status 0546 * 0547 * DESCRIPTION: Setup a CMOS operation region 0548 * 0549 * MUTEX: Assumes namespace is not locked 0550 * 0551 ******************************************************************************/ 0552 0553 ACPI_STATUS 0554 AcpiEvCmosRegionSetup ( 0555 ACPI_HANDLE Handle, 0556 UINT32 Function, 0557 void *HandlerContext, 0558 void **RegionContext) 0559 { 0560 ACPI_FUNCTION_TRACE (EvCmosRegionSetup); 0561 0562 0563 return_ACPI_STATUS (AE_OK); 0564 } 0565 0566 0567 /******************************************************************************* 0568 * 0569 * FUNCTION: AcpiEvDefaultRegionSetup 0570 * 0571 * PARAMETERS: Handle - Region we are interested in 0572 * Function - Start or stop 0573 * HandlerContext - Address space handler context 0574 * RegionContext - Region specific context 0575 * 0576 * RETURN: Status 0577 * 0578 * DESCRIPTION: Default region initialization 0579 * 0580 ******************************************************************************/ 0581 0582 ACPI_STATUS 0583 AcpiEvDefaultRegionSetup ( 0584 ACPI_HANDLE Handle, 0585 UINT32 Function, 0586 void *HandlerContext, 0587 void **RegionContext) 0588 { 0589 ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); 0590 0591 0592 if (Function == ACPI_REGION_DEACTIVATE) 0593 { 0594 *RegionContext = NULL; 0595 } 0596 else 0597 { 0598 *RegionContext = HandlerContext; 0599 } 0600 0601 return_ACPI_STATUS (AE_OK); 0602 } 0603 0604 0605 /******************************************************************************* 0606 * 0607 * FUNCTION: AcpiEvInitializeRegion 0608 * 0609 * PARAMETERS: RegionObj - Region we are initializing 0610 * AcpiNsLocked - Is namespace locked? 0611 * 0612 * RETURN: Status 0613 * 0614 * DESCRIPTION: Initializes the region, finds any _REG methods and saves them 0615 * for execution at a later time 0616 * 0617 * Get the appropriate address space handler for a newly 0618 * created region. 0619 * 0620 * This also performs address space specific initialization. For 0621 * example, PCI regions must have an _ADR object that contains 0622 * a PCI address in the scope of the definition. This address is 0623 * required to perform an access to PCI config space. 0624 * 0625 * MUTEX: Interpreter should be unlocked, because we may run the _REG 0626 * method for this region. 0627 * 0628 ******************************************************************************/ 0629 0630 ACPI_STATUS 0631 AcpiEvInitializeRegion ( 0632 ACPI_OPERAND_OBJECT *RegionObj, 0633 BOOLEAN AcpiNsLocked) 0634 { 0635 ACPI_OPERAND_OBJECT *HandlerObj; 0636 ACPI_OPERAND_OBJECT *ObjDesc; 0637 ACPI_ADR_SPACE_TYPE SpaceId; 0638 ACPI_NAMESPACE_NODE *Node; 0639 ACPI_STATUS Status; 0640 ACPI_NAMESPACE_NODE *MethodNode; 0641 ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; 0642 ACPI_OPERAND_OBJECT *RegionObj2; 0643 0644 0645 ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); 0646 0647 0648 if (!RegionObj) 0649 { 0650 return_ACPI_STATUS (AE_BAD_PARAMETER); 0651 } 0652 0653 if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) 0654 { 0655 return_ACPI_STATUS (AE_OK); 0656 } 0657 0658 RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); 0659 if (!RegionObj2) 0660 { 0661 return_ACPI_STATUS (AE_NOT_EXIST); 0662 } 0663 0664 Node = AcpiNsGetParentNode (RegionObj->Region.Node); 0665 SpaceId = RegionObj->Region.SpaceId; 0666 0667 /* Setup defaults */ 0668 0669 RegionObj->Region.Handler = NULL; 0670 RegionObj2->Extra.Method_REG = NULL; 0671 RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); 0672 RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; 0673 0674 /* Find any "_REG" method associated with this region definition */ 0675 0676 Status = AcpiNsSearchOneScope ( 0677 *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); 0678 if (ACPI_SUCCESS (Status)) 0679 { 0680 /* 0681 * The _REG method is optional and there can be only one per region 0682 * definition. This will be executed when the handler is attached 0683 * or removed 0684 */ 0685 RegionObj2->Extra.Method_REG = MethodNode; 0686 } 0687 0688 /* 0689 * The following loop depends upon the root Node having no parent 0690 * ie: AcpiGbl_RootNode->ParentEntry being set to NULL 0691 */ 0692 while (Node) 0693 { 0694 /* Check to see if a handler exists */ 0695 0696 HandlerObj = NULL; 0697 ObjDesc = AcpiNsGetAttachedObject (Node); 0698 if (ObjDesc) 0699 { 0700 /* Can only be a handler if the object exists */ 0701 0702 switch (Node->Type) 0703 { 0704 case ACPI_TYPE_DEVICE: 0705 0706 HandlerObj = ObjDesc->Device.Handler; 0707 break; 0708 0709 case ACPI_TYPE_PROCESSOR: 0710 0711 HandlerObj = ObjDesc->Processor.Handler; 0712 break; 0713 0714 case ACPI_TYPE_THERMAL: 0715 0716 HandlerObj = ObjDesc->ThermalZone.Handler; 0717 break; 0718 0719 default: 0720 /* Ignore other objects */ 0721 break; 0722 } 0723 0724 while (HandlerObj) 0725 { 0726 /* Is this handler of the correct type? */ 0727 0728 if (HandlerObj->AddressSpace.SpaceId == SpaceId) 0729 { 0730 /* Found correct handler */ 0731 0732 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 0733 "Found handler %p for region %p in obj %p\n", 0734 HandlerObj, RegionObj, ObjDesc)); 0735 0736 Status = AcpiEvAttachRegion (HandlerObj, RegionObj, 0737 AcpiNsLocked); 0738 0739 /* 0740 * Tell all users that this region is usable by 0741 * running the _REG method 0742 */ 0743 if (AcpiNsLocked) 0744 { 0745 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0746 if (ACPI_FAILURE (Status)) 0747 { 0748 return_ACPI_STATUS (Status); 0749 } 0750 } 0751 0752 Status = AcpiEvExecuteRegMethod (RegionObj, 1); 0753 0754 if (AcpiNsLocked) 0755 { 0756 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 0757 if (ACPI_FAILURE (Status)) 0758 { 0759 return_ACPI_STATUS (Status); 0760 } 0761 } 0762 0763 return_ACPI_STATUS (AE_OK); 0764 } 0765 0766 /* Try next handler in the list */ 0767 0768 HandlerObj = HandlerObj->AddressSpace.Next; 0769 } 0770 } 0771 0772 /* This node does not have the handler we need; Pop up one level */ 0773 0774 Node = AcpiNsGetParentNode (Node); 0775 } 0776 0777 /* If we get here, there is no handler for this region */ 0778 0779 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 0780 "No handler for RegionType %s(%X) (RegionObj %p)\n", 0781 AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); 0782 0783 return_ACPI_STATUS (AE_NOT_EXIST); 0784 } 0785
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |