From 94a1d5c540826ebe79e61cf31bdb2e7249154cbf Mon Sep 17 00:00:00 2001 From: Will Sowerbutts Date: Fri, 6 Jan 2017 19:02:52 +0000 Subject: [PATCH] Kernel: zeta-v2: Change to dynamic bufpool --- Kernel/platform-zeta-v2/config.h | 6 +++--- Kernel/platform-zeta-v2/crt0.s | 7 ++++--- Kernel/platform-zeta-v2/discard.c | 2 ++ Kernel/platform-zeta-v2/main.c | 15 +++++++++++++++ Kernel/platform-zeta-v2/zeta-v2.s | 8 ++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Kernel/platform-zeta-v2/config.h b/Kernel/platform-zeta-v2/config.h index 0e7cbebe..76b11550 100644 --- a/Kernel/platform-zeta-v2/config.h +++ b/Kernel/platform-zeta-v2/config.h @@ -24,6 +24,7 @@ #define PROGBASE 0x0000 /* also data base */ #define PROGLOAD 0x0100 /* also data base */ #define PROGTOP 0xF000 /* Top of program, base of U_DATA copy */ +#define KERNTOP 0xF000 /* Top of kernel (first 3 banks), base of shared bank */ #define PROC_SIZE 64 /* Memory needed per process */ /* WRS: this is probably wrong -- we want to swap the full 64K minus the common code */ @@ -38,7 +39,8 @@ #define BOOTDEVICENAMES "hd#,fd,,rd" //#define SWAPDEV (256 + 1) /* Device for swapping */ -#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 zeta-v2.s */ #define NMOUNTS 4 /* Number of mounts at a time */ #define MAX_BLKDEV 4 /* 1 ROM disk, 1 RAM disk, 1 floppy, 1 PPIDE */ @@ -85,5 +87,3 @@ #endif #define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */ - -#define platform_discard() diff --git a/Kernel/platform-zeta-v2/crt0.s b/Kernel/platform-zeta-v2/crt0.s index dc1cf1c2..285a8c42 100644 --- a/Kernel/platform-zeta-v2/crt0.s +++ b/Kernel/platform-zeta-v2/crt0.s @@ -18,9 +18,10 @@ .area _HEAP ; note that areas below here may be overwritten by the heap at runtime, so ; put initialisation stuff in here - .area _INITIALIZER - .area _GSINIT - .area _GSFINAL + .area _BUFFERS ; _BUFFERS grows to consume all before it (up to KERNTOP) + .area _INITIALIZER ; binman copies this to the right place for us + .area _GSINIT ; unused + .area _GSFINAL ; unused .area _DISCARD .area _COMMONMEM diff --git a/Kernel/platform-zeta-v2/discard.c b/Kernel/platform-zeta-v2/discard.c index ce78eff8..dbf7caad 100644 --- a/Kernel/platform-zeta-v2/discard.c +++ b/Kernel/platform-zeta-v2/discard.c @@ -17,6 +17,8 @@ void init_hardware_c(void) { ramsize = 512; procmem = 512 - 64 - (DEV_RD_RAM_PAGES<<4); + /* zero out the initial bufpool */ + memset(bufpool, 0, (char*)bufpool_end - (char*)bufpool); } void pagemap_init(void) diff --git a/Kernel/platform-zeta-v2/main.c b/Kernel/platform-zeta-v2/main.c index 66aa345f..3832bd12 100644 --- a/Kernel/platform-zeta-v2/main.c +++ b/Kernel/platform-zeta-v2/main.c @@ -8,6 +8,21 @@ #endif 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++; + } + + kprintf("platform_discard: bufpool=%x, bufpool_end=%x\n", bufpool, bufpool_end); +} void platform_idle(void) { diff --git a/Kernel/platform-zeta-v2/zeta-v2.s b/Kernel/platform-zeta-v2/zeta-v2.s index 03ba17f6..2a64dee3 100644 --- a/Kernel/platform-zeta-v2/zeta-v2.s +++ b/Kernel/platform-zeta-v2/zeta-v2.s @@ -17,6 +17,7 @@ .globl mpgsel_cache .globl _kernel_pages .globl _trap_reboot + .globl _bufpool ; imported symbols .globl _ramsize @@ -44,6 +45,13 @@ CONSOLE_DIVISOR .equ (1843200 / (16 * CONSOLE_RATE)) CONSOLE_DIVISOR_HIGH .equ (CONSOLE_DIVISOR >> 8) CONSOLE_DIVISOR_LOW .equ (CONSOLE_DIVISOR & 0xFF) +;========================================================================= +; Buffers +;========================================================================= + .area _BUFFERS +_bufpool: + .ds (BUFSIZE * 4) ; adjust NBUFS in config.h in line with this + ;========================================================================= ; Initialization code ;========================================================================= -- 2.34.1