#define TICKSPERSEC 60 /* Ticks per second */
#define PROGBASE 0x0000 /* Base of user */
#define PROGLOAD 0x0100 /* Load and run here */
-#define PROGTOP 0x7D00 /* Top of program, base of U_DATA stash */
+#define PROGTOP 0x7E00 /* Top of program, base of U_DATA stash */
#define PROC_SIZE 32 /* Memory needed per process */
#define SWAP_SIZE 0x40 /* 32K in blocks */
#define NUM_DEV_TTY 3
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
#define SWAPDEV (swap_dev) /* Device for swapping (dynamic). */
-#define NBUFS 10 /* Number of block buffers */
+#define NBUFS 10 /* Number of block buffers - keep in sync with asm! */
#define NMOUNTS 4 /* Number of mounts at a time */
+/* Reclaim the discard space for buffers */
+#define CONFIG_DYNAMIC_BUFPOOL
-#define platform_discard()
+extern void platform_discard(void);
; put initialisation stuff in here
.area _GSINIT
.area _GSFINAL
- .area _COMMONMEM
+ ; Buffers must be directly before discard as they will
+ ; expand over it
+ .area _BUFFERS
.area _DISCARD
+ .area _COMMONMEM
; imported symbols
.globl _fuzix_main
.globl l__DATA
.globl s__DISCARD
.globl l__DISCARD
+ .globl s__BUFFERS
+ .globl l__BUFFERS
.globl s__COMMONMEM
.globl l__COMMONMEM
.globl s__INITIALIZER
.globl kstack_top
+ ; exports
+ .globl _discard_size
+
; startup code
.area _CODE
ld bc, #l__COMMONMEM
ldir
; then the discard
- ld de, #s__DISCARD
- ld bc, #l__DISCARD
- ldir
+; Discard can just be linked in but is next to the buffers
+; ld de, #s__DISCARD
+; ld bc, #l__DISCARD
+; ldir
; then zero the data area
ld hl, #s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
ldir
-
-; TODO: Move the common into the other bank, pain as we may well have
-; code in low bank and __COMMON packed in high. Needs to be in
-; .COMMONMEM and map the other page low
-;
+; Zero buffers area
+ ld hl, #s__BUFFERS
+ ld de, #s__BUFFERS + 1
+ ld bc, #l__BUFFERS - 1
+ ld (hl), #0
+ ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop
+
+ .area _DISCARD
+_discard_size:
+ .dw l__DISCARD
-mwxuy
-i fuzix.ihx
-b _CODE=0x0100
--b _DISCARD=0xD000
-b _COMMONMEM=0xE800
-l z80
platform-trs80/crt0.rel
U_DATA .equ 0xE800 ; (this is struct u_data from kernel.h)
U_DATA__TOTALSIZE .equ 0x200 ; 256+256 (we don't save istack)
-U_DATA_STASH .equ 0x7D00 ; BD00-BEFF
+U_DATA_STASH .equ 0x7E00 ; 7E00-7FFF
PROGBASE .equ 0x0000
PROGLOAD .equ 0x0100
Z80_TYPE .equ 1
+
+NBUFS .equ 10
uint8_t vtattr_cap;
+struct blkbuf *bufpool_end = bufpool + NBUFS;
+
/* On idle we spin checking for the terminals. Gives us more responsiveness
for the polled ports */
void platform_idle(void)
timer_interrupt();
}
+/*
+ * Once we are about to load init we can throw the boot code away
+ * and convert it into disk cache. This gets us 7 or so buffer
+ * back which more than doubles our cache size !
+ */
+void platform_discard(void)
+{
+ extern uint16_t discard_size;
+ bufptr bp = bufpool_end;
+
+ discard_size /= sizeof(struct blkbuf);
+
+ kprintf("%d buffers reclaimed from discard\n", discard_size);
+
+ bufpool_end += discard_size; /* Reclaim the discard space */
+
+ memset(bp, 0, discard_size * sizeof(struct blkbuf));
+ /* discard_size is in discard so it dies here */
+ for (bp = bufpool + NBUFS; bp < bufpool_end; ++bp) {
+ bp->bf_dev = NO_DEVICE;
+ bp->bf_busy = BF_FREE;
+ }
+}
+
#ifdef CONFIG_RTC
__sfr __at 0xB0 rtc_secl;
.globl s__COMMONMEM
.globl l__COMMONMEM
+ .globl _bufpool
+
.include "kernel.def"
.include "../kernel.def"
+ .area _BUFFERS
+
+_bufpool:
+ .ds BUFSIZE * NBUFS
; -----------------------------------------------------------------------------
; COMMON MEMORY BANK (0xE800 upwards)
; -----------------------------------------------------------------------------