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

📄 nsaccess.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace *              $Revision: 135 $ * ******************************************************************************//* *  Copyright (C) 2000, 2001 R. Byron Moore * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include "acpi.h"#include "amlcode.h"#include "acinterp.h"#include "acnamesp.h"#include "acdispat.h"#define _COMPONENT          ACPI_NAMESPACE	 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 = AE_OK;	const predefined_names  *init_val = NULL;	acpi_namespace_node     *new_node;	acpi_operand_object     *obj_desc;	FUNCTION_TRACE ("Ns_root_initialize");	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	/*	 * 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++) {		status = acpi_ns_lookup (NULL, init_val->name, init_val->type,				 IMODE_LOAD_PASS2, 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) {			/*			 * 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_INTEGER:				obj_desc->integer.value =						(acpi_integer) STRTOUL (init_val->val, NULL, 10);				break;			case ACPI_TYPE_STRING:				/*				 * Build an object around the static string				 */				obj_desc->string.length = STRLEN (init_val->val);				obj_desc->string.pointer = init_val->val;				obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;				break;			case ACPI_TYPE_MUTEX:				obj_desc->mutex.sync_level =						 (u16) STRTOUL (init_val->val, NULL, 10);				if (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)) {						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)) {						goto unlock_and_exit;					}				}				break;			default:				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 */			acpi_ns_attach_object (new_node, obj_desc, obj_desc->common.type);			/* Remove local reference to the object */			acpi_ut_remove_reference (obj_desc);		}	}unlock_and_exit:	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	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 (	acpi_generic_state      *scope_info,	NATIVE_CHAR             *pathname,	acpi_object_type8       type,	operating_mode          interpreter_mode,	u32                     flags,	acpi_walk_state         *walk_state,	acpi_namespace_node     **return_node){	acpi_status             status;	acpi_namespace_node     *prefix_node;	acpi_namespace_node     *current_node = NULL;	acpi_namespace_node     *scope_to_push = NULL;	acpi_namespace_node     *this_node = NULL;	u32                     num_segments;	acpi_name               simple_name;	u8                      null_name_path = FALSE;	acpi_object_type8       type_to_check_for;	acpi_object_type8       this_search_type;	u32                     local_flags = flags & ~NS_ERROR_IF_FOUND;	DEBUG_EXEC              (u32 i;)	FUNCTION_TRACE ("Ns_lookup");	if (!return_node) {		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	acpi_gbl_ns_lookup_count++;	*return_node = ENTRY_NOT_FOUND;	if (!acpi_gbl_root_node) {		return (AE_NO_NAMESPACE);	}	/*	 * Get the prefix scope.	 * A null scope means use the root scope	 */	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));		prefix_node = acpi_gbl_root_node;	}	else {		prefix_node = scope_info->scope.node;	}	/*	 * This check is explicitly split to relax the Type_to_check_for	 * conditions for Bank_field_defn. Originally, both Bank_field_defn and	 * Def_field_defn caused Type_to_check_for to be set to ACPI_TYPE_REGION,	 * but the Bank_field_defn may also check for a Field definition as well	 * as an Operation_region.	 */	if (INTERNAL_TYPE_FIELD_DEFN == type) {

⌨️ 快捷键说明

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