trs80: fix hard disk problems
authorAlan Cox <alan@linux.intel.com>
Fri, 15 May 2015 23:32:24 +0000 (00:32 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 15 May 2015 23:32:24 +0000 (00:32 +0100)
- Sector offset was wrong so it didn't interoperate
- User mode fetched only half the sectors so execve broke on hd
- Tools replicated hd offset bug

With these fixed you can partition and run FUZIX on the hard disk device even
if set up directly or under another OS.

Swap still blows up but this doesn't appear to be an hd bug at this point

Kernel/platform-trs80/devhd.c
Kernel/platform-trs80/devhd_discard.c
Kernel/tools/trslabel.c

index 70f1188..7106415 100644 (file)
@@ -79,7 +79,7 @@ int hd_transfer(uint8_t minor, bool is_read, uint8_t rawflag)
                if (((uint16_t)udata.u_offset|udata.u_count) & BLKMASK)
                        goto bad2;
                dptr = (uint16_t)udata.u_base;
-               nblock = udata.u_count >> 9;
+               nblock = udata.u_count >> 8;
                block = udata.u_offset >> 9;
                hd_page = udata.u_page;
        } else if (rawflag == 2) {
@@ -99,7 +99,7 @@ int hd_transfer(uint8_t minor, bool is_read, uint8_t rawflag)
        hd_seccnt = 1;
 
        sector = block;
-       sector = ((sector << 1) & 0x1E) | 0x01;
+       sector = (sector << 1) & 0x1E;
 
        cyl = block >> 4;
 
index d5dd0a2..0c3615a 100644 (file)
@@ -22,7 +22,7 @@ static void hd_swapon(struct minipart *p, unsigned int d, unsigned int i)
           We need 32K per process: hardwire it here - FIX if you change
           the mapping model */
 
-       swap_dev = (d << 4) + i + 1 + 0x100;
+       swap_dev = (d << 4) + i + 1;
 
        if (cyls >= MAX_SWAPS)
                cyls = MAX_SWAPS - 1;
@@ -48,7 +48,7 @@ void hd_probe(void)
                }
                hd_seccnt = 1;
                hd_sdh = 0x80 | (dev << 3);
-               hd_secnum = 2;
+               hd_secnum = 1;
                hd_cyllo = 0;
                hd_cylhi = 0;
                hd_cmd = HDCMD_READ;
index 0895f5e..97d909a 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, const char *argv[]) {
   p.g.cyl = buf[28] | (buf[29] << 8);
   p.g.head = buf[30];
   printf("Disk is %d cylinders, %d heads\n", p.g.cyl, p.g.head);
-  p.g.sec = 16;
+  p.g.sec = 32;
   p.g.precomp = 0;
   p.g.land = p.g.cyl + 1;
   p.g.seek = 0;
@@ -46,7 +46,7 @@ int main(int argc, const char *argv[]) {
 
   /* FIXME: should fill in matching LBA bits */
 
-  if (fseek(vol, 512 + 384L, SEEK_SET) < 0) {
+  if (fseek(vol, 256 + 384L, SEEK_SET) < 0) {
     perror(argv[1]);
     exit(1);
   }