nc100: rework ram disc logic so we can get rid of legacy stuff
authorAlan Cox <alan@linux.intel.com>
Thu, 14 May 2015 20:12:41 +0000 (21:12 +0100)
committerAlan Cox <alan@linux.intel.com>
Thu, 14 May 2015 20:12:41 +0000 (21:12 +0100)
Kernel/platform-nc100/devrd.c
Kernel/platform-nc100/nc100.s

index dd12fe3..6c5674d 100644 (file)
@@ -8,6 +8,9 @@
 #include <printf.h>
 #include <devrd.h>
 
+/* 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;
 }
index fec413e..8b32d06 100644 (file)
@@ -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