summaryrefslogtreecommitdiff
path: root/com32/modules/chain.c
Commit message (Collapse)AuthorAgeFilesLines
* chain.c32: pass partition number to stage2 of Grub LegacyGert Hulselmans2010-06-271-5/+8
| | | | | | | | | | | | Grub Legacy stage2 will read the install_partition variable from memory address 0x8208. We only need to change the value at 0x820a to the correct partition number: -1: whole drive (default) 0-3: primary partitions 4-*: logical partitions Signed-off-by: Gert Hulselmans <gerth@zytor.com>
* chain.c32: only pass partition number in DH, when grldr= is usedGert Hulselmans2010-06-271-1/+11
| | | | | | | | | | | | | | | | | | | | Add grldr= as boot parameter, so the partition number is only passed to grub4dos grldr, when grldr= is used. Currently the partition number is passed in DH unconditionally. As consequence, grldr will set its root partition on which is searches its menu.lst to (hd0), because -1 (whole drive) is passed in DH as root partition: chain.c32 file=/grldr When the conditional check, this problem is solved: chain.c32 file=/grldr Grub4dos will search all partitions for its menu.lst When you want to set the root partition, use something like the following: chain.c32 hd0,2 grldr=/grldr chain.c32 fs grldr=/grldr Signed-off-by: Gert Hulselmans <gerth@zytor.com>
* chain.c32: add keeppxe to usage output and cleanup commentsGert Hulselmans2010-06-271-21/+25
| | | | | Add keeppxe to usage output. Cleanup some comments.
* Export the 64-bit partition offset and use it in chain.cH. Peter Anvin2010-06-271-2/+3
| | | | | | | | | | | | | When used with the "fs" option to chain.c32, we need to know our own filesystem offset. That means knowing if we used the MBR vs GPT partition information, as well as if we ended up using the passed-in information or not. Resolve this by providing an explicit pointer to the current partition offset. Eventually this should be replaced by some kind of statfs() call. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: fix handover to a logical partitionH. Peter Anvin2010-06-261-48/+65
| | | | | | | | Make sure the handover information to a logical partition is adjusted correctly -- we can't just hand over the partition entry, but we have to adjust start_lba to match the real start LBA. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: "fs" is a singular token, only match if completeH. Peter Anvin2010-06-261-1/+1
| | | | | | | fs is a full token, not a prefix. Reported-by: Gert Hulselmans <gerth@zytor.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain: Support booting GPT partition by labelShao Miller2010-06-261-5/+72
| | | | | | | Use the "label:" specifier followed by the label for one of a GPT disk's partitions. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Support booting GPT disk/partition by GUIDShao Miller2010-06-261-22/+148
| | | | | | | Use the "guid:" specifier followed by the GUID for a GPT disk or one of its partitions. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain.c32: correctly set the length of the GPT handover structuresyslinux-4.00-pre61H. Peter Anvin2010-06-251-50/+57
| | | | | | | We need to make sure the entire GPT handover structure is mapped correctly by the shuffler. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* chain: Implement GPT hand-over protocol as documentedShao Miller2010-06-251-1/+50
| | | | | | | When a partition was yielded by a GPT partition iterator, we follow the protocol documented in syslinux/doc/gpt.txt. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Allow booting the Syslinux partition with "fs"Shao Miller2010-06-241-31/+44
| | | | | | | | | | We will now accept an "fs" option which instructs us to chain-load whatever partition we were booted from. Not useful for PXELINUX, for obvious reasons. Can be used in combination with a "file=" option, to boot something other than Syslinux. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: A sprinkling of documentationShao Miller2010-06-241-20/+29
| | | | Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Remove type-assurance macro for declarationsShao Miller2010-06-241-7/+6
| | | | | | | | | | A coding pattern from WinVBlock leaked through whereby a macro is used to declare functions having the same prototype. This makes their declarations look a little less like a traditional declarations however, so that pattern has been removed. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Support GPT disksShao Miller2010-06-241-1/+230
| | | | | | | | A GPT disk partition iterator is introduced, so we can chain-load partitions on such a disk. Tested-by: Shao Miller <shao.miller@yrdsb.edu.on.ca> Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Change disk partition iteration strategyShao Miller2010-06-241-111/+219
| | | | | | | | | | In order to support more than just MBR and EBR walking, we introduce the abstraction of a partition iterator. Currently there are just the two types: MBR partition iterator and extended partition iterator. Tested-by: Shao Miller <shao.miller@yrdsb.edu.on.ca> Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Fix allocation size in read_sectorsShao Miller2010-06-241-1/+1
| | | | | | Oops. We might allocate more than just one sector. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Add DOS partition dumping routine for debuggingShao Miller2010-06-231-0/+33
| | | | Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Use struct mbr where applicableShao Miller2010-06-231-39/+52
| | | | | | Instead of magic offsets. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Use CHS typedef and macrosShao Miller2010-06-221-6/+13
| | | | | | | | A DOS partition table entry contains cylinder, head, sector tuples which can be convenient to group together and extract with convenience macros. Currently unused. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Allow reading more than a single sectorShao Miller2010-06-221-9/+15
| | | | Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain: Run Nindent on com32/modules/chain.cShao Miller2010-06-221-26/+24
| | | | Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
* chain.c32: add support for loading GRUB stage2Paul Bolle2010-06-071-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds (basic) support for GRUB stage2 image files. Loading a stage2 image will probably give you a GRUB prompt, with GRUB's "root" set at "(hd0)" (ie, entire first disk). Maybe the "root" will differ in less common setups. (One can of course select another disk and/or partition with GRUB's "root" command.) This has only been tested with version 3.2 stage2 images (as used by GRUB 0.97). I'm not familiair with differences with other versions. GRUB's loading mechanism allows to somehow provide stage2 with the selected disk and partition, BSD slice, etc. (ie, to tell stage2 what it's "root" is). I don't yet understand the notation used in that mechanism. Besides, since stage2 images will not necessarily be loaded from the disk (and partition, etc.) they were installed to, it seems best to just use the first disk. GRUB stage1_5 image files load quite similarly. However, for some reason, a short test only got those images to print an error ("Error 17"). This could be related to the partition info these images are provided with when they're loaded. I have never used stage1_5 images, and do not know how to properly use and configure those, so my test stopped there, and stage1_5 images are not supported. Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* chain.c32 sethidden option fixMichal Soltys2010-04-231-1/+1
| | | | | | Hidden sectors value was applied at the wrong offset. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: Fix chaining to MBRsH. Peter Anvin2010-03-051-6/+5
| | | | | | | | The change to load the bootsector even when loading a bootstrap from a file broke the handing of chainloading the MBR of a disk. Fix this. Debugging-info-by: Thomas Mieslinger <thomas.mieslinger@lundl.de> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c: part_info -> partinfosyslinux-3.85-pre11H. Peter Anvin2010-02-131-1/+1
| | | | Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: add option to set hidden sectors; load boot sector for NTLDRH. Peter Anvin2010-02-131-66/+134
| | | | | | | Add an option to update the in-memory version of FAT/NTFS hidden sectors (== partition offset); load the boot sector for NTLDR. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: Handle nonlinear logical partitionssyslinux-3.85-pre3H. Peter Anvin2010-01-271-5/+8
| | | | | | | | | | | Some partitioning program, including at least parted, apparently create the list of logical partition headers nonlinearly with the partition themselves. Thus, make it a requirement that then fit inside the overall extended partition, but not inside the corresponding sublogical partition. Reported-by: Gert Huselmans <gerth@zytor.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: simplify the grub4dos supportH. Peter Anvin2010-01-101-13/+9
| | | | | | | Grub4dos (like Grub in general) uses the same partition numbers as Linux (and chain.c32), minus one. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: add grldr= command for Grub4dosKim Mik2010-01-101-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | grldr of Grub4dos wants the partition number in DH: 0xff: whole drive 0-3: primary partitions 4-*: logical partitions Hmmm... there really isn't a huge reason not to do this unconditionally, at least unless it's known to cause problems. It would be better, of course, if grldr used the standard DS:SI, but it doesn't, so oh well. Some info of a Grub4dos developer (Tinybit): GRLDR can be loaded at any address with alignment 16(i.e., a possible segment base address). Generally you want to load it at 0000:7C00, or at 2000:0000. Of course you never load it at 0000:0000 or similar. Before jumping to the entry point at the very beginning of GRLDR, you should setup DL=(BIOS drive) and DH=(partition number). For partition numbers, 0 - 3 are primary, 4 - 0xFE are logical. (DH=0xFF) stands for whole drive(unpartitioned). DH will later be passed to install_partition(the third byte, from bit 16 to bit 23). http://www.boot-land.net/forums/index.php?showtopic=8457&st=20&start=20 post #22
* chain.c32: stylistic comments/usage output changesKim Mik2009-12-281-2/+2
| | | | | | | | | Comments fix and usage output corrected for chain.c32 - Gert Hulselmans Signed-off-by: Gert Hulselmans <kimmik999999@yahoo.co.uk> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c: do a proper copy operation for the cmldr signatureH. Peter Anvin2009-12-281-9/+14
| | | | | | | Instead of writing into memory that we might not own, create a proper copy operation using syslinux_add_movelist(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: add support for booting the Recovery Console of Windows NT/2K/XPKim Mik2009-12-281-0/+17
| | | | | | | | | | | | | | The following patch for chain.c32 adds support to boot the Recovery Console of Windows NT/2K/XP. Normally when you want to boot the recovery console, you need to patch "cmdcons\0" into the bootsectorof the partition (8 bytes starting at 0x3 (4th byte)). We can do this patching in memory: strcpy((char *) 0x7c03, "cmdcons"); To boot the recovery console with chain.c32: chain.c32 cmldr=/cmldr - Gert Hulselmans
* chain.c32: fixing implicit declaration of function ↵Kim Mik2009-12-281-0/+1
| | | | | | | | | | | | | | | | | | ‘syslinux_force_text_mode’ When building chain.c32: $ make chain.c32 gcc -Wp,-MT,chain.o,-MD,./..chain.o.d -std=gnu99 -m32 -fno-stack-protector -mregparm=3 -DREGPARM=3 -march=i386 -Os -W -Wall -march=i386 -fomit-frame-pointer -D__COM32__ -nostdinc -iwithprefix include -I../../com32/libutil/include -I../../com32/include -I../../com32/gplinclude -c -o chain.o chain.c chain.c: In function ‘do_boot’: chain.c:552: warning: implicit declaration of function ‘syslinux_force_text_mode’ ld -m elf_i386 -T ../../com32/lib/com32.ld -o chain.elf chain.o ../../com32/libutil/libutil_com.a ../../com32/gpllib/libcom32gpl.a ../../com32/lib/libcom32.a /usr/lib/gcc/i486-linux-gnu/4.4.1/libgcc.a objcopy -O binary chain.elf chain.c32 The following was missing: #include <syslinux/video.h> - Gert Hulselmans
* chain.c32: force text modeH. Peter Anvin2009-12-181-0/+3
| | | | | | When loading an unknown system, revert to text mode first. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* [chain] Run Nindent on chain.cShao Miller2009-10-291-33/+28
|
* [chain] Add support for chain-loading another isolinux.binGert Hulselmans2009-10-291-0/+118
| | | | | Add 'isolinux=' option to chain.c32 for chain-loading another isolinux.bin.
* Improving chain.c32 help messageGert Hulselmans2009-10-271-1/+12
| | | | | | | Impact: Error message is more detailed In case of syntax error, the message is far more detailed and provides the same content as the documentation integrated in the source code.
* chain: missing some \n one error messagesErwan Velu2009-09-291-4/+4
| | | | | | | | Impact: visual Some \n where missing in some error() calls Signed-off-by: Gert Hulselmans <kimmik999999@yahoo.co.uk>
* Merge commit 'syslinux-3.83-pre1'H. Peter Anvin2009-07-271-2/+1
|\ | | | | | | | | | | | | Conflicts: com32/modules/chain.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * chain.c32: set DL properly when loaded from ISOLINUXH. Peter Anvin2009-07-231-2/+1
| | | | | | | | | | | | | | When loaded from ISOLINUX, we still have a valid boot drive. Set it! This permits the use of chainloaded boot loaders. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Run Nindent on com32/modules/chain.cH. Peter Anvin2009-05-291-563/+574
|/ | | | | | | | | Automatically reformat com32/modules/chain.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: remove clobber of drivename/partitionH. Peter Anvin2009-05-211-3/+0
| | | | | | | | Remove a clobber of drivename and partition, after we have spent time computing what the should have been... Reported-by: Luciano Miguel Ferreira Rocha <strange@nsk.no-ip.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Update copyright noticesH. Peter Anvin2009-04-041-0/+1
| | | | Update copyright notices; add Intel copyright notices where appropriate.
* chain.c32: remove misleading commentH. Peter Anvin2009-03-311-1/+0
| | | | | | Remove a never-implemented, misleading comment Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* chain.c32: remove loadbase < 0x7c00 hackH. Peter Anvin2009-03-311-70/+7
| | | | | | | Remove the special hack for loadbase < 0x7c00. We no longer need it, since the shuffler will relocate appropriately by magic. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* chain.c32: error out on missing boot sector signatureH. Peter Anvin2008-07-301-0/+7
| | | | | | | | If we're booting a disk or partition, then error out if the loaded sector doesn't have a boot sector signature, rather than the otherwise-inevitable crash. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: fix test for partition types which can be hiddensyslinux-3.71-pre11Sergey Vlasov2008-07-161-1/+1
| | | | | | | | | | | The result of shift in C is undefined if the shift count is greater than the width of type. On x86 the corresponding CPU instruction masks the shift count with 0x1f, therefore (mask >> (t & ~0x10)) & 1) gives false positives for types greater than 0x1f (e.g., the partition type 0x8e (Linux LVM) could be "hidden" to 0x9e). Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: fix bounce buffer handlingSergey Vlasov2008-07-161-4/+7
| | | | | | | | | | | | | | | Fix breakage in the "hide" option support patch: - The code which initialized the global variable "dapa" was lost in commit 81c203f2, therefore EBIOS access did not work properly. Fixed by removing the global variable completely and moving all bounce buffer handling into read_sector() and write_sector(). - write_sector() copied data to the bounce buffer, but then tried to use the pointer to the original buffer in BIOS calls. Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain.c32: explicitly verify after writing MBRsyslinux-3.71-pre7H. Peter Anvin2008-07-111-4/+20
| | | | | If we write the MBR, do verify by reading it back and comparing. Right now all we do is print an error, though.
* chain.c32: new "hide" optionH. Peter Anvin2008-07-111-9/+104
| | | | Option for chain.c32 to hide primary partitions on the boot drive.