Skip to content

Commit

Permalink
Relaxe Sized requirement for Mapper::map_to
Browse files Browse the repository at this point in the history
This makes it possible to use the method with trait objects.

Resolves rust-osdev/acpi#78
  • Loading branch information
phil-opp committed Dec 28, 2020
1 parent 38f1c7d commit 469fb2c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
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 @@ -626,7 +626,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 @@ -158,7 +158,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 @@ -248,7 +248,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 @@ -336,7 +336,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 469fb2c

Please sign in to comment.