Remove the sole usage of the const_option feature

This commit is contained in:
bjorn3
2023-12-12 20:35:30 +01:00
committed by Jeremy Soller
parent 82a87be7d5
commit 2aea52a94b
3 changed files with 4 additions and 27 deletions
-1
View File
@@ -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)]
-25
View File
@@ -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::<PageInfo>().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<u8>, layout: core::alloc::Layout) {
unreachable!();
}
// TODO: Allow zeroing out frames to be optional in RMM?
fn allocate_zeroed(&self, layout: core::alloc::Layout) -> Result<NonNull<[u8]>, 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::ptr::NonNull<[u8]>, core::alloc::AllocError> {
self.allocate_zeroed(layout)
}
}
#[cold]
fn init_sections() {
let mut guard = SECTIONS.write();
+4 -1
View File
@@ -54,7 +54,10 @@ pub enum Response {
Fd(Arc<RwLock<FileDescription>>),
}
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<str>, flags: usize, context: Weak<RwLock<Context>>) -> UserInner {