paging.c
/* Map a physical page to the virtual address addr.
 * If the page table entry points to a swapped block
 * restore the content of the page from the swapped
 * block and free the swapped block.
 */
Map a physical page to the virtual address addr.
If the page table entry points to a swapped block
restore the content of the page from the swapped
block and free the swapped block.
Map a physical page to the virtual address addr . If the page table entry points to a swapped block restore the content of the page from the swapped block and free the swapped block .
void
map_address(pde_t *pgdir, uint addr)
{
	pte_t *target;
	if( (target = walkpgdir(pgdir, (char *)addr, 1)) == 0 ) {
		target = swap_page(pgdir);
	} 
	uint ppn = PTE_ADDR(*target);	
	char *pg = (char *)P2V(ppn);
	if( (*target & ~(PTE_P)) ){
		read_page_from_disk(ROOTDEV, pg, *target);
		bfree_page(ROOTDEV, *target);
	}
}
void map_address ( pde_t * pgdir , uint addr ) { pte_t * target ; if ( ( target = walkpgdir ( pgdir , ( char * ) addr , 1 ) ) == 0 ) { target = swap_page ( pgdir ) ; } uint ppn = PTE_ADDR ( * target ) ; char * pg = ( char * ) P2V ( ppn ) ; if ( ( * target & ~ ( PTE_P ) ) ) { read_page_from_disk ( ROOTDEV , pg , * target ) ; bfree_page ( ROOTDEV , * target ) ; } }
Map a physical page to the virtual address addr.
Map a physical page to the virtual address addr .
// cprintf("MAP ADDRESS"); // int swap_blk; //Recheck for round down !!! // if((swap_blk = getswappedblk(pgdir, addr)) != -1){ // panic("map_address is not implemented");