From: Alan Cox Date: Thu, 14 May 2015 20:12:41 +0000 (+0100) Subject: nc100: rework ram disc logic so we can get rid of legacy stuff X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1cafceb2091dcea136fc729ed50c803411dbf5ee;p=FUZIX.git nc100: rework ram disc logic so we can get rid of legacy stuff --- diff --git a/Kernel/platform-nc100/devrd.c b/Kernel/platform-nc100/devrd.c index dd12fe39..6c5674d0 100644 --- a/Kernel/platform-nc100/devrd.c +++ b/Kernel/platform-nc100/devrd.c @@ -8,6 +8,9 @@ #include #include +/* Kernel page mapping */ +static const uint8_t kmap[] = { 0x83, 0x84, 0x85 }; + static int rd_transfer(bool is_read, uint8_t rawflag) { blkno_t block; @@ -16,8 +19,10 @@ static int rd_transfer(bool is_read, uint8_t rawflag) int dlen; int ct = 0; int map; + const uint8_t *p; if(rawflag) { + p = (const uint8_t *)&udata.u_page; dlen = udata.u_count; dptr = (uint16_t)udata.u_base; if ((dlen|udata.u_offset) & BLKMASK) { @@ -26,8 +31,8 @@ static int rd_transfer(bool is_read, uint8_t rawflag) } block = udata.u_offset >> 9; block_xfer = dlen >> 9; - map = 1; } else { /* rawflag == 0 */ + p = kmap; dlen = 512; dptr = (uint16_t)udata.u_buf->bf_data; block = udata.u_buf->bf_blk; @@ -37,9 +42,12 @@ static int rd_transfer(bool is_read, uint8_t rawflag) block += 2*320; /* ramdisc starts at 320K in */ while (ct < block_xfer) { + /* Pass the page to map for the data */ + map = p[(dptr >> 14)]; rd_memcpy(is_read, map, dptr, block); block++; ct++; + dptr += 512; } return ct; } diff --git a/Kernel/platform-nc100/nc100.s b/Kernel/platform-nc100/nc100.s index fec413ed..8b32d06d 100644 --- a/Kernel/platform-nc100/nc100.s +++ b/Kernel/platform-nc100/nc100.s @@ -263,30 +263,15 @@ outcharw: ; ; Disk helper ; -; FIXME: raw mode only works for aligned cases. Should probably just drop it -; _rd_memcpy: push ix ld ix, #0 add ix, sp - ; 4(ix) = is_read, 5(ix) = map, 6-7(ix) = dptr, 8-9(ix) = block + ; 4(ix) = is_read, 5(ix) = dptr page 6-7(ix) = dptr, 8-9(ix) = block ld l, 6(ix) ld h, 7(ix) ld c, 5(ix) ld e, 8(ix) ld d, 9(ix) - ld a, c ; We want 0 or 3 for the bank effect - add a - add c - ld c, a - ld a, h - and #0xC0 ; bank bits - rlca ; into 0-1 - rlca - add #0x83 ; kernel base - cp #0x86 ; common ?? - jr z, rd_nomod - add c -rd_nomod: ld c, a ; C is now the bank code for dptr ld a, h and #0x3F ; Remove bank bits from H or #0x80 ; Will be at 0x8000