wok-next rev 17160

syslinux/iso2exe: full zImage support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Sep 17 11:38:34 2014 +0200 (2014-09-17)
parents f4afbc468065
children c15bb3c9e12d
files syslinux/stuff/iso2exe/Makefile syslinux/stuff/iso2exe/README syslinux/stuff/iso2exe/a20.c syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/bootlinux.c syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/libdos.c syslinux/stuff/iso2exe/libdos.h syslinux/stuff/iso2exe/meminfo.S
line diff
     1.1 --- a/syslinux/stuff/iso2exe/Makefile	Tue Sep 16 14:21:09 2014 +0200
     1.2 +++ b/syslinux/stuff/iso2exe/Makefile	Wed Sep 17 11:38:34 2014 +0200
     1.3 @@ -7,6 +7,7 @@
     1.4  meminfo.exe: meminfo.S
     1.5  	cc -o meminfo.o -Wa,-a=meminfo.lst -c meminfo.S
     1.6  	objcopy -O binary meminfo.o meminfo.exe
     1.7 +	chmod +x $@
     1.8  
     1.9  iso2exe: iso2exe.sh boot.com bootiso.bin init win32.exe
    1.10  	cp iso2exe.sh $@
    1.11 @@ -32,6 +33,7 @@
    1.12  
    1.13  tazboot.exe: boot.com
    1.14  	com2exe $< > $@
    1.15 +	chmod +x $@
    1.16  
    1.17  OBJS = boot.o iso9660.o libdos.o bootlinux.o
    1.18  boot.com: $(OBJS)
     2.1 --- a/syslinux/stuff/iso2exe/README	Tue Sep 16 14:21:09 2014 +0200
     2.2 +++ b/syslinux/stuff/iso2exe/README	Wed Sep 17 11:38:34 2014 +0200
     2.3 @@ -36,7 +36,7 @@
     2.4  - text	 	launch SliTaz in RAM with text mode
     2.5  - install	SliTaz UMSDOS like installation
     2.6  
     2.7 -If the prognam name includes one of the supported modes, the according mode is
     2.8 +If the program name includes one of the supported modes, the according mode is
     2.9  assumed. Example 'C:\> slitazlive.exe' starts SliTaz in RAM with graphics.
    2.10  
    2.11  
     3.1 --- a/syslinux/stuff/iso2exe/a20.c	Tue Sep 16 14:21:09 2014 +0200
     3.2 +++ b/syslinux/stuff/iso2exe/a20.c	Wed Sep 17 11:38:34 2014 +0200
     3.3 @@ -1,83 +1,6 @@
     3.4  #ifndef __A20
     3.5  #define __A20
     3.6  
     3.7 -// http://www.win.tue.nl/~aeb/linux/kbd/A20.html
     3.8 -static void a20enable(void)
     3.9 -{
    3.10 -#asm
    3.11 -		call	a20test
    3.12 -
    3.13 -		in	al, 0x92	// fast A20
    3.14 -		test	al, #0x2
    3.15 -		jnz	no92
    3.16 -		or	al, #0x2	// Enable A20
    3.17 -		and	al, #0xFE	// Do not reset machine
    3.18 -		out	0x92, al
    3.19 -		call	a20test
    3.20 -no92:
    3.21 -		call	empty_8042
    3.22 -		mov	al, #0xD1	// command write
    3.23 -		out	0x64, al 
    3.24 -		call	empty_8042
    3.25 -		mov	al, #0xDF	// Enable A20
    3.26 -		out	0x60, al 
    3.27 -		call	empty_8042
    3.28 -
    3.29 -		mov	al, #0xFF	// Null command, but UHCI wants it
    3.30 -		out	0x64, al 
    3.31 -		call	empty_8042
    3.32 -		call	a20test
    3.33 -		
    3.34 -		mov	ax, #0x2401
    3.35 -		int	0x15
    3.36 -		call	a20test
    3.37 -		
    3.38 -		in	al, 0xEE	// fast enable A20
    3.39 -		jmp	a20test
    3.40 -
    3.41 -empty_8042:
    3.42 -		mov	ah, #-32
    3.43 -wait_8042:
    3.44 -		in	al, 0x64
    3.45 -		inc	ax		// FF 32x : no kbd
    3.46 -		jz	enabled
    3.47 -		dec	ax
    3.48 -		shr	ax, #1		// Bit 0: input data
    3.49 -		jc	data
    3.50 -		shr	ax, #1		// Bit 1: buffer empty
    3.51 -		jc	wait_8042
    3.52 -		ret
    3.53 -data:
    3.54 -		in	al, 0x60	// read data
    3.55 -		jmp	wait_8042
    3.56 -a20test:
    3.57 -		push	ds
    3.58 -		xor	cx, cx
    3.59 -		xor	bx, bx
    3.60 -		mov	ds, cx		// ds = 0000
    3.61 -		dec	cx
    3.62 -		mov	gs, cx		// gs = FFFF
    3.63 -		cli
    3.64 -a1:
    3.65 -		mov	ax, [bx]
    3.66 -		not	ax
    3.67 -		mov	dx, ax
    3.68 -		seg	gs
    3.69 -		xchg	dx, [bx+10]
    3.70 -		cmp	ax, [bx]
    3.71 -		seg	gs
    3.72 -		mov	[bx+10], dx
    3.73 -		loopne	a1
    3.74 -		pop	ds
    3.75 -		xchg	ax, cx
    3.76 -		sti
    3.77 -		jne	enabled
    3.78 -		pop	cx		// quit a20enable
    3.79 -enabled:
    3.80 -		ret			// ax != 0 : enabled
    3.81 -#endasm
    3.82 -}
    3.83 -
    3.84  #define A20HOLDBUFFER	0x80000
    3.85  static int a20buffer = 0;
    3.86  static void movehia20(void)
    3.87 @@ -88,7 +11,7 @@
    3.88  	}
    3.89  	a20buffer = 1;
    3.90  #asm
    3.91 -		pusha
    3.92 +		pusha			// more than 1Mb => 286+
    3.93  		push	#A20HOLDBUFFER/16
    3.94  		pop	es
    3.95  		mov	di, _mem	// mem.base & 0xFFFF
    3.96 @@ -106,9 +29,8 @@
    3.97  static void realmode_switch_a20(void)
    3.98  {
    3.99  	if (!a20buffer) return;
   3.100 -	a20enable();
   3.101  #asm
   3.102 -		pusha
   3.103 +		pusha			// more than 1Mb => 286+
   3.104  		xor	di, di		// 30
   3.105  		mov	cx, #9		// 2E..1E
   3.106  a20z1:
     4.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Tue Sep 16 14:21:09 2014 +0200
     4.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Wed Sep 17 11:38:34 2014 +0200
     4.3 @@ -127,36 +127,28 @@
     4.4  exestart:
     4.5  	cld
     4.6  	movw	$0x100, %si
     4.7 -	movw	-127(%si), %ax
     4.8 +	movw	-126(%si), %ax
     4.9  	cwd				// clear dx
    4.10  	pushw	%dx			// dos exit
    4.11 -	cmpw	$0x2F20, %ax
    4.12 -	movw	$0x1000+EXESTR(help), %ax
    4.13 -	je	abort
    4.14 -	pushfw			// save flags
    4.15 -		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
    4.16 -		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
    4.17 -	// movb	$0x10, %ah
    4.18 -	pushw	%ax
    4.19 -	popfw			// < 286 : flags[12..15] are forced 1
    4.20 -	pushfw			// = 286 : flags[12..15] are forced 0
    4.21 -	popw	%cx		// > 286 : only flags[15] is forced 0
    4.22 -	popfw			// restore flags
    4.23 -	addb	%ah, %ch	// test F0 and 00 cases
    4.24 -	cmpb	%ah, %ch
    4.25 -	movb	$EXESTR(no386), %al
    4.26 -	jbe	abort		// C=8086/80186, Z=80286
    4.27 +	cmpb	$0x2F, %al
    4.28 +	movw	$0x3000+EXESTR(help), %ax
    4.29 +	jbe	abort
    4.30 +	int	$0x21
    4.31 +	cmpb	$3, %al
    4.32 +	movb	$EXESTR(noDOS3), %al
    4.33 +	jb	abort
    4.34  #if 1
    4.35 -	movw	(%si), %cx
    4.36 -	jcxz	is386
    4.37 +	cmpw	(%si), %dx	// checksum not set
    4.38 +	je	chked
    4.39  #endif
    4.40  	movw	$(EXELOC(0x8000))/2, %cx
    4.41  chklp:
    4.42  	lodsw
    4.43  	addw	%ax, %dx
    4.44  	loop	chklp
    4.45 -	movb	$EXESTR(chkerr), %al
    4.46 -	je	is386		// dx == 0 ?
    4.47 +chked:
    4.48 +	movw	$0x1000+EXESTR(chkerr), %ax
    4.49 +	je	tst386		// dx == 0 ?
    4.50  abort:
    4.51  puts:
    4.52  	movb	$0x80, %ah
    4.53 @@ -171,21 +163,37 @@
    4.54  	int	$0x10
    4.55  	jmp	putslp
    4.56  
    4.57 +tst386:
    4.58 +	pushfw			// save flags
    4.59 +		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
    4.60 +		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
    4.61 +	// movb	$0x10, %ah
    4.62 +	pushw	%ax
    4.63 +	popfw			// < 286 : flags[12..15] are forced 1
    4.64 +	pushfw			// = 286 : flags[12..15] are forced 0
    4.65 +	popw	%bx		// > 286 : only flags[15] is forced 0
    4.66 +	popfw			// restore flags
    4.67 +	addb	%ah, %bh	// test F0 and 00 cases
    4.68 +	cmpb	%ah, %bh
    4.69 +	movb	$EXESTR(no386), %al
    4.70 +#undef NEED386
    4.71 +#ifdef NEED386
    4.72 +	jbe	abort		// C=8086/80186, Z=80286
    4.73 +#else
    4.74 +	jbe	is86		// C=8086/80186, Z=80286
    4.75 +#endif
    4.76  is386:
    4.77 -	movl	%cr0, %eax
    4.78 +	smsww	%ax		// not privileged
    4.79  	andb	$1, %al
    4.80  	jne	tstvcpi
    4.81 +	movl	%cr0, %eax	// privileged
    4.82  	incl	%eax
    4.83  	movb	$EXESTR(rmPaging), %al
    4.84  	js	abort
    4.85  	movb	$EXESTR(realmodemsg), %al
    4.86  realmode:
    4.87 +is86:
    4.88  	call	puts
    4.89 -	movb	$0x30, %ah
    4.90 -	int	$0x21
    4.91 -	cmpb	$3, %al
    4.92 -	movb	$EXESTR(noDOS3), %al
    4.93 -	jb	abort
    4.94  	movw	$0x0100, %di
    4.95  	movw	comstart-end_header(%di), %si		// .com address
    4.96  	pushw	%di
    4.97 @@ -202,7 +210,7 @@
    4.98  	jmp	realmode
    4.99  tstvcpi:
   4.100  	pushw	%ds
   4.101 -	movw	%cx, %ds		// %cx = 0
   4.102 +	movw	%dx, %ds		// %dx = 0
   4.103  	movw	0x67*4+2, %ds
   4.104  	movw	$10, %si
   4.105  	lodsl
   4.106 @@ -241,7 +249,7 @@
   4.107  	.ascii	"No EMM386/VCPI 4"	// No EMM386/VCPI 4.0+
   4.108  	.byte	EXESTR(dot0)
   4.109  chkerr:
   4.110 -	.ascii	"Broken ISO image fil"	// Broken ISO image file.
   4.111 +	.ascii	"Broken ISO9660 fil"	// Broken ISO9660 file.
   4.112  	.byte	EXESTR(eeol)
   4.113  vm86modemsg:
   4.114  	.ascii	"vm86"			// vm86 mode.
     5.1 --- a/syslinux/stuff/iso2exe/bootlinux.c	Tue Sep 16 14:21:09 2014 +0200
     5.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c	Wed Sep 17 11:38:34 2014 +0200
     5.3 @@ -1,7 +1,9 @@
     5.4  #include <stdio.h>
     5.5 +#include "libdos.h"
     5.6  #include "iso9660.h"
     5.7  
     5.8  static unsigned setup_version;
     5.9 +#define ELKSSIG		0x1E6
    5.10  #define SETUPSECTORS	0x1F1
    5.11  #define ROFLAG		0x1F2
    5.12  #define SYSSIZE		0x1F4
    5.13 @@ -39,11 +41,16 @@
    5.14  	while (1);
    5.15  }
    5.16  
    5.17 +static int iselks;
    5.18  static int vm86(void)
    5.19  {
    5.20  #asm
    5.21 -		smsw	ax
    5.22 +		xor	ax, ax
    5.23 +		cmp	ax, _iselks
    5.24 +		jne	fakerealmode	// elks may run on a 8086
    5.25 +		smsw	ax		// 286+
    5.26  		and	ax, #1		// 0:realmode	1:vm86
    5.27 +fakerealmode:
    5.28  #endasm
    5.29  } 
    5.30  
    5.31 @@ -55,13 +62,31 @@
    5.32  static void movehi(void)
    5.33  {
    5.34  #asm
    5.35 -		pusha
    5.36 +		push	si
    5.37 +		push	di
    5.38 +
    5.39 +		mov	si, #_mem
    5.40 +		cmp	word ptr [si+2], #0x10
    5.41 +		jnc	movehiz
    5.42 +		mov	ax, [si+1]
    5.43 +		mov	cl, #4
    5.44 +		shl	ax, cl		// 8086 support for elks
    5.45 +		mov	es, ax
    5.46 +		mov	di, #0x00FF
    5.47 +		and	di, [si]
    5.48 +		mov	si, #_buffer
    5.49 +		mov	cx, #BUFFERSZ/2
    5.50 +		cld
    5.51 +		rep
    5.52 +		  movw
    5.53 +		jmp	movedone
    5.54 +movehiz:
    5.55  		xor	di, di		// 30
    5.56  		mov	cx, #9		// 2E..1E
    5.57  zero1:
    5.58  		push	di
    5.59  		loop	zero1
    5.60 -		push	dword [_mem]	// 1A mem.base
    5.61 +		push	dword [si]	// 1A mem.base
    5.62  		push	#-1		// 18
    5.63  		push	di		// 16
    5.64  		xor	eax, eax
    5.65 @@ -86,15 +111,17 @@
    5.66  		xchg	[si+0x1F], al	// bits 24..31
    5.67  		int	0x15
    5.68  		add	sp, #0x30
    5.69 -		popa
    5.70 +movedone:
    5.71 +		pop	di
    5.72 +		pop	si
    5.73  #endasm
    5.74  }
    5.75  
    5.76  #define ZIMAGE_SUPPORT
    5.77 +#define FULL_ZIMAGE
    5.78  
    5.79  #ifdef ZIMAGE_SUPPORT
    5.80  static unsigned zimage = 0;
    5.81 -#ifndef FULL_ZIMAGE 
    5.82  static unsigned getss(void)
    5.83  {
    5.84  #asm
    5.85 @@ -102,18 +129,6 @@
    5.86  #endasm
    5.87  }
    5.88  #endif
    5.89 -#endif
    5.90 -
    5.91 -static int versiondos;
    5.92 -static int dosversion(void)
    5.93 -{
    5.94 -#asm
    5.95 -		mov	ah, #0x30
    5.96 -		int	0x21
    5.97 -		cbw
    5.98 -		mov	_versiondos, ax
    5.99 -#endasm
   5.100 -}
   5.101  
   5.102  static unsigned extendedramsizeinkb(void)
   5.103  {
   5.104 @@ -135,10 +150,12 @@
   5.105  		die("Need real mode");
   5.106  	switch (mem.align) {
   5.107  	case 0:	// kernel
   5.108 +#ifdef __MSDOS__ 
   5.109  		if ((unsigned) (dosversion() - 3) > 7 - 3) {
   5.110  			printf("DOS %d not supported.\nTrying anyway...\n",
   5.111  				versiondos);
   5.112  		}
   5.113 +#endif
   5.114  		mem.align = PAGE_SIZE;
   5.115  		break;
   5.116  	case PAGE_SIZE: // first initrd : keep 16M..48M for the kernel
   5.117 @@ -165,21 +182,21 @@
   5.118  	mem.base &= - mem.align;
   5.119  }
   5.120  
   5.121 +static unsigned setupseg = SETUP_SEGMENT;
   5.122  static unsigned setupofs = 0;
   5.123  
   5.124  void movesetup(void)
   5.125  {
   5.126  #asm
   5.127 -		pusha
   5.128 -		push	#SETUP_SEGMENT
   5.129 -		pop	es
   5.130 +		push	si
   5.131 +		mov	es, _setupseg
   5.132  		mov	si, #_buffer
   5.133 -		mov	di, _setupofs
   5.134 +		xchg	di, _setupofs
   5.135  		mov	cx, #BUFFERSZ/2
   5.136  		rep
   5.137  		  movsw
   5.138 -		mov	_setupofs, di
   5.139 -		popa
   5.140 +		xchg	_setupofs, di
   5.141 +		pop	si
   5.142  #endasm
   5.143  }
   5.144  
   5.145 @@ -190,23 +207,40 @@
   5.146  #endasm
   5.147  }
   5.148  
   5.149 +static unsigned long kernel_version = 0;
   5.150  unsigned long loadkernel(void)
   5.151  {
   5.152  	unsigned setup, n = BUFFERSZ;
   5.153 -	unsigned long syssize = 0, kernel_version = 0;
   5.154 +	unsigned long syssize = 0;
   5.155  
   5.156  	do {
   5.157  		isoread(buffer, n);
   5.158  		if (setupofs == 0) {
   5.159  			if (* (unsigned short *) (buffer + BOOTFLAG) != 0xAA55)
   5.160  				die("The kernel is not bootable");
   5.161 +#asm
   5.162 +			int	0x12
   5.163 +			jc	has640k
   5.164 +			dec	ax
   5.165 +			and	al, #0xC0
   5.166 +			mov	cl, #6
   5.167 +			shl	ax, cl
   5.168 +			cmp	ax, _setupseg
   5.169 +			jnc	has640k
   5.170 +			mov	_setupseg, ax
   5.171 +has640k:
   5.172 +#endasm
   5.173  			setup = (1 + buffer[SETUPSECTORS]) << 9;
   5.174  			if (setup == 512) setup = 5 << 9;
   5.175  			syssize = * (unsigned long  *) (buffer + SYSSIZE) << 4;
   5.176 +			if (!syssize) syssize = 0x7F000;
   5.177  			setup_version = * (unsigned short *) (buffer + VERSION);
   5.178  #define HDRS	0x53726448
   5.179  			if (* (unsigned long *) (buffer + HEADER) != HDRS)
   5.180  				setup_version = 0;
   5.181 +#define ELKS	0x534B4C45
   5.182 +			if (* (unsigned long *) (buffer + ELKSSIG) == ELKS)
   5.183 +				iselks = 1;
   5.184  			if (setup_version < 0x204)
   5.185  				syssize &= 0x000FFFFFUL;
   5.186  			if (setup_version) {
   5.187 @@ -237,16 +271,16 @@
   5.188  			}
   5.189  			if (!setup_version || !(buffer[LOADFLAGS] & 1)) {
   5.190  #ifdef ZIMAGE_SUPPORT
   5.191 -#ifndef FULL_ZIMAGE 
   5.192  				zimage = getss() + 0x1000;
   5.193  				mem.base = zimage * 16L; 
   5.194 -				if (mem.base + syssize > SETUP_SEGMENT*16L - 32)
   5.195 +				if (mem.base + syssize > setupseg*16L - 32) {
   5.196 +#ifdef FULL_ZIMAGE
   5.197 +					zimage = 0x11;
   5.198 +					mem.base = 0x110000L;	// 1M + 64K HMA 
   5.199 +#else
   5.200  					die("Out of memory");
   5.201 -#else
   5.202 -				zimage = 0x11;
   5.203 -				mem.base = 0x110000L;	// 1M + 64K HMA 
   5.204 -
   5.205  #endif
   5.206 +				}
   5.207  #else
   5.208  				die("Not a bzImage format");
   5.209  #endif
   5.210 @@ -258,17 +292,16 @@
   5.211  	} while (setup > 0);
   5.212  
   5.213  #asm
   5.214 +		push	si
   5.215 +		mov	si, #0x200
   5.216 +		cmp	si, _setup_version
   5.217 +		jae	noversion
   5.218  		push	ds
   5.219 -		push	#SETUP_SEGMENT
   5.220 -		pop	ds
   5.221 -		mov	si, #0x200
   5.222 -		mov	eax, #0x53726448	// HdrS
   5.223 +		mov	ds, _setupseg		// setup > 2.00 => 386+
   5.224 +		xor	eax, eax
   5.225  		cdq				// clear edx
   5.226 -		cmp	[si+2], eax
   5.227 -		jne	noversion
   5.228  		add	si, [si+14]
   5.229  		mov	cx, #3
   5.230 -		xor	ax, ax
   5.231  nextdigit:
   5.232  		shl	al, #4
   5.233  		shl	ax, #4
   5.234 @@ -281,10 +314,9 @@
   5.235  		shld	edx, eax, #8
   5.236  		loop	next
   5.237  		pop	ds
   5.238 -		mov	.loadkernel.kernel_version[bp], edx
   5.239 -		push	ds
   5.240 +		mov	_kernel_version, edx
   5.241  noversion:
   5.242 -		pop	ds
   5.243 +		pop	si
   5.244  #endasm
   5.245  	load(syssize);
   5.246  	return kernel_version;
   5.247 @@ -292,15 +324,15 @@
   5.248  
   5.249  void loadinitrd(void)
   5.250  {
   5.251 -	if (setup_version && zimage == 0)
   5.252 +	if (setup_version)
   5.253  		load(isofilesize);
   5.254  }
   5.255  
   5.256  void bootlinux(char *cmdline)
   5.257  {
   5.258 +	dosshutdown();
   5.259  #asm
   5.260 -	push	#SETUP_SEGMENT
   5.261 -	pop	es
   5.262 +	mov	es, _setupseg
   5.263  #endasm
   5.264  	if (cmdline) {
   5.265  		if (setup_version <= 0x201) {
   5.266 @@ -345,82 +377,111 @@
   5.267  #endasm
   5.268  #ifdef ZIMAGE_SUPPORT
   5.269  #asm
   5.270 +	cld
   5.271 +	mov	ax, _mem
   5.272 +	mov	dx, _mem+2
   5.273  	mov	bx, _zimage
   5.274 +	mov	bp, _iselks
   5.275 +	mov	si, #sysmove
   5.276 +	mov	di, #SETUP_END
   5.277 +	mov	cx, #endsysmove-sysmove
   5.278  	or	bx, bx
   5.279  	jz	notzimage
   5.280 -		mov	eax, _mem
   5.281 -#ifndef FULL_ZIMAGE 
   5.282 -		shr	eax, #4		// top
   5.283 -		mov	dx, #SYSTEM_SEGMENT
   5.284 -#else
   5.285 -		dec	eax
   5.286 -		shr	eax, #16
   5.287 -		inc	ax
   5.288 -		mov	dx, #SYSTEM_SEGMENT/0x1000
   5.289 -#endif
   5.290  		push	cs
   5.291  		pop	ds
   5.292 -		push	ss
   5.293 -		pop	es
   5.294  		push	es
   5.295 -		mov	si, #sysmove
   5.296 -		mov	di, #SETUP_END
   5.297  		push	di
   5.298 -		mov	cx, #endsysmove-sysmove
   5.299 -		cld
   5.300  		rep
   5.301  		  movsb
   5.302  		retf
   5.303  sysmove:
   5.304 -#ifndef FULL_ZIMAGE 
   5.305 -		mov	ds, bx
   5.306 -		mov	es, dx
   5.307 -		xor	di, di
   5.308 -		xor	si, si
   5.309 -		mov	cl, #8
   5.310 -		rep
   5.311 -		  movsw
   5.312 -		inc	bx
   5.313 +#ifdef FULL_ZIMAGE
   5.314 +		cmp	dx, #0x0010
   5.315 +		jb	lowsys
   5.316 +// bx first 64k page, dx:ax last byte+1
   5.317 +		xchg	ax, cx			// clear ax
   5.318 +		jcxz	aligned
   5.319  		inc	dx
   5.320 -		cmp	ax, bx
   5.321 -		jne	sysmove
   5.322 -#else
   5.323 -		xchg	ax, cx
   5.324 +aligned:
   5.325  		mov	si, di
   5.326 -		push	es
   5.327 -		pop	ds
   5.328 -		push	cx
   5.329  		mov	cx, #0x18
   5.330  		rep
   5.331  		  stosw
   5.332 +		push	es
   5.333 +		pop	ds
   5.334  		dec	cx
   5.335 -		mov	[si+0x10], cx
   5.336 -		mov	[si+0x18], cx
   5.337 -		pop	cx
   5.338 +		mov	[si+0x10], cx	// limit = -1
   5.339 +		mov	[si+0x18], cx	// limit = -1
   5.340 +		mov	cx, #0x9300+SYSTEM_SEGMENT/0x1000
   5.341  		mov	bh, #0x93
   5.342 -		mov	dh, #0x93
   5.343  mvdown:
   5.344  		mov	[si+0x12+2], bx	// srce
   5.345 -		mov	[si+0x1A+2], dx	// dest
   5.346 -		pusha
   5.347 +		mov	[si+0x1A+2], cx	// dest
   5.348 +		pusha			// more than 1Mb => 286+
   5.349  		mov	cx, #0x8000
   5.350  		mov	ah, #0x87
   5.351 -		int	0x15	// catched by himem.sys: may need dos=high,umb
   5.352 +		int	0x15
   5.353  		popa
   5.354  		inc	bx
   5.355 -		inc	dx
   5.356 -		cmp	cl, bl
   5.357 +		inc	cx
   5.358 +		cmp	dl, bl
   5.359  		jne	mvdown
   5.360 +		jmp	notzimage
   5.361  #endif
   5.362 +lowsys:
   5.363 +// bx first segment, dx:ax last byte+1 (paragraph aligned)
   5.364 +		mov	cl, #4
   5.365 +		shr	ax, cl
   5.366 +		mov	cl, #12
   5.367 +		shl	dx, cl
   5.368 +		or	ax, dx		// last segment+1
   5.369 +		mov	dx, #SYSTEM_SEGMENT
   5.370 +		sub	ax, bx		// ax = paragraph count
   5.371 +		sub	bx, dx
   5.372 +		jnc	sysmovelp
   5.373 +		add	dx, ax		// top down
   5.374 +		dec	dx
   5.375 +sysmovelp:		// move ax paragraphs from bx+dx:0 to dx:0
   5.376 +		mov	es, dx
   5.377 +		mov	cx, dx
   5.378 +		add	cx, bx
   5.379 +		mov	ds, cx
   5.380 +		sbb	cx, cx		// cx = 0 : -1
   5.381 +		cmc			// C  = 1 :  0
   5.382 +		adc	dx, cx
   5.383 +		xor	di, di
   5.384 +		xor	si, si
   5.385 +		mov	cx, #8
   5.386 +		rep
   5.387 +		  movsw
   5.388 +		dec	ax
   5.389 +		jne	sysmovelp
   5.390  notzimage:
   5.391 +	or	bp, bp
   5.392 +	jz	notelks
   5.393 +	push	ss
   5.394 +	pop	ds
   5.395 +	mov	cx, #0x100
   5.396 +	mov	es, cx
   5.397 +	mov	ch, #0x78	// do not overload SYSTEM_SEGMENT
   5.398 +	xor	si, si
   5.399 +	xor	di, di
   5.400 +	push	es
   5.401 +	rep
   5.402 +	  movsw
   5.403 +	pop	ss
   5.404 +notelks:
   5.405  #endasm
   5.406  #endif
   5.407  #asm
   5.408 -	push	ss
   5.409 -	pop	ds
   5.410 -	push	ds
   5.411 -	pop	es
   5.412 -	jmpi	0, #0x9020
   5.413 +	mov	ax, ss
   5.414 +	mov	ds, ax
   5.415 +	mov	es, ax
   5.416 +	add	ax, #0x20
   5.417 +	push	ax
   5.418 +	xor	dx, dx
   5.419 +	push	dx
   5.420 +	retf
   5.421  endsysmove:
   5.422  #endasm
   5.423  }
     6.1 --- a/syslinux/stuff/iso2exe/init	Tue Sep 16 14:21:09 2014 +0200
     6.2 +++ b/syslinux/stuff/iso2exe/init	Wed Sep 17 11:38:34 2014 +0200
     6.3 @@ -67,10 +67,10 @@
     6.4  {
     6.5  	echo "Extracting $(basename $1) ..."
     6.6  	case $(get 0 $1) in
     6.7 -	*35615)	zcat $1 ;;
     6.8 -	*\ 93)	unlzma -c $1 ;;
     6.9 -	*)	cat $1 ;;
    6.10 -	esac | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    6.11 +	*35615)	( zcat || gunzip ) ;;
    6.12 +	*\ 93)	unlzma ;;
    6.13 +	*)	cat ;;
    6.14 +	esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    6.15  }
    6.16  
    6.17  getuuid()
     7.1 --- a/syslinux/stuff/iso2exe/libdos.c	Tue Sep 16 14:21:09 2014 +0200
     7.2 +++ b/syslinux/stuff/iso2exe/libdos.c	Wed Sep 17 11:38:34 2014 +0200
     7.3 @@ -128,3 +128,58 @@
     7.4  		sbb	ax, ax
     7.5  #endasm
     7.6  }
     7.7 +
     7.8 +void dosshutdown(void)
     7.9 +{
    7.10 +#asm
    7.11 +		push	bp
    7.12 +		push	si
    7.13 +		push	di
    7.14 +		push	ds
    7.15 +		seg	cs
    7.16 +		mov	stack+2, ss
    7.17 +		seg	cs
    7.18 +		mov	stack,sp
    7.19 +		xor	bx, bx
    7.20 +		mov	ds, bx		// ds = 0
    7.21 +		mov	[bx+4], #step
    7.22 +		mov	[bx+6], cs
    7.23 +		pushf
    7.24 +		pop	ax
    7.25 +		or	ax, #0x100	// set TF
    7.26 +		push	ax
    7.27 +		popf
    7.28 +		jmp	far [bx+4*0x19]
    7.29 +stack:
    7.30 +		.long	0
    7.31 +stepagain:
    7.32 +		iret
    7.33 +step:
    7.34 +		push	si
    7.35 +		push	ds
    7.36 +		mov	si, sp
    7.37 +		seg	ss
    7.38 +		lds	si, [si+4]
    7.39 +		cmp	word ptr [si], #0x19CD
    7.40 +		pop	ds
    7.41 +		pop	si
    7.42 +		jne	stepagain
    7.43 +		seg	cs
    7.44 +		lss	sp, stack
    7.45 +		pop	ds
    7.46 +		pop	di
    7.47 +		pop	si
    7.48 +		pop	bp
    7.49 +#endasm
    7.50 +}
    7.51 +
    7.52 +int versiondos;
    7.53 +int dosversion(void)
    7.54 +{
    7.55 +#asm
    7.56 +		mov	ah, #0x30
    7.57 +		int	0x21
    7.58 +		cbw
    7.59 +		mov	_versiondos, ax
    7.60 +#endasm
    7.61 +}
     8.1 --- a/syslinux/stuff/iso2exe/libdos.h	Tue Sep 16 14:21:09 2014 +0200
     8.2 +++ b/syslinux/stuff/iso2exe/libdos.h	Wed Sep 17 11:38:34 2014 +0200
     8.3 @@ -6,8 +6,13 @@
     8.4  extern char *progname(void);
     8.5  extern int chdir(char *path);
     8.6  extern int chdirname(char *path);
     8.7 +extern void dosshutdown(void);
     8.8 +extern int versiondos;
     8.9 +extern int dosversion(void);
    8.10  # else
    8.11 -#define progname() argv[0]
    8.12 +#define progname() (argv[0])
    8.13  #define chdirname(x) chdir(dirname(x))
    8.14 +#define dosshutdown()
    8.15 +#define dosversion() (0)
    8.16  # endif
    8.17  #endif
     9.1 --- a/syslinux/stuff/iso2exe/meminfo.S	Tue Sep 16 14:21:09 2014 +0200
     9.2 +++ b/syslinux/stuff/iso2exe/meminfo.S	Wed Sep 17 11:38:34 2014 +0200
     9.3 @@ -53,6 +53,20 @@
     9.4  	popw	%ds
     9.5  	pushw	%cs
     9.6  	popw	%es
     9.7 +#if 1
     9.8 +	pushfw			// save flags
     9.9 +		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
    9.10 +		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
    9.11 +	movb	$0x10, %ah
    9.12 +	pushw	%ax
    9.13 +	popfw			// < 286 : flags[12..15] are forced 1
    9.14 +	pushfw			// = 286 : flags[12..15] are forced 0
    9.15 +	popw	%bx		// > 286 : only flags[15] is forced 0
    9.16 +	popfw			// restore flags
    9.17 +	addb	%ah, %bh	// test F0 and 00 cases
    9.18 +	cmpb	%ah, %bh
    9.19 +	jbe	fail		// C=8086/80186, Z=80286
    9.20 +#endif
    9.21  	xorl	%ebx, %ebx
    9.22  e820lp:
    9.23  	movl	$0xe820, %eax
    9.24 @@ -104,13 +118,15 @@
    9.25  	movw	%bx, 24+2(%di)
    9.26  	incb	%dh
    9.27  	movw	%dx, 56+2(%di)
    9.28 -	shrw	$6, %ax		// 1K -> 64K
    9.29 +	movw	%cx, %dx
    9.30 +	movb	$6, %cl
    9.31 +	shrw	%cl, %ax		// 1K -> 64K
    9.32  	jz	e801_configured
    9.33 -	shrw	$6, %cx		// 1K -> 64K
    9.34 +	shrw	%cl, %dx		// 1K -> 64K
    9.35  	addw	$0x10, %ax
    9.36 -	addw	$0x10, %cx
    9.37 +	addw	$0x10, %dx
    9.38  	movw	%ax, 8+2(%di)
    9.39 -	movw	%cx, 40+2(%di)
    9.40 +	movw	%dx, 40+2(%di)
    9.41  	movw	$extended, %si
    9.42  	call	pute801
    9.43  	call	pute801
    9.44 @@ -133,7 +149,8 @@
    9.45  	popw	%di
    9.46  	jc	fail3
    9.47  	movb	$0x10, 0+2(%di)		// 1M
    9.48 -	shrw	$6, %ax		// 1K -> 64K
    9.49 +	movb	$6, %cl
    9.50 +	shrw	%cl, %ax		// 1K -> 64K
    9.51  	jz	fail3
    9.52  	addw	$0x10, %ax
    9.53  	movw	%ax, 8+2(%di)