From: Will Sowerbutts Date: Fri, 6 Jan 2017 18:53:44 +0000 (+0000) Subject: Kernel: p112: Change to dynamic bufpool X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2fb7650e25953b5b4f2b7f27851c25b3ccd6177a;p=FUZIX.git Kernel: p112: Change to dynamic bufpool --- diff --git a/Kernel/platform-p112/config.h b/Kernel/platform-p112/config.h index cdc050d8..92ded8fb 100644 --- a/Kernel/platform-p112/config.h +++ b/Kernel/platform-p112/config.h @@ -25,6 +25,7 @@ #define PROGBASE 0x0000 /* also data base */ #define PROGLOAD 0x0100 /* also data base */ #define PROGTOP 0xF800 /* Top of program, base of U_DATA copy */ +#define KERNTOP 0xF000 /* Kernel has lower 60KB */ #define PROC_SIZE 64 /* Memory needed per process */ /* We need a tidier way to do this from the loader */ @@ -35,7 +36,9 @@ #define NUM_DEV_TTY 5 #define TTYDEV (512+1) /* System console (used by kernel, init) */ -#define NBUFS 10 /* Number of block buffers */ + +#define CONFIG_DYNAMIC_BUFPOOL /* we expand bufpool to overwrite the _DISCARD segment at boot */ +#define NBUFS 4 /* Number of block buffers, keep in line with space reserved in p112.s */ #define NMOUNTS 4 /* Number of mounts at a time */ /* Hardware parameters */ @@ -62,5 +65,3 @@ /* We have the P112 floppy controller */ #define CONFIG_P112_FLOPPY - -#define platform_discard() diff --git a/Kernel/platform-p112/crt0.s b/Kernel/platform-p112/crt0.s index e77a5473..28c4b1ce 100644 --- a/Kernel/platform-p112/crt0.s +++ b/Kernel/platform-p112/crt0.s @@ -17,6 +17,7 @@ .area _HEAP ; note that areas below here may be overwritten by the heap at runtime, so ; put initialisation stuff in here + .area _BUFFERS ; _BUFFERS grows to consume all before it (up to KERNTOP) .area _INITIALIZER .area _GSINIT .area _GSFINAL diff --git a/Kernel/platform-p112/discard.c b/Kernel/platform-p112/discard.c index 8551cbd6..70348630 100644 --- a/Kernel/platform-p112/discard.c +++ b/Kernel/platform-p112/discard.c @@ -15,6 +15,8 @@ void init_hardware_c(void) { ramsize = 1024; procmem = 1024 - 64 - (DEV_RD_RAM_PAGES<<2); + /* zero out the initial bufpool */ + memset(bufpool, 0, (char*)bufpool_end - (char*)bufpool); } void pagemap_init(void) diff --git a/Kernel/platform-p112/main.c b/Kernel/platform-p112/main.c index 30883a3b..2d7edc9f 100644 --- a/Kernel/platform-p112/main.c +++ b/Kernel/platform-p112/main.c @@ -10,6 +10,19 @@ uint16_t ramtop = PROGTOP; extern unsigned char irqvector; +struct blkbuf *bufpool_end = bufpool + NBUFS; /* minimal for boot -- expanded after we're done with _DISCARD */ + +void platform_discard(void) +{ + while(bufpool_end < (struct blkbuf*)(KERNTOP - sizeof(struct blkbuf))){ + memset(bufpool_end, 0, sizeof(struct blkbuf)); +#if BF_FREE != 0 + bufpool_end->bf_busy = BF_FREE; /* redundant when BF_FREE == 0 */ +#endif + bufpool_end->bf_dev = NO_DEVICE; + bufpool_end++; + } +} void z180_timer_interrupt(void) { diff --git a/Kernel/platform-p112/p112.s b/Kernel/platform-p112/p112.s index 68cd2ec3..73d800aa 100644 --- a/Kernel/platform-p112/p112.s +++ b/Kernel/platform-p112/p112.s @@ -13,6 +13,7 @@ .globl outcharhex .globl platform_interrupt_all .globl _trap_reboot + .globl _bufpool ; imported symbols .globl z180_init_hardware @@ -24,6 +25,13 @@ .include "../cpu-z180/z180.def" .include "../kernel.def" +; ----------------------------------------------------------------------------- +; Buffers +; ----------------------------------------------------------------------------- + .area _BUFFERS +_bufpool: + .ds (BUFSIZE * 4) ; adjust NBUFS in config.h in line with this + ; ----------------------------------------------------------------------------- ; Initialisation code ; -----------------------------------------------------------------------------