aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2010-08-22 23:31:55 +0200
committerMichal Soltys <soltys@ziu.info>2010-09-28 09:32:52 +0200
commit505a26ad9794776d7b018c81bf993751fba6b06f (patch)
tree95022c2c639c7871a5b8c1b6cc7a4858bf5b611c
parentbd488610577a8cafb4f226f8ec3d093c51b67121 (diff)
downloadsyslinux-505a26ad9794776d7b018c81bf993751fba6b06f.tar.gz
syslinux-505a26ad9794776d7b018c81bf993751fba6b06f.tar.xz
syslinux-505a26ad9794776d7b018c81bf993751fba6b06f.zip
chain, options: fixes, additions
- add 'bss=' option - update usage() - ommited offsets in 'file=' and 'sect=' default to 0x7c00 now - cosmetics Signed-off-by: Michal Soltys <soltys@ziu.info>
-rw-r--r--com32/chain/chain.c16
-rw-r--r--com32/chain/options.c40
-rw-r--r--com32/chain/utility.c1
3 files changed, 34 insertions, 23 deletions
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index 88424dbd..7eed8808 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -302,11 +302,11 @@ static void hide_unhide(const struct part_iter *_iter)
if (_iter->type != typedos) {
error("Option 'hide' is only meaningful for legacy partition scheme.");
- goto out;
+ goto bail;
}
if (!(mbr = disk_read_sectors(&_iter->di, 0, 1))) {
error("WARNING: Couldn't read MBR to hide/unhide partitions.\n");
- goto out;
+ goto bail;
}
if (_iter->index < 1 || _iter->index > 4)
@@ -330,7 +330,7 @@ static void hide_unhide(const struct part_iter *_iter)
if (write_back && disk_write_verify_sector(&_iter->di, 0, mbr))
error("WARNING: failed to write MBR for option 'hide'\n");
-out:
+bail:
free(mbr);
}
@@ -350,7 +350,6 @@ int find_dp(struct part_iter **_iter)
error("Unable to find requested MBR signature.\n");
goto bail;
}
-
} else if (!strncmp(opt.drivename, "guid", 4)) {
if (str_to_guid(opt.drivename + 5, &gpt_guid))
goto bail;
@@ -358,7 +357,6 @@ int find_dp(struct part_iter **_iter)
error("Unable to find requested GPT disk or partition by guid.\n");
goto bail;
}
-
} else if (!strncmp(opt.drivename, "label", 5)) {
if (!opt.drivename[6]) {
error("No label specified.\n");
@@ -368,7 +366,6 @@ int find_dp(struct part_iter **_iter)
error("Unable to find requested GPT partition by label.\n");
goto bail;
}
-
} else if ((opt.drivename[0] == 'h' || opt.drivename[0] == 'f') &&
opt.drivename[1] == 'd') {
hd = opt.drivename[0] == 'h' ? 0x80 : 0;
@@ -387,19 +384,14 @@ int find_dp(struct part_iter **_iter)
"'boot' and 'fs' are meaningless.\n");
goto bail;
}
-#if 0
/* offsets match, but in case it changes in the future */
if (sdi->c.filesystem == SYSLINUX_FS_ISOLINUX) {
drive = sdi->iso.drive_number;
fs_lba = *sdi->iso.partoffset;
} else {
-#endif
drive = sdi->disk.drive_number;
fs_lba = *sdi->disk.partoffset;
-#if 0
}
-#endif
-
if (disk_get_params(drive, &diskinfo))
goto bail;
/* this will start iteration over disk emulation, possibly raw */
@@ -736,7 +728,7 @@ int main(int argc, char *argv[])
printf("iter dsk: %d\n", iter->di.disk);
printf("iter idx: %d\n", iter->index);
printf("iter lba: %llu\n", iter->start_lba);
- if (hand_area)
+ if (hidx >= 0)
printf("hand lba: %u\n", hand_area->start_lba);
#endif
diff --git a/com32/chain/options.c b/com32/chain/options.c
index efb563d7..35141248 100644
--- a/com32/chain/options.c
+++ b/com32/chain/options.c
@@ -10,13 +10,13 @@ int soi_s2n(char *ptr, unsigned int *seg,
unsigned int *off,
unsigned int *ip)
{
- unsigned int segval = 0, offval = 0, ipval = 0, val;
+ unsigned int segval = 0, offval = 0x7c00, ipval = 0x7c00, val;
char *p;
segval = strtoul(ptr, &p, 0);
- if (*p == ':')
+ if (p[0] == ':' && p[1] && p[1] != ':')
offval = strtoul(p+1, &p, 0);
- if (*p == ':')
+ if (p[0] == ':' && p[1] && p[1] != ':')
ipval = strtoul(p+1, NULL, 0);
val = (segval << 4) + offval;
@@ -47,7 +47,10 @@ bail:
void usage(void)
{
- static const char *const usage[] = { "\
+ unsigned int i;
+ static const char key[] = "Press any key...\n";
+ static const char *const usage[] = {
+"\
Usage:\n\
chain.c32 [options]\n\
chain.c32 {fd|hd}<disk> [<partition>] [options]\n\
@@ -56,16 +59,18 @@ Usage:\n\
chain.c32 label{:|=}<label> [<partition>] [options]\n\
chain.c32 boot{,| }[<partition>] [options]\n\
chain.c32 fs [options]\n\
-\nOptions ('no' prefix specify defaulti value):\n\
+", "\
+\nOptions ('no' prefix specify default value):\n\
file=<loader> Load and execute file\n\
seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>\n\
nofilebpb Treat file in memory as BPB compatible\n\
sect[=<s[:o[:i]]>] Load sector at <s:o>, jump to <s:i>\n\
- defaults to 0:0x7C00:0x7C00\n\
+ - ommited o/i values default 0x7C00\n\
maps Map loaded sector into real memory\n\
nosethid[den] Set BPB's hidden sectors field\n\
nosetgeo Set BPB's sectors per track and heads fields\n\
- nosetdrv[@<off>] Set BPB's drive unit field at <o>\n\
+ nosetdrv[@<off>] Set BPB's drive unit field at <off>\n\
- <off> defaults to autodetection\n\
- only 0x24 and 0x40 are accepted\n\
nosetbpb Enable set{hid,geo,drv}\n\
@@ -90,12 +95,17 @@ Usage:\n\
grub=<loader> Load GRUB Legacy stage2\n\
grubcfg=<filename> Set alternative config filename for GRUB Legacy\n\
grldr=<loader> Load GRUB4DOS grldr\n\
-\nPlease see doc/chain.txt for the detailed documentation.\n"
+ bss=<filename> Emulate BSS (see doc/chain.txt for differences)\n\
+\nPlease see doc/chain.txt for the detailed documentation.\n\
+"
};
- error(usage[0]);
- error("Press any key...\n");
- wait_key();
- error(usage[1]);
+ for (i = 0; i < sizeof(usage)/sizeof(usage[0]); i++) {
+ if (i) {
+ error(key);
+ wait_key();
+ }
+ error(usage[i]);
+ }
}
int parse_args(int argc, char *argv[])
@@ -112,6 +122,14 @@ int parse_args(int argc, char *argv[])
} else if (!strncmp(argv[i], "seg=", 4)) {
if (soi_s2n(argv[i] + 4, &opt.fseg, &opt.foff, &opt.fip))
goto bail;
+ } else if (!strncmp(argv[i], "bss=", 4)) {
+ opt.file = argv[i] + 4;
+ opt.maps = false;
+ opt.sethid = true;
+ opt.setgeo = true;
+ opt.setdrv = true;
+ opt.drvoff = ~0u;
+ opt.filebpb = true;
} else if (!strncmp(argv[i], "isolinux=", 9)) {
opt.file = argv[i] + 9;
opt.isolinux = true;
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index 9b978a61..5aa196df 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -112,3 +112,4 @@ uint32_t get_file_lba(const char *filename)
return lba;
}
+/* vim: set ts=8 sts=4 sw=4 noet: */