2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: nsxfname - Public interfaces to the ACPI subsystem
|
|
|
|
* ACPI Namespace oriented interfaces
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2008-04-24 11:00:13 +08:00
|
|
|
* Copyright (C) 2000 - 2008, Intel Corp.
|
2005-04-17 06:20:36 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2008-12-31 03:01:23 +08:00
|
|
|
#include <acpi/accommon.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <acpi/acnamesp.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_NAMESPACE
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("nsxfname")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_get_handle
|
|
|
|
*
|
|
|
|
* PARAMETERS: Parent - Object to search under (search scope).
|
2005-04-19 10:49:35 +08:00
|
|
|
* Pathname - Pointer to an asciiz string containing the
|
|
|
|
* name
|
|
|
|
* ret_handle - Where the return handle is returned
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: This routine will search for a caller specified name in the
|
|
|
|
* name space. The caller can restrict the search region by
|
|
|
|
* specifying a non NULL parent. The parent value is itself a
|
|
|
|
* namespace handle.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_get_handle(acpi_handle parent,
|
|
|
|
acpi_string pathname, acpi_handle * ret_handle)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node = NULL;
|
|
|
|
struct acpi_namespace_node *prefix_node = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_ENTRY();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Parameter Validation */
|
|
|
|
|
|
|
|
if (!ret_handle || !pathname) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a parent handle to a prefix node */
|
|
|
|
|
|
|
|
if (parent) {
|
2005-08-05 12:44:28 +08:00
|
|
|
prefix_node = acpi_ns_map_handle_to_node(parent);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!prefix_node) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
2007-02-03 00:48:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid cases are:
|
|
|
|
* 1) Fully qualified pathname
|
|
|
|
* 2) Parent + Relative pathname
|
|
|
|
*
|
|
|
|
* Error for <null Parent + relative path>
|
|
|
|
*/
|
|
|
|
if (acpi_ns_valid_root_prefix(pathname[0])) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
/* Pathname is fully qualified (starts with '\') */
|
|
|
|
|
|
|
|
/* Special case for root-only, since we can't search for it */
|
|
|
|
|
|
|
|
if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
|
|
|
|
*ret_handle =
|
|
|
|
acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
|
|
|
|
return (AE_OK);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-02-03 00:48:22 +08:00
|
|
|
} else if (!prefix_node) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
/* Relative path with null prefix is disallowed */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
return (AE_BAD_PARAMETER);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
/* Find the Node and convert to a handle */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
status =
|
|
|
|
acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
*ret_handle = acpi_ns_convert_entry_to_handle(node);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_handle)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_get_name
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Handle to be converted to a pathname
|
|
|
|
* name_type - Full pathname or single segment
|
|
|
|
* Buffer - Buffer for returned path
|
|
|
|
*
|
|
|
|
* RETURN: Pointer to a string containing the fully qualified Name.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: This routine returns the fully qualified name associated with
|
|
|
|
* the Handle parameter. This and the acpi_pathname_to_handle are
|
|
|
|
* complementary functions.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (name_type > ACPI_NAME_TYPE_MAX) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_validate_buffer(buffer);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name_type == ACPI_FULL_PATHNAME) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Get the full pathname (From the namespace root) */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ns_handle_to_pathname(handle, buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wants the single segment ACPI name.
|
|
|
|
* Validate handle and convert to a namespace Node
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
node = acpi_ns_map_handle_to_node(handle);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!node) {
|
|
|
|
status = AE_BAD_PARAMETER;
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate/Allocate/Clear caller buffer */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just copy the ACPI name from the Node and zero terminate it */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
|
|
|
|
ACPI_NAME_SIZE);
|
|
|
|
((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_OK;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
unlock_and_exit:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
|
2005-04-17 06:20:36 +08:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_name)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_get_object_info
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Object Handle
|
2005-04-19 10:49:35 +08:00
|
|
|
* Buffer - Where the info is returned
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Returns information about an object as gleaned from the
|
|
|
|
* namespace node and possibly by running several standard
|
|
|
|
* control methods (Such as in the case of a device.)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
struct acpi_device_info *info;
|
|
|
|
struct acpi_device_info *return_info;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct acpi_compatible_id_list *cid_list = NULL;
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_size size;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!handle || !buffer) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_validate_buffer(buffer);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!info) {
|
|
|
|
return (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
node = acpi_ns_map_handle_to_node(handle);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!node) {
|
2005-08-05 12:44:28 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
|
2008-07-04 10:18:34 +08:00
|
|
|
status = AE_BAD_PARAMETER;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init return structure */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
size = sizeof(struct acpi_device_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
info->type = node->type;
|
|
|
|
info->name = node->name.integer;
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid = 0;
|
|
|
|
|
2008-07-04 10:53:58 +08:00
|
|
|
if (node->type == ACPI_TYPE_METHOD) {
|
|
|
|
info->param_count = node->object->method.param_count;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If not a device, we are all done */
|
|
|
|
|
|
|
|
if (info->type == ACPI_TYPE_DEVICE) {
|
|
|
|
/*
|
|
|
|
* Get extra info for ACPI Devices objects only:
|
|
|
|
* Run the Device _HID, _UID, _CID, _STA, _ADR and _sx_d methods.
|
|
|
|
*
|
|
|
|
* Note: none of these methods are required, so they may or may
|
|
|
|
* not be present for this device. The Info->Valid bitfield is used
|
|
|
|
* to indicate which methods were found and ran successfully.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Execute the Device._HID method */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_execute_HID(node, &info->hardware_id);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_HID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the Device._UID method */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_execute_UID(node, &info->unique_id);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_UID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the Device._CID method */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_execute_CID(node, &cid_list);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2006-01-28 05:43:00 +08:00
|
|
|
size += cid_list->size;
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_CID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the Device._STA method */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_execute_STA(node, &info->current_status);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_STA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the Device._ADR method */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
|
|
|
|
&info->address);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_ADR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the Device._sx_d methods */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_execute_sxds(node, info->highest_dstates);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
info->valid |= ACPI_VALID_SXDS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate/Allocate/Clear caller buffer */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ut_initialize_buffer(buffer, size);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Populate the return buffer */
|
|
|
|
|
|
|
|
return_info = buffer->pointer;
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (cid_list) {
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MEMCPY(&return_info->compatibility_id, cid_list,
|
|
|
|
cid_list->size);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
cleanup:
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(info);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (cid_list) {
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(cid_list);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_object_info)
|