vmap_page_range
user_0531932
c_cpp
a year ago
1.6 kB
6
Indexable
Never
/* * vmap_page_range - map a range of page at aligned address */ int vmap_page_range(struct pcb_t *caller, // process call int addr, // start address which is aligned to pagesz int pgnum, // num of mapping page struct framephy_struct *frames, // list of the mapped frames struct vm_rg_struct *ret_rg) // return mapped region, the real mapped fp { // no guarantee all given pages are mapped // uint32_t * pte = malloc(sizeof(uint32_t)); // int fpn; int pgit = 0; int pgn = PAGING_PGN(addr); ret_rg->rg_end = ret_rg->rg_start = addr; // at least the very first space is usable struct framephy_struct* traverse = frames; struct mm_struct *mm = caller->mm; //printf("Traverse fpn: %d\n", traverse->fpn); while(traverse!= NULL) { //printf("Traverse fpn: %d\n", traverse->fpn); /* TODO map range of frame to address space * [addr to addr + pgnum*PAGING_PAGESZ * in page table caller->mm->pgd[] */ uint32_t pte; pte_set_fpn(&pte, traverse->fpn); //printf("traverse->fpn: %d\n", traverse->fpn); mm->pgd[pgn + pgit] = pte; /* Tracking for later page replacement activities (if needed) * Enqueue new usage page */ enlist_pgn_node(&caller->mm->fifo_pgn, pgn + pgit); /* Update return region */ ret_rg->rg_end += PAGING_PAGESZ; pgit++; traverse=traverse->fp_next; } return 0; }