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

📄 hwxface.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Name: hwxface.c - Hardware access external interfaces *              $Revision: 36 $ * *****************************************************************************//* *  Copyright (C) 2000 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 "acnamesp.h"#include "achware.h"#define _COMPONENT          HARDWARE	 MODULE_NAME         ("hwxface")/****************************************************************************** * * Hardware globals * ******************************************************************************/ACPI_C_STATE_HANDLER        acpi_hw_cx_handlers[MAX_CX_STATES] =			  {NULL, acpi_hw_enter_c1, NULL, NULL};u32                         acpi_hw_active_cx_state = 1;/**************************************************************************** * * FUNCTION:    Acpi_get_processor_throttling_info * * PARAMETERS:  Processor_handle    - handle for the cpu to get info about *              User_buffer         - caller supplied buffer * * RETURN:      Status of function * * DESCRIPTION: Get throttling capabilities for the processor, this routine *              builds the data directly into the callers buffer * ****************************************************************************/ACPI_STATUSacpi_get_processor_throttling_info (	ACPI_HANDLE             processor_handle,	ACPI_BUFFER             *user_buffer){	NATIVE_UINT             percent_step;	NATIVE_UINT             next_percent;	NATIVE_UINT             num_throttle_states;	NATIVE_UINT             buffer_space_needed;	NATIVE_UINT             i;	u8                      duty_width;	ACPI_NAMESPACE_NODE     *cpu_node;	ACPI_OPERAND_OBJECT     *cpu_obj;	ACPI_CPU_THROTTLING_STATE *state_ptr;	/*	 *  Have to at least have a buffer to return info in	 */	if (!user_buffer) {		return(AE_BAD_PARAMETER);	}	/*	 *  Convert and validate the device handle	 */	cpu_node = acpi_ns_convert_handle_to_entry (processor_handle);	if (!cpu_node) {		return (AE_BAD_PARAMETER);	}   /*	*   Check for an existing internal object	*/	cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node);	if (!cpu_obj) {		return (AE_NOT_FOUND);	}	/*	 * (Duty Width on IA-64 is zero)	 */	duty_width = acpi_gbl_FADT->duty_width;	/*	 *  P0 must always have a P_BLK all others may be null	 *  in either case, we can't throttle a processor that has no P_BLK	 *	 *  Also if no Duty width, one state and it is 100%	 *	 */	if (!cpu_obj->processor.length || !duty_width ||		(ACPI_UINT16_MAX < cpu_obj->processor.address))	{		/*		 *  Acpi_even though we can't throttle, we still have one state (100%)		 */		num_throttle_states = 1;	}	else {		num_throttle_states = (int) acpi_hw_local_pow (2,duty_width);	}	buffer_space_needed = num_throttle_states * sizeof (ACPI_CPU_THROTTLING_STATE);	if ((user_buffer->length < buffer_space_needed) || !user_buffer->pointer) {		user_buffer->length = buffer_space_needed;		return (AE_BUFFER_OVERFLOW);	}	user_buffer->length = buffer_space_needed;	state_ptr           = (ACPI_CPU_THROTTLING_STATE *) user_buffer->pointer;	percent_step        = 1000 / num_throttle_states;	/*	 * Build each entry in the buffer.  Note that we're using the value	 * 1000 and dividing each state by 10 to better avoid round-off	 * accumulation.  Also note that the throttling STATES are ordered	 * sequentially from 100% (state 0) on down (e.g. 87.5% = state 1),	 * which is exactly opposite from duty cycle values (12.5% = state 1).	 */	for (i = 0, next_percent = 1000; i < num_throttle_states; i++) {		state_ptr[i].state_number = i;		state_ptr[i].percent_of_clock = next_percent / 10;		next_percent -= percent_step;	}	return(AE_OK);}/**************************************************************************** * * FUNCTION:    Acpi_get_processor_throttling_state * * PARAMETERS:  Processor_handle    - handle for the cpu to throttle *              Throttle_state      - throttling state to enter * * RETURN:      Status of function * * DESCRIPTION: Get current hardware throttling state * ****************************************************************************/ACPI_STATUSacpi_get_processor_throttling_state (	ACPI_HANDLE             processor_handle,	u32                     *throttle_state){	ACPI_NAMESPACE_NODE     *cpu_node;	ACPI_OPERAND_OBJECT     *cpu_obj;	u32                     num_throttle_states;	u32                     duty_cycle;	u8                      duty_offset;	u8                      duty_width;	/* Convert and validate the device handle */	cpu_node = acpi_ns_convert_handle_to_entry (processor_handle);	if (!cpu_node || !throttle_state) {		return (AE_BAD_PARAMETER);	}   /* Check for an existing internal object */	cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node);	if (!cpu_obj) {		return (AE_NOT_FOUND);	}	/*	 * No Duty fields in IA64 tables	 */	duty_offset = acpi_gbl_FADT->duty_offset;	duty_width = acpi_gbl_FADT->duty_width;	/*	 *  Must have a valid P_BLK P0 must have a P_BLK all others may be null	 *  in either case, we can't thottle a processor that has no P_BLK	 *  that means we are in the only supported state (0 - 100%)	 *	 *  also, if Duty_width is zero there are no additional states	 */	if (!cpu_obj->processor.length || !duty_width ||		(ACPI_UINT16_MAX < cpu_obj->processor.address))	{		*throttle_state = 0;		return(AE_OK);	}	num_throttle_states = (u32) acpi_hw_local_pow (2,duty_width);	/*	 *  Get the current duty cycle value.	 */	duty_cycle = acpi_hw_get_duty_cycle (duty_offset,			   cpu_obj->processor.address,			   num_throttle_states);	/*	 * Convert duty cycle to throttling state (invert).	 */	if (duty_cycle == 0) {		*throttle_state = 0;	}	else {		*throttle_state = num_throttle_states - duty_cycle;	}	return(AE_OK);}/**************************************************************************** * * FUNCTION:    Acpi_set_processor_throttling_state * * PARAMETERS:  Processor_handle    - handle for the cpu to throttle *              Throttle_state      - throttling state to enter * * RETURN:      Status of function * * DESCRIPTION: Set hardware into requested throttling state, the handle *              passed in must have a valid P_BLK * ****************************************************************************/ACPI_STATUSacpi_set_processor_throttling_state (	ACPI_HANDLE             processor_handle,	u32                     throttle_state){	ACPI_NAMESPACE_NODE    *cpu_node;	ACPI_OPERAND_OBJECT    *cpu_obj;	u32                     num_throttle_states = 0;	u8                      duty_offset;	u8                      duty_width;	u32                     duty_cycle = 0;	/* Convert and validate the device handle */	cpu_node = acpi_ns_convert_handle_to_entry (processor_handle);	if (!cpu_node) {		return (AE_BAD_PARAMETER);	}   /* Check for an existing internal object */	cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node);	if (!cpu_obj) {		return (AE_NOT_FOUND);	}	/*	 * No Duty fields in IA64 tables	 */	duty_offset = acpi_gbl_FADT->duty_offset;	duty_width = acpi_gbl_FADT->duty_width;	/*	 *  Must have a valid P_BLK P0 must have a P_BLK all others may be null	 *  in either case, we can't thottle a processor that has no P_BLK	 *  that means we are in the only supported state (0 - 100%)	 *	 *  also, if Duty_width is zero there are no additional states	 */	if (!cpu_obj->processor.length || !duty_width ||		(ACPI_UINT16_MAX < cpu_obj->processor.address))	{		/*		 *  If caller wants to set the state to the only state we handle

⌨️ 快捷键说明

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