1 /******************************************************************************
3 * Module Name: nsxfname - Public interfaces to the ACPI subsystem
4 * ACPI Namespace oriented interfaces
7 *****************************************************************************/
10 * Copyright (C) 2000, 2001 R. Byron Moore
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #define _COMPONENT ACPI_NAMESPACE
32 MODULE_NAME ("nsxfname")
35 /****************************************************************************
37 * FUNCTION: Acpi_get_handle
39 * PARAMETERS: Parent - Object to search under (search scope).
40 * Path_name - Pointer to an asciiz string containing the
42 * Ret_handle - Where the return handle is placed
46 * DESCRIPTION: This routine will search for a caller specified name in the
47 * name space. The caller can restrict the search region by
48 * specifying a non NULL parent. The parent value is itself a
51 ******************************************************************************/
57 ACPI_HANDLE
*ret_handle
)
60 ACPI_NAMESPACE_NODE
*node
= NULL
;
61 ACPI_NAMESPACE_NODE
*prefix_node
= NULL
;
64 if (!ret_handle
|| !pathname
) {
65 return (AE_BAD_PARAMETER
);
68 /* Convert a parent handle to a prefix node */
71 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
73 prefix_node
= acpi_ns_convert_handle_to_entry (parent
);
75 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
76 return (AE_BAD_PARAMETER
);
79 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
82 /* Special case for root, since we can't search for it */
84 if (STRCMP (pathname
, NS_ROOT_PATH
) == 0) {
85 *ret_handle
= acpi_ns_convert_entry_to_handle (acpi_gbl_root_node
);
90 * Find the Node and convert to a handle
92 status
= acpi_ns_get_node (pathname
, prefix_node
, &node
);
95 if (ACPI_SUCCESS (status
)) {
96 *ret_handle
= acpi_ns_convert_entry_to_handle (node
);
103 /****************************************************************************
105 * FUNCTION: Acpi_get_pathname
107 * PARAMETERS: Handle - Handle to be converted to a pathname
108 * Name_type - Full pathname or single segment
109 * Ret_path_ptr - Buffer for returned path
111 * RETURN: Pointer to a string containing the fully qualified Name.
113 * DESCRIPTION: This routine returns the fully qualified name associated with
114 * the Handle parameter. This and the Acpi_pathname_to_handle are
115 * complementary functions.
117 ******************************************************************************/
123 ACPI_BUFFER
*ret_path_ptr
)
126 ACPI_NAMESPACE_NODE
*node
;
129 /* Buffer pointer must be valid always */
131 if (!ret_path_ptr
|| (name_type
> ACPI_NAME_TYPE_MAX
)) {
132 return (AE_BAD_PARAMETER
);
135 /* Allow length to be zero and ignore the pointer */
137 if ((ret_path_ptr
->length
) &&
138 (!ret_path_ptr
->pointer
)) {
139 return (AE_BAD_PARAMETER
);
142 if (name_type
== ACPI_FULL_PATHNAME
) {
143 /* Get the full pathname (From the namespace root) */
145 status
= acpi_ns_handle_to_pathname (handle
, &ret_path_ptr
->length
,
146 ret_path_ptr
->pointer
);
151 * Wants the single segment ACPI name.
152 * Validate handle and convert to an Node
155 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
156 node
= acpi_ns_convert_handle_to_entry (handle
);
158 status
= AE_BAD_PARAMETER
;
159 goto unlock_and_exit
;
162 /* Check if name will fit in buffer */
164 if (ret_path_ptr
->length
< PATH_SEGMENT_LENGTH
) {
165 ret_path_ptr
->length
= PATH_SEGMENT_LENGTH
;
166 status
= AE_BUFFER_OVERFLOW
;
167 goto unlock_and_exit
;
170 /* Just copy the ACPI name from the Node and zero terminate it */
172 STRNCPY (ret_path_ptr
->pointer
, (NATIVE_CHAR
*) &node
->name
,
174 ((NATIVE_CHAR
*) ret_path_ptr
->pointer
) [ACPI_NAME_SIZE
] = 0;
180 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
185 /****************************************************************************
187 * FUNCTION: Acpi_get_object_info
189 * PARAMETERS: Handle - Object Handle
190 * Info - Where the info is returned
194 * DESCRIPTION: Returns information about an object as gleaned from the
195 * namespace node and possibly by running several standard
196 * control methods (Such as in the case of a device.)
198 ******************************************************************************/
201 acpi_get_object_info (
203 ACPI_DEVICE_INFO
*info
)
208 u32 device_status
= 0;
209 ACPI_INTEGER address
= 0;
210 ACPI_NAMESPACE_NODE
*node
;
213 /* Parameter validation */
215 if (!handle
|| !info
) {
216 return (AE_BAD_PARAMETER
);
219 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
221 node
= acpi_ns_convert_handle_to_entry (handle
);
223 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
224 return (AE_BAD_PARAMETER
);
227 info
->type
= node
->type
;
228 info
->name
= node
->name
;
230 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
233 * If not a device, we are all done.
235 if (info
->type
!= ACPI_TYPE_DEVICE
) {
241 * Get extra info for ACPI devices only. Run the
242 * _HID, _UID, _STA, and _ADR methods. Note: none
243 * of these methods are required, so they may or may
244 * not be present. The Info->Valid bits are used
245 * to indicate which methods ran successfully.
250 /* Execute the _HID method and save the result */
252 status
= acpi_cm_execute_HID (node
, &hid
);
253 if (ACPI_SUCCESS (status
)) {
254 STRNCPY (info
->hardware_id
, hid
.buffer
, sizeof(info
->hardware_id
));
256 info
->valid
|= ACPI_VALID_HID
;
259 /* Execute the _UID method and save the result */
261 status
= acpi_cm_execute_UID (node
, &uid
);
262 if (ACPI_SUCCESS (status
)) {
263 STRCPY (info
->unique_id
, uid
.buffer
);
265 info
->valid
|= ACPI_VALID_UID
;
269 * Execute the _STA method and save the result
270 * _STA is not always present
273 status
= acpi_cm_execute_STA (node
, &device_status
);
274 if (ACPI_SUCCESS (status
)) {
275 info
->current_status
= device_status
;
276 info
->valid
|= ACPI_VALID_STA
;
280 * Execute the _ADR method and save result if successful
281 * _ADR is not always present
284 status
= acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR
,
287 if (ACPI_SUCCESS (status
)) {
288 info
->address
= address
;
289 info
->valid
|= ACPI_VALID_ADR
;