Skip to content

Commit c61a3f9

Browse files
committed
Relaxe Sized requirement for Mapper::map_to
This makes it possible to use the method with trait objects. Resolves rust-osdev/acpi#78
1 parent aad1e2e commit c61a3f9

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/structures/paging/mapper/mapped_page_table.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
5353
allocator: &mut A,
5454
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
5555
where
56-
A: FrameAllocator<Size4KiB>,
56+
A: FrameAllocator<Size4KiB> + ?Sized,
5757
{
5858
let p4 = &mut self.level_4_table;
5959
let p3 = self.page_table_walker.create_next_table(
@@ -81,7 +81,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
8181
allocator: &mut A,
8282
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
8383
where
84-
A: FrameAllocator<Size4KiB>,
84+
A: FrameAllocator<Size4KiB> + ?Sized,
8585
{
8686
let p4 = &mut self.level_4_table;
8787
let p3 = self.page_table_walker.create_next_table(
@@ -114,7 +114,7 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
114114
allocator: &mut A,
115115
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
116116
where
117-
A: FrameAllocator<Size4KiB>,
117+
A: FrameAllocator<Size4KiB> + ?Sized,
118118
{
119119
let p4 = &mut self.level_4_table;
120120
let p3 = self.page_table_walker.create_next_table(
@@ -153,7 +153,7 @@ impl<'a, P: PhysToVirt> Mapper<Size1GiB> for MappedPageTable<'a, P> {
153153
allocator: &mut A,
154154
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
155155
where
156-
A: FrameAllocator<Size4KiB>,
156+
A: FrameAllocator<Size4KiB> + ?Sized,
157157
{
158158
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
159159
}
@@ -261,7 +261,7 @@ impl<'a, P: PhysToVirt> Mapper<Size2MiB> for MappedPageTable<'a, P> {
261261
allocator: &mut A,
262262
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
263263
where
264-
A: FrameAllocator<Size4KiB>,
264+
A: FrameAllocator<Size4KiB> + ?Sized,
265265
{
266266
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
267267
}
@@ -389,7 +389,7 @@ impl<'a, P: PhysToVirt> Mapper<Size4KiB> for MappedPageTable<'a, P> {
389389
allocator: &mut A,
390390
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
391391
where
392-
A: FrameAllocator<Size4KiB>,
392+
A: FrameAllocator<Size4KiB> + ?Sized,
393393
{
394394
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
395395
}
@@ -626,7 +626,7 @@ impl<P: PhysToVirt> PageTableWalker<P> {
626626
allocator: &mut A,
627627
) -> Result<&'b mut PageTable, PageTableCreateError>
628628
where
629-
A: FrameAllocator<Size4KiB>,
629+
A: FrameAllocator<Size4KiB> + ?Sized,
630630
{
631631
let created;
632632

src/structures/paging/mapper/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub trait Mapper<S: PageSize> {
158158
) -> Result<MapperFlush<S>, MapToError<S>>
159159
where
160160
Self: Sized,
161-
A: FrameAllocator<Size4KiB>,
161+
A: FrameAllocator<Size4KiB> + ?Sized,
162162
{
163163
let parent_table_flags = flags
164164
& (PageTableFlags::PRESENT
@@ -248,7 +248,7 @@ pub trait Mapper<S: PageSize> {
248248
) -> Result<MapperFlush<S>, MapToError<S>>
249249
where
250250
Self: Sized,
251-
A: FrameAllocator<Size4KiB>;
251+
A: FrameAllocator<Size4KiB> + ?Sized;
252252

253253
/// Removes a mapping from the page table and returns the frame that used to be mapped.
254254
///
@@ -336,7 +336,7 @@ pub trait Mapper<S: PageSize> {
336336
) -> Result<MapperFlush<S>, MapToError<S>>
337337
where
338338
Self: Sized,
339-
A: FrameAllocator<Size4KiB>,
339+
A: FrameAllocator<Size4KiB> + ?Sized,
340340
S: PageSize,
341341
Self: Mapper<S>,
342342
{

src/structures/paging/mapper/offset_page_table.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
7070
allocator: &mut A,
7171
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
7272
where
73-
A: FrameAllocator<Size4KiB>,
73+
A: FrameAllocator<Size4KiB> + ?Sized,
7474
{
7575
self.inner
7676
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
@@ -137,7 +137,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
137137
allocator: &mut A,
138138
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
139139
where
140-
A: FrameAllocator<Size4KiB>,
140+
A: FrameAllocator<Size4KiB> + ?Sized,
141141
{
142142
self.inner
143143
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
@@ -204,7 +204,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
204204
allocator: &mut A,
205205
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
206206
where
207-
A: FrameAllocator<Size4KiB>,
207+
A: FrameAllocator<Size4KiB> + ?Sized,
208208
{
209209
self.inner
210210
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)

src/structures/paging/mapper/recursive_page_table.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a> RecursivePageTable<'a> {
108108
allocator: &mut A,
109109
) -> Result<&'b mut PageTable, MapToError<S>>
110110
where
111-
A: FrameAllocator<Size4KiB>,
111+
A: FrameAllocator<Size4KiB> + ?Sized,
112112
{
113113
/// This inner function is used to limit the scope of `unsafe`.
114114
///
@@ -120,7 +120,7 @@ impl<'a> RecursivePageTable<'a> {
120120
allocator: &mut A,
121121
) -> Result<&'b mut PageTable, MapToError<S>>
122122
where
123-
A: FrameAllocator<Size4KiB>,
123+
A: FrameAllocator<Size4KiB> + ?Sized,
124124
{
125125
use crate::structures::paging::PageTableFlags as Flags;
126126

@@ -165,7 +165,7 @@ impl<'a> RecursivePageTable<'a> {
165165
allocator: &mut A,
166166
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
167167
where
168-
A: FrameAllocator<Size4KiB>,
168+
A: FrameAllocator<Size4KiB> + ?Sized,
169169
{
170170
use crate::structures::paging::PageTableFlags as Flags;
171171
let p4 = &mut self.p4;
@@ -199,7 +199,7 @@ impl<'a> RecursivePageTable<'a> {
199199
allocator: &mut A,
200200
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
201201
where
202-
A: FrameAllocator<Size4KiB>,
202+
A: FrameAllocator<Size4KiB> + ?Sized,
203203
{
204204
use crate::structures::paging::PageTableFlags as Flags;
205205
let p4 = &mut self.p4;
@@ -243,7 +243,7 @@ impl<'a> RecursivePageTable<'a> {
243243
allocator: &mut A,
244244
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
245245
where
246-
A: FrameAllocator<Size4KiB>,
246+
A: FrameAllocator<Size4KiB> + ?Sized,
247247
{
248248
let p4 = &mut self.p4;
249249

@@ -297,7 +297,7 @@ impl<'a> Mapper<Size1GiB> for RecursivePageTable<'a> {
297297
allocator: &mut A,
298298
) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>
299299
where
300-
A: FrameAllocator<Size4KiB>,
300+
A: FrameAllocator<Size4KiB> + ?Sized,
301301
{
302302
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
303303
}
@@ -419,7 +419,7 @@ impl<'a> Mapper<Size2MiB> for RecursivePageTable<'a> {
419419
allocator: &mut A,
420420
) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>
421421
where
422-
A: FrameAllocator<Size4KiB>,
422+
A: FrameAllocator<Size4KiB> + ?Sized,
423423
{
424424
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
425425
}
@@ -576,7 +576,7 @@ impl<'a> Mapper<Size4KiB> for RecursivePageTable<'a> {
576576
allocator: &mut A,
577577
) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>
578578
where
579-
A: FrameAllocator<Size4KiB>,
579+
A: FrameAllocator<Size4KiB> + ?Sized,
580580
{
581581
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
582582
}

0 commit comments

Comments
 (0)