uint16_t base = SWAPBASE;
uint16_t size = (0x4000 - SWAPBASE) >> 9;
uint16_t i;
-
- swapproc = p;
+ uint8_t *pt = (uint8_t *)&p->page;
if (page)
panic("process already swapped!\n");
blk = map * SWAP_SIZE;
/* Write the app (and possibly the uarea etc..) to disk */
for (i = 0; i < 4; i ++) {
- swapwrite(SWAPDEV, blk, size, (uint8_t *)base);
+ swapwrite(SWAPDEV, blk, size, base, *pt++);
base += 0x4000;
/* Last bank is determined by SWAP SIZE. We do the maths
in 512's (0x60 = 0xC000) */
/*
* Swap ourself in: must be on the swap stack when we do this
*/
-void swapin(ptptr p)
+void swapin(ptptr p, uint16_t map)
{
- uint16_t blk = p->p_page2 * SWAP_SIZE;
+ uint16_t blk = map * SWAP_SIZE;
uint16_t base = SWAPBASE;
uint16_t size = (0x4000 - SWAPBASE) >> 9;
uint16_t i;
+ uint8_t *pt = (uint8_t *)&p->page;
#ifdef DEBUG
kprintf("Swapin %x, %d\n", p, p->p_page);
return;
}
- /* Return our swap */
- swapmap_add(p->p_page2);
-
- swapproc = p; /* always ourself */
for (i = 0; i < 4; i ++) {
- swapread(SWAPDEV, blk, size, (uint8_t *)base);
+ swapread(SWAPDEV, blk, size, base, *pt++);
base += 0x4000;
/* Last bank is determined by SWAP SIZE. We do the maths
in 512's (0x60 = 0xC000) */
uint16_t map;
uint16_t base = SWAPBASE;
uint16_t size = (0x4000 - SWAPBASE) >> 9;
-
- swapproc = p;
+ uint8_t *pt = (uint8_t *)&p->page;
if (page)
panic("process already swapped!\n");
/* Write the app (and possibly the uarea etc..) to disk */
for (i = 0; i < 4; i ++) {
- swapwrite(SWAPDEV, blk, size, base);
+ swapwrite(SWAPDEV, blk, size, base, *pt++);
base += 0x4000;
/* Last bank is determined by SWAP SIZE. We do the maths
in 512's (0x60 = 0xC000) */
/*
* Swap ourself in: must be on the swap stack when we do this
*/
-void swapin(ptptr p)
+void swapin(ptptr p, uint16_t map)
{
- uint16_t blk = p->p_page2 * SWAP_SIZE;
+ uint16_t blk = map * SWAP_SIZE;
uint16_t base = SWAPBASE;
uint16_t size = (0x4000 - SWAPBASE) >> 9;
+ uint16_t i;
+ uint8_t *pt = (uint8_t *)&p->page;
#ifdef DEBUG
kprintf("Swapin %x, %d\n", p, p->p_page);
return;
}
- /* Return our swap */
- swapmap_add(p->p_page2);
-
/* This may need other tweaks as its a special nasty case where
we don't want to overwrite the live stack but buffer and fix up
in tricks.s */
blk++;
#endif
- swapproc = p; /* always ourself */
for (i = 0; i < 4; i ++) {
- swapread(SWAPDEV, blk, size, base);
+ swapread(SWAPDEV, blk, size, base, *pt++);
base += 0x4000;
/* Last bank is determined by SWAP SIZE. We do the maths
in 512's (0x60 = 0xC000) */
uint16_t blk;
uint16_t map;
- swapproc = p;
-
if (!page)
panic("process already swapped!\n");
#ifdef DEBUG
return ENOMEM;
blk = map * SWAP_SIZE;
/* Write the app (and possibly the uarea etc..) to disk */
- swapwrite(SWAPDEV, blk, SWAPTOP - SWAPBASE,
- (uint8_t *)SWAPBASE);
+ swapwrite(SWAPDEV, blk, SWAPTOP - SWAPBASE, SWAPBASE, p->page);
pagemap_free(p);
p->p_page = 0;
p->p_page2 = map;
/*
* Swap ourself in: must be on the swap stack when we do this
*/
-void swapin(ptptr p)
+void swapin(ptptr p, uint16_t map)
{
- uint16_t blk = p->p_page2 * SWAP_SIZE;
+ uint16_t blk = map * SWAP_SIZE;
#ifdef DEBUG
kprintf("Swapin %x, %d\n", p, p->p_page);
kprintf("%x: nopage!\n", p);
return;
}
-
- /* Return our swap */
- swapmap_add(p->p_page2);
-
- swapproc = p; /* always ourself */
- swapread(SWAPDEV, blk, SWAPTOP - SWAPBASE,
- (uint8_t *)SWAPBASE);
+ swapread(SWAPDEV, blk, SWAPTOP - SWAPBASE, SWAPBASE, p->page);
#ifdef DEBUG
kprintf("%x: swapin done %d\n", p, p->p_page);
#endif
#endif
/* swap.c */
-extern ptptr swapproc;
+extern uint16_t swappage;
extern uint8_t *swapbase;
extern unsigned int swapcnt;
extern blkno_t swapblk;
extern int swapread(uint16_t dev, blkno_t blkno, unsigned int nbytes,
- uint8_t *buf);
+ uint16_t buf, uint16_t page);
extern int swapwrite(uint16_t dev, blkno_t blkno, unsigned int nbytes,
- uint8_t *buf);
+ uint16_t buf, uint16_t page);
extern void swapmap_add(uint8_t swap);
extern int swapmap_alloc(void);
extern ptptr swapneeded(ptptr p, int selfok);
extern void swapper(ptptr p);
+/* These two are provided by the bank code selected for the port */
extern int swapout(ptptr p);
-extern void swapin(ptptr p);
+extern void swapin(ptptr p, uint16_t map);
/* syscalls_fs.c, syscalls_proc.c, syscall_other.c etc */
extern void updoff(void);
uint16_t blk;
uint16_t map;
- swapproc = p;
-
if (!page)
panic("process already swapped!\n");
#ifdef DEBUG
blk = map * SWAP_SIZE;
/* Write the app (and possibly the uarea etc..) to disk */
swapwrite(SWAPDEV, blk, SWAPTOP - SWAPBASE,
- SWAPBASE);
+ SWAPBASE, 1);
p->p_page = 0;
p->p_page2 = map;
#ifdef DEBUG
/*
* Swap ourself in: must be on the swap stack when we do this
*/
-void swapin(ptptr p)
+void swapin(ptptr p, uint16_t map)
{
- uint16_t blk = p->p_page2 * SWAP_SIZE;
+ uint16_t blk = map * SWAP_SIZE;
#ifdef DEBUG
kprintf("Swapin %x, %d\n", p, p->p_page);
return;
}
- /* Return our swap */
- swapmap_add(p->p_page2);
-
- swapproc = p; /* always ourself */
swapread(SWAPDEV, blk, SWAPTOP - SWAPBASE,
- SWAPBASE);
+ SWAPBASE, 1);
#ifdef DEBUG
kprintf("%x: swapin done %d\n", p, p->p_page);
#endif
uint8_t *swapbase;
unsigned int swapcnt;
blkno_t swapblk;
-ptptr swapproc; /* Target process space */
+uint16_t swappage; /* Target page */
/* Table of available maps */
static uint8_t swapmap[MAX_SWAPS];
return 0;
}
+/* FIXME: clean this up by having a common i/o structure to avoid
+ all the mode 1 and mode 2 confusion and conversions */
+
int swapread(uint16_t dev, blkno_t blkno, unsigned int nbytes,
- uint8_t *buf)
+ uint16_t buf, uint16_t page)
{
- swapbase = buf;
+ swapbase = swap_map(buf);
swapcnt = nbytes;
swapblk = blkno;
+ swappage = page;
return ((*dev_tab[major(dev)].dev_read) (minor(dev), 2, 0));
}
int swapwrite(uint16_t dev, blkno_t blkno, unsigned int nbytes,
- uint8_t *buf)
+ uint16_t buf, uint16_t page)
{
- swapbase = buf;
+ swapbase = swap_map(buf);
swapcnt = nbytes;
swapblk = blkno;
+ swappage = page;
return ((*dev_tab[major(dev)].dev_write) (minor(dev), 2, 0));
}
*/
void swapper(ptptr p)
{
- pagemap_alloc(p); /* May cause a swapout */
+ uint16_t map = p->p_page2;
+ pagemap_alloc(p); /* May cause a swapout. May also destroy
+ the old value of p->page2 */
#ifdef DEBUG
kprintf("Swapping in %x (page %d), utab.ptab %x\n", p, p->p_page,
udata.u_ptab);
#endif
- swapin(p);
+ swapin(p, map);
+ swapmap_add(map);
#ifdef DEBUG
kprintf("Swapped in %x (page %d), udata.ptab %x\n",
p, p->p_page, udata.u_ptab);