1 1.1 jruoho /****************************************************************************** 2 1.1 jruoho * 3 1.1 jruoho * Module Name: nsxfname - Public interfaces to the ACPI subsystem 4 1.1 jruoho * ACPI Namespace oriented interfaces 5 1.1 jruoho * 6 1.1 jruoho *****************************************************************************/ 7 1.1 jruoho 8 1.17 christos /****************************************************************************** 9 1.17 christos * 10 1.17 christos * 1. Copyright Notice 11 1.17 christos * 12 1.18 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 13 1.1 jruoho * All rights reserved. 14 1.1 jruoho * 15 1.17 christos * 2. License 16 1.17 christos * 17 1.17 christos * 2.1. This is your license from Intel Corp. under its intellectual property 18 1.17 christos * rights. You may have additional license terms from the party that provided 19 1.17 christos * you this software, covering your right to use that party's intellectual 20 1.17 christos * property rights. 21 1.17 christos * 22 1.17 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 1.17 christos * copy of the source code appearing in this file ("Covered Code") an 24 1.17 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 1.17 christos * base code distributed originally by Intel ("Original Intel Code") to copy, 26 1.17 christos * make derivatives, distribute, use and display any portion of the Covered 27 1.17 christos * Code in any form, with the right to sublicense such rights; and 28 1.17 christos * 29 1.17 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 1.17 christos * license (with the right to sublicense), under only those claims of Intel 31 1.17 christos * patents that are infringed by the Original Intel Code, to make, use, sell, 32 1.17 christos * offer to sell, and import the Covered Code and derivative works thereof 33 1.17 christos * solely to the minimum extent necessary to exercise the above copyright 34 1.17 christos * license, and in no event shall the patent license extend to any additions 35 1.17 christos * to or modifications of the Original Intel Code. No other license or right 36 1.17 christos * is granted directly or by implication, estoppel or otherwise; 37 1.17 christos * 38 1.17 christos * The above copyright and patent license is granted only if the following 39 1.17 christos * conditions are met: 40 1.17 christos * 41 1.17 christos * 3. Conditions 42 1.17 christos * 43 1.17 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 1.17 christos * Redistribution of source code of any substantial portion of the Covered 45 1.17 christos * Code or modification with rights to further distribute source must include 46 1.17 christos * the above Copyright Notice, the above License, this list of Conditions, 47 1.17 christos * and the following Disclaimer and Export Compliance provision. In addition, 48 1.17 christos * Licensee must cause all Covered Code to which Licensee contributes to 49 1.17 christos * contain a file documenting the changes Licensee made to create that Covered 50 1.17 christos * Code and the date of any change. Licensee must include in that file the 51 1.17 christos * documentation of any changes made by any predecessor Licensee. Licensee 52 1.17 christos * must include a prominent statement that the modification is derived, 53 1.17 christos * directly or indirectly, from Original Intel Code. 54 1.17 christos * 55 1.17 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 1.17 christos * Redistribution of source code of any substantial portion of the Covered 57 1.17 christos * Code or modification without rights to further distribute source must 58 1.17 christos * include the following Disclaimer and Export Compliance provision in the 59 1.17 christos * documentation and/or other materials provided with distribution. In 60 1.17 christos * addition, Licensee may not authorize further sublicense of source of any 61 1.17 christos * portion of the Covered Code, and must include terms to the effect that the 62 1.17 christos * license from Licensee to its licensee is limited to the intellectual 63 1.17 christos * property embodied in the software Licensee provides to its licensee, and 64 1.17 christos * not to intellectual property embodied in modifications its licensee may 65 1.17 christos * make. 66 1.17 christos * 67 1.17 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 1.17 christos * substantial portion of the Covered Code or modification must reproduce the 69 1.17 christos * above Copyright Notice, and the following Disclaimer and Export Compliance 70 1.17 christos * provision in the documentation and/or other materials provided with the 71 1.17 christos * distribution. 72 1.17 christos * 73 1.17 christos * 3.4. Intel retains all right, title, and interest in and to the Original 74 1.17 christos * Intel Code. 75 1.17 christos * 76 1.17 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 1.17 christos * Intel shall be used in advertising or otherwise to promote the sale, use or 78 1.17 christos * other dealings in products derived from or relating to the Covered Code 79 1.17 christos * without prior written authorization from Intel. 80 1.17 christos * 81 1.17 christos * 4. Disclaimer and Export Compliance 82 1.17 christos * 83 1.17 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 1.17 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 1.17 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 1.17 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 1.17 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 1.17 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 1.17 christos * PARTICULAR PURPOSE. 90 1.17 christos * 91 1.17 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 1.17 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 1.17 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 1.17 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 1.17 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 1.17 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 1.17 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 1.17 christos * LIMITED REMEDY. 99 1.17 christos * 100 1.17 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 1.17 christos * software or system incorporating such software without first obtaining any 102 1.17 christos * required license or other approval from the U. S. Department of Commerce or 103 1.17 christos * any other agency or department of the United States Government. In the 104 1.17 christos * event Licensee exports any such software from the United States or 105 1.17 christos * re-exports any such software from a foreign destination, Licensee shall 106 1.17 christos * ensure that the distribution and export/re-export of the software is in 107 1.17 christos * compliance with all laws, regulations, orders, or other restrictions of the 108 1.17 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 1.17 christos * any of its subsidiaries will export/re-export any technical data, process, 110 1.17 christos * software, or service, directly or indirectly, to any country for which the 111 1.17 christos * United States government or any agency thereof requires an export license, 112 1.17 christos * other governmental approval, or letter of assurance, without first obtaining 113 1.17 christos * such license, approval or letter. 114 1.17 christos * 115 1.17 christos ***************************************************************************** 116 1.17 christos * 117 1.17 christos * Alternatively, you may choose to be licensed under the terms of the 118 1.17 christos * following license: 119 1.17 christos * 120 1.3 jruoho * Redistribution and use in source and binary forms, with or without 121 1.3 jruoho * modification, are permitted provided that the following conditions 122 1.3 jruoho * are met: 123 1.3 jruoho * 1. Redistributions of source code must retain the above copyright 124 1.3 jruoho * notice, this list of conditions, and the following disclaimer, 125 1.3 jruoho * without modification. 126 1.3 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer 127 1.3 jruoho * substantially similar to the "NO WARRANTY" disclaimer below 128 1.3 jruoho * ("Disclaimer") and any redistribution must be conditioned upon 129 1.3 jruoho * including a substantially similar Disclaimer requirement for further 130 1.3 jruoho * binary redistribution. 131 1.3 jruoho * 3. Neither the names of the above-listed copyright holders nor the names 132 1.3 jruoho * of any contributors may be used to endorse or promote products derived 133 1.3 jruoho * from this software without specific prior written permission. 134 1.3 jruoho * 135 1.3 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 136 1.3 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 137 1.14 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 138 1.3 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 139 1.17 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 140 1.17 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 141 1.17 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 142 1.17 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 143 1.17 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 144 1.17 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 145 1.17 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 146 1.17 christos * 147 1.17 christos * Alternatively, you may choose to be licensed under the terms of the 148 1.17 christos * GNU General Public License ("GPL") version 2 as published by the Free 149 1.17 christos * Software Foundation. 150 1.17 christos * 151 1.17 christos *****************************************************************************/ 152 1.1 jruoho 153 1.4 christos #define EXPORT_ACPI_INTERFACES 154 1.1 jruoho 155 1.1 jruoho #include "acpi.h" 156 1.1 jruoho #include "accommon.h" 157 1.1 jruoho #include "acnamesp.h" 158 1.1 jruoho #include "acparser.h" 159 1.1 jruoho #include "amlcode.h" 160 1.1 jruoho 161 1.1 jruoho 162 1.1 jruoho #define _COMPONENT ACPI_NAMESPACE 163 1.1 jruoho ACPI_MODULE_NAME ("nsxfname") 164 1.1 jruoho 165 1.1 jruoho /* Local prototypes */ 166 1.1 jruoho 167 1.1 jruoho static char * 168 1.1 jruoho AcpiNsCopyDeviceId ( 169 1.4 christos ACPI_PNP_DEVICE_ID *Dest, 170 1.4 christos ACPI_PNP_DEVICE_ID *Source, 171 1.1 jruoho char *StringArea); 172 1.1 jruoho 173 1.1 jruoho 174 1.1 jruoho /****************************************************************************** 175 1.1 jruoho * 176 1.1 jruoho * FUNCTION: AcpiGetHandle 177 1.1 jruoho * 178 1.1 jruoho * PARAMETERS: Parent - Object to search under (search scope). 179 1.1 jruoho * Pathname - Pointer to an asciiz string containing the 180 1.1 jruoho * name 181 1.1 jruoho * RetHandle - Where the return handle is returned 182 1.1 jruoho * 183 1.1 jruoho * RETURN: Status 184 1.1 jruoho * 185 1.1 jruoho * DESCRIPTION: This routine will search for a caller specified name in the 186 1.4 christos * name space. The caller can restrict the search region by 187 1.4 christos * specifying a non NULL parent. The parent value is itself a 188 1.1 jruoho * namespace handle. 189 1.1 jruoho * 190 1.1 jruoho ******************************************************************************/ 191 1.1 jruoho 192 1.1 jruoho ACPI_STATUS 193 1.1 jruoho AcpiGetHandle ( 194 1.1 jruoho ACPI_HANDLE Parent, 195 1.16 christos const char *Pathname, 196 1.1 jruoho ACPI_HANDLE *RetHandle) 197 1.1 jruoho { 198 1.1 jruoho ACPI_STATUS Status; 199 1.1 jruoho ACPI_NAMESPACE_NODE *Node = NULL; 200 1.1 jruoho ACPI_NAMESPACE_NODE *PrefixNode = NULL; 201 1.2 jruoho ACPI_STRING UPathname = __UNCONST(Pathname); 202 1.1 jruoho 203 1.1 jruoho 204 1.1 jruoho ACPI_FUNCTION_ENTRY (); 205 1.1 jruoho 206 1.1 jruoho 207 1.1 jruoho /* Parameter Validation */ 208 1.1 jruoho 209 1.1 jruoho if (!RetHandle || !Pathname) 210 1.1 jruoho { 211 1.1 jruoho return (AE_BAD_PARAMETER); 212 1.1 jruoho } 213 1.1 jruoho 214 1.1 jruoho /* Convert a parent handle to a prefix node */ 215 1.1 jruoho 216 1.1 jruoho if (Parent) 217 1.1 jruoho { 218 1.1 jruoho PrefixNode = AcpiNsValidateHandle (Parent); 219 1.1 jruoho if (!PrefixNode) 220 1.1 jruoho { 221 1.1 jruoho return (AE_BAD_PARAMETER); 222 1.1 jruoho } 223 1.1 jruoho } 224 1.1 jruoho 225 1.1 jruoho /* 226 1.1 jruoho * Valid cases are: 227 1.1 jruoho * 1) Fully qualified pathname 228 1.1 jruoho * 2) Parent + Relative pathname 229 1.1 jruoho * 230 1.1 jruoho * Error for <null Parent + relative path> 231 1.1 jruoho */ 232 1.4 christos if (ACPI_IS_ROOT_PREFIX (Pathname[0])) 233 1.1 jruoho { 234 1.1 jruoho /* Pathname is fully qualified (starts with '\') */ 235 1.1 jruoho 236 1.1 jruoho /* Special case for root-only, since we can't search for it */ 237 1.1 jruoho 238 1.7 christos if (!strcmp (Pathname, ACPI_NS_ROOT_PATH)) 239 1.1 jruoho { 240 1.1 jruoho *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); 241 1.1 jruoho return (AE_OK); 242 1.1 jruoho } 243 1.1 jruoho } 244 1.1 jruoho else if (!PrefixNode) 245 1.1 jruoho { 246 1.1 jruoho /* Relative path with null prefix is disallowed */ 247 1.1 jruoho 248 1.1 jruoho return (AE_BAD_PARAMETER); 249 1.1 jruoho } 250 1.1 jruoho 251 1.1 jruoho /* Find the Node and convert to a handle */ 252 1.1 jruoho 253 1.2 jruoho Status = AcpiNsGetNode (PrefixNode, UPathname, ACPI_NS_NO_UPSEARCH, &Node); 254 1.1 jruoho if (ACPI_SUCCESS (Status)) 255 1.1 jruoho { 256 1.1 jruoho *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); 257 1.1 jruoho } 258 1.1 jruoho 259 1.1 jruoho return (Status); 260 1.1 jruoho } 261 1.1 jruoho 262 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiGetHandle) 263 1.1 jruoho 264 1.1 jruoho 265 1.1 jruoho /****************************************************************************** 266 1.1 jruoho * 267 1.1 jruoho * FUNCTION: AcpiGetName 268 1.1 jruoho * 269 1.1 jruoho * PARAMETERS: Handle - Handle to be converted to a pathname 270 1.1 jruoho * NameType - Full pathname or single segment 271 1.1 jruoho * Buffer - Buffer for returned path 272 1.1 jruoho * 273 1.1 jruoho * RETURN: Pointer to a string containing the fully qualified Name. 274 1.1 jruoho * 275 1.1 jruoho * DESCRIPTION: This routine returns the fully qualified name associated with 276 1.4 christos * the Handle parameter. This and the AcpiPathnameToHandle are 277 1.1 jruoho * complementary functions. 278 1.1 jruoho * 279 1.1 jruoho ******************************************************************************/ 280 1.1 jruoho 281 1.1 jruoho ACPI_STATUS 282 1.1 jruoho AcpiGetName ( 283 1.1 jruoho ACPI_HANDLE Handle, 284 1.1 jruoho UINT32 NameType, 285 1.1 jruoho ACPI_BUFFER *Buffer) 286 1.1 jruoho { 287 1.1 jruoho ACPI_STATUS Status; 288 1.1 jruoho 289 1.1 jruoho 290 1.1 jruoho /* Parameter validation */ 291 1.1 jruoho 292 1.1 jruoho if (NameType > ACPI_NAME_TYPE_MAX) 293 1.1 jruoho { 294 1.1 jruoho return (AE_BAD_PARAMETER); 295 1.1 jruoho } 296 1.1 jruoho 297 1.1 jruoho Status = AcpiUtValidateBuffer (Buffer); 298 1.1 jruoho if (ACPI_FAILURE (Status)) 299 1.1 jruoho { 300 1.1 jruoho return (Status); 301 1.1 jruoho } 302 1.1 jruoho 303 1.1 jruoho /* 304 1.1 jruoho * Wants the single segment ACPI name. 305 1.1 jruoho * Validate handle and convert to a namespace Node 306 1.1 jruoho */ 307 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 308 1.1 jruoho if (ACPI_FAILURE (Status)) 309 1.1 jruoho { 310 1.1 jruoho return (Status); 311 1.1 jruoho } 312 1.1 jruoho 313 1.9 christos if (NameType == ACPI_FULL_PATHNAME || 314 1.9 christos NameType == ACPI_FULL_PATHNAME_NO_TRAILING) 315 1.1 jruoho { 316 1.9 christos /* Get the full pathname (From the namespace root) */ 317 1.9 christos 318 1.9 christos Status = AcpiNsHandleToPathname (Handle, Buffer, 319 1.9 christos NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); 320 1.1 jruoho } 321 1.9 christos else 322 1.9 christos { 323 1.9 christos /* Get the single name */ 324 1.1 jruoho 325 1.9 christos Status = AcpiNsHandleToName (Handle, Buffer); 326 1.1 jruoho } 327 1.1 jruoho 328 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 329 1.1 jruoho return (Status); 330 1.1 jruoho } 331 1.1 jruoho 332 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiGetName) 333 1.1 jruoho 334 1.1 jruoho 335 1.1 jruoho /****************************************************************************** 336 1.1 jruoho * 337 1.1 jruoho * FUNCTION: AcpiNsCopyDeviceId 338 1.1 jruoho * 339 1.4 christos * PARAMETERS: Dest - Pointer to the destination PNP_DEVICE_ID 340 1.4 christos * Source - Pointer to the source PNP_DEVICE_ID 341 1.1 jruoho * StringArea - Pointer to where to copy the dest string 342 1.1 jruoho * 343 1.1 jruoho * RETURN: Pointer to the next string area 344 1.1 jruoho * 345 1.4 christos * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data. 346 1.1 jruoho * 347 1.1 jruoho ******************************************************************************/ 348 1.1 jruoho 349 1.1 jruoho static char * 350 1.1 jruoho AcpiNsCopyDeviceId ( 351 1.4 christos ACPI_PNP_DEVICE_ID *Dest, 352 1.4 christos ACPI_PNP_DEVICE_ID *Source, 353 1.1 jruoho char *StringArea) 354 1.1 jruoho { 355 1.4 christos /* Create the destination PNP_DEVICE_ID */ 356 1.1 jruoho 357 1.1 jruoho Dest->String = StringArea; 358 1.1 jruoho Dest->Length = Source->Length; 359 1.1 jruoho 360 1.1 jruoho /* Copy actual string and return a pointer to the next string area */ 361 1.1 jruoho 362 1.7 christos memcpy (StringArea, Source->String, Source->Length); 363 1.1 jruoho return (StringArea + Source->Length); 364 1.1 jruoho } 365 1.1 jruoho 366 1.1 jruoho 367 1.1 jruoho /****************************************************************************** 368 1.1 jruoho * 369 1.1 jruoho * FUNCTION: AcpiGetObjectInfo 370 1.1 jruoho * 371 1.1 jruoho * PARAMETERS: Handle - Object Handle 372 1.1 jruoho * ReturnBuffer - Where the info is returned 373 1.1 jruoho * 374 1.1 jruoho * RETURN: Status 375 1.1 jruoho * 376 1.1 jruoho * DESCRIPTION: Returns information about an object as gleaned from the 377 1.1 jruoho * namespace node and possibly by running several standard 378 1.1 jruoho * control methods (Such as in the case of a device.) 379 1.1 jruoho * 380 1.10 christos * For Device and Processor objects, run the Device _HID, _UID, _CID, 381 1.8 christos * _CLS, _ADR, _SxW, and _SxD methods. 382 1.1 jruoho * 383 1.1 jruoho * Note: Allocates the return buffer, must be freed by the caller. 384 1.1 jruoho * 385 1.8 christos * Note: This interface is intended to be used during the initial device 386 1.8 christos * discovery namespace traversal. Therefore, no complex methods can be 387 1.8 christos * executed, especially those that access operation regions. Therefore, do 388 1.8 christos * not add any additional methods that could cause problems in this area. 389 1.10 christos * Because of this reason support for the following methods has been removed: 390 1.10 christos * 1) _SUB method was removed (11/2015) 391 1.10 christos * 2) _STA method was removed (02/2018) 392 1.8 christos * 393 1.1 jruoho ******************************************************************************/ 394 1.1 jruoho 395 1.1 jruoho ACPI_STATUS 396 1.1 jruoho AcpiGetObjectInfo ( 397 1.1 jruoho ACPI_HANDLE Handle, 398 1.1 jruoho ACPI_DEVICE_INFO **ReturnBuffer) 399 1.1 jruoho { 400 1.1 jruoho ACPI_NAMESPACE_NODE *Node; 401 1.1 jruoho ACPI_DEVICE_INFO *Info; 402 1.4 christos ACPI_PNP_DEVICE_ID_LIST *CidList = NULL; 403 1.4 christos ACPI_PNP_DEVICE_ID *Hid = NULL; 404 1.4 christos ACPI_PNP_DEVICE_ID *Uid = NULL; 405 1.7 christos ACPI_PNP_DEVICE_ID *Cls = NULL; 406 1.1 jruoho char *NextIdString; 407 1.1 jruoho ACPI_OBJECT_TYPE Type; 408 1.1 jruoho ACPI_NAME Name; 409 1.1 jruoho UINT8 ParamCount= 0; 410 1.7 christos UINT16 Valid = 0; 411 1.1 jruoho UINT32 InfoSize; 412 1.1 jruoho UINT32 i; 413 1.1 jruoho ACPI_STATUS Status; 414 1.1 jruoho 415 1.1 jruoho 416 1.1 jruoho /* Parameter validation */ 417 1.1 jruoho 418 1.1 jruoho if (!Handle || !ReturnBuffer) 419 1.1 jruoho { 420 1.1 jruoho return (AE_BAD_PARAMETER); 421 1.1 jruoho } 422 1.1 jruoho 423 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 424 1.1 jruoho if (ACPI_FAILURE (Status)) 425 1.1 jruoho { 426 1.4 christos return (Status); 427 1.1 jruoho } 428 1.1 jruoho 429 1.1 jruoho Node = AcpiNsValidateHandle (Handle); 430 1.1 jruoho if (!Node) 431 1.1 jruoho { 432 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 433 1.1 jruoho return (AE_BAD_PARAMETER); 434 1.1 jruoho } 435 1.1 jruoho 436 1.1 jruoho /* Get the namespace node data while the namespace is locked */ 437 1.1 jruoho 438 1.1 jruoho InfoSize = sizeof (ACPI_DEVICE_INFO); 439 1.1 jruoho Type = Node->Type; 440 1.1 jruoho Name = Node->Name.Integer; 441 1.1 jruoho 442 1.1 jruoho if (Node->Type == ACPI_TYPE_METHOD) 443 1.1 jruoho { 444 1.1 jruoho ParamCount = Node->Object->Method.ParamCount; 445 1.1 jruoho } 446 1.1 jruoho 447 1.1 jruoho Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 448 1.1 jruoho if (ACPI_FAILURE (Status)) 449 1.1 jruoho { 450 1.1 jruoho return (Status); 451 1.1 jruoho } 452 1.1 jruoho 453 1.1 jruoho if ((Type == ACPI_TYPE_DEVICE) || 454 1.1 jruoho (Type == ACPI_TYPE_PROCESSOR)) 455 1.1 jruoho { 456 1.1 jruoho /* 457 1.1 jruoho * Get extra info for ACPI Device/Processor objects only: 458 1.8 christos * Run the Device _HID, _UID, _CLS, and _CID methods. 459 1.1 jruoho * 460 1.1 jruoho * Note: none of these methods are required, so they may or may 461 1.1 jruoho * not be present for this device. The Info->Valid bitfield is used 462 1.1 jruoho * to indicate which methods were found and run successfully. 463 1.1 jruoho */ 464 1.1 jruoho 465 1.1 jruoho /* Execute the Device._HID method */ 466 1.1 jruoho 467 1.1 jruoho Status = AcpiUtExecute_HID (Node, &Hid); 468 1.1 jruoho if (ACPI_SUCCESS (Status)) 469 1.1 jruoho { 470 1.1 jruoho InfoSize += Hid->Length; 471 1.1 jruoho Valid |= ACPI_VALID_HID; 472 1.1 jruoho } 473 1.1 jruoho 474 1.1 jruoho /* Execute the Device._UID method */ 475 1.1 jruoho 476 1.1 jruoho Status = AcpiUtExecute_UID (Node, &Uid); 477 1.1 jruoho if (ACPI_SUCCESS (Status)) 478 1.1 jruoho { 479 1.1 jruoho InfoSize += Uid->Length; 480 1.1 jruoho Valid |= ACPI_VALID_UID; 481 1.1 jruoho } 482 1.1 jruoho 483 1.1 jruoho /* Execute the Device._CID method */ 484 1.1 jruoho 485 1.1 jruoho Status = AcpiUtExecute_CID (Node, &CidList); 486 1.1 jruoho if (ACPI_SUCCESS (Status)) 487 1.1 jruoho { 488 1.1 jruoho /* Add size of CID strings and CID pointer array */ 489 1.1 jruoho 490 1.4 christos InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST)); 491 1.1 jruoho Valid |= ACPI_VALID_CID; 492 1.1 jruoho } 493 1.7 christos 494 1.7 christos /* Execute the Device._CLS method */ 495 1.7 christos 496 1.7 christos Status = AcpiUtExecute_CLS (Node, &Cls); 497 1.7 christos if (ACPI_SUCCESS (Status)) 498 1.7 christos { 499 1.7 christos InfoSize += Cls->Length; 500 1.7 christos Valid |= ACPI_VALID_CLS; 501 1.7 christos } 502 1.1 jruoho } 503 1.1 jruoho 504 1.1 jruoho /* 505 1.1 jruoho * Now that we have the variable-length data, we can allocate the 506 1.1 jruoho * return buffer 507 1.1 jruoho */ 508 1.1 jruoho Info = ACPI_ALLOCATE_ZEROED (InfoSize); 509 1.1 jruoho if (!Info) 510 1.1 jruoho { 511 1.1 jruoho Status = AE_NO_MEMORY; 512 1.1 jruoho goto Cleanup; 513 1.1 jruoho } 514 1.1 jruoho 515 1.1 jruoho /* Get the fixed-length data */ 516 1.1 jruoho 517 1.1 jruoho if ((Type == ACPI_TYPE_DEVICE) || 518 1.1 jruoho (Type == ACPI_TYPE_PROCESSOR)) 519 1.1 jruoho { 520 1.1 jruoho /* 521 1.1 jruoho * Get extra info for ACPI Device/Processor objects only: 522 1.10 christos * Run the _ADR and, SxW, and _SxD methods. 523 1.1 jruoho * 524 1.4 christos * Notes: none of these methods are required, so they may or may 525 1.1 jruoho * not be present for this device. The Info->Valid bitfield is used 526 1.1 jruoho * to indicate which methods were found and run successfully. 527 1.1 jruoho */ 528 1.1 jruoho 529 1.1 jruoho /* Execute the Device._ADR method */ 530 1.1 jruoho 531 1.1 jruoho Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, 532 1.8 christos &Info->Address); 533 1.1 jruoho if (ACPI_SUCCESS (Status)) 534 1.1 jruoho { 535 1.1 jruoho Valid |= ACPI_VALID_ADR; 536 1.1 jruoho } 537 1.1 jruoho 538 1.1 jruoho /* Execute the Device._SxW methods */ 539 1.1 jruoho 540 1.1 jruoho Status = AcpiUtExecutePowerMethods (Node, 541 1.8 christos AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, 542 1.8 christos Info->LowestDstates); 543 1.1 jruoho if (ACPI_SUCCESS (Status)) 544 1.1 jruoho { 545 1.1 jruoho Valid |= ACPI_VALID_SXWS; 546 1.1 jruoho } 547 1.1 jruoho 548 1.1 jruoho /* Execute the Device._SxD methods */ 549 1.1 jruoho 550 1.1 jruoho Status = AcpiUtExecutePowerMethods (Node, 551 1.8 christos AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, 552 1.8 christos Info->HighestDstates); 553 1.1 jruoho if (ACPI_SUCCESS (Status)) 554 1.1 jruoho { 555 1.1 jruoho Valid |= ACPI_VALID_SXDS; 556 1.1 jruoho } 557 1.1 jruoho } 558 1.1 jruoho 559 1.1 jruoho /* 560 1.1 jruoho * Create a pointer to the string area of the return buffer. 561 1.1 jruoho * Point to the end of the base ACPI_DEVICE_INFO structure. 562 1.1 jruoho */ 563 1.1 jruoho NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); 564 1.1 jruoho if (CidList) 565 1.1 jruoho { 566 1.4 christos /* Point past the CID PNP_DEVICE_ID array */ 567 1.1 jruoho 568 1.4 christos NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_PNP_DEVICE_ID)); 569 1.1 jruoho } 570 1.1 jruoho 571 1.1 jruoho /* 572 1.8 christos * Copy the HID, UID, and CIDs to the return buffer. The variable-length 573 1.8 christos * strings are copied to the reserved area at the end of the buffer. 574 1.1 jruoho * 575 1.1 jruoho * For HID and CID, check if the ID is a PCI Root Bridge. 576 1.1 jruoho */ 577 1.1 jruoho if (Hid) 578 1.1 jruoho { 579 1.1 jruoho NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, 580 1.1 jruoho Hid, NextIdString); 581 1.1 jruoho 582 1.1 jruoho if (AcpiUtIsPciRootBridge (Hid->String)) 583 1.1 jruoho { 584 1.1 jruoho Info->Flags |= ACPI_PCI_ROOT_BRIDGE; 585 1.1 jruoho } 586 1.1 jruoho } 587 1.1 jruoho 588 1.1 jruoho if (Uid) 589 1.1 jruoho { 590 1.1 jruoho NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, 591 1.1 jruoho Uid, NextIdString); 592 1.1 jruoho } 593 1.1 jruoho 594 1.1 jruoho if (CidList) 595 1.1 jruoho { 596 1.1 jruoho Info->CompatibleIdList.Count = CidList->Count; 597 1.1 jruoho Info->CompatibleIdList.ListSize = CidList->ListSize; 598 1.1 jruoho 599 1.1 jruoho /* Copy each CID */ 600 1.1 jruoho 601 1.1 jruoho for (i = 0; i < CidList->Count; i++) 602 1.1 jruoho { 603 1.1 jruoho NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], 604 1.1 jruoho &CidList->Ids[i], NextIdString); 605 1.1 jruoho 606 1.1 jruoho if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) 607 1.1 jruoho { 608 1.1 jruoho Info->Flags |= ACPI_PCI_ROOT_BRIDGE; 609 1.1 jruoho } 610 1.1 jruoho } 611 1.1 jruoho } 612 1.1 jruoho 613 1.7 christos if (Cls) 614 1.7 christos { 615 1.12 christos (void) AcpiNsCopyDeviceId (&Info->ClassCode, 616 1.7 christos Cls, NextIdString); 617 1.7 christos } 618 1.7 christos 619 1.1 jruoho /* Copy the fixed-length data */ 620 1.1 jruoho 621 1.1 jruoho Info->InfoSize = InfoSize; 622 1.1 jruoho Info->Type = Type; 623 1.1 jruoho Info->Name = Name; 624 1.1 jruoho Info->ParamCount = ParamCount; 625 1.1 jruoho Info->Valid = Valid; 626 1.1 jruoho 627 1.1 jruoho *ReturnBuffer = Info; 628 1.1 jruoho Status = AE_OK; 629 1.1 jruoho 630 1.1 jruoho 631 1.1 jruoho Cleanup: 632 1.1 jruoho if (Hid) 633 1.1 jruoho { 634 1.1 jruoho ACPI_FREE (Hid); 635 1.1 jruoho } 636 1.1 jruoho if (Uid) 637 1.1 jruoho { 638 1.1 jruoho ACPI_FREE (Uid); 639 1.1 jruoho } 640 1.1 jruoho if (CidList) 641 1.1 jruoho { 642 1.1 jruoho ACPI_FREE (CidList); 643 1.1 jruoho } 644 1.7 christos if (Cls) 645 1.7 christos { 646 1.7 christos ACPI_FREE (Cls); 647 1.7 christos } 648 1.1 jruoho return (Status); 649 1.1 jruoho } 650 1.1 jruoho 651 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) 652 1.1 jruoho 653 1.1 jruoho 654 1.1 jruoho /****************************************************************************** 655 1.1 jruoho * 656 1.1 jruoho * FUNCTION: AcpiInstallMethod 657 1.1 jruoho * 658 1.1 jruoho * PARAMETERS: Buffer - An ACPI table containing one control method 659 1.1 jruoho * 660 1.1 jruoho * RETURN: Status 661 1.1 jruoho * 662 1.1 jruoho * DESCRIPTION: Install a control method into the namespace. If the method 663 1.1 jruoho * name already exists in the namespace, it is overwritten. The 664 1.1 jruoho * input buffer must contain a valid DSDT or SSDT containing a 665 1.1 jruoho * single control method. 666 1.1 jruoho * 667 1.1 jruoho ******************************************************************************/ 668 1.1 jruoho 669 1.1 jruoho ACPI_STATUS 670 1.1 jruoho AcpiInstallMethod ( 671 1.1 jruoho UINT8 *Buffer) 672 1.1 jruoho { 673 1.1 jruoho ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); 674 1.1 jruoho UINT8 *AmlBuffer; 675 1.1 jruoho UINT8 *AmlStart; 676 1.1 jruoho char *Path; 677 1.1 jruoho ACPI_NAMESPACE_NODE *Node; 678 1.1 jruoho ACPI_OPERAND_OBJECT *MethodObj; 679 1.1 jruoho ACPI_PARSE_STATE ParserState; 680 1.1 jruoho UINT32 AmlLength; 681 1.1 jruoho UINT16 Opcode; 682 1.1 jruoho UINT8 MethodFlags; 683 1.1 jruoho ACPI_STATUS Status; 684 1.1 jruoho 685 1.1 jruoho 686 1.1 jruoho /* Parameter validation */ 687 1.1 jruoho 688 1.1 jruoho if (!Buffer) 689 1.1 jruoho { 690 1.1 jruoho return (AE_BAD_PARAMETER); 691 1.1 jruoho } 692 1.1 jruoho 693 1.1 jruoho /* Table must be a DSDT or SSDT */ 694 1.1 jruoho 695 1.11 christos if (!ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT) && 696 1.11 christos !ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_SSDT)) 697 1.1 jruoho { 698 1.1 jruoho return (AE_BAD_HEADER); 699 1.1 jruoho } 700 1.1 jruoho 701 1.1 jruoho /* First AML opcode in the table must be a control method */ 702 1.1 jruoho 703 1.1 jruoho ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); 704 1.1 jruoho Opcode = AcpiPsPeekOpcode (&ParserState); 705 1.1 jruoho if (Opcode != AML_METHOD_OP) 706 1.1 jruoho { 707 1.1 jruoho return (AE_BAD_PARAMETER); 708 1.1 jruoho } 709 1.1 jruoho 710 1.1 jruoho /* Extract method information from the raw AML */ 711 1.1 jruoho 712 1.1 jruoho ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); 713 1.1 jruoho ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); 714 1.1 jruoho Path = AcpiPsGetNextNamestring (&ParserState); 715 1.8 christos 716 1.1 jruoho MethodFlags = *ParserState.Aml++; 717 1.1 jruoho AmlStart = ParserState.Aml; 718 1.13 christos AmlLength = (UINT32) ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); 719 1.1 jruoho 720 1.1 jruoho /* 721 1.1 jruoho * Allocate resources up-front. We don't want to have to delete a new 722 1.1 jruoho * node from the namespace if we cannot allocate memory. 723 1.1 jruoho */ 724 1.1 jruoho AmlBuffer = ACPI_ALLOCATE (AmlLength); 725 1.1 jruoho if (!AmlBuffer) 726 1.1 jruoho { 727 1.1 jruoho return (AE_NO_MEMORY); 728 1.1 jruoho } 729 1.1 jruoho 730 1.1 jruoho MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 731 1.1 jruoho if (!MethodObj) 732 1.1 jruoho { 733 1.1 jruoho ACPI_FREE (AmlBuffer); 734 1.1 jruoho return (AE_NO_MEMORY); 735 1.1 jruoho } 736 1.1 jruoho 737 1.1 jruoho /* Lock namespace for AcpiNsLookup, we may be creating a new node */ 738 1.1 jruoho 739 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 740 1.1 jruoho if (ACPI_FAILURE (Status)) 741 1.1 jruoho { 742 1.1 jruoho goto ErrorExit; 743 1.1 jruoho } 744 1.1 jruoho 745 1.1 jruoho /* The lookup either returns an existing node or creates a new one */ 746 1.1 jruoho 747 1.1 jruoho Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, 748 1.8 christos ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); 749 1.1 jruoho 750 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 751 1.1 jruoho 752 1.1 jruoho if (ACPI_FAILURE (Status)) /* NsLookup */ 753 1.1 jruoho { 754 1.1 jruoho if (Status != AE_ALREADY_EXISTS) 755 1.1 jruoho { 756 1.1 jruoho goto ErrorExit; 757 1.1 jruoho } 758 1.1 jruoho 759 1.1 jruoho /* Node existed previously, make sure it is a method node */ 760 1.1 jruoho 761 1.1 jruoho if (Node->Type != ACPI_TYPE_METHOD) 762 1.1 jruoho { 763 1.1 jruoho Status = AE_TYPE; 764 1.1 jruoho goto ErrorExit; 765 1.1 jruoho } 766 1.1 jruoho } 767 1.1 jruoho 768 1.1 jruoho /* Copy the method AML to the local buffer */ 769 1.1 jruoho 770 1.7 christos memcpy (AmlBuffer, AmlStart, AmlLength); 771 1.1 jruoho 772 1.1 jruoho /* Initialize the method object with the new method's information */ 773 1.1 jruoho 774 1.1 jruoho MethodObj->Method.AmlStart = AmlBuffer; 775 1.1 jruoho MethodObj->Method.AmlLength = AmlLength; 776 1.1 jruoho 777 1.1 jruoho MethodObj->Method.ParamCount = (UINT8) 778 1.1 jruoho (MethodFlags & AML_METHOD_ARG_COUNT); 779 1.1 jruoho 780 1.1 jruoho if (MethodFlags & AML_METHOD_SERIALIZED) 781 1.1 jruoho { 782 1.3 jruoho MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED; 783 1.3 jruoho 784 1.1 jruoho MethodObj->Method.SyncLevel = (UINT8) 785 1.1 jruoho ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); 786 1.1 jruoho } 787 1.1 jruoho 788 1.1 jruoho /* 789 1.1 jruoho * Now that it is complete, we can attach the new method object to 790 1.1 jruoho * the method Node (detaches/deletes any existing object) 791 1.1 jruoho */ 792 1.3 jruoho Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD); 793 1.1 jruoho 794 1.1 jruoho /* 795 1.1 jruoho * Flag indicates AML buffer is dynamic, must be deleted later. 796 1.1 jruoho * Must be set only after attach above. 797 1.1 jruoho */ 798 1.1 jruoho Node->Flags |= ANOBJ_ALLOCATED_BUFFER; 799 1.1 jruoho 800 1.1 jruoho /* Remove local reference to the method object */ 801 1.1 jruoho 802 1.1 jruoho AcpiUtRemoveReference (MethodObj); 803 1.1 jruoho return (Status); 804 1.1 jruoho 805 1.1 jruoho 806 1.1 jruoho ErrorExit: 807 1.1 jruoho 808 1.1 jruoho ACPI_FREE (AmlBuffer); 809 1.1 jruoho ACPI_FREE (MethodObj); 810 1.1 jruoho return (Status); 811 1.1 jruoho } 812 1.1 jruoho 813 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiInstallMethod) 814