Skip to content

Commit b316171

Browse files
committed
deps: update fast-trap
Signed-off-by: YdrMaster <ydrml@hotmail.com>
1 parent 3b2e41d commit b316171

File tree

4 files changed

+57
-99
lines changed

4 files changed

+57
-99
lines changed

Cargo.lock

Lines changed: 41 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustsbi-qemu/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ edition = "2021"
1717
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1818

1919
[dependencies]
20-
rustsbi = "0.3.0"
20+
rustsbi = "0.3.1"
2121
sbi-spec = { version = "0.0.4", features = ["legacy"] }
2222
riscv = "0.10.1"
2323
spin = "0.9"
@@ -28,6 +28,4 @@ sifive-test-device = "0.0.0"
2828
dtb-walker = "=0.2.0-alpha.3"
2929

3030
hsm-cell = { path = "../hsm-cell" }
31-
fast-trap = { git = "https://github.com/YdrMaster/fast-trap", rev = "51a9c71", features = [
32-
"riscv-m",
33-
] }
31+
fast-trap = { version = "=0.0.1", features = ["riscv-m"] }

rustsbi-qemu/src/trap_stack.rs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use crate::{fast_handler, hart_id, Supervisor, LEN_STACK_PER_HART, NUM_HART_MAX};
2-
use core::{
3-
mem::{forget, size_of},
4-
ptr::NonNull,
5-
};
6-
use fast_trap::{FlowContext, FreeTrapStack, TrapStackBlock};
2+
use core::{mem::forget, ptr::NonNull};
3+
use fast_trap::{FlowContext, FreeTrapStack};
74
use hsm_cell::{HsmCell, LocalHsmCell, RemoteHsmCell};
85

96
/// 栈空间。
@@ -89,39 +86,20 @@ impl Stack {
8986
let hart = self.hart_context();
9087
let context_ptr = hart.context_ptr();
9188
hart.init();
89+
let range = self.0.as_ptr_range();
9290
forget(
93-
FreeTrapStack::new(StackRef(self), context_ptr, fast_handler)
94-
.unwrap()
95-
.load(),
91+
FreeTrapStack::new(
92+
range.start as usize..range.end as usize,
93+
|_| {},
94+
context_ptr,
95+
fast_handler,
96+
)
97+
.unwrap()
98+
.load(),
9699
);
97100
}
98101
}
99102

100-
#[repr(transparent)]
101-
struct StackRef(&'static mut Stack);
102-
103-
impl AsRef<[u8]> for StackRef {
104-
#[inline]
105-
fn as_ref(&self) -> &[u8] {
106-
&self.0 .0[size_of::<HartContext>()..]
107-
}
108-
}
109-
110-
impl AsMut<[u8]> for StackRef {
111-
#[inline]
112-
fn as_mut(&mut self) -> &mut [u8] {
113-
&mut self.0 .0[size_of::<HartContext>()..]
114-
}
115-
}
116-
117-
impl TrapStackBlock for StackRef {}
118-
119-
impl Drop for StackRef {
120-
fn drop(&mut self) {
121-
panic!("Root stack cannot be dropped")
122-
}
123-
}
124-
125103
/// 硬件线程上下文。
126104
struct HartContext {
127105
/// 陷入上下文。

test-kernel/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ publish = false
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11-
sbi-testing = { version = "0.0.1", features = ["log"] }
11+
sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "7a5e920", features = [
12+
"log",
13+
] }
1214
log = "0.4.17"
1315
riscv = "0.10.1"
1416
spin = "0.9"

0 commit comments

Comments
 (0)