aboutsummaryrefslogtreecommitdiffstats
path: root/com32/chain
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2011-03-09 00:15:36 +0100
committerMichal Soltys <soltys@ziu.info>2011-03-09 00:15:36 +0100
commit4bcdb24bdb463e8b5cdf5d54a950b5e82776874b (patch)
tree849968aa5aca20220e6de3566e6d1775f1d26936 /com32/chain
parentb6d27b9550fdf166b7cb185f39db01832a72a066 (diff)
downloadsyslinux-4bcdb24bdb463e8b5cdf5d54a950b5e82776874b.tar.gz
syslinux-4bcdb24bdb463e8b5cdf5d54a950b5e82776874b.tar.xz
syslinux-4bcdb24bdb463e8b5cdf5d54a950b5e82776874b.zip
com32/chain: modify lba2chs() towards using disk_chs type
Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain')
-rw-r--r--com32/chain/chain.c12
-rw-r--r--com32/chain/mangle.c9
-rw-r--r--com32/chain/utility.c6
-rw-r--r--com32/chain/utility.h2
4 files changed, 13 insertions, 16 deletions
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index 2fe65c0f..6a028a46 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -416,8 +416,8 @@ static int setup_handover(const struct part_iter *iter,
len = ~0u;
if (iter->di.lbacnt < len)
len = (uint32_t)iter->di.lbacnt;
- *(uint32_t *)ha->start = lba2chs(&iter->di, 0, l2c_cadd);
- *(uint32_t *)ha->end = lba2chs(&iter->di, len - 1, l2c_cadd);
+ lba2chs(&ha->start, &iter->di, 0, l2c_cadd);
+ lba2chs(&ha->end, &iter->di, len - 1, l2c_cadd);
ha->active_flag = 0x80;
ha->ostype = 0xDA; /* "Non-FS Data", anything is good here though ... */
ha->start_lba = 0;
@@ -435,8 +435,8 @@ static int setup_handover(const struct part_iter *iter,
error("Could not build GPT hand-over record!\n");
goto bail;
}
- *(uint32_t *)ha->start = lba2chs(&iter->di, gp->lba_first, l2c_cadd);
- *(uint32_t *)ha->end = lba2chs(&iter->di, gp->lba_last, l2c_cadd);
+ lba2chs(&ha->start, &iter->di, gp->lba_first, l2c_cadd);
+ lba2chs(&ha->end, &iter->di, gp->lba_last, l2c_cadd);
ha->active_flag = 0x80;
ha->ostype = 0xED;
/* All bits set by default */
@@ -467,8 +467,8 @@ static int setup_handover(const struct part_iter *iter,
error("Could not build MBR hand-over record!\n");
goto bail;
}
- *(uint32_t *)ha->start = lba2chs(&iter->di, iter->start_lba, l2c_cadd);
- *(uint32_t *)ha->end = lba2chs(&iter->di, iter->start_lba + dp->length - 1, l2c_cadd);
+ lba2chs(&ha->start, &iter->di, iter->start_lba, l2c_cadd);
+ lba2chs(&ha->end, &iter->di, iter->start_lba + dp->length - 1, l2c_cadd);
ha->active_flag = dp->active_flag;
ha->ostype = dp->ostype;
ha->start_lba = (uint32_t)iter->start_lba; /* fine, we iterate over legacy scheme */
diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index 1525047d..5d4e7185 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -554,13 +554,8 @@ static int mpe_setchs(const struct disk_info *di,
ochs1 = *(uint32_t *)dp->start;
ochs2 = *(uint32_t *)dp->end;
- *(uint32_t *)dp->start =
- lba2chs(di, lba1, l2c_cadd) |
- (*(uint32_t *)dp->start & 0xFF000000);
-
- *(uint32_t *)dp->end =
- lba2chs(di, lba1 + dp->length - 1, l2c_cadd) |
- (*(uint32_t *)dp->end & 0xFF000000);
+ lba2chs(&dp->start, di, lba1, l2c_cadd);
+ lba2chs(&dp->end, di, lba1 + dp->length - 1, l2c_cadd);
return
*(uint32_t *)dp->start != ochs1 ||
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index f0bfd8fd..fb59551b 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -46,7 +46,7 @@ void wait_key(void)
} while (!cnt || (cnt < 0 && errno == EAGAIN));
}
-uint32_t lba2chs(const struct disk_info *di, uint64_t lba, uint32_t mode)
+void lba2chs(disk_chs *dst, const struct disk_info *di, uint64_t lba, uint32_t mode)
{
uint32_t c, h, s, t;
uint32_t cs, hs, ss;
@@ -86,7 +86,9 @@ uint32_t lba2chs(const struct disk_info *di, uint64_t lba, uint32_t mode)
c = t / hs;
}
- return h | (s << 8) | ((c & 0x300) << 6) | ((c & 0xFF) << 16);
+ (*dst)[0] = h;
+ (*dst)[1] = s | ((c & 0x300) >> 2);
+ (*dst)[2] = c;
}
uint32_t get_file_lba(const char *filename)
diff --git a/com32/chain/utility.h b/com32/chain/utility.h
index 9a40bc65..8a08be71 100644
--- a/com32/chain/utility.h
+++ b/com32/chain/utility.h
@@ -20,7 +20,7 @@
void error(const char *msg);
int guid_is0(const struct guid *guid);
void wait_key(void);
-uint32_t lba2chs(const struct disk_info *di, uint64_t lba, uint32_t mode);
+void lba2chs(disk_chs *dst, const struct disk_info *di, uint64_t lba, uint32_t mode);
uint32_t get_file_lba(const char *filename);
int drvoff_detect(int type, unsigned int *off);
int bpb_detect(const uint8_t *bpb, const char *tag);