dragon-nx32: Raw support on DriveWire (limited to blocks)
authorTormod Volden <debian.tormod@gmail.com>
Tue, 12 May 2015 21:09:39 +0000 (23:09 +0200)
committerAlan Cox <alan@linux.intel.com>
Tue, 12 May 2015 23:05:06 +0000 (00:05 +0100)
CONFIG_LEGACY_EXEC is still left in place until floppy
driver also gets raw support.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Kernel/platform-dragon-nx32/devdw.c
Kernel/platform-dragon-nx32/drivewire.s

index 0034a7d..4d1b81d 100644 (file)
@@ -20,18 +20,26 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag)
 {
     blkno_t block;
     uint16_t dptr;
-    int ct = 0;
+    int nblock;
     int tries;
     uint8_t err;
     uint8_t *driveptr = dw_tab + minor;
-    uint8_t cmd[5];
+    uint8_t cmd[6];
     irqflags_t irq;
 
-    if(rawflag)
+    if (rawflag == 0)  {
+        dptr = (uint16_t)udata.u_buf->bf_data;
+        block = udata.u_buf->bf_blk;
+        nblock = 2;
+    } else if (rawflag == 1) {
+        if (((uint16_t)udata.u_offset|udata.u_count) & BLKMASK)
+            goto bad2;
+        dptr = (uint16_t)udata.u_base;
+        block = udata.u_offset >> 9;
+        nblock = udata.u_count >> 8;
+    } else
         goto bad2;
 
-    dptr = (uint16_t)udata.u_buf->bf_data;
-    block = udata.u_buf->bf_blk;
 
 //    kprintf("Issue command: drive %d\n", minor);
     /* maybe mimicking floppy driver more than needed? */
@@ -40,11 +48,12 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag)
     cmd[2] = (block << 1) & 0xFF;
     cmd[3] = dptr >> 8;
     cmd[4] = dptr & 0xFF;
+    cmd[5] = rawflag;
     *driveptr = minor; /* pass minor (drive number) through here for now */
         
-    while (ct < 2) {
+    while (nblock--) {
         for (tries = 0; tries < 4 ; tries++) {
-            // kprintf("dw_operation on block %d ct %d\n", block, ct);
+            // kprintf("dw_operation block %d left %d\n", block, nblock);
             irq = di(); /* for now block interrupts for whole operation */
             err = dw_operation(cmd, driveptr);
             irqrestore(irq);
@@ -58,7 +67,8 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag)
             goto bad;
         cmd[3]++;      /* Move on 256 bytes in the buffer */
         cmd[2]++;      /* Next sector for 2nd block */
-        ct++;
+        if (cmd[2] == 0)
+            cmd[1]++;
     }
     return 1;
 bad:
index babebeb..f1718ed 100644 (file)
        .globl _dw_operation
        .globl _dw_reset
 
-       .area .text
+       ; imported
+       .globl map_process_always
+       .globl map_kernel
+
+       .area .common
 
 _dw_reset:
        ; maybe reinitalise PIA here?
@@ -20,9 +24,13 @@ _dw_reset:
 _dw_operation:
        pshs y
        ; get parameters from C, X points to cmd packet
-       ldy 4,s         ; driveptr
+       ldy 4,s         ; driveptr (dw_tab in .bss so kernel bank)
        lda ,y          ; for now, contains minor = drive number directly
-       ldb ,x          ; write flag
+       ldb 5,x         ; rawflag
+       pshs b
+       beq @nomap
+       jsr map_process_always
+@nomap ldb ,x          ; write flag
        ; buffer location into Y
        ldy 3,x
        ; sector number into X
@@ -35,9 +43,12 @@ _dw_operation:
 @done  bcs @err
        bne @err
        ldx #0
+@fin   tst ,s+
+       beq @ret
+       jsr map_kernel
 @ret   puls y,pc
 @err   ldx #0xFFFF
-       bra @ret
+       bra @fin
 
 ; Write a sector to the DriveWire server
 ; Drive number in A, sector number in X, buffer location in Y