pub fn map_allocate(&mut self,
                        vaddr: usize,
                        size: usize,
                        page_type: PageType)
                        -> Result<(), Error> {

        let vaddr_aligned = align_down(vaddr, PAGE_SIZE);
        let size_aligned = align_up(size, PAGE_SIZE);

        let pages = size_aligned / PAGE_SIZE;

        let mut mapped = 0;

        let mut pageset = self.pageset.lock();

        let mut cur_vaddr = vaddr_aligned;

        while mapped < pages {
            let (paddr_start, acq_pages) =
                memory::acquire_region(RegionUser::Process(self.id),
                                            pages - mapped)
                     .ok_or(Error::OutOfMemory(mapped))?;

            let paddr_end = paddr_start + acq_pages * PAGE_SIZE;

            pageset.map_pages_with_type(
                    cur_vaddr,
                    (paddr_start..paddr_end).step_by(PAGE_SIZE),
                    page_type.user())
                 .map_err(|e| Error::from(e))?;

            self.owned_regions.push(ProcessOwnedRegion {
                vaddr: cur_vaddr,
                paddr: paddr_start,
                pages: acq_pages,
            });

            mapped += acq_pages;
            cur_vaddr += acq_pages * PAGE_SIZE;
        }

        Ok(())
    }
/// Allocates at least enough pages at `vaddr` to contain `size`.
Allocates at least enough pages at `vaddr` to contain `size`.
Allocates at least enough pages at ` vaddr ` to contain ` size ` .
pub fn map_allocate(&mut self,
                        vaddr: usize,
                        size: usize,
                        page_type: PageType)
                        -> Result<(), Error> {
        let vaddr_aligned = align_down(vaddr, PAGE_SIZE);
        let size_aligned = align_up(size, PAGE_SIZE);
        let pages = size_aligned / PAGE_SIZE;
        let mut mapped = 0;
        let mut pageset = self.pageset.lock();
        let mut cur_vaddr = vaddr_aligned;
        while mapped < pages {
            let (paddr_start, acq_pages) =
                memory::acquire_region(RegionUser::Process(self.id),
                                            pages - mapped)
                     .ok_or(Error::OutOfMemory(mapped))?;
            let paddr_end = paddr_start + acq_pages * PAGE_SIZE;
            pageset.map_pages_with_type(
                    cur_vaddr,
                    (paddr_start..paddr_end).step_by(PAGE_SIZE),
                    page_type.user())
                 .map_err(|e| Error::from(e))?;
            self.owned_regions.push(ProcessOwnedRegion {
                vaddr: cur_vaddr,
                paddr: paddr_start,
                pages: acq_pages,
            });
            mapped += acq_pages;
            cur_vaddr += acq_pages * PAGE_SIZE;
        }
        Ok(())
    }
pub fn map_allocate ( & mut self , vaddr : usize , size : usize , page_type : PageType ) -> Result < ( ) , Error > { let vaddr_aligned = align_down ( vaddr , PAGE_SIZE ) ; let size_aligned = align_up ( size , PAGE_SIZE ) ; let pages = size_aligned / PAGE_SIZE ; let mut mapped = 0 ; let mut pageset = self . pageset . lock ( ) ; let mut cur_vaddr = vaddr_aligned ; while mapped < pages { let ( paddr_start , acq_pages ) = memory :: acquire_region ( RegionUser :: Process ( self . id ) , pages - mapped ) . ok_or ( Error :: OutOfMemory ( mapped ) ) ? ; let paddr_end = paddr_start + acq_pages * PAGE_SIZE ; pageset . map_pages_with_type ( cur_vaddr , ( paddr_start .. paddr_end ) . step_by ( PAGE_SIZE ) , page_type . user ( ) ) . map_err ( | e | Error :: from ( e ) ) ? ; self . owned_regions . push ( ProcessOwnedRegion { vaddr : cur_vaddr , paddr : paddr_start , pages : acq_pages , } ) ; mapped += acq_pages ; cur_vaddr += acq_pages * PAGE_SIZE ; } Ok ( ( ) ) }
Allocates at least enough pages at `vaddr` to contain `size`.
Allocates at least enough pages at ` vaddr ` to contain ` size ` .
&mut self
vaddr
usize
size
usize
page_type
PageType