Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
5912e264
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5912e264
编写于
2月 28, 2015
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'tmon-fixes' of .git into next
上级
f1260791
986ffe03
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
14 deletion
+63
-14
tools/thermal/tmon/.gitignore
tools/thermal/tmon/.gitignore
+1
-0
tools/thermal/tmon/Makefile
tools/thermal/tmon/Makefile
+12
-3
tools/thermal/tmon/tmon.8
tools/thermal/tmon/tmon.8
+2
-0
tools/thermal/tmon/tmon.c
tools/thermal/tmon/tmon.c
+12
-2
tools/thermal/tmon/tui.c
tools/thermal/tmon/tui.c
+36
-9
未找到文件。
tools/thermal/tmon/.gitignore
0 → 100644
浏览文件 @
5912e264
/tmon
tools/thermal/tmon/Makefile
浏览文件 @
5912e264
...
...
@@ -2,8 +2,8 @@ VERSION = 1.0
BINDIR
=
usr/bin
WARNFLAGS
=
-Wall
-Wshadow
-W
-Wformat
-Wimplicit-function-declaration
-Wimplicit-int
CFLAGS
=
-O1
${WARNFLAGS}
-fstack-protector
CC
=
gcc
CFLAGS
+
=
-O1
${WARNFLAGS}
-fstack-protector
CC
=
$(CROSS_COMPILE)
gcc
CFLAGS
+=
-D
VERSION
=
\"
$(VERSION)
\"
LDFLAGS
+=
...
...
@@ -16,12 +16,21 @@ INSTALL_CONFIGFILE=install -m 644 -p
CONFIG_FILE
=
CONFIG_PATH
=
# Static builds might require -ltinfo, for instance
ifneq
($(findstring -static, $(LDFLAGS)),)
STATIC
:=
--static
endif
TMON_LIBS
=
-lm
-lpthread
TMON_LIBS
+=
$(
shell
pkg-config
--libs
$(STATIC)
panelw ncursesw 2> /dev/null
||
\
pkg-config
--libs
$(STATIC)
panel ncurses 2> /dev/null
||
\
echo
-lpanel
-lncurses
)
OBJS
=
tmon.o tui.o sysfs.o pid.o
OBJS
+=
tmon
:
$(OBJS) Makefile tmon.h
$(CC)
$
{CFLAGS}
$(LDFLAGS)
$(OBJS)
-o
$(TARGET)
-lm
-lpanel
-lncursesw
-ltinfo
-lpthread
$(CC)
$
(CFLAGS)
$(LDFLAGS)
$(OBJS)
-o
$(TARGET)
$(TMON_LIBS)
valgrind
:
tmon
sudo
valgrind
-v
--track-origins
=
yes
--tool
=
memcheck
--leak-check
=
yes
--show-reachable
=
yes
--num-callers
=
20
--track-fds
=
yes
./
$(TARGET)
1> /dev/null
...
...
tools/thermal/tmon/tmon.8
浏览文件 @
5912e264
...
...
@@ -55,6 +55,8 @@ The \fB-l --log\fP option write data to /var/tmp/tmon.log
.PP
The \fB-t --time-interval\fP option sets the polling interval in seconds
.PP
The \fB-T --target-temp\fP option sets the initial target temperature
.PP
The \fB-v --version\fP option shows the version of \fBtmon \fP
.PP
The \fB-z --zone\fP option sets the target therma zone instance to be controlled
...
...
tools/thermal/tmon/tmon.c
浏览文件 @
5912e264
...
...
@@ -64,6 +64,7 @@ void usage()
printf
(
" -h, --help show this help message
\n
"
);
printf
(
" -l, --log log data to /var/tmp/tmon.log
\n
"
);
printf
(
" -t, --time-interval sampling time interval, > 1 sec.
\n
"
);
printf
(
" -T, --target-temp initial target temperature
\n
"
);
printf
(
" -v, --version show version
\n
"
);
printf
(
" -z, --zone target thermal zone id
\n
"
);
...
...
@@ -219,6 +220,7 @@ static struct option opts[] = {
{
"control"
,
1
,
NULL
,
'c'
},
{
"daemon"
,
0
,
NULL
,
'd'
},
{
"time-interval"
,
1
,
NULL
,
't'
},
{
"target-temp"
,
1
,
NULL
,
'T'
},
{
"log"
,
0
,
NULL
,
'l'
},
{
"help"
,
0
,
NULL
,
'h'
},
{
"version"
,
0
,
NULL
,
'v'
},
...
...
@@ -231,7 +233,7 @@ int main(int argc, char **argv)
{
int
err
=
0
;
int
id2
=
0
,
c
;
double
yk
=
0
.
0
;
/* controller output */
double
yk
=
0
.
0
,
temp
;
/* controller output */
int
target_tz_index
;
if
(
geteuid
()
!=
0
)
{
...
...
@@ -239,7 +241,7 @@ int main(int argc, char **argv)
exit
(
EXIT_FAILURE
);
}
while
((
c
=
getopt_long
(
argc
,
argv
,
"c:dlht:vgz:"
,
opts
,
&
id2
))
!=
-
1
)
{
while
((
c
=
getopt_long
(
argc
,
argv
,
"c:dlht:
T:
vgz:"
,
opts
,
&
id2
))
!=
-
1
)
{
switch
(
c
)
{
case
'c'
:
no_control
=
0
;
...
...
@@ -254,6 +256,14 @@ int main(int argc, char **argv)
if
(
ticktime
<
1
)
ticktime
=
1
;
break
;
case
'T'
:
temp
=
strtod
(
optarg
,
NULL
);
if
(
temp
<
0
)
{
fprintf
(
stderr
,
"error: temperature must be positive
\n
"
);
return
1
;
}
target_temp_user
=
temp
;
break
;
case
'l'
:
printf
(
"Logging data to /var/tmp/tmon.log
\n
"
);
logging
=
1
;
...
...
tools/thermal/tmon/tui.c
浏览文件 @
5912e264
...
...
@@ -30,6 +30,18 @@
#include "tmon.h"
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
#define max(x, y) ({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
static
PANEL
*
data_panel
;
static
PANEL
*
dialogue_panel
;
static
PANEL
*
top
;
...
...
@@ -98,6 +110,18 @@ void write_status_bar(int x, char *line)
wrefresh
(
status_bar_window
);
}
/* wrap at 5 */
#define DIAG_DEV_ROWS 5
/*
* list cooling devices + "set temp" entry; wraps after 5 rows, if they fit
*/
static
int
diag_dev_rows
(
void
)
{
int
entries
=
ptdata
.
nr_cooling_dev
+
1
;
int
rows
=
max
(
DIAG_DEV_ROWS
,
(
entries
+
1
)
/
2
);
return
min
(
rows
,
entries
);
}
void
setup_windows
(
void
)
{
int
y_begin
=
1
;
...
...
@@ -122,7 +146,7 @@ void setup_windows(void)
* dialogue window is a pop-up, when needed it lays on top of cdev win
*/
dialogue_window
=
subwin
(
stdscr
,
ptdata
.
nr_cooling_dev
+
5
,
maxx
-
50
,
dialogue_window
=
subwin
(
stdscr
,
diag_dev_rows
()
+
5
,
maxx
-
50
,
DIAG_Y
,
DIAG_X
);
thermal_data_window
=
subwin
(
stdscr
,
ptdata
.
nr_tz_sensor
*
...
...
@@ -258,21 +282,26 @@ void show_cooling_device(void)
}
const
char
DIAG_TITLE
[]
=
"[ TUNABLES ]"
;
#define DIAG_DEV_ROWS 5
void
show_dialogue
(
void
)
{
int
j
,
x
=
0
,
y
=
0
;
int
rows
,
cols
;
WINDOW
*
w
=
dialogue_window
;
if
(
tui_disabled
||
!
w
)
return
;
getmaxyx
(
w
,
rows
,
cols
);
/* Silence compiler 'unused' warnings */
(
void
)
cols
;
werase
(
w
);
box
(
w
,
0
,
0
);
mvwprintw
(
w
,
0
,
maxx
/
4
,
DIAG_TITLE
);
/* list all the available tunables */
for
(
j
=
0
;
j
<=
ptdata
.
nr_cooling_dev
;
j
++
)
{
y
=
j
%
DIAG_DEV_ROWS
;
y
=
j
%
diag_dev_rows
()
;
if
(
y
==
0
&&
j
!=
0
)
x
+=
20
;
if
(
j
==
ptdata
.
nr_cooling_dev
)
...
...
@@ -283,12 +312,10 @@ void show_dialogue(void)
ptdata
.
cdi
[
j
].
type
,
ptdata
.
cdi
[
j
].
instance
);
}
wattron
(
w
,
A_BOLD
);
mvwprintw
(
w
,
DIAG_DEV_ROWS
+
1
,
1
,
"Enter Choice [A-Z]?"
);
mvwprintw
(
w
,
diag_dev_rows
()
+
1
,
1
,
"Enter Choice [A-Z]?"
);
wattroff
(
w
,
A_BOLD
);
/* y size of dialogue win is nr cdev + 5, so print legend
* at the bottom line
*/
mvwprintw
(
w
,
ptdata
.
nr_cooling_dev
+
3
,
1
,
/* print legend at the bottom line */
mvwprintw
(
w
,
rows
-
2
,
1
,
"Legend: A=Active, P=Passive, C=Critical"
);
wrefresh
(
dialogue_window
);
...
...
@@ -437,7 +464,7 @@ static void handle_input_choice(int ch)
snprintf
(
buf
,
sizeof
(
buf
),
"New Value for %.10s-%2d: "
,
ptdata
.
cdi
[
cdev_id
].
type
,
ptdata
.
cdi
[
cdev_id
].
instance
);
write_dialogue_win
(
buf
,
DIAG_DEV_ROWS
+
2
,
2
);
write_dialogue_win
(
buf
,
diag_dev_rows
()
+
2
,
2
);
handle_input_val
(
cdev_id
);
}
else
{
snprintf
(
buf
,
sizeof
(
buf
),
"Invalid selection %d"
,
ch
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录