summaryrefslogtreecommitdiff
path: root/com32/chain
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2010-08-26 09:21:55 +0200
committerMichal Soltys <soltys@ziu.info>2010-09-28 09:32:52 +0200
commit2cb7f5d10e6c94a0cac7a425f23d244b25b0727b (patch)
treea8f47119eb18a12db6cb327cb8098a082303de4c /com32/chain
parent1c1f14dc77b5b361333a7e790eed3206526fb26d (diff)
downloadsyslinux-2cb7f5d10e6c94a0cac7a425f23d244b25b0727b.tar.gz
chain, options: bugfixes, adjustments; big doc update
- seg='s offset values default to 0 if ommited - sect='s offset values default to 0x7c00 if ommited - FDOS's bootsector loaded at 0x1fe0 - drive / partition parsing: bugfix, so lables with ',' are recognized properly - big documentation update Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain')
-rw-r--r--com32/chain/chain.c7
-rw-r--r--com32/chain/options.c61
-rw-r--r--com32/chain/options.h3
3 files changed, 40 insertions, 31 deletions
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index 12372aab..e983dcba 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -378,7 +378,7 @@ static int pem_setchs(const struct disk_info *di,
*(uint32_t *)dp->end != ochs2;
}
-static int pe_mangle(struct part_iter *_iter)
+static int pentry_mangle(struct part_iter *_iter)
{
int wb = 0, werr = 0;
uint32_t cebr_lba = 0;
@@ -522,7 +522,7 @@ int find_dp(struct part_iter **_iter)
}
/* main options done - only thing left is explicit partition specification,
* if we're still at the disk stage with the iterator AND user supplied
- * partition number (including disk).
+ * partition number (including disk pseudo-partition).
*/
if (!iter->index && opt.partition) {
partition = strtol(opt.partition, NULL, 0);
@@ -713,7 +713,7 @@ int main(int argc, char *argv[])
/* Perform initial partition entry mangling */
if (opt.hide || opt.mbrchs)
- pe_mangle(iter);
+ pentry_mangle(iter);
/* hide_unhide(iter);*/
/* Load the boot file */
@@ -817,6 +817,7 @@ int main(int argc, char *argv[])
if (try_mangles_bpb(iter, data + sidx))
goto bail;
+ /* This *must* be after BPB mangling */
if (opt.cmldr && mangles_cmldr(data + sidx))
goto bail;
}
diff --git a/com32/chain/options.c b/com32/chain/options.c
index f12a9755..6fb07fd8 100644
--- a/com32/chain/options.c
+++ b/com32/chain/options.c
@@ -8,11 +8,15 @@
int soi_s2n(char *ptr, unsigned int *seg,
unsigned int *off,
- unsigned int *ip)
+ unsigned int *ip,
+ unsigned int def)
{
- unsigned int segval = 0, offval = 0x7c00, ipval = 0x7c00, val;
+ unsigned int segval = 0, offval, ipval, val;
char *p;
+ offval = def;
+ ipval = def;
+
segval = strtoul(ptr, &p, 0);
if (p[0] == ':' && p[1] && p[1] != ':')
offval = strtoul(p+1, &p, 0);
@@ -53,20 +57,21 @@ void usage(void)
"\
Usage:\n\
chain.c32 [options]\n\
- chain.c32 {fd|hd}<disk> [<partition>] [options]\n\
- chain.c32 mbr{:|=}<id> [<partition>] [options]\n\
- chain.c32 guid{:|=}<guid> [<partition>] [options]\n\
- chain.c32 label{:|=}<label> [<partition>] [options]\n\
- chain.c32 boot{,| }[<partition>] [options]\n\
+ chain.c32 {fd|hd}<disk>{,| }[<part#>] [options]\n\
+ chain.c32 mbr{:|=}<id>{, | }[<part#>] [options]\n\
+ chain.c32 guid{:|=}<guid>{,| }[<part#>] [options]\n\
+ chain.c32 label{:|=}<label> [<part#>] [options]\n\
+ chain.c32 boot{,| }[<part#>] [options]\n\
chain.c32 fs [options]\n\
", "\
-\nOptions ('no' prefix specify default value):\n\
- file=<loader> Load and execute file\n\
+\nOptions #1 ('no' prefix specifies default value):\n\
+ file=<file> 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\
+ - defaults to 0:0x7C00:0x7C00\n\
+ - ommited o/i values default to 0\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\
+ - ommited o/i values default to 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\
@@ -74,6 +79,9 @@ Usage:\n\
- <off> defaults to autodetection\n\
- only 0x24 and 0x40 are accepted\n\
nosetbpb Enable set{hid,geo,drv}\n\
+ nofilebpb Treat file in memory as BPB compatible\n\
+", "\
+\nOptions #2 ('no' prefix specifies default value):\n\
nosave Write adjusted sector back to disk\n\
hand Prepare handover area\n\
nohptr Force ds:si and ds:bp to point to handover area\n\
@@ -85,7 +93,7 @@ Usage:\n\
nowarn Wait for a keypress to continue chainloading\n\
- useful to see emited warnings\n\
", "\
-\nComposite options:\n\
+\nOptions #3 ('no' prefix specifies default value):\n\
isolinux=<loader> Load another version of ISOLINUX\n\
ntldr=<loader> Load Windows NTLDR, SETUPLDR.BIN or BOOTMGR\n\
cmldr=<loader> Load Recovery Console of Windows NT/2K/XP/2003\n\
@@ -122,7 +130,7 @@ int parse_args(int argc, char *argv[])
} else if (!strcmp(argv[i], "nofile")) {
opt.file = NULL;
} else if (!strncmp(argv[i], "seg=", 4)) {
- if (soi_s2n(argv[i] + 4, &opt.fseg, &opt.foff, &opt.fip))
+ if (soi_s2n(argv[i] + 4, &opt.fseg, &opt.foff, &opt.fip, 0))
goto bail;
} else if (!strncmp(argv[i], "bss=", 4)) {
opt.file = argv[i] + 4;
@@ -132,6 +140,7 @@ int parse_args(int argc, char *argv[])
opt.setdrv = true;
opt.drvoff = ~0u;
opt.filebpb = true;
+ /* opt.save = true; */
} else if (!strncmp(argv[i], "isolinux=", 9)) {
opt.file = argv[i] + 9;
opt.isolinux = true;
@@ -164,9 +173,7 @@ int parse_args(int argc, char *argv[])
opt.fseg = 0x60; /* FREEDOS wants this address */
opt.foff = 0;
opt.fip = 0;
- opt.sseg = 0x9000;
- opt.soff = 0;
- opt.sip = 0;
+ opt.sseg = 0x1FE0;
opt.file = argv[i] + 8;
opt.sethid = true;
opt.setgeo = true;
@@ -180,9 +187,7 @@ int parse_args(int argc, char *argv[])
opt.fseg = 0x70; /* MS-DOS 2.00 .. 6.xx wants this address */
opt.foff = 0;
opt.fip = v == 7 ? 0x200 : 0; /* MS-DOS 7.0+ wants this ip */
- opt.sseg = 0x9000;
- opt.soff = 0;
- opt.sip = 0;
+ opt.sseg = 0x8000;
opt.file = argv[i] + v;
opt.sethid = true;
opt.setgeo = true;
@@ -288,7 +293,7 @@ int parse_args(int argc, char *argv[])
} else if (!strncmp(argv[i], "sect=", 5) ||
!strcmp(argv[i], "sect")) {
if (argv[i][4]) {
- if (soi_s2n(argv[i] + 5, &opt.sseg, &opt.soff, &opt.sip))
+ if (soi_s2n(argv[i] + 5, &opt.sseg, &opt.soff, &opt.sip, 0x7c00))
goto bail;
if ((opt.sseg << 4) + opt.soff + SECTOR - 1 > ADDRMAX) {
error("Arguments of 'sect=' are invalid - resulting address too big.\n");
@@ -326,13 +331,15 @@ int parse_args(int argc, char *argv[])
|| !strncmp(argv[i], "boot,", 5)
|| !strcmp(argv[i], "fs")) {
opt.drivename = argv[i];
- p = strchr(opt.drivename, ',');
- if (p) {
- *p = '\0';
- opt.partition = p + 1;
- } else if (argv[i + 1] && argv[i + 1][0] >= '0'
- && argv[i + 1][0] <= '9') {
- opt.partition = argv[++i];
+ if (strncmp(argv[i], "label", 5)) {
+ p = strchr(opt.drivename, ',');
+ if (p) {
+ *p = '\0';
+ opt.partition = p + 1;
+ } else if (argv[i + 1] && argv[i + 1][0] >= '0'
+ && argv[i + 1][0] <= '9') {
+ opt.partition = argv[++i];
+ }
}
} else {
usage();
diff --git a/com32/chain/options.h b/com32/chain/options.h
index e400eca5..acd50e62 100644
--- a/com32/chain/options.h
+++ b/com32/chain/options.h
@@ -1,7 +1,8 @@
#ifndef _COM32_CHAIN_OPTIONS_H
#define _COM32_CHAIN_OPTIONS_H
-int soi_s2n(char *ptr, unsigned int *seg, unsigned int *off, unsigned int *ip);
+int soi_s2n(char *ptr, unsigned int *seg, unsigned int *off,
+ unsigned int *ip, unsigned int def);
void usage(void);
int parse_args(int argc, char *argv[]);