[syslinux:disklib] disklib: make CHS calculation match core/fs/diskio.c

syslinux-bot for Michal Soltys soltys at ziu.info
Wed Oct 13 08:36:47 PDT 2010


Commit-ID:  9c8db7560e2dc83d1191bb2f90b4d4d0ae3d37d6
Gitweb:     http://syslinux.zytor.com/commit/9c8db7560e2dc83d1191bb2f90b4d4d0ae3d37d6
Author:     Michal Soltys <soltys at ziu.info>
AuthorDate: Wed, 13 Oct 2010 10:57:36 +0200
Committer:  Michal Soltys <soltys at ziu.info>
CommitDate: Wed, 13 Oct 2010 10:57:36 +0200

disklib: make CHS calculation match core/fs/diskio.c

Signed-off-by: Michal Soltys <soltys at ziu.info>


---
 com32/lib/syslinux/disk.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index 3585da5..d6409af 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);



More information about the Syslinux-commits mailing list