From 63ffa4ef49967f580bcbffc730b600f2ef0b4de7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 20 Feb 2019 22:30:48 +0000 Subject: [PATCH] swap: allow offet 0 to be used for swap Don't make it the default because some platforms use swap slot 0 for other things --- Kernel/bank16k.c | 4 ++-- Kernel/bank16k_low.c | 4 ++-- Kernel/bank65c816.c | 4 ++-- Kernel/bank8k.c | 4 ++-- Kernel/bankfixed.c | 4 ++-- Kernel/simple.c | 4 ++-- Kernel/swap.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Kernel/bank16k.c b/Kernel/bank16k.c index 096986dc..a218ca43 100644 --- a/Kernel/bank16k.c +++ b/Kernel/bank16k.c @@ -229,7 +229,7 @@ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; uint16_t base = SWAPBASE; uint16_t size = (0x4000 - SWAPBASE) >> 9; uint16_t i; @@ -243,7 +243,7 @@ int swapout(ptptr p) /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; blk = map * SWAP_SIZE; /* Write the app (and possibly the uarea etc..) to disk */ diff --git a/Kernel/bank16k_low.c b/Kernel/bank16k_low.c index 6023f26d..84375c57 100644 --- a/Kernel/bank16k_low.c +++ b/Kernel/bank16k_low.c @@ -174,7 +174,7 @@ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; uint16_t base = SWAPBASE; uint16_t size = (0x4000 - SWAPBASE) >> 9; uint8_t *pt = (uint8_t *)&p->page; @@ -187,7 +187,7 @@ int swapout(ptptr p) /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; blk = map * SWAP_SIZE; diff --git a/Kernel/bank65c816.c b/Kernel/bank65c816.c index e15af867..7e0683b6 100644 --- a/Kernel/bank65c816.c +++ b/Kernel/bank65c816.c @@ -85,7 +85,7 @@ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; if (!page) panic(PANIC_ALREADYSWAP); @@ -94,7 +94,7 @@ int swapout(ptptr p) #endif /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; blk = map * SWAP_SIZE; /* Write the user CPU stack and DP to disk */ diff --git a/Kernel/bank8k.c b/Kernel/bank8k.c index 11834b78..b4a0cb21 100644 --- a/Kernel/bank8k.c +++ b/Kernel/bank8k.c @@ -276,7 +276,7 @@ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; uint16_t base = SWAPBASE; uint16_t size = (0x2000 - SWAPBASE) >> 9; uint8_t i; @@ -293,7 +293,7 @@ int swapout(ptptr p) /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; blk = map * SWAP_SIZE; /* Write the app (and possibly the uarea etc..) to disk */ diff --git a/Kernel/bankfixed.c b/Kernel/bankfixed.c index bafe0652..f487f511 100644 --- a/Kernel/bankfixed.c +++ b/Kernel/bankfixed.c @@ -92,13 +92,13 @@ int swapout(ptptr p) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; if (!page) panic(PANIC_ALREADYSWAP); /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; #ifdef DEBUG kprintf("Swapping out %x (%d) to map %d\n", p, p->p_page, map); diff --git a/Kernel/simple.c b/Kernel/simple.c index e3562a2f..9b5afa60 100644 --- a/Kernel/simple.c +++ b/Kernel/simple.c @@ -70,7 +70,7 @@ int swapout_new(ptptr p, void *u) { uint16_t page = p->p_page; uint16_t blk; - uint16_t map; + int16_t map; #ifdef DEBUG kprintf("Swapping out %x (%d)\n", p, p->p_pid); @@ -79,7 +79,7 @@ int swapout_new(ptptr p, void *u) panic(PANIC_ALREADYSWAP); /* Are we out of swap ? */ map = swapmap_alloc(); - if (map == 0) + if (map == -1) return ENOMEM; blk = map * SWAP_SIZE; /* Write the app (and uarea etc..) to disk */ diff --git a/Kernel/swap.c b/Kernel/swap.c index 3b3bca01..3d0b9d1f 100644 --- a/Kernel/swap.c +++ b/Kernel/swap.c @@ -39,7 +39,7 @@ int swapmap_alloc(void) return swapmap[--swapptr]; } else - return 0; + return -1; } void swapmap_init(uint8_t swap) -- 2.34.1