riscv: use upstream riscv module

Still pulling from git, as the version number hasn't been bumped yet.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-11 17:49:03 +08:00
parent 17dd2dcd6f
commit 09890a2ca3
8 changed files with 24 additions and 25 deletions

21
Cargo.lock generated
View file

@ -194,7 +194,7 @@ name = "kernel"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"vexriscv", "riscv",
"xous", "xous",
] ]
@ -351,6 +351,15 @@ version = "0.6.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1" checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1"
[[package]]
name = "riscv"
version = "0.5.5"
source = "git+https://github.com/rust-embedded/riscv.git?rev=30af64cad7b3869a14182ab18b48ad0c71cce1ed#30af64cad7b3869a14182ab18b48ad0c71cce1ed"
dependencies = [
"bare-metal",
"bit_field",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.2.3" version = "0.2.3"
@ -470,16 +479,6 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
[[package]]
name = "vexriscv"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8cca4a24ec0049cadb38a5a0767529d28f3ea7bb5e5233b8f6cc02a1d8f0a51"
dependencies = [
"bare-metal",
"bit_field",
]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.9.0+wasi-snapshot-preview1" version = "0.9.0+wasi-snapshot-preview1"

View file

@ -7,7 +7,7 @@ description = "Core kernel for Xous, including task switching and memory managem
[dependencies] [dependencies]
bitflags = "1.2.1" bitflags = "1.2.1"
vexriscv = "0.0.2" riscv = { git = "https://github.com/rust-embedded/riscv.git", rev = "30af64cad7b3869a14182ab18b48ad0c71cce1ed" }
xous = { path = "../xous-rs" } xous = { path = "../xous-rs" }
[features] [features]

View file

@ -2,7 +2,7 @@
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
mod riscv; mod riscv;
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
pub use riscv::*; pub use crate::arch::riscv::*;
#[cfg(target_arch = "riscv64")] #[cfg(target_arch = "riscv64")]
mod riscv; mod riscv;

View file

@ -1,4 +1,4 @@
use vexriscv::register::{satp, sie, sstatus}; use riscv::register::{satp, sie, sstatus};
use xous::PID; use xous::PID;
pub mod exception; pub mod exception;
@ -20,6 +20,10 @@ pub fn init() {
} }
} }
pub fn wfi() {
unsafe { riscv::asm::wfi() };
}
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
/// Everything required to keep track of a single thread of execution. /// Everything required to keep track of a single thread of execution.

View file

@ -2,7 +2,7 @@ use crate::arch::current_pid;
use crate::arch::mem::MemoryMapping; use crate::arch::mem::MemoryMapping;
use crate::mem::MemoryManagerHandle; use crate::mem::MemoryManagerHandle;
use crate::processtable::{ProcessContext, ProcessState, SystemServicesHandle, RETURN_FROM_ISR}; use crate::processtable::{ProcessContext, ProcessState, SystemServicesHandle, RETURN_FROM_ISR};
use vexriscv::register::{scause, sepc, sie, sstatus, stval, vsim, vsip}; use riscv::register::{scause, sepc, sie, sstatus, stval, vexriscv::sim, vexriscv::sip};
use xous::{SysCall, PID}; use xous::{SysCall, PID};
extern "Rust" { extern "Rust" {
@ -26,11 +26,11 @@ pub fn enable_all_irqs() {
pub fn enable_irq(irq_no: usize) { pub fn enable_irq(irq_no: usize) {
// Note that the vexriscv "IRQ Mask" register is inverse-logic -- // Note that the vexriscv "IRQ Mask" register is inverse-logic --
// that is, setting a bit in the "mask" register unmasks (i.e. enables) it. // that is, setting a bit in the "mask" register unmasks (i.e. enables) it.
vsim::write(vsim::read() | (1 << irq_no)); sim::write(sim::read() | (1 << irq_no));
} }
pub fn disable_irq(irq_no: usize) { pub fn disable_irq(irq_no: usize) {
vsim::write(vsim::read() & !(1 << irq_no)); sim::write(sim::read() & !(1 << irq_no));
} }
static mut PREVIOUS_PID: Option<PID> = None; static mut PREVIOUS_PID: Option<PID> = None;
@ -169,7 +169,7 @@ pub extern "C" fn trap_handler(
println!("CPU Exception on PID {}: {}", pid, ex); println!("CPU Exception on PID {}: {}", pid, ex);
loop {} loop {}
} else { } else {
let irqs_pending = vsip::read(); let irqs_pending = sip::read();
// Safe to access globals since interrupts are disabled // Safe to access globals since interrupts are disabled
// when this function runs. // when this function runs.
unsafe { unsafe {

View file

@ -1,6 +1,6 @@
use crate::mem::MemoryManager; use crate::mem::MemoryManager;
use core::fmt; use core::fmt;
use vexriscv::register::satp; use riscv::register::satp;
use xous::{MemoryFlags, PID}; use xous::{MemoryFlags, PID};
pub const DEFAULT_STACK_TOP: usize = 0x8000_0000; pub const DEFAULT_STACK_TOP: usize = 0x8000_0000;

View file

@ -1,5 +1,5 @@
use crate::processtable::ProcessContext; use crate::processtable::ProcessContext;
use vexriscv::register::{sepc, sstatus}; use riscv::register::{sepc, sstatus};
extern "C" { extern "C" {
fn _xous_resume_context(regs: *const usize) -> !; fn _xous_resume_context(regs: *const usize) -> !;

View file

@ -1,13 +1,9 @@
#![cfg_attr(not(test), no_main)] #![cfg_attr(not(test), no_main)]
#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_std)]
extern crate vexriscv;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
extern crate xous;
#[macro_use] #[macro_use]
mod debug; mod debug;
@ -127,7 +123,7 @@ pub extern "C" fn main() {
} }
None => { None => {
println!("No runnable tasks found. Zzz..."); println!("No runnable tasks found. Zzz...");
unsafe { vexriscv::asm::wfi() }; arch::wfi();
} }
} }
} }