aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-12-07 11:46:37 -0500
committerKevin O'Connor <kevin@koconnor.net>2013-12-07 12:59:45 -0500
commit302a6e82dc9e8c6f1028f98e578336aed07d8f66 (patch)
tree5796887dcff9755d8dbce6bf4e685917e73e5fa1
parentb94170cc4b6b08d03ac21e1c2390c94b7b881e7c (diff)
downloadseabios-302a6e82dc9e8c6f1028f98e578336aed07d8f66.zip
seabios-302a6e82dc9e8c6f1028f98e578336aed07d8f66.tar.gz
seabios-302a6e82dc9e8c6f1028f98e578336aed07d8f66.tar.bz2
floppy: Fix incorrect LBA to CHS translation.
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>
-rw-r--r--src/hw/floppy.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index d43b489..c5118ec 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -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);