Skip to content

Commit 1c6ee58

Browse files
committed
add experimental feature flag
1 parent 2deaefa commit 1c6ee58

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt" ]
4141
inline_asm = []
4242
abi_x86_interrupt = []
4343
const_fn = []
44+
experimental = []
4445

4546
[package.metadata.docs.rs]
4647
rustdoc-args = ["--cfg", "docsrs"]

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#[cfg(feature = "experimental")]
2+
use crate::structures::paging::PageTableIndex;
13
use crate::structures::paging::{
24
frame::PhysFrame,
35
frame_alloc::FrameAllocator,
46
mapper::*,
57
page::{AddressNotAligned, Page, Size1GiB, Size2MiB, Size4KiB},
68
page_table::{FrameError, PageTable, PageTableEntry, PageTableFlags},
7-
PageTableIndex,
89
};
910

1011
/// A Mapper implementation that relies on a PhysAddr to VirtAddr conversion function.
@@ -142,6 +143,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
142143
Ok(MapperFlush::new(page))
143144
}
144145

146+
#[cfg(feature = "experimental")]
145147
#[inline]
146148
fn next_table_fn_create_next_table<'b, A>(
147149
(flags, allocator): &mut (PageTableFlags, &mut A),
@@ -156,6 +158,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
156158
.map_err(Into::into)
157159
}
158160

161+
#[cfg(feature = "experimental")]
159162
#[inline]
160163
fn next_table_fn_next_table_mut<'b, T>(
161164
_: &mut T,
@@ -165,6 +168,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
165168
walker.next_table_mut(entry)
166169
}
167170

171+
#[cfg(feature = "experimental")]
168172
fn modify_range_1gib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
169173
&mut self,
170174
pages: PageRange<Size1GiB>,
@@ -230,6 +234,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
230234
})
231235
}
232236

237+
#[cfg(feature = "experimental")]
233238
#[inline]
234239
fn map_to_range_1gib<F, A>(
235240
&mut self,
@@ -258,6 +263,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
258263
)
259264
}
260265

266+
#[cfg(feature = "experimental")]
261267
fn modify_range_2mib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
262268
&mut self,
263269
pages: PageRange<Size2MiB>,
@@ -360,6 +366,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
360366
})
361367
}
362368

369+
#[cfg(feature = "experimental")]
363370
#[inline]
364371
fn map_to_range_2mib<F, A>(
365372
&mut self,
@@ -388,6 +395,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
388395
)
389396
}
390397

398+
#[cfg(feature = "experimental")]
391399
fn modify_range_4kib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
392400
&mut self,
393401
pages: PageRange<Size4KiB>,
@@ -526,6 +534,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
526534
})
527535
}
528536

537+
#[cfg(feature = "experimental")]
529538
#[inline]
530539
fn map_to_range_4kib<F, A>(
531540
&mut self,
@@ -571,6 +580,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
571580
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
572581
}
573582

583+
#[cfg(feature = "experimental")]
574584
#[inline]
575585
unsafe fn map_to_range_with_table_flags<A>(
576586
&mut self,
@@ -597,6 +607,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
597607
)
598608
}
599609

610+
#[cfg(feature = "experimental")]
600611
#[inline]
601612
unsafe fn map_range_with_table_flags<A>(
602613
&mut self,
@@ -644,6 +655,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
644655
Ok((frame, MapperFlush::new(page)))
645656
}
646657

658+
#[cfg(feature = "experimental")]
647659
#[inline]
648660
unsafe fn unmap_range<D>(
649661
&mut self,
@@ -689,6 +701,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
689701
Ok(MapperFlush::new(page))
690702
}
691703

704+
#[cfg(feature = "experimental")]
692705
#[inline]
693706
unsafe fn update_flags_range(
694707
&mut self,
@@ -774,6 +787,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
774787
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
775788
}
776789

790+
#[cfg(feature = "experimental")]
777791
#[inline]
778792
unsafe fn map_to_range_with_table_flags<A>(
779793
&mut self,
@@ -800,6 +814,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
800814
)
801815
}
802816

