src/kernel/mm/vmm/vmm.c
/**
 * @note alloc a page from vmm pool. the physic pages are not continuous.
 *       use valloc_raw and vmap to get continuous physic pages.
 * @param vmm_pool
 * @param vaddr
 * @param page_count
 * @return
 */
@note alloc a page from vmm pool. the physic pages are not continuous.
use valloc_raw and vmap to get continuous physic pages.
@note alloc a page from vmm pool . the physic pages are not continuous . use valloc_raw and vmap to get continuous physic pages .
addr_t valloc_no_lock(vmm_t * vmm_pool, addr_t vaddr, size_t page_count , base_t rw_flag){
    addr_t ret;
    addr_t alloc_addr = valloc_raw_no_lock(vmm_pool, vaddr, page_count);
    if(alloc_addr == NULL){
        ret = NULL;
        goto out;
    }
    vaddr = PAGE_ALIGN(vaddr);
    addr_t start = vaddr;
    int i = 0;
    for(;i<page_count;i++,vaddr+=PAGE_SIZE){
        addr_t paddr = kalloc(1);
        if(paddr==NULL){
            goto map_fail;
        }
        vmap_no_lock(vmm_pool, vaddr, paddr, 1, rw_flag);
    }
    ret = start;
    goto out;
    map_fail:
    vunmap_no_lock(vmm_pool, start, i, true);
    out:
    return ret;
}
addr_t valloc_no_lock ( vmm_t * vmm_pool , addr_t vaddr , size_t page_count , base_t rw_flag ) { addr_t ret ; addr_t alloc_addr = valloc_raw_no_lock ( vmm_pool , vaddr , page_count ) ; if ( alloc_addr == NULL ) { ret = NULL ; goto out ; } vaddr = PAGE_ALIGN ( vaddr ) ; addr_t start = vaddr ; int i = 0 ; for ( ; i < page_count ; i ++ , vaddr += PAGE_SIZE ) { addr_t paddr = kalloc ( 1 ) ; if ( paddr == NULL ) { goto map_fail ; } vmap_no_lock ( vmm_pool , vaddr , paddr , 1 , rw_flag ) ; } ret = start ; goto out ; map_fail : vunmap_no_lock ( vmm_pool , start , i , true ) ; out : return ret ; }
@note alloc a page from vmm pool.
@note alloc a page from vmm pool .