]> xenbits.xensource.com Git - seabios.git/commitdiff
floppy: Fix incorrect LBA to CHS translation.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 7 Dec 2013 16:46:37 +0000 (11:46 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 7 Dec 2013 17:59:45 +0000 (12:59 -0500)
The floppy LBA to CHS translation was incorrect for the last sector of
a given cylinder.  This wasn't a problem under QEMU as it came to the
same results anyway, but it causes errors of real floppy controllers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/floppy.c

index d43b4893bc0b3e08853b3555db08b7c1cae079f0..c5118ec76c458c3daf48e6dc18657bb6cebce586 100644 (file)
@@ -496,11 +496,10 @@ static struct chs_s
 lba2chs(struct disk_op_s *op)
 {
     struct chs_s res = { };
-    u32 lba = op->lba;
 
-    u32 tmp = lba + 1;
+    u32 tmp = op->lba;
     u16 nls = GET_GLOBALFLAT(op->drive_gf->lchs.sector);
-    res.sector = tmp % nls;
+    res.sector = (tmp % nls) + 1;
 
     tmp /= nls;
     u16 nlh = GET_GLOBALFLAT(op->drive_gf->lchs.head);