wok-6.x rev 17473

syslinux/iso2exe: add 64bits support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 27 17:56:57 2014 +0100 (2014-12-27)
parents c8d2616c785e
children f889c01820d0
files ipxe/stuff/lkrnprefix.S syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/bootlinux.c syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso9660.c syslinux/stuff/iso2exe/libdos.c
line diff
     1.1 --- a/ipxe/stuff/lkrnprefix.S	Sat Dec 27 17:44:46 2014 +0200
     1.2 +++ b/ipxe/stuff/lkrnprefix.S	Sat Dec 27 17:56:57 2014 +0100
     1.3 @@ -101,6 +101,7 @@
     1.4  	.word	-( HEADER_SIZE / 16 )	// Initial (relative) CS value
     1.5  //	.word	0x001C			// File address of relocation table
     1.6  //	.word	0,0,0			// Overlay number
     1.7 +	.ascii	"(SliTaz)"
     1.8  
     1.9  start:
    1.10  	pushw	%dx
     2.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Sat Dec 27 17:44:46 2014 +0200
     2.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Sat Dec 27 17:56:57 2014 +0100
     2.3 @@ -90,9 +90,7 @@
     2.4  dxfound:
     2.5  	movw	%dx, 10(%bp)
     2.6  	call	checkboot
     2.7 -noboot:
     2.8  	.ascii	"No isolinux mbr."
     2.9 -noboot_end:
    2.10  
    2.11  	.org	0x0080
    2.12  ////////////////////////////// EXE/PE header //////////////////////////////////
    2.13 @@ -109,13 +107,12 @@
    2.14  	iret
    2.15  
    2.16  error:
    2.17 -	movw	$noboot_end-noboot, %cx
    2.18 -putsloop:
    2.19  	lodsb
    2.20  	movw	$7, %bx
    2.21  	movb	$0xE, %ah
    2.22  	int	$0x10
    2.23 -	loop	putsloop
    2.24 +	cmp	$'.', %al
    2.25 +	jne	error
    2.26  halt:
    2.27  	hlt
    2.28  	jmp	halt
    2.29 @@ -128,10 +125,13 @@
    2.30  	cld
    2.31  	movw	$0x100, %si
    2.32  	movw	-127(%si), %ax
    2.33 +	cmpb	$0x2F, %al
    2.34 +	je	ishelp
    2.35 +	cmpw	$0x2F20, %ax
    2.36 +ishelp:
    2.37 +	movw	$0x3000+EXESTR(help), %ax
    2.38  	cwd				// clear dx
    2.39  	pushw	%dx			// dos exit()
    2.40 -	cmpw	$0x2F20, %ax
    2.41 -	movw	$0x3000+EXESTR(help), %ax
    2.42  	je	abort
    2.43  	int	$0x21			// get DOS version
    2.44  	cmpb	$3, %al
    2.45 @@ -197,9 +197,9 @@
    2.46  	movw	$0x0100, %di
    2.47  	movw	comstart-end_header(%di), %si		// .com address
    2.48  	pushw	%di
    2.49 -	movb	$0x7D, %ch
    2.50 +	movb	$0x7C/2, %ch	// 31K-31.5K, > com length
    2.51  	rep
    2.52 -	movsb
    2.53 +	movsw
    2.54  moveret:
    2.55  	ret
    2.56  
    2.57 @@ -213,12 +213,13 @@
    2.58  	movw	%dx, %ds		// %dx = 0
    2.59  	movw	0x67*4+2, %ds
    2.60  	movw	$10, %si
    2.61 -	lodsl
    2.62 +	lodsw
    2.63  	xorw	$0x4D45, %ax		// EM(MX) or EM(MQ)
    2.64 -	lodsl
    2.65 +	lodsw
    2.66 +	lodsw
    2.67  	popw	%ds
    2.68  	jne	NoVCPI
    2.69 -	xorl	$0x30585858, %eax	// XXX0
    2.70 +	xorw	$0x5858, %ax		// XX(X0)
    2.71  	movw	$EXEADRS(CmdVCPI), %si
    2.72  ChkVCPI:
    2.73  NoVCPI:
    2.74 @@ -237,11 +238,10 @@
    2.75  	.byte	0x46			// version
    2.76  	.byte	0
    2.77  
    2.78 -// -------------------------------------------------------------------
    2.79 -
    2.80 -help:
    2.81 -	.ascii	"SliTaz GNU/L"		// SliTaz GNU/Linux boot loader
    2.82 -	.byte	EXESTR(iloader)
    2.83 +// --------------- Must be in 7F40 7FFF range ------------------------
    2.84 +//noloader:
    2.85 +//	.ascii	"No isol"		// No isolinux boot loader
    2.86 +//	.byte	EXESTR(iloader)
    2.87  no386:
    2.88  	.ascii	"No 386"		// No 386+
    2.89  	.byte	EXESTR(plus)
    2.90 @@ -258,20 +258,12 @@
    2.91  	.ascii	"Invalid: paging + "	// Invalid: paging + real mode.
    2.92  realmodemsg:
    2.93  	.ascii	"real"			// real mode.
    2.94 -// --------------- Must be in 00C0 013F range ------------------------
    2.95 +// --------------- Must be in 7FC0 7FFF range ------------------------
    2.96  mode:
    2.97  	.ascii	" mod"
    2.98  eeol:
    2.99  	.ascii  "e"
   2.100  	.byte	EXESTR(eol)
   2.101 -//noloader:
   2.102 -//	.ascii	"No isol"		// No isolinux boot loader
   2.103 -iloader:
   2.104 -	.ascii	"inux boot loader"
   2.105 -eol:
   2.106 -	.ascii	"."
   2.107 -eol2:
   2.108 -	.asciz	"\r\n"
   2.109  noDOS3:
   2.110  	.ascii	"No DOS 3"		// No DOS 3.0+
   2.111  dot0:
   2.112 @@ -279,6 +271,14 @@
   2.113  plus:
   2.114  	.ascii	"+"
   2.115  	.byte	EXESTR(eol2)
   2.116 +help:
   2.117 +	.ascii	"SliTaz GNU/L"		// SliTaz GNU/Linux boot loader
   2.118 +iloader:
   2.119 +	.ascii	"inux boot loader"
   2.120 +eol:
   2.121 +	.ascii	"."
   2.122 +eol2:
   2.123 +	.asciz	"\r\n"
   2.124  
   2.125  	.org	0x8000
   2.126  ////////////////////////// ISO9660 header /////////////////////////////////////
     3.1 --- a/syslinux/stuff/iso2exe/bootlinux.c	Sat Dec 27 17:44:46 2014 +0200
     3.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c	Sat Dec 27 17:56:57 2014 +0100
     3.3 @@ -1,6 +1,9 @@
     3.4  #include <stdio.h>
     3.5  #include "libdos.h"
     3.6  #include "iso9660.h"
     3.7 +#asm
     3.8 +		use16	86
     3.9 +#endasm
    3.10  
    3.11  #define ELKSSIG		0x1E6
    3.12  #define SETUPSECTORS	0x1F1
    3.13 @@ -47,8 +50,10 @@
    3.14  		mov	ax, _iselks
    3.15  		dec	ax
    3.16  		je	fakerealmode	// elks may run on a 8086
    3.17 +		use16	286
    3.18  		smsw	ax		// 286+
    3.19  		and	ax, #1		// 0:realmode	1:vm86
    3.20 +		use16	86
    3.21  fakerealmode:
    3.22  #endasm
    3.23  } 
    3.24 @@ -95,20 +100,23 @@
    3.25  		  movw
    3.26  		jmp	movedone
    3.27  movehiz:				// 30
    3.28 +		use16	286		// more than 1Mb => 286+
    3.29  		mov	cx, #9		// 2E..1E
    3.30  zero1:
    3.31  		push	ax
    3.32  		loop	zero1
    3.33 -		push	dword [si]	// 1A mem.base
    3.34 +		push	word [si+2]
    3.35 +		push	word [si]	// 1A mem.base
    3.36  		push	#-1		// 18
    3.37  		push	ax		// 16
    3.38 -		cwde
    3.39 -		cdq
    3.40 -		mov	dx, ds
    3.41 -		shl	edx, #4
    3.42 -		mov	ax, #_buffer
    3.43 -		add	edx, eax
    3.44 -		push	edx		// 12 linear_address(buffer)
    3.45 +		mov	ax, ds
    3.46 +		mov	dx, ax
    3.47 +		shl	ax, #4
    3.48 +		shr	dx, #12
    3.49 +		add	ax, #_buffer
    3.50 +		adc	dx, #0
    3.51 +		push	dx
    3.52 +		push	ax
    3.53  		push	#-1		// 10
    3.54  		mov	cl, #8		// 0E..00
    3.55  zero2:
    3.56 @@ -124,6 +132,7 @@
    3.57  		xchg	[si+0x1F], al	// bits 24..31
    3.58  		int	0x15
    3.59  		add	sp, #0x30
    3.60 +		use16	86
    3.61  movedone:
    3.62  		pop	di
    3.63  		pop	si
    3.64 @@ -427,11 +436,13 @@
    3.65  mvdown:
    3.66  		mov	[si+0x12+2], bx	// srce
    3.67  		mov	[si+0x1A+2], cx	// dest
    3.68 -		pusha			// more than 1Mb => 286+
    3.69 +		use16	286		// more than 1Mb => 286+
    3.70 +		pusha
    3.71  		mov	cx, #0x8000
    3.72  		mov	ah, #0x87
    3.73  		int	0x15
    3.74  		popa
    3.75 +		use16	86
    3.76  		inc	bx
    3.77  		inc	cx
    3.78  		cmp	dl, bl
     4.1 --- a/syslinux/stuff/iso2exe/init	Sat Dec 27 17:44:46 2014 +0200
     4.2 +++ b/syslinux/stuff/iso2exe/init	Sat Dec 27 17:56:57 2014 +0100
     4.3 @@ -33,6 +33,13 @@
     4.4  	umount /proc
     4.5  }
     4.6  
     4.7 +bytes2bin()
     4.8 +{
     4.9 +	for i in $@ ; do
    4.10 +		printf '\\\\x%02X' $(($i&255)) | xargs echo -en
    4.11 +	done
    4.12 +}
    4.13 +
    4.14  words2bin()
    4.15  {
    4.16  	for i in $@ ; do
    4.17 @@ -218,7 +225,7 @@
    4.18  		if [ -d /media/cdrom/fs ]; then
    4.19  			cp -a /media/cdrom/fs/. /mnt/slitaz
    4.20  		elif is_loram ; then
    4.21 -			for i in /media/cdrom/boot/rootfs?.* ; do
    4.22 +			for i in /media/cdrom/boot/rootfs?*.* ; do
    4.23  				[ -s $(basename $i) ] && continue
    4.24  				cpio -i $i
    4.25  			done
    4.26 @@ -393,6 +400,31 @@
    4.27  	cp /media/cdrom/boot/memtest /mnt/memtest.exe
    4.28  }
    4.29  
    4.30 +mkfloppy()
    4.31 +{
    4.32 +	ddq if=$1 of=/dev/fd0
    4.33 +	[ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
    4.34 +	J=$(($(get 3 $1 1) + 0x02))
    4.35 +	R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
    4.36 +	[ $R -lt 2500 ] || return
    4.37 +	[ $((($(get 500 $file)-1) & 31)) -lt 30 ] &&
    4.38 +	dd if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
    4.39 +	G="18 0 2 0 0 0 0 0"
    4.40 +	[ $J -gt 25 ] || G=""
    4.41 +	F=0
    4.42 +	for i in 1 2 3; do
    4.43 +		F=$((((2880-$R-$F-$F)*3+1023)/1024))
    4.44 +	done
    4.45 +	bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
    4.46 +		0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
    4.47 +		$G | ddq bs=1 of=/dev/fd0
    4.48 +	ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
    4.49 +	for i in $R $(($R+$F)) ; do
    4.50 +		bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
    4.51 +	done
    4.52 +	echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
    4.53 +}
    4.54 +
    4.55  fdmemtest()
    4.56  {
    4.57  	$DIALOG --clear \
    4.58 @@ -403,8 +435,7 @@
    4.59  miss many of the failures that are detected by Memtest86.\n\n
    4.60  Please insert a blank disk in floppy drive.\n
    4.61  " 12 70
    4.62 -	[ $? -eq 0 ] || return
    4.63 -	ddq if=/media/cdrom/boot/memtest of=/dev/fd0
    4.64 +	[ $? -eq 0 ] && mkfloppy /media/cdrom/boot/memtest
    4.65  }
    4.66  
    4.67  pxe()
    4.68 @@ -433,8 +464,7 @@
    4.69  from the Web using PXE and HTTP protocols.\n\n
    4.70  Please insert a blank disk in floppy drive.\n
    4.71  " 12 70
    4.72 -	[ $? -eq 0 ] || return
    4.73 -	ddq if=/media/cdrom/boot/?pxe of=/dev/fd0
    4.74 +	[ $? -eq 0 ] && mkfloppy /media/cdrom/boot/?pxe
    4.75  }
    4.76  
    4.77  gotposixovl()
     5.1 --- a/syslinux/stuff/iso2exe/iso9660.c	Sat Dec 27 17:44:46 2014 +0200
     5.2 +++ b/syslinux/stuff/iso2exe/iso9660.c	Sat Dec 27 17:56:57 2014 +0100
     5.3 @@ -3,6 +3,9 @@
     5.4  #include <stdio.h>
     5.5  #include "iso9660.h"
     5.6  #define __ROCKRIDGE
     5.7 +#asm
     5.8 +		use16	86
     5.9 +#endasm
    5.10  
    5.11  char *isofilename;
    5.12  unsigned long isofileofs, isofilesize;
    5.13 @@ -121,12 +124,56 @@
    5.14  	return 0;
    5.15  }
    5.16  
    5.17 +static int cpuhaslm(void)
    5.18 +{
    5.19 +#asm
    5.20 +	pushf			// save flags
    5.21 +		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
    5.22 +		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
    5.23 +	mov	ax, #0x1000
    5.24 +	push	ax
    5.25 +	popf			// < 286 : flags[12..15] are forced 1
    5.26 +	pushf			// = 286 : flags[12..15] are forced 0
    5.27 +	pop	bx		// > 286 : only flags[15] is forced 0
    5.28 +	popf			// restore flags (IOPL)
    5.29 +	add	bh, ah		// test F0 and 00 cases
    5.30 +	cmp	bh, ah
    5.31 +	cbw
    5.32 +	jbe	not386		// C=8086/80186, Z=80286
    5.33 +	use16	386
    5.34 +	pushfd
    5.35 +	pushfd
    5.36 +	pop	ebx
    5.37 +	mov	ecx, ebx
    5.38 +	btc	ebx, #21	// toggle CPUID feature bit
    5.39 +	push	ebx
    5.40 +	popfd
    5.41 +	pushfd
    5.42 +	pop	ebx
    5.43 +	popfd
    5.44 +	xor	ebx, ecx
    5.45 +	bt	ebx, #21	// CPUID feature bit ?
    5.46 +	jnc	nocpuid
    5.47 +	mov	eax, #0x80000001	// Extended Processor Info and Feature Bits
    5.48 +	.byte	0x0F, 0xA2	// cpuid
    5.49 +	xor	ax, ax
    5.50 +	bt	edx, #29	// LM feature bit ?
    5.51 +	adc	ax, ax
    5.52 +	use16	86
    5.53 +nocpuid:
    5.54 +not386:
    5.55 +#endasm
    5.56 +}
    5.57 +
    5.58  #define IS_DIR(x)( ((x) & ~0777) == 040000)
    5.59 -int isoopen(char *name)
    5.60 +int isoopen(char *filename)
    5.61  {
    5.62  	int restart;
    5.63 -	char *s, c;
    5.64 +	char *name, *s, c;
    5.65 +	int _64bits = cpuhaslm();
    5.66  
    5.67 +retry32:
    5.68 +	name = filename;
    5.69  	while (*name == '/') {
    5.70  		name++;
    5.71  		isoreset(NULL);
    5.72 @@ -137,7 +184,14 @@
    5.73  		c = *s;
    5.74  		*s = 0;
    5.75  		for (restart = 1; isoreaddir(restart) == 0; restart = 0) {
    5.76 -			if (strcmp(name, isofilename)) continue;
    5.77 +			char *n = name, *i = isofilename;
    5.78 +			if (_64bits) {
    5.79 +				int len = strlen(name);
    5.80 +				if (strncmp(name, isofilename), len) continue;
    5.81 +				n = "64";
    5.82 +				i += len;
    5.83 +			}
    5.84 +			if (strcmp(n, i)) continue;
    5.85  			if (IS_DIR(isofilemod)) {
    5.86  				isodirofs = isofileofs;
    5.87  				isodirsize = isofilesize;
    5.88 @@ -149,6 +203,11 @@
    5.89  			}
    5.90  			return 0;
    5.91  		}
    5.92 +		if (_64bits) {
    5.93 +			_64bits = 0;
    5.94 +			*s = c;
    5.95 +			goto retry32;
    5.96 +		}
    5.97  		return -1;
    5.98  	  next: ;
    5.99  	}
     6.1 --- a/syslinux/stuff/iso2exe/libdos.c	Sat Dec 27 17:44:46 2014 +0200
     6.2 +++ b/syslinux/stuff/iso2exe/libdos.c	Sat Dec 27 17:56:57 2014 +0100
     6.3 @@ -1,4 +1,7 @@
     6.4  #include "libdos.h"
     6.5 +#asm
     6.6 +		use16	86
     6.7 +#endasm
     6.8  
     6.9  char *progname(void)
    6.10  {
    6.11 @@ -165,7 +168,10 @@
    6.12  		pop	si
    6.13  		jne	stepagain
    6.14  		seg	cs
    6.15 -		lss	sp, stack
    6.16 +		lds	di, stack
    6.17 +		push	ds
    6.18 +		pop	ss
    6.19 +		mov	sp, di
    6.20  		pop	ds
    6.21  		pop	di
    6.22  		pop	si