coco3: discard: import of more dragon code
authorBrett Gordon <beretta42@gmail.com>
Thu, 22 Oct 2015 06:24:08 +0000 (02:24 -0400)
committerBrett Gordon <beretta42@gmail.com>
Thu, 22 Oct 2015 06:24:08 +0000 (02:24 -0400)
Kernel/platform-coco3/coco3.s
Kernel/platform-coco3/config.h
Kernel/platform-coco3/fuzix.link
Kernel/platform-coco3/kernel.def
Kernel/platform-coco3/main.c

index cde88c3..bcd6d08 100644 (file)
@@ -19,6 +19,8 @@
            .globl map_restore
            .globl _need_resched
            .globl _hz
+           .globl _bufpool
+           .globl _discard_size
 
             ; exported debugging tools
             .globl _trap_monitor
             include "kernel.def"
             include "../kernel09.def"
 
+
+       .area   .buffers
+
+_bufpool:
+       .ds     BUFSIZE*NBUFS
+
+       .area   .discard
+_discard_size:
+       .db     __sectionlen_.discard__/BUFSIZE
+       
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK
 ; -----------------------------------------------------------------------------
index 25c891b..52a9303 100644 (file)
@@ -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()
index 1de5531..724436a 100644 (file)
@@ -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
index b72d531..050260a 100644 (file)
@@ -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
index 921e758..abd735a 100644 (file)
@@ -5,6 +5,26 @@
 #include <devtty.h>
 
 
+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)
 {
 }