Final tweaks and TRS80 now swaps on partitions other than 0
authorAlan Cox <alan@linux.intel.com>
Tue, 6 Jan 2015 23:28:15 +0000 (23:28 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 6 Jan 2015 23:28:15 +0000 (23:28 +0000)
You can now set up a 10MB hd or similar with a mix of disk and swap, and it
also won't randomly pee on disks it doesn't own.

Kernel/include/diskgeom.h
Kernel/platform-trs80/devhd.c
Kernel/tools/trslabel.c

index e77b43a..faffec1 100644 (file)
@@ -30,18 +30,18 @@ struct diskgeom {
 /* Labelling bits needed for a CHS drive */
 struct minipart {
   struct diskgeom g;
-  uint16_t cyl[15];
-  uint8_t type[15];
+  uint16_t cyl[16];
+  uint8_t type[16];
 };
 
 /* The full entry, including the LBA offsets added by the labeller
    for use if in LBA mode. The LBAs must match the cyl pointers */
 struct minipart_lba {
   struct diskgeom g;
-  uint16_t cyl[15];
-  uint8_t type[15];
+  uint16_t cyl[16];
+  uint8_t type[16];
   uint8_t gap;
-  uint32_t lba[15];
+  uint32_t lba[16];
 };
 
 #endif
index c46bfed..c0812fd 100644 (file)
@@ -79,7 +79,7 @@ static uint8_t hd_xfer(bool is_read, uint16_t addr)
                hd_xfer_in(addr);
        else
                hd_xfer_out(addr);
-       /* Should beeturning READY, and maybe SEEKDONE */
+       /* Should be returning READY, and maybe SEEKDONE */
        return hd_status;
 }
 
@@ -231,7 +231,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 + 0x100;
 
        if (cyls >= MAX_SWAPS)
                cyls = MAX_SWAPS - 1;
index 6409560..0895f5e 100644 (file)
@@ -39,7 +39,8 @@ int main(int argc, const char *argv[]) {
   p.g.seek = 0;
   p.g.secsize = 8;
   
-  p.cyl[0] = p.g.cyl - 32;
+  p.cyl[0] = 0;        /* Must be zero */
+  p.cyl[1] = p.g.cyl - 32;
   p.type[0] = 0x55;
   p.type[1] = 0x56;