To Do:
-- Check the swap hooks are ok
-- Turn on swap so we can make progress
+DONE - Check the swap hooks are ok
+DONE - Turn on swap so we can make progress
+ - Debug crash on swapping
- Set video space in CODE3 bank to 0 not 0xFF for neatness
- Look at what is needed for other suitable interfaces. DIVMMC would
in particular be good to support but that means another harder
- Later DivIDE and DivMMC support both a 16K page mode and a lot more
RAM (up to 512K). That at the very least would make a kick ass
ramdisc/swap device even if the unit lacks the allram switch
+ (May also make sense to hae a build 'the other way up' where we
+ page apps out of 0000-3FFF copying 4000-7FFF.
- Speccyboot (ENC28J60)
- SpectraNet (W5100)
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 */
+ /* We never swap the live process so the second page is always
+ page 6 (FIXME: this will not be true once we go past 128K) */
if (low_bank == p)
panic("swapout");
#define CONFIG_FONT8X8
#define CONFIG_FONT8X8SMALL
+#define CONFIG_DYNAMIC_SWAP
+
/* Custom banking */
/* We have two mappings from our 128K of memory */
#define NUM_DEV_TTY 1
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
-/* #define SWAPDEV 2051 */ /* Microdrive 3 : FIXME - configure and probe */
#define NBUFS 9 /* Number of block buffers */
#define NMOUNTS 4 /* Number of mounts at a time */
#define MAX_BLKDEV 2 /* 2 IDE drives, 1 SD drive */
#define SWAPBASE 0x8000
#define SWAPTOP 0x10000UL
#define SWAP_SIZE 0x40
-#define MAX_SWAPS 3 /* For now */
+#define MAX_SWAPS 16
+#define SWAPDEV (swap_dev) /* Device for swapping (dynamic). */
/* All our pages get mapped into the top 16K bank for swapping use */
#define swap_map(x) ((uint8_t *)(x|0xC000))
#include <kdata.h>
#include <printf.h>
#include <devtty.h>
+#include <blkdev.h>
void pagemap_init(void)
{
-#ifdef SWAPDEV
- /* Swap */
- swapmap_init(0);
- swapmap_init(1);
- swapmap_init(2);
-#endif
}
uint8_t platform_param(char *p)
{
}
+/*
+ * This function is called for partitioned devices if a partition is found
+ * and marked as swap type. The first one found will be used as swap. We
+ * only support one swap device.
+ */
+void platform_swap_found(uint8_t letter, uint8_t m)
+{
+ blkdev_t *blk = blk_op.blkdev;
+ uint16_t n;
+ if (swap_dev != 0xFFFF)
+ return;
+ letter -= 'a';
+ kputs("(swap) ");
+ swap_dev = letter << 4 | m;
+ n = blk->lba_count[m - 1] / SWAP_SIZE;
+ if (n > MAX_SWAPS)
+ n = MAX_SWAPS;
+#ifdef SWAPDEV
+ while (n)
+ swapmap_add(n--);
+#endif
+}
#include <devtty.h>
uint16_t ramtop = PROGTOP;
+uint16_t swap_dev = 0xFFFF;
/* On idle we spin checking for the terminals. Gives us more responsiveness
for the polled ports */
; Interrupts should be off when this is called
_dup_low_page:
- ld a, #0x06 + 0x18 ; low page alternate
+ di ; FIXME: check callers properly
+ ld a, #0x06 + 0x18 ; low page alternate
ld bc, #0x7ffd
out (c), a
- ld hl, #0x8000 ; Fixed
- ld de, #0xC000 ; Page we just mapped in
+ ld hl, #0x8000 ; fixed
+ ld de, #0xC000 ; page we just mapped in
ld bc, #16384
ldir
- ld a, (current_map) ; restore mapping
+ ld a, (current_map) ; restore mapping
or #0x18 ; ROM bits
ld bc, #0x7ffd
out (c), a