6a8eaf034ff224d6cef1ac314c96424966aebc83
1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2017, 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.
45 #define EXPORT_ACPI_INTERFACES
52 #define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nsxfobj")
55 /*******************************************************************************
57 * FUNCTION: AcpiGetType
59 * PARAMETERS: Handle - Handle of object whose type is desired
60 * RetType - Where the type will be placed
64 * DESCRIPTION: This routine returns the type associatd with a particular handle
66 ******************************************************************************/
71 ACPI_OBJECT_TYPE
*RetType
)
73 ACPI_NAMESPACE_NODE
*Node
;
77 /* Parameter Validation */
81 return (AE_BAD_PARAMETER
);
84 /* Special case for the predefined Root Node (return type ANY) */
86 if (Handle
== ACPI_ROOT_OBJECT
)
88 *RetType
= ACPI_TYPE_ANY
;
92 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
93 if (ACPI_FAILURE (Status
))
98 /* Convert and validate the handle */
100 Node
= AcpiNsValidateHandle (Handle
);
103 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
104 return (AE_BAD_PARAMETER
);
107 *RetType
= Node
->Type
;
109 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
113 ACPI_EXPORT_SYMBOL (AcpiGetType
)
116 /*******************************************************************************
118 * FUNCTION: AcpiGetParent
120 * PARAMETERS: Handle - Handle of object whose parent is desired
121 * RetHandle - Where the parent handle will be placed
125 * DESCRIPTION: Returns a handle to the parent of the object represented by
128 ******************************************************************************/
133 ACPI_HANDLE
*RetHandle
)
135 ACPI_NAMESPACE_NODE
*Node
;
136 ACPI_NAMESPACE_NODE
*ParentNode
;
142 return (AE_BAD_PARAMETER
);
145 /* Special case for the predefined Root Node (no parent) */
147 if (Handle
== ACPI_ROOT_OBJECT
)
149 return (AE_NULL_ENTRY
);
152 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
153 if (ACPI_FAILURE (Status
))
158 /* Convert and validate the handle */
160 Node
= AcpiNsValidateHandle (Handle
);
163 Status
= AE_BAD_PARAMETER
;
167 /* Get the parent entry */
169 ParentNode
= Node
->Parent
;
170 *RetHandle
= ACPI_CAST_PTR (ACPI_HANDLE
, ParentNode
);
172 /* Return exception if parent is null */
176 Status
= AE_NULL_ENTRY
;
182 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
186 ACPI_EXPORT_SYMBOL (AcpiGetParent
)
189 /*******************************************************************************
191 * FUNCTION: AcpiGetNextObject
193 * PARAMETERS: Type - Type of object to be searched for
194 * Parent - Parent object whose children we are getting
195 * LastChild - Previous child that was found.
196 * The NEXT child will be returned
197 * RetHandle - Where handle to the next object is placed
201 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
202 * valid, Scope is ignored. Otherwise, the first object within
205 ******************************************************************************/
209 ACPI_OBJECT_TYPE Type
,
212 ACPI_HANDLE
*RetHandle
)
215 ACPI_NAMESPACE_NODE
*Node
;
216 ACPI_NAMESPACE_NODE
*ParentNode
= NULL
;
217 ACPI_NAMESPACE_NODE
*ChildNode
= NULL
;
220 /* Parameter validation */
222 if (Type
> ACPI_TYPE_EXTERNAL_MAX
)
224 return (AE_BAD_PARAMETER
);
227 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
228 if (ACPI_FAILURE (Status
))
233 /* If null handle, use the parent */
237 /* Start search at the beginning of the specified scope */
239 ParentNode
= AcpiNsValidateHandle (Parent
);
242 Status
= AE_BAD_PARAMETER
;
248 /* Non-null handle, ignore the parent */
249 /* Convert and validate the handle */
251 ChildNode
= AcpiNsValidateHandle (Child
);
254 Status
= AE_BAD_PARAMETER
;
259 /* Internal function does the real work */
261 Node
= AcpiNsGetNextNodeTyped (Type
, ParentNode
, ChildNode
);
264 Status
= AE_NOT_FOUND
;
270 *RetHandle
= ACPI_CAST_PTR (ACPI_HANDLE
, Node
);
276 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
280 ACPI_EXPORT_SYMBOL (AcpiGetNextObject
)