![]() |
|
|||
File indexing completed on 2025-05-11 08:24:03
0001 /****************************************************************************** 0002 * 0003 * Module Name: nsinit - namespace initialization 0004 * 0005 *****************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2024, 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 * Alternatively, you may choose to be licensed under the terms of the 0117 * following license: 0118 * 0119 * Redistribution and use in source and binary forms, with or without 0120 * modification, are permitted provided that the following conditions 0121 * are met: 0122 * 1. Redistributions of source code must retain the above copyright 0123 * notice, this list of conditions, and the following disclaimer, 0124 * without modification. 0125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0126 * substantially similar to the "NO WARRANTY" disclaimer below 0127 * ("Disclaimer") and any redistribution must be conditioned upon 0128 * including a substantially similar Disclaimer requirement for further 0129 * binary redistribution. 0130 * 3. Neither the names of the above-listed copyright holders nor the names 0131 * of any contributors may be used to endorse or promote products derived 0132 * from this software without specific prior written permission. 0133 * 0134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0145 * 0146 * Alternatively, you may choose to be licensed under the terms of the 0147 * GNU General Public License ("GPL") version 2 as published by the Free 0148 * Software Foundation. 0149 * 0150 *****************************************************************************/ 0151 0152 #include "acpi.h" 0153 #include "accommon.h" 0154 #include "acnamesp.h" 0155 #include "acdispat.h" 0156 #include "acinterp.h" 0157 #include "acevents.h" 0158 0159 #define _COMPONENT ACPI_NAMESPACE 0160 ACPI_MODULE_NAME ("nsinit") 0161 0162 /* Local prototypes */ 0163 0164 static ACPI_STATUS 0165 AcpiNsInitOneObject ( 0166 ACPI_HANDLE ObjHandle, 0167 UINT32 Level, 0168 void *Context, 0169 void **ReturnValue); 0170 0171 static ACPI_STATUS 0172 AcpiNsInitOneDevice ( 0173 ACPI_HANDLE ObjHandle, 0174 UINT32 NestingLevel, 0175 void *Context, 0176 void **ReturnValue); 0177 0178 static ACPI_STATUS 0179 AcpiNsFindIniMethods ( 0180 ACPI_HANDLE ObjHandle, 0181 UINT32 NestingLevel, 0182 void *Context, 0183 void **ReturnValue); 0184 0185 0186 /******************************************************************************* 0187 * 0188 * FUNCTION: AcpiNsInitializeObjects 0189 * 0190 * PARAMETERS: None 0191 * 0192 * RETURN: Status 0193 * 0194 * DESCRIPTION: Walk the entire namespace and perform any necessary 0195 * initialization on the objects found therein 0196 * 0197 ******************************************************************************/ 0198 0199 ACPI_STATUS 0200 AcpiNsInitializeObjects ( 0201 void) 0202 { 0203 ACPI_STATUS Status; 0204 ACPI_INIT_WALK_INFO Info; 0205 0206 0207 ACPI_FUNCTION_TRACE (NsInitializeObjects); 0208 0209 0210 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0211 "[Init] Completing Initialization of ACPI Objects\n")); 0212 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 0213 "**** Starting initialization of namespace objects ****\n")); 0214 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 0215 "Final data object initialization: ")); 0216 0217 /* Clear the info block */ 0218 0219 memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); 0220 0221 /* Walk entire namespace from the supplied root */ 0222 0223 /* 0224 * TBD: will become ACPI_TYPE_PACKAGE as this type object 0225 * is now the only one that supports deferred initialization 0226 * (forward references). 0227 */ 0228 Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 0229 ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, &Info, NULL); 0230 if (ACPI_FAILURE (Status)) 0231 { 0232 ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); 0233 } 0234 0235 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 0236 "Namespace contains %u (0x%X) objects\n", 0237 Info.ObjectCount, 0238 Info.ObjectCount)); 0239 0240 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 0241 "%u Control Methods found\n%u Op Regions found\n", 0242 Info.MethodCount, Info.OpRegionCount)); 0243 0244 return_ACPI_STATUS (AE_OK); 0245 } 0246 0247 0248 /******************************************************************************* 0249 * 0250 * FUNCTION: AcpiNsInitializeDevices 0251 * 0252 * PARAMETERS: None 0253 * 0254 * RETURN: ACPI_STATUS 0255 * 0256 * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. 0257 * This means running _INI on all present devices. 0258 * 0259 * Note: We install PCI config space handler on region access, 0260 * not here. 0261 * 0262 ******************************************************************************/ 0263 0264 ACPI_STATUS 0265 AcpiNsInitializeDevices ( 0266 UINT32 Flags) 0267 { 0268 ACPI_STATUS Status = AE_OK; 0269 ACPI_DEVICE_WALK_INFO Info; 0270 ACPI_HANDLE Handle; 0271 0272 0273 ACPI_FUNCTION_TRACE (NsInitializeDevices); 0274 0275 0276 if (!(Flags & ACPI_NO_DEVICE_INIT)) 0277 { 0278 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0279 "[Init] Initializing ACPI Devices\n")); 0280 0281 /* Init counters */ 0282 0283 Info.DeviceCount = 0; 0284 Info.Num_STA = 0; 0285 Info.Num_INI = 0; 0286 0287 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 0288 "Initializing Device/Processor/Thermal objects " 0289 "and executing _INI/_STA methods:\n")); 0290 0291 /* Tree analysis: find all subtrees that contain _INI methods */ 0292 0293 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 0294 ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); 0295 if (ACPI_FAILURE (Status)) 0296 { 0297 goto ErrorExit; 0298 } 0299 0300 /* Allocate the evaluation information block */ 0301 0302 Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 0303 if (!Info.EvaluateInfo) 0304 { 0305 Status = AE_NO_MEMORY; 0306 goto ErrorExit; 0307 } 0308 0309 /* 0310 * Execute the "global" _INI method that may appear at the root. 0311 * This support is provided for Windows compatibility (Vista+) and 0312 * is not part of the ACPI specification. 0313 */ 0314 Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; 0315 Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; 0316 Info.EvaluateInfo->Parameters = NULL; 0317 Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; 0318 0319 Status = AcpiNsEvaluate (Info.EvaluateInfo); 0320 if (ACPI_SUCCESS (Status)) 0321 { 0322 Info.Num_INI++; 0323 } 0324 0325 /* 0326 * Execute \_SB._INI. 0327 * There appears to be a strict order requirement for \_SB._INI, 0328 * which should be evaluated before any _REG evaluations. 0329 */ 0330 Status = AcpiGetHandle (NULL, "\\_SB", &Handle); 0331 if (ACPI_SUCCESS (Status)) 0332 { 0333 memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); 0334 Info.EvaluateInfo->PrefixNode = Handle; 0335 Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; 0336 Info.EvaluateInfo->Parameters = NULL; 0337 Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; 0338 0339 Status = AcpiNsEvaluate (Info.EvaluateInfo); 0340 if (ACPI_SUCCESS (Status)) 0341 { 0342 Info.Num_INI++; 0343 } 0344 } 0345 } 0346 0347 /* 0348 * Run all _REG methods 0349 * 0350 * Note: Any objects accessed by the _REG methods will be automatically 0351 * initialized, even if they contain executable AML (see the call to 0352 * AcpiNsInitializeObjects below). 0353 * 0354 * Note: According to the ACPI specification, we actually needn't execute 0355 * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config 0356 * operation regions, it is required to evaluate _REG for those on a PCI 0357 * root bus that doesn't contain _BBN object. So this code is kept here 0358 * in order not to break things. 0359 */ 0360 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) 0361 { 0362 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0363 "[Init] Executing _REG OpRegion methods\n")); 0364 0365 Status = AcpiEvInitializeOpRegions (); 0366 if (ACPI_FAILURE (Status)) 0367 { 0368 goto ErrorExit; 0369 } 0370 } 0371 0372 if (!(Flags & ACPI_NO_DEVICE_INIT)) 0373 { 0374 /* Walk namespace to execute all _INIs on present devices */ 0375 0376 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 0377 ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); 0378 0379 /* 0380 * Any _OSI requests should be completed by now. If the BIOS has 0381 * requested any Windows OSI strings, we will always truncate 0382 * I/O addresses to 16 bits -- for Windows compatibility. 0383 */ 0384 if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) 0385 { 0386 AcpiGbl_TruncateIoAddresses = TRUE; 0387 } 0388 0389 ACPI_FREE (Info.EvaluateInfo); 0390 if (ACPI_FAILURE (Status)) 0391 { 0392 goto ErrorExit; 0393 } 0394 0395 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 0396 " Executed %u _INI methods requiring %u _STA executions " 0397 "(examined %u objects)\n", 0398 Info.Num_INI, Info.Num_STA, Info.DeviceCount)); 0399 } 0400 0401 return_ACPI_STATUS (Status); 0402 0403 0404 ErrorExit: 0405 ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); 0406 return_ACPI_STATUS (Status); 0407 } 0408 0409 0410 /******************************************************************************* 0411 * 0412 * FUNCTION: AcpiNsInitOnePackage 0413 * 0414 * PARAMETERS: ObjHandle - Node 0415 * Level - Current nesting level 0416 * Context - Not used 0417 * ReturnValue - Not used 0418 * 0419 * RETURN: Status 0420 * 0421 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every package 0422 * within the namespace. Used during dynamic load of an SSDT. 0423 * 0424 ******************************************************************************/ 0425 0426 ACPI_STATUS 0427 AcpiNsInitOnePackage ( 0428 ACPI_HANDLE ObjHandle, 0429 UINT32 Level, 0430 void *Context, 0431 void **ReturnValue) 0432 { 0433 ACPI_STATUS Status; 0434 ACPI_OPERAND_OBJECT *ObjDesc; 0435 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 0436 0437 0438 ObjDesc = AcpiNsGetAttachedObject (Node); 0439 if (!ObjDesc) 0440 { 0441 return (AE_OK); 0442 } 0443 0444 /* Exit if package is already initialized */ 0445 0446 if (ObjDesc->Package.Flags & AOPOBJ_DATA_VALID) 0447 { 0448 return (AE_OK); 0449 } 0450 0451 Status = AcpiDsGetPackageArguments (ObjDesc); 0452 if (ACPI_FAILURE (Status)) 0453 { 0454 return (AE_OK); 0455 } 0456 0457 Status = AcpiUtWalkPackageTree (ObjDesc, NULL, AcpiDsInitPackageElement, 0458 NULL); 0459 if (ACPI_FAILURE (Status)) 0460 { 0461 return (AE_OK); 0462 } 0463 0464 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; 0465 return (AE_OK); 0466 } 0467 0468 0469 /******************************************************************************* 0470 * 0471 * FUNCTION: AcpiNsInitOneObject 0472 * 0473 * PARAMETERS: ObjHandle - Node 0474 * Level - Current nesting level 0475 * Context - Points to a init info struct 0476 * ReturnValue - Not used 0477 * 0478 * RETURN: Status 0479 * 0480 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object 0481 * within the namespace. 0482 * 0483 * Currently, the only objects that require initialization are: 0484 * 1) Methods 0485 * 2) Op Regions 0486 * 0487 ******************************************************************************/ 0488 0489 static ACPI_STATUS 0490 AcpiNsInitOneObject ( 0491 ACPI_HANDLE ObjHandle, 0492 UINT32 Level, 0493 void *Context, 0494 void **ReturnValue) 0495 { 0496 ACPI_OBJECT_TYPE Type; 0497 ACPI_STATUS Status = AE_OK; 0498 ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; 0499 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 0500 ACPI_OPERAND_OBJECT *ObjDesc; 0501 0502 0503 ACPI_FUNCTION_NAME (NsInitOneObject); 0504 0505 0506 Info->ObjectCount++; 0507 0508 /* And even then, we are only interested in a few object types */ 0509 0510 Type = AcpiNsGetType (ObjHandle); 0511 ObjDesc = AcpiNsGetAttachedObject (Node); 0512 if (!ObjDesc) 0513 { 0514 return (AE_OK); 0515 } 0516 0517 /* Increment counters for object types we are looking for */ 0518 0519 switch (Type) 0520 { 0521 case ACPI_TYPE_REGION: 0522 0523 Info->OpRegionCount++; 0524 break; 0525 0526 case ACPI_TYPE_BUFFER_FIELD: 0527 0528 Info->FieldCount++; 0529 break; 0530 0531 case ACPI_TYPE_LOCAL_BANK_FIELD: 0532 0533 Info->FieldCount++; 0534 break; 0535 0536 case ACPI_TYPE_BUFFER: 0537 0538 Info->BufferCount++; 0539 break; 0540 0541 case ACPI_TYPE_PACKAGE: 0542 0543 Info->PackageCount++; 0544 break; 0545 0546 default: 0547 0548 /* No init required, just exit now */ 0549 0550 return (AE_OK); 0551 } 0552 0553 /* If the object is already initialized, nothing else to do */ 0554 0555 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 0556 { 0557 return (AE_OK); 0558 } 0559 0560 /* Must lock the interpreter before executing AML code */ 0561 0562 AcpiExEnterInterpreter (); 0563 0564 /* 0565 * Only initialization of Package objects can be deferred, in order 0566 * to support forward references. 0567 */ 0568 switch (Type) 0569 { 0570 case ACPI_TYPE_LOCAL_BANK_FIELD: 0571 0572 /* TBD: BankFields do not require deferred init, remove this code */ 0573 0574 Info->FieldInit++; 0575 Status = AcpiDsGetBankFieldArguments (ObjDesc); 0576 break; 0577 0578 case ACPI_TYPE_PACKAGE: 0579 0580 /* Complete the initialization/resolution of the package object */ 0581 0582 Info->PackageInit++; 0583 Status = AcpiNsInitOnePackage (ObjHandle, Level, NULL, NULL); 0584 break; 0585 0586 default: 0587 0588 /* No other types should get here */ 0589 0590 Status = AE_TYPE; 0591 ACPI_EXCEPTION ((AE_INFO, Status, 0592 "Opcode is not deferred [%4.4s] (%s)", 0593 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); 0594 break; 0595 } 0596 0597 if (ACPI_FAILURE (Status)) 0598 { 0599 ACPI_EXCEPTION ((AE_INFO, Status, 0600 "Could not execute arguments for [%4.4s] (%s)", 0601 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); 0602 } 0603 0604 /* 0605 * We ignore errors from above, and always return OK, since we don't want 0606 * to abort the walk on any single error. 0607 */ 0608 AcpiExExitInterpreter (); 0609 return (AE_OK); 0610 } 0611 0612 0613 /******************************************************************************* 0614 * 0615 * FUNCTION: AcpiNsFindIniMethods 0616 * 0617 * PARAMETERS: ACPI_WALK_CALLBACK 0618 * 0619 * RETURN: ACPI_STATUS 0620 * 0621 * DESCRIPTION: Called during namespace walk. Finds objects named _INI under 0622 * device/processor/thermal objects, and marks the entire subtree 0623 * with a SUBTREE_HAS_INI flag. This flag is used during the 0624 * subsequent device initialization walk to avoid entire subtrees 0625 * that do not contain an _INI. 0626 * 0627 ******************************************************************************/ 0628 0629 static ACPI_STATUS 0630 AcpiNsFindIniMethods ( 0631 ACPI_HANDLE ObjHandle, 0632 UINT32 NestingLevel, 0633 void *Context, 0634 void **ReturnValue) 0635 { 0636 ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); 0637 ACPI_NAMESPACE_NODE *Node; 0638 ACPI_NAMESPACE_NODE *ParentNode; 0639 0640 0641 /* Keep count of device/processor/thermal objects */ 0642 0643 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 0644 if ((Node->Type == ACPI_TYPE_DEVICE) || 0645 (Node->Type == ACPI_TYPE_PROCESSOR) || 0646 (Node->Type == ACPI_TYPE_THERMAL)) 0647 { 0648 Info->DeviceCount++; 0649 return (AE_OK); 0650 } 0651 0652 /* We are only looking for methods named _INI */ 0653 0654 if (!ACPI_COMPARE_NAMESEG (Node->Name.Ascii, METHOD_NAME__INI)) 0655 { 0656 return (AE_OK); 0657 } 0658 0659 /* 0660 * The only _INI methods that we care about are those that are 0661 * present under Device, Processor, and Thermal objects. 0662 */ 0663 ParentNode = Node->Parent; 0664 switch (ParentNode->Type) 0665 { 0666 case ACPI_TYPE_DEVICE: 0667 case ACPI_TYPE_PROCESSOR: 0668 case ACPI_TYPE_THERMAL: 0669 0670 /* Mark parent and bubble up the INI present flag to the root */ 0671 0672 while (ParentNode) 0673 { 0674 ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; 0675 ParentNode = ParentNode->Parent; 0676 } 0677 break; 0678 0679 default: 0680 0681 break; 0682 } 0683 0684 return (AE_OK); 0685 } 0686 0687 0688 /******************************************************************************* 0689 * 0690 * FUNCTION: AcpiNsInitOneDevice 0691 * 0692 * PARAMETERS: ACPI_WALK_CALLBACK 0693 * 0694 * RETURN: ACPI_STATUS 0695 * 0696 * DESCRIPTION: This is called once per device soon after ACPI is enabled 0697 * to initialize each device. It determines if the device is 0698 * present, and if so, calls _INI. 0699 * 0700 ******************************************************************************/ 0701 0702 static ACPI_STATUS 0703 AcpiNsInitOneDevice ( 0704 ACPI_HANDLE ObjHandle, 0705 UINT32 NestingLevel, 0706 void *Context, 0707 void **ReturnValue) 0708 { 0709 ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); 0710 ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; 0711 UINT32 Flags; 0712 ACPI_STATUS Status; 0713 ACPI_NAMESPACE_NODE *DeviceNode; 0714 0715 0716 ACPI_FUNCTION_TRACE (NsInitOneDevice); 0717 0718 0719 /* We are interested in Devices, Processors and ThermalZones only */ 0720 0721 DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 0722 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 0723 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 0724 (DeviceNode->Type != ACPI_TYPE_THERMAL)) 0725 { 0726 return_ACPI_STATUS (AE_OK); 0727 } 0728 0729 /* 0730 * Because of an earlier namespace analysis, all subtrees that contain an 0731 * _INI method are tagged. 0732 * 0733 * If this device subtree does not contain any _INI methods, we 0734 * can exit now and stop traversing this entire subtree. 0735 */ 0736 if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) 0737 { 0738 return_ACPI_STATUS (AE_CTRL_DEPTH); 0739 } 0740 0741 /* 0742 * Run _STA to determine if this device is present and functioning. We 0743 * must know this information for two important reasons (from ACPI spec): 0744 * 0745 * 1) We can only run _INI if the device is present. 0746 * 2) We must abort the device tree walk on this subtree if the device is 0747 * not present and is not functional (we will not examine the children) 0748 * 0749 * The _STA method is not required to be present under the device, we 0750 * assume the device is present if _STA does not exist. 0751 */ 0752 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 0753 ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); 0754 0755 Status = AcpiUtExecute_STA (DeviceNode, &Flags); 0756 if (ACPI_FAILURE (Status)) 0757 { 0758 /* Ignore error and move on to next device */ 0759 0760 return_ACPI_STATUS (AE_OK); 0761 } 0762 0763 /* 0764 * Flags == -1 means that _STA was not found. In this case, we assume that 0765 * the device is both present and functional. 0766 * 0767 * From the ACPI spec, description of _STA: 0768 * 0769 * "If a device object (including the processor object) does not have an 0770 * _STA object, then OSPM assumes that all of the above bits are set (in 0771 * other words, the device is present, ..., and functioning)" 0772 */ 0773 if (Flags != ACPI_UINT32_MAX) 0774 { 0775 WalkInfo->Num_STA++; 0776 } 0777 0778 /* 0779 * Examine the PRESENT and FUNCTIONING status bits 0780 * 0781 * Note: ACPI spec does not seem to specify behavior for the present but 0782 * not functioning case, so we assume functioning if present. 0783 */ 0784 if (!(Flags & ACPI_STA_DEVICE_PRESENT)) 0785 { 0786 /* Device is not present, we must examine the Functioning bit */ 0787 0788 if (Flags & ACPI_STA_DEVICE_FUNCTIONING) 0789 { 0790 /* 0791 * Device is not present but is "functioning". In this case, 0792 * we will not run _INI, but we continue to examine the children 0793 * of this device. 0794 * 0795 * From the ACPI spec, description of _STA: (Note - no mention 0796 * of whether to run _INI or not on the device in question) 0797 * 0798 * "_STA may return bit 0 clear (not present) with bit 3 set 0799 * (device is functional). This case is used to indicate a valid 0800 * device for which no device driver should be loaded (for example, 0801 * a bridge device.) Children of this device may be present and 0802 * valid. OSPM should continue enumeration below a device whose 0803 * _STA returns this bit combination" 0804 */ 0805 return_ACPI_STATUS (AE_OK); 0806 } 0807 else 0808 { 0809 /* 0810 * Device is not present and is not functioning. We must abort the 0811 * walk of this subtree immediately -- don't look at the children 0812 * of such a device. 0813 * 0814 * From the ACPI spec, description of _INI: 0815 * 0816 * "If the _STA method indicates that the device is not present, 0817 * OSPM will not run the _INI and will not examine the children 0818 * of the device for _INI methods" 0819 */ 0820 return_ACPI_STATUS (AE_CTRL_DEPTH); 0821 } 0822 } 0823 0824 /* 0825 * The device is present or is assumed present if no _STA exists. 0826 * Run the _INI if it exists (not required to exist) 0827 * 0828 * Note: We know there is an _INI within this subtree, but it may not be 0829 * under this particular device, it may be lower in the branch. 0830 */ 0831 if (!ACPI_COMPARE_NAMESEG (DeviceNode->Name.Ascii, "_SB_") || 0832 DeviceNode->Parent != AcpiGbl_RootNode) 0833 { 0834 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 0835 ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); 0836 0837 memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); 0838 Info->PrefixNode = DeviceNode; 0839 Info->RelativePathname = METHOD_NAME__INI; 0840 Info->Parameters = NULL; 0841 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 0842 0843 Status = AcpiNsEvaluate (Info); 0844 if (ACPI_SUCCESS (Status)) 0845 { 0846 WalkInfo->Num_INI++; 0847 } 0848 0849 #ifdef ACPI_DEBUG_OUTPUT 0850 else if (Status != AE_NOT_FOUND) 0851 { 0852 /* Ignore error and move on to next device */ 0853 0854 char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); 0855 0856 ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", 0857 ScopeName)); 0858 ACPI_FREE (ScopeName); 0859 } 0860 #endif 0861 } 0862 0863 /* Ignore errors from above */ 0864 0865 Status = AE_OK; 0866 0867 /* 0868 * The _INI method has been run if present; call the Global Initialization 0869 * Handler for this device. 0870 */ 0871 if (AcpiGbl_InitHandler) 0872 { 0873 Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); 0874 } 0875 0876 return_ACPI_STATUS (Status); 0877 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |