Skip to content

Commit

Permalink
make map_range_with_table_flags and map_range unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Sep 5, 2021
1 parent c1f380e commit 7a00802
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/structures/paging/mapper/mapped_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size1GiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -801,7 +801,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size2MiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -1024,7 +1024,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size4KiB>,
flags: PageTableFlags,
Expand Down
14 changes: 12 additions & 2 deletions src/structures/paging/mapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,15 @@ pub trait Mapper<S: PageSize> {

/// Maps frames from the allocator to the given range of virtual pages.
///
/// ## Safety
///
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
/// all safety requirements of it also apply for this function.
///
/// ## Errors
///
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
mut pages: PageRange<S>,
flags: PageTableFlags,
Expand Down Expand Up @@ -419,11 +424,16 @@ pub trait Mapper<S: PageSize> {

/// Maps frames from the allocator to the given range of virtual pages.
///
/// ## Safety
///
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
/// all safety requirements of it also apply for this function.
///
/// ## Errors
///
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
#[inline]
fn map_range<A>(
unsafe fn map_range<A>(
&mut self,
pages: PageRange<S>,
flags: PageTableFlags,
Expand Down
6 changes: 3 additions & 3 deletions src/structures/paging/mapper/offset_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size1GiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -214,7 +214,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size2MiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -331,7 +331,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size4KiB>,
flags: PageTableFlags,
Expand Down
6 changes: 3 additions & 3 deletions src/structures/paging/mapper/recursive_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ impl<'a> Mapper<Size1GiB> for RecursivePageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size1GiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -984,7 +984,7 @@ impl<'a> Mapper<Size2MiB> for RecursivePageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size2MiB>,
flags: PageTableFlags,
Expand Down Expand Up @@ -1236,7 +1236,7 @@ impl<'a> Mapper<Size4KiB> for RecursivePageTable<'a> {
}

#[inline]
fn map_range_with_table_flags<A>(
unsafe fn map_range_with_table_flags<A>(
&mut self,
pages: PageRange<Size4KiB>,
flags: PageTableFlags,
Expand Down

0 comments on commit 7a00802

Please sign in to comment.