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

📄 evgpe.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch * *****************************************************************************//* * 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/acevents.h>#include <acpi/acnamesp.h>#define _COMPONENT          ACPI_EVENTS	 ACPI_MODULE_NAME    ("evgpe")/******************************************************************************* * * FUNCTION:    acpi_ev_set_gpe_type * * PARAMETERS:  gpe_event_info          - GPE to set *              Type                    - New type * * RETURN:      Status * * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) * ******************************************************************************/acpi_statusacpi_ev_set_gpe_type (	struct acpi_gpe_event_info      *gpe_event_info,	u8                              type){	acpi_status                     status;	ACPI_FUNCTION_TRACE ("ev_set_gpe_type");	/* Validate type and update register enable masks */	switch (type) {	case ACPI_GPE_TYPE_WAKE:	case ACPI_GPE_TYPE_RUNTIME:	case ACPI_GPE_TYPE_WAKE_RUN:		break;	default:		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	/* Disable the GPE if currently enabled */	status = acpi_ev_disable_gpe (gpe_event_info);	/* Type was validated above */	gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */	gpe_event_info->flags |= type;              /* Insert type */	return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION:    acpi_ev_update_gpe_enable_masks * * PARAMETERS:  gpe_event_info          - GPE to update *              Type                    - What to do: ACPI_GPE_DISABLE or *                                        ACPI_GPE_ENABLE * * RETURN:      Status * * DESCRIPTION: Updates GPE register enable masks based on the GPE type * ******************************************************************************/acpi_statusacpi_ev_update_gpe_enable_masks (	struct acpi_gpe_event_info      *gpe_event_info,	u8                              type){	struct acpi_gpe_register_info   *gpe_register_info;	u8                              register_bit;	ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");	gpe_register_info = gpe_event_info->register_info;	if (!gpe_register_info) {		return_ACPI_STATUS (AE_NOT_EXIST);	}	register_bit = gpe_event_info->register_bit;	/* 1) Disable case.  Simply clear all enable bits */	if (type == ACPI_GPE_DISABLE) {		ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);		ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);		return_ACPI_STATUS (AE_OK);	}	/* 2) Enable case.  Set/Clear the appropriate enable bits */	switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {	case ACPI_GPE_TYPE_WAKE:		ACPI_SET_BIT   (gpe_register_info->enable_for_wake, register_bit);		ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);		break;	case ACPI_GPE_TYPE_RUNTIME:		ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);		ACPI_SET_BIT   (gpe_register_info->enable_for_run, register_bit);		break;	case ACPI_GPE_TYPE_WAKE_RUN:		ACPI_SET_BIT   (gpe_register_info->enable_for_wake, register_bit);		ACPI_SET_BIT   (gpe_register_info->enable_for_run, register_bit);		break;	default:		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    acpi_ev_enable_gpe * * PARAMETERS:  gpe_event_info          - GPE to enable *              write_to_hardware       - Enable now, or just mark data structs *                                        (WAKE GPEs should be deferred) * * RETURN:      Status * * DESCRIPTION: Enable a GPE based on the GPE type * ******************************************************************************/acpi_statusacpi_ev_enable_gpe (	struct acpi_gpe_event_info      *gpe_event_info,	u8                              write_to_hardware){	acpi_status                     status;	ACPI_FUNCTION_TRACE ("ev_enable_gpe");	/* Make sure HW enable masks are updated */	status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/* Mark wake-enabled or HW enable, or both */	switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {	case ACPI_GPE_TYPE_WAKE:		ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);		break;	case ACPI_GPE_TYPE_WAKE_RUN:		ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);		/*lint -fallthrough */	case ACPI_GPE_TYPE_RUNTIME:		ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);		if (write_to_hardware) {			/* Clear the GPE (of stale events), then enable it */			status = acpi_hw_clear_gpe (gpe_event_info);			if (ACPI_FAILURE (status)) {				return_ACPI_STATUS (status);			}			/* Enable the requested runtime GPE */			status = acpi_hw_write_gpe_enable_reg (gpe_event_info);		}		break;	default:		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    acpi_ev_disable_gpe * * PARAMETERS:  gpe_event_info          - GPE to disable * * RETURN:      Status * * DESCRIPTION: Disable a GPE based on the GPE type * ******************************************************************************/acpi_statusacpi_ev_disable_gpe (	struct acpi_gpe_event_info      *gpe_event_info){	acpi_status                     status;	ACPI_FUNCTION_TRACE ("ev_disable_gpe");	if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {		return_ACPI_STATUS (AE_OK);	}	/* Make sure HW enable masks are updated */	status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/* Mark wake-disabled or HW disable, or both */	switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {	case ACPI_GPE_TYPE_WAKE:		ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);		break;	case ACPI_GPE_TYPE_WAKE_RUN:		ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);		/*lint -fallthrough */	case ACPI_GPE_TYPE_RUNTIME:		/* Disable the requested runtime GPE */		ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);		status = acpi_hw_write_gpe_enable_reg (gpe_event_info);		break;	default:		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    acpi_ev_get_gpe_event_info * * PARAMETERS:  gpe_device          - Device node.  NULL for GPE0/GPE1 *              gpe_number          - Raw GPE number * * RETURN:      A GPE event_info struct. NULL if not a valid GPE * * DESCRIPTION: Returns the event_info struct associated with this GPE. *              Validates the gpe_block and the gpe_number * *              Should be called only when the GPE lists are semaphore locked *              and not subject to change. * ******************************************************************************/struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info (	acpi_handle                     gpe_device,	u32                             gpe_number){	union acpi_operand_object       *obj_desc;	struct acpi_gpe_block_info      *gpe_block;	acpi_native_uint                i;	ACPI_FUNCTION_ENTRY ();	/* A NULL gpe_block means use the FADT-defined GPE block(s) */	if (!gpe_device) {		/* Examine GPE Block 0 and 1 (These blocks are permanent) */		for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {			gpe_block = acpi_gbl_gpe_fadt_blocks[i];			if (gpe_block) {				if ((gpe_number >= gpe_block->block_base_number) &&					(gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {					return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);				}			}		}		/* The gpe_number was not in the range of either FADT GPE block */		return (NULL);	}	/* A Non-NULL gpe_device means this is a GPE Block Device */	obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device);	if (!obj_desc ||		!obj_desc->device.gpe_block) {		return (NULL);	}	gpe_block = obj_desc->device.gpe_block;	if ((gpe_number >= gpe_block->block_base_number) &&		(gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {		return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);	}	return (NULL);}/******************************************************************************* * * FUNCTION:    acpi_ev_gpe_detect * * PARAMETERS:  gpe_xrupt_list      - Interrupt block for this interrupt. *                                    Can have multiple GPE blocks attached. * * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * * DESCRIPTION: Detect if any GP events have occurred.  This function is *              executed at interrupt level. *

⌨️ 快捷键说明

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