Skip to content

Commit

Permalink
msx2: use dynamic buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
geijoenr committed Jun 10, 2017
1 parent 7798aba commit 6cdf69b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Kernel/platform-msx2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
/* As reported to user space - 4 banks, 16K page size */
#define CONFIG_BANKS 4

/* reclaim discarded space for buffers */
#define CONFIG_DYNAMIC_BUFPOOL

#define CONFIG_FONT6X8

/* Vt definitions */
Expand All @@ -43,9 +46,9 @@

/* Device parameters */
#define NUM_DEV_TTY 5
#define TTYSIZ 64
#define TTYSIZ 128
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
#define NBUFS 10 /* Number of block buffers */
#define NBUFS 6 /* Number of block buffers */
#define NMOUNTS 4 /* Number of mounts at a time */

#define CONFIG_SD
Expand All @@ -55,5 +58,3 @@
#define MAX_BLKDEV 1 /* Single SD drive */
#define CONFIG_RTC
//#define CONFIG_RTC_RP5C01_NVRAM

#define platform_discard()
5 changes: 5 additions & 0 deletions Kernel/platform-msx2/crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
.globl _infobits
.globl _machine_type

.globl _discard_size

; startup code @0x100
.area _CODE

Expand Down Expand Up @@ -149,3 +151,6 @@ cpfont:
stop: halt
jr stop

.area _DISCARD
_discard_size:
.dw l__DISCARD
4 changes: 2 additions & 2 deletions Kernel/platform-msx2/devmegasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ void sd_spi_txrx_sector(bool is_read)
} else {
/* kernel only */
if (is_read)
memcpy((uint8_t *)addr, (uint8_t *)MSD_RDWR, BLKSIZE);
memcpy(blk_op.addr, (uint8_t *)MSD_RDWR, BLKSIZE);
else
memcpy((uint8_t *)MSD_RDWR, (uint8_t *)addr, BLKSIZE);
memcpy((uint8_t *)MSD_RDWR, blk_op.addr, BLKSIZE);
}
sd_spi_unmap_interface();
}
Expand Down
1 change: 1 addition & 0 deletions Kernel/platform-msx2/fuzix.lnk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-mwxuy
-i fuzix.ihx
-b _CODE=0x0000
-b _BUFFERS=0xD000
-b _COMMONMEM=0xF000
-b _DISCARD=0xE000
-b _FONT=0xFA00
Expand Down
1 change: 1 addition & 0 deletions Kernel/platform-msx2/kernel.def
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Z80_TYPE .equ 1

PROGBASE .equ 0x0000
PROGLOAD .equ 0x0100
NBUFS .equ 6
26 changes: 26 additions & 0 deletions Kernel/platform-msx2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

uint16_t msxmaps;

struct blkbuf *bufpool_end = bufpool + NBUFS;

void platform_idle(void)
{
__asm
Expand Down Expand Up @@ -44,3 +46,27 @@ void platform_interrupt(void)
kbd_interrupt();
timer_interrupt();
}

/*
* 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 uint16_t discard_size;
bufptr bp = bufpool_end;

discard_size /= sizeof(struct blkbuf);

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;
}
}
5 changes: 5 additions & 0 deletions Kernel/platform-msx2/msx2.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.globl _mapslot_bank1
.globl _mapslot_bank2
.globl _need_resched
.globl _bufpool

; video driver
.globl _vtinit
Expand Down Expand Up @@ -56,6 +57,10 @@
.include "kernel.def"
.include "../kernel.def"

.area _BUFFERS

_bufpool:
.ds BUFSIZE * NBUFS
; -----------------------------------------------------------------------------
; COMMON MEMORY BANK (0xF000 upwards)
; -----------------------------------------------------------------------------
Expand Down

0 comments on commit 6cdf69b

Please sign in to comment.