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
37 #define _COMPONENT ACPI_NAMESPACE
38 MODULE_NAME ("nsxfname")
41 /****************************************************************************
43 * FUNCTION: Acpi_get_handle
45 * PARAMETERS: Parent - Object to search under (search scope).
46 * Path_name - Pointer to an asciiz string containing the
48 * Ret_handle - Where the return handle is placed
52 * DESCRIPTION: This routine will search for a caller specified name in the
53 * name space. The caller can restrict the search region by
54 * specifying a non NULL parent. The parent value is itself a
57 ******************************************************************************/
63 ACPI_HANDLE *ret_handle)
66 ACPI_NAMESPACE_NODE *node = NULL;
67 ACPI_NAMESPACE_NODE *prefix_node = NULL;
70 if (!ret_handle || !pathname) {
71 return (AE_BAD_PARAMETER);
74 /* Convert a parent handle to a prefix node */
77 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
79 prefix_node = acpi_ns_convert_handle_to_entry (parent);
81 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
82 return (AE_BAD_PARAMETER);
85 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
88 /* Special case for root, since we can't search for it */
90 if (STRCMP (pathname, NS_ROOT_PATH) == 0) {
91 *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
96 * Find the Node and convert to a handle
98 status = acpi_ns_get_node (pathname, prefix_node, &node);
101 if (ACPI_SUCCESS (status)) {
102 *ret_handle = acpi_ns_convert_entry_to_handle (node);
109 /****************************************************************************
111 * FUNCTION: Acpi_get_pathname
113 * PARAMETERS: Handle - Handle to be converted to a pathname
114 * Name_type - Full pathname or single segment
115 * Ret_path_ptr - Buffer for returned path
117 * RETURN: Pointer to a string containing the fully qualified Name.
119 * DESCRIPTION: This routine returns the fully qualified name associated with
120 * the Handle parameter. This and the Acpi_pathname_to_handle are
121 * complementary functions.
123 ******************************************************************************/
129 ACPI_BUFFER *ret_path_ptr)
132 ACPI_NAMESPACE_NODE *node;
135 /* Buffer pointer must be valid always */
137 if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) {
138 return (AE_BAD_PARAMETER);
141 /* Allow length to be zero and ignore the pointer */
143 if ((ret_path_ptr->length) &&
144 (!ret_path_ptr->pointer)) {
145 return (AE_BAD_PARAMETER);
148 if (name_type == ACPI_FULL_PATHNAME) {
149 /* Get the full pathname (From the namespace root) */
151 status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length,
152 ret_path_ptr->pointer);
157 * Wants the single segment ACPI name.
158 * Validate handle and convert to an Node
161 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
162 node = acpi_ns_convert_handle_to_entry (handle);
164 status = AE_BAD_PARAMETER;
165 goto unlock_and_exit;
168 /* Check if name will fit in buffer */
170 if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) {
171 ret_path_ptr->length = PATH_SEGMENT_LENGTH;
172 status = AE_BUFFER_OVERFLOW;
173 goto unlock_and_exit;
176 /* Just copy the ACPI name from the Node and zero terminate it */
178 STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name,
180 ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
186 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
191 /****************************************************************************
193 * FUNCTION: Acpi_get_object_info
195 * PARAMETERS: Handle - Object Handle
196 * Info - Where the info is returned
200 * DESCRIPTION: Returns information about an object as gleaned from the
201 * namespace node and possibly by running several standard
202 * control methods (Such as in the case of a device.)
204 ******************************************************************************/
207 acpi_get_object_info (
209 ACPI_DEVICE_INFO *info)
214 u32 device_status = 0;
215 ACPI_INTEGER address = 0;
216 ACPI_NAMESPACE_NODE *node;
219 /* Parameter validation */
221 if (!handle || !info) {
222 return (AE_BAD_PARAMETER);
225 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
227 node = acpi_ns_convert_handle_to_entry (handle);
229 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
230 return (AE_BAD_PARAMETER);
233 info->type = node->type;
234 info->name = node->name;
236 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
239 * If not a device, we are all done.
241 if (info->type != ACPI_TYPE_DEVICE) {
247 * Get extra info for ACPI devices only. Run the
248 * _HID, _UID, _STA, and _ADR methods. Note: none
249 * of these methods are required, so they may or may
250 * not be present. The Info->Valid bits are used
251 * to indicate which methods ran successfully.
256 /* Execute the _HID method and save the result */
258 status = acpi_cm_execute_HID (node, &hid);
259 if (ACPI_SUCCESS (status)) {
260 STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id));
262 info->valid |= ACPI_VALID_HID;
265 /* Execute the _UID method and save the result */
267 status = acpi_cm_execute_UID (node, &uid);
268 if (ACPI_SUCCESS (status)) {
269 STRCPY (info->unique_id, uid.buffer);
271 info->valid |= ACPI_VALID_UID;
275 * Execute the _STA method and save the result
276 * _STA is not always present
279 status = acpi_cm_execute_STA (node, &device_status);
280 if (ACPI_SUCCESS (status)) {
281 info->current_status = device_status;
282 info->valid |= ACPI_VALID_STA;
286 * Execute the _ADR method and save result if successful
287 * _ADR is not always present
290 status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR,
293 if (ACPI_SUCCESS (status)) {
294 info->address = address;
295 info->valid |= ACPI_VALID_ADR;