⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nsaccess.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace * ******************************************************************************//* * Copyright (C) 2000 - 2005, R. Byron Moore * 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>#include <acpi/amlcode.h>#include <acpi/acnamesp.h>#include <acpi/acdispat.h>#define _COMPONENT          ACPI_NAMESPACE	 ACPI_MODULE_NAME    ("nsaccess")/******************************************************************************* * * FUNCTION:    acpi_ns_root_initialize * * PARAMETERS:  None * * RETURN:      Status * * DESCRIPTION: Allocate and initialize the default root named objects * * MUTEX:       Locks namespace for entire execution * ******************************************************************************/acpi_statusacpi_ns_root_initialize (void){	acpi_status                         status;	const struct acpi_predefined_names *init_val = NULL;	struct acpi_namespace_node          *new_node;	union acpi_operand_object           *obj_desc;	acpi_string                         val = NULL;	ACPI_FUNCTION_TRACE ("ns_root_initialize");	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/*	 * 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 */	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,		"Entering predefined entries into namespace\n"));	for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {		/* _OSI is optional for now, will be permanent later */		if (!ACPI_STRCMP (init_val->name, "_OSI") && !acpi_gbl_create_osi_method) {			continue;		}		status = acpi_ns_lookup (NULL, init_val->name, init_val->type,				  ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,				  NULL, &new_node);		if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ {			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,				"Could not create predefined name %s, %s\n",				init_val->name, acpi_format_exception (status)));		}		/*		 * Name entered successfully.		 * If entry in pre_defined_names[] specifies an		 * initial value, create the initial value.		 */		if (init_val->val) {			status = acpi_os_predefined_override (init_val, &val);			if (ACPI_FAILURE (status)) {				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,					"Could not override predefined %s\n",					init_val->name));			}			if (!val) {				val = init_val->val;			}			/*			 * Entry requests an initial value, allocate a			 * descriptor for it.			 */			obj_desc = acpi_ut_create_internal_object (init_val->type);			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:				obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val);				obj_desc->common.flags |= AOPOBJ_DATA_VALID;#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App)				/*				 * i_aSL Compiler cheats by putting parameter count				 * in the owner_iD				 */				new_node->owner_id = obj_desc->method.param_count;#else				/* Mark this as a very SPECIAL method */				obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY;				obj_desc->method.implementation = acpi_ut_osi_implementation;#endif				break;			case ACPI_TYPE_INTEGER:				obj_desc->integer.value = ACPI_TO_INTEGER (val);				break;			case ACPI_TYPE_STRING:				/*				 * Build an object around the static string				 */				obj_desc->string.length = (u32) ACPI_STRLEN (val);				obj_desc->string.pointer = val;				obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;				break;			case ACPI_TYPE_MUTEX:				obj_desc->mutex.node = new_node;				obj_desc->mutex.sync_level = (u8) (ACPI_TO_INTEGER (val) - 1);				if (ACPI_STRCMP (init_val->name, "_GL_") == 0) {					/*					 * Create a counting semaphore for the					 * global lock					 */					status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,							 1, &obj_desc->mutex.semaphore);					if (ACPI_FAILURE (status)) {						acpi_ut_remove_reference (obj_desc);						goto unlock_and_exit;					}					/*					 * We just created the mutex for the					 * global lock, save it					 */					acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;				}				else {					/* Create a mutex */					status = acpi_os_create_semaphore (1, 1,							   &obj_desc->mutex.semaphore);					if (ACPI_FAILURE (status)) {						acpi_ut_remove_reference (obj_desc);						goto unlock_and_exit;					}				}				break;			default:				ACPI_REPORT_ERROR (("Unsupported initial type value %X\n",					init_val->type));				acpi_ut_remove_reference (obj_desc);				obj_desc = NULL;				continue;			}			/* Store pointer to value descriptor in the Node */			status = acpi_ns_attach_object (new_node, obj_desc,					 ACPI_GET_OBJECT_TYPE (obj_desc));			/* Remove local reference to the object */			acpi_ut_remove_reference (obj_desc);		}	}unlock_and_exit:	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	/* Save a handle to "_GPE", it is always present */	if (ACPI_SUCCESS (status)) {		status = acpi_ns_get_node_by_path ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH,				  &acpi_gbl_fadt_gpe_device);	}	return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION:    acpi_ns_lookup * * PARAMETERS:  prefix_node     - Search scope if name is not fully qualified *              Pathname        - Search pathname, in internal format *                                (as represented in the AML stream) *              Type            - Type associated with name *              interpreter_mode - IMODE_LOAD_PASS2 => add name if not found *              Flags           - Flags describing the search restrictions *              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_statusacpi_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){	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;	u32                             local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND |			   ACPI_NS_SEARCH_PARENT);	ACPI_FUNCTION_TRACE ("ns_lookup");	if (!return_node) {		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	acpi_gbl_ns_lookup_count++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -