From: Alan Cox Date: Sat, 3 Jun 2017 21:46:39 +0000 (+0100) Subject: nc100: first cut at fixing breakage when a read crosses a bank boundary X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=038ec99bb7b294958eff82548a62ea8e617b9b74;p=FUZIX.git nc100: first cut at fixing breakage when a read crosses a bank boundary --- diff --git a/Kernel/platform-nc100/devrd.c b/Kernel/platform-nc100/devrd.c index 305e21b2..fe7b36e5 100644 --- a/Kernel/platform-nc100/devrd.c +++ b/Kernel/platform-nc100/devrd.c @@ -29,9 +29,15 @@ static int rd_transfer(bool is_read, uint8_t rawflag) dptr = (uint16_t)udata.u_dptr; while (ct < udata.u_nblock) { + uint16_t len; /* Pass the page to map for the data */ map = p[(dptr >> 14)]; - rd_memcpy(is_read, map, dptr, udata.u_block); + len = 0x4000 - (dptr & 0x3FFF); + if (len >= BLKSIZE) + rd_memcpy(is_read, map, dptr, udata.u_block, BLKSIZE, 0, 0); + else + rd_memcpy(is_read, map, dptr, udata.u_block, len, + p[(dptr >> 14) + 1], BLKSIZE - len); udata.u_block++; ct++; dptr += BLKSIZE; diff --git a/Kernel/platform-nc100/devrd.h b/Kernel/platform-nc100/devrd.h index 6320b269..0b8d49a5 100644 --- a/Kernel/platform-nc100/devrd.h +++ b/Kernel/platform-nc100/devrd.h @@ -7,7 +7,8 @@ int rd_write(uint8_t minor, uint8_t rawflag, uint8_t flag); int rd_open(uint8_t minor, uint16_t flag); /* asm banking helper */ -void rd_memcpy(uint8_t isread, uint8_t map, uint16_t dptr, uint16_t block); +void rd_memcpy(uint8_t isread, uint8_t map, uint16_t dptr, uint16_t block, + uint16_t len, uint8_t map2, uint16_t len2); #endif /* __DEVRD_DOT_H__ */ diff --git a/Kernel/platform-nc100/nc100.s b/Kernel/platform-nc100/nc100.s index 72662504..98b4c1fd 100644 --- a/Kernel/platform-nc100/nc100.s +++ b/Kernel/platform-nc100/nc100.s @@ -366,12 +366,13 @@ outcharw: ret ; -; Disk helper - FIXME should be IRQ safe nowdays +; Disk helper - FIXME - do we need the di/ei still ; _rd_memcpy: push ix ld ix, #0 add ix, sp ; 4(ix) = is_read, 5(ix) = dptr page 6-7(ix) = dptr, 8-9(ix) = block + ; 10-11(ix) = len, 12(ix) = map2, 13-14(ix) = len2 ld l, 6(ix) ld h, 7(ix) ld c, 5(ix) @@ -410,8 +411,24 @@ _rd_memcpy: push ix ; ; All mapped, and then its simple ; -rd_write: ld bc, #512 +rd_write: ld c, 10(ix) + ld b, 11(ix) ldir + + ld a, 12(ix) ; second page map or 0 = none + or a + jr z, rd_done ; usual case + out (0x12) ,a + ld c, 13(ix) + ld b, 14(ix) + ld a, 4(ix) + or a + jr z, rd_part2 + ld hl, #0x8000 + jr copy_part2 +rd_part2: ld de, #0x8000 +copy_part2: ldir +rd_done: call map_kernel ; map the kernel and return ei pop ix