~ubuntu-branches/ubuntu/dapper/cpufreqd/dapper

« back to all changes in this revision

Viewing changes to cpufreqd.h

  • Committer: Bazaar Package Importer
  • Author(s): Mattia Dongili
  • Date: 2005-11-27 18:47:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127184742-9h26euwetr6kh1e6
Tags: 2.0.0-1

* New upstream release.
* cpufreqd.init: exit succesfully in case a stop is issued and
  cpufreqd is found running as requested by LSB thus making it
  possible to remove cpufreqd when cpufreqd itsef is stopped
  (closes: #340133)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright (C) 2002-2005  Mattia Dongili<dongili@supereva.it>
3
 
 *                           George Staikos <staikos@0wned.org>
4
 
 *   
5
 
 *  Copyright (C) 2003-2005 Rene Rebe <rene@rocklinux.org>
6
 
 *
7
 
 *  2003.16.08
8
 
 *  - added support for cpu monitoring, base code by Dietz Proepper and minor
9
 
 *    fixes by Mattia Dongili
10
 
 *
11
 
 *  This program is free software; you can redistribute it and/or modify
12
 
 *  it under the terms of the GNU General Public License as published by
13
 
 *  the Free Software Foundation; either version 2 of the License, or
14
 
 *  (at your option) any later version.
15
 
 *
16
 
 *  This program is distributed in the hope that it will be useful,
17
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 
 *  GNU General Public License for more details.
20
 
 *
21
 
 *  You should have received a copy of the GNU General Public License
22
 
 *  along with this program; if not, write to the Free Software
23
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
 
 */
25
 
 
26
 
#ifndef __CPUFREQD_H
27
 
#define __CPUFREQD_H
28
 
 
29
 
#include <stdio.h>
30
 
#include <stdarg.h>
31
 
#include <limits.h>
32
 
#include <stdlib.h>
33
 
#include <unistd.h>
34
 
#include <errno.h>
35
 
#include <sys/types.h>
36
 
#include <sys/stat.h>
37
 
#include <fcntl.h>
38
 
#include <getopt.h>
39
 
#include <time.h>
40
 
#include <string.h>
41
 
#include <syslog.h>
42
 
#include <signal.h>
43
 
#include <ctype.h>
44
 
#include <dirent.h>
45
 
#include <dlfcn.h>
46
 
#include <libgen.h>
47
 
 
48
 
#include "string_list.h"
49
 
 
50
 
#define _CPUFREQD_VERSION_      "1.2.3"
51
 
 
52
 
#ifdef HAVE_CONFIG_H
53
 
#include "config.h"
54
 
#endif
55
 
 
56
 
#ifndef CPUFREQD_CONFDIR
57
 
#define CPUFREQD_CONFDIR  "/etc/"
58
 
#endif
59
 
 
60
 
#ifndef CPUFREQD_LIBDIR
61
 
#define CPUFREQD_LIBDIR   ""
62
 
#endif
63
 
 
64
 
#ifndef CPUFREQD_STATEDIR
65
 
#define CPUFREQD_STATEDIR   "/var/"
66
 
#endif
67
 
 
68
 
#define CPUFREQD_CONFIG   CPUFREQD_CONFDIR"cpufreqd.conf"
69
 
#define CPUFREQD_PIDFILE  CPUFREQD_STATEDIR"run/cpufreqd.pid"
70
 
#define APM_PROC_FILE     "/proc/apm"
71
 
#define ACPI_PROC_DIR     "/proc/acpi/"
72
 
#define ACPI_BATTERY_DIR  "/proc/acpi/battery/"
73
 
#define ACPI_AC_DIR       "/proc/acpi/ac_adapter/"
74
 
#define PMU_PROC_DIR      "/proc/pmu"
75
 
#define CPUINFO_PROC      "/proc/cpuinfo"
76
 
 
77
 
#define CPUFREQ_SYSFS_INTERFACE               "/sys/devices/system/cpu/cpu0/cpufreq"
78
 
#define CPUFREQ_SYSFS_INTERFACE_POLICY  "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_governor"
79
 
#define CPUFREQ_SYSFS_INTERFACE_MAX     "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_max_freq"
80
 
#define CPUFREQ_SYSFS_INTERFACE_MIN     "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_min_freq"
81
 
#define CPUFREQ_SYSFS_INTERFACE_CPUMAX     "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
82
 
#define CPUFREQ_SYSFS_INTERFACE_CPUMIN     "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"
83
 
#define CPUFREQ_PROC_INTERFACE          "/proc/cpufreq"
84
 
#define CPUFREQ_PROC_INTERFACE_SPEED    "/proc/sys/cpu/0/speed"
85
 
#define CPUFREQ_PROC_INTERFACE_MIN      "/proc/sys/cpu/0/speed-min"
86
 
#define CPUFREQ_PROC_INTERFACE_MAX      "/proc/sys/cpu/0/speed-max"
87
 
 
88
 
/* kernel version constants */
89
 
#define KVER_24 1
90
 
#define KVER_26 2
91
 
 
92
 
struct interval {
93
 
  int min;
94
 
  int max;
95
 
};
96
 
 
97
 
typedef struct interval battery_interval;
98
 
typedef struct interval cpu_interval;
99
 
 
100
 
typedef struct profile {
101
 
  char name[255];
102
 
  long int min_freq;
103
 
  long int max_freq;
104
 
  unsigned char sep;
105
 
  char policy_name[255];
106
 
  struct profile *next;
107
 
} profile;
108
 
 
109
 
/* TODO: add precedence factor for rules having he same score */
110
 
/* TODO: add a command to be executed after the rule is activated */
111
 
typedef struct rule {
112
 
  char name[255];
113
 
  unsigned int ac;        /* AC power state */
114
 
  battery_interval *bat;
115
 
  cpu_interval *cpu;  
116
 
  float cpu_nice_scale;     /* how much will nice cpu time influence this rule? */
117
 
  int delay_cycles;       /* # of cycles this rule can wait before being applyed */
118
 
  char profile_name[255];
119
 
  struct string_list *program_list;
120
 
  profile *prof;
121
 
  struct rule *next;
122
 
  int hits;
123
 
} rule;
124
 
 
125
 
typedef struct sys_info {
126
 
  int has_battery:1;
127
 
  unsigned int ac;
128
 
  /*
129
 
  int old_weighted_activity;
130
 
  int cur_sys_activity;
131
 
  int cur_nice_activity;
132
 
  */
133
 
  int cpu_percent;
134
 
  int battery_percent;
135
 
  int battery_time;
136
 
  int temp;
137
 
  unsigned int flags;
138
 
        char version[101];
139
 
        char time[101];
140
 
} sys_info;
141
 
 
142
 
#define MATCH_AC       8
143
 
#define MATCH_CPU      4
144
 
#define MATCH_BATTERY  2
145
 
#define MATCH_PROG     1
146
 
 
147
 
#define DEFAULT_NICE_SCALE  3
148
 
#define DEFAULT_VERBOSITY   4
149
 
#define DEFAULT_POLL        1
150
 
#define DEFAULT_PMPLUGIN    "acpi"
151
 
 
152
 
typedef struct {
153
 
  char config_file[512];
154
 
  char pidfile[512];
155
 
  char pm_plugin[101];
156
 
  unsigned int poll_interval;
157
 
  int cpu_num;
158
 
  unsigned int has_sysfs;
159
 
  unsigned int no_daemon;
160
 
  unsigned int log_level_overridden;
161
 
  unsigned int acpi_workaround;
162
 
  long int cpu_min_freq;
163
 
  long int cpu_max_freq;
164
 
  int log_level;
165
 
  int kver;
166
 
  rule *rules;
167
 
  profile *profiles;
168
 
} general;
169
 
 
170
 
#endif