Function largest_pages

Source
pub(crate) fn largest_pages<C: PageTableConfig>(
    va: Vaddr,
    pa: Paddr,
    len: usize,
) -> impl Iterator<Item = (Paddr, PagingLevel)>
Expand description

Splits the address range into largest page table items.

Each of the returned items is a tuple of the physical address and the paging level. It is helpful when you want to map a physical address range into the provided virtual address.

For example, on x86-64, C: PageTableConfig may specify level 1 page as 4KiB, level 2 page as 2MiB, and level 3 page as 1GiB. Suppose that the supplied physical address range is from 0x3fdff000 to 0x80002000, and the virtual address is also 0x3fdff000, the following 5 items will be returned:

0x3fdff000                                                 0x80002000
start                                                             end
  |----|----------------|--------------------------------|----|----|
   4KiB      2MiB                       1GiB              4KiB 4KiB

ยงPanics

Panics if:

  • any of va, pa, or len is not aligned to the base page size;
  • the range va..(va + len) is not valid for the page table.