1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2013, 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
47 #include <acpi/acpi.h>
51 #define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME("nsxfobj")
54 /*******************************************************************************
56 * FUNCTION: acpi_get_id
58 * PARAMETERS: Handle - Handle of object whose id is desired
59 * ret_id - Where the id will be placed
63 * DESCRIPTION: This routine returns the owner id associated with a handle
65 ******************************************************************************/
66 acpi_status
acpi_get_id(acpi_handle handle
, acpi_owner_id
* ret_id
)
68 struct acpi_namespace_node
*node
;
71 /* Parameter Validation */
74 return (AE_BAD_PARAMETER
);
77 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
78 if (ACPI_FAILURE(status
)) {
82 /* Convert and validate the handle */
84 node
= acpi_ns_validate_handle(handle
);
86 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
87 return (AE_BAD_PARAMETER
);
90 *ret_id
= node
->owner_id
;
92 status
= acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
96 ACPI_EXPORT_SYMBOL(acpi_get_id
)
98 /*******************************************************************************
100 * FUNCTION: acpi_get_type
102 * PARAMETERS: handle - Handle of object whose type is desired
103 * ret_type - Where the type will be placed
107 * DESCRIPTION: This routine returns the type associatd with a particular handle
109 ******************************************************************************/
110 acpi_status
acpi_get_type(acpi_handle handle
, acpi_object_type
* ret_type
)
112 struct acpi_namespace_node
*node
;
115 /* Parameter Validation */
118 return (AE_BAD_PARAMETER
);
122 * Special case for the predefined Root Node
125 if (handle
== ACPI_ROOT_OBJECT
) {
126 *ret_type
= ACPI_TYPE_ANY
;
130 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
131 if (ACPI_FAILURE(status
)) {
135 /* Convert and validate the handle */
137 node
= acpi_ns_validate_handle(handle
);
139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
140 return (AE_BAD_PARAMETER
);
143 *ret_type
= node
->type
;
145 status
= acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
149 ACPI_EXPORT_SYMBOL(acpi_get_type
)
151 /*******************************************************************************
153 * FUNCTION: acpi_get_parent
155 * PARAMETERS: handle - Handle of object whose parent is desired
156 * ret_handle - Where the parent handle will be placed
160 * DESCRIPTION: Returns a handle to the parent of the object represented by
163 ******************************************************************************/
164 acpi_status
acpi_get_parent(acpi_handle handle
, acpi_handle
* ret_handle
)
166 struct acpi_namespace_node
*node
;
167 struct acpi_namespace_node
*parent_node
;
171 return (AE_BAD_PARAMETER
);
174 /* Special case for the predefined Root Node (no parent) */
176 if (handle
== ACPI_ROOT_OBJECT
) {
177 return (AE_NULL_ENTRY
);
180 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
181 if (ACPI_FAILURE(status
)) {
185 /* Convert and validate the handle */
187 node
= acpi_ns_validate_handle(handle
);
189 status
= AE_BAD_PARAMETER
;
190 goto unlock_and_exit
;
193 /* Get the parent entry */
195 parent_node
= node
->parent
;
196 *ret_handle
= ACPI_CAST_PTR(acpi_handle
, parent_node
);
198 /* Return exception if parent is null */
201 status
= AE_NULL_ENTRY
;
206 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
210 ACPI_EXPORT_SYMBOL(acpi_get_parent
)
212 /*******************************************************************************
214 * FUNCTION: acpi_get_next_object
216 * PARAMETERS: type - Type of object to be searched for
217 * parent - Parent object whose children we are getting
218 * last_child - Previous child that was found.
219 * The NEXT child will be returned
220 * ret_handle - Where handle to the next object is placed
224 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
225 * valid, Scope is ignored. Otherwise, the first object within
228 ******************************************************************************/
230 acpi_get_next_object(acpi_object_type type
,
232 acpi_handle child
, acpi_handle
* ret_handle
)
235 struct acpi_namespace_node
*node
;
236 struct acpi_namespace_node
*parent_node
= NULL
;
237 struct acpi_namespace_node
*child_node
= NULL
;
239 /* Parameter validation */
241 if (type
> ACPI_TYPE_EXTERNAL_MAX
) {
242 return (AE_BAD_PARAMETER
);
245 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
246 if (ACPI_FAILURE(status
)) {
250 /* If null handle, use the parent */
254 /* Start search at the beginning of the specified scope */
256 parent_node
= acpi_ns_validate_handle(parent
);
258 status
= AE_BAD_PARAMETER
;
259 goto unlock_and_exit
;
262 /* Non-null handle, ignore the parent */
263 /* Convert and validate the handle */
265 child_node
= acpi_ns_validate_handle(child
);
267 status
= AE_BAD_PARAMETER
;
268 goto unlock_and_exit
;
272 /* Internal function does the real work */
274 node
= acpi_ns_get_next_node_typed(type
, parent_node
, child_node
);
276 status
= AE_NOT_FOUND
;
277 goto unlock_and_exit
;
281 *ret_handle
= ACPI_CAST_PTR(acpi_handle
, node
);
286 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
290 ACPI_EXPORT_SYMBOL(acpi_get_next_object
)