wok rev 13699

syslinux/iso2exe: only DOS 3, 4 and 6 supported :-/
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 15 13:43:51 2012 +0100 (2012-12-15)
parents db0eb389448c
children 837a5d71872c
files syslinux/stuff/iso2exe/README syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/bootlinux.c syslinux/stuff/iso2exe/init
line diff
     1.1 --- a/syslinux/stuff/iso2exe/README	Fri Dec 14 22:52:32 2012 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/README	Sat Dec 15 13:43:51 2012 +0100
     1.3 @@ -18,7 +18,7 @@
     1.4  - to start SliTaz in RAM (live) in graphics mode or text mode.
     1.5  
     1.6  - to install SliTaz "a la UMSDOS" in the \slitaz\ subdirectory. The easiest
     1.7 -  way install to SliTaz. No partitioning. No questions.
     1.8 +  way to install SliTaz. No partitioning. No questions.
     1.9  
    1.10  
    1.11  Usage:
    1.12 @@ -69,7 +69,9 @@
    1.13  
    1.14  Limitations:
    1.15  
    1.16 -- Real mode support only. VM86 is not (yet?) supported.
    1.17 +- Only DOS 3, 4 and 6 supported. Checked with http://www.allbootdisks.com/
    1.18 +
    1.19 +- Real mode support only. VM86 is not supported.
    1.20  
    1.21  - Image/zImage format not supported, bzImage only. Can't boot memtest or gpxe.
    1.22  
     2.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Fri Dec 14 22:52:32 2012 +0000
     2.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Sat Dec 15 13:43:51 2012 +0100
     2.3 @@ -44,19 +44,25 @@
     2.4  	pushf
     2.5  	pushw	%ds
     2.6  	pushw	%es
     2.7 -	pushw	$0
     2.8 -	popw	%ds
     2.9  	call	setreg
    2.10  	rep
    2.11  	movsw
    2.12  	ljmp	$0, $0x0600+start2
    2.13  	
    2.14 +readsector2:
    2.15 +	incw	%cx
    2.16 +readsector1:
    2.17 +	movw	%cx, (%bx)
    2.18 +	incw	%cx
    2.19 +	movw	$0x201, %ax
    2.20 +	int	$0x13
    2.21  setreg:
    2.22  	cld
    2.23 -	pushw	%ds
    2.24 -	popw	%es
    2.25 -	movw	$0x7C00, %si
    2.26 -	movw	%si, %bx
    2.27 +	xorw	%bx, %bx		// Clear C
    2.28 +	movw	%bx, %ds
    2.29 +	movw	%bx, %es
    2.30 +	movb	$0x7C, %bh
    2.31 +	movw	%bx, %si
    2.32  	movw	$0x0600, %di
    2.33  	movw	$0x0100, %cx
    2.34  return:
    2.35 @@ -64,29 +70,26 @@
    2.36  start2:
    2.37  	movw	$0x80, %dx
    2.38  dxloop:
    2.39 -	movw	$1, %cx
    2.40 -	movw	$0x201, %ax
    2.41 -	int	$0x13
    2.42 -	jc	next
    2.43 -	call 	setreg
    2.44 +	call	readsector1
    2.45  	repe
    2.46  	cmpsw
    2.47  	je	dxfound
    2.48  next:
    2.49 -	addb	$0x7D, %dl		// try every hard disk
    2.50 -	andb	$0x83, %dl		//   and floppy disk
    2.51 -	cmpb	$0x80, %dl
    2.52 +	xorw	%cx, %cx
    2.53 +	xchgw	%ax, %dx
    2.54 +	addb	$0x7D, %al		// try every hard disk
    2.55 +	andb	$0x83, %al		//   and floppy disk
    2.56 +	cmpb	$0x80, %al
    2.57 +	xchgw	%ax, %dx
    2.58  	jnz	dxloop
    2.59  fail:
    2.60  	int	$0x19
    2.61  dxfound:
    2.62  	movw	%dx, 10(%bp)
    2.63 -	movb	$2, %cl			// %ch = 0
    2.64 -	movw	$0x201, %ax
    2.65 -	int	$0x13
    2.66 -	jc	fail
    2.67 -	cmpw	$0xAA55, 0x7DFE
    2.68 -	jne	fail
    2.69 +	call	readsector2
    2.70 +	lodsw
    2.71 +	decw	%ax
    2.72 +	jz	fail			// read fail or not isohydrid
    2.73  	popw	%es
    2.74  	popw	%ds
    2.75  	popf
    2.76 @@ -104,17 +107,18 @@
    2.77  rmPaging:
    2.78  	.ascii	"Broken paging$"
    2.79  ERRvcpi:
    2.80 -	.ascii	"No VCPI 4.0+$"
    2.81 +	.ascii	"No EMM386/VCPI 4.0+$"
    2.82  chkerr:
    2.83 -	.ascii	"Broken ISO$"
    2.84 +	.ascii	"Broken ISO file$"
    2.85  realmodemsg:
    2.86  	.ascii	"Real mode$"
    2.87  vm86modemsg:
    2.88  	.ascii	"VM86 mode$"
    2.89  help:
    2.90 -	.ascii	"SliTaz GNU/Linux bootloader$"
    2.91 +	.ascii	"SliTaz GNU/Linux boot loader$"
    2.92  
    2.93  fixseg:
    2.94 +	cld
    2.95  	movb	$EXESTR(help), %dl
    2.96  	movw	$0x100, %si
    2.97  	cmpw	$0x3F2F, -126(%si)	# /? 
    2.98 @@ -133,21 +137,21 @@
    2.99  skip:
   2.100  	pushf
   2.101  	popw	%ax
   2.102 -	movw	$0xF0F0, %cx
   2.103 -	orb	%ah, %ch
   2.104 +	movw	$0xF0F0, %dx
   2.105 +	orb	%ah, %dh
   2.106  	andb	$0xF, %ah
   2.107  	pushw	%ax
   2.108  	popf
   2.109  	pushf
   2.110  	popw	%ax
   2.111 -	andb	%cl, %ah
   2.112 -	cmp	%cl, %ah
   2.113 +	andb	%dl, %ah
   2.114 +	cmp	%dl, %ah
   2.115  	je	NotSupported	// 8086 family
   2.116 -	pushw	%cx
   2.117 +	pushw	%dx
   2.118  	popf
   2.119  	pushf
   2.120  	popw	%ax
   2.121 -	andb	%cl, %ah
   2.122 +	andb	%dl, %ah
   2.123  	jnz	is386		// 80286 family
   2.124  NotSupported:
   2.125  	movb	$EXESTR(no386), %dl
   2.126 @@ -162,24 +166,19 @@
   2.127  	ret
   2.128  
   2.129  is386:
   2.130 -	movb	$0x30, %ah
   2.131 -	int	$0x21
   2.132 -	cmpb	$3, %al
   2.133 -	movb	$EXESTR(noDOS3), %dl
   2.134 -	jb	abort
   2.135  	movl	%cr0, %eax
   2.136  	andb	$1, %al
   2.137  	jne	tstvcpi
   2.138  	movb	$EXESTR(rmPaging), %dl
   2.139  	shll	$1, %eax
   2.140 +cabort:
   2.141  	jc	abort
   2.142  	movb	$EXESTR(realmodemsg), %dl
   2.143  	jmp	realmode
   2.144  
   2.145  tstvcpi:
   2.146  	pushw	%ds
   2.147 -	pushw	$0
   2.148 -	popw	%ds
   2.149 +	movw	%cx, %ds		// %cx = 0
   2.150  	movw	0x67*4+2, %ds
   2.151  	std
   2.152  	movw	$14, %si
   2.153 @@ -190,7 +189,6 @@
   2.154  	popw	%ds
   2.155  NoVCPI:
   2.156  	movb	$EXESTR(ERRvcpi), %dl
   2.157 -goabort:
   2.158  	jne	abort
   2.159  	shll	$8, %eax
   2.160  	cmpl	$0x4D4D4500, %eax	// [XQ]MME
   2.161 @@ -215,8 +213,12 @@
   2.162  	movb	$EXESTR(vm86modemsg), %dl
   2.163  realmode:
   2.164  	call	puts
   2.165 +	movb	$0x30, %ah
   2.166 +	int	$0x21
   2.167 +	cmpb	$3, %al
   2.168 +	movb	$EXESTR(noDOS3), %dl
   2.169 +	jb	cabort
   2.170  	movw	EXEADRS(comstart), %ax			// .com address
   2.171 -	cld
   2.172  	movw	$moveend-move, %cx
   2.173  	movw	$EXEADRS(move), %si
   2.174  	movw	$0xC000, %di
     3.1 --- a/syslinux/stuff/iso2exe/bootlinux.c	Fri Dec 14 22:52:32 2012 +0000
     3.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c	Sat Dec 15 13:43:51 2012 +0100
     3.3 @@ -88,12 +88,29 @@
     3.4  #endasm
     3.5  }
     3.6  
     3.7 +static int versiondos;
     3.8 +static int dosversion(void)
     3.9 +{
    3.10 +#asm
    3.11 +		mov	ah, #0x30
    3.12 +		int	0x21
    3.13 +		cbw
    3.14 +		mov	_versiondos, ax
    3.15 +#endasm
    3.16 +}
    3.17 +
    3.18  static void load(struct mem *p, unsigned long size)
    3.19  {
    3.20  	if (vm86())
    3.21  		die("Need real mode");
    3.22  	switch (p->align) {
    3.23  	case 0:	// kernel
    3.24 +		switch (dosversion()) {
    3.25 +		case 3: case 4: case 6: break;
    3.26 +		default:
    3.27 +			printf("DOS %d not supported.\nTrying anyway...\n",
    3.28 +				versiondos);
    3.29 +		}
    3.30  		p->align = 4096;
    3.31  		break;
    3.32  	case 4096: // first initrd
     4.1 --- a/syslinux/stuff/iso2exe/init	Fri Dec 14 22:52:32 2012 +0000
     4.2 +++ b/syslinux/stuff/iso2exe/init	Sat Dec 15 13:43:51 2012 +0100
     4.3 @@ -4,7 +4,7 @@
     4.4  
     4.5  get()
     4.6  {
     4.7 -	od -j $1 -N ${3:-4} -t u${3:-4} -An $2
     4.8 +	od -j $1 -N ${3:-2} -t u${3:-2} -An $2
     4.9  }
    4.10  
    4.11  getarg()
    4.12 @@ -15,8 +15,8 @@
    4.13  gettazboot()
    4.14  {
    4.15  	echo "Creating $(basename $1) ..."
    4.16 -	O=$(($(get 34 /mnt/$ISO 2) - 0xE0))
    4.17 -	L=$((0x8000 - $(get 28 /mnt/$ISO 2) - $O))
    4.18 +	O=$(($(get 34 /mnt/$ISO) - 0xE0))
    4.19 +	L=$((0x8000 - $(get 28 /mnt/$ISO) - $O))
    4.20  	S=$((32+$L))
    4.21  	P=$((($S+511)/512))
    4.22  	E=$((4096-(32*$P)))
    4.23 @@ -30,7 +30,7 @@
    4.24  
    4.25  checkmagic()
    4.26  {
    4.27 -	[ -s $1 ] && [ $(getarg magic) == $(get 28 $1) ]
    4.28 +	[ -s $1 ] && [ $(getarg magic) == $(get 28 $1 4) ]
    4.29  }
    4.30  
    4.31  getiso()
    4.32 @@ -52,7 +52,7 @@
    4.33  uncpio()
    4.34  {
    4.35  	echo "Extracting $(basename $1) ..."
    4.36 -	case $(get 0 $1 2) in
    4.37 +	case $(get 0 $1) in
    4.38  	*35615)	zcat $1 ;;
    4.39  	*\ 93)	unlzma -c $1 ;;
    4.40  	*)	cat $1 ;;
    4.41 @@ -291,11 +291,11 @@
    4.42  Please plug your USB stick in now.\n 
    4.43  " 18 70
    4.44  	[ $? -eq 0 ] || return
    4.45 +	sleep 5
    4.46  	DEV="$(grep -l 1 /sys/block/*/removable | \
    4.47  		sed 's|/sys/block/\(.*\)/removable|\1|')"
    4.48  	[ -n "$DEV" ] || return
    4.49  	exec 3>&1
    4.50 -	sleep 5
    4.51  	device=`$DIALOG  --clear \
    4.52  	--title " Select your USB key " \
    4.53  	--menu "\nPlease select the USB key according to its known size.\n\n" \
    4.54 @@ -312,11 +312,11 @@
    4.55  	--title " Select the filesystem " \
    4.56  	--menu "\nPlease select the filesystem type to create.\n\n\
    4.57  The filesystem creation will erase all the data \
    4.58 -on the USB key." 14 70 4 \
    4.59 +in the USB key." 14 70 4 \
    4.60  		"none"	"Do not erase the USB key" \
    4.61  		"ext3"	"Ext3 journaling filesystem" \
    4.62  		"ext2"	"Ext2 filesystem" \
    4.63 -		"fat32"	"Window FAT32 filesystem" \
    4.64 +		"fat32"	"Windows FAT32 filesystem" \
    4.65  	2>&1 1>&3`
    4.66  	retval=$?
    4.67  	exec 3>&-