-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathidlestat.h
More file actions
143 lines (126 loc) · 2.99 KB
/
idlestat.h
File metadata and controls
143 lines (126 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* idlestat.h
*
* Copyright (C) 2014, Linaro Limited.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 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; version 2 of the License.
*
* 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.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Contributors:
* Daniel Lezcano <daniel.lezcano@linaro.org>
* Zoran Markovic <zoran.markovic@linaro.org>
*
*/
#ifndef __IDLESTAT_H
#define __IDLESTAT_H
#define BUFSIZE 256
#define NAMELEN 16
#define MAXCSTATE 16
#define MAXPSTATE 16
#define MAX(A, B) (A > B ? A : B)
#define MIN(A, B) (A < B ? A : B)
#define AVG(A, B, I) ((A) + ((B - A) / (I)))
#define IRQ_WAKEUP_UNIT_NAME "cpu"
#define CPUIDLE_STATE_TARGETRESIDENCY_PATH_FORMAT \
"/sys/devices/system/cpu/cpu%d/cpuidle/state%d/residency"
#define CPUFREQ_AVFREQ_PATH_FORMAT \
"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_frequencies"
#define CPUIDLE_STATENAME_PATH_FORMAT \
"/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name"
struct cpuidle_data {
double begin;
double end;
double duration;
};
struct cpuidle_cstate {
char *name;
struct cpuidle_data *data;
int nrdata;
int premature_wakeup;
int could_sleep_more;
double avg_time;
double max_time;
double min_time;
double duration;
int target_residency; /* -1 if not available */
};
enum IRQ_TYPE {
HARD_IRQ = 0,
IPI_IRQ,
IRQ_TYPE_MAX
};
struct wakeup_irq {
int id;
int irq_type;
char name[NAMELEN+1];
int count;
int not_predicted;
};
struct wakeup_info {
struct wakeup_irq *irqinfo;
int nrdata;
};
struct cpuidle_cstates {
struct cpuidle_cstate cstate[MAXCSTATE];
struct wakeup_info wakeinfo;
int last_cstate;
int cstate_max;
struct wakeup_irq *wakeirq;
int not_predicted;
};
struct cpufreq_pstate {
int id;
unsigned int freq;
int count;
double min_time;
double max_time;
double avg_time;
double duration;
};
struct cpufreq_pstates {
struct cpufreq_pstate *pstate;
int current;
int idle;
double time_enter;
double time_exit;
int max;
};
struct cpuidle_datas {
struct cpuidle_cstates *cstates;
struct cpufreq_pstates *pstates;
int nrcpus;
};
enum modes {
TRACE = 0,
IMPORT
};
enum formats {
IDLESTAT_HEADER = 0,
TRACE_CMD_HEADER
};
struct program_options {
int mode;
int format;
int display;
unsigned int duration;
char *filename;
char *outfilename;
int verbose;
};
#define IDLE_DISPLAY 0x1
#define FREQUENCY_DISPLAY 0x2
#define WAKEUP_DISPLAY 0x4
#endif