Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
51bba09a
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
51bba09a
编写于
7月 31, 2017
作者:
z13955633063
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove cpuusage.c
remove unused line in SConstruct
上级
72cfe9dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
122 addition
and
95 deletion
+122
-95
bsp/hifive1/SConstruct
bsp/hifive1/SConstruct
+0
-9
bsp/hifive1/applications/applications.c
bsp/hifive1/applications/applications.c
+2
-11
bsp/hifive1/drivers/cpuusage.c
bsp/hifive1/drivers/cpuusage.c
+0
-75
bsp/hifive1/platform/plic_driver.c
bsp/hifive1/platform/plic_driver.c
+120
-0
未找到文件。
bsp/hifive1/SConstruct
浏览文件 @
51bba09a
...
...
@@ -25,14 +25,5 @@ Export('rtconfig')
# prepare building environment
objs
=
PrepareBuilding
(
env
,
RTT_ROOT
)
if
GetDepend
(
'RT_USING_WEBSERVER'
):
objs
=
objs
+
SConscript
(
RTT_ROOT
+
'/components/net/webserver/SConscript'
,
variant_dir
=
'build/net/webserver'
,
duplicate
=
0
)
if
GetDepend
(
'RT_USING_RTGUI'
):
objs
=
objs
+
SConscript
(
RTT_ROOT
+
'/examples/gui/SConscript'
,
variant_dir
=
'build/examples/gui'
,
duplicate
=
0
)
# libc testsuite
#objs = objs + SConscript(RTT_ROOT + '/examples/libc/SConscript', variant_dir='build/examples/libc', duplicate=0)
# make a building
DoBuilding
(
TARGET
,
objs
)
bsp/hifive1/applications/applications.c
浏览文件 @
51bba09a
...
...
@@ -17,22 +17,13 @@ static void led_thread_entry(void* parameter)
rt_hw_led_init
();
while
(
0
)
{
/* led1 on */
#ifndef RT_USING_FINSH
/* rt_kprintf("led on, count : %d\r\n",count);*/
#endif
rt_kprintf
(
"core freq at %d Hz
\n
"
,
get_cpu_freq
());
count
++
;
rt_thread_delay
(
RT_TIMER_TICK_PER_SECOND
/
2
);
/* sleep 0.5 second and switch to other thread */
/* rt_hw_led_on(0);*/
rt_thread_delay
(
RT_TIMER_TICK_PER_SECOND
/
2
);
/* sleep 0.5 second and switch to other thread */
/* led1 off */
#ifndef RT_USING_FINSH
/* rt_kprintf("led off\r\n");*/
#endif
rt_hw_led_off
(
0
);
/* rt_thread_delay( RT_TIMER_TICK_PER_SECOND*2);*/
rt_thread_delay
(
RT_TIMER_TICK_PER_SECOND
*
2
);
}
}
static
rt_uint8_t
led_stack
[
1024
];
...
...
bsp/hifive1/drivers/cpuusage.c
已删除
100644 → 0
浏览文件 @
72cfe9dd
#include <rtthread.h>
#include <rthw.h>
#include "board.h"
static
rt_uint8_t
cpu_usage_major
=
0
,
cpu_usage_minor
=
0
;
static
rt_uint32_t
idle_begin
=
0
,
idle_count
=
0
;
static
rt_uint32_t
run_begin
=
0
,
run_count
=
0
;
static
rt_uint32_t
update_tick
=
0
;
static
wtdog_count
=
0
;
#define jiffies rt_tick_get()
void
cpu_usage_idle_hook
()
{
wtdog_count
=
0
;
}
void
thread_switch_hook
(
struct
rt_thread
*
from
,
struct
rt_thread
*
to
)
{
//leave idle
if
(
from
->
init_priority
==
RT_THREAD_PRIORITY_MAX
-
1
)
{
run_begin
=
jiffies
;
idle_count
+=
jiffies
-
idle_begin
;
}
//enter idle
if
(
to
->
init_priority
==
RT_THREAD_PRIORITY_MAX
-
1
)
{
idle_begin
=
jiffies
;
run_count
+=
jiffies
-
run_begin
;
}
//enter main once 500ms
else
if
(
to
->
init_priority
==
2
)
{
register
rt_uint32_t
total_count
;
run_count
+=
jiffies
-
run_begin
;
run_begin
=
jiffies
;
total_count
=
run_count
+
idle_count
;
cpu_usage_major
=
(
run_count
*
100
)
/
total_count
;
cpu_usage_minor
=
((
run_count
*
100
)
%
total_count
)
*
100
/
total_count
;
idle_count
=
run_count
=
0
;
update_tick
=
rt_tick_get
();
}
}
#if defined(RT_USING_FINSH)
#include <finsh.h>
void
cpu_usage
()
{
//long time no update?? 100%
if
((
rt_tick_get
()
-
update_tick
)
>
1000
)
{
cpu_usage_major
=
100
;
cpu_usage_minor
=
0
;
}
rt_kprintf
(
"Cpu Usage: %d.%d
\n
"
,
cpu_usage_major
,
cpu_usage_minor
);
}
void
rt_usage_info
(
rt_uint32_t
*
major
,
rt_uint32_t
*
minor
)
{
//long time no update?? 100%
if
((
rt_tick_get
()
-
update_tick
)
>
1000
)
{
cpu_usage_major
=
100
;
cpu_usage_minor
=
0
;
}
if
(
major
)
*
major
=
cpu_usage_major
;
if
(
minor
)
*
minor
=
cpu_usage_minor
;
}
RTM_EXPORT
(
rt_usage_info
);
FINSH_FUNCTION_EXPORT
(
cpu_usage
,
cpu
usage
);
MSH_CMD_EXPORT
(
cpu_usage
,
cpu
usage
);
#endif //RT_USING_FINSH
bsp/hifive1/platform/plic_driver.c
0 → 100644
浏览文件 @
51bba09a
#include "sifive/devices/plic.h"
#include "plic_driver.h"
#include "platform.h"
#include "encoding.h"
#include <string.h>
void
volatile_memzero
(
uint8_t
*
base
,
unsigned
int
size
)
{
volatile
uint8_t
*
ptr
;
for
(
ptr
=
base
;
ptr
<
(
base
+
size
);
ptr
++
){
*
ptr
=
0
;
}
}
void
PLIC_init
(
plic_instance_t
*
this_plic
,
uintptr_t
base_addr
,
uint32_t
num_sources
,
uint32_t
num_priorities
)
{
this_plic
->
base_addr
=
base_addr
;
this_plic
->
num_sources
=
num_sources
;
this_plic
->
num_priorities
=
num_priorities
;
// Disable all interrupts (don't assume that these registers are reset).
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile_memzero
((
uint8_t
*
)
(
this_plic
->
base_addr
+
PLIC_ENABLE_OFFSET
+
(
hart_id
<<
PLIC_ENABLE_SHIFT_PER_TARGET
)),
(
num_sources
+
8
)
/
8
);
// Set all priorities to 0 (equal priority -- don't assume that these are reset).
volatile_memzero
((
uint8_t
*
)(
this_plic
->
base_addr
+
PLIC_PRIORITY_OFFSET
),
(
num_sources
+
1
)
<<
PLIC_PRIORITY_SHIFT_PER_SOURCE
);
// Set the threshold to 0.
volatile
plic_threshold
*
threshold
=
(
plic_threshold
*
)
(
this_plic
->
base_addr
+
PLIC_THRESHOLD_OFFSET
+
(
hart_id
<<
PLIC_THRESHOLD_SHIFT_PER_TARGET
));
*
threshold
=
0
;
}
void
PLIC_set_threshold
(
plic_instance_t
*
this_plic
,
plic_threshold
threshold
){
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile
plic_threshold
*
threshold_ptr
=
(
plic_threshold
*
)
(
this_plic
->
base_addr
+
PLIC_THRESHOLD_OFFSET
+
(
hart_id
<<
PLIC_THRESHOLD_SHIFT_PER_TARGET
));
*
threshold_ptr
=
threshold
;
}
void
PLIC_enable_interrupt
(
plic_instance_t
*
this_plic
,
plic_source
source
){
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile
uint8_t
*
current_ptr
=
(
volatile
uint8_t
*
)(
this_plic
->
base_addr
+
PLIC_ENABLE_OFFSET
+
(
hart_id
<<
PLIC_ENABLE_SHIFT_PER_TARGET
)
+
(
source
>>
3
));
uint8_t
current
=
*
current_ptr
;
current
=
current
|
(
1
<<
(
source
&
0x7
));
*
current_ptr
=
current
;
}
void
PLIC_disable_interrupt
(
plic_instance_t
*
this_plic
,
plic_source
source
){
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile
uint8_t
*
current_ptr
=
(
volatile
uint8_t
*
)
(
this_plic
->
base_addr
+
PLIC_ENABLE_OFFSET
+
(
hart_id
<<
PLIC_ENABLE_SHIFT_PER_TARGET
)
+
(
source
>>
3
));
uint8_t
current
=
*
current_ptr
;
current
=
current
&
~
((
1
<<
(
source
&
0x7
)));
*
current_ptr
=
current
;
}
void
PLIC_set_priority
(
plic_instance_t
*
this_plic
,
plic_source
source
,
plic_priority
priority
){
if
(
this_plic
->
num_priorities
>
0
)
{
volatile
plic_priority
*
priority_ptr
=
(
volatile
plic_priority
*
)
(
this_plic
->
base_addr
+
PLIC_PRIORITY_OFFSET
+
(
source
<<
PLIC_PRIORITY_SHIFT_PER_SOURCE
));
*
priority_ptr
=
priority
;
}
}
plic_source
PLIC_claim_interrupt
(
plic_instance_t
*
this_plic
){
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile
plic_source
*
claim_addr
=
(
volatile
plic_source
*
)
(
this_plic
->
base_addr
+
PLIC_CLAIM_OFFSET
+
(
hart_id
<<
PLIC_CLAIM_SHIFT_PER_TARGET
));
return
*
claim_addr
;
}
void
PLIC_complete_interrupt
(
plic_instance_t
*
this_plic
,
plic_source
source
){
unsigned
long
hart_id
=
read_csr
(
mhartid
);
volatile
plic_source
*
claim_addr
=
(
volatile
plic_source
*
)
(
this_plic
->
base_addr
+
PLIC_CLAIM_OFFSET
+
(
hart_id
<<
PLIC_CLAIM_SHIFT_PER_TARGET
));
*
claim_addr
=
source
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录