![]() |
|
|||
File indexing completed on 2025-05-11 08:24:03
0001 /****************************************************************************** 0002 * 0003 * Module Name: nsxfname - Public interfaces to the ACPI subsystem 0004 * ACPI Namespace oriented interfaces 0005 * 0006 *****************************************************************************/ 0007 0008 /****************************************************************************** 0009 * 0010 * 1. Copyright Notice 0011 * 0012 * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 0013 * All rights reserved. 0014 * 0015 * 2. License 0016 * 0017 * 2.1. This is your license from Intel Corp. under its intellectual property 0018 * rights. You may have additional license terms from the party that provided 0019 * you this software, covering your right to use that party's intellectual 0020 * property rights. 0021 * 0022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0023 * copy of the source code appearing in this file ("Covered Code") an 0024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0025 * base code distributed originally by Intel ("Original Intel Code") to copy, 0026 * make derivatives, distribute, use and display any portion of the Covered 0027 * Code in any form, with the right to sublicense such rights; and 0028 * 0029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0030 * license (with the right to sublicense), under only those claims of Intel 0031 * patents that are infringed by the Original Intel Code, to make, use, sell, 0032 * offer to sell, and import the Covered Code and derivative works thereof 0033 * solely to the minimum extent necessary to exercise the above copyright 0034 * license, and in no event shall the patent license extend to any additions 0035 * to or modifications of the Original Intel Code. No other license or right 0036 * is granted directly or by implication, estoppel or otherwise; 0037 * 0038 * The above copyright and patent license is granted only if the following 0039 * conditions are met: 0040 * 0041 * 3. Conditions 0042 * 0043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0044 * Redistribution of source code of any substantial portion of the Covered 0045 * Code or modification with rights to further distribute source must include 0046 * the above Copyright Notice, the above License, this list of Conditions, 0047 * and the following Disclaimer and Export Compliance provision. In addition, 0048 * Licensee must cause all Covered Code to which Licensee contributes to 0049 * contain a file documenting the changes Licensee made to create that Covered 0050 * Code and the date of any change. Licensee must include in that file the 0051 * documentation of any changes made by any predecessor Licensee. Licensee 0052 * must include a prominent statement that the modification is derived, 0053 * directly or indirectly, from Original Intel Code. 0054 * 0055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0056 * Redistribution of source code of any substantial portion of the Covered 0057 * Code or modification without rights to further distribute source must 0058 * include the following Disclaimer and Export Compliance provision in the 0059 * documentation and/or other materials provided with distribution. In 0060 * addition, Licensee may not authorize further sublicense of source of any 0061 * portion of the Covered Code, and must include terms to the effect that the 0062 * license from Licensee to its licensee is limited to the intellectual 0063 * property embodied in the software Licensee provides to its licensee, and 0064 * not to intellectual property embodied in modifications its licensee may 0065 * make. 0066 * 0067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0068 * substantial portion of the Covered Code or modification must reproduce the 0069 * above Copyright Notice, and the following Disclaimer and Export Compliance 0070 * provision in the documentation and/or other materials provided with the 0071 * distribution. 0072 * 0073 * 3.4. Intel retains all right, title, and interest in and to the Original 0074 * Intel Code. 0075 * 0076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0077 * Intel shall be used in advertising or otherwise to promote the sale, use or 0078 * other dealings in products derived from or relating to the Covered Code 0079 * without prior written authorization from Intel. 0080 * 0081 * 4. Disclaimer and Export Compliance 0082 * 0083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0089 * PARTICULAR PURPOSE. 0090 * 0091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0098 * LIMITED REMEDY. 0099 * 0100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0101 * software or system incorporating such software without first obtaining any 0102 * required license or other approval from the U. S. Department of Commerce or 0103 * any other agency or department of the United States Government. In the 0104 * event Licensee exports any such software from the United States or 0105 * re-exports any such software from a foreign destination, Licensee shall 0106 * ensure that the distribution and export/re-export of the software is in 0107 * compliance with all laws, regulations, orders, or other restrictions of the 0108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0109 * any of its subsidiaries will export/re-export any technical data, process, 0110 * software, or service, directly or indirectly, to any country for which the 0111 * United States government or any agency thereof requires an export license, 0112 * other governmental approval, or letter of assurance, without first obtaining 0113 * such license, approval or letter. 0114 * 0115 ***************************************************************************** 0116 * 0117 * Alternatively, you may choose to be licensed under the terms of the 0118 * following license: 0119 * 0120 * Redistribution and use in source and binary forms, with or without 0121 * modification, are permitted provided that the following conditions 0122 * are met: 0123 * 1. Redistributions of source code must retain the above copyright 0124 * notice, this list of conditions, and the following disclaimer, 0125 * without modification. 0126 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0127 * substantially similar to the "NO WARRANTY" disclaimer below 0128 * ("Disclaimer") and any redistribution must be conditioned upon 0129 * including a substantially similar Disclaimer requirement for further 0130 * binary redistribution. 0131 * 3. Neither the names of the above-listed copyright holders nor the names 0132 * of any contributors may be used to endorse or promote products derived 0133 * from this software without specific prior written permission. 0134 * 0135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0146 * 0147 * Alternatively, you may choose to be licensed under the terms of the 0148 * GNU General Public License ("GPL") version 2 as published by the Free 0149 * Software Foundation. 0150 * 0151 *****************************************************************************/ 0152 0153 #define EXPORT_ACPI_INTERFACES 0154 0155 #include "acpi.h" 0156 #include "accommon.h" 0157 #include "acnamesp.h" 0158 #include "acparser.h" 0159 #include "amlcode.h" 0160 0161 0162 #define _COMPONENT ACPI_NAMESPACE 0163 ACPI_MODULE_NAME ("nsxfname") 0164 0165 /* Local prototypes */ 0166 0167 static char * 0168 AcpiNsCopyDeviceId ( 0169 ACPI_PNP_DEVICE_ID *Dest, 0170 ACPI_PNP_DEVICE_ID *Source, 0171 char *StringArea); 0172 0173 0174 /****************************************************************************** 0175 * 0176 * FUNCTION: AcpiGetHandle 0177 * 0178 * PARAMETERS: Parent - Object to search under (search scope). 0179 * Pathname - Pointer to an asciiz string containing the 0180 * name 0181 * RetHandle - Where the return handle is returned 0182 * 0183 * RETURN: Status 0184 * 0185 * DESCRIPTION: This routine will search for a caller specified name in the 0186 * name space. The caller can restrict the search region by 0187 * specifying a non NULL parent. The parent value is itself a 0188 * namespace handle. 0189 * 0190 ******************************************************************************/ 0191 0192 ACPI_STATUS 0193 AcpiGetHandle ( 0194 ACPI_HANDLE Parent, 0195 const char *Pathname, 0196 ACPI_HANDLE *RetHandle) 0197 { 0198 ACPI_STATUS Status; 0199 ACPI_NAMESPACE_NODE *Node = NULL; 0200 ACPI_NAMESPACE_NODE *PrefixNode = NULL; 0201 0202 0203 ACPI_FUNCTION_ENTRY (); 0204 0205 0206 /* Parameter Validation */ 0207 0208 if (!RetHandle || !Pathname) 0209 { 0210 return (AE_BAD_PARAMETER); 0211 } 0212 0213 /* Convert a parent handle to a prefix node */ 0214 0215 if (Parent) 0216 { 0217 PrefixNode = AcpiNsValidateHandle (Parent); 0218 if (!PrefixNode) 0219 { 0220 return (AE_BAD_PARAMETER); 0221 } 0222 } 0223 0224 /* 0225 * Valid cases are: 0226 * 1) Fully qualified pathname 0227 * 2) Parent + Relative pathname 0228 * 0229 * Error for <null Parent + relative path> 0230 */ 0231 if (ACPI_IS_ROOT_PREFIX (Pathname[0])) 0232 { 0233 /* Pathname is fully qualified (starts with '\') */ 0234 0235 /* Special case for root-only, since we can't search for it */ 0236 0237 if (!strcmp (Pathname, ACPI_NS_ROOT_PATH)) 0238 { 0239 *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); 0240 return (AE_OK); 0241 } 0242 } 0243 else if (!PrefixNode) 0244 { 0245 /* Relative path with null prefix is disallowed */ 0246 0247 return (AE_BAD_PARAMETER); 0248 } 0249 0250 /* Find the Node and convert to a handle */ 0251 0252 Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); 0253 if (ACPI_SUCCESS (Status)) 0254 { 0255 *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); 0256 } 0257 0258 return (Status); 0259 } 0260 0261 ACPI_EXPORT_SYMBOL (AcpiGetHandle) 0262 0263 0264 /****************************************************************************** 0265 * 0266 * FUNCTION: AcpiGetName 0267 * 0268 * PARAMETERS: Handle - Handle to be converted to a pathname 0269 * NameType - Full pathname or single segment 0270 * Buffer - Buffer for returned path 0271 * 0272 * RETURN: Pointer to a string containing the fully qualified Name. 0273 * 0274 * DESCRIPTION: This routine returns the fully qualified name associated with 0275 * the Handle parameter. This and the AcpiPathnameToHandle are 0276 * complementary functions. 0277 * 0278 ******************************************************************************/ 0279 0280 ACPI_STATUS 0281 AcpiGetName ( 0282 ACPI_HANDLE Handle, 0283 UINT32 NameType, 0284 ACPI_BUFFER *Buffer) 0285 { 0286 ACPI_STATUS Status; 0287 0288 0289 /* Parameter validation */ 0290 0291 if (NameType > ACPI_NAME_TYPE_MAX) 0292 { 0293 return (AE_BAD_PARAMETER); 0294 } 0295 0296 Status = AcpiUtValidateBuffer (Buffer); 0297 if (ACPI_FAILURE (Status)) 0298 { 0299 return (Status); 0300 } 0301 0302 /* 0303 * Wants the single segment ACPI name. 0304 * Validate handle and convert to a namespace Node 0305 */ 0306 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 0307 if (ACPI_FAILURE (Status)) 0308 { 0309 return (Status); 0310 } 0311 0312 if (NameType == ACPI_FULL_PATHNAME || 0313 NameType == ACPI_FULL_PATHNAME_NO_TRAILING) 0314 { 0315 /* Get the full pathname (From the namespace root) */ 0316 0317 Status = AcpiNsHandleToPathname (Handle, Buffer, 0318 NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); 0319 } 0320 else 0321 { 0322 /* Get the single name */ 0323 0324 Status = AcpiNsHandleToName (Handle, Buffer); 0325 } 0326 0327 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0328 return (Status); 0329 } 0330 0331 ACPI_EXPORT_SYMBOL (AcpiGetName) 0332 0333 0334 /****************************************************************************** 0335 * 0336 * FUNCTION: AcpiNsCopyDeviceId 0337 * 0338 * PARAMETERS: Dest - Pointer to the destination PNP_DEVICE_ID 0339 * Source - Pointer to the source PNP_DEVICE_ID 0340 * StringArea - Pointer to where to copy the dest string 0341 * 0342 * RETURN: Pointer to the next string area 0343 * 0344 * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data. 0345 * 0346 ******************************************************************************/ 0347 0348 static char * 0349 AcpiNsCopyDeviceId ( 0350 ACPI_PNP_DEVICE_ID *Dest, 0351 ACPI_PNP_DEVICE_ID *Source, 0352 char *StringArea) 0353 { 0354 /* Create the destination PNP_DEVICE_ID */ 0355 0356 Dest->String = StringArea; 0357 Dest->Length = Source->Length; 0358 0359 /* Copy actual string and return a pointer to the next string area */ 0360 0361 memcpy (StringArea, Source->String, Source->Length); 0362 return (StringArea + Source->Length); 0363 } 0364 0365 0366 /****************************************************************************** 0367 * 0368 * FUNCTION: AcpiGetObjectInfo 0369 * 0370 * PARAMETERS: Handle - Object Handle 0371 * ReturnBuffer - Where the info is returned 0372 * 0373 * RETURN: Status 0374 * 0375 * DESCRIPTION: Returns information about an object as gleaned from the 0376 * namespace node and possibly by running several standard 0377 * control methods (Such as in the case of a device.) 0378 * 0379 * For Device and Processor objects, run the Device _HID, _UID, _CID, 0380 * _CLS, _ADR, _SxW, and _SxD methods. 0381 * 0382 * Note: Allocates the return buffer, must be freed by the caller. 0383 * 0384 * Note: This interface is intended to be used during the initial device 0385 * discovery namespace traversal. Therefore, no complex methods can be 0386 * executed, especially those that access operation regions. Therefore, do 0387 * not add any additional methods that could cause problems in this area. 0388 * Because of this reason support for the following methods has been removed: 0389 * 1) _SUB method was removed (11/2015) 0390 * 2) _STA method was removed (02/2018) 0391 * 0392 ******************************************************************************/ 0393 0394 ACPI_STATUS 0395 AcpiGetObjectInfo ( 0396 ACPI_HANDLE Handle, 0397 ACPI_DEVICE_INFO **ReturnBuffer) 0398 { 0399 ACPI_NAMESPACE_NODE *Node; 0400 ACPI_DEVICE_INFO *Info; 0401 ACPI_PNP_DEVICE_ID_LIST *CidList = NULL; 0402 ACPI_PNP_DEVICE_ID *Hid = NULL; 0403 ACPI_PNP_DEVICE_ID *Uid = NULL; 0404 ACPI_PNP_DEVICE_ID *Cls = NULL; 0405 char *NextIdString; 0406 ACPI_OBJECT_TYPE Type; 0407 ACPI_NAME Name; 0408 UINT8 ParamCount= 0; 0409 UINT16 Valid = 0; 0410 UINT32 InfoSize; 0411 UINT32 i; 0412 ACPI_STATUS Status; 0413 0414 0415 /* Parameter validation */ 0416 0417 if (!Handle || !ReturnBuffer) 0418 { 0419 return (AE_BAD_PARAMETER); 0420 } 0421 0422 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 0423 if (ACPI_FAILURE (Status)) 0424 { 0425 return (Status); 0426 } 0427 0428 Node = AcpiNsValidateHandle (Handle); 0429 if (!Node) 0430 { 0431 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0432 return (AE_BAD_PARAMETER); 0433 } 0434 0435 /* Get the namespace node data while the namespace is locked */ 0436 0437 InfoSize = sizeof (ACPI_DEVICE_INFO); 0438 Type = Node->Type; 0439 Name = Node->Name.Integer; 0440 0441 if (Node->Type == ACPI_TYPE_METHOD) 0442 { 0443 ParamCount = Node->Object->Method.ParamCount; 0444 } 0445 0446 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0447 if (ACPI_FAILURE (Status)) 0448 { 0449 return (Status); 0450 } 0451 0452 if ((Type == ACPI_TYPE_DEVICE) || 0453 (Type == ACPI_TYPE_PROCESSOR)) 0454 { 0455 /* 0456 * Get extra info for ACPI Device/Processor objects only: 0457 * Run the Device _HID, _UID, _CLS, and _CID methods. 0458 * 0459 * Note: none of these methods are required, so they may or may 0460 * not be present for this device. The Info->Valid bitfield is used 0461 * to indicate which methods were found and run successfully. 0462 */ 0463 0464 /* Execute the Device._HID method */ 0465 0466 Status = AcpiUtExecute_HID (Node, &Hid); 0467 if (ACPI_SUCCESS (Status)) 0468 { 0469 InfoSize += Hid->Length; 0470 Valid |= ACPI_VALID_HID; 0471 } 0472 0473 /* Execute the Device._UID method */ 0474 0475 Status = AcpiUtExecute_UID (Node, &Uid); 0476 if (ACPI_SUCCESS (Status)) 0477 { 0478 InfoSize += Uid->Length; 0479 Valid |= ACPI_VALID_UID; 0480 } 0481 0482 /* Execute the Device._CID method */ 0483 0484 Status = AcpiUtExecute_CID (Node, &CidList); 0485 if (ACPI_SUCCESS (Status)) 0486 { 0487 /* Add size of CID strings and CID pointer array */ 0488 0489 InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST)); 0490 Valid |= ACPI_VALID_CID; 0491 } 0492 0493 /* Execute the Device._CLS method */ 0494 0495 Status = AcpiUtExecute_CLS (Node, &Cls); 0496 if (ACPI_SUCCESS (Status)) 0497 { 0498 InfoSize += Cls->Length; 0499 Valid |= ACPI_VALID_CLS; 0500 } 0501 } 0502 0503 /* 0504 * Now that we have the variable-length data, we can allocate the 0505 * return buffer 0506 */ 0507 Info = ACPI_ALLOCATE_ZEROED (InfoSize); 0508 if (!Info) 0509 { 0510 Status = AE_NO_MEMORY; 0511 goto Cleanup; 0512 } 0513 0514 /* Get the fixed-length data */ 0515 0516 if ((Type == ACPI_TYPE_DEVICE) || 0517 (Type == ACPI_TYPE_PROCESSOR)) 0518 { 0519 /* 0520 * Get extra info for ACPI Device/Processor objects only: 0521 * Run the _ADR and, SxW, and _SxD methods. 0522 * 0523 * Notes: none of these methods are required, so they may or may 0524 * not be present for this device. The Info->Valid bitfield is used 0525 * to indicate which methods were found and run successfully. 0526 */ 0527 0528 /* Execute the Device._ADR method */ 0529 0530 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, 0531 &Info->Address); 0532 if (ACPI_SUCCESS (Status)) 0533 { 0534 Valid |= ACPI_VALID_ADR; 0535 } 0536 0537 /* Execute the Device._SxW methods */ 0538 0539 Status = AcpiUtExecutePowerMethods (Node, 0540 AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, 0541 Info->LowestDstates); 0542 if (ACPI_SUCCESS (Status)) 0543 { 0544 Valid |= ACPI_VALID_SXWS; 0545 } 0546 0547 /* Execute the Device._SxD methods */ 0548 0549 Status = AcpiUtExecutePowerMethods (Node, 0550 AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, 0551 Info->HighestDstates); 0552 if (ACPI_SUCCESS (Status)) 0553 { 0554 Valid |= ACPI_VALID_SXDS; 0555 } 0556 } 0557 0558 /* 0559 * Create a pointer to the string area of the return buffer. 0560 * Point to the end of the base ACPI_DEVICE_INFO structure. 0561 */ 0562 NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); 0563 if (CidList) 0564 { 0565 /* Point past the CID PNP_DEVICE_ID array */ 0566 0567 NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_PNP_DEVICE_ID)); 0568 } 0569 0570 /* 0571 * Copy the HID, UID, and CIDs to the return buffer. The variable-length 0572 * strings are copied to the reserved area at the end of the buffer. 0573 * 0574 * For HID and CID, check if the ID is a PCI Root Bridge. 0575 */ 0576 if (Hid) 0577 { 0578 NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, 0579 Hid, NextIdString); 0580 0581 if (AcpiUtIsPciRootBridge (Hid->String)) 0582 { 0583 Info->Flags |= ACPI_PCI_ROOT_BRIDGE; 0584 } 0585 } 0586 0587 if (Uid) 0588 { 0589 NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, 0590 Uid, NextIdString); 0591 } 0592 0593 if (CidList) 0594 { 0595 Info->CompatibleIdList.Count = CidList->Count; 0596 Info->CompatibleIdList.ListSize = CidList->ListSize; 0597 0598 /* Copy each CID */ 0599 0600 for (i = 0; i < CidList->Count; i++) 0601 { 0602 NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], 0603 &CidList->Ids[i], NextIdString); 0604 0605 if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) 0606 { 0607 Info->Flags |= ACPI_PCI_ROOT_BRIDGE; 0608 } 0609 } 0610 } 0611 0612 if (Cls) 0613 { 0614 (void) AcpiNsCopyDeviceId (&Info->ClassCode, 0615 Cls, NextIdString); 0616 } 0617 0618 /* Copy the fixed-length data */ 0619 0620 Info->InfoSize = InfoSize; 0621 Info->Type = Type; 0622 Info->Name = Name; 0623 Info->ParamCount = ParamCount; 0624 Info->Valid = Valid; 0625 0626 *ReturnBuffer = Info; 0627 Status = AE_OK; 0628 0629 0630 Cleanup: 0631 if (Hid) 0632 { 0633 ACPI_FREE (Hid); 0634 } 0635 if (Uid) 0636 { 0637 ACPI_FREE (Uid); 0638 } 0639 if (CidList) 0640 { 0641 ACPI_FREE (CidList); 0642 } 0643 if (Cls) 0644 { 0645 ACPI_FREE (Cls); 0646 } 0647 return (Status); 0648 } 0649 0650 ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) 0651 0652 0653 /****************************************************************************** 0654 * 0655 * FUNCTION: AcpiInstallMethod 0656 * 0657 * PARAMETERS: Buffer - An ACPI table containing one control method 0658 * 0659 * RETURN: Status 0660 * 0661 * DESCRIPTION: Install a control method into the namespace. If the method 0662 * name already exists in the namespace, it is overwritten. The 0663 * input buffer must contain a valid DSDT or SSDT containing a 0664 * single control method. 0665 * 0666 ******************************************************************************/ 0667 0668 ACPI_STATUS 0669 AcpiInstallMethod ( 0670 UINT8 *Buffer) 0671 { 0672 ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); 0673 UINT8 *AmlBuffer; 0674 UINT8 *AmlStart; 0675 char *Path; 0676 ACPI_NAMESPACE_NODE *Node; 0677 ACPI_OPERAND_OBJECT *MethodObj; 0678 ACPI_PARSE_STATE ParserState; 0679 UINT32 AmlLength; 0680 UINT16 Opcode; 0681 UINT8 MethodFlags; 0682 ACPI_STATUS Status; 0683 0684 0685 /* Parameter validation */ 0686 0687 if (!Buffer) 0688 { 0689 return (AE_BAD_PARAMETER); 0690 } 0691 0692 /* Table must be a DSDT or SSDT */ 0693 0694 if (!ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT) && 0695 !ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_SSDT)) 0696 { 0697 return (AE_BAD_HEADER); 0698 } 0699 0700 /* First AML opcode in the table must be a control method */ 0701 0702 ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); 0703 Opcode = AcpiPsPeekOpcode (&ParserState); 0704 if (Opcode != AML_METHOD_OP) 0705 { 0706 return (AE_BAD_PARAMETER); 0707 } 0708 0709 /* Extract method information from the raw AML */ 0710 0711 ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); 0712 ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); 0713 Path = AcpiPsGetNextNamestring (&ParserState); 0714 0715 MethodFlags = *ParserState.Aml++; 0716 AmlStart = ParserState.Aml; 0717 AmlLength = (UINT32) ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); 0718 0719 /* 0720 * Allocate resources up-front. We don't want to have to delete a new 0721 * node from the namespace if we cannot allocate memory. 0722 */ 0723 AmlBuffer = ACPI_ALLOCATE (AmlLength); 0724 if (!AmlBuffer) 0725 { 0726 return (AE_NO_MEMORY); 0727 } 0728 0729 MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 0730 if (!MethodObj) 0731 { 0732 ACPI_FREE (AmlBuffer); 0733 return (AE_NO_MEMORY); 0734 } 0735 0736 /* Lock namespace for AcpiNsLookup, we may be creating a new node */ 0737 0738 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 0739 if (ACPI_FAILURE (Status)) 0740 { 0741 goto ErrorExit; 0742 } 0743 0744 /* The lookup either returns an existing node or creates a new one */ 0745 0746 Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, 0747 ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); 0748 0749 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 0750 0751 if (ACPI_FAILURE (Status)) /* NsLookup */ 0752 { 0753 if (Status != AE_ALREADY_EXISTS) 0754 { 0755 goto ErrorExit; 0756 } 0757 0758 /* Node existed previously, make sure it is a method node */ 0759 0760 if (Node->Type != ACPI_TYPE_METHOD) 0761 { 0762 Status = AE_TYPE; 0763 goto ErrorExit; 0764 } 0765 } 0766 0767 /* Copy the method AML to the local buffer */ 0768 0769 memcpy (AmlBuffer, AmlStart, AmlLength); 0770 0771 /* Initialize the method object with the new method's information */ 0772 0773 MethodObj->Method.AmlStart = AmlBuffer; 0774 MethodObj->Method.AmlLength = AmlLength; 0775 0776 MethodObj->Method.ParamCount = (UINT8) 0777 (MethodFlags & AML_METHOD_ARG_COUNT); 0778 0779 if (MethodFlags & AML_METHOD_SERIALIZED) 0780 { 0781 MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED; 0782 0783 MethodObj->Method.SyncLevel = (UINT8) 0784 ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); 0785 } 0786 0787 /* 0788 * Now that it is complete, we can attach the new method object to 0789 * the method Node (detaches/deletes any existing object) 0790 */ 0791 Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD); 0792 0793 /* 0794 * Flag indicates AML buffer is dynamic, must be deleted later. 0795 * Must be set only after attach above. 0796 */ 0797 Node->Flags |= ANOBJ_ALLOCATED_BUFFER; 0798 0799 /* Remove local reference to the method object */ 0800 0801 AcpiUtRemoveReference (MethodObj); 0802 return (Status); 0803 0804 0805 ErrorExit: 0806 0807 ACPI_FREE (AmlBuffer); 0808 ACPI_FREE (MethodObj); 0809 return (Status); 0810 } 0811 0812 ACPI_EXPORT_SYMBOL (AcpiInstallMethod)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |