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

📄 proc.c

📁 Linux 2.4 内核下动态电源管理(Dynamic Power Management)的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		       "Quick Idles               : %u\n", 		       idle_lats.quick_idles);	len += sprintf(page + len, 		       "Full Idles                : %u\n", 		       idle_lats.full_idles);	len += sprintf(page + len, 		       "Inefficient Idles         : %u\n", 		       idle_lats.inefficient_idles);	len += sprintf(page + len, 		       "Interrupted Idles         : %u\n", 		       idle_lats.interrupted_idles);	len += sprintf(page + len, 		       "Max. Latency to Idle      : %u", 		       idle_lats.max_latency_to_idle);	len += sprintf_usec(page + len, idle_lats.max_latency_to_idle);	len += sprintf(page + len, 		       "Max. Latency to Idle-Task : %u", 		       idle_lats.max_latency_to_idle_task);	len += sprintf_usec(page + len, idle_lats.max_latency_to_idle_task);	len += sprintf(page + len, 		       "Max. Crit. Sect. to Idle  : %u", 		       idle_lats.max_cs_to_idle);	len += sprintf_usec(page + len, idle_lats.max_cs_to_idle);	*eof = 1;	return len;}static int write_proc_dpm_idle_stats (struct file *file, const char *buffer,			 unsigned long count, void *data){	unsigned long flags;	spin_lock_irqsave(&dpm_policy_lock, flags);	dpm_init_idle_stats();	spin_unlock_irqrestore(&dpm_policy_lock, flags);	return count;}#endif /* CONFIG_DPM_IDLE_STATS */#endif /* CONFIG_DPM_STATS *//*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * /proc/driver/dpm/state (Read-Only) * * Reading this file produces the following: *  * policy_name os os_name class_name os_opt_name opt_name hz *  * Where: * * policy_name = The name of the current policy * os          = The curret operating state index * os_name     = The current operating state name * class_name  = The name of the current operating point class * os_opt_name = The name of the implied operating point for the policy, class *               and state. * opt_name    = The name of the actual operating point; may be different if *               the operating state and operating point are out of sync. * hz          = The frequency of the statistics timer * * If DPM is disabled the line will appear as: * * N/A -1 N/A N/A N/A <hz> * *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/static intread_proc_dpm_state(char *page, char **start, off_t offset, 		    int count, int *eof, void *data){	unsigned long flags;	int len = 0;	if (dpm_lock_interruptible())		return -ERESTARTSYS;	if (!dpm_enabled) {		len += sprintf(page + len, "N/A -1 N/A N/A N/A N/A %d\n",			       DPM_MD_HZ);	} else {		spin_lock_irqsave(&dpm_policy_lock, flags);		len += sprintf(page + len,"%s %d %s %s %s %s %d\n",			       dpm_active_policy->name, 			       dpm_active_state,			       dpm_state_names[dpm_active_state],			       dpm_active_policy->			       classes[dpm_active_state]->name, 			       dpm_active_policy->			       classes[dpm_active_state]->opt->name,			       dpm_active_opt->name,			       DPM_MD_HZ);		spin_unlock_irqrestore(&dpm_policy_lock, flags);	}	dpm_unlock();	*eof = 1;	return len;}/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * /proc/driver/dpm/debug (Read-Only) * * Whatever it needs to be *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/#ifdef DEBUGstatic intread_proc_dpm_debug(char *page, char **start, off_t offset, 		    int count, int *eof, void *data){	int len = 0;	len += sprintf(page + len, "No DEBUG info\n");	*eof = 1;	return len;}#endif /* DEBUG *//**************************************************************************** * /proc/driver/dpm init/cleanup ****************************************************************************/static struct proc_dir_entry *proc_dpm;static struct proc_dir_entry *proc_dpm_cmd;static struct proc_dir_entry *proc_dpm_state;#ifdef DPM_MD_PROC_INITstatic struct proc_dir_entry *proc_dpm_md;#endif#ifdef CONFIG_DPM_STATSstatic struct proc_dir_entry *proc_dpm_stats;#ifdef CONFIG_DPM_OPT_STATSstatic struct proc_dir_entry *proc_dpm_opt_stats;#endif#ifdef CONFIG_DPM_IDLE_STATSstatic struct proc_dir_entry *proc_dpm_idle_stats;#endif#endif#ifdef DEBUGstatic struct proc_dir_entry *proc_dpm_debug;#endif#ifdef CONFIG_DPM_TRACEstatic struct proc_dir_entry *proc_dpm_trace;#endifvoid __initdpm_proc_init(void){	proc_dpm = proc_mkdir("driver/dpm", NULL);	if (proc_dpm) {		proc_dpm_cmd =			create_proc_entry("cmd",					  S_IWUSR,					  proc_dpm);		if (proc_dpm_cmd)			proc_dpm_cmd->write_proc = write_proc_dpm_cmd;		proc_dpm_state =			create_proc_read_entry("state",					       S_IRUGO,					       proc_dpm,					       read_proc_dpm_state, 					       NULL); #ifdef CONFIG_DPM_STATS		proc_dpm_stats =			create_proc_read_entry("stats",					       S_IRUGO,					       proc_dpm,					       read_proc_dpm_stats, 					       NULL); #ifdef CONFIG_DPM_OPT_STATS		proc_dpm_opt_stats =			create_proc_read_entry("opt_stats",					       S_IRUGO,					       proc_dpm,					       read_proc_dpm_opt_stats, 					       NULL); #endif /* CONFIG_DPM_OPT_STATS  */#ifdef CONFIG_DPM_IDLE_STATS		proc_dpm_idle_stats =			create_proc_read_entry("idle_stats",					       S_IWUSR | S_IRUGO,					       proc_dpm,					       read_proc_dpm_idle_stats, 					       NULL); 		if (proc_dpm_idle_stats)			proc_dpm_idle_stats->write_proc =				write_proc_dpm_idle_stats;#endif /* CONFIG_DPM_IDLE_STATS */#endif /* CONFIG_DPM_STATS */#ifdef DEBUG		proc_dpm_debug =			create_proc_read_entry("debug",					       S_IRUGO,					       proc_dpm,					       read_proc_dpm_debug, 					       NULL); #endif#ifdef CONFIG_DPM_TRACE		proc_dpm_trace =			create_proc_read_entry("trace",					       S_IWUSR | S_IRUGO,					       proc_dpm,					       read_proc_dpm_trace, 					       NULL); 		if (proc_dpm_trace)			proc_dpm_trace->write_proc = write_proc_dpm_trace;#endif#ifdef DPM_MD_PROC_INIT		proc_dpm_md = proc_mkdir("md", proc_dpm);		DPM_MD_PROC_INIT(proc_dpm_md);#endif	} else {	  printk(KERN_ERR "Attempt to create /proc/driver/dpm failed\n");	}}#ifdef MODULEvoid __exit#elsevoid #endifdpm_proc_cleanup(void){	if (proc_dpm_cmd) {		remove_proc_entry("cmd", proc_dpm);		proc_dpm_cmd = NULL;	}	if (proc_dpm_state) {		remove_proc_entry("state", proc_dpm);		proc_dpm_state = NULL;	}#ifdef CONFIG_DPM_STATS	if (proc_dpm_stats) {		remove_proc_entry("stats", proc_dpm);		proc_dpm_stats = NULL;	}#ifdef CONFIG_DPM_OPT_STATS	if (proc_dpm_opt_stats) {		remove_proc_entry("opt_stats", proc_dpm);		proc_dpm_opt_stats = NULL;	}#endif /*CONFIG_DPM_OPT_STATS  */#ifdef CONFIG_DPM_IDLE_STATS	if (proc_dpm_idle_stats) {		remove_proc_entry("idle_stats", proc_dpm);		proc_dpm_idle_stats = NULL;	}#endif /* CONFIG_DPM_IDLE_STATS */#endif /* CONFIG_DPM_STATS */#ifdef DEBUG	if (proc_dpm_debug) {		remove_proc_entry("debug", proc_dpm);		proc_dpm_debug = NULL;	}#endif#ifdef CONFIG_DPM_TRACE	if (proc_dpm_trace) {		remove_proc_entry("trace", proc_dpm);		proc_dpm_trace = NULL;	}#endif#ifdef DPM_MD_PROC_CLEANUP	DPM_MD_PROC_CLEANUP(proc_dpm_md);	remove_proc_entry("md", proc_dpm);#endif	remove_proc_entry("driver/dpm", NULL);}/**************************************************************************** * Machine-dependent /proc/driver/dpm/md entries ****************************************************************************//*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * /proc/driver/dpm/md/opts (Read-only) * * Reading this file will produce a dump of the current operating point, and a * listing of all of the defined operating points. * *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/static struct proc_dir_entry *proc_dpm_md_opts;static struct proc_dir_entry *proc_dpm_md_cmd;extern int read_proc_dpm_md_opts(char *page, char **start, off_t offset,				 int count, int *eof, void *data);extern int write_proc_dpm_md_cmd (struct file *file, const char *buffer,				  unsigned long count, void *data);void __initdpm_generic_md_proc_init(struct proc_dir_entry *proc_dpm_md){	proc_dpm_md_opts =		create_proc_read_entry("opts",				       S_IRUGO,				       proc_dpm_md,				       read_proc_dpm_md_opts, 				       NULL); 	proc_dpm_md_cmd =		create_proc_entry("cmd",				  S_IWUSR,				  proc_dpm_md);	if (proc_dpm_md_cmd)		proc_dpm_md_cmd->write_proc = write_proc_dpm_md_cmd;}#ifdef MODULEvoid __exit#elsevoid#endifdpm_generic_md_proc_cleanup(struct proc_dir_entry *proc_dpm_md){	if (proc_dpm_md_opts) {		remove_proc_entry("opts", proc_dpm_md);		proc_dpm_md_opts = NULL;	}	if (proc_dpm_md_cmd) {		remove_proc_entry("cmd", proc_dpm_md);		proc_dpm_md_cmd = NULL;	}}/* * Local variables: * c-basic-offset: 8 * End: */

⌨️ 快捷键说明

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