This gets me another 7 buffers on my build.
OS_BANK equ 0 ; value from include/kernel.h
EAGAIN equ 11 ; value from include/kernel.h
+
+
+; Keep in sync with struct blkbuf
+BUFSIZE equ 521
/* Permit large I/O requests to bypass cache and go direct to userspace */
#define CONFIG_LARGE_IO_DIRECT
+/* Reclaim the discard space for buffers */
+#define CONFIG_DYNAMIC_BUFPOOL
+
#define MAX_BLKDEV 3 /* 2 IDE drives + 1 SPI */
#define SD_DRIVE_COUNT 1 /* Could be higher with multiple CS used */
#define DEVICE_IDE /* enable if IDE interface present */
#define NDEVS 2 /* Devices 0..NDEVS-1 are capable of being mounted */
/* (add new mountable devices to beginning area.) */
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
-#define NBUFS 6 /* Number of block buffers */
+#define NBUFS 5 /* Number of block buffers at boot time */
#define NMOUNTS 2 /* Number of mounts at a time */
#define swap_map(x) ((uint8_t *)(x))
-#define platform_discard()
+/* Remember to update platform-dragon-nx32/kernel.defs to match */
jsr _fuzix_main
orcc #0x10
stop: bra stop
-
; common Dragon platform
;
- .module dragon
-
- ; exported
- .globl _mpi_present
- .globl _mpi_set_slot
- .globl _cart_hash
- .globl _cart_analyze_hdb
- .globl _hdb_offset
- .globl _hdb_id
- .globl _hdb_port
- .globl _hdb_timeout
-
- ; imported
- .globl unix_syscall_entry
- .globl fd_nmi_handler
- .globl size_ram
- .globl null_handler
- .globl _vid256x192
- .globl _vtoutput
-
- ; exported debugging tools
- .globl _trap_monitor
- .globl _trap_reboot
- .globl outchar
- .globl _di
- .globl _ei
- .globl _irqrestore
-
- include "kernel.def"
- include "../kernel09.def"
-
-
- .area .vectors
+ .module dragon
+
+ ; exported
+ .globl _mpi_present
+ .globl _mpi_set_slot
+ .globl _cart_hash
+ .globl _cart_analyze_hdb
+ .globl _hdb_offset
+ .globl _hdb_id
+ .globl _hdb_port
+ .globl _hdb_timeout
+ .globl _bufpool
+ .globl _discard_size
+
+ ; imported
+ .globl unix_syscall_entry
+ .globl fd_nmi_handler
+ .globl size_ram
+ .globl null_handler
+ .globl _vid256x192
+ .globl _vtoutput
+
+ ; exported debugging tools
+ .globl _trap_monitor
+ .globl _trap_reboot
+ .globl outchar
+ .globl _di
+ .globl _ei
+ .globl _irqrestore
+
+ include "kernel.def"
+ include "../kernel09.def"
+
+
+ .area .vectors
;
; At 0x100 as required by the Dragon ROM
;
- jmp badswi_handler ; 0x100
- jmp badswi_handler ; 0x103
- jmp unix_syscall_entry ; 0x106
- jmp fd_nmi_handler ; 0x109
- jmp interrupt_handler ; 0x10C
- jmp firq_handler ; 0x10F
+ jmp badswi_handler ; 0x100
+ jmp badswi_handler ; 0x103
+ jmp unix_syscall_entry ; 0x106
+ jmp fd_nmi_handler ; 0x109
+ jmp interrupt_handler ; 0x10C
+ jmp firq_handler ; 0x10F
+
+ .area .buffers
+ ;
+ ; We use the linker to place these just below
+ ; the discard area
+ ;
+_bufpool:
+ .ds BUFSIZE*NBUFS
+
+ ; And expose the discard buffer count to C - but in discard
+ ; so we can blow it away and precomputed at link time
+ .area .discard
+_discard_size:
+ .db __sectionlen_.discard__/BUFSIZE
.area .text
_trap_reboot:
orcc #0x10
clr 0xFFBE
+ clr 0x0071
jmp [0xFFFE]
_trap_monitor:
section .vectors load 0x0100
section .start load 0x1c00
section .common
-section .text2
+section .text
+section .buffers
section .discard
section .udata load 0x7D00
-section .text load 0x8010
+section .text2 load 0x8010
section .bss high 0xFC00
section .data
section .videodata
PROGBASE equ 0x8000 ; programs and data start here
+NBUFS equ 5
+
; Have these defined so that lowlevel-6809.s can be used as-is
SAM_USER macro
endm
uint8_t carttype[4];
uint16_t cartaddr[4];
uint8_t bootslot = 0;
+struct blkbuf *bufpool_end = bufpool + NBUFS;
void platform_idle(void)
{
{
}
+/*
+ * Once we are about to load init we can throw the boot code away
+ * and convert it into disk cache. This gets us 7 or so buffer
+ * back which more than doubles our cache size !
+ */
+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; /* Reclaim the discard space */
+
+ memset(bp, 0, discard_size * sizeof(struct blkbuf));
+ /* discard_size is in discard so it dies here */
+ for (bp = bufpool + NBUFS; bp < bufpool_end; ++bp) {
+ bp->bf_dev = NO_DEVICE;
+ bp->bf_busy = BF_FREE;
+ }
+}