Skip to content

Commit

Permalink
lib: update dependency sbi-rt and sbi-spec
Browse files Browse the repository at this point in the history
Signed-off-by: Zhouqi Jiang <[email protected]>
  • Loading branch information
luojia65 committed Dec 27, 2023
1 parent 3cf1777 commit ff15b5a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
15 changes: 12 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
resolver = "2"
members = ["rustsbi-qemu", "hsm-cell", "test-kernel", "bench-kernel", "xtask"]
default-members = ["xtask"]

[profile.release]
opt-level = 3
2 changes: 1 addition & 1 deletion bench-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sbi-rt = "0.0.2"
sbi-rt = "0.0.3-rc.5"
riscv = "0.10.1"
uart_16550 = "0.2"
rcore-console = "0.0.0"
2 changes: 1 addition & 1 deletion hsm-cell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sbi-spec = "0.0.4"
sbi-spec = "0.0.7-alpha.3"

[lib]
name = "hsm_cell"
Expand Down
22 changes: 12 additions & 10 deletions hsm-cell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<T> HsmCell<T> {
/// 创建一个新的共享对象。
pub const fn new() -> Self {
Self {
status: AtomicUsize::new(HART_STATE_STOPPED),
status: AtomicUsize::new(hart_state::STOPPED),
val: UnsafeCell::new(None),
}
}
Expand Down Expand Up @@ -59,8 +59,8 @@ impl<T> LocalHsmCell<'_, T> {
pub fn start(&self) -> Result<T, usize> {
loop {
match self.0.status.compare_exchange(
HART_STATE_START_PENDING,
HART_STATE_STARTED,
hart_state::START_PENDING,
hart_state::STARTED,
Ordering::AcqRel,
Ordering::Relaxed,
) {
Expand All @@ -74,19 +74,21 @@ impl<T> LocalHsmCell<'_, T> {
/// 关闭。
#[inline]
pub fn stop(&self) {
self.0.status.store(HART_STATE_STOPPED, Ordering::Release)
self.0.status.store(hart_state::STOPPED, Ordering::Release)
}

/// 关闭。
#[inline]
pub fn suspend(&self) {
self.0.status.store(HART_STATE_SUSPENDED, Ordering::Relaxed)
self.0
.status
.store(hart_state::SUSPENDED, Ordering::Relaxed)
}

/// 关闭。
#[inline]
pub fn resume(&self) {
self.0.status.store(HART_STATE_STARTED, Ordering::Relaxed)
self.0.status.store(hart_state::STARTED, Ordering::Relaxed)
}
}

Expand All @@ -98,7 +100,7 @@ impl<T> RemoteHsmCell<'_, T> {
.0
.status
.compare_exchange(
HART_STATE_STOPPED,
hart_state::STOPPED,
HART_STATE_START_PENDING_EXT,
Ordering::Acquire,
Ordering::Relaxed,
Expand All @@ -108,7 +110,7 @@ impl<T> RemoteHsmCell<'_, T> {
unsafe { *self.0.val.get() = Some(t) };
self.0
.status
.store(HART_STATE_START_PENDING, Ordering::Release);
.store(hart_state::START_PENDING, Ordering::Release);
true
} else {
false
Expand All @@ -119,7 +121,7 @@ impl<T> RemoteHsmCell<'_, T> {
#[inline]
pub fn sbi_get_status(&self) -> usize {
match self.0.status.load(Ordering::Relaxed) {
HART_STATE_START_PENDING_EXT => HART_STATE_START_PENDING,
HART_STATE_START_PENDING_EXT => hart_state::START_PENDING,
normal => normal,
}
}
Expand All @@ -129,7 +131,7 @@ impl<T> RemoteHsmCell<'_, T> {
pub fn allow_ipi(&self) -> bool {
matches!(
self.0.status.load(Ordering::Relaxed),
HART_STATE_STARTED | HART_STATE_SUSPENDED
hart_state::STARTED | hart_state::SUSPENDED
)
}
}
2 changes: 1 addition & 1 deletion rustsbi-qemu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) {
// 打印启动信息
print!(
"\
[rustsbi] RustSBI version {ver_sbi}, adapting to RISC-V SBI v1.0.0
[rustsbi] RustSBI version {ver_sbi}, adapting to RISC-V SBI v2.0.0
{logo}
[rustsbi] Implementation : RustSBI-QEMU Version {ver_impl}
[rustsbi] Platform Name : {model}
Expand Down

0 comments on commit ff15b5a

Please sign in to comment.