diff --git a/kernel/src/sync.rs b/kernel/src/sync.rs index 01e9eb1..8946c3b 100644 --- a/kernel/src/sync.rs +++ b/kernel/src/sync.rs @@ -4,27 +4,12 @@ use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut}; use crate::arch::platform::{irq_mask_save, irq_restore}; -/// Dummy lock implementation, does not do any locking. -/// -/// Only safe to use before I implement context switching or -/// interrupts are enabled. -#[repr(transparent)] -pub struct NullLock { - value: UnsafeCell, -} - /// Same as [NullLock], but ensures IRQs are disabled while /// the lock is held pub struct IrqSafeNullLock { value: UnsafeCell, } -/// Dummy lock guard for [NullLock] -#[repr(transparent)] -pub struct NullLockGuard<'a, T: ?Sized> { - value: &'a mut T, -} - /// Same as [NullLockGuard], but reverts IRQ mask back to normal /// when dropped pub struct IrqSafeNullLockGuard<'a, T: ?Sized> { @@ -76,39 +61,4 @@ impl Drop for IrqSafeNullLockGuard<'_, T> { } } -impl NullLock { - /// Constructs a new instance of the lock, wrapping `value` - #[inline(always)] - pub const fn new(value: T) -> Self { - Self { - value: UnsafeCell::new(value), - } - } - - /// Returns [NullLockGuard] for this lock - #[inline(always)] - pub fn lock(&self) -> NullLockGuard { - NullLockGuard { - value: unsafe { &mut *self.value.get() }, - } - } -} - -impl Deref for NullLockGuard<'_, T> { - type Target = T; - - fn deref(&self) -> &Self::Target { - self.value - } -} - -impl DerefMut for NullLockGuard<'_, T> { - fn deref_mut(&mut self) -> &mut Self::Target { - self.value - } -} - -unsafe impl Sync for NullLock {} unsafe impl Sync for IrqSafeNullLock {} - -pub use IrqSafeNullLock as Spin;