1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
48 #include <contrib/dev/acpica/include/acpi.h>
49 #include <contrib/dev/acpica/include/accommon.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
53 #define _COMPONENT ACPI_NAMESPACE
54 ACPI_MODULE_NAME ("nsxfobj")
56 /*******************************************************************************
58 * FUNCTION: AcpiGetType
60 * PARAMETERS: Handle - Handle of object whose type is desired
61 * RetType - Where the type will be placed
65 * DESCRIPTION: This routine returns the type associatd with a particular handle
67 ******************************************************************************/
72 ACPI_OBJECT_TYPE *RetType)
74 ACPI_NAMESPACE_NODE *Node;
78 /* Parameter Validation */
82 return (AE_BAD_PARAMETER);
86 * Special case for the predefined Root Node
89 if (Handle == ACPI_ROOT_OBJECT)
91 *RetType = ACPI_TYPE_ANY;
95 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
96 if (ACPI_FAILURE (Status))
101 /* Convert and validate the handle */
103 Node = AcpiNsValidateHandle (Handle);
106 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
107 return (AE_BAD_PARAMETER);
110 *RetType = Node->Type;
113 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
117 ACPI_EXPORT_SYMBOL (AcpiGetType)
120 /*******************************************************************************
122 * FUNCTION: AcpiGetParent
124 * PARAMETERS: Handle - Handle of object whose parent is desired
125 * RetHandle - Where the parent handle will be placed
129 * DESCRIPTION: Returns a handle to the parent of the object represented by
132 ******************************************************************************/
137 ACPI_HANDLE *RetHandle)
139 ACPI_NAMESPACE_NODE *Node;
140 ACPI_NAMESPACE_NODE *ParentNode;
146 return (AE_BAD_PARAMETER);
149 /* Special case for the predefined Root Node (no parent) */
151 if (Handle == ACPI_ROOT_OBJECT)
153 return (AE_NULL_ENTRY);
156 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
157 if (ACPI_FAILURE (Status))
162 /* Convert and validate the handle */
164 Node = AcpiNsValidateHandle (Handle);
167 Status = AE_BAD_PARAMETER;
171 /* Get the parent entry */
173 ParentNode = Node->Parent;
174 *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode);
176 /* Return exception if parent is null */
180 Status = AE_NULL_ENTRY;
186 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
190 ACPI_EXPORT_SYMBOL (AcpiGetParent)
193 /*******************************************************************************
195 * FUNCTION: AcpiGetNextObject
197 * PARAMETERS: Type - Type of object to be searched for
198 * Parent - Parent object whose children we are getting
199 * LastChild - Previous child that was found.
200 * The NEXT child will be returned
201 * RetHandle - Where handle to the next object is placed
205 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
206 * valid, Scope is ignored. Otherwise, the first object within
209 ******************************************************************************/
213 ACPI_OBJECT_TYPE Type,
216 ACPI_HANDLE *RetHandle)
219 ACPI_NAMESPACE_NODE *Node;
220 ACPI_NAMESPACE_NODE *ParentNode = NULL;
221 ACPI_NAMESPACE_NODE *ChildNode = NULL;
224 /* Parameter validation */
226 if (Type > ACPI_TYPE_EXTERNAL_MAX)
228 return (AE_BAD_PARAMETER);
231 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
232 if (ACPI_FAILURE (Status))
237 /* If null handle, use the parent */
241 /* Start search at the beginning of the specified scope */
243 ParentNode = AcpiNsValidateHandle (Parent);
246 Status = AE_BAD_PARAMETER;
252 /* Non-null handle, ignore the parent */
253 /* Convert and validate the handle */
255 ChildNode = AcpiNsValidateHandle (Child);
258 Status = AE_BAD_PARAMETER;
263 /* Internal function does the real work */
265 Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode);
268 Status = AE_NOT_FOUND;
274 *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
280 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
284 ACPI_EXPORT_SYMBOL (AcpiGetNextObject)