diff --git a/src/call.rs b/src/call.rs index 807b9491b9..ccb51aa82a 100644 --- a/src/call.rs +++ b/src/call.rs @@ -205,56 +205,6 @@ pub fn open>(path: T, flags: usize) -> Result { unsafe { syscall3(SYS_OPEN, path.as_ref().as_ptr() as usize, path.as_ref().len(), flags) } } -/// Allocate frames, linearly in physical memory. -/// -/// # Errors -/// -/// * `EPERM` - `uid != 0` -/// * `ENOMEM` - the system has run out of available memory -pub unsafe fn physalloc(size: usize) -> Result { - syscall1(SYS_PHYSALLOC, size) -} - -/// Allocate frames, linearly in physical memory, with an extra set of flags. If the flags contain -/// [`PARTIAL_ALLOC`], this will result in `physalloc3` with `min = 1`. -/// -/// Refer to the simpler [`physalloc`] and the more complex [`physalloc3`], that this convenience -/// function is based on. -/// -/// # Errors -/// -/// * `EPERM` - `uid != 0` -/// * `ENOMEM` - the system has run out of available memory -pub unsafe fn physalloc2(size: usize, flags: usize) -> Result { - let mut ret = 1usize; - physalloc3(size, flags, &mut ret) -} - -/// Allocate frames, linearly in physical memory, with an extra set of flags. If the flags contain -/// [`PARTIAL_ALLOC`], the `min` parameter specifies the number of frames that have to be allocated -/// for this operation to succeed. The return value is the offset of the first frame, and `min` is -/// overwritten with the number of frames actually allocated. -/// -/// Refer to the simpler [`physalloc`] and the simpler library function [`physalloc2`]. -/// -/// # Errors -/// -/// * `EPERM` - `uid != 0` -/// * `ENOMEM` - the system has run out of available memory -/// * `EINVAL` - `min = 0` -pub unsafe fn physalloc3(size: usize, flags: usize, min: &mut usize) -> Result { - syscall3(SYS_PHYSALLOC3, size, flags, min as *mut usize as usize) -} - -/// Free physically allocated pages -/// -/// # Errors -/// -/// * `EPERM` - `uid != 0` -pub unsafe fn physfree(physical_address: usize, size: usize) -> Result { - syscall2(SYS_PHYSFREE, physical_address, size) -} - /// Map physical memory to virtual memory /// /// # Errors diff --git a/src/flag.rs b/src/flag.rs index fa65952138..40b41ff387 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -173,71 +173,6 @@ bitflags! { const PHYSMAP_NO_CACHE = 0x0000_0004; } } -bitflags! { - /// Extra flags for [`physalloc2`] or [`physalloc3`]. - /// - /// [`physalloc2`]: ../call/fn.physalloc2.html - /// [`physalloc3`]: ../call/fn.physalloc3.html - pub struct PhysallocFlags: usize { - /// Only allocate memory within the 32-bit physical memory space. This is necessary for - /// some devices may not support 64-bit memory. - const SPACE_32 = 0x0000_0001; - - /// The frame that will be allocated, is going to reside anywhere in 64-bit space. This - /// flag is redundant for the most part, except when overriding some other default. - const SPACE_64 = 0x0000_0002; - - /// Do a "partial allocation", which means that not all of the frames specified in the - /// frame count `size` actually have to be allocated. This means that if the allocator was - /// unable to find a physical memory range large enough, it can instead return whatever - /// range it decides is optimal. Thus, instead of letting one driver get an expensive - /// 128MiB physical memory range when the physical memory has become fragmented, and - /// failing, it can instead be given a more optimal range. If the device supports - /// scatter-gather lists, then the driver only has to allocate more ranges, and the device - /// will do vectored I/O. - /// - /// PARTIAL_ALLOC supports different allocation strategies, refer to - /// [`Optimal`], [`GreatestRange`]. - /// - /// [`Optimal`]: ./enum.PartialAllocStrategy.html - /// [`GreatestRange`]: ./enum.PartialAllocStrategy.html - const PARTIAL_ALLOC = 0x0000_0004; - } -} - -/// The bitmask of the partial allocation strategy. Currently four different strategies are -/// supported. If [`PARTIAL_ALLOC`] is not set, this bitmask is no longer reserved. -pub const PARTIAL_ALLOC_STRATEGY_MASK: usize = 0x0003_0000; - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -#[repr(usize)] -pub enum PartialAllocStrategy { - /// The allocator decides itself the size of the memory range, based on e.g. free memory ranges - /// and other processes which require large physical memory chunks. - Optimal = 0x0001_0000, - - /// The allocator returns the absolute greatest range it can find. - GreatestRange = 0x0002_0000, - - /// The allocator returns the first range that fits the minimum count, without searching extra. - Greedy = 0x0003_0000, -} -impl Default for PartialAllocStrategy { - fn default() -> Self { - Self::Optimal - } -} - -impl PartialAllocStrategy { - pub fn from_raw(raw: usize) -> Option { - match raw { - 0x0001_0000 => Some(Self::Optimal), - 0x0002_0000 => Some(Self::GreatestRange), - 0x0003_0000 => Some(Self::Greedy), - _ => None, - } - } -} // The top 48 bits of PTRACE_* are reserved, for now diff --git a/src/number.rs b/src/number.rs index ea956fc0c1..c22cdc306a 100644 --- a/src/number.rs +++ b/src/number.rs @@ -74,9 +74,6 @@ pub const SYS_KILL: usize = 37; pub const SYS_MPROTECT: usize = 125; pub const SYS_MKNS: usize = 984; pub const SYS_NANOSLEEP: usize =162; -pub const SYS_PHYSALLOC: usize =945; -pub const SYS_PHYSALLOC3: usize=9453; -pub const SYS_PHYSFREE: usize = 946; pub const SYS_PHYSMAP: usize = 947; pub const SYS_VIRTTOPHYS: usize=949; pub const SYS_SETPGID: usize = 57;