Skip to content

Commit ec87383

Browse files
committed
Make MappedFrame::start_address public and const add add size method
1 parent 5c795ad commit ec87383

File tree

1 file changed

+19
-5
lines changed
  • src/structures/paging/mapper

1 file changed

+19
-5
lines changed

src/structures/paging/mapper/mod.rs

+19-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,25 @@ pub enum MappedFrame {
8585
}
8686

8787
impl MappedFrame {
88-
fn start_address(&self) -> PhysAddr {
89-
match self {
90-
MappedFrame::Size4KiB(frame) => frame.start_address(),
91-
MappedFrame::Size2MiB(frame) => frame.start_address(),
92-
MappedFrame::Size1GiB(frame) => frame.start_address(),
88+
const_fn! {
89+
/// Returns the start address of the frame.
90+
pub fn start_address(&self) -> PhysAddr {
91+
match self {
92+
MappedFrame::Size4KiB(frame) => frame.start_address(),
93+
MappedFrame::Size2MiB(frame) => frame.start_address(),
94+
MappedFrame::Size1GiB(frame) => frame.start_address(),
95+
}
96+
}
97+
}
98+
99+
const_fn! {
100+
/// Returns the size the frame (4KB, 2MB or 1GB).
101+
pub fn size(&self) -> u64 {
102+
match self {
103+
MappedFrame::Size4KiB(frame) => frame.size(),
104+
MappedFrame::Size2MiB(frame) => frame.size(),
105+
MappedFrame::Size1GiB(frame) => frame.size(),
106+
}
93107
}
94108
}
95109
}

0 commit comments

Comments
 (0)