diff options
author | Michal Soltys <soltys@ziu.info> | 2010-09-28 19:57:28 +0200 |
---|---|---|
committer | Michal Soltys <soltys@ziu.info> | 2010-10-08 12:40:51 +0200 |
commit | 81f86009696b5c7eff76e1981e967367235c5f7c (patch) | |
tree | 9f7d86b09f75877da049c9fab6321b8547255cd0 /com32/chain/utility.c | |
parent | 71485af3c0b47409fbd721d83f20fb8fcac76e42 (diff) | |
download | syslinux-81f86009696b5c7eff76e1981e967367235c5f7c.tar.gz |
com32/chain: utility's lba2chs update
This patch adds 3 modes of operation to lba2chs:
l2c_cnul - strict cylinder mode, using at most the value returned by
13h/48h or 13h/08h
l2c_cadd - allow using 1 cylinder more. Only if cylinders are less than
1024 and total drive's lba size is not on a cylinder boundary.
l2c_max - allow using any cylinder number.
Modes have effect only if CHS geometry (cbios) is valid. chain.c uses
l2c_cadd.
Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain/utility.c')
-rw-r--r-- | com32/chain/utility.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/com32/chain/utility.c b/com32/chain/utility.c index 98249529..b30042b5 100644 --- a/com32/chain/utility.c +++ b/com32/chain/utility.c @@ -27,7 +27,7 @@ void error(const char *msg) int guid_is0(const struct guid *guid) { - return !*(const uint64_t *)guid && !*((const uint64_t *)guid+1); + return !*(const uint64_t *)guid && !*((const uint64_t *)guid + 1); } void wait_key(void) @@ -48,19 +48,23 @@ void wait_key(void) } while (!cnt || (cnt < 0 && errno == EAGAIN)); } -uint32_t lba2chs(const struct disk_info *di, uint64_t lba) +uint32_t lba2chs(const struct disk_info *di, uint64_t lba, uint32_t mode) { uint32_t c, h, s, t; uint32_t cs, hs, ss; /* - * Not much reason here, but if we have no valid chs geometry, we assume + * Not much reason here, but if we have no valid CHS geometry, we assume * "typical" ones to have something to return. */ if (di->cbios) { cs = di->cyl; hs = di->head; - ss = di->sect; + ss = di->spt; + if (mode == l2c_cadd && cs < 1024 && di->lbacnt > cs*hs*ss) + cs++; + else if (mode == l2c_cmax) + cs = 1024; } else { if (di->disk & 0x80) { cs = 1024; |