2005-04-17 05:20:36 +07:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: nsaccess - Top-level functions for accessing ACPI namespace
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2015-02-05 14:20:45 +07:00
|
|
|
* Copyright (C) 2000 - 2015, Intel Corp.
|
2005-04-17 05:20:36 +07: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>
|
2009-01-09 12:30:03 +07:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "amlcode.h"
|
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "acdispat.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_NAMESPACE
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_MODULE_NAME("nsaccess")
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ns_root_initialize
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Allocate and initialize the default root named objects
|
|
|
|
*
|
|
|
|
* MUTEX: Locks namespace for entire execution
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_status acpi_ns_root_initialize(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_status status;
|
2005-04-17 05:20:36 +07:00
|
|
|
const struct acpi_predefined_names *init_val = NULL;
|
2005-08-05 11:44:28 +07:00
|
|
|
struct acpi_namespace_node *new_node;
|
|
|
|
union acpi_operand_object *obj_desc;
|
|
|
|
acpi_string val = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 04:15:00 +07:00
|
|
|
ACPI_FUNCTION_TRACE(ns_root_initialize);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The global root ptr is initially NULL, so a non-NULL value indicates
|
|
|
|
* that acpi_ns_root_initialize() has already been called; just return.
|
|
|
|
*/
|
|
|
|
if (acpi_gbl_root_node) {
|
|
|
|
status = AE_OK;
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell the rest of the subsystem that the root is initialized
|
|
|
|
* (This is OK because the namespace is locked)
|
|
|
|
*/
|
|
|
|
acpi_gbl_root_node = &acpi_gbl_root_node_struct;
|
|
|
|
|
|
|
|
/* Enter the pre-defined names in the name table */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Entering predefined entries into namespace\n"));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* _OSI is optional for now, will be permanent later */
|
|
|
|
|
2015-07-01 13:45:11 +07:00
|
|
|
if (!strcmp(init_val->name, "_OSI")
|
2005-08-05 11:44:28 +07:00
|
|
|
&& !acpi_gbl_create_osi_method) {
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
status = acpi_ns_lookup(NULL, init_val->name, init_val->type,
|
|
|
|
ACPI_IMODE_LOAD_PASS2,
|
|
|
|
ACPI_NS_NO_UPSEARCH, NULL, &new_node);
|
2012-10-31 09:26:36 +07:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-28 04:43:00 +07:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Could not create predefined name %s",
|
|
|
|
init_val->name));
|
2012-10-31 09:26:36 +07:00
|
|
|
continue;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-03-06 09:05:18 +07:00
|
|
|
* Name entered successfully. If entry in pre_defined_names[] specifies
|
|
|
|
* an initial value, create the initial value.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
if (init_val->val) {
|
2005-08-05 11:44:28 +07:00
|
|
|
status = acpi_os_predefined_override(init_val, &val);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-28 04:43:00 +07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Could not override predefined %s",
|
|
|
|
init_val->name));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!val) {
|
|
|
|
val = init_val->val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry requests an initial value, allocate a
|
|
|
|
* descriptor for it.
|
|
|
|
*/
|
2005-08-05 11:44:28 +07:00
|
|
|
obj_desc =
|
|
|
|
acpi_ut_create_internal_object(init_val->type);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!obj_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert value string from table entry to
|
|
|
|
* internal representation. Only types actually
|
|
|
|
* used for initial values are implemented here.
|
|
|
|
*/
|
|
|
|
switch (init_val->type) {
|
|
|
|
case ACPI_TYPE_METHOD:
|
2013-06-08 07:58:14 +07:00
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
obj_desc->method.param_count =
|
|
|
|
(u8) ACPI_TO_INTEGER(val);
|
2005-04-17 05:20:36 +07:00
|
|
|
obj_desc->common.flags |= AOPOBJ_DATA_VALID;
|
|
|
|
|
2005-07-30 05:15:00 +07:00
|
|
|
#if defined (ACPI_ASL_COMPILER)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-07-12 08:40:10 +07:00
|
|
|
/* Save the parameter count for the iASL compiler */
|
2005-07-30 05:15:00 +07:00
|
|
|
|
|
|
|
new_node->value = obj_desc->method.param_count;
|
2005-04-17 05:20:36 +07:00
|
|
|
#else
|
|
|
|
/* Mark this as a very SPECIAL method */
|
|
|
|
|
2011-01-12 08:19:43 +07:00
|
|
|
obj_desc->method.info_flags =
|
|
|
|
ACPI_METHOD_INTERNAL_ONLY;
|
|
|
|
obj_desc->method.dispatch.implementation =
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_ut_osi_implementation;
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_INTEGER:
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
obj_desc->integer.value = ACPI_TO_INTEGER(val);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_STRING:
|
|
|
|
|
2009-03-06 09:05:18 +07:00
|
|
|
/* Build an object around the static string */
|
|
|
|
|
2015-07-01 13:45:11 +07:00
|
|
|
obj_desc->string.length = (u32)strlen(val);
|
2005-04-17 05:20:36 +07:00
|
|
|
obj_desc->string.pointer = val;
|
|
|
|
obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_MUTEX:
|
|
|
|
|
|
|
|
obj_desc->mutex.node = new_node;
|
2005-08-05 11:44:28 +07:00
|
|
|
obj_desc->mutex.sync_level =
|
|
|
|
(u8) (ACPI_TO_INTEGER(val) - 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-02-02 23:48:18 +07:00
|
|
|
/* Create a mutex */
|
|
|
|
|
|
|
|
status =
|
|
|
|
acpi_os_create_mutex(&obj_desc->mutex.
|
|
|
|
os_mutex);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ut_remove_reference(obj_desc);
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
2006-06-24 04:04:00 +07:00
|
|
|
|
2007-02-02 23:48:18 +07:00
|
|
|
/* Special case for ACPI Global Lock */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-07-01 13:45:11 +07:00
|
|
|
if (strcmp(init_val->name, "_GL_") == 0) {
|
2008-04-10 22:06:37 +07:00
|
|
|
acpi_gbl_global_lock_mutex = obj_desc;
|
2006-06-24 04:04:00 +07:00
|
|
|
|
2007-02-02 23:48:18 +07:00
|
|
|
/* Create additional counting semaphore for global lock */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-06-24 04:04:00 +07:00
|
|
|
status =
|
2007-02-02 23:48:21 +07:00
|
|
|
acpi_os_create_semaphore(1, 0,
|
2007-02-02 23:48:18 +07:00
|
|
|
&acpi_gbl_global_lock_semaphore);
|
2005-08-05 11:44:28 +07:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ut_remove_reference
|
|
|
|
(obj_desc);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2006-01-28 04:43:00 +07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 16:56:40 +07:00
|
|
|
"Unsupported initial type value 0x%X",
|
2006-01-28 04:43:00 +07:00
|
|
|
init_val->type));
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_ut_remove_reference(obj_desc);
|
2005-04-17 05:20:36 +07:00
|
|
|
obj_desc = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store pointer to value descriptor in the Node */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
status = acpi_ns_attach_object(new_node, obj_desc,
|
2009-02-18 13:44:03 +07:00
|
|
|
obj_desc->common.type);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Remove local reference to the object */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_ut_remove_reference(obj_desc);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 08:30:02 +07:00
|
|
|
unlock_and_exit:
|
2005-08-05 11:44:28 +07:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Save a handle to "_GPE", it is always present */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
2006-05-27 03:36:00 +07:00
|
|
|
status = acpi_ns_get_node(NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
|
|
|
|
&acpi_gbl_fadt_gpe_device);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ns_lookup
|
|
|
|
*
|
2005-04-19 09:49:35 +07:00
|
|
|
* PARAMETERS: scope_info - Current scope info block
|
2012-07-12 08:40:10 +07:00
|
|
|
* pathname - Search pathname, in internal format
|
2005-04-17 05:20:36 +07:00
|
|
|
* (as represented in the AML stream)
|
2012-07-12 08:40:10 +07:00
|
|
|
* type - Type associated with name
|
2005-04-17 05:20:36 +07:00
|
|
|
* interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
|
2012-07-12 08:40:10 +07:00
|
|
|
* flags - Flags describing the search restrictions
|
2005-04-17 05:20:36 +07:00
|
|
|
* walk_state - Current state of the walk
|
|
|
|
* return_node - Where the Node is placed (if found
|
|
|
|
* or created successfully)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Find or enter the passed name in the name space.
|
|
|
|
* Log an error if name not found in Exec mode.
|
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is locked.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_ns_lookup(union acpi_generic_state *scope_info,
|
|
|
|
char *pathname,
|
|
|
|
acpi_object_type type,
|
|
|
|
acpi_interpreter_mode interpreter_mode,
|
|
|
|
u32 flags,
|
|
|
|
struct acpi_walk_state *walk_state,
|
|
|
|
struct acpi_namespace_node **return_node)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_status status;
|
|
|
|
char *path = pathname;
|
|
|
|
struct acpi_namespace_node *prefix_node;
|
|
|
|
struct acpi_namespace_node *current_node = NULL;
|
|
|
|
struct acpi_namespace_node *this_node = NULL;
|
|
|
|
u32 num_segments;
|
|
|
|
u32 num_carats;
|
|
|
|
acpi_name simple_name;
|
|
|
|
acpi_object_type type_to_check_for;
|
|
|
|
acpi_object_type this_search_type;
|
|
|
|
u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
|
2006-05-13 04:12:00 +07:00
|
|
|
u32 local_flags;
|
2005-08-05 11:44:28 +07:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 04:15:00 +07:00
|
|
|
ACPI_FUNCTION_TRACE(ns_lookup);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (!return_node) {
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2015-07-01 13:44:17 +07:00
|
|
|
local_flags = flags &
|
|
|
|
~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
|
|
|
|
ACPI_NS_SEARCH_PARENT);
|
2005-04-17 05:20:36 +07:00
|
|
|
*return_node = ACPI_ENTRY_NOT_FOUND;
|
2006-05-13 04:12:00 +07:00
|
|
|
acpi_gbl_ns_lookup_count++;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (!acpi_gbl_root_node) {
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(AE_NO_NAMESPACE);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2009-03-06 09:05:18 +07:00
|
|
|
/* Get the prefix scope. A null scope means use the root scope */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
if ((!scope_info) || (!scope_info->scope.node)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Null scope prefix, using root node (%p)\n",
|
|
|
|
acpi_gbl_root_node));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
prefix_node = acpi_gbl_root_node;
|
2005-08-05 11:44:28 +07:00
|
|
|
} else {
|
2005-04-17 05:20:36 +07:00
|
|
|
prefix_node = scope_info->scope.node;
|
2005-08-05 11:44:28 +07:00
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
|
|
|
|
ACPI_DESC_TYPE_NAMED) {
|
2006-01-28 04:43:00 +07:00
|
|
|
ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
|
|
|
|
prefix_node,
|
|
|
|
acpi_ut_get_descriptor_name(prefix_node)));
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(AE_AML_INTERNAL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2006-10-03 11:00:00 +07:00
|
|
|
if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
|
|
|
|
/*
|
|
|
|
* This node might not be a actual "scope" node (such as a
|
2009-03-06 09:05:18 +07:00
|
|
|
* Device/Method, etc.) It could be a Package or other object
|
|
|
|
* node. Backup up the tree to find the containing scope node.
|
2006-10-03 11:00:00 +07:00
|
|
|
*/
|
|
|
|
while (!acpi_ns_opens_scope(prefix_node->type) &&
|
|
|
|
prefix_node->type != ACPI_TYPE_ANY) {
|
2010-05-26 10:53:07 +07:00
|
|
|
prefix_node = prefix_node->parent;
|
2006-10-03 11:00:00 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-06 09:05:18 +07:00
|
|
|
/* Save type. TBD: may be no longer necessary */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
type_to_check_for = type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Begin examination of the actual pathname
|
|
|
|
*/
|
|
|
|
if (!pathname) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* A Null name_path is allowed and refers to the root */
|
|
|
|
|
|
|
|
num_segments = 0;
|
2005-08-05 11:44:28 +07:00
|
|
|
this_node = acpi_gbl_root_node;
|
|
|
|
path = "";
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Null Pathname (Zero segments), Flags=%X\n",
|
|
|
|
flags));
|
|
|
|
} else {
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Name pointer is valid (and must be in internal name format)
|
|
|
|
*
|
|
|
|
* Check for scope prefixes:
|
|
|
|
*
|
|
|
|
* As represented in the AML stream, a namepath consists of an
|
|
|
|
* optional scope prefix followed by a name segment part.
|
|
|
|
*
|
|
|
|
* If present, the scope prefix is either a Root Prefix (in
|
|
|
|
* which case the name is fully qualified), or one or more
|
|
|
|
* Parent Prefixes (in which case the name's scope is relative
|
|
|
|
* to the current scope).
|
|
|
|
*/
|
|
|
|
if (*path == (u8) AML_ROOT_PREFIX) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Pathname is fully qualified, start from the root */
|
|
|
|
|
|
|
|
this_node = acpi_gbl_root_node;
|
|
|
|
search_parent_flag = ACPI_NS_NO_UPSEARCH;
|
|
|
|
|
|
|
|
/* Point to name segment part */
|
|
|
|
|
|
|
|
path++;
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Path is absolute from root [%p]\n",
|
|
|
|
this_node));
|
|
|
|
} else {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Pathname is relative to current scope, start there */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Searching relative to prefix scope [%4.4s] (%p)\n",
|
|
|
|
acpi_ut_get_node_name(prefix_node),
|
|
|
|
prefix_node));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle multiple Parent Prefixes (carat) by just getting
|
|
|
|
* the parent node for each prefix instance.
|
|
|
|
*/
|
|
|
|
this_node = prefix_node;
|
|
|
|
num_carats = 0;
|
|
|
|
while (*path == (u8) AML_PARENT_PREFIX) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Name is fully qualified, no search rules apply */
|
|
|
|
|
|
|
|
search_parent_flag = ACPI_NS_NO_UPSEARCH;
|
2009-03-06 09:05:18 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Point past this prefix to the name segment
|
|
|
|
* part or the next Parent Prefix
|
|
|
|
*/
|
|
|
|
path++;
|
|
|
|
|
|
|
|
/* Backup to the parent node */
|
|
|
|
|
|
|
|
num_carats++;
|
2010-05-26 10:53:07 +07:00
|
|
|
this_node = this_node->parent;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!this_node) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Current scope has no parent scope */
|
|
|
|
|
2006-01-28 04:43:00 +07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2013-09-23 08:51:13 +07:00
|
|
|
"%s: Path has too many parent prefixes (^) "
|
|
|
|
"- reached beyond root node",
|
|
|
|
pathname));
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(AE_NOT_FOUND);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
2010-05-26 10:47:13 +07:00
|
|
|
"Search scope is [%4.4s], path has %u carat(s)\n",
|
2005-08-05 11:44:28 +07:00
|
|
|
acpi_ut_get_node_name
|
|
|
|
(this_node), num_carats));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the number of ACPI name segments in this pathname.
|
|
|
|
*
|
|
|
|
* The segment part consists of either:
|
|
|
|
* - A Null name segment (0)
|
|
|
|
* - A dual_name_prefix followed by two 4-byte name segments
|
|
|
|
* - A multi_name_prefix followed by a byte indicating the
|
|
|
|
* number of segments and the segments themselves.
|
|
|
|
* - A single 4-byte name segment
|
|
|
|
*
|
|
|
|
* Examine the name prefix opcode, if any, to determine the number of
|
|
|
|
* segments.
|
|
|
|
*/
|
|
|
|
switch (*path) {
|
|
|
|
case 0:
|
|
|
|
/*
|
|
|
|
* Null name after a root or parent prefixes. We already
|
|
|
|
* have the correct target node and there are no name segments.
|
|
|
|
*/
|
|
|
|
num_segments = 0;
|
|
|
|
type = this_node->type;
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Prefix-only Pathname (Zero name segments), Flags=%X\n",
|
|
|
|
flags));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_DUAL_NAME_PREFIX:
|
|
|
|
|
|
|
|
/* More than one name_seg, search rules do not apply */
|
|
|
|
|
|
|
|
search_parent_flag = ACPI_NS_NO_UPSEARCH;
|
|
|
|
|
|
|
|
/* Two segments, point to first name segment */
|
|
|
|
|
|
|
|
num_segments = 2;
|
|
|
|
path++;
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Dual Pathname (2 segments, Flags=%X)\n",
|
|
|
|
flags));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_MULTI_NAME_PREFIX_OP:
|
|
|
|
|
|
|
|
/* More than one name_seg, search rules do not apply */
|
|
|
|
|
|
|
|
search_parent_flag = ACPI_NS_NO_UPSEARCH;
|
|
|
|
|
|
|
|
/* Extract segment count, point to first name segment */
|
|
|
|
|
|
|
|
path++;
|
2005-08-05 11:44:28 +07:00
|
|
|
num_segments = (u32) (u8) * path;
|
2005-04-17 05:20:36 +07:00
|
|
|
path++;
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
2010-05-26 10:47:13 +07:00
|
|
|
"Multi Pathname (%u Segments, Flags=%X)\n",
|
2005-08-05 11:44:28 +07:00
|
|
|
num_segments, flags));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Not a Null name, no Dual or Multi prefix, hence there is
|
|
|
|
* only one name segment and Pathname is already pointing to it.
|
|
|
|
*/
|
|
|
|
num_segments = 1;
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Simple Pathname (1 segment, Flags=%X)\n",
|
|
|
|
flags));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-11-13 09:48:00 +07:00
|
|
|
* Search namespace for each segment of the name. Loop through and
|
2005-04-17 05:20:36 +07:00
|
|
|
* verify (or add to the namespace) each name segment.
|
|
|
|
*
|
|
|
|
* The object type is significant only at the last name
|
2008-11-13 09:48:00 +07:00
|
|
|
* segment. (We don't care about the types along the path, only
|
2005-04-17 05:20:36 +07:00
|
|
|
* the type of the final target object.)
|
|
|
|
*/
|
|
|
|
this_search_type = ACPI_TYPE_ANY;
|
|
|
|
current_node = this_node;
|
|
|
|
while (num_segments && current_node) {
|
|
|
|
num_segments--;
|
|
|
|
if (!num_segments) {
|
2009-03-06 09:05:18 +07:00
|
|
|
|
|
|
|
/* This is the last segment, enable typechecking */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
this_search_type = type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only allow automatic parent search (search rules) if the caller
|
|
|
|
* requested it AND we have a single, non-fully-qualified name_seg
|
|
|
|
*/
|
|
|
|
if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
|
2005-08-05 11:44:28 +07:00
|
|
|
(flags & ACPI_NS_SEARCH_PARENT)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
local_flags |= ACPI_NS_SEARCH_PARENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set error flag according to caller */
|
|
|
|
|
|
|
|
if (flags & ACPI_NS_ERROR_IF_FOUND) {
|
|
|
|
local_flags |= ACPI_NS_ERROR_IF_FOUND;
|
|
|
|
}
|
2015-07-01 13:44:17 +07:00
|
|
|
|
|
|
|
/* Set override flag according to caller */
|
|
|
|
|
|
|
|
if (flags & ACPI_NS_OVERRIDE_IF_FOUND) {
|
|
|
|
local_flags |= ACPI_NS_OVERRIDE_IF_FOUND;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract one ACPI name from the front of the pathname */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_MOVE_32_TO_32(&simple_name, path);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Try to find the single (4 character) ACPI name */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
status =
|
|
|
|
acpi_ns_search_and_enter(simple_name, walk_state,
|
|
|
|
current_node, interpreter_mode,
|
|
|
|
this_search_type, local_flags,
|
|
|
|
&this_node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
if (status == AE_NOT_FOUND) {
|
2006-10-02 11:00:00 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Name not found in ACPI namespace */
|
|
|
|
|
2005-08-05 11:44:28 +07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
|
|
|
|
"Name [%4.4s] not found in scope [%4.4s] %p\n",
|
|
|
|
(char *)&simple_name,
|
|
|
|
(char *)¤t_node->name,
|
|
|
|
current_node));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
*return_node = this_node;
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-04-10 22:06:39 +07:00
|
|
|
/* More segments to follow? */
|
|
|
|
|
|
|
|
if (num_segments > 0) {
|
|
|
|
/*
|
|
|
|
* If we have an alias to an object that opens a scope (such as a
|
2009-03-06 09:05:18 +07:00
|
|
|
* device or processor), we need to dereference the alias here so
|
|
|
|
* that we can access any children of the original node (via the
|
|
|
|
* remaining segments).
|
2008-04-10 22:06:39 +07:00
|
|
|
*/
|
|
|
|
if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
|
2008-11-13 09:51:49 +07:00
|
|
|
if (!this_node->object) {
|
|
|
|
return_ACPI_STATUS(AE_NOT_EXIST);
|
|
|
|
}
|
|
|
|
|
2008-04-10 22:06:39 +07:00
|
|
|
if (acpi_ns_opens_scope
|
2009-03-06 09:05:18 +07:00
|
|
|
(((struct acpi_namespace_node *)
|
|
|
|
this_node->object)->type)) {
|
2008-04-10 22:06:39 +07:00
|
|
|
this_node =
|
|
|
|
(struct acpi_namespace_node *)
|
|
|
|
this_node->object;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-04-10 22:06:39 +07:00
|
|
|
/* Special handling for the last segment (num_segments == 0) */
|
|
|
|
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Sanity typecheck of the target object:
|
|
|
|
*
|
|
|
|
* If 1) This is the last segment (num_segments == 0)
|
|
|
|
* 2) And we are looking for a specific type
|
|
|
|
* (Not checking for TYPE_ANY)
|
|
|
|
* 3) Which is not an alias
|
|
|
|
* 4) Which is not a local type (TYPE_SCOPE)
|
|
|
|
* 5) And the type of target object is known (not TYPE_ANY)
|
|
|
|
* 6) And target object does not match what we are looking for
|
|
|
|
*
|
|
|
|
* Then we have a type mismatch. Just warn and ignore it.
|
|
|
|
*/
|
|
|
|
if ((type_to_check_for != ACPI_TYPE_ANY) &&
|
|
|
|
(type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
|
|
|
|
(type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS)
|
|
|
|
&& (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE)
|
|
|
|
&& (this_node->type != ACPI_TYPE_ANY)
|
|
|
|
&& (this_node->type != type_to_check_for)) {
|
|
|
|
|
|
|
|
/* Complain about a type mismatch */
|
|
|
|
|
|
|
|
ACPI_WARNING((AE_INFO,
|
|
|
|
"NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
|
|
|
|
ACPI_CAST_PTR(char, &simple_name),
|
|
|
|
acpi_ut_get_type_name(this_node->
|
|
|
|
type),
|
|
|
|
acpi_ut_get_type_name
|
|
|
|
(type_to_check_for)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the last name segment and we are not looking for a
|
2009-03-06 09:05:18 +07:00
|
|
|
* specific type, but the type of found object is known, use that
|
|
|
|
* type to (later) see if it opens a scope.
|
2008-04-10 22:06:39 +07:00
|
|
|
*/
|
|
|
|
if (type == ACPI_TYPE_ANY) {
|
|
|
|
type = this_node->type;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Point to next name segment and make this node current */
|
|
|
|
|
|
|
|
path += ACPI_NAME_SIZE;
|
|
|
|
current_node = this_node;
|
|
|
|
}
|
|
|
|
|
2009-03-06 09:05:18 +07:00
|
|
|
/* Always check if we need to open a new scope */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
|
|
|
|
/*
|
|
|
|
* If entry is a type which opens a scope, push the new scope on the
|
|
|
|
* scope stack.
|
|
|
|
*/
|
2005-08-05 11:44:28 +07:00
|
|
|
if (acpi_ns_opens_scope(type)) {
|
|
|
|
status =
|
|
|
|
acpi_ds_scope_stack_push(this_node, type,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*return_node = this_node;
|
2005-08-05 11:44:28 +07:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|