forked from M-Labs/artiq
Rust: style (NFC).
This commit is contained in:
parent
999290fe52
commit
ab3bd67412
|
@ -1,30 +1,30 @@
|
|||
use board::csr::timer0;
|
||||
use board::csr;
|
||||
|
||||
const INIT: u64 = ::core::i64::MAX as u64;
|
||||
const FREQ: u64 = ::board::csr::CONFIG_CLOCK_FREQUENCY as u64;
|
||||
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
timer0::en_write(0);
|
||||
timer0::load_write(INIT);
|
||||
timer0::reload_write(INIT);
|
||||
timer0::en_write(1);
|
||||
csr::timer0::en_write(0);
|
||||
csr::timer0::load_write(INIT);
|
||||
csr::timer0::reload_write(INIT);
|
||||
csr::timer0::en_write(1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ms() -> u64 {
|
||||
unsafe {
|
||||
timer0::update_value_write(1);
|
||||
(INIT - timer0::value_read()) / (FREQ / 1_000)
|
||||
csr::timer0::update_value_write(1);
|
||||
(INIT - csr::timer0::value_read()) / (FREQ / 1_000)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spin_us(interval: u64) {
|
||||
unsafe {
|
||||
timer0::update_value_write(1);
|
||||
let threshold = timer0::value_read() - interval * (FREQ / 1_000_000);
|
||||
while timer0::value_read() > threshold {
|
||||
timer0::update_value_write(1)
|
||||
csr::timer0::update_value_write(1);
|
||||
let threshold = csr::timer0::value_read() - interval * (FREQ / 1_000_000);
|
||||
while csr::timer0::value_read() > threshold {
|
||||
csr::timer0::update_value_write(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use core::ptr;
|
||||
use board::csr::kernel_cpu;
|
||||
use board::csr;
|
||||
use mailbox;
|
||||
|
||||
const KERNELCPU_EXEC_ADDRESS: usize = 0x42000000;
|
||||
|
@ -8,7 +8,7 @@ const KERNELCPU_LAST_ADDRESS: usize = (0x4fffffff - 1024*1024);
|
|||
const KSUPPORT_HEADER_SIZE: usize = 0x80;
|
||||
|
||||
pub unsafe fn start() {
|
||||
if kernel_cpu::reset_read() == 0 {
|
||||
if csr::kernel_cpu::reset_read() == 0 {
|
||||
panic!("attempted to start kernel CPU when it is already running")
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@ pub unsafe fn start() {
|
|||
(KERNELCPU_EXEC_ADDRESS - KSUPPORT_HEADER_SIZE) as *mut u8,
|
||||
ksupport_end - ksupport_start);
|
||||
|
||||
kernel_cpu::reset_write(0);
|
||||
csr::kernel_cpu::reset_write(0);
|
||||
}
|
||||
|
||||
pub fn stop() {
|
||||
unsafe { kernel_cpu::reset_write(1) }
|
||||
unsafe { csr::kernel_cpu::reset_write(1) }
|
||||
mailbox::acknowledge();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue