pub fn map_pages(p: &mut [PageDirEntry],
                 va: VirtAddr,
                 size: usize,
                 mut pa: PhysAddr,
                 permissions: Entry)
                 -> Result<(), ()> {
    let mut a = va.page_rounddown();
    let last = va.offset::<u8>((size - 1) as isize).page_rounddown();

    loop {
        let pte = walkpgdir(p, a, true)?;

        if pte.0 & PRESENT == PRESENT {
            panic!("remap failed");
        }
        let mut new_entry = permissions | PRESENT;
        new_entry.bits |= pa.addr();
        *pte = PageTableEntry(new_entry);
        if a == last {
            break;
        }

        a = a.offset::<u8>(PGSIZE as isize);
        pa = pa.offset::<u8>(PGSIZE as isize);
    }
    Ok(())
}
/// Given page directory entries, Create PTEs for virtual addresses starting at va.
Given page directory entries, Create PTEs for virtual addresses starting at va.
Given page directory entries Create PTEs for virtual addresses starting at va .
pub fn map_pages(p: &mut [PageDirEntry],
                 va: VirtAddr,
                 size: usize,
                 mut pa: PhysAddr,
                 permissions: Entry)
                 -> Result<(), ()> {
    let mut a = va.page_rounddown();
    let last = va.offset::<u8>((size - 1) as isize).page_rounddown();
    loop {
        let pte = walkpgdir(p, a, true)?;
        if pte.0 & PRESENT == PRESENT {
            panic!("remap failed");
        }
        let mut new_entry = permissions | PRESENT;
        new_entry.bits |= pa.addr();
        *pte = PageTableEntry(new_entry);
        if a == last {
            break;
        }
        a = a.offset::<u8>(PGSIZE as isize);
        pa = pa.offset::<u8>(PGSIZE as isize);
    }
    Ok(())
}
pub fn map_pages ( p : & mut [ PageDirEntry ] , va : VirtAddr , size : usize , mut pa : PhysAddr , permissions : Entry ) -> Result < ( ) , ( ) > { let mut a = va . page_rounddown ( ) ; let last = va . offset :: < u8 > ( ( size - 1 ) as isize ) . page_rounddown ( ) ; loop { let pte = walkpgdir ( p , a , true ) ? ; if pte . 0 & PRESENT == PRESENT { panic ! ( " " ) ; } let mut new_entry = permissions | PRESENT ; new_entry . bits |= pa . addr ( ) ; * pte = PageTableEntry ( new_entry ) ; if a == last { break ; } a = a . offset :: < u8 > ( PGSIZE as isize ) ; pa = pa . offset :: < u8 > ( PGSIZE as isize ) ; } Ok ( ( ) ) }
Given page directory entries, Create PTEs for virtual addresses starting at va.
Given page directory entries Create PTEs for virtual addresses starting at va .
p
&mut [PageDirEntry]
va
VirtAddr
size
usize
pa
PhysAddr
permissions
Entry
p
&mut [PageDirEntry]
va
VirtAddr
size
usize
pa
PhysAddr
permissions
Entry