wok rev 14257
syslinux/iso2exe: check kernel version, add floppy bootstrap stub
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Mar 28 11:51:42 2013 +0100 (2013-03-28) |
parents | 27ae6e723835 |
children | 8567588e9396 |
files | syslinux/stuff/iso2exe/Makefile syslinux/stuff/iso2exe/README syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/bootlinux.c syslinux/stuff/iso2exe/bootlinux.h syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/win32.c syslinux/stuff/iso2exe/win32.ico syslinux/stuff/iso2exe/win32.rc |
line diff
1.1 --- a/syslinux/stuff/iso2exe/Makefile Wed Mar 27 11:40:17 2013 +0100 1.2 +++ b/syslinux/stuff/iso2exe/Makefile Thu Mar 28 11:51:42 2013 +0100 1.3 @@ -35,8 +35,11 @@ 1.4 1.5 libdos.o: libdos.c libdos.h 1.6 1.7 -win32.exe: win32.c 1.8 - i586-pc-mingw32-gcc -s -o $@ $< -lws2_32 && upx --ultra-brute $@ 1.9 +win32.res: win32.rc win32.ico 1.10 + i586-pc-mingw32-windres $< -O coff -o $@ 1.11 + 1.12 +win32.exe: win32.c winutils.c win32.res 1.13 + i586-pc-mingw32-gcc -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ 1.14 1.15 %.o: %.c 1.16 $(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $<
2.1 --- a/syslinux/stuff/iso2exe/README Wed Mar 27 11:40:17 2013 +0100 2.2 +++ b/syslinux/stuff/iso2exe/README Thu Mar 28 11:51:42 2013 +0100 2.3 @@ -59,7 +59,9 @@ 2.4 +-----------------+ 2.5 | DOS .COM loader | Load bzImage, the last rootfs*.gz and the ISO initramfs 2.6 +-----------------+ 2.7 - | WIN32 PE .exe | USB boot Key creator / floppy bootstrap creator. 2.8 + | WIN32 PE .exe | NT+ boot device creator / Win9x DOS .COM launcher. 2.9 + +-----------------+ 2.10 + | floppy bootstrap| CD-ROM emulation boot driver for hard disk ISO image 2.11 +-----------------+ 2.12 unused 2.13 +-----------------+
3.1 --- a/syslinux/stuff/iso2exe/boot.c Wed Mar 27 11:40:17 2013 +0100 3.2 +++ b/syslinux/stuff/iso2exe/boot.c Thu Mar 28 11:51:42 2013 +0100 3.3 @@ -39,7 +39,8 @@ 3.4 } 3.5 if (isoopen(mode)) 3.6 isoopen("bzImage"); 3.7 - loadkernel(); 3.8 + if (loadkernel() < 0x20630) 3.9 + init = ""; // Does not support multiple initramfs 3.10 isoopen(rootfs); 3.11 loadinitrd(); 3.12 lseek(isofd, 24, SEEK_SET); 3.13 @@ -87,7 +88,7 @@ 3.14 char *kernel, *initrd, *cmdline, *cmdfile, *s; 3.15 3.16 argv[0] = progname(); 3.17 - bootiso(argv); // iso ? parsing is /init.exe stuff ! 3.18 + bootiso(argv + (argc == 2)); // iso ? parsing is /init.exe stuff ! 3.19 3.20 chdirname(*argv); 3.21 cmdfile = "tazboot.cmd";
4.1 --- a/syslinux/stuff/iso2exe/bootiso.S Wed Mar 27 11:40:17 2013 +0100 4.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Thu Mar 28 11:51:42 2013 +0100 4.3 @@ -25,6 +25,8 @@ 4.4 .word 0 // File address of relocation table 4.5 id: 4.6 .word 0 // Overlay number 4.7 +fdcnt: 4.8 + .byte 0 // Bootstrap floppy sector count 4.9 4.10 /////////////////////// Master Boot Record code ////////////////////////////// 4.11
5.1 --- a/syslinux/stuff/iso2exe/bootlinux.c Wed Mar 27 11:40:17 2013 +0100 5.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c Thu Mar 28 11:51:42 2013 +0100 5.3 @@ -156,10 +156,17 @@ 5.4 #endasm 5.5 } 5.6 5.7 -void loadkernel(void) 5.8 +static unsigned getcs(void) 5.9 +{ 5.10 +#asm 5.11 + mov ax, cs 5.12 +#endasm 5.13 +} 5.14 + 5.15 +unsigned long loadkernel(void) 5.16 { 5.17 unsigned setup, n = BUFFERSZ; 5.18 - unsigned long syssize = 0; 5.19 + unsigned long syssize = 0, version = 0; 5.20 5.21 do { 5.22 isoread(buffer, n); 5.23 @@ -181,7 +188,7 @@ 5.24 #asm 5.25 jmp end_realmode_switch 5.26 _far_realmode_switch: 5.27 - call _realmode_switch 5.28 + call REALMODE_SWITCH 5.29 cli 5.30 mov al, #0x80 // Disable NMI 5.31 out 0x70, al 5.32 @@ -236,7 +243,42 @@ 5.33 n = (setup > BUFFERSZ) ? BUFFERSZ : setup; 5.34 } while (setup > 0); 5.35 5.36 +#asm 5.37 + push ds 5.38 + push #SETUP_SEGMENT 5.39 + pop ds 5.40 + mov si, #0x200 5.41 + mov eax, #0x53726448 // HdrS 5.42 + cdq // clear edx 5.43 + cmp [si+2], eax 5.44 + jne noversion 5.45 + add si, [si+14] 5.46 + mov cx, #3 5.47 + xor ax, ax 5.48 +nextdigit: 5.49 + shl edx, #4 5.50 + or dl, al 5.51 +next: 5.52 + lodsb 5.53 + xor ah, #1 5.54 + sub al, #0x30 5.55 + cmp al, #9 5.56 + jbe nextdigit 5.57 + shr ah, #1 5.58 + jc got2 5.59 + mov al, #0xF 5.60 + and al, dl 5.61 + and dl, #0xF0 5.62 + shl edx, #4 5.63 + or dl, al 5.64 +got2: 5.65 + loop next 5.66 + pop ds 5.67 + mov .loadkernel.version[bp], edx 5.68 +noversion: 5.69 +#endasm 5.70 load(&kernelmem, syssize); 5.71 + return version; 5.72 } 5.73 5.74 void loadinitrd(void)
6.1 --- a/syslinux/stuff/iso2exe/bootlinux.h Wed Mar 27 11:40:17 2013 +0100 6.2 +++ b/syslinux/stuff/iso2exe/bootlinux.h Thu Mar 28 11:51:42 2013 +0100 6.3 @@ -1,6 +1,6 @@ 6.4 #ifndef __BOOTLINUX_H 6.5 #define __BOOTLINUX_H 6.6 -extern void loadkernel(void); 6.7 +extern long loadkernel(void); 6.8 extern void loadinitrd(void); 6.9 extern void bootlinux(char *cmdline); 6.10 #endif
7.1 --- a/syslinux/stuff/iso2exe/init Wed Mar 27 11:40:17 2013 +0100 7.2 +++ b/syslinux/stuff/iso2exe/init Thu Mar 28 11:51:42 2013 +0100 7.3 @@ -294,6 +294,67 @@ 7.4 [ -s /media/cdrom/$1 ] && echo -en "$2 ${3// /.}" 7.5 } 7.6 7.7 +fdbootstrap() 7.8 +{ 7.9 + sz=$(echo $(od -j 28 -N 1 -t u1 -An /mnt/$ISO)) 7.10 + if [ 0$sz -eq 0 ]; then 7.11 + $DIALOG --clear \ 7.12 + --title " No floppy bootstrap available " \ 7.13 + --msgbox \ 7.14 +"\nThe floppy bootstrap code is not available in the ISO file.\n\n 7.15 +Can't create the floppy.\n 7.16 +" 9 70 7.17 + else 7.18 + $DIALOG --clear \ 7.19 + --title " Create a floppy bootstrap " \ 7.20 + --yes-label "Continue" --yesno \ 7.21 +"\nThe floppy will install a driver to access to the ISO file 7.22 +on your hard disk and will emulate a CD-ROM during the boot process.\n\n 7.23 +Please insert a floppy in drive now.\n 7.24 +" 10 70 7.25 + [ $? -eq 0 ] || return 7.26 + dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$(($sz * 512)) \ 7.27 + skip=$(( $(od -j 60 -N 4 -t u4 -An) - ($sz * 512) )) 7.28 + echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 7.29 + fi 7.30 +} 7.31 + 7.32 +usbdev() 7.33 +{ 7.34 + sleep 5 7.35 + DEV="$(grep -l 1 /sys/block/*/removable | \ 7.36 + sed 's|/sys/block/\(.*\)/removable|\1|')" 7.37 + [ -n "$DEV" ] || return 7.38 + exec 3>&1 7.39 + device=`$DIALOG --clear \ 7.40 + --title " Select your USB key " \ 7.41 + --menu "\nPlease select the USB key according to its known size.\n\n" \ 7.42 + 14 70 4 \ 7.43 + $(for i in $DEV ; do 7.44 + echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB" 7.45 + done) \ 7.46 + 2>&1 1>&3` 7.47 + retval=$? 7.48 + exec 3>&- 7.49 + [ $retval -eq 0 ] 7.50 +} 7.51 + 7.52 +usbbootkey() 7.53 +{ 7.54 + $DIALOG --clear \ 7.55 + --title " Create a USB boot key " \ 7.56 + --yes-label "Continue" --yesno \ 7.57 +"\nThe USB key will be used like a CD-ROM. You will not be able to write 7.58 +any data on it.\n\n 7.59 +You should choose 'USB key read/write installation' to be 7.60 +able to save the package updates or your own configuration and data files.\n\n 7.61 +Please plug your USB stick in now.\n 7.62 +" 13 70 7.63 + [ $? -eq 0 ] || return 7.64 + usbdev || return 7.65 + dd if=/mnt/$ISO of=$device 7.66 +} 7.67 + 7.68 usbkey() 7.69 { 7.70 $DIALOG --clear \ 7.71 @@ -310,24 +371,9 @@ 7.72 Unlike a device name, the UUID has the benefit of never changing from machine 7.73 to machine.\n\n 7.74 Please plug your USB stick in now.\n 7.75 -" 18 70 7.76 +" 19 70 7.77 [ $? -eq 0 -a -n "$(which tazusb)" ] || return 7.78 - sleep 5 7.79 - DEV="$(grep -l 1 /sys/block/*/removable | \ 7.80 - sed 's|/sys/block/\(.*\)/removable|\1|')" 7.81 - [ -n "$DEV" ] || return 7.82 - exec 3>&1 7.83 - device=`$DIALOG --clear \ 7.84 - --title " Select your USB key " \ 7.85 - --menu "\nPlease select the USB key according to its known size.\n\n" \ 7.86 - 14 70 4 \ 7.87 - $(for i in $DEV ; do 7.88 - echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB" 7.89 - done) \ 7.90 - 2>&1 1>&3` 7.91 - retval=$? 7.92 - exec 3>&- 7.93 - [ $retval -eq 0 ] || continue 7.94 + usbdev || return 7.95 exec 3>&1 7.96 format=`$DIALOG --clear \ 7.97 --title " Select the filesystem " \ 7.98 @@ -341,7 +387,7 @@ 7.99 2>&1 1>&3` 7.100 retval=$? 7.101 exec 3>&- 7.102 - [ $retval -eq 0 ] || continue 7.103 + [ $retval -eq 0 ] || return 7.104 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format 7.105 tazusb gen-iso2usb /mnt/$ISO $device 7.106 } 7.107 @@ -427,13 +473,15 @@ 7.108 exec 3>&1 7.109 value=`$DIALOG --clear \ 7.110 --title " Welcome to SliTaz " \ 7.111 - --menu "\nPlease select" 17 70 9 \ 7.112 + --menu "\nPlease select" 19 70 11 \ 7.113 "live" "SliTaz RAM boot" \ 7.114 "text" "SliTaz RAM boot (text mode only)" \ 7.115 $(cdfile README "readme" "Show the README file") \ 7.116 $(cdfile md5sum "md5" "Check ISO files") \ 7.117 "install" "Hard disk installation" \ 7.118 - "usbkey" "USB key installation" \ 7.119 + "usbkey" "USB key read/write installation" \ 7.120 + "usbbootkey" "USB boot key (read only)" \ 7.121 + "fdbootstrap" "Floppy bootstrap" \ 7.122 "tazboot" "Get tazboot.exe Linux loader" \ 7.123 $(cdfile Xboot/memtest "memtest" "Get Memtest86") \ 7.124 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \
8.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Wed Mar 27 11:40:17 2013 +0100 8.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Mar 28 11:51:42 2013 +0100 8.3 @@ -59,16 +59,27 @@ 8.4 LOC=$(($LOC+40)) 8.5 done 8.6 ddq if=/tmp/exe$$ of=$1 bs=1 skip=128 seek=$OFS conv=notrunc 8.7 + store 60 $OFS $1 8.8 fi 8.9 rm -f /tmp/exe$$ 8.10 - store 60 $OFS $1 8.11 +} 8.12 + 8.13 +add_fdbootstrap() 8.14 +{ 8.15 + SIZE=$($0 --get bootfd.bin 2> /dev/null | tee /tmp/exe$$ | wc -c) 8.16 + if [ $SIZE -ne 0 ]; then 8.17 + OFS=$(( $OFS - $SIZE )) 8.18 + printf "Adding floppy bootstrap file at %04X...\n" $OFS 8.19 + $0 --get bootfd.bin | ddq of=$1 bs=1 seek=$OFS conv=notrunc 8.20 + store 28 $(($SIZE/512)) $1 8 8.21 + fi 8.22 } 8.23 case "$1" in 8.24 --build) 8.25 shift 8.26 [ $(tar cf - $@ | wc -c) -gt $((32 * 1024)) ] && 8.27 - echo "The file set $@ is too large (31K max) :" && 8.28 - ls -l $@ && exit 1 8.29 + echo "WARNING: The file set $@ is too large (31K max) :" && 8.30 + ls -l $@ 8.31 cat >> $0 <<EOM 8.32 $(tar cf - $@ | lzma e -si -so | uuencode -m -) 8.33 EOT 8.34 @@ -86,12 +97,14 @@ 8.35 add_rootfs $DATA > /dev/null 8.36 add_doscom $DATA > /dev/null 8.37 add_win32exe $DATA > /dev/null 8.38 + add_fdbootstrap $DATA > /dev/null 8.39 + name=${3:-bootiso} 8.40 cat <<EOT 8.41 8.42 -#define BOOTISOSZ $((0x8400 - $OFS)) 8.43 +#define $(echo $name | tr '[a-z]' '[A-Z]')SZ $((0x8400 - $OFS)) 8.44 8.45 #ifdef WIN32 8.46 -static char bootiso[] = { 8.47 +static char $name[] = { 8.48 $(hexdump -v -n 1024 -e '" " 16/1 "0x%02X, "' -e '" // %04.4_ax |" 16/1 "%_p" "| \n"' $DATA | sed 's/ 0x ,/ /g') 8.49 $(hexdump -v -s $OFS -e '" " 16/1 "0x%02X, "' -e '" // %04.4_ax |" 16/1 "%_p" "| \n"' $DATA | sed 's/ 0x ,/ /g') 8.50 }; 8.51 @@ -119,6 +132,7 @@ 8.52 8.53 main() 8.54 { 8.55 + [ $(id -u) -ne 0 ] && exec su -c "$0 $@" < /dev/tty 8.56 case "$1" in 8.57 --get) shift 8.58 uudecode | unlzma | tar xOf - $@ 8.59 @@ -142,6 +156,7 @@ 8.60 add_rootfs $1 8.61 add_doscom $1 8.62 add_win32exe $1 8.63 + add_fdbootstrap $1 8.64 store 26 ${RANDOM:-0} $1 8.65 i=66 8.66 n=0
9.1 --- a/syslinux/stuff/iso2exe/win32.c Wed Mar 27 11:40:17 2013 +0100 9.2 +++ b/syslinux/stuff/iso2exe/win32.c Thu Mar 28 11:51:42 2013 +0100 9.3 @@ -2,5 +2,5 @@ 9.4 9.5 int main() 9.6 { 9.7 - MessageBox(NULL,"No support for Windows yet.","Sorry",MB_OK); 9.8 + MessageBox(NULL,"No support for Windows yet.","Sorry",MB_OK|MB_ICONERROR); 9.9 }
10.1 Binary file syslinux/stuff/iso2exe/win32.ico has changed
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/syslinux/stuff/iso2exe/win32.rc Thu Mar 28 11:51:42 2013 +0100 11.3 @@ -0,0 +1,27 @@ 11.4 +/* http://msdn.microsoft.com/en-us/library/aa381058.aspx */ 11.5 + 11.6 +id ICON "./win32.ico" /* BMP32x32 */ 11.7 +1 VERSIONINFO 11.8 +FILEVERSION 1,0,0,0 11.9 +PRODUCTVERSION 1,0,0,0 11.10 +BEGIN 11.11 + BLOCK "StringFileInfo" 11.12 + BEGIN 11.13 + BLOCK "040904E4" 11.14 + BEGIN 11.15 + VALUE "CompanyName", "SliTaz" 11.16 + VALUE "FileDescription", "Hybrid ISO9660 bootstrap" 11.17 + VALUE "FileVersion", "1.0" 11.18 + VALUE "InternalName", "iso2exe" 11.19 + VALUE "LegalCopyright", "SliTaz" 11.20 + VALUE "OriginalFilename", "win32.exe" 11.21 + VALUE "ProductName", "iso2exe" 11.22 + VALUE "ProductVersion", "1.0" 11.23 + END 11.24 + END 11.25 + 11.26 + BLOCK "VarFileInfo" 11.27 + BEGIN 11.28 + VALUE "Translation", 0x409, 1252 11.29 + END 11.30 +END