提交 51bba09a 编写于 作者: z13955633063's avatar z13955633063

remove cpuusage.c

remove unused line in SConstruct
上级 72cfe9dd
......@@ -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)
......@@ -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];
......
#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
#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.
先完成此消息的编辑!
想要评论请 注册