From: hpa Date: Thu, 9 Dec 2004 06:27:12 +0000 (+0000) Subject: Support non-mkisofs mastering programs X-Git-Tag: syslinux-3.11~351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46898c5d701d3c9e31649da002346af7c53e7adf;p=platform%2Fupstream%2Fsyslinux.git Support non-mkisofs mastering programs --- diff --git a/Makefile b/Makefile index f77f259..463d1f7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -## ----------------------------------------------------------------------- ## $Id$ +## ----------------------------------------------------------------------- ## -## Copyright 1998-2003 H. Peter Anvin - All Rights Reserved +## Copyright 1998-2004 H. Peter Anvin - All Rights Reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ LIB_SO = libsyslinux.so.$(VERSION) # CSRC = syslinux.c syslinux-nomtools.c syslxmod.c gethostip.c NASMSRC = ldlinux.asm syslinux.asm copybs.asm \ - pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm + pxelinux.asm mbr.asm isolinux.asm SOURCES = $(CSRC) *.h $(NASMSRC) *.inc # syslinux.exe is BTARGET so as to not require everyone to have the # mingw suite installed @@ -115,17 +115,20 @@ pxelinux.bin: pxelinux.asm kwdhash.gen version.gen $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ -l pxelinux.lst -o pxelinux.bin pxelinux.asm -isolinux.bin: isolinux.asm kwdhash.gen version.gen +isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ -l isolinux.lst -o isolinux.bin isolinux.asm + $(PERL) checksumiso.pl isolinux.bin pxelinux.0: pxelinux.bin cp pxelinux.bin pxelinux.0 # Special verbose version of isolinux.bin -isolinux-debug.bin: isolinux-debug.asm kwdhash.gen +isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ - -l isolinux-debug.lst -o isolinux-debug.bin isolinux-debug.asm + -DDEBUG_MESSAGES \ + -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm + $(PERL) checksumiso.pl $@ ldlinux.bss: ldlinux.bin dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1 diff --git a/NEWS b/NEWS index a3a0849..82c24c8 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ Changes in 2.12: not use the linker for the 16-bit code. * SYSLINUX: If we're building on a machine without a Win32 (mingw) compiler, just skip building syslinux.exe. + * ISOLINUX: Support non-mkisofs mastering programs, at least + as long as the image is single-session. For best results, + ISOLINUX should be the only boot loader installed. Changes in 2.11: * ALL: Add an API call to get the configuration file name. diff --git a/checksumiso.pl b/checksumiso.pl new file mode 100755 index 0000000..b552742 --- /dev/null +++ b/checksumiso.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# +# Construct a checksum for isolinux*.bin, compatible +# with an mkisofs boot-info-table +# + +use bytes; +use integer; + +($file) = @ARGV; + +open(FILE, '+<', $file) or die "$0: Cannot open $file: $!\n"; +binmode FILE; + +if ( !seek(FILE,64,0) ) { + die "$0: Cannot seek past header\n"; +} + +$csum = 0; +$bytes = 64; +while ( ($n = read(FILE, $dw, 4)) > 0 ) { + $dw .= "\0\0\0\0"; # Pad to at least 32 bits + ($v) = unpack("V", $dw); + $csum = ($csum + $v) & 0xffffffff; + $bytes += $n; +} + +if ( !seek(FILE,16,0) ) { + die "$0: Cannot seek to header\n"; +} + +print FILE pack("VV", $bytes, $csum); + +close(FILE); + +exit 0; diff --git a/isolinux-debug.asm b/isolinux-debug.asm deleted file mode 100644 index be3b6ce..0000000 --- a/isolinux-debug.asm +++ /dev/null @@ -1,21 +0,0 @@ -;; $Id$ -;; ----------------------------------------------------------------------- -;; -;; Copyright 2002 H. Peter Anvin - All Rights Reserved -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, Inc., 53 Temple Place Ste 330, -;; Bostom MA 02111-1307, USA; either version 2 of the License, or -;; (at your option) any later version; incorporated herein by reference. -;; -;; ----------------------------------------------------------------------- - -;; -;; isolinux-debug.asm -;; -;; Wrapper for debugging version of ISOLINUX -;; - -%define DEBUG_MESSAGES -%include "isolinux.asm" diff --git a/isolinux.asm b/isolinux.asm index 150f9cb..4da7f1b 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -240,10 +240,12 @@ _start: ; Far jump makes sure we canonicalize the address jmp 0:_start1 times 8-($-$$) nop ; Pad to file offset 8 - ; This table gets filled in by mkisofs using the - ; -boot-info-table option -bi_pvd: dd 0xdeadbeef ; LBA of primary volume descriptor -bi_file: dd 0xdeadbeef ; LBA of boot file + ; This table hopefully gets filled in by mkisofs using the + ; -boot-info-table option. If not, the values in this + ; table are default values that we can use to get us what + ; we need, at least under a certain set of assumptions. +bi_pvd: dd 16 ; LBA of primary volume descriptor +bi_file: dd 0 ; LBA of boot file bi_length: dd 0xdeadbeef ; Length of boot file bi_csum: dd 0xdeadbeef ; Checksum of boot file bi_reserved: times 10 dd 0xdeadbeef ; Reserved @@ -280,15 +282,6 @@ initial_csum: xor edi,edi loop .loop mov [FirstSecSum],edi - ; Set up boot file sizes - mov eax,[bi_length] - sub eax,SECTORSIZE-3 - shr eax,2 ; bytes->dwords - mov [ImageDwords],eax ; boot file dwords - add eax,(2047 >> 2) - shr eax,9 ; dwords->sectors - mov [ImageSectors],ax ; boot file sectors - mov [DriveNo],dl %ifdef DEBUG_MESSAGES mov si,startup_msg @@ -319,11 +312,63 @@ initial_csum: xor edi,edi %endif found_drive: + ; Alright, we have found the drive. Now, try to find the + ; boot file itself. If we have a boot info table, life is + ; good; if not, we have to make some assumptions, and try + ; to figure things out ourselves. In particular, the + ; assumptions we have to make are: + ; - single session only + ; - only one boot entry (no menu or other alternatives) + + cmp dword [bi_file],0 ; Address of code to load + jne found_file ; Boot info table present :) + +;%ifdef DEBUG_MESSAGES + mov si,noinfotable_msg + call writemsg +;%endif + + ; No such luck. See if the the spec packet contained one. + mov eax,[sp_lba] + and eax,eax + jz set_file ; Good enough + +;%ifdef DEBUG_MESSAGES + mov si,noinfoinspec_msg + call writemsg +;%endif + + ; No such luck. Get the Boot Record Volume, assuming single + ; session disk, and that we're the first entry in the chain + mov eax,17 ; Assumed address of BRV + mov bx,trackbuf + call getonesec + + mov eax,[trackbuf+47h] ; Get boot catalog address + mov bx,trackbuf + call getonesec ; Get boot catalog + + mov eax,[trackbuf+28h] ; First boot entry + ; And hope and pray this is us... + ; Some BIOSes apparently have limitations on the size ; that may be loaded (despite the El Torito spec being very ; clear on the fact that it must all be loaded.) Therefore, ; we load it ourselves, and *bleep* the BIOS. +set_file: + mov [bi_file],eax + +found_file: + ; Set up boot file sizes + mov eax,[bi_length] + sub eax,SECTORSIZE-3 + shr eax,2 ; bytes->dwords + mov [ImageDwords],eax ; boot file dwords + add eax,(2047 >> 2) + shr eax,9 ; dwords->sectors + mov [ImageSectors],ax ; boot file sectors + mov eax,[bi_file] ; Address of code to load inc eax ; Don't reload bootstrap code %ifdef DEBUG_MESSAGES @@ -749,6 +794,8 @@ loaded_msg: db 'Loaded boot image, verifying...', CR, LF, 0 verify_msg: db 'Image checksum verified.', CR, LF, 0 allread_msg db 'Main image read, jumping to main code...', CR, LF, 0 %endif +noinfotable_msg db 'No boot info table, assuming single session disk...', CR, LF, 0 +noinfoinspec_msg db 'Spec packet missing LBA information, trying to wing it...', CR, LF, 0 spec_err_msg: db 'Loading spec packet failed, trying to wing it...', CR, LF, 0 maybe_msg: db 'Found something at drive = ', 0 alright_msg: db 'Looks like it might be right, continuing...', CR, LF, 0 @@ -782,22 +829,6 @@ sp_chs: db 0,0,0 ; Simulated CHS geometry sp_dummy: db 0 ; Scratch, safe to overwrite ; -; Spec packet for disk image emulation -; - align 8, db 0 -dspec_packet: db 13h ; Size of packet -dsp_media: db 0 ; Media type -dsp_drive: db 0 ; Drive number -dsp_controller: db 0 ; Controller index -dsp_lba: dd 0 ; LBA for emulated disk image -dsp_devspec: dw 0 ; IDE/SCSI information -dsp_buffer: dw 0 ; User-provided buffer -dsp_loadseg: dw 0 ; Load segment -dsp_sectors: dw 1 ; Sector count -dsp_chs: db 0,0,0 ; Simulated CHS geometry -dsp_dummy: db 0 ; Scratch, safe to overwrite - -; ; EBIOS drive parameter packet ; align 8, db 0 @@ -1667,6 +1698,7 @@ img_table: ; ; Misc initialized (data) variables ; + align 4, db 0 AppendLen dw 0 ; Bytes in append= command OntimeoutLen dw 0 ; Bytes in ontimeout command OnerrorLen dw 0 ; Bytes in onerror command @@ -1684,6 +1716,22 @@ UserFont db 0 ; Using a user-specified font ScrollAttribute db 07h ; White on black (for text mode) ; +; Spec packet for disk image emulation +; + align 8, db 0 +dspec_packet: db 13h ; Size of packet +dsp_media: db 0 ; Media type +dsp_drive: db 0 ; Drive number +dsp_controller: db 0 ; Controller index +dsp_lba: dd 0 ; LBA for emulated disk image +dsp_devspec: dw 0 ; IDE/SCSI information +dsp_buffer: dw 0 ; User-provided buffer +dsp_loadseg: dw 0 ; Load segment +dsp_sectors: dw 1 ; Sector count +dsp_chs: db 0,0,0 ; Simulated CHS geometry +dsp_dummy: db 0 ; Scratch, safe to overwrite + +; ; Variables that are uninitialized in SYSLINUX but initialized here ; ; **** ISOLINUX:: We may have to make this flexible, based on what the