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.
45 #include <acpi/acpi.h>
49 #define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME("nsxfobj")
52 /*******************************************************************************
54 * FUNCTION: acpi_get_id
56 * PARAMETERS: Handle - Handle of object whose id is desired
57 * ret_id - Where the id will be placed
61 * DESCRIPTION: This routine returns the owner id associated with a handle
63 ******************************************************************************/
64 acpi_status
acpi_get_id(acpi_handle handle
, acpi_owner_id
* ret_id
)
66 struct acpi_namespace_node
*node
;
69 /* Parameter Validation */
72 return (AE_BAD_PARAMETER
);
75 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
76 if (ACPI_FAILURE(status
)) {
80 /* Convert and validate the handle */
82 node
= acpi_ns_validate_handle(handle
);
84 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
85 return (AE_BAD_PARAMETER
);
88 *ret_id
= node
->owner_id
;
90 status
= acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
94 ACPI_EXPORT_SYMBOL(acpi_get_id
)
96 /*******************************************************************************
98 * FUNCTION: acpi_get_type
100 * PARAMETERS: Handle - Handle of object whose type is desired
101 * ret_type - Where the type will be placed
105 * DESCRIPTION: This routine returns the type associatd with a particular handle
107 ******************************************************************************/
108 acpi_status
acpi_get_type(acpi_handle handle
, acpi_object_type
* ret_type
)
110 struct acpi_namespace_node
*node
;
113 /* Parameter Validation */
116 return (AE_BAD_PARAMETER
);
120 * Special case for the predefined Root Node
123 if (handle
== ACPI_ROOT_OBJECT
) {
124 *ret_type
= ACPI_TYPE_ANY
;
128 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
129 if (ACPI_FAILURE(status
)) {
133 /* Convert and validate the handle */
135 node
= acpi_ns_validate_handle(handle
);
137 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
138 return (AE_BAD_PARAMETER
);
141 *ret_type
= node
->type
;
143 status
= acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
147 ACPI_EXPORT_SYMBOL(acpi_get_type
)
149 /*******************************************************************************
151 * FUNCTION: acpi_get_parent
153 * PARAMETERS: Handle - Handle of object whose parent is desired
154 * ret_handle - Where the parent handle will be placed
158 * DESCRIPTION: Returns a handle to the parent of the object represented by
161 ******************************************************************************/
162 acpi_status
acpi_get_parent(acpi_handle handle
, acpi_handle
* ret_handle
)
164 struct acpi_namespace_node
*node
;
165 struct acpi_namespace_node
*parent_node
;
169 return (AE_BAD_PARAMETER
);
172 /* Special case for the predefined Root Node (no parent) */
174 if (handle
== ACPI_ROOT_OBJECT
) {
175 return (AE_NULL_ENTRY
);
178 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
179 if (ACPI_FAILURE(status
)) {
183 /* Convert and validate the handle */
185 node
= acpi_ns_validate_handle(handle
);
187 status
= AE_BAD_PARAMETER
;
188 goto unlock_and_exit
;
191 /* Get the parent entry */
193 parent_node
= node
->parent
;
194 *ret_handle
= ACPI_CAST_PTR(acpi_handle
, parent_node
);
196 /* Return exception if parent is null */
199 status
= AE_NULL_ENTRY
;
204 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
208 ACPI_EXPORT_SYMBOL(acpi_get_parent
)
210 /*******************************************************************************
212 * FUNCTION: acpi_get_next_object
214 * PARAMETERS: Type - Type of object to be searched for
215 * Parent - Parent object whose children we are getting
216 * last_child - Previous child that was found.
217 * The NEXT child will be returned
218 * ret_handle - Where handle to the next object is placed
222 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
223 * valid, Scope is ignored. Otherwise, the first object within
226 ******************************************************************************/
228 acpi_get_next_object(acpi_object_type type
,
230 acpi_handle child
, acpi_handle
* ret_handle
)
233 struct acpi_namespace_node
*node
;
234 struct acpi_namespace_node
*parent_node
= NULL
;
235 struct acpi_namespace_node
*child_node
= NULL
;
237 /* Parameter validation */
239 if (type
> ACPI_TYPE_EXTERNAL_MAX
) {
240 return (AE_BAD_PARAMETER
);
243 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
244 if (ACPI_FAILURE(status
)) {
248 /* If null handle, use the parent */
252 /* Start search at the beginning of the specified scope */
254 parent_node
= acpi_ns_validate_handle(parent
);
256 status
= AE_BAD_PARAMETER
;
257 goto unlock_and_exit
;
260 /* Non-null handle, ignore the parent */
261 /* Convert and validate the handle */
263 child_node
= acpi_ns_validate_handle(child
);
265 status
= AE_BAD_PARAMETER
;
266 goto unlock_and_exit
;
270 /* Internal function does the real work */
272 node
= acpi_ns_get_next_node_typed(type
, parent_node
, child_node
);
274 status
= AE_NOT_FOUND
;
275 goto unlock_and_exit
;
279 *ret_handle
= ACPI_CAST_PTR(acpi_handle
, node
);
284 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
288 ACPI_EXPORT_SYMBOL(acpi_get_next_object
)