From: Brett Gordon Date: Thu, 22 Oct 2015 06:24:08 +0000 (-0400) Subject: coco3: discard: import of more dragon code X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e967405e3d6c3b37e8051316b5a6fe179c7c2a69;p=FUZIX.git coco3: discard: import of more dragon code --- diff --git a/Kernel/platform-coco3/coco3.s b/Kernel/platform-coco3/coco3.s index cde88c35..bcd6d08b 100644 --- a/Kernel/platform-coco3/coco3.s +++ b/Kernel/platform-coco3/coco3.s @@ -19,6 +19,8 @@ .globl map_restore .globl _need_resched .globl _hz + .globl _bufpool + .globl _discard_size ; exported debugging tools .globl _trap_monitor @@ -39,6 +41,16 @@ include "kernel.def" include "../kernel09.def" + + .area .buffers + +_bufpool: + .ds BUFSIZE*NBUFS + + .area .discard +_discard_size: + .db __sectionlen_.discard__/BUFSIZE + ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK ; ----------------------------------------------------------------------------- diff --git a/Kernel/platform-coco3/config.h b/Kernel/platform-coco3/config.h index 25c891b4..52a93037 100644 --- a/Kernel/platform-coco3/config.h +++ b/Kernel/platform-coco3/config.h @@ -11,6 +11,9 @@ /* Use C helpers for usermem */ #undef CONFIG_USERMEM_C +/* Reclaim discard space for buffers */ +#define CONFIG_DYNAMIC_BUFPOOL + /* We use flexible 16K banks so use the helper */ #define CONFIG_BANK16 #define CONFIG_BANKS 4 @@ -85,4 +88,3 @@ extern unsigned char vt_map( unsigned char c ); #define MAX_BLKDEV 4 /* 2 IDE + 2 SDC */ #define DEVICE_IDE /* enable if IDE interface present */ -#define platform_discard() diff --git a/Kernel/platform-coco3/fuzix.link b/Kernel/platform-coco3/fuzix.link index 1de5531d..724436af 100644 --- a/Kernel/platform-coco3/fuzix.link +++ b/Kernel/platform-coco3/fuzix.link @@ -8,8 +8,9 @@ section .text section .text.hot section .test.unlikely section .data -section .bss +section .buffers section .discard +section .bss section .udata load 0xe000 section .common section .cpage load 0xfe00 diff --git a/Kernel/platform-coco3/kernel.def b/Kernel/platform-coco3/kernel.def index b72d5314..050260a8 100644 --- a/Kernel/platform-coco3/kernel.def +++ b/Kernel/platform-coco3/kernel.def @@ -22,4 +22,7 @@ SAM_RESTORE macro ;; asm/c shared IDE stuff IDEDATA equ 0xFF50 -IDEDATA_L equ 0xFF58 \ No newline at end of file +IDEDATA_L equ 0xFF58 + + +NBUFS equ 5 \ No newline at end of file diff --git a/Kernel/platform-coco3/main.c b/Kernel/platform-coco3/main.c index 921e7583..abd735a1 100644 --- a/Kernel/platform-coco3/main.c +++ b/Kernel/platform-coco3/main.c @@ -5,6 +5,26 @@ #include +struct blkbuf *bufpool_end = bufpool + NBUFS; + +void platform_discard(void) +{ + extern uint8_t discard_size; + bufptr bp = bufpool_end; + + kprintf("%d buffers reclaimed from discard\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; + } +} + + void platform_idle(void) { }