817+
#[cfg(feature = "experimental")]
803818
#[inline]
804819
unsafe fn map_range_with_table_flags<A>(
805820
&mut self,
@@ -850,6 +865,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
850865
Ok((frame, MapperFlush::new(page)))
851866
}
852867

868+
#[cfg(feature = "experimental")]
853869
#[inline]
854870
unsafe fn unmap_range<D>(
855871
&mut self,
@@ -899,6 +915,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
899915
Ok(MapperFlush::new(page))
900916
}
901917

918+
#[cfg(feature = "experimental")]
902919
#[inline]
903920
unsafe fn update_flags_range(
904921
&mut self,
@@ -997,6 +1014,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
9971014
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
9981015
}
9991016

1017+
#[cfg(feature = "experimental")]
10001018
#[inline]
10011019
unsafe fn map_to_range_with_table_flags<A>(
10021020
&mut self,
@@ -1023,6 +1041,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10231041
)
10241042
}
10251043

1044+
#[cfg(feature = "experimental")]
10261045
#[inline]
10271046
unsafe fn map_range_with_table_flags<A>(
10281047
&mut self,
@@ -1069,6 +1088,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10691088
Ok((frame, MapperFlush::new(page)))
10701089
}
10711090

1091+
#[cfg(feature = "experimental")]
10721092
#[inline]
10731093
unsafe fn unmap_range<D>(
10741094
&mut self,
@@ -1123,6 +1143,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
11231143
Ok(MapperFlush::new(page))
11241144
}
11251145

1146+
#[cfg(feature = "experimental")]
11261147
#[inline]
11271148
unsafe fn update_flags_range(
11281149
&mut self,

src/structures/paging/mapper/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ pub use self::recursive_page_table::{InvalidPageTable, RecursivePageTable};
88

99
use core::convert::Infallible;
1010

11+
#[cfg(feature = "experimental")]
12+
use crate::structures::paging::{frame::PhysFrameRange, page::PageRange, FrameDeallocator};
1113
use crate::structures::paging::{
12-
frame::PhysFrameRange, frame_alloc::FrameAllocator, page::PageRange,
13-
page_table::PageTableFlags, FrameDeallocator, Page, PageSize, PhysFrame, Size1GiB, Size2MiB,
14-
Size4KiB,
14+
frame_alloc::FrameAllocator, page_table::PageTableFlags, Page, PageSize, PhysFrame, Size1GiB,
15+
Size2MiB, Size4KiB,
1516
};
1617
use crate::{PhysAddr, VirtAddr};
1718

@@ -196,6 +197,7 @@ pub trait Mapper<S: PageSize> {
196197
self.map_to_with_table_flags(page, frame, flags, parent_table_flags, frame_allocator)
197198
}
198199

200+
#[cfg(feature = "experimental")]
199201
/// Maps the given range of frames to the range of virtual pages.
200202
///
201203
/// ## Safety
@@ -318,6 +320,7 @@ pub trait Mapper<S: PageSize> {
318320
Self: Sized,
319321
A: FrameAllocator<Size4KiB> + ?Sized;
320322

323+
#[cfg(feature = "experimental")]
321324
/// Maps the given range of frames to the range of virtual pages.
322325
///
323326
/// ## Safety
@@ -370,6 +373,7 @@ pub trait Mapper<S: PageSize> {
370373
.map(|_| MapperFlushRange::new(pages))
371374
}
372375

376+
#[cfg(feature = "experimental")]
373377
/// Maps frames from the allocator to the given range of virtual pages.
374378
///
375379
/// ## Safety
@@ -422,6 +426,7 @@ pub trait Mapper<S: PageSize> {
422426
})
423427
}
424428

