# HG changeset patch # User Pascal Bellard # Date 1364467902 -3600 # Node ID 65b3fd0022edfb953d1b35ad548aba1736249295 # Parent 27ae6e723835507b3e8c126d5201cb2e55fd43dc syslinux/iso2exe: check kernel version, add floppy bootstrap stub diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/Makefile --- a/syslinux/stuff/iso2exe/Makefile Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/Makefile Thu Mar 28 11:51:42 2013 +0100 @@ -35,8 +35,11 @@ libdos.o: libdos.c libdos.h -win32.exe: win32.c - i586-pc-mingw32-gcc -s -o $@ $< -lws2_32 && upx --ultra-brute $@ +win32.res: win32.rc win32.ico + i586-pc-mingw32-windres $< -O coff -o $@ + +win32.exe: win32.c winutils.c win32.res + i586-pc-mingw32-gcc -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ %.o: %.c $(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $< diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/README --- a/syslinux/stuff/iso2exe/README Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/README Thu Mar 28 11:51:42 2013 +0100 @@ -59,7 +59,9 @@ +-----------------+ | DOS .COM loader | Load bzImage, the last rootfs*.gz and the ISO initramfs +-----------------+ - | WIN32 PE .exe | USB boot Key creator / floppy bootstrap creator. + | WIN32 PE .exe | NT+ boot device creator / Win9x DOS .COM launcher. + +-----------------+ + | floppy bootstrap| CD-ROM emulation boot driver for hard disk ISO image +-----------------+ unused +-----------------+ diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/boot.c --- a/syslinux/stuff/iso2exe/boot.c Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/boot.c Thu Mar 28 11:51:42 2013 +0100 @@ -39,7 +39,8 @@ } if (isoopen(mode)) isoopen("bzImage"); - loadkernel(); + if (loadkernel() < 0x20630) + init = ""; // Does not support multiple initramfs isoopen(rootfs); loadinitrd(); lseek(isofd, 24, SEEK_SET); @@ -87,7 +88,7 @@ char *kernel, *initrd, *cmdline, *cmdfile, *s; argv[0] = progname(); - bootiso(argv); // iso ? parsing is /init.exe stuff ! + bootiso(argv + (argc == 2)); // iso ? parsing is /init.exe stuff ! chdirname(*argv); cmdfile = "tazboot.cmd"; diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/bootiso.S Thu Mar 28 11:51:42 2013 +0100 @@ -25,6 +25,8 @@ .word 0 // File address of relocation table id: .word 0 // Overlay number +fdcnt: + .byte 0 // Bootstrap floppy sector count /////////////////////// Master Boot Record code ////////////////////////////// diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/bootlinux.c --- a/syslinux/stuff/iso2exe/bootlinux.c Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/bootlinux.c Thu Mar 28 11:51:42 2013 +0100 @@ -156,10 +156,17 @@ #endasm } -void loadkernel(void) +static unsigned getcs(void) +{ +#asm + mov ax, cs +#endasm +} + +unsigned long loadkernel(void) { unsigned setup, n = BUFFERSZ; - unsigned long syssize = 0; + unsigned long syssize = 0, version = 0; do { isoread(buffer, n); @@ -181,7 +188,7 @@ #asm jmp end_realmode_switch _far_realmode_switch: - call _realmode_switch + call REALMODE_SWITCH cli mov al, #0x80 // Disable NMI out 0x70, al @@ -236,7 +243,42 @@ n = (setup > BUFFERSZ) ? BUFFERSZ : setup; } while (setup > 0); +#asm + push ds + push #SETUP_SEGMENT + pop ds + mov si, #0x200 + mov eax, #0x53726448 // HdrS + cdq // clear edx + cmp [si+2], eax + jne noversion + add si, [si+14] + mov cx, #3 + xor ax, ax +nextdigit: + shl edx, #4 + or dl, al +next: + lodsb + xor ah, #1 + sub al, #0x30 + cmp al, #9 + jbe nextdigit + shr ah, #1 + jc got2 + mov al, #0xF + and al, dl + and dl, #0xF0 + shl edx, #4 + or dl, al +got2: + loop next + pop ds + mov .loadkernel.version[bp], edx +noversion: +#endasm load(&kernelmem, syssize); + return version; } void loadinitrd(void) diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/bootlinux.h --- a/syslinux/stuff/iso2exe/bootlinux.h Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/bootlinux.h Thu Mar 28 11:51:42 2013 +0100 @@ -1,6 +1,6 @@ #ifndef __BOOTLINUX_H #define __BOOTLINUX_H -extern void loadkernel(void); +extern long loadkernel(void); extern void loadinitrd(void); extern void bootlinux(char *cmdline); #endif diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/init Thu Mar 28 11:51:42 2013 +0100 @@ -294,6 +294,67 @@ [ -s /media/cdrom/$1 ] && echo -en "$2 ${3// /.}" } +fdbootstrap() +{ + sz=$(echo $(od -j 28 -N 1 -t u1 -An /mnt/$ISO)) + if [ 0$sz -eq 0 ]; then + $DIALOG --clear \ + --title " No floppy bootstrap available " \ + --msgbox \ +"\nThe floppy bootstrap code is not available in the ISO file.\n\n +Can't create the floppy.\n +" 9 70 + else + $DIALOG --clear \ + --title " Create a floppy bootstrap " \ + --yes-label "Continue" --yesno \ +"\nThe floppy will install a driver to access to the ISO file +on your hard disk and will emulate a CD-ROM during the boot process.\n\n +Please insert a floppy in drive now.\n +" 10 70 + [ $? -eq 0 ] || return + dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$(($sz * 512)) \ + skip=$(( $(od -j 60 -N 4 -t u4 -An) - ($sz * 512) )) + echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 + fi +} + +usbdev() +{ + sleep 5 + DEV="$(grep -l 1 /sys/block/*/removable | \ + sed 's|/sys/block/\(.*\)/removable|\1|')" + [ -n "$DEV" ] || return + exec 3>&1 + device=`$DIALOG --clear \ + --title " Select your USB key " \ + --menu "\nPlease select the USB key according to its known size.\n\n" \ + 14 70 4 \ + $(for i in $DEV ; do + echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB" + done) \ + 2>&1 1>&3` + retval=$? + exec 3>&- + [ $retval -eq 0 ] +} + +usbbootkey() +{ + $DIALOG --clear \ + --title " Create a USB boot key " \ + --yes-label "Continue" --yesno \ +"\nThe USB key will be used like a CD-ROM. You will not be able to write +any data on it.\n\n +You should choose 'USB key read/write installation' to be +able to save the package updates or your own configuration and data files.\n\n +Please plug your USB stick in now.\n +" 13 70 + [ $? -eq 0 ] || return + usbdev || return + dd if=/mnt/$ISO of=$device +} + usbkey() { $DIALOG --clear \ @@ -310,24 +371,9 @@ Unlike a device name, the UUID has the benefit of never changing from machine to machine.\n\n Please plug your USB stick in now.\n -" 18 70 +" 19 70 [ $? -eq 0 -a -n "$(which tazusb)" ] || return - sleep 5 - DEV="$(grep -l 1 /sys/block/*/removable | \ - sed 's|/sys/block/\(.*\)/removable|\1|')" - [ -n "$DEV" ] || return - exec 3>&1 - device=`$DIALOG --clear \ - --title " Select your USB key " \ - --menu "\nPlease select the USB key according to its known size.\n\n" \ - 14 70 4 \ - $(for i in $DEV ; do - echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB" - done) \ - 2>&1 1>&3` - retval=$? - exec 3>&- - [ $retval -eq 0 ] || continue + usbdev || return exec 3>&1 format=`$DIALOG --clear \ --title " Select the filesystem " \ @@ -341,7 +387,7 @@ 2>&1 1>&3` retval=$? exec 3>&- - [ $retval -eq 0 ] || continue + [ $retval -eq 0 ] || return [ "$format" != "none" ] && tazusb format $device "SliTaz" $format tazusb gen-iso2usb /mnt/$ISO $device } @@ -427,13 +473,15 @@ exec 3>&1 value=`$DIALOG --clear \ --title " Welcome to SliTaz " \ - --menu "\nPlease select" 17 70 9 \ + --menu "\nPlease select" 19 70 11 \ "live" "SliTaz RAM boot" \ "text" "SliTaz RAM boot (text mode only)" \ $(cdfile README "readme" "Show the README file") \ $(cdfile md5sum "md5" "Check ISO files") \ "install" "Hard disk installation" \ - "usbkey" "USB key installation" \ + "usbkey" "USB key read/write installation" \ + "usbbootkey" "USB boot key (read only)" \ + "fdbootstrap" "Floppy bootstrap" \ "tazboot" "Get tazboot.exe Linux loader" \ $(cdfile Xboot/memtest "memtest" "Get Memtest86") \ $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \ diff -r 27ae6e723835 -r 65b3fd0022ed syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Wed Mar 27 11:40:17 2013 +0100 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Mar 28 11:51:42 2013 +0100 @@ -59,16 +59,27 @@ LOC=$(($LOC+40)) done ddq if=/tmp/exe$$ of=$1 bs=1 skip=128 seek=$OFS conv=notrunc + store 60 $OFS $1 fi rm -f /tmp/exe$$ - store 60 $OFS $1 +} + +add_fdbootstrap() +{ + SIZE=$($0 --get bootfd.bin 2> /dev/null | tee /tmp/exe$$ | wc -c) + if [ $SIZE -ne 0 ]; then + OFS=$(( $OFS - $SIZE )) + printf "Adding floppy bootstrap file at %04X...\n" $OFS + $0 --get bootfd.bin | ddq of=$1 bs=1 seek=$OFS conv=notrunc + store 28 $(($SIZE/512)) $1 8 + fi } case "$1" in --build) shift [ $(tar cf - $@ | wc -c) -gt $((32 * 1024)) ] && - echo "The file set $@ is too large (31K max) :" && - ls -l $@ && exit 1 + echo "WARNING: The file set $@ is too large (31K max) :" && + ls -l $@ cat >> $0 < /dev/null add_doscom $DATA > /dev/null add_win32exe $DATA > /dev/null + add_fdbootstrap $DATA > /dev/null + name=${3:-bootiso} cat <