Allocate pages in the specified page table starting at the page containing virtual address \p start_addr and large enough to contain \p size bytes. \p flags PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
(
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
mapper: &mut impl Mapper<Size4KiB>,
start_addr: VirtAddr,
size: u64,
flags: PageTableFlags)
| 241 | /// |
| 242 | /// \p flags PageTableFlags::PRESENT | PageTableFlags::WRITABLE; |
| 243 | pub fn allocate_pages_mapper( |
| 244 | frame_allocator: &mut impl FrameAllocator<Size4KiB>, |
| 245 | mapper: &mut impl Mapper<Size4KiB>, |
| 246 | start_addr: VirtAddr, |
| 247 | size: u64, |
| 248 | flags: PageTableFlags) |
| 249 | -> Result<(), MapToError<Size4KiB>> { |
| 250 | |
| 251 | let page_range = { |
| 252 | let end_addr = start_addr + size - 1u64; |
| 253 | let start_page = Page::containing_address(start_addr); |
| 254 | let end_page = Page::containing_address(end_addr); |
| 255 | Page::range_inclusive(start_page, end_page) |
| 256 | }; |
| 257 | |
| 258 | for page in page_range { |
| 259 | let frame = frame_allocator |
| 260 | .allocate_frame() |
| 261 | .ok_or(MapToError::FrameAllocationFailed)?; |
| 262 | unsafe { |
| 263 | mapper.map_to(page, |
| 264 | frame, |
| 265 | flags, |
| 266 | frame_allocator)?.flush() |
| 267 | }; |
| 268 | } |
| 269 | |
| 270 | Ok(()) |
| 271 | } |
| 272 | |
| 273 | pub fn allocate_pages(level_4_table: *mut PageTable, |
| 274 | start_addr: VirtAddr, |
no test coverage detected