Merge #21
21: Add 64-bit targets, reads for composite CSRs, bump version r=dvc94ch a=Disasm Co-authored-by: Vadim Kaushan <admin@disasm.info>
This commit is contained in:
commit
2450868523
|
@ -24,6 +24,14 @@ matrix:
|
|||
rust: nightly
|
||||
if: (branch = staging OR branch = trying OR branch = master) OR (type = pull_request AND branch = master)
|
||||
|
||||
- env: TARGET=riscv64imac-unknown-none-elf
|
||||
rust: nightly
|
||||
if: (branch = staging OR branch = trying OR branch = master) OR (type = pull_request AND branch = master)
|
||||
|
||||
- env: TARGET=riscv64gc-unknown-none-elf
|
||||
rust: nightly
|
||||
if: (branch = staging OR branch = trying OR branch = master) OR (type = pull_request AND branch = master)
|
||||
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: stable
|
||||
if: (branch = staging OR branch = trying OR branch = master) OR (type = pull_request AND branch = master)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "riscv"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
repository = "https://github.com/rust-embedded/riscv"
|
||||
authors = ["The RISC-V Team <risc-v@teams.rust-embedded.org>"]
|
||||
categories = ["embedded", "hardware-support", "no-std"]
|
||||
|
|
|
@ -10,7 +10,11 @@ rm -f bin/*.a
|
|||
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o
|
||||
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imac asm32.S -o bin/$crate-32.o
|
||||
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o bin/$crate-32.o
|
||||
cp bin/riscv32imac-unknown-none-elf.a bin/riscv32imc-unknown-none-elf.a
|
||||
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o bin/$crate-32.o
|
||||
|
||||
riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
|
||||
ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
||||
ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
||||
|
||||
rm bin/$crate.o
|
||||
rm bin/$crate-32.o
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -208,3 +208,25 @@ macro_rules! set_clear_csr {
|
|||
clear_csr!($(#[$attr])*, $clear_field, $e);
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! read_composite_csr {
|
||||
($hi:expr, $lo:expr) => {
|
||||
/// Reads the CSR as a 64-bit value
|
||||
#[inline]
|
||||
pub fn read64() -> u64 {
|
||||
match () {
|
||||
#[cfg(riscv32)]
|
||||
() => loop {
|
||||
let hi = $hi;
|
||||
let lo = $lo;
|
||||
if hi == $hi {
|
||||
return ((hi as u64) << 32) | lo as u64;
|
||||
}
|
||||
},
|
||||
|
||||
#[cfg(not(riscv32))]
|
||||
() => $lo as u64,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//! mcycle register
|
||||
|
||||
read_csr_as_usize!(0xB00, __read_mcycle);
|
||||
read_composite_csr!(super::mcycleh::read(), read());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! mie register
|
||||
|
||||
use bit_field::BitField;
|
||||
|
||||
/// mie register
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Mie {
|
||||
|
@ -16,55 +18,55 @@ impl Mie {
|
|||
/// User Software Interrupt Enable
|
||||
#[inline]
|
||||
pub fn usoft(&self) -> bool {
|
||||
self.bits & (1 << 0) == 1 << 0
|
||||
self.bits.get_bit(0)
|
||||
}
|
||||
|
||||
/// Supervisor Software Interrupt Enable
|
||||
#[inline]
|
||||
pub fn ssoft(&self) -> bool {
|
||||
self.bits & (1 << 1) == 1 << 1
|
||||
self.bits.get_bit(1)
|
||||
}
|
||||
|
||||
/// Machine Software Interrupt Enable
|
||||
#[inline]
|
||||
pub fn msoft(&self) -> bool {
|
||||
self.bits & (1 << 3) == 1 << 3
|
||||
self.bits.get_bit(3)
|
||||
}
|
||||
|
||||
/// User Timer Interrupt Enable
|
||||
#[inline]
|
||||
pub fn utimer(&self) -> bool {
|
||||
self.bits & (1 << 4) == 1 << 4
|
||||
self.bits.get_bit(4)
|
||||
}
|
||||
|
||||
/// Supervisor Timer Interrupt Enable
|
||||
#[inline]
|
||||
pub fn stimer(&self) -> bool {
|
||||
self.bits & (1 << 5) == 1 << 5
|
||||
self.bits.get_bit(5)
|
||||
}
|
||||
|
||||
/// Machine Timer Interrupt Enable
|
||||
#[inline]
|
||||
pub fn mtimer(&self) -> bool {
|
||||
self.bits & (1 << 7) == 1 << 7
|
||||
self.bits.get_bit(7)
|
||||
}
|
||||
|
||||
/// User External Interrupt Enable
|
||||
#[inline]
|
||||
pub fn uext(&self) -> bool {
|
||||
self.bits & (1 << 8) == 1 << 8
|
||||
self.bits.get_bit(8)
|
||||
}
|
||||
|
||||
/// Supervisor External Interrupt Enable
|
||||
#[inline]
|
||||
pub fn sext(&self) -> bool {
|
||||
self.bits & (1 << 9) == 1 << 9
|
||||
self.bits.get_bit(9)
|
||||
}
|
||||
|
||||
/// Machine External Interrupt Enable
|
||||
#[inline]
|
||||
pub fn mext(&self) -> bool {
|
||||
self.bits & (1 << 11) == 1 << 11
|
||||
self.bits.get_bit(11)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//! minstret register
|
||||
|
||||
read_csr_as_usize!(0xB02, __read_minstret);
|
||||
read_composite_csr!(super::minstreth::read(), read());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! mip register
|
||||
|
||||
use bit_field::BitField;
|
||||
|
||||
/// mip register
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Mip {
|
||||
|
@ -16,55 +18,55 @@ impl Mip {
|
|||
/// User Software Interrupt Pending
|
||||
#[inline]
|
||||
pub fn usoft(&self) -> bool {
|
||||
self.bits & (1 << 0) == 1 << 0
|
||||
self.bits.get_bit(0)
|
||||
}
|
||||
|
||||
/// Supervisor Software Interrupt Pending
|
||||
#[inline]
|
||||
pub fn ssoft(&self) -> bool {
|
||||
self.bits & (1 << 1) == 1 << 1
|
||||
self.bits.get_bit(1)
|
||||
}
|
||||
|
||||
/// Machine Software Interrupt Pending
|
||||
#[inline]
|
||||
pub fn msoft(&self) -> bool {
|
||||
self.bits & (1 << 3) == 1 << 3
|
||||
self.bits.get_bit(3)
|
||||
}
|
||||
|
||||
/// User Timer Interrupt Pending
|
||||
#[inline]
|
||||
pub fn utimer(&self) -> bool {
|
||||
self.bits & (1 << 4) == 1 << 4
|
||||
self.bits.get_bit(4)
|
||||
}
|
||||
|
||||
/// Supervisor Timer Interrupt Pending
|
||||
#[inline]
|
||||
pub fn stimer(&self) -> bool {
|
||||
self.bits & (1 << 5) == 1 << 5
|
||||
self.bits.get_bit(5)
|
||||
}
|
||||
|
||||
/// Machine Timer Interrupt Pending
|
||||
#[inline]
|
||||
pub fn mtimer(&self) -> bool {
|
||||
self.bits & (1 << 7) == 1 << 7
|
||||
self.bits.get_bit(7)
|
||||
}
|
||||
|
||||
/// User External Interrupt Pending
|
||||
#[inline]
|
||||
pub fn uext(&self) -> bool {
|
||||
self.bits & (1 << 8) == 1 << 8
|
||||
self.bits.get_bit(8)
|
||||
}
|
||||
|
||||
/// Supervisor External Interrupt Pending
|
||||
#[inline]
|
||||
pub fn sext(&self) -> bool {
|
||||
self.bits & (1 << 9) == 1 << 9
|
||||
self.bits.get_bit(9)
|
||||
}
|
||||
|
||||
/// Machine External Interrupt Pending
|
||||
#[inline]
|
||||
pub fn mext(&self) -> bool {
|
||||
self.bits & (1 << 11) == 1 << 11
|
||||
self.bits.get_bit(11)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//! time register
|
||||
|
||||
read_csr_as_usize!(0xC01, __read_time);
|
||||
read_composite_csr!(super::timeh::read(), read());
|
||||
|
|
Loading…
Reference in New Issue