Skip to content

Commit 110f6ae

Browse files
committed
very small fixes
1 parent f39cce9 commit 110f6ae

6 files changed

Lines changed: 21 additions & 16 deletions

File tree

beskar-lib/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn __init() {
8585
pub fn debug_break() {
8686
#[cfg(debug_assertions)]
8787
unsafe {
88-
core::arch::asm!("int3");
88+
core::arch::asm!("int3", options(nomem, nostack, preserves_flags));
8989
}
9090
}
9191

@@ -96,6 +96,6 @@ pub fn debug_break() {
9696
pub fn debug_break_value(x: u64) {
9797
#[cfg(debug_assertions)]
9898
unsafe {
99-
core::arch::asm!("int3", in("rax") x);
99+
core::arch::asm!("int3", in("rax") x, options(nomem, nostack, preserves_flags));
100100
}
101101
}

hyperdrive/src/locks/mcs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! The second one being a wrapper around the first one that allows to safely lock a `MaybeUninit` value.
1010
//!
1111
//! These structure accept a generic type `T` that is the type of the data protected by the lock.
12-
//! The second generic type `B` is the back-off strategy used by the lock.
12+
//! The second generic type `R` is the relax strategy used by the lock.
1313
//!
1414
//! ### `McsLock`
1515
//!
@@ -109,8 +109,8 @@ use core::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
109109
pub struct McsLock<T: ?Sized, R: RelaxStrategy = Spin> {
110110
/// Tail of the queue.
111111
tail: AtomicPtr<McsNode>,
112-
/// Back-off strategy.
113-
_back_off: PhantomData<R>,
112+
/// Relax strategy.
113+
_relax: PhantomData<R>,
114114
/// Data protected by the lock.
115115
data: UnsafeCell<T>,
116116
}
@@ -163,7 +163,7 @@ impl<T, R: RelaxStrategy> McsLock<T, R> {
163163
Self {
164164
tail: AtomicPtr::new(ptr::null_mut()),
165165
data: UnsafeCell::new(value),
166-
_back_off: PhantomData,
166+
_relax: PhantomData,
167167
}
168168
}
169169

hyperdrive/src/locks/rw.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! It is an evolution of the spinlock, where multiple readers can access the data at the same time.
55
//!
66
//! The structure accept a generic type `T` that is the type of the data protected by the lock.
7-
//! The second generic type `B` is the back-off strategy used by the lock.
7+
//! The second generic type `R` is the relax strategy used by the lock.
88
//!
99
//! ## Starvation-Resistance
1010
//!
@@ -154,8 +154,8 @@ struct AtomicState<R: RelaxStrategy = Spin> {
154154
readers: AtomicU32,
155155
/// Whether a writer has acquired the lock.
156156
writer: AtomicBool,
157-
/// Back-off strategy.
158-
_back_off: PhantomData<R>,
157+
/// Relax strategy.
158+
_relax: PhantomData<R>,
159159
}
160160

161161
unsafe impl<R: RelaxStrategy> Send for AtomicState<R> {}
@@ -167,7 +167,7 @@ impl<R: RelaxStrategy> AtomicState<R> {
167167
Self {
168168
readers: AtomicU32::new(0),
169169
writer: AtomicBool::new(false),
170-
_back_off: PhantomData,
170+
_relax: PhantomData,
171171
}
172172
}
173173

hyperdrive/src/locks/ticket.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub struct TicketLock<T: ?Sized, R: RelaxStrategy = super::Spin> {
3838
next_ticket: AtomicU32,
3939
/// The ticket number of the current thread holding the lock.
4040
now_serving: AtomicU32,
41-
/// The back-off strategy to use when the lock is contended.
42-
_back_off: PhantomData<R>,
41+
/// The relax strategy to use when the lock is contended.
42+
_relax: PhantomData<R>,
4343
/// The inner data protected by the lock.
4444
data: UnsafeCell<T>,
4545
}
@@ -58,7 +58,7 @@ impl<T, R: RelaxStrategy> TicketLock<T, R> {
5858
next_ticket: AtomicU32::new(0),
5959
now_serving: AtomicU32::new(0),
6060
data: UnsafeCell::new(data),
61-
_back_off: PhantomData,
61+
_relax: PhantomData,
6262
}
6363
}
6464

kernel/src/drivers/storage/nvme.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,11 @@ impl Status {
620620

621621
// TODO: Implement the rest of the fields
622622
}
623+
624+
#[inline]
625+
pub fn with_nvme_controller<F, R>(f: F) -> Option<R>
626+
where
627+
F: FnOnce(&mut NvmeControllers) -> R,
628+
{
629+
NVME_CONTROLLER.with_locked_if_init(f)
630+
}

kernel/src/storage.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ pub fn init() {
2929
);
3030
device_fs.add_device(PathBuf::new("/fb"), Box::new(video::screen::ScreenDevice));
3131
VFS.mount(PathBuf::new("/dev"), Box::new(device_fs));
32-
33-
// TODO: Mount RAM disk (FAT32)
34-
// VFS.mount(PathBuf::new("/ramdisk"), todo!());
3532
}
3633

3734
#[must_use]

0 commit comments

Comments
 (0)