Next Generation WASM Microkernel Operating System

refactor: separate memory subsystem into own crate #1

open opened by jonaskruckenberg.de targeting main from jonas/refactor/mem
Labels

None yet.

Participants 1
AT URI
at://did:plc:wur5mmsnhlocanyqtus3oex5/sh.tangled.repo.pull/3lwbnsqcrd622
+23 -28
Interdiff #2 โ†’ #3
Cargo.lock

This file has not been changed.

libs/mem/Cargo.toml

This file has not been changed.

libs/mem/proptest-regressions/frame.txt

This file has not been changed.

+1 -1
libs/mem/src/access_rules.rs
··· 66 66 fn into_bits(self) -> u8 { 67 67 self as u8 68 68 } 69 - } 69 + }
+3 -4
libs/mem/src/address_space.rs
··· 14 14 use core::ops::{Bound, ControlFlow, Range}; 15 15 use core::ptr::NonNull; 16 16 17 - use anyhow::{format_err, Context}; 18 - use rand::distr::Uniform; 17 + use anyhow::{Context, format_err}; 18 + pub(crate) use batch::Batch; 19 19 use rand::Rng; 20 + use rand::distr::Uniform; 20 21 use rand_chacha::ChaCha20Rng; 21 22 use region::AddressSpaceRegion; 22 23 use wavltree::{CursorMut, WAVLTree}; ··· 24 25 use crate::access_rules::AccessRules; 25 26 use crate::utils::assert_unsafe_precondition_; 26 27 use crate::{AddressRangeExt, PhysicalAddress, VirtualAddress}; 27 - 28 - pub(crate) use batch::Batch; 29 28 30 29 pub unsafe trait RawAddressSpace { 31 30 /// The smallest addressable chunk of memory of this address space. All address argument provided
+2 -13
libs/mem/src/address_space/batch.rs
··· 173 173 // Safety: the caller promised the correctness of the values on construction of 174 174 // the operation. 175 175 unsafe { 176 - raw_aspace.map( 177 - op.virt, 178 - op.phys, 179 - op.len, 180 - op.access_rules, 181 - &mut flush, 182 - )?; 176 + raw_aspace.map(op.virt, op.phys, op.len, op.access_rules, &mut flush)?; 183 177 } 184 178 } 185 179 BatchOperation::Unmap(op) => { ··· 199 193 // Safety: the caller promised the correctness of the values on construction of 200 194 // the operation. 201 195 unsafe { 202 - raw_aspace.set_access_rules( 203 - op.virt, 204 - op.len, 205 - op.access_rules, 206 - &mut flush, 207 - ); 196 + raw_aspace.set_access_rules(op.virt, op.len, op.access_rules, &mut flush); 208 197 } 209 198 } 210 199 };
+8 -4
libs/mem/src/address_space/region.rs
··· 114 114 range: impl RangeBounds<VirtualAddress>, 115 115 access_rules: AccessRules, 116 116 batch: &mut Batch, 117 - raw_aspace: &mut R 117 + raw_aspace: &mut R, 118 118 ) -> crate::Result<()> { 119 119 let vmo_relative = self.bounds_to_vmo_relative(range); 120 120 ··· 159 159 &self, 160 160 range: impl RangeBounds<VirtualAddress>, 161 161 batch: &mut Batch, 162 - raw_aspace: &mut R 162 + raw_aspace: &mut R, 163 163 ) -> crate::Result<()> { 164 164 let vmo_relative = self.bounds_to_vmo_relative(range); 165 165 ··· 193 193 } 194 194 195 195 /// Update the access rules of this `AddressSpaceRegion`. 196 - pub fn update_access_rules(&mut self, access_rules: AccessRules, batch: &mut Batch) -> crate::Result<()> { 196 + pub fn update_access_rules( 197 + &mut self, 198 + access_rules: AccessRules, 199 + batch: &mut Batch, 200 + ) -> crate::Result<()> { 197 201 todo!() 198 202 } 199 203 ··· 304 308 // self.vmo.decommit(bounds, batch) 305 309 // } 306 310 // 307 - // /// updates the access rules fo this region 311 + // /// updates the access rules of this region 308 312 // pub fn update_access_rules( 309 313 // &mut self, 310 314 // access_rules: AccessRules,
libs/mem/src/addresses.rs

This file has not been changed.

+2 -2
libs/mem/src/frame.rs
··· 15 15 use core::sync::atomic; 16 16 use core::sync::atomic::{AtomicUsize, Ordering}; 17 17 18 - use cordyceps::{list, Linked}; 18 + use cordyceps::{Linked, list}; 19 19 use pin_project::pin_project; 20 20 21 - use crate::frame_alloc::FrameAllocator; 22 21 use crate::PhysicalAddress; 22 + use crate::frame_alloc::FrameAllocator; 23 23 24 24 /// Soft limit on the amount of references that may be made to a `Frame`. 25 25 const MAX_REFCOUNT: usize = isize::MAX as usize;
libs/mem/src/frame_alloc.rs

This file has not been changed.

libs/mem/src/frame_alloc/area.rs

This file has not been changed.

libs/mem/src/frame_alloc/area_selection.rs

This file has not been changed.

+1 -1
libs/mem/src/lib.rs
··· 6 6 mod addresses; 7 7 mod frame; 8 8 pub mod frame_alloc; 9 + #[cfg(test)] 9 10 mod test_utils; 10 11 mod utils; 11 12 mod vmo; ··· 15 16 pub use access_rules::{AccessRules, WriteOrExecute}; 16 17 pub use addresses::{AddressRangeExt, PhysicalAddress, VirtualAddress}; 17 18 pub use frame::{Frame, FrameRef}; 18 -
+4 -2
libs/mem/src/test_utils.rs
··· 58 58 } 59 59 } 60 60 61 - unsafe impl<const PAGE_SIZE: usize, const ADDR_BITS: u32> RawAddressSpace for TestAddressSpace<PAGE_SIZE, ADDR_BITS> { 61 + unsafe impl<const PAGE_SIZE: usize, const ADDR_BITS: u32> RawAddressSpace 62 + for TestAddressSpace<PAGE_SIZE, ADDR_BITS> 63 + { 62 64 const PAGE_SIZE: usize = PAGE_SIZE; 63 65 const VIRT_ADDR_BITS: u32 = ADDR_BITS; 64 66 ··· 166 168 fn flush(self) -> crate::Result<()> { 167 169 Ok(()) 168 170 } 169 - } 171 + }
+1 -1
libs/mem/src/utils.rs
··· 28 28 } 29 29 }; 30 30 } 31 - pub(crate) use assert_unsafe_precondition_; 31 + pub(crate) use assert_unsafe_precondition_;
+1
libs/mem/src/vmo.rs
··· 13 13 use fallible_iterator::FallibleIterator; 14 14 use lock_api::RwLock; 15 15 use smallvec::SmallVec; 16 + 16 17 use crate::frame_list::FrameList; 17 18 use crate::{FrameRef, PhysicalAddress}; 18 19
libs/wavltree/src/cursor.rs

This file has not been changed.

libs/wavltree/src/lib.rs

This file has not been changed.

History

5 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
refactor: separate memory subsystem into own crate
merge conflicts detected
expand
  • Cargo.lock:135
  • libs/wavltree/src/cursor.rs:88
expand 0 comments
1 commit
expand
refactor: separate memory subsystem into own crate
expand 0 comments
1 commit
expand
refactor: separate memory subsystem into own crate
expand 0 comments
1 commit
expand
refactor: separate memory subsystem into own crate
expand 0 comments
1 commit
expand
refactor: separate memory subsystem into own crate
expand 0 comments