nsxfname.c revision 117521
167754Smsmith/****************************************************************************** 267754Smsmith * 367754Smsmith * Module Name: nsxfname - Public interfaces to the ACPI subsystem 467754Smsmith * ACPI Namespace oriented interfaces 5117521Snjl * $Revision: 97 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 13114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 1470243Smsmith * All rights reserved. 1567754Smsmith * 1667754Smsmith * 2. License 1767754Smsmith * 1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1967754Smsmith * rights. You may have additional license terms from the party that provided 2067754Smsmith * you this software, covering your right to use that party's intellectual 2167754Smsmith * property rights. 2267754Smsmith * 2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2867754Smsmith * Code in any form, with the right to sublicense such rights; and 2967754Smsmith * 3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3167754Smsmith * license (with the right to sublicense), under only those claims of Intel 3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3567754Smsmith * license, and in no event shall the patent license extend to any additions 3667754Smsmith * to or modifications of the Original Intel Code. No other license or right 3767754Smsmith * is granted directly or by implication, estoppel or otherwise; 3867754Smsmith * 3967754Smsmith * The above copyright and patent license is granted only if the following 4067754Smsmith * conditions are met: 4167754Smsmith * 4267754Smsmith * 3. Conditions 4367754Smsmith * 4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4567754Smsmith * Redistribution of source code of any substantial portion of the Covered 4667754Smsmith * Code or modification with rights to further distribute source must include 4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4867754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5167754Smsmith * Code and the date of any change. Licensee must include in that file the 5267754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5367754Smsmith * must include a prominent statement that the modification is derived, 5467754Smsmith * directly or indirectly, from Original Intel Code. 5567754Smsmith * 5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5767754Smsmith * Redistribution of source code of any substantial portion of the Covered 5867754Smsmith * Code or modification without rights to further distribute source must 5967754Smsmith * include the following Disclaimer and Export Compliance provision in the 6067754Smsmith * documentation and/or other materials provided with distribution. In 6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6367754Smsmith * license from Licensee to its licensee is limited to the intellectual 6467754Smsmith * property embodied in the software Licensee provides to its licensee, and 6567754Smsmith * not to intellectual property embodied in modifications its licensee may 6667754Smsmith * make. 6767754Smsmith * 6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7167754Smsmith * provision in the documentation and/or other materials provided with the 7267754Smsmith * distribution. 7367754Smsmith * 7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7567754Smsmith * Intel Code. 7667754Smsmith * 7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7967754Smsmith * other dealings in products derived from or relating to the Covered Code 8067754Smsmith * without prior written authorization from Intel. 8167754Smsmith * 8267754Smsmith * 4. Disclaimer and Export Compliance 8367754Smsmith * 8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8567754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9067754Smsmith * PARTICULAR PURPOSE. 9167754Smsmith * 9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9967754Smsmith * LIMITED REMEDY. 10067754Smsmith * 10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10267754Smsmith * software or system incorporating such software without first obtaining any 10367754Smsmith * required license or other approval from the U. S. Department of Commerce or 10467754Smsmith * any other agency or department of the United States Government. In the 10567754Smsmith * event Licensee exports any such software from the United States or 10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10767754Smsmith * ensure that the distribution and export/re-export of the software is in 10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11167754Smsmith * software, or service, directly or indirectly, to any country for which the 11267754Smsmith * United States government or any agency thereof requires an export license, 11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11467754Smsmith * such license, approval or letter. 11567754Smsmith * 11667754Smsmith *****************************************************************************/ 11767754Smsmith 11867754Smsmith#define __NSXFNAME_C__ 11967754Smsmith 12067754Smsmith#include "acpi.h" 12167754Smsmith#include "acnamesp.h" 12267754Smsmith 12367754Smsmith 12477424Smsmith#define _COMPONENT ACPI_NAMESPACE 12591116Smsmith ACPI_MODULE_NAME ("nsxfname") 12667754Smsmith 12767754Smsmith 128117521Snjl/****************************************************************************** 12967754Smsmith * 13067754Smsmith * FUNCTION: AcpiGetHandle 13167754Smsmith * 13267754Smsmith * PARAMETERS: Parent - Object to search under (search scope). 13367754Smsmith * PathName - Pointer to an asciiz string containing the 13467754Smsmith * name 13567754Smsmith * RetHandle - Where the return handle is placed 13667754Smsmith * 13767754Smsmith * RETURN: Status 13867754Smsmith * 13967754Smsmith * DESCRIPTION: This routine will search for a caller specified name in the 14067754Smsmith * name space. The caller can restrict the search region by 14167754Smsmith * specifying a non NULL parent. The parent value is itself a 14267754Smsmith * namespace handle. 14367754Smsmith * 14467754Smsmith ******************************************************************************/ 14567754Smsmith 14667754SmsmithACPI_STATUS 14767754SmsmithAcpiGetHandle ( 14867754Smsmith ACPI_HANDLE Parent, 14967754Smsmith ACPI_STRING Pathname, 15067754Smsmith ACPI_HANDLE *RetHandle) 15167754Smsmith{ 15267754Smsmith ACPI_STATUS Status; 15369450Smsmith ACPI_NAMESPACE_NODE *Node = NULL; 15467754Smsmith ACPI_NAMESPACE_NODE *PrefixNode = NULL; 15567754Smsmith 15667754Smsmith 15791116Smsmith ACPI_FUNCTION_ENTRY (); 15883174Smsmith 15983174Smsmith 16077424Smsmith /* Parameter Validation */ 16177424Smsmith 16267754Smsmith if (!RetHandle || !Pathname) 16367754Smsmith { 16467754Smsmith return (AE_BAD_PARAMETER); 16567754Smsmith } 16667754Smsmith 16769746Smsmith /* Convert a parent handle to a prefix node */ 16869746Smsmith 16967754Smsmith if (Parent) 17067754Smsmith { 17191116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 17291116Smsmith if (ACPI_FAILURE (Status)) 17391116Smsmith { 17491116Smsmith return (Status); 17591116Smsmith } 17667754Smsmith 17785756Smsmith PrefixNode = AcpiNsMapHandleToNode (Parent); 17869450Smsmith if (!PrefixNode) 17967754Smsmith { 18091116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 18167754Smsmith return (AE_BAD_PARAMETER); 18267754Smsmith } 18367754Smsmith 18491116Smsmith Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 18591116Smsmith if (ACPI_FAILURE (Status)) 18691116Smsmith { 18791116Smsmith return (Status); 18891116Smsmith } 18967754Smsmith } 19067754Smsmith 19167754Smsmith /* Special case for root, since we can't search for it */ 19267754Smsmith 19391116Smsmith if (ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH) == 0) 19467754Smsmith { 19567754Smsmith *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); 19667754Smsmith return (AE_OK); 19767754Smsmith } 19867754Smsmith 19967754Smsmith /* 20069746Smsmith * Find the Node and convert to a handle 20167754Smsmith */ 202117521Snjl Status = AcpiNsGetNodeByPath (Pathname, PrefixNode, ACPI_NS_NO_UPSEARCH, 203117521Snjl &Node); 20467754Smsmith 20567754Smsmith *RetHandle = NULL; 20669746Smsmith if (ACPI_SUCCESS (Status)) 20767754Smsmith { 20867754Smsmith *RetHandle = AcpiNsConvertEntryToHandle (Node); 20967754Smsmith } 21067754Smsmith 21167754Smsmith return (Status); 21267754Smsmith} 21367754Smsmith 21467754Smsmith 215117521Snjl/****************************************************************************** 21667754Smsmith * 21783174Smsmith * FUNCTION: AcpiGetName 21867754Smsmith * 21967754Smsmith * PARAMETERS: Handle - Handle to be converted to a pathname 22067754Smsmith * NameType - Full pathname or single segment 22191116Smsmith * Buffer - Buffer for returned path 22267754Smsmith * 22367754Smsmith * RETURN: Pointer to a string containing the fully qualified Name. 22467754Smsmith * 22567754Smsmith * DESCRIPTION: This routine returns the fully qualified name associated with 22667754Smsmith * the Handle parameter. This and the AcpiPathnameToHandle are 22767754Smsmith * complementary functions. 22867754Smsmith * 22967754Smsmith ******************************************************************************/ 23067754Smsmith 23167754SmsmithACPI_STATUS 23267754SmsmithAcpiGetName ( 23367754Smsmith ACPI_HANDLE Handle, 23467754Smsmith UINT32 NameType, 23591116Smsmith ACPI_BUFFER *Buffer) 23667754Smsmith{ 23767754Smsmith ACPI_STATUS Status; 23867754Smsmith ACPI_NAMESPACE_NODE *Node; 23967754Smsmith 24067754Smsmith 24191116Smsmith /* Parameter validation */ 24267754Smsmith 24391116Smsmith if (NameType > ACPI_NAME_TYPE_MAX) 24467754Smsmith { 24567754Smsmith return (AE_BAD_PARAMETER); 24667754Smsmith } 24767754Smsmith 24891116Smsmith Status = AcpiUtValidateBuffer (Buffer); 24991116Smsmith if (ACPI_FAILURE (Status)) 25067754Smsmith { 25191116Smsmith return (Status); 25267754Smsmith } 25367754Smsmith 25467754Smsmith if (NameType == ACPI_FULL_PATHNAME) 25567754Smsmith { 25667754Smsmith /* Get the full pathname (From the namespace root) */ 25767754Smsmith 25891116Smsmith Status = AcpiNsHandleToPathname (Handle, Buffer); 25967754Smsmith return (Status); 26067754Smsmith } 26167754Smsmith 26267754Smsmith /* 26367754Smsmith * Wants the single segment ACPI name. 26491116Smsmith * Validate handle and convert to a namespace Node 26567754Smsmith */ 26691116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 26791116Smsmith if (ACPI_FAILURE (Status)) 26891116Smsmith { 26991116Smsmith return (Status); 27091116Smsmith } 27191116Smsmith 27285756Smsmith Node = AcpiNsMapHandleToNode (Handle); 27367754Smsmith if (!Node) 27467754Smsmith { 27567754Smsmith Status = AE_BAD_PARAMETER; 27667754Smsmith goto UnlockAndExit; 27767754Smsmith } 27867754Smsmith 27991116Smsmith /* Validate/Allocate/Clear caller buffer */ 28067754Smsmith 281114237Snjl Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); 28291116Smsmith if (ACPI_FAILURE (Status)) 28367754Smsmith { 28467754Smsmith goto UnlockAndExit; 28567754Smsmith } 28667754Smsmith 28767754Smsmith /* Just copy the ACPI name from the Node and zero terminate it */ 28867754Smsmith 28999679Siwasaki ACPI_STRNCPY (Buffer->Pointer, Node->Name.Ascii, 29067754Smsmith ACPI_NAME_SIZE); 291114237Snjl ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; 29267754Smsmith Status = AE_OK; 29367754Smsmith 29467754Smsmith 29567754SmsmithUnlockAndExit: 29667754Smsmith 29791116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 29867754Smsmith return (Status); 29967754Smsmith} 30067754Smsmith 30167754Smsmith 302117521Snjl/****************************************************************************** 30367754Smsmith * 30467754Smsmith * FUNCTION: AcpiGetObjectInfo 30567754Smsmith * 30667754Smsmith * PARAMETERS: Handle - Object Handle 30767754Smsmith * Info - Where the info is returned 30867754Smsmith * 30967754Smsmith * RETURN: Status 31067754Smsmith * 31167754Smsmith * DESCRIPTION: Returns information about an object as gleaned from the 31267754Smsmith * namespace node and possibly by running several standard 31367754Smsmith * control methods (Such as in the case of a device.) 31467754Smsmith * 31567754Smsmith ******************************************************************************/ 31667754Smsmith 31767754SmsmithACPI_STATUS 31867754SmsmithAcpiGetObjectInfo ( 31967754Smsmith ACPI_HANDLE Handle, 320117521Snjl ACPI_BUFFER *Buffer) 32167754Smsmith{ 32267754Smsmith ACPI_STATUS Status; 32367754Smsmith ACPI_NAMESPACE_NODE *Node; 324117521Snjl ACPI_DEVICE_INFO Info; 325117521Snjl ACPI_DEVICE_INFO *ReturnInfo; 326117521Snjl ACPI_COMPATIBLE_ID_LIST *CidList = NULL; 327117521Snjl ACPI_SIZE Size; 32867754Smsmith 32967754Smsmith 33067754Smsmith /* Parameter validation */ 33167754Smsmith 332117521Snjl if (!Handle || !Buffer) 33367754Smsmith { 33467754Smsmith return (AE_BAD_PARAMETER); 33567754Smsmith } 33667754Smsmith 337117521Snjl Status = AcpiUtValidateBuffer (Buffer); 338117521Snjl if (ACPI_FAILURE (Status)) 339117521Snjl { 340117521Snjl return (Status); 341117521Snjl } 342117521Snjl 34391116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 34491116Smsmith if (ACPI_FAILURE (Status)) 34591116Smsmith { 34691116Smsmith return (Status); 34791116Smsmith } 34867754Smsmith 34985756Smsmith Node = AcpiNsMapHandleToNode (Handle); 35067754Smsmith if (!Node) 35167754Smsmith { 35291116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 35367754Smsmith return (AE_BAD_PARAMETER); 35467754Smsmith } 35567754Smsmith 356117521Snjl /* Init return structure */ 35767754Smsmith 358117521Snjl Size = sizeof (ACPI_DEVICE_INFO); 359117521Snjl ACPI_MEMSET (&Info, 0, Size); 360117521Snjl 361117521Snjl Info.Type = Node->Type; 362117521Snjl Info.Name = Node->Name.Integer; 363117521Snjl Info.Valid = 0; 364117521Snjl 36591116Smsmith Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 36691116Smsmith if (ACPI_FAILURE (Status)) 36791116Smsmith { 36891116Smsmith return (Status); 36991116Smsmith } 37067754Smsmith 371117521Snjl /* If not a device, we are all done */ 372117521Snjl 373117521Snjl if (Info.Type == ACPI_TYPE_DEVICE) 37467754Smsmith { 375117521Snjl /* 376117521Snjl * Get extra info for ACPI Devices objects only: 377117521Snjl * Run the Device _HID, _UID, _CID, _STA, and _ADR methods. 378117521Snjl * 379117521Snjl * Note: none of these methods are required, so they may or may 380117521Snjl * not be present for this device. The Info.Valid bitfield is used 381117521Snjl * to indicate which methods were found and ran successfully. 382117521Snjl */ 38367754Smsmith 384117521Snjl /* Execute the Device._HID method */ 38567754Smsmith 386117521Snjl Status = AcpiUtExecute_HID (Node, &Info.HardwareId); 387117521Snjl if (ACPI_SUCCESS (Status)) 388117521Snjl { 389117521Snjl Info.Valid |= ACPI_VALID_HID; 390117521Snjl } 39167754Smsmith 392117521Snjl /* Execute the Device._UID method */ 39367754Smsmith 394117521Snjl Status = AcpiUtExecute_UID (Node, &Info.UniqueId); 395117521Snjl if (ACPI_SUCCESS (Status)) 396117521Snjl { 397117521Snjl Info.Valid |= ACPI_VALID_UID; 398117521Snjl } 399117521Snjl 400117521Snjl /* Execute the Device._CID method */ 401117521Snjl 402117521Snjl Status = AcpiUtExecute_CID (Node, &CidList); 403117521Snjl if (ACPI_SUCCESS (Status)) 404117521Snjl { 405117521Snjl Size += ((ACPI_SIZE) CidList->Count - 1) * 406117521Snjl sizeof (ACPI_COMPATIBLE_ID); 407117521Snjl Info.Valid |= ACPI_VALID_CID; 408117521Snjl } 409117521Snjl 410117521Snjl /* Execute the Device._STA method */ 411117521Snjl 412117521Snjl Status = AcpiUtExecute_STA (Node, &Info.CurrentStatus); 413117521Snjl if (ACPI_SUCCESS (Status)) 414117521Snjl { 415117521Snjl Info.Valid |= ACPI_VALID_STA; 416117521Snjl } 417117521Snjl 418117521Snjl /* Execute the Device._ADR method */ 419117521Snjl 420117521Snjl Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, 421117521Snjl &Info.Address); 422117521Snjl if (ACPI_SUCCESS (Status)) 423117521Snjl { 424117521Snjl Info.Valid |= ACPI_VALID_ADR; 425117521Snjl } 426117521Snjl 427117521Snjl Status = AE_OK; 42867754Smsmith } 42967754Smsmith 430117521Snjl /* Validate/Allocate/Clear caller buffer */ 43167754Smsmith 432117521Snjl Status = AcpiUtInitializeBuffer (Buffer, Size); 433117521Snjl if (ACPI_FAILURE (Status)) 43467754Smsmith { 435117521Snjl goto Cleanup; 43667754Smsmith } 43767754Smsmith 438117521Snjl /* Populate the return buffer */ 439117521Snjl 440117521Snjl ReturnInfo = Buffer->Pointer; 441117521Snjl ACPI_MEMCPY (ReturnInfo, &Info, sizeof (ACPI_DEVICE_INFO)); 442117521Snjl 443117521Snjl if (CidList) 44467754Smsmith { 445117521Snjl ACPI_MEMCPY (&ReturnInfo->CompatibilityId, CidList, CidList->Size); 44667754Smsmith } 44767754Smsmith 44867754Smsmith 449117521SnjlCleanup: 450117521Snjl if (CidList) 45167754Smsmith { 452117521Snjl ACPI_MEM_FREE (CidList); 45367754Smsmith } 454117521Snjl return (Status); 45567754Smsmith} 45667754Smsmith 457