/* Video terminal, not a serial tty */
#define CONFIG_VT
-/* Keyboard contains not ascii symbols */
+/* Keyboard contains non-ascii symbols */
#define CONFIG_UNIKEY
#define CONFIG_FONT8X8
#define CONFIG_FONT8X8SMALL
+#define CONFIG_DYNAMIC_BUFPOOL
#define CONFIG_DYNAMIC_SWAP
/* Custom banking */
#define NUM_DEV_TTY 1
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
-#define NBUFS 9 /* Number of block buffers */
+#define NBUFS 5 /* Number of block buffers */
#define NMOUNTS 4 /* Number of mounts at a time */
-#define MAX_BLKDEV 2 /* 2 IDE drives, 1 SD drive */
+#define MAX_BLKDEV 4 /* 2 IDE drives, 2 SD drive */
#define SWAPBASE 0x8000
#define SWAPTOP 0x10000UL
/* All our pages get mapped into the top 16K bank for swapping use */
#define swap_map(x) ((uint8_t *)(x|0xC000))
-
-#define platform_discard()
.area _COMMONDATA
.area _INITIALIZED
;
- ; We move INITIALIZER into INITIALIZED at preparation time
- ; then pack COMMONMEM.. end of INITIALIZED after DISCARD
- ; in the load image. Beyond that point we just zero.
+ ; Beyond this point we just zero.
;
.area _DATA
.area _BSEG
.area _HEAP
.area _GSINIT
.area _GSFINAL
+ ; We moved our font elsewhere
.area _FONT
;
+ ; Finally the buffers so they can expand
+ ;
+ .area _BUFFERS
+ ;
; All our code is banked at 0xC000
;
.area _CODE1
.area _CODE2
;
- ; Code3 sits above the display area along with the font and video
+ ; Code3 sits above the display area along with the video
; code so that they can access the display easily. It lives at
; 0xDB00 therefore
;
.area _CODE3
.area _VIDEO
- ; FIXME: We should switch to the ROM font and an ascii remap ?
- .area _FONT
; Discard is dumped in at 0x8000 and will be blown away later.
.area _DISCARD
.globl _fuzix_main
.globl init_early
.globl init_hardware
+ .globl l__BUFFERS
+ .globl s__BUFFERS
.globl l__DATA
.globl s__DATA
.globl kstack_top
.globl nmi_handler
.globl interrupt_handler
+ .include "../kernel.def"
.include "kernel.def"
; startup code
ld bc, #l__DATA-1
ld (hl), #0
ldir
+ ld hl, #s__BUFFERS
+ ld de, #s__BUFFERS+1
+ ld bc, #l__BUFFERS-1
+ ld (hl), #0
+ ldir
ld sp, #kstack_top
.area _STUBS
stubs:
.ds 768
+
+ .area _BUFFERS
+;
+; Buffers (we use asm to set this up as we need them in a special segment
+; so we can recover the discard memory into the buffer pool
+;
+
+ .globl _bufpool
+ .area _BUFFERS
+
+_bufpool:
+ .ds BUFSIZE * NBUFS
-i fuzix.ihx
-b _CONST=0x400
-b _COMMONDATA=0x2200
+-b _BUFFERS=0x6000
-b _CODE1=0xC000
-b _CODE2=0xC000
-b _CODE3=0xDB00
PROGBASE .equ 0x8000
PROGLOAD .equ 0x8000
+NBUFS .equ 5
return len;
}
+/* This points to the last buffer in the disk buffers. There must be at least
+ four buffers to avoid deadlocks. */
+struct blkbuf *bufpool_end = bufpool + NBUFS;
+
+/*
+ * We pack discard into the memory image is if it were just normal
+ * code but place it at the end after the buffers. When we finish up
+ * booting we turn everything from the buffer pool to the start of
+ * user space into buffers.
+ *
+ * We don't touch discard. Discard is just turned into user space.
+ */
+void platform_discard(void)
+{
+ uint16_t discard_size = PROGBASE - (uint16_t)bufpool_end;
+ bufptr bp = bufpool_end;
+
+ discard_size /= sizeof(struct blkbuf);
+
+ kprintf("%d buffers added\n", discard_size);
+
+ bufpool_end += discard_size;
+
+ memset( bp, 0, discard_size * sizeof(struct blkbuf) );
+
+ for( bp = bufpool + NBUFS; bp < bufpool_end; ++bp ){
+ bp->bf_dev = NO_DEVICE;
+ bp->bf_busy = BF_FREE;
+ }
+}
+
#ifndef SWAPDEV
/* Adding dummy swapper since it is referenced by tricks.s */
void swapper(ptptr p)