Skip to content

Commit

Permalink
Merge pull request #204 from rust-osdev/mapper_unsized
Browse files Browse the repository at this point in the history
Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to`
  • Loading branch information
phil-opp authored Dec 28, 2020
2 parents 5b0eac1 + 9a8d1dc commit f316ad4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- **Breaking:** Also return flags for `MapperAllSizes::translate()` ([#207](https://github.com/rust-osdev/x86_64/pull/207))
- Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to` ([204](https://github.com/rust-osdev/x86_64/pull/204))

# 0.12.3 – 2020-10-31

Expand Down
14 changes: 7 additions & 7 deletions src/structures/paging/mapper/mapped_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let p4 = &mut self.level_4_table;
let p3 = self.page_table_walker.create_next_table(
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let p4 = &mut self.level_4_table;
let p3 = self.page_table_walker.create_next_table(
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let p4 = &mut self.level_4_table;
let p3 = self.page_table_walker.create_next_table(
Expand Down Expand Up @@ -153,7 +153,7 @@ impl<'a, P: PhysToVirt> Mapper<Size1GiB> for MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<'a, P: PhysToVirt> Mapper<Size2MiB> for MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down Expand Up @@ -389,7 +389,7 @@ impl<'a, P: PhysToVirt> Mapper<Size4KiB> for MappedPageTable<'a, P> {
allocator: &mut A,
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down Expand Up @@ -643,7 +643,7 @@ impl<P: PhysToVirt> PageTableWalker<P> {
allocator: &mut A,
) -> Result<&'b mut PageTable, PageTableCreateError>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let created;

Expand Down
6 changes: 3 additions & 3 deletions src/structures/paging/mapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub trait Mapper<S: PageSize> {
) -> Result<MapperFlush<S>, MapToError<S>>
where
Self: Sized,
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let parent_table_flags = flags
& (PageTableFlags::PRESENT
Expand Down Expand Up @@ -260,7 +260,7 @@ pub trait Mapper<S: PageSize> {
) -> Result<MapperFlush<S>, MapToError<S>>
where
Self: Sized,
A: FrameAllocator<Size4KiB>;
A: FrameAllocator<Size4KiB> + ?Sized;

/// Removes a mapping from the page table and returns the frame that used to be mapped.
///
Expand Down Expand Up @@ -348,7 +348,7 @@ pub trait Mapper<S: PageSize> {
) -> Result<MapperFlush<S>, MapToError<S>>
where
Self: Sized,
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
S: PageSize,
Self: Mapper<S>,
{
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 @@ -70,7 +70,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.inner
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.inner
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
Expand Down Expand Up @@ -204,7 +204,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.inner
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
Expand Down
16 changes: 8 additions & 8 deletions src/structures/paging/mapper/recursive_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'a> RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<&'b mut PageTable, MapToError<S>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
/// This inner function is used to limit the scope of `unsafe`.
///
Expand All @@ -120,7 +120,7 @@ impl<'a> RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<&'b mut PageTable, MapToError<S>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
use crate::structures::paging::PageTableFlags as Flags;

Expand Down Expand Up @@ -165,7 +165,7 @@ impl<'a> RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
use crate::structures::paging::PageTableFlags as Flags;
let p4 = &mut self.p4;
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
use crate::structures::paging::PageTableFlags as Flags;
let p4 = &mut self.p4;
Expand Down Expand Up @@ -243,7 +243,7 @@ impl<'a> RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
let p4 = &mut self.p4;

Expand Down Expand Up @@ -297,7 +297,7 @@ impl<'a> Mapper<Size1GiB> for RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down Expand Up @@ -419,7 +419,7 @@ impl<'a> Mapper<Size2MiB> for RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down Expand Up @@ -576,7 +576,7 @@ impl<'a> Mapper<Size4KiB> for RecursivePageTable<'a> {
allocator: &mut A,
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
where
A: FrameAllocator<Size4KiB>,
A: FrameAllocator<Size4KiB> + ?Sized,
{
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
}
Expand Down

0 comments on commit f316ad4

Please sign in to comment.