summaryrefslogtreecommitdiff
path: root/com32/lib
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2010-10-09 23:55:50 +0200
committerMichal Soltys <soltys@ziu.info>2010-10-12 00:37:17 +0200
commitf5a591bf3b23f6f5fd25871f0f319b49c42e207e (patch)
tree631ad5ce0a1fa1aa32637fbb65908e84563a8e42 /com32/lib
parent0df48d45f6560954d3b71a82ea84c669db9b6ae9 (diff)
downloadsyslinux-f5a591bf3b23f6f5fd25871f0f319b49c42e207e.tar.gz
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@ziu.info>
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/syslinux/disk.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index ddc3c5d4..3585da58 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 */