nsxfobj.c revision 100966
1219820Sjeff/******************************************************************************* 2219820Sjeff * 3219820Sjeff * Module Name: nsxfobj - Public interfaces to the ACPI subsystem 4219820Sjeff * ACPI Object oriented interfaces 5219820Sjeff * $Revision: 113 $ 6219820Sjeff * 7219820Sjeff ******************************************************************************/ 8219820Sjeff 9219820Sjeff/****************************************************************************** 10219820Sjeff * 11219820Sjeff * 1. Copyright Notice 12219820Sjeff * 13219820Sjeff * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 14219820Sjeff * All rights reserved. 15219820Sjeff * 16219820Sjeff * 2. License 17219820Sjeff * 18219820Sjeff * 2.1. This is your license from Intel Corp. under its intellectual property 19219820Sjeff * rights. You may have additional license terms from the party that provided 20219820Sjeff * you this software, covering your right to use that party's intellectual 21219820Sjeff * property rights. 22219820Sjeff * 23219820Sjeff * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24219820Sjeff * copy of the source code appearing in this file ("Covered Code") an 25219820Sjeff * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26219820Sjeff * base code distributed originally by Intel ("Original Intel Code") to copy, 27219820Sjeff * make derivatives, distribute, use and display any portion of the Covered 28219820Sjeff * Code in any form, with the right to sublicense such rights; and 29219820Sjeff * 30219820Sjeff * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31219820Sjeff * license (with the right to sublicense), under only those claims of Intel 32219820Sjeff * patents that are infringed by the Original Intel Code, to make, use, sell, 33219820Sjeff * offer to sell, and import the Covered Code and derivative works thereof 34219820Sjeff * solely to the minimum extent necessary to exercise the above copyright 35219820Sjeff * license, and in no event shall the patent license extend to any additions 36219820Sjeff * to or modifications of the Original Intel Code. No other license or right 37219820Sjeff * is granted directly or by implication, estoppel or otherwise; 38219820Sjeff * 39219820Sjeff * The above copyright and patent license is granted only if the following 40219820Sjeff * conditions are met: 41219820Sjeff * 42219820Sjeff * 3. Conditions 43219820Sjeff * 44219820Sjeff * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45219820Sjeff * Redistribution of source code of any substantial portion of the Covered 46219820Sjeff * Code or modification with rights to further distribute source must include 47219820Sjeff * the above Copyright Notice, the above License, this list of Conditions, 48219820Sjeff * and the following Disclaimer and Export Compliance provision. In addition, 49219820Sjeff * Licensee must cause all Covered Code to which Licensee contributes to 50219820Sjeff * contain a file documenting the changes Licensee made to create that Covered 51219820Sjeff * Code and the date of any change. Licensee must include in that file the 52219820Sjeff * documentation of any changes made by any predecessor Licensee. Licensee 53219820Sjeff * must include a prominent statement that the modification is derived, 54219820Sjeff * directly or indirectly, from Original Intel Code. 55219820Sjeff * 56219820Sjeff * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57219820Sjeff * Redistribution of source code of any substantial portion of the Covered 58219820Sjeff * Code or modification without rights to further distribute source must 59219820Sjeff * include the following Disclaimer and Export Compliance provision in the 60219820Sjeff * documentation and/or other materials provided with distribution. In 61219820Sjeff * addition, Licensee may not authorize further sublicense of source of any 62219820Sjeff * portion of the Covered Code, and must include terms to the effect that the 63219820Sjeff * license from Licensee to its licensee is limited to the intellectual 64219820Sjeff * property embodied in the software Licensee provides to its licensee, and 65219820Sjeff * not to intellectual property embodied in modifications its licensee may 66219820Sjeff * make. 67219820Sjeff * 68219820Sjeff * 3.3. Redistribution of Executable. Redistribution in executable form of any 69219820Sjeff * substantial portion of the Covered Code or modification must reproduce the 70219820Sjeff * above Copyright Notice, and the following Disclaimer and Export Compliance 71219820Sjeff * provision in the documentation and/or other materials provided with the 72219820Sjeff * distribution. 73219820Sjeff * 74219820Sjeff * 3.4. Intel retains all right, title, and interest in and to the Original 75219820Sjeff * Intel Code. 76219820Sjeff * 77219820Sjeff * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78219820Sjeff * Intel shall be used in advertising or otherwise to promote the sale, use or 79219820Sjeff * other dealings in products derived from or relating to the Covered Code 80219820Sjeff * without prior written authorization from Intel. 81219820Sjeff * 82219820Sjeff * 4. Disclaimer and Export Compliance 83219820Sjeff * 84219820Sjeff * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85219820Sjeff * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86219820Sjeff * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87219820Sjeff * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88219820Sjeff * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90219820Sjeff * PARTICULAR PURPOSE. 91219820Sjeff * 92219820Sjeff * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93219820Sjeff * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94219820Sjeff * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95219820Sjeff * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96219820Sjeff * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97219820Sjeff * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98219820Sjeff * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99219820Sjeff * LIMITED REMEDY. 100219820Sjeff * 101219820Sjeff * 4.3. Licensee shall not export, either directly or indirectly, any of this 102219820Sjeff * software or system incorporating such software without first obtaining any 103219820Sjeff * required license or other approval from the U. S. Department of Commerce or 104219820Sjeff * any other agency or department of the United States Government. In the 105219820Sjeff * event Licensee exports any such software from the United States or 106219820Sjeff * re-exports any such software from a foreign destination, Licensee shall 107219820Sjeff * ensure that the distribution and export/re-export of the software is in 108219820Sjeff * compliance with all laws, regulations, orders, or other restrictions of the 109219820Sjeff * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110219820Sjeff * any of its subsidiaries will export/re-export any technical data, process, 111219820Sjeff * software, or service, directly or indirectly, to any country for which the 112219820Sjeff * United States government or any agency thereof requires an export license, 113219820Sjeff * other governmental approval, or letter of assurance, without first obtaining 114219820Sjeff * such license, approval or letter. 115219820Sjeff * 116219820Sjeff *****************************************************************************/ 117219820Sjeff 118219820Sjeff 119219820Sjeff#define __NSXFOBJ_C__ 120219820Sjeff 121219820Sjeff#include "acpi.h" 122219820Sjeff#include "acnamesp.h" 123219820Sjeff 124219820Sjeff 125219820Sjeff#define _COMPONENT ACPI_NAMESPACE 126219820Sjeff ACPI_MODULE_NAME ("nsxfobj") 127219820Sjeff 128219820Sjeff/******************************************************************************* 129219820Sjeff * 130219820Sjeff * FUNCTION: AcpiGetType 131219820Sjeff * 132219820Sjeff * PARAMETERS: Handle - Handle of object whose type is desired 133219820Sjeff * *RetType - Where the type will be placed 134219820Sjeff * 135219820Sjeff * RETURN: Status 136219820Sjeff * 137219820Sjeff * DESCRIPTION: This routine returns the type associatd with a particular handle 138219820Sjeff * 139219820Sjeff ******************************************************************************/ 140219820Sjeff 141219820SjeffACPI_STATUS 142219820SjeffAcpiGetType ( 143219820Sjeff ACPI_HANDLE Handle, 144219820Sjeff ACPI_OBJECT_TYPE *RetType) 145219820Sjeff{ 146219820Sjeff ACPI_NAMESPACE_NODE *Node; 147219820Sjeff ACPI_STATUS Status; 148219820Sjeff 149219820Sjeff 150219820Sjeff /* Parameter Validation */ 151219820Sjeff 152219820Sjeff if (!RetType) 153219820Sjeff { 154219820Sjeff return (AE_BAD_PARAMETER); 155219820Sjeff } 156219820Sjeff 157219820Sjeff /* 158219820Sjeff * Special case for the predefined Root Node 159219820Sjeff * (return type ANY) 160219820Sjeff */ 161219820Sjeff if (Handle == ACPI_ROOT_OBJECT) 162219820Sjeff { 163219820Sjeff *RetType = ACPI_TYPE_ANY; 164219820Sjeff return (AE_OK); 165219820Sjeff } 166219820Sjeff 167219820Sjeff Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 168219820Sjeff if (ACPI_FAILURE (Status)) 169219820Sjeff { 170219820Sjeff return (Status); 171219820Sjeff } 172219820Sjeff 173219820Sjeff /* Convert and validate the handle */ 174219820Sjeff 175219820Sjeff Node = AcpiNsMapHandleToNode (Handle); 176219820Sjeff if (!Node) 177219820Sjeff { 178219820Sjeff (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 179219820Sjeff return (AE_BAD_PARAMETER); 180219820Sjeff } 181219820Sjeff 182219820Sjeff *RetType = Node->Type; 183219820Sjeff 184219820Sjeff 185219820Sjeff Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 186219820Sjeff return (Status); 187219820Sjeff} 188219820Sjeff 189219820Sjeff 190219820Sjeff/******************************************************************************* 191219820Sjeff * 192219820Sjeff * FUNCTION: AcpiGetParent 193219820Sjeff * 194219820Sjeff * PARAMETERS: Handle - Handle of object whose parent is desired 195219820Sjeff * RetHandle - Where the parent handle will be placed 196219820Sjeff * 197219820Sjeff * RETURN: Status 198219820Sjeff * 199219820Sjeff * DESCRIPTION: Returns a handle to the parent of the object represented by 200219820Sjeff * Handle. 201219820Sjeff * 202219820Sjeff ******************************************************************************/ 203219820Sjeff 204219820SjeffACPI_STATUS 205219820SjeffAcpiGetParent ( 206219820Sjeff ACPI_HANDLE Handle, 207219820Sjeff ACPI_HANDLE *RetHandle) 208219820Sjeff{ 209219820Sjeff ACPI_NAMESPACE_NODE *Node; 210219820Sjeff ACPI_STATUS Status; 211219820Sjeff 212219820Sjeff 213219820Sjeff if (!RetHandle) 214219820Sjeff { 215219820Sjeff return (AE_BAD_PARAMETER); 216219820Sjeff } 217219820Sjeff 218219820Sjeff /* Special case for the predefined Root Node (no parent) */ 219219820Sjeff 220219820Sjeff if (Handle == ACPI_ROOT_OBJECT) 221219820Sjeff { 222219820Sjeff return (AE_NULL_ENTRY); 223219820Sjeff } 224219820Sjeff 225219820Sjeff Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 226219820Sjeff if (ACPI_FAILURE (Status)) 227219820Sjeff { 228219820Sjeff return (Status); 229219820Sjeff } 230219820Sjeff 231219820Sjeff /* Convert and validate the handle */ 232219820Sjeff 233219820Sjeff Node = AcpiNsMapHandleToNode (Handle); 234219820Sjeff if (!Node) 235219820Sjeff { 236219820Sjeff Status = AE_BAD_PARAMETER; 237219820Sjeff goto UnlockAndExit; 238219820Sjeff } 239219820Sjeff 240219820Sjeff /* Get the parent entry */ 241219820Sjeff 242219820Sjeff *RetHandle = 243219820Sjeff AcpiNsConvertEntryToHandle (AcpiNsGetParentNode (Node)); 244219820Sjeff 245219820Sjeff /* Return exeption if parent is null */ 246219820Sjeff 247219820Sjeff if (!AcpiNsGetParentNode (Node)) 248219820Sjeff { 249219820Sjeff Status = AE_NULL_ENTRY; 250219820Sjeff } 251219820Sjeff 252219820Sjeff 253219820SjeffUnlockAndExit: 254219820Sjeff 255219820Sjeff (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 256219820Sjeff return (Status); 257219820Sjeff} 258219820Sjeff 259219820Sjeff 260219820Sjeff/******************************************************************************* 261219820Sjeff * 262219820Sjeff * FUNCTION: AcpiGetNextObject 263219820Sjeff * 264219820Sjeff * PARAMETERS: Type - Type of object to be searched for 265219820Sjeff * Parent - Parent object whose children we are getting 266219820Sjeff * LastChild - Previous child that was found. 267219820Sjeff * The NEXT child will be returned 268219820Sjeff * RetHandle - Where handle to the next object is placed 269219820Sjeff * 270219820Sjeff * RETURN: Status 271219820Sjeff * 272219820Sjeff * DESCRIPTION: Return the next peer object within the namespace. If Handle is 273219820Sjeff * valid, Scope is ignored. Otherwise, the first object within 274219820Sjeff * Scope is returned. 275219820Sjeff * 276219820Sjeff ******************************************************************************/ 277219820Sjeff 278219820SjeffACPI_STATUS 279219820SjeffAcpiGetNextObject ( 280219820Sjeff ACPI_OBJECT_TYPE Type, 281219820Sjeff ACPI_HANDLE Parent, 282219820Sjeff ACPI_HANDLE Child, 283219820Sjeff ACPI_HANDLE *RetHandle) 284219820Sjeff{ 285219820Sjeff ACPI_STATUS Status; 286219820Sjeff ACPI_NAMESPACE_NODE *Node; 287219820Sjeff ACPI_NAMESPACE_NODE *ParentNode = NULL; 288219820Sjeff ACPI_NAMESPACE_NODE *ChildNode = NULL; 289219820Sjeff 290219820Sjeff 291219820Sjeff /* Parameter validation */ 292219820Sjeff 293219820Sjeff if (Type > ACPI_TYPE_MAX) 294219820Sjeff { 295219820Sjeff return (AE_BAD_PARAMETER); 296219820Sjeff } 297219820Sjeff 298219820Sjeff Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 299219820Sjeff if (ACPI_FAILURE (Status)) 300219820Sjeff { 301219820Sjeff return (Status); 302219820Sjeff } 303219820Sjeff 304219820Sjeff /* If null handle, use the parent */ 305219820Sjeff 306219820Sjeff if (!Child) 307219820Sjeff { 308219820Sjeff /* Start search at the beginning of the specified scope */ 309219820Sjeff 310219820Sjeff ParentNode = AcpiNsMapHandleToNode (Parent); 311219820Sjeff if (!ParentNode) 312219820Sjeff { 313219820Sjeff Status = AE_BAD_PARAMETER; 314219820Sjeff goto UnlockAndExit; 315219820Sjeff } 316219820Sjeff } 317219820Sjeff else 318219820Sjeff { 319219820Sjeff /* Non-null handle, ignore the parent */ 320219820Sjeff /* Convert and validate the handle */ 321219820Sjeff 322219820Sjeff ChildNode = AcpiNsMapHandleToNode (Child); 323219820Sjeff if (!ChildNode) 324219820Sjeff { 325219820Sjeff Status = AE_BAD_PARAMETER; 326219820Sjeff goto UnlockAndExit; 327219820Sjeff } 328219820Sjeff } 329219820Sjeff 330219820Sjeff /* Internal function does the real work */ 331219820Sjeff 332219820Sjeff Node = AcpiNsGetNextNode (Type, ParentNode, ChildNode); 333219820Sjeff if (!Node) 334219820Sjeff { 335219820Sjeff Status = AE_NOT_FOUND; 336219820Sjeff goto UnlockAndExit; 337219820Sjeff } 338219820Sjeff 339219820Sjeff if (RetHandle) 340219820Sjeff { 341219820Sjeff *RetHandle = AcpiNsConvertEntryToHandle (Node); 342219820Sjeff } 343219820Sjeff 344219820Sjeff 345219820SjeffUnlockAndExit: 346219820Sjeff 347219820Sjeff (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 348219820Sjeff return (Status); 349219820Sjeff} 350219820Sjeff 351219820Sjeff 352219820Sjeff