429+
#[cfg(feature = "experimental")]
425430
/// Maps frames from the allocator to the given range of virtual pages.
426431
///
427432
/// ## Safety
@@ -455,6 +460,7 @@ pub trait Mapper<S: PageSize> {
455460
/// Note that no page tables or pages are deallocated.
456461
fn unmap(&mut self, page: Page<S>) -> Result<(PhysFrame<S>, MapperFlush<S>), UnmapError>;
457462

463+
#[cfg(feature = "experimental")]
458464
/// Removes a range of mapping from the page table and deallocate the frames that used to be mapped.
459465
///
460466
/// Note that no page tables or pages are deallocated.
@@ -510,6 +516,7 @@ pub trait Mapper<S: PageSize> {
510516
flags: PageTableFlags,
511517
) -> Result<MapperFlush<S>, FlagUpdateError>;
512518

519+
#[cfg(feature = "experimental")]
513520
/// Updates the flags of a range of existing mappings.
514521
///
515522
/// ## Safety
@@ -617,6 +624,7 @@ pub trait Mapper<S: PageSize> {
617624
self.map_to(page, frame, flags, frame_allocator)
618625
}
619626

627+
#[cfg(feature = "experimental")]
620628
/// Maps the given range of frames to the range of virtual pages with the same address.
621629
///
622630
/// ## Safety
@@ -671,6 +679,7 @@ impl<S: PageSize> MapperFlush<S> {
671679
pub fn ignore(self) {}
672680
}
673681

682+
#[cfg(feature = "experimental")]
674683
/// This type represents a range of pages whose mappings have changed in the page table.
675684
///
676685
/// The old mappings might be still cached in the translation lookaside buffer (TLB), so they need
@@ -680,6 +689,7 @@ impl<S: PageSize> MapperFlush<S> {
680689
#[must_use = "Page Table changes must be flushed or ignored."]
681690
pub struct MapperFlushRange<S: PageSize>(PageRange<S>);
682691

692+
#[cfg(feature = "experimental")]
683693
impl<S: PageSize> MapperFlushRange<S> {
684694
/// Create a new flush promise
685695
#[inline]

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
7474
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
7575
}
7676

77+
#[cfg(feature = "experimental")]
7778
#[inline]
7879
unsafe fn map_to_range_with_table_flags<A>(
7980
&mut self,
@@ -96,6 +97,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
9697
)
9798
}
9899

100+
#[cfg(feature = "experimental")]
99101
#[inline]
100102
unsafe fn map_range_with_table_flags<A>(
101103
&mut self,
@@ -119,6 +121,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
119121
self.inner.unmap(page)
120122
}
121123

124+
#[cfg(feature = "experimental")]
122125
#[inline]
123126
unsafe fn unmap_range<D>(
124127
&mut self,
@@ -191,6 +194,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
191194
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
192195
}
193196

197+
#[cfg(feature = "experimental")]
194198
#[inline]
195199
unsafe fn map_to_range_with_table_flags<A>(
196200
&mut self,
@@ -213,6 +217,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
213217
)
214218
}
215219

220+
#[cfg(feature = "experimental")]
216221
#[inline]
217222
unsafe fn map_range_with_table_flags<A>(
218223
&mut self,
@@ -236,6 +241,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
236241
self.inner.unmap(page)
237242
}
238243

244+
#[cfg(feature = "experimental")]
239245
#[inline]
240246
unsafe fn unmap_range<D>(
241247
&mut self,
@@ -308,6 +314,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
308314
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
309315
}
310316

317+
#[cfg(feature = "experimental")]
311318
#[inline]
312319
unsafe fn map_to_range_with_table_flags<A>(
313320
&mut self,
@@ -330,6 +337,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
330337
)
331338
}
332339

340+
#[cfg(feature = "experimental")]
333341
#[inline]
334342
unsafe fn map_range_with_table_flags<A>(
335343
&mut self,
@@ -353,6 +361,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
353361
self.inner.unmap(page)
354362
}
355363

364+
#[cfg(feature = "experimental")]
356365
#[inline]
357366
unsafe fn unmap_range<D>(
358367
&mut self,

0 commit comments

Comments
 (0)