diff --git a/src/main.rs b/src/main.rs index ccfcf793df..f2ffd9b542 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,6 @@ #![feature(allocator_api)] #![feature(asm_const)] // TODO: Relax requirements of most asm invocations -#![feature(const_option)] #![feature(const_refs_to_cell)] #![feature(int_roundings)] #![feature(let_chains)] diff --git a/src/memory/mod.rs b/src/memory/mod.rs index 3f39908efc..d2cd33c014 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -2,7 +2,6 @@ //! Some code was borrowed from [Phil Opp's Blog](http://os.phil-opp.com/allocating-frames.html) use core::cell::SyncUnsafeCell; -use core::ptr::NonNull; use core::{cmp, mem}; use core::num::NonZeroUsize; use core::sync::atomic::{AtomicUsize, Ordering}; @@ -232,30 +231,6 @@ const _: () = { assert!(mem::size_of::().is_power_of_two()); }; -/// Allocator that bypasses the kernel heap, instead allocating directly from physical memory. -pub struct DirectAllocator; - -unsafe impl core::alloc::Allocator for DirectAllocator { - unsafe fn deallocate(&self, ptr: core::ptr::NonNull, layout: core::alloc::Layout) { - unreachable!(); - } - // TODO: Allow zeroing out frames to be optional in RMM? - fn allocate_zeroed(&self, layout: core::alloc::Layout) -> Result, core::alloc::AllocError> { - assert!(layout.align() <= PAGE_SIZE); - - let phys = allocate_frames(layout.size().div_ceil(PAGE_SIZE)).ok_or(core::alloc::AllocError)?; - - Ok(unsafe { - let virt = RmmA::phys_to_virt(phys.start_address()).data() as *mut u8; - - NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(virt as *mut u8, layout.size())) - }) - } - fn allocate(&self, layout: core::alloc::Layout) -> Result, core::alloc::AllocError> { - self.allocate_zeroed(layout) - } -} - #[cold] fn init_sections() { let mut guard = SECTIONS.write(); diff --git a/src/scheme/user.rs b/src/scheme/user.rs index 9aeb73ec06..80ebdb8dbc 100644 --- a/src/scheme/user.rs +++ b/src/scheme/user.rs @@ -54,7 +54,10 @@ pub enum Response { Fd(Arc>), } -const ONE: NonZeroUsize = NonZeroUsize::new(1).unwrap(); +const ONE: NonZeroUsize = match NonZeroUsize::new(1) { + Some(one) => one, + None => unreachable!(), +}; impl UserInner { pub fn new(root_id: SchemeId, scheme_id: SchemeId, handle_id: usize, name: Box, flags: usize, context: Weak>) -> UserInner {