rc2014: turn on all the features for external buffers
authorAlan Cox <alan@linux.intel.com>
Sat, 6 Oct 2018 19:31:15 +0000 (20:31 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 6 Oct 2018 19:31:15 +0000 (20:31 +0100)
Kernel/platform-rc2014/Makefile
Kernel/platform-rc2014/config.h
Kernel/platform-rc2014/crt0.s
Kernel/platform-rc2014/discard.c
Kernel/platform-rc2014/fuzix.lnk
Kernel/platform-rc2014/main.c
Kernel/platform-rc2014/rc2014.s

index 15f0fd6..4a62f2f 100644 (file)
@@ -1,5 +1,5 @@
-ASRCS = crt0.s tricks.s commonmem.s rc2014.s monitor.s vfdterm.s
-CSRCS = devices.c main.c devtty.c vfd-debug.c vfd-term.c
+ASRCS = crt0.s tricks.s commonmem.s rc2014.s monitor.s vfdterm.s buffers.s
+CSRCS = devices.c main.c devtty.c vfd-debug.c vfd-term.c extbuffer.c
 CSRCS += devinput.c
 DISCARD_CSRCS = discard.c
 DISCARD_DSRCS = ../dev/devide_discard.c ../dev/ds1302_discard.c
index 19bad41..f45a124 100644 (file)
@@ -34,7 +34,9 @@ extern unsigned int swap_dev;
 #define MAX_SWAPS   16         /* We will size if from the partition */
 /* Swap will be set up when a suitably labelled partition is seen */
 #define CONFIG_DYNAMIC_SWAP
-
+/* We have lots of RAM so make better use of it for disk buffers. We grab
+   a 16K page and use it as our disk cache */
+#define CONFIG_BLKBUF_EXTERNAL
 /*
  *     When the kernel swaps something it needs to map the right page into
  *     memory using map_for_swap and then turn the user address into a
@@ -47,8 +49,7 @@ extern unsigned int swap_dev;
 #define CMDLINE        NULL  /* Location of root dev name */
 #define BOOTDEVICENAMES "hd#,fd,,rd"
 
-#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 NBUFS    32       /* 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 5       /* 1 floppy, 4 IDE */
@@ -59,19 +60,19 @@ extern unsigned int swap_dev;
 #define CONFIG_NO_CLOCK
 
 /* Floppy support */
-#define CONFIG_FLOPPY          /* #define CONFIG_FLOPPY to enable floppy */
+#undef CONFIG_FLOPPY           /* #define CONFIG_FLOPPY to enable floppy */
 /* IDE/CF support */
 #define CONFIG_IDE
 
-#define CONFIG_VFD_TERM         /* #define CONFIG_VFD_TERM to show console output on VFD display */
+#undef CONFIG_VFD_TERM         /* #define CONFIG_VFD_TERM to show console output on VFD display */
 
 #define CONFIG_INPUT                   /* Input device for joystick */
 #define CONFIG_INPUT_GRABMAX   0       /* No keyboard to grab */
 
 /* Core Networking support */
-#define CONFIG_NET
+#undef CONFIG_NET
 /* User mode uIP TCP/IP daemon */
-#define CONFIG_NET_NATIVE
+#undef CONFIG_NET_NATIVE
 
 #define NUM_DEV_TTY 2
 
index 4878de8..40f5de3 100644 (file)
@@ -18,7 +18,6 @@
         .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 ; binman copies this to the right place for us
         .area _GSINIT      ; unused
         .area _GSFINAL     ; unused
index 27abf14..d1c517b 100644 (file)
 
 void init_hardware_c(void)
 {
-//    vfd_debug_init();
 #ifdef CONFIG_VFD_TERM
     vfd_term_init();
 #endif
     ramsize = 512;
     procmem = 512 - 64;
-    /* zero out the initial bufpool */
-    memset(bufpool, 0, (char*)bufpool_end - (char*)bufpool);
 }
 
 void pagemap_init(void)
@@ -30,10 +27,10 @@ void pagemap_init(void)
        /* RC2014 512/512K has RAM in the top 512 KiB of physical memory
         * corresponding pages are 32-63 (page size is 16 KiB)
         * Pages 32-34 are used by the kernel
-        * Page 35 is the common area
-        * Pages starting from DEV_RD_START are used by RAM disk
+        * Page 35 is the common area for init
+         * Page 36 is the disk cache
         */
-       for (i = 32 + 4; i < 64; i++)
+       for (i = 32 + 5; i < 64; i++)
                pagemap_add(i);
 
        /* finally add the common area */
@@ -42,6 +39,16 @@ void pagemap_init(void)
 
 void map_init(void)
 {
+       /* Point the buffers into the 16-32K range that will be used by
+          the buffer remap. It's an ideal location because it has no
+          vectors and is low enough it will overlay only code so we never
+          worry about copying into the overlaid address space */
+       bufptr bp = bufpool;
+       uint8_t *p = (uint8_t *)0x4000;
+       while(bp < bufpool_end) {
+               bp++->__bf_data = p;
+               p += BLKSIZE;
+       }
 }
 
 /*
index 46c28c7..7706252 100644 (file)
@@ -15,6 +15,8 @@ version.rel
 lowlevel-z80.rel
 platform-rc2014/tricks.rel
 platform-rc2014/main.rel
+platform-rc2014/extbuffer.rel
+platform-rc2014/buffers.rel
 timer.rel
 kdata.rel
 platform-rc2014/devfd.rel
index ea81b6f..9740df1 100644 (file)
@@ -9,20 +9,11 @@
 #include <ds1302.h>
 
 extern unsigned char irqvector;
-struct blkbuf *bufpool_end = bufpool + NBUFS;  /* minimal for boot -- expanded after we're done with _DISCARD */
 uint8_t timermsr = 0;
 uint16_t swap_dev = 0xFFFF;
 
 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 platform_idle(void)
index 16b5ad7..6235ce5 100644 (file)
@@ -8,6 +8,9 @@
        .globl _program_vectors
        .globl map_kernel
        .globl map_process
+       .globl map_buffers
+       .globl map_buffers_user
+       .globl map_buffers_user_h
        .globl map_kernel_di
        .globl map_process_di
        .globl map_process_always
@@ -68,13 +71,6 @@ ACIA_RTS_HIGH_A      .EQU     0xD6   ; rts high, xmit interrupt disabled
 ACIA_RTS_LOW_A       .EQU     0x96   ; rts low, xmit interrupt disabled
 ;ACIA_RTS_LOW_A       .EQU     0xB6   ; rts low, xmit interrupt enabled
 
-;=========================================================================
-; Buffers
-;=========================================================================
-        .area _BUFFERS
-_bufpool:
-        .ds (BUFSIZE * 4) ; adjust NBUFS in config.h in line with this
-
 ;=========================================================================
 ; Initialization code
 ;=========================================================================
@@ -269,6 +265,26 @@ map_process_always_di:
        ld hl,#U_DATA__U_PAGE
         jr map_process_2_pophl_ret
 
+map_buffers_user:
+       push hl
+       ld hl,(U_DATA__U_PAGE)
+       ld h,#36
+       ld (_ubuffer_pages),hl
+       ld hl,(U_DATA__U_PAGE + 2)
+       ld (_ubuffer_pages + 2),hl
+       ld hl,#_ubuffer_pages
+        jr map_process_2_pophl_ret
+
+map_buffers_user_h:
+       push hl
+       ld hl,(U_DATA__U_PAGE)
+       ld (_ubuffer_pages),hl
+       ld hl,(U_DATA__U_PAGE + 2)
+       ld l,#36
+       ld (_ubuffer_pages + 2),hl
+       ld hl,#_ubuffer_pages
+        jr map_process_2_pophl_ret
+
 ;=========================================================================
 ; map_process - map process or kernel pages
 ; Inputs: page table address in HL, map kernel if HL == 0
@@ -291,6 +307,16 @@ map_kernel_di:
        ld hl,#_kernel_pages
         jr map_process_2_pophl_ret
 
+;=========================================================================
+; map_buffers - map kernel with disk buffers at 0x4000-0x7FFF
+; Inputs: none
+; Outputs: none; all registers preserved
+;=========================================================================
+map_buffers:
+       push hl
+       ld hl,#_kernelbuf_pages
+        jr map_process_2_pophl_ret
+
 ;=========================================================================
 ; map_process_2 - map process or kernel pages
 ; Inputs: page table address in HL
@@ -383,6 +409,12 @@ mpgsel_cache:
 _kernel_pages:
        .db     32,33,34,35
 
+; kernel page mapping with buffer window
+_kernelbuf_pages:
+       .db     32,36,34,35
+
+_ubuffer_pages:
+       .db     0,0,0,0
 ; memory page mapping save area for map_save/map_restore
 map_savearea:
        .db     0,0,0,0