[syslinux] [RFC/PATCH] New chainloading functionality

Michal Soltys soltys at ziu.info
Mon Jul 26 15:50:31 PDT 2010


This patch introduces extra functionality to chain.c, mainly with reference to
BPB adjustments, but not only that. It expects 3 small patches I sent earlier
(they are included for easy reference, patches 1-3/4).

The changes introduced are:

1) file and boot sector use separate options to control load address and jump
address (if applicable). Options are as described below:

 * segbs=<seg[:off[:ip]]>
 *      main control of where the sector (boot sector or mbr) should be loaded
 *      at, and where to actually jump. Default value is 0:7C00:7C00. Numbers
 *      are parsed as *HEX* values. Of course, if you set custom segbs without
 *      specifying some of the values (or leaving empty field near colon),
 *      unspecified ones are assumed 0. Overall, sector is loaded at seg:off,
 *      and the jump is made to seg:ip.
 *
 * seg=<seg[:off[:ip]]>
 *      similary to segbs option, this controls where to load file (if
 *      applicable - see file= option and derivatives). File takes precedence
 *      over boot sector, so in case their areas overlap, only file will be
 *      loaded.

To retain compatibility with older configs simple invocation such as seg=0x60
is perfectly valid. Only potential incompatibilities here, is if someone used
decimal values (e.g. seg=96) or if someone used seg= to actually control boot
sector address/jump (extremely unlikely).

Old logic of load_base used first for file, then for sector is no longer
present.

2) Overlapping regions are checked very carefully. File takes precedence over
boot sector, and boot sector over handover area - see the patch, near boot
sector loading and handover area creation.

3) bsnomap option allows reading/adjusting/writing boot sector, without mapping
it to real memory before chainloading. Useful for adjusting BPB without being
forced to set proper segbs= address.

4) All win/dos file options have been updated accordingly, with rich comments.

5) setdrive[@<offset>] option:

 *      update the "drive unit" field in a FAT/NTFS boot sector. Offset should
 *      be either 0x24 (FAT/NTFS excluding FAT32) or 0x40 (FAT32 only) -
 *      chainloader won't accept other values. Offset is parsed as a *HEX*
 *      number. Offsetless value defaults to 0x24.

6) setgeometry - for legacy spt and heads fields in BPB

7) setbpb

 *      A shortcut that enables set{hidden,geometry} options;
 *      setdrive is not covered by this shortcut, due to the ambiguity.

8) writebs, filebpb

 * writebs
 *      Write updated boot sector to the disk. This is performed only
 *      if some of the BPB's fields actually changed.
 *
 * filebpb
 *      An option that let loaded file be treated as BPB compatible. If any of
 *      the previous set* options is specified and file is being loaded, BPB at
 *      appropriate offsets will be adjusted accordingly. Obviously, writebs
 *      options is ignored for file. It can be used for crude sort-of emulation
 *      of syslinux's native .BSS capability, where BPB patching is limited only
 *      to options specified by set* (but it reflects actual BIOS imaginations)


Other changes:

- argument parsing is moved outside main
- cosmetic text fixes

Further stuff to do:

- some more tests with unusual configs
- splitting main into smaller chunks
- doc/chain.txt

Michal Soltys (4):
  chain.c: mismatch between index and mbr_index in mbr iterator
  chain.c: gpt's index/private.index mismatch fix, cosmetic iterator
    changes
  chain.c: allocation fixes
  chain.c: New functionality

 com32/modules/chain.c |  611 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 445 insertions(+), 166 deletions(-)




More information about the Syslinux mailing list