nc100: first cut at fixing breakage when a read crosses a bank boundary
authorAlan Cox <alan@linux.intel.com>
Sat, 3 Jun 2017 21:46:39 +0000 (22:46 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 3 Jun 2017 21:46:39 +0000 (22:46 +0100)
Kernel/platform-nc100/devrd.c
Kernel/platform-nc100/devrd.h
Kernel/platform-nc100/nc100.s

index 305e21b..fe7b36e 100644 (file)
@@ -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;
index 6320b26..0b8d49a 100644 (file)
@@ -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__ */
 
index 7266250..98b4c1f 100644 (file)
@@ -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