Actually read data into user memory, rather than scribbling randomly across the
authorDavid Given <dg@cowlark.com>
Tue, 24 Apr 2018 19:01:27 +0000 (21:01 +0200)
committerDavid Given <dg@cowlark.com>
Tue, 24 Apr 2018 19:01:27 +0000 (21:01 +0200)
address space (which never works).

Kernel/platform-amstradnc/devfd.c

index 4360bae..1b89a87 100644 (file)
@@ -92,17 +92,20 @@ static int devfd_transfer(bool is_read, uint8_t is_raw)
 {
     int ct = 0;
     int tries;
-    int blocks = udata.u_nblock;
-    uint16_t lba = udata.u_block;
+    int blocks;
+    uint16_t lba;
+
+    /* This must happen first, as it updates the udata variables. */
+    if (is_raw && d_blkoff(BLKSHIFT))
+        return -1;
+    blocks = udata.u_nblock;
+    lba = udata.u_block;
 
     // kprintf("[%s %d @ %x : %d:%x]\n", is_read ? "read" : "write",
     //     blocks, lba, is_raw, udata.u_dptr);
     // if (!is_read)
     //     return blocks << BLKSHIFT;
 
-    if (is_raw && d_blkoff(BLKSHIFT))
-        return -1;
-
     fd_select(0);
     fd765_is_user = is_raw;
     fd765_buffer = udata.u_dptr;