enable timer interrupt for K210

toolchain_update
WangRunji 6 years ago
parent b7e124930d
commit 020e3505ee

@ -536,6 +536,9 @@ gen_full_rlib
#if ! [[ -f outdir/ucore ]] #if ! [[ -f outdir/ucore ]]
#then #then
if [[ ${K210} = 1 ]]; then
export LINK_K210='-L native=kendryte'
fi
rustc --edition=2018 --crate-name ucore src/main.rs \ rustc --edition=2018 --crate-name ucore src/main.rs \
--color always --crate-type bin --emit=link \ --color always --crate-type bin --emit=link \
-C opt-level=1 \ -C opt-level=1 \
@ -560,7 +563,7 @@ rustc --edition=2018 --crate-name ucore src/main.rs \
--extern ucore_process=$PWD/outdir/libucore_process.rlib \ --extern ucore_process=$PWD/outdir/libucore_process.rlib \
--extern volatile=$PWD/outdir/libvolatile.rlib \ --extern volatile=$PWD/outdir/libvolatile.rlib \
--extern xmas_elf=$PWD/outdir/libxmas_elf.rlib \ --extern xmas_elf=$PWD/outdir/libxmas_elf.rlib \
-L native=outdir -L native=outdir ${LINK_K210}
#fi #fi
if [[ ${K210} = 1 ]]; then if [[ ${K210} = 1 ]]; then

@ -37,7 +37,8 @@ pub fn init() {
unsafe { mie::set_mtimer(); } unsafe { mie::set_mtimer(); }
#[cfg(not(feature = "m_mode"))] #[cfg(not(feature = "m_mode"))]
unsafe { sie::set_stimer(); } unsafe { sie::set_stimer(); }
#[cfg(feature = "board_k210")]
unsafe { assert_eq!(clint_timer_init(), 0); }
set_next(); set_next();
info!("timer: init end"); info!("timer: init end");
} }
@ -46,22 +47,23 @@ pub fn init() {
* @brief: * @brief:
* set the next timer interrupt * set the next timer interrupt
*/ */
#[cfg(not(feature = "board_k210"))]
pub fn set_next() { pub fn set_next() {
// 100Hz @ QEMU // 100Hz @ QEMU
let timebase = 250000; let timebase = 250000;
set_timer(get_cycle() + timebase); sbi::set_timer(get_cycle() + timebase);
} }
/* #[cfg(feature = "board_k210")]
* @brief: pub fn set_next() {
* set time for timer interrupt
*/
fn set_timer(t: u64) {
#[cfg(feature = "no_bbl")]
unsafe { unsafe {
asm!("csrw 0x321, $0; csrw 0x322, $1" assert_eq!(clint_timer_start(10, true), 0);
: : "r"(t as u32), "r"((t >> 32) as u32) : : "volatile");
} }
#[cfg(not(feature = "no_bbl"))] }
sbi::set_timer(t);
#[link(name = "kendryte")]
#[cfg(feature = "board_k210")]
extern "C" {
fn clint_timer_init() -> i32;
fn clint_timer_start(interval_ms: u64, single_shot: bool) -> i32;
} }
Loading…
Cancel
Save