[syslinux:disklib] disklib: updates to params/read/write functions
syslinux-bot for Michal Soltys
soltys at ziu.info
Wed Oct 13 08:36:46 PDT 2010
Commit-ID: f5a591bf3b23f6f5fd25871f0f319b49c42e207e
Gitweb: http://syslinux.zytor.com/commit/f5a591bf3b23f6f5fd25871f0f319b49c42e207e
Author: Michal Soltys <soltys at ziu.info>
AuthorDate: Sat, 9 Oct 2010 23:55:50 +0200
Committer: Michal Soltys <soltys at ziu.info>
CommitDate: Tue, 12 Oct 2010 00:37:17 +0200
disklib: updates to params/read/write functions
disk_get_params():
Don't bail out if we fail int13h/48h call in ebios == 1 case. Regular
CHS might still be enough.
disk_read_sectors(), disk_write_sectors():
We don't need separate cases for valid and invalid cbios with the data
prepared by the current disk_get_params() function.
Signed-off-by: Michal Soltys <soltys at ziu.info>
---
com32/lib/syslinux/disk.c | 62 +++++++++++++++++---------------------------
1 files changed, 24 insertions(+), 38 deletions(-)
diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index ddc3c5d..3585da5 100644
--- a/com32/lib/syslinux/disk.c
+++ b/com32/lib/syslinux/disk.c
@@ -77,6 +77,7 @@ int disk_get_params(int disk, struct disk_info *const diskinfo)
memset(diskinfo, 0, sizeof *diskinfo);
diskinfo->disk = disk;
+ diskinfo->bps = SECTOR;
/* Get EBIOS support */
memset(&inreg, 0, sizeof inreg);
@@ -105,18 +106,15 @@ int disk_get_params(int disk, struct disk_info *const diskinfo)
__intcall(0x13, &inreg, &outreg);
- if (outreg.eflags.l & EFLAGS_CF)
- return -1; /* this really shouldn't happen if we have ebios */
-
- diskinfo->lbacnt = eparam->lbacnt;
- if (eparam->bps)
- diskinfo->bps = eparam->bps;
- else
- diskinfo->bps = SECTOR;
- /*
- * don't think about using geometry data returned by
- * 48h, as it can differ from 08h a lot ...
- */
+ if (!(outreg.eflags.l & EFLAGS_CF)) {
+ diskinfo->lbacnt = eparam->lbacnt;
+ if (eparam->bps)
+ diskinfo->bps = eparam->bps;
+ /*
+ * don't think about using geometry data returned by
+ * 48h, as it can differ from 08h a lot ...
+ */
+ }
}
/*
* Get disk parameters the old way - really only useful for hard
@@ -191,20 +189,14 @@ void *disk_read_sectors(const struct disk_info *const diskinfo, uint64_t lba,
unsigned int c, h, s, t;
/*
* if we passed lba + count check and we get here, that means that
- * lbacnt was calculated from chs geometry, thus 32bits are perfectly
- * enough and lbacnt corresponds to cylinder boundary
+ * lbacnt was calculated from chs geometry (or faked from 1/1/1), thus
+ * 32bits are perfectly enough and lbacnt corresponds to cylinder
+ * boundary
*/
- if (!diskinfo->cbios) {
- /* We failed to get the geometry */
- s = 1;
- h = 0;
- c = 0;
- } else {
- s = (lba % diskinfo->spt) + 1;
- t = lba / diskinfo->spt;
- h = t % diskinfo->head;
- c = t / diskinfo->head;
- }
+ s = (lba % diskinfo->spt) + 1;
+ t = lba / diskinfo->spt;
+ h = t % diskinfo->head;
+ c = t / diskinfo->head;
inreg.eax.b[0] = count;
inreg.eax.b[1] = 0x02; /* Read */
@@ -267,20 +259,14 @@ int disk_write_sectors(const struct disk_info *const diskinfo, uint64_t lba,
unsigned int c, h, s, t;
/*
* if we passed lba + count check and we get here, that means that
- * lbacnt was calculated from chs geometry, thus 32bits are perfectly
- * enough and lbacnt corresponds to cylinder boundary
+ * lbacnt was calculated from chs geometry (or faked from 1/1/1), thus
+ * 32bits are perfectly enough and lbacnt corresponds to cylinder
+ * boundary
*/
- if (!diskinfo->cbios) {
- /* We failed to get the geometry */
- s = 1;
- h = 0;
- c = 0;
- } else {
- s = (lba % diskinfo->spt) + 1;
- t = lba / diskinfo->spt;
- h = t % diskinfo->head;
- c = t / diskinfo->head;
- }
+ s = (lba % diskinfo->spt) + 1;
+ t = lba / diskinfo->spt;
+ h = t % diskinfo->head;
+ c = t / diskinfo->head;
inreg.eax.b[0] = count;
inreg.eax.b[1] = 0x03; /* Write */
More information about the Syslinux-commits
mailing list