Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions awkernel_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ version = "0.2"
optional = true

[dependencies.riscv]
version = "0.11.1"
version = "0.16.1"
optional = true

[dependencies.x86_64]
Expand Down Expand Up @@ -95,7 +95,7 @@ x86 = [
]
aarch64 = ["dep:awkernel_aarch64", "awkernel_sync/aarch64"]
rv32 = ["dep:riscv", "awkernel_sync/rv32"]
rv64 = ["awkernel_sync/rv64"]
rv64 = ["dep:riscv", "awkernel_sync/rv64"]
std = ["dep:libc", "dep:socket2", "awkernel_sync/std"]
spinlock = ["awkernel_sync/spinlock"]
# LFN (Long File Name) support
Expand Down
3 changes: 3 additions & 0 deletions awkernel_lib/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pub mod aarch64;
#[cfg(all(feature = "x86", not(feature = "std")))]
pub mod x86_64;

#[cfg(all(any(feature = "rv32", feature = "rv64"), not(feature = "std")))]
pub mod rv_common;

#[cfg(all(feature = "rv32", not(feature = "std")))]
pub mod rv32;

Expand Down
1 change: 0 additions & 1 deletion awkernel_lib/src/arch/rv32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub(super) mod cpu;
pub(super) mod delay;
pub(super) mod dvfs;
pub(super) mod frame_allocator;
pub(super) mod interrupt;
pub(super) mod memory;
pub(super) mod page_table;
pub(super) mod paging;
Expand Down
33 changes: 0 additions & 33 deletions awkernel_lib/src/arch/rv32/interrupt.rs

This file was deleted.

1 change: 0 additions & 1 deletion awkernel_lib/src/arch/rv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub(super) mod cpu;
pub(super) mod delay;
pub(super) mod dvfs;
pub(super) mod frame_allocator;
pub(super) mod interrupt;
pub(super) mod page_table;
pub(super) mod paging;
pub(super) mod vm;
Expand Down
33 changes: 0 additions & 33 deletions awkernel_lib/src/arch/rv64/interrupt.rs

This file was deleted.

6 changes: 6 additions & 0 deletions awkernel_lib/src/arch/rv_common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[cfg(feature = "rv32")]
use super::rv32::RV32 as ArchImpl;
#[cfg(feature = "rv64")]
use super::rv64::RV64 as ArchImpl;

pub(super) mod interrupt;
31 changes: 31 additions & 0 deletions awkernel_lib/src/arch/rv_common/interrupt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use super::ArchImpl;
use crate::interrupt::Interrupt;
use riscv::register::mstatus;

impl Interrupt for ArchImpl {
#[inline]
fn get_flag() -> usize {
let mie_mask = 0x08;
mstatus::read().bits() & mie_mask
}
#[inline]
fn disable() {
unsafe { mstatus::clear_mie() };
}
#[inline]
fn enable() {
unsafe { mstatus::set_mie() };
}
#[inline]
fn are_enabled() -> bool {
mstatus::read().mie()
}
#[inline]
fn set_flag(flag: usize) {
if flag & 0x08 > 0 {
Self::enable();
} else {
Self::disable();
}
}
}