wok-next rev 13713
syslinux/iso2exe: add loram support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 18 16:09:07 2012 +0100 (2012-12-18) |
parents | 493d6ffb095b |
children | aec1594b57d7 |
files | syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/syslinux/stuff/iso2exe/bootiso.S Tue Dec 18 02:59:46 2012 +0000 1.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Tue Dec 18 16:09:07 2012 +0100 1.3 @@ -39,10 +39,14 @@ 1.4 start: 1.5 incw %bp 1.6 pushw %dx // restore SP 1.7 + pushw $0 1.8 + popw %ds 1.9 + movw $0x7C00, %bx 1.10 + pushfw 1.11 + pushw %ds 1.12 + pushw %bx 1.13 pushaw 1.14 movw %sp, %bp 1.15 - pushf 1.16 - pushw %ds 1.17 pushw %es 1.18 call setreg 1.19 rep 1.20 @@ -58,10 +62,8 @@ 1.21 int $0x13 1.22 setreg: 1.23 cld 1.24 - xorw %bx, %bx // Clear C 1.25 - movw %bx, %ds 1.26 - movw %bx, %es 1.27 - movb $0x7C, %bh 1.28 + pushw %ds 1.29 + popw %es 1.30 movw %bx, %si 1.31 movw $0x0600, %di 1.32 movw $0x0100, %cx 1.33 @@ -83,147 +85,144 @@ 1.34 xchgw %ax, %dx 1.35 jnz dxloop 1.36 fail: 1.37 - int $0x19 1.38 + movw $0x0600+noloader, %si 1.39 + call putslp 1.40 +stop: 1.41 + hlt 1.42 + jmp stop 1.43 dxfound: 1.44 movw %dx, 10(%bp) 1.45 call readsector2 1.46 lodsw 1.47 - decw %ax 1.48 + shrw $1, %ax 1.49 jz fail // read fail or not isohydrid 1.50 popw %es 1.51 - popw %ds 1.52 - popf 1.53 popa 1.54 - ljmp $0, $0x7C00 1.55 + iret 1.56 1.57 + 1.58 ////////////////////////////// DOS EXE code /////////////////////////////////// 1.59 1.60 +help: 1.61 + .ascii "SliTaz GNU/Linux" 1.62 + .byte EXESTR(loader) 1.63 +no386: 1.64 + .ascii "No 386" // No 386+ 1.65 + .byte EXESTR(plus) 1.66 +ERRvcpi: 1.67 + .ascii "No EMM386/VCPI 4" // No EMM386/VCPI 4.0+ 1.68 + .byte EXESTR(dot0) 1.69 +chkerr: 1.70 + .ascii "Broken ISO image fil" // Broken ISO image file. 1.71 + .byte EXESTR(eeol) 1.72 +vm86modemsg: 1.73 + .ascii "vm86" // vm86 mode. 1.74 + .byte EXESTR(mode) 1.75 +rmPaging: 1.76 + .ascii "Invalid: paging + " // Invalid: paging + real mode. 1.77 +realmodemsg: 1.78 + .ascii "real" // real mode. 1.79 +// ------------------------------------------------------------------- 1.80 +mode: 1.81 + .ascii " mod" 1.82 +eeol: 1.83 + .ascii "e" 1.84 + .byte EXESTR(eol) 1.85 +noloader: 1.86 + .ascii "No" 1.87 +loader: 1.88 + .ascii " boot loader" 1.89 eol: 1.90 - .ascii ".\r\n$" 1.91 -no386: 1.92 - .ascii "No 386+$" 1.93 + .ascii "." 1.94 +eol2: 1.95 + .asciz "\r\n" 1.96 noDOS3: 1.97 - .ascii "No DOS 3.0+$" 1.98 -rmPaging: 1.99 - .ascii "Broken paging$" 1.100 -ERRvcpi: 1.101 - .ascii "No EMM386/VCPI 4.0+$" 1.102 -chkerr: 1.103 - .ascii "Broken ISO file$" 1.104 -realmodemsg: 1.105 - .ascii "Real mode$" 1.106 -vm86modemsg: 1.107 - .ascii "VM86 mode$" 1.108 -help: 1.109 - .ascii "SliTaz GNU/Linux boot loader$" 1.110 + .ascii "No DOS 3" // No DOS 3.0+ 1.111 +dot0: 1.112 + .ascii ".0" 1.113 +plus: 1.114 + .ascii "+" 1.115 + .byte EXESTR(eol2) 1.116 1.117 fixseg: 1.118 cld 1.119 - movb $EXESTR(help), %dl 1.120 movw $0x100, %si 1.121 - cmpw $0x3F2F, -126(%si) # /? 1.122 + movw -127(%si), %ax 1.123 + cwd 1.124 + pushw %dx // dos exit 1.125 + cmpw $0x2F20, %ax 1.126 + movb $EXESTR(help), %al 1.127 je abort 1.128 movw (%si), %cx 1.129 jcxz skip 1.130 - xorw %dx, %dx 1.131 movw $0x7FE0/2, %cx 1.132 chklp: 1.133 lodsw 1.134 addw %ax, %dx 1.135 loop chklp 1.136 orw %dx, %dx 1.137 - movb $EXESTR(chkerr), %dl 1.138 + movb $EXESTR(chkerr), %al 1.139 jne abort 1.140 skip: 1.141 - pushf 1.142 - popw %ax 1.143 - movw $0xF0F0, %dx 1.144 - orb %ah, %dh 1.145 - andb $0xF, %ah 1.146 + pushfw // save flags 1.147 + // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1.148 + // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF 1.149 + movb $0x70, %ah 1.150 pushw %ax 1.151 - popf 1.152 - pushf 1.153 - popw %ax 1.154 - andb %dl, %ah 1.155 - cmp %dl, %ah 1.156 - je NotSupported // 8086 family 1.157 - pushw %dx 1.158 - popf 1.159 - pushf 1.160 - popw %ax 1.161 - andb %dl, %ah 1.162 - jnz is386 // 80286 family 1.163 + popfw // < 286 : flags[12..15] are forced 1 1.164 + pushfw // = 286 : flags[12..15] are forced 0 1.165 + popw %ax // > 286 : only flags[15] is forced 0 1.166 + popfw // restore flags 1.167 + addb $0x10, %ah // test F0 and 00 cases 1.168 + cmpb $0x10, %ah 1.169 + ja is386 // C=8086/80186, Z=80286 1.170 +#if 0 1.171 + jz is286 1.172 + xorw %bx, %bx 1.173 + movb (%bx), %dh 1.174 + decw %bx 1.175 + xorw %bx, (%bx) // 80186 write bytes at FFFF and 10000 1.176 + movw (%bx), %ax 1.177 + xorw %bx, (%bx) // 8086 write bytes at FFFF and 0000 1.178 + cmpw %ah, %dh 1.179 + jnz is186 1.180 +#endif 1.181 NotSupported: 1.182 - movb $EXESTR(no386), %dl 1.183 + movb $EXESTR(no386), %al 1.184 abort: 1.185 puts: 1.186 - movb $1, %dh 1.187 - call puts2 1.188 - movw $EXEADRS(eol), %dx 1.189 -puts2: 1.190 - movb $9, %ah 1.191 - int $0x21 1.192 - ret 1.193 + movb $1, %ah 1.194 + xchgw %ax, %si 1.195 +putslp: 1.196 + lodsb 1.197 + orb %al, %al 1.198 + jz moveret 1.199 + js puts 1.200 + movw $7, %bx 1.201 + movb $0xE, %ah 1.202 + int $0x10 1.203 + jmp putslp 1.204 1.205 is386: 1.206 movl %cr0, %eax 1.207 andb $1, %al 1.208 jne tstvcpi 1.209 - movb $EXESTR(rmPaging), %dl 1.210 shll $1, %eax 1.211 -cabort: 1.212 + movb $EXESTR(rmPaging), %al 1.213 jc abort 1.214 - movb $EXESTR(realmodemsg), %dl 1.215 - jmp realmode 1.216 - 1.217 -tstvcpi: 1.218 - pushw %ds 1.219 - movw %cx, %ds // %cx = 0 1.220 - movw 0x67*4+2, %ds 1.221 - std 1.222 - movw $14, %si 1.223 - lodsl 1.224 - cmpl $0x30585858, %eax // 0XXX 1.225 - lodsl 1.226 - cld 1.227 - popw %ds 1.228 -NoVCPI: 1.229 - movb $EXESTR(ERRvcpi), %dl 1.230 - jne abort 1.231 - shll $8, %eax 1.232 - cmpl $0x4D4D4500, %eax // [XQ]MME 1.233 - movw $EXEADRS(CmdVCPI), %si 1.234 -ChkVCPI: 1.235 - jne NoVCPI 1.236 - lodsb 1.237 - shlw $8, %ax 1.238 - je VersionVCPI 1.239 - int $0x67 1.240 - jmp ChkVCPI 1.241 - 1.242 -CmdVCPI: 1.243 - .byte 0x40 // status 1.244 - .byte 0xDE // vcpi present ? 1.245 - .byte 0x46 // version 1.246 - .byte 0 1.247 - 1.248 -VersionVCPI: 1.249 - cmpb $0x40, %al // >= 4.0 ? 1.250 - jb NoVCPI 1.251 - movb $EXESTR(vm86modemsg), %dl 1.252 + movb $EXESTR(realmodemsg), %al 1.253 realmode: 1.254 call puts 1.255 movb $0x30, %ah 1.256 int $0x21 1.257 cmpb $3, %al 1.258 - movb $EXESTR(noDOS3), %dl 1.259 - jb cabort 1.260 + movb $EXESTR(noDOS3), %al 1.261 + jb abort 1.262 movw EXEADRS(comstart), %ax // .com address 1.263 movw $moveend-move, %cx 1.264 movw $EXEADRS(move), %si 1.265 movw $0xC000, %di 1.266 jmp move2 1.267 - 1.268 move: 1.269 movb $0x80, %ch 1.270 xchgw %ax, %si 1.271 @@ -232,9 +231,49 @@ 1.272 pushw %di 1.273 rep 1.274 movsb 1.275 +moveret: 1.276 ret 1.277 moveend: 1.278 - 1.279 + 1.280 +VersionVCPI: 1.281 + cmpb $0x40, %dl // >= 4.0 ? 1.282 + jb NoVCPI 1.283 + movb $EXESTR(vm86modemsg), %al 1.284 + jmp realmode 1.285 +tstvcpi: 1.286 + pushw %ds 1.287 + movw %cx, %ds // %cx = 0 1.288 + movw 0x67*4+2, %ds 1.289 + movw $10, %si 1.290 + lodsw 1.291 + xorw $0x4D45, %ax // EM(MX) or EM(MQ) 1.292 + xchgw %ax, %dx 1.293 + lodsw // si += 2 1.294 + lodsw 1.295 + xorw $0x5858, %ax // XX 1.296 + orw %ax, %dx 1.297 + lodsw 1.298 + popw %ds 1.299 + xorw $0x3058, %ax // X0 1.300 + orw %ax, %dx 1.301 + movw $EXEADRS(CmdVCPI), %si 1.302 +ChkVCPI: 1.303 +NoVCPI: 1.304 + xchgw %ax, %dx 1.305 + movb $EXESTR(ERRvcpi), %al 1.306 + jne abort 1.307 + lodsb 1.308 + shlw $8, %ax 1.309 + je VersionVCPI 1.310 + int $0x67 1.311 + testb %ah, %ah 1.312 + jmp ChkVCPI 1.313 +CmdVCPI: 1.314 + .byte 0x40 // status 1.315 + .byte 0xDE // vcpi present ? 1.316 + .byte 0x46 // version 1.317 + .byte 0 1.318 + 1.319 .org 440 1.320 //////////////////////////// partition table ////////////////////////////////// 1.321
2.1 --- a/syslinux/stuff/iso2exe/init Tue Dec 18 02:59:46 2012 +0000 2.2 +++ b/syslinux/stuff/iso2exe/init Tue Dec 18 16:09:07 2012 +0100 2.3 @@ -4,7 +4,9 @@ 2.4 2.5 get() 2.6 { 2.7 - od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2.8 + od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null || 2.9 + dd if=$2 bs=1 skip=$1 count=${3:-2} 2> /dev/null | \ 2.10 + hexdump -e "\"\" 1/${3:-2} \"%d\"" 2.11 } 2.12 2.13 getarg() 2.14 @@ -35,17 +37,15 @@ 2.15 2.16 getiso() 2.17 { 2.18 + mkdir -p /media/cdrom 2.19 blkid | while read dev info ; do 2.20 - case "$info" in 2.21 - *dos*|*fat*|*ntfs*) 2.22 - mount ${dev%:} /mnt 2.23 - if checkmagic /mnt/$ISO; then 2.24 - mount -o loop,ro /mnt/$ISO /media/cdrom 2.25 - echo "Found $ISO on ${dev%:}" 2.26 - break 2.27 - fi 2.28 - umount /mnt ;; 2.29 - esac 2.30 + mount ${dev%:} /mnt 2.31 + if checkmagic /mnt/$ISO; then 2.32 + mount -o loop,ro /mnt/$ISO /media/cdrom 2.33 + echo "Found $ISO on ${dev%:}" 2.34 + break 2.35 + fi 2.36 + umount /mnt 2.37 done 2.38 } 2.39 2.40 @@ -75,7 +75,7 @@ 2.41 /dev/hd* /dev/sd* ; do 2.42 cp -a $i /tmp/fs$i 2.43 done 2.44 - for i in /bin/busybox /usr/sbin/mount.posixovl $(which blkid); do 2.45 + for i in /bin/busybox $(which mount.posixovl) $(which blkid); do 2.46 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \ 2.47 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib 2.48 cp $i /tmp/fs/bin 2.49 @@ -111,14 +111,33 @@ 2.50 rm -rf /tmp/fs 2.51 } 2.52 2.53 +is_loram() 2.54 +{ 2.55 + [ -s /lib/squashfs.ko* ] 2.56 +} 2.57 + 2.58 doinstall() 2.59 { 2.60 mkdir /mnt/slitaz 2.61 mount.posixovl /mnt/slitaz || return 2.62 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos 2.63 - for i in $(ls -r /media/cdrom/boot/rootfs*); do 2.64 - uncpio $i /mnt/slitaz 2.65 - done 2.66 + if [ -d /media/cdrom/fs ]; then 2.67 + cp -a /media/cdrom/fs/. /mnt/slitaz 2.68 + elif is_loram ; then 2.69 + for i in /media/cdrom/boot/rootfs?.* ; do 2.70 + [ -s $(basename $i) ] && continue 2.71 + cpio -i $i 2.72 + done 2.73 + for i in $(ls -r /media/cdrom/boot/rootfs*); do 2.74 + mount -o loop,ro $i /sqfs/mnt 2.75 + cp -a /sqfs/mnt/. /mnt/slitaz 2.76 + umount -d /sqfs/mnt 2.77 + done 2.78 + else 2.79 + for i in $(ls -r /media/cdrom/boot/rootfs*); do 2.80 + uncpio $i /mnt/slitaz 2.81 + done 2.82 + fi 2.83 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \ 2.84 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \ 2.85 /media/cdrom/README /media/cdrom/boot/memtest* ; do 2.86 @@ -135,7 +154,7 @@ 2.87 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \ 2.88 /mnt/slitaz/boot/README /mnt/slitaz/boot/tazboot.cmd 2.89 [ -x /mnt/slitaz/usr/sbin/mount.posixovl ] || 2.90 - cp /usr/sbin/mount.posixovl /mnt/slitaz/usr/sbin 2.91 + cp $(which mount.posixovl) /mnt/slitaz/usr/sbin 2.92 ! grep -qs tazboot /mnt/boot.ini && cat >> /mnt/boot.ini <<EOT 2.93 C:\\slitaz\\boot\\tazboot.exe="SliTaz" 2.94 EOT 2.95 @@ -160,7 +179,7 @@ 2.96 To do a traditional installation with disk partitioning, 2.97 start SliTaz Live with 'SliTaz RAM boot' menu.\n 2.98 " 16 70 2.99 - [ $? -eq 0 -a -x /usr/sbin/mount.posixovl ] || return 2.100 + [ $? -eq 0 -a -n "$(which mount.posixovl)" ] || return 2.101 doinstall 2.102 umount /proc 2.103 exec chroot /mnt/slitaz /sbin/init 2.104 @@ -191,7 +210,8 @@ 2.105 2.106 md5() 2.107 { 2.108 - ( cd /media/cdrom ; md5sum -c md5sum ) | tee /tmp/data 2.109 + echo "Checking files..." 2.110 + ( cd /media/cdrom ; md5sum -c md5sum ) > /tmp/data 2.111 $DIALOG --clear \ 2.112 --title " Checked files " \ 2.113 --textbox /tmp/data 24 78 2.114 @@ -325,8 +345,34 @@ 2.115 tazusb gen-iso2usb /mnt/$ISO $device 2.116 } 2.117 2.118 +mount_loram() 2.119 +{ 2.120 + is_loram || return 2.121 + insmod /lib/squashfs.ko* 2> /dev/null 2.122 + if [ -d /media/cdrom/fs ]; then 2.123 + ln -s /media/cdrom/fs /sqfs 2.124 + else 2.125 + mkdir /sqfs 2.126 + mount -o loop,ro -t squashfs /rootfs*.gz /sqfs 2.127 + fi 2.128 + ln -s /sqfs/lib/* lib 2.129 + ln -s /sqfs/usr /sqfs/var / 2.130 + for i in dmesg basename tr od reboot poweroff getty sync ; do 2.131 + ln -s /sqfs/bin/busybox /bin/$i 2.132 + done 2.133 +} 2.134 + 2.135 +umount_loram() 2.136 +{ 2.137 + is_loram || return 2.138 + rm /var /usr 2.139 + umount -d /sqfs 2.140 + rmdir /sqfs 2.141 +} 2.142 + 2.143 text() 2.144 { 2.145 + umount_loram 2.146 umount -d /media/cdrom 2.147 umount /mnt 2.148 umount /proc 2.149 @@ -342,36 +388,38 @@ 2.150 text 2.151 } 2.152 2.153 -reboot() 2.154 +restart() 2.155 { 2.156 - umount -d /media/cdrom 2.157 - umount /mnt 2.158 - /sbin/reboot -f 2.159 + sync 2.160 + [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt 2.161 + reboot -f 2.162 } 2.163 2.164 -poweroff() 2.165 +stop() 2.166 { 2.167 - umount -d /media/cdrom 2.168 - umount /mnt 2.169 - /sbin/poweroff -f 2.170 + sync 2.171 + [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt 2.172 + poweroff -f 2.173 } 2.174 2.175 shell() 2.176 { 2.177 - /sbin/getty -n -l /bin/ash 38400 tty1 2.178 + getty -n -l /bin/ash 38400 tty1 || sh 2.179 } 2.180 2.181 [ -x /usr/sbin/mount.posixovl ] || 2.182 -mv /usr/sbin/mount.posixovl.iso2exe /usr/sbin/mount.posixovl 2.183 +mv /bin/mount.posixovl.iso2exe /usr/sbin/mount.posixovl 2> /dev/null || 2.184 +mv /bin/mount.posixovl.iso2exe /bin/mount.posixovl 2.185 mount -t proc /proc /proc 2.186 -dmesg > /tmp/dmesg 2.187 ISO="$(getarg iso | sed 's/.://;s|\\|/|g')" 2.188 getiso 2.189 +mount_loram 2.190 case "$(basename $ISO | tr [A-Z] [a-z])$(getarg mode)" in 2.191 *install*) install ;; 2.192 *live*) live ;; 2.193 *text*) text ;; 2.194 esac 2.195 +dmesg > /tmp/dmesg 2.196 2.197 while true; do 2.198 exec 3>&1 2.199 @@ -389,8 +437,8 @@ 2.200 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \ 2.201 $(cdfile Xboot/gpxe "gpxe" "Get SliTaz Web boot utility") \ 2.202 $(cdfile boot/gpxe "fdgpxe" "Create a SliTaz Web boot floppy") \ 2.203 - "reboot" "Restart the computer" \ 2.204 - "poweroff" "Power off" \ 2.205 + "restart" "Restart the computer" \ 2.206 + "stop" "Power off" \ 2.207 "bootlog" "Linux boot messages" \ 2.208 "shell" "Shell prompt" \ 2.209 2>&1 1>&3`
3.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Dec 18 02:59:46 2012 +0000 3.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Tue Dec 18 16:09:07 2012 +0100 3.3 @@ -50,11 +50,12 @@ 3.4 3.5 # keep the largest room for the tazlito info file 3.6 TMP=/tmp/iso2exe$$ 3.7 - mkdir -p $TMP/usr/sbin 3.8 - cp /usr/sbin/mount.posixovl $TMP/usr/sbin/mount.posixovl.iso2exe 3.9 + mkdir -p $TMP/bin $TMP/dev 3.10 + cp /usr/sbin/mount.posixovl $TMP/bin/mount.posixovl.iso2exe 3.11 + cp -a /dev/?d?* $TMP/dev 3.12 $0 --get init > $TMP/init.exe 3.13 - chmod +x $TMP/init.exe $TMP/usr/sbin/mount.posixov* 3.14 - ( cd $TMP ; ls init.exe usr/sbin/mount.posixov* | cpio -o -H newc ) | \ 3.15 + chmod +x $TMP/init.exe $TMP/bin/mount.posixov* 3.16 + ( cd $TMP ; find * | cpio -o -H newc ) | \ 3.17 lzma e $TMP/rootfs.gz -si 2> /dev/null 3.18 SIZE=$(wc -c < $TMP/rootfs.gz) 3.19 store 28 $SIZE $1