/* * Swap out the memory of a process to make room * for something else. */ int swapout(ptptr p) { uint16_t blk; uint16_t map; if (!p->p_page) panic("process already swapped!\n"); #ifdef DEBUG kprintf("Swapping out %x (%d)\n", p, p->p_page); #endif /* We mever swap the live process so the second page is always page 6 */ if (low_bank == p) panic("swapout"); /* Are we out of swap ? */ map = swapmap_alloc(); if (map == 0) return ENOMEM; blk = map * SWAP_SIZE; /* Write the top page and the included uarea stash to disk */ swapwrite(SWAPDEV, blk, 0x4000, 0xC000, p->p_page); /* Write the alt bank via the top 16K window */ swapwrite(SWAPDEV, blk + 0x20, 0x4000, 0xC000, 6); /* Release the mapping */ pagemap_free(p); p->p_page = 0; p->p_page2 = map; #ifdef DEBUG kprintf("%x: swapout done %d\n", p, p->p_page); #endif return 0; }
int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; uint16_t map; uint16_t base = SWAPBASE; uint16_t size = (0x4000 - SWAPBASE) >> 9; uint16_t i; uint8_t *pt = (uint8_t *)&p->p_page; if (!page) panic(PANIC_ALREADYSWAP); #ifdef DEBUG kprintf("Swapping out %x (%d)\n", p, p->p_page); #endif /* Are we out of swap ? */ map = swapmap_alloc(); if (map == 0) return ENOMEM; blk = map * SWAP_SIZE; /* Write the app (and possibly the uarea etc..) to disk */ for (i = 0; i < 4; i++) { swapwrite(SWAPDEV, blk, size, base, *pt++); base += 0x4000; base &= 0xC000; /* Snap to bank alignment */ blk += size; /* Last bank is determined by SWAP SIZE. We do the maths in 512's (0x60 = 0xC000) */ if (i == 2) size = SWAP_SIZE + (SWAPBASE >> 9) - 0x60; else size = 0x20; }
int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; uint16_t map; uint16_t base = SWAPBASE; uint16_t size = (0x4000 - SWAPBASE) >> 9; uint8_t *pt = (uint8_t *)&p->page; if (page) panic("process already swapped!\n"); #ifdef DEBUG kprintf("Swapping out %x (%d)\n", p, p->p_page); #endif /* Are we out of swap ? */ map = swapmap_alloc(); if (map == 0) return ENOMEM; blk = map * SWAP_SIZE; #ifdef CONFIG_HAS_LOW_PAGE swapwrite(SWAPDEV, blk, 1, 0x0000); blk++; #endif /* Write the app (and possibly the uarea etc..) to disk */ for (i = 0; i < 4; i ++) { swapwrite(SWAPDEV, blk, size, base, *pt++); base += 0x4000; /* Last bank is determined by SWAP SIZE. We do the maths in 512's (0x60 = 0xC000) */ if (i == 3) size = SWAP_SIZE_EXCL_ZP - 0x60; else size = 0x20; } pagemap_free(p); p->p_page = 0; p->p_page2 = map; #ifdef DEBUG kprintf("%x: swapout done %d\n", p, p->p_page); #endif return 0; }
/* * Swap out the memory of a process to make room * for something else */ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; uint16_t map; #ifdef UDATA_SWAPSIZE uint8_t *ptr; #endif swapproc = p; if (page) { #ifdef DEBUG kprintf("Swapping out %x (%d)\n", p, p->p_page); #endif /* Are we out of swap ? */ if (swapptr == 0) return ENOMEM; swap_flush_cache(p); map = swapmap[--swapptr]; blk = map * SWAP_SIZE; #ifdef UDATA_SWAPSIZE /* Allow the platform to do things like handle the uarea stash */ ptr = swapout_prepare_uarea(p); /* Write to disk if the platform asks us */ if (ptr) swapwrite(SWAPDEV, blk, UDATA_SWAPSIZE, ptr); #endif /* Write the app (and possibly the uarea etc..) to disk */ swapwrite(SWAPDEV, blk + UDATA_BLOCKS, SWAPTOP - SWAPBASE, SWAPBASE); pagemap_free(p); p->p_page = 0; p->p_page2 = map; #ifdef DEBUG kprintf("%x: swapout done %d\n", p, p->p_page); #endif } #ifdef DEBUG else kprintf("%x: process already swapped!\n", p); #endif return 0; }
void swapout(void) { struct vmpage *page = NULL; struct vmpage *hdrtab = curproc->vmhdrtab; unsigned long spage; vmdeqpage(&page); if (page) { spage = swapalloc(); swapwrite(spage, vmpageadr(page, hdrtab)); } return; }