aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2010-10-13 10:57:36 +0200
committerMichal Soltys <soltys@ziu.info>2010-10-13 10:57:36 +0200
commit9c8db7560e2dc83d1191bb2f90b4d4d0ae3d37d6 (patch)
tree3a511b96aa4f81a355d33e600353417288e43d9d
parentf5a591bf3b23f6f5fd25871f0f319b49c42e207e (diff)
downloadsyslinux-disklib.tar.gz
syslinux-disklib.tar.xz
syslinux-disklib.zip
disklib: make CHS calculation match core/fs/diskio.cdisklib
Signed-off-by: Michal Soltys <soltys@ziu.info>
-rw-r--r--com32/lib/syslinux/disk.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index 3585da58..d6409af6 100644
--- a/com32/lib/syslinux/disk.c
+++ b/com32/lib/syslinux/disk.c
@@ -193,15 +193,15 @@ void *disk_read_sectors(const struct disk_info *const diskinfo, uint64_t lba,
* 32bits are perfectly enough and lbacnt corresponds to cylinder
* boundary
*/
- s = (lba % diskinfo->spt) + 1;
+ s = lba % diskinfo->spt;
t = lba / diskinfo->spt;
h = t % diskinfo->head;
c = t / diskinfo->head;
inreg.eax.b[0] = count;
inreg.eax.b[1] = 0x02; /* Read */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = ((c >> 2) & 0xc0u) | s;
+ inreg.ecx.b[1] = c;
+ inreg.ecx.b[0] = ((c & 0x300) >> 2) | (s+1);
inreg.edx.b[1] = h;
inreg.edx.b[0] = diskinfo->disk;
inreg.ebx.w[0] = OFFS(buf);
@@ -263,15 +263,15 @@ int disk_write_sectors(const struct disk_info *const diskinfo, uint64_t lba,
* 32bits are perfectly enough and lbacnt corresponds to cylinder
* boundary
*/
- s = (lba % diskinfo->spt) + 1;
+ s = lba % diskinfo->spt;
t = lba / diskinfo->spt;
h = t % diskinfo->head;
c = t / diskinfo->head;
inreg.eax.b[0] = count;
inreg.eax.b[1] = 0x03; /* Write */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = ((c >> 2) & 0xc0u) | s;
+ inreg.ecx.b[1] = c;
+ inreg.ecx.b[0] = ((c & 0x300) >> 2) | (s+1);
inreg.edx.b[1] = h;
inreg.edx.b[0] = diskinfo->disk;
inreg.ebx.w[0] = OFFS(buf);