[syslinux:master] chain/chain.c: add "raw" handover
syslinux-bot for Michal Soltys
soltys at ziu.info
Mon Mar 26 15:03:19 PDT 2012
Commit-ID: e3423edd89533515e502504b03539bd902e4bf0e
Gitweb: http://www.syslinux.org/commit/e3423edd89533515e502504b03539bd902e4bf0e
Author: Michal Soltys <soltys at ziu.info>
AuthorDate: Sat, 28 Aug 2010 16:15:37 +0200
Committer: Michal Soltys <soltys at ziu.info>
CommitDate: Tue, 28 Sep 2010 09:32:53 +0200
chain/chain.c: add "raw" handover
This adds a possibility to create an area resembling proper handover,
when booting mbr of some media. If we have custom/special booting code
always expecting handover, this would allow us to boot it from the 1st
sector as well.
Signed-off-by: Michal Soltys <soltys at ziu.info>
---
com32/chain/chain.c | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index b846f16..bd8cd0c 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -571,7 +571,6 @@ static int setup_handover(const struct part_iter *iter,
error("Could not build GPT hand-over record!\n");
goto bail;
}
- memset(ha, 0, synth_size);
*(uint32_t *)ha->start = lba2chs(&iter->di, gp->lba_first);
*(uint32_t *)ha->end = lba2chs(&iter->di, gp->lba_last);
ha->active_flag = 0x80;
@@ -594,30 +593,42 @@ static int setup_handover(const struct part_iter *iter,
disk_dos_part_dump(ha);
disk_gpt_part_dump((struct disk_gpt_part_entry *)(plen + 1));
#endif
- } else if (iter->type == typedos) {
- /* MBR handover protocol */
- dp = (const struct disk_dos_part_entry *)iter->record;
+ } else if (iter->type == typedos || iter->type == typeraw) {
+ /* MBR / RAW handover protocol */
synth_size = sizeof(struct disk_dos_part_entry);
ha = malloc(synth_size);
if (!ha) {
- error("Could not build MBR hand-over record!\n");
+ error("Could not build MBR / RAW hand-over record!\n");
goto bail;
}
-
- *(uint32_t *)ha->start = lba2chs(&iter->di, iter->start_lba);
- *(uint32_t *)ha->end = lba2chs(&iter->di, iter->start_lba + dp->length - 1);
- ha->active_flag = dp->active_flag;
- ha->ostype = dp->ostype;
- ha->start_lba = (uint32_t)iter->start_lba; /* fine, we iterate over legacy scheme */
- ha->length = dp->length;
-
+ if (!iter->index) {
+ *(uint32_t *)ha->start = lba2chs(&iter->di, 0);
+ *(uint32_t *)ha->end = lba2chs(&iter->di, 2879);
+ ha->active_flag = 0x80;
+ ha->ostype = 0xDA;
+ ha->start_lba = 0;
+ ha->length = 2880;
+ } else if (iter->type == typedos) {
+ dp = (const struct disk_dos_part_entry *)iter->record;
+
+ *(uint32_t *)ha->start = lba2chs(&iter->di, iter->start_lba);
+ *(uint32_t *)ha->end = lba2chs(&iter->di, iter->start_lba + dp->length - 1);
+ ha->active_flag = dp->active_flag;
+ ha->ostype = dp->ostype;
+ ha->start_lba = (uint32_t)iter->start_lba; /* fine, we iterate over legacy scheme */
+ ha->length = dp->length;
#ifdef DEBUG
- dprintf("MBR handover:\n");
- disk_dos_part_dump(ha);
+ dprintf("MBR handover:\n");
+ disk_dos_part_dump(ha);
+ } else {
+ goto bail;
#endif
+ }
+#ifdef DEBUG
} else {
/* shouldn't ever happen */
goto bail;
+#endif
}
data->base = 0x7be;
@@ -714,12 +725,9 @@ int main(int argc, char *argv[])
}
/* Prep the handover */
- if (!iter->index) {
- opt.hand = false;
- } else if (opt.hand) {
+ if (opt.hand) {
if (setup_handover(iter, &hdat))
goto bail;
-
/* Verify possible conflicts */
if ( ( opt.file && overlap(&fdat, &hdat)) ||
( opt.sect && overlap(&sdat, &hdat) && opt.maps) ) {
More information about the Syslinux-commits
mailing list