wok rev 24013

linld: add quick boot switch
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 18 08:56:43 2021 +0000 (5 months ago)
parents a1b12ae1c852
children c1844f1c4954
files linld/stuff/src/!COMPILE.BAT linld/stuff/src/A20.ASM linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/HIMEM.CPP linld/stuff/src/JUMP.ASM linld/stuff/src/LINK.CMD linld/stuff/src/LINLD.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/MEMTOP.ASM linld/stuff/src/VCPI.ASM linld/stuff/src/XMM.ASM linld/stuff/src/_BEG.ASM linld/stuff/src/_END.ASM linld/stuff/src/pipehole.awk wpa_supplicant/receipt
line diff
     1.1 --- a/linld/stuff/src/!COMPILE.BAT	Thu Feb 11 17:59:34 2021 +0000
     1.2 +++ b/linld/stuff/src/!COMPILE.BAT	Thu Feb 18 08:56:43 2021 +0000
     1.3 @@ -3,7 +3,8 @@
     1.4  tasm /h > helptasm.log
     1.5  bcc > helpbcc.log
     1.6  tlink > helptlink.log
     1.7 -bcc @bccopt.opt -S -mt -DISOHOOK -DMOVE_SETUP -DLARGE_IMAGES *.cpp > cpp.log
     1.8 +bcc @bccopt.opt -S -mt -DQUICK_BOOT -DISOHOOK -DMOVE_SETUP *.cpp > cpp.log
     1.9 +#bcc @bccopt.opt -S -mt -DWITH_XMM_ALLOC -DQUICK_BOOT -DISOHOOK -DMOVE_SETUP *.cpp > cpp.log
    1.10  ren LINLD.ASM LINLD.ASO
    1.11  ren LOAD.ASM LOAD.ASO
    1.12  ren HIMEM.ASM HIMEM.ASO
    1.13 @@ -12,5 +13,6 @@
    1.14  mawk -f pipehole.awk LOAD.ASO > LOAD.ASM
    1.15  mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM
    1.16  mawk -f pipehole.awk ISO9660.ASO > ISO9660.ASM
    1.17 -tasm /la /m /dISOHOOK /dBIG_CMDLINE /dMOVE_SETUP /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log
    1.18 +tasm /la /m /dQUICK_BOOT /dISOHOOK /dMOVE_SETUP /dNO386 /dLONG_FILENAME *.asm > asm.log
    1.19 +#tasm /la /m /dWITH_XMM_ALLOC /dLARGE_ZIMAGE /dQUICK_BOOT /dISOHOOK /dMOVE_SETUP /dNO386 /dLONG_FILENAME *.asm > asm.log
    1.20  tlink /m /s /t @link.cmd > lnk.log
     2.1 --- a/linld/stuff/src/A20.ASM	Thu Feb 11 17:59:34 2021 +0000
     2.2 +++ b/linld/stuff/src/A20.ASM	Thu Feb 18 08:56:43 2021 +0000
     2.3 @@ -104,7 +104,7 @@
     2.4  	global	@moverm$qpus:near
     2.5  @moverm$qpus:
     2.6  		push	si di
     2.7 -		xor	di,di
     2.8 +		xor	di,di			; default setup 9000:0000
     2.9  		extrn	_heap_top:word
    2.10  		ifdef	NO386
    2.11  		mov	ax,[_heap_top]
    2.12 @@ -119,7 +119,7 @@
    2.13  		extrn	_cpu386:byte
    2.14  		test	[_cpu386],cl
    2.15  		jne	@bzimage
    2.16 -		mov	bx,offset bzimage86
    2.17 +		mov	bx,offset bzimage86	; no himem with 8086 !
    2.18  @godie:
    2.19  		call	near die
    2.20  @zimage:
    2.21 @@ -128,7 +128,7 @@
    2.22  		jae	@sys@ok
    2.23  		xchg	ax,cx			; segment min 1000h
    2.24  @sys@ok:
    2.25 -		inc	ax
    2.26 +		inc	ax			; first free segment
    2.27  		extrn	N_LXLSH@4:near
    2.28  		call	N_LXLSH@4
    2.29  		mov	[word ((image_himem bx+4).fallback)],ax
    2.30 @@ -137,20 +137,25 @@
    2.31  		adc	dx,[word ((image_himem bx+4).size)+2]
    2.32  		ifdef	MOVE_SETUP
    2.33  		mov	di,8000h
    2.34 -		sub	di,[bx]		; rm_size
    2.35 +		sub	di,[bx]			; rm_size
    2.36  		extrn	_rm_offset:word
    2.37  		mov	[_rm_offset],di
    2.38 -		sub	ax,di		; -rm_offset
    2.39 +		sub	ax,di			; -rm_offset
    2.40  		sbb	dx,cx
    2.41  		endif
    2.42  		mov	cl,12
    2.43 -		shl	dx,cl		; last segment
    2.44 -		jc	@jbe_overflow	; >= 1Mb ?
    2.45 +		shl	dx,cl			; last sys segment
    2.46 +		ifndef	LARGE_ZIMAGE
    2.47 +		;jc	@jbe_overflow		; >= 1Mb ???
    2.48 +		else
    2.49 +		;jnc	@bzimage		; < 1Mb
    2.50 +		;mov	dh,-1
    2.51 +		endif
    2.52  @bzimage:
    2.53  		extrn	_topseg:near
    2.54  		call	near _topseg
    2.55  		mov	[word sssp+2],ax
    2.56 -		and	ch,0		; vcpi flag
    2.57 +		and	ch,0			; vcpi flag
    2.58  		org	$-1
    2.59  		global	_vcpi:byte
    2.60  _vcpi		db	?
    2.61 @@ -168,19 +173,19 @@
    2.62  		jae	@sys@ok
    2.63  		xchg	ax,cx			; segment min 1000h
    2.64  @sys@ok:
    2.65 -		inc	ax
    2.66 +		inc	ax			; first free segment
    2.67  		shl	eax,4
    2.68  		mov	[(image_himem bx+4).fallback],eax
    2.69  		add	eax,[(image_himem bx+4).size]
    2.70  		ifdef	MOVE_SETUP
    2.71  		mov	di,8000h
    2.72 -		sub	di,[bx]		; rm_size
    2.73 +		sub	di,[bx]			; rm_size
    2.74  		extrn	_rm_offset:word
    2.75  		mov	[_rm_offset],di
    2.76 -		movzx	ecx,di		; -rm_offset
    2.77 +		movzx	ecx,di			; -rm_offset
    2.78  		sub	eax,ecx
    2.79  		endif
    2.80 -		shl	eax,4
    2.81 +		shr	eax,4
    2.82  		mov	ch,0
    2.83  @bzimage:
    2.84  		xchg	ax,dx
    2.85 @@ -190,8 +195,23 @@
    2.86  		endif
    2.87  		add	dh,ch		; 60k room for malloc_bufv_or_die
    2.88  		cmp	ax,dx
    2.89 +		ifdef	LARGE_ZIMAGE
    2.90 +		ja	@nooverflow0
    2.91 +	     extrn   _cmdnum:dword
    2.92 +base_himem	=	(dword _cmdnum+12)
    2.93 +		ifdef	NO386
    2.94 +		les	cx,[base_himem]
    2.95 +		mov	[word ((image_himem bx+4).fallback)],cx
    2.96 +		mov	[word ((image_himem bx+4).fallback)+2],es
    2.97 +		else
    2.98 +		mov	ecx,[base_himem]
    2.99 +		mov	[(image_himem bx+4).fallback],ecx
   2.100 +		endif
   2.101 +@nooverflow0:
   2.102 +		endif
   2.103  		les	cx,[bx]		; rm_size
   2.104  		mov	si,es		; rm_buf
   2.105 +		ifndef	LARGE_ZIMAGE
   2.106  @jbe_overflow:
   2.107  ; Oops! We can stomp on our toes... better stop now
   2.108  		mov	bx,offset overflow
   2.109 @@ -202,6 +222,7 @@
   2.110  		call	near die
   2.111  @nooverflow:
   2.112  		endif
   2.113 +		endif
   2.114  		mov	es,ax
   2.115  @@move_clear:
   2.116  		movsb
     3.1 --- a/linld/stuff/src/COMMON.H	Thu Feb 11 17:59:34 2021 +0000
     3.2 +++ b/linld/stuff/src/COMMON.H	Thu Feb 18 08:56:43 2021 +0000
     3.3 @@ -66,21 +66,20 @@
     3.4  #define topmem		(cmdnum[2])
     3.5  #define base_himem	(cmdnum[3])
     3.6  #define	skip_alloc	(* (char *) &cmdnum[4])
     3.7 +#ifdef QUICK_BOOT
     3.8 +extern u32 cmdnum[7];
     3.9 +#else
    3.10  extern u32 cmdnum[5];
    3.11 +#endif
    3.12  
    3.13 -extern _fastcall void memcpy_image(struct image_himem *m);
    3.14 +extern _fastcall void memcpy_image_kernel();
    3.15 +extern _fastcall void memcpy_image_initrd();
    3.16  extern _fastcall void storepage(u32 *dst);
    3.17 -#ifdef LARGE_IMAGES
    3.18  extern _fastcall void reset_bufv(unsigned long *p);
    3.19  extern "C" unsigned long* prev_bufv();
    3.20  extern "C" unsigned long* next_bufv();
    3.21  #define next(p)	 p = next_bufv()
    3.22  #define prev(p)	 p = prev_bufv()
    3.23 -#else
    3.24 -#define reset_bufv(p)
    3.25 -#define next(p)	 ++p
    3.26 -#define prev(p)	 --p
    3.27 -#endif
    3.28  extern char vcpi;
    3.29  extern char version_string[];
    3.30  // External asm helpers
    3.31 @@ -89,7 +88,7 @@
    3.32  #endif
    3.33  extern "C" u32 memtop();
    3.34  extern "C" void enable_a20_or_die();
    3.35 -extern "C" void vm2rm();
    3.36 +extern "C" void far vm2rm();
    3.37  extern "C" void hook_int15_88();
    3.38  
    3.39  // C++ helpers
     4.1 --- a/linld/stuff/src/CRTL.ASM	Thu Feb 11 17:59:34 2021 +0000
     4.2 +++ b/linld/stuff/src/CRTL.ASM	Thu Feb 18 08:56:43 2021 +0000
     4.3 @@ -605,15 +605,13 @@
     4.4  
     4.5  ;***************************************************************
     4.6  
     4.7 -	ifdef	LARGE_IMAGES
     4.8  struc   data_himem			;struct data_himem {
     4.9 -first		dd	?		;   0  u32 first;
    4.10 -cacheidx	dw	?		;   4  int cacheidx;
    4.11 -pageidx		dw	?		;   6  int pageidx;
    4.12 +first		dd	?		;   0  u32 first;	*must* be the first one
    4.13 +cacheidx	dw	?		;   4  int cacheidx;	quad *
    4.14 +pageidx		dw	?		;   6  int pageidx;	byte *
    4.15  cache		dd	1024 dup(?)	;   8  int cache;
    4.16  page		dd	1024 dup(?)	;4104  int page;
    4.17 -ends	data_himem			;}; // size=8200
    4.18 -	endif
    4.19 +ends	data_himem			;};
    4.20  
    4.21  ;***************************************************************
    4.22  ;_fastcall u32* malloc_bufv_or_die(si:struct image_himem *m);
    4.23 @@ -623,48 +621,28 @@
    4.24  
    4.25                  p386
    4.26  		push	si
    4.27 -		mov	bx,si
    4.28 -	ifdef	LARGE_IMAGES
    4.29 -		movzx	eax,[word ((image_himem si).size) + 2]
    4.30 -		shr	ax,4			; pages index size = size >> 20
    4.31 -		add	ax,8+4096+8
    4.32 +		;mov	ecx,[(image_himem si).size]
    4.33 +		;shr	ecx,20			; pages index size = size >> 20
    4.34 +		;mov	ax,cx
    4.35 +		;add	ax,size data_himem-4096
    4.36 +		mov	ax,size data_himem
    4.37  		call	malloc_or_die
    4.38 -		mov	cx,4096+4095		; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE;
    4.39 +		;mov	cx,4096+4095		; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE;
    4.40 +		mov	ecx,4096+4095		; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE;
    4.41  		add	ecx,[(image_himem si).size]
    4.42  		shr	ecx,12
    4.43  		mov	[curdata],ax
    4.44 -	else
    4.45 -		mov	eax,[(image_himem si).size]
    4.46 -		dec	eax
    4.47 -		shr	eax,12
    4.48 -		inc	ax			; cnt = (m->size+PAGE_MASK)/PAGE_SIZE;
    4.49 -		push	ax
    4.50 -		inc	ax			; cnt+1
    4.51 -		shl	ax,2			; bufv => vcpi => vm86
    4.52 -; our malloc zeroes allocated mem: bufv[cnt]=0;
    4.53 -; Allocate pages, storing addrs in addrbuf
    4.54 -		call	malloc_or_die
    4.55 -		pop	cx
    4.56 -		push	ax
    4.57 -	endif
    4.58 -		mov	[(image_himem si).bufv],ax
    4.59 +		mov	[(image_himem si).bufv],ax	; update m->bufv
    4.60  		xchg	ax,si
    4.61  @@vcpi_alloc:
    4.62                  mov     ax,0DE04h		; allocate a 4K page => EDX
    4.63                  int     67h
    4.64  		or	ah,ah
    4.65 -		stc
    4.66  		mov	bx,offset vcpi_alloc_err
    4.67  		jnz	jmpdie
    4.68  ; for (i = cnt-1; i >= 0; i--)
    4.69 -	ifdef	LARGE_IMAGES
    4.70  		mov	eax,ecx
    4.71  		dec	eax
    4.72 -	else
    4.73 -		mov	ax,cx
    4.74 -		dec	ax
    4.75 -		cwde
    4.76 -	endif
    4.77  		shl	eax,12		; i*_4k
    4.78  ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again
    4.79  		mov	bx,offset _imgs.fallback
    4.80 @@ -677,16 +655,15 @@
    4.81  		jae	@@vcpi_alloc
    4.82  @@pmok:
    4.83  ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again
    4.84 -		add	eax,[bx-2+2+32]	; +initrd.fallback
    4.85 +		add	eax,[bx-2+2+size image_himem]	; +initrd.fallback
    4.86  		cmp	eax,edx		; initrd.fallback+i*_4k > edx ?
    4.87  		ja	@@initrdok
    4.88 -		mov	eax,[bx-2+6+32]	; initrd.size
    4.89 -		add	eax,[bx-2+2+32]	; +initrd.fallback
    4.90 +		mov	eax,[bx-2+6+size image_himem]	; initrd.size
    4.91 +		add	eax,[bx-2+2+size image_himem]	; +initrd.fallback
    4.92  		cmp	eax,edx		; initrd.fallback+initrd.size > edx ?
    4.93 -@@jnc_vcpi_alloc:
    4.94 +@@ja_vcpi_alloc:
    4.95  		ja	@@vcpi_alloc
    4.96  @@initrdok:
    4.97 -	ifdef	LARGE_IMAGES
    4.98  		cmp	[(data_himem si).first],0
    4.99  		jne	@@notfirst
   4.100  		mov	[(data_himem si).first],edx
   4.101 @@ -696,7 +673,7 @@
   4.102  		jae	@@nextpage
   4.103  		shl	bx,2
   4.104  		inc	[(data_himem si).cacheidx]
   4.105 -		mov	[(data_himem bx+si).cache],edx
   4.106 +		mov	[(data_himem bx+si).cache],edx	; cache[cacheidx++] = edx
   4.107  		loopd	@@vcpi_alloc
   4.108  		mov	[(data_himem bx+si).cache],ecx	; last is 0
   4.109  @@nextpage:
   4.110 @@ -714,15 +691,9 @@
   4.111  		call	storepage		; storepage(edx,cx)	
   4.112  		pop	cx
   4.113  		or	ecx,ecx			; clear C
   4.114 -		jnz	@@jnc_vcpi_alloc
   4.115 +		jnz	@@ja_vcpi_alloc
   4.116  		mov	[dword (data_himem si).cacheidx],ecx
   4.117  		xchg	ax,si
   4.118 -	else
   4.119 -		mov	[si],edx
   4.120 -		lodsd				; si=+4
   4.121 -		loop	@@vcpi_alloc
   4.122 -		pop	ax
   4.123 -	endif
   4.124  		pop	si
   4.125  		ret
   4.126  		ifdef	NO386
   4.127 @@ -733,14 +704,16 @@
   4.128  
   4.129  
   4.130  ;***************************************************************
   4.131 +;_fastcall void memcpy_image_initrd(si:struct image_himem *m);
   4.132 +;_fastcall void memcpy_image_kernel(si:struct image_himem *m);
   4.133  ;_fastcall void memcpy_image(bx:struct image_himem *m);
   4.134  ;***************************************************************
   4.135 -	global	memcpy_image_initrd:near
   4.136 -memcpy_image_initrd:
   4.137 -		lea	bx,[si+32]
   4.138 +	global	@memcpy_image_initrd$qv:near
   4.139 +@memcpy_image_initrd$qv:
   4.140 +		lea	bx,[si+size image_himem]
   4.141  		db	0A9h			; test	ax,imm
   4.142 -	global	memcpy_image_kernel:near
   4.143 -memcpy_image_kernel:
   4.144 +	global	@memcpy_image_kernel$qv:near
   4.145 +@memcpy_image_kernel$qv:
   4.146  		mov	bx,si
   4.147          proc    @memcpy_image$qp11image_himem near
   4.148  
   4.149 @@ -749,13 +722,9 @@
   4.150  		mov	eax,[(image_himem bx).buf]
   4.151  		cmp	eax,edx			; if (m->fallback != m->buf)
   4.152  		jz	@@skip			;   memcpy32(m->fallback,0,m->buf,m->size)
   4.153 -	ifdef	LARGE_IMAGES
   4.154  		mov	ecx,[(image_himem bx).size]
   4.155  memcpy_imagez:					; memcpy_imagez(edx,eax,ecx)
   4.156  		push	ecx
   4.157 -	else
   4.158 -		push	[(image_himem bx).size]
   4.159 -	endif
   4.160  		push	eax
   4.161  		push	0
   4.162  call_memcpy32:
   4.163 @@ -763,7 +732,7 @@
   4.164  		else
   4.165  		les	ax,[dword ((image_himem bx).fallback)]
   4.166  		mov	dx,es
   4.167 -		mov	cx,[word ((image_himem bx).buf)]
   4.168 +		les	cx,[dword ((image_himem bx).buf)]
   4.169  		cmp	ax,cx			; if (m->fallback != m->buf)
   4.170  		jnz	@@do
   4.171  		cmp	dx,[word ((image_himem bx).buf)+2]
   4.172 @@ -771,14 +740,13 @@
   4.173  @@do:
   4.174  		push	[word ((image_himem bx).size)+2]
   4.175  		push	[word ((image_himem bx).size)]
   4.176 -		push	[word ((image_himem bx).buf)+2]
   4.177 -		push	cx
   4.178 +		push	es			; [word ((image_himem bx).buf)+2]
   4.179 +		push	cx			; [word ((image_himem bx).buf)]
   4.180  		xor	cx,cx
   4.181  		push	cx
   4.182  call_memcpy32:
   4.183  		push	dx			; push dx:ax
   4.184  		push	ax
   4.185 -	ifdef	LARGE_IMAGES
   4.186  		jmp	@@memcpy
   4.187  memcpy_imagez:					; memcpy_imagez(edx,eax,ecx)
   4.188  		p386
   4.189 @@ -789,7 +757,6 @@
   4.190  		ifdef	NO386
   4.191                  p8086
   4.192  		endif
   4.193 -	endif
   4.194  		endif
   4.195  @@memcpy:
   4.196  		extrn	memcpy32:near
   4.197 @@ -832,7 +799,6 @@
   4.198          endp    @storepage$qpul
   4.199  
   4.200  
   4.201 -	ifdef	LARGE_IMAGES
   4.202                  p386
   4.203  ;***************************************************************
   4.204  ;_fastcall void reset_bufv(di:u32 *p);
   4.205 @@ -841,7 +807,7 @@
   4.206          proc    @reset_bufv$qpul near
   4.207  
   4.208  		mov	[curdata],di
   4.209 -		and	[dword (data_himem di).cacheidx],0
   4.210 +		and	[dword (data_himem di).cacheidx],0	; and pageidx=0
   4.211  		ret
   4.212  
   4.213          endp    @reset_bufv$qpul
   4.214 @@ -858,17 +824,21 @@
   4.215  		db	73h			; jnc
   4.216  _next_bufv:
   4.217  		clc
   4.218 +		push	si
   4.219  		mov	bx,0
   4.220  		org	$-2
   4.221  curdata		dw	?
   4.222  		sbb	ax,ax
   4.223  		cmc
   4.224  		adc	ax,[(data_himem bx).cacheidx]	; -1/+1
   4.225 +		mov	si,3ffh
   4.226 +		and	si,ax
   4.227 +		mov	[(data_himem bx).cacheidx],si
   4.228 +		shl	si,2
   4.229  		xor	ecx,ecx
   4.230  		test	ax,0fc00h
   4.231 -		jz	@@gotpage
   4.232 -		push	ax			; FFFF / 0400
   4.233 -		sar	ax,8			; FFFC / 0004
   4.234 +		jz	@@gotpage		; FFFF / 0400
   4.235 +		xchg	al,ah			; FFFC / 0004
   4.236  		and	al,0fch
   4.237  		add	[(data_himem bx).pageidx],ax
   4.238  		mov	di,[(data_himem bx).pageidx]
   4.239 @@ -879,29 +849,21 @@
   4.240  		add	edx,ecx
   4.241  		mov	eax,[di]
   4.242  		or	eax,eax
   4.243 -		jnz	@@pageok
   4.244 -		pop	ax
   4.245 -		ret
   4.246 -@@pageok:
   4.247 -		mov	cx,4096
   4.248 -		call	memcpy_imagez		; get page
   4.249 -		pop	ax			; FFFF / 0400
   4.250 -		cbw
   4.251 -		shr	ax,6			; 03FF / 0000
   4.252 +		jz	@@ret
   4.253 +		mov	cx,4096			; get page
   4.254 +		call	memcpy_imagez		; memcpy_imagez(edx,eax,ecx)
   4.255  @@gotpage:
   4.256 -		mov	[(data_himem bx).cacheidx],ax
   4.257 -		shl	ax,2
   4.258 -		xchg	ax,di
   4.259 -		lea	ax,[(data_himem bx+di).cache]		
   4.260 -		or	di,[(data_himem bx).pageidx]	; !pageidx && !cacheidx
   4.261 +		lea	ax,[(data_himem bx+si).cache]		
   4.262 +		or	si,[(data_himem bx).pageidx]	; !pageidx && !cacheidx
   4.263  		jnz	@@notfirst2
   4.264  		xchg	ax,bx				; &first
   4.265  @@notfirst2:
   4.266  		xchg	ax,di
   4.267 +@@ret:
   4.268 +		pop	si
   4.269  		ret
   4.270  
   4.271          endp    _prev_bufv
   4.272 -	endif
   4.273  
   4.274  		ifdef	NO386
   4.275                  p8086
     5.1 --- a/linld/stuff/src/HIMEM.CPP	Thu Feb 11 17:59:34 2021 +0000
     5.2 +++ b/linld/stuff/src/HIMEM.CPP	Thu Feb 18 08:56:43 2021 +0000
     5.3 @@ -10,19 +10,26 @@
     5.4  
     5.5  void load_image(struct image_himem *m) {
     5.6      m->remaining = m->size;
     5.7 +    u32* bufv= &himem_buf;
     5.8 +#ifdef WITH_XMM_ALLOC
     5.9      m->buf = m->fallback;	// set no_exit btw: die() won't return to DOS
    5.10 -    u32* bufv= &himem_buf;
    5.11      if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ?
    5.12  	if(vcpi) {
    5.13  	    bufv = (u32 *)malloc_bufv_or_die(m);	// update m->bufv
    5.14  	}
    5.15 -#ifdef WITH_XMM_ALLOC
    5.16  	else {
    5.17              xmm_alloc(m);			// update m->buf
    5.18  	}
    5.19 -#endif
    5.20      }
    5.21      himem_buf = m->buf;
    5.22 +#else
    5.23 +    *bufv = m->buf = m->fallback;	// set no_exit btw: die() won't return to DOS
    5.24 +    if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ?
    5.25 +	if(vcpi) {
    5.26 +	    bufv = (u32 *)malloc_bufv_or_die(m);	// update m->bufv
    5.27 +	}
    5.28 +    }
    5.29 +#endif
    5.30      do {
    5.31          u16 size;
    5.32  	if(s16(size = read_image(m)) -1 < 0) break;
    5.33 @@ -37,7 +44,8 @@
    5.34  // Called just before rm->pm
    5.35  void far last_ditch() {
    5.36      asm {
    5.37 -	cli
    5.38 +	pushf
    5.39 +	;cli
    5.40  	push	ds
    5.41  	push	cs
    5.42  	pop	ds
    5.43 @@ -52,15 +60,17 @@
    5.44      }
    5.45      vm2rm();
    5.46      struct image_himem *m = &pm;
    5.47 +#define KERNEL	0
    5.48 +#define INITRD	1
    5.49      u32 *q;
    5.50 -    if(((u16 *)&m->fallback)[1] >= 0x10) // >=	_1m ?
    5.51 -	((u16 *)&m->fallback)[1] = 0x10;
    5.52 -    q = m->bufv;
    5.53 +    if(((u16 *)&m[KERNEL].fallback)[1] >= 0x10) // >=	_1m ?
    5.54 +	((u16 *)&m[KERNEL].fallback)[1] = 0x10;
    5.55 +    q = m[KERNEL].bufv;
    5.56      if(q==0) {
    5.57          // Move kernel
    5.58 -        memcpy_image(m);
    5.59 +        memcpy_image_kernel();
    5.60          // Move initrd
    5.61 -        memcpy_image(pm2initrd(m));
    5.62 +        memcpy_image_initrd();
    5.63      } else { //vcpi
    5.64  #if defined(__BORLANDC__) && defined(NO386)
    5.65  #pragma option -3
    5.66 @@ -71,33 +81,32 @@
    5.67          // Move kernel
    5.68          // 'Gathering' copy in chunks of PAGE_SIZE
    5.69          // No risk of overlapping: kernel is copied from above to 1m mark
    5.70 -        m->size = pm2initrd(m)->size = PAGE_SIZE;
    5.71 +        m[KERNEL].size = m[INITRD].size = PAGE_SIZE;
    5.72  #define ADD_PAGE(x)	(*(unsigned long *)(((char *)&x)+1)+=PAGE_SIZE/256)
    5.73  #define SUB_PAGE(x)	(*(unsigned long *)(((char *)&x)+1)-=PAGE_SIZE/256)
    5.74  	reset_bufv(q);
    5.75  	do {
    5.76 -            m->buf = *q;
    5.77 -            memcpy_image(m);
    5.78 -            next(q); ADD_PAGE(m->fallback);
    5.79 +            m[KERNEL].buf = *q;
    5.80 +            memcpy_image_kernel();
    5.81 +            next(q); ADD_PAGE(m[KERNEL].fallback);
    5.82          } while(*q);
    5.83          // Move initrd
    5.84 -	m = pm2initrd(m);
    5.85 -        if(((u16 *)&m->fallback)[1]) {
    5.86 +        if(((u16 *)&m[INITRD].fallback)[1]) {
    5.87              // This is tricky: copy initrd backwards to reduce
    5.88              // risk of overlapping: use the fact that initrd is copied
    5.89              // to the very top of ram
    5.90              // (overlapping still can happen with more than 256mb ram)
    5.91              // (generic solution for this overwrite problem, anyone?)
    5.92 -            q=m->bufv;
    5.93 +            q=m[INITRD].bufv;
    5.94  	    reset_bufv(q);
    5.95              do {
    5.96 -                next(q); ADD_PAGE(m->fallback);
    5.97 +                next(q); ADD_PAGE(m[INITRD].fallback);
    5.98              } while(*q);
    5.99              do {
   5.100 -                prev(q); SUB_PAGE(m->fallback);
   5.101 -                m->buf = *q;
   5.102 -                memcpy_image(m);
   5.103 -            } while(q != m->bufv);
   5.104 +                prev(q); SUB_PAGE(m[INITRD].fallback);
   5.105 +                m[INITRD].buf = *q;
   5.106 +                memcpy_image_initrd();
   5.107 +            } while(q != m[INITRD].bufv);
   5.108          }
   5.109      }
   5.110      asm {
   5.111 @@ -110,5 +119,6 @@
   5.112  	popa
   5.113  # endif
   5.114  	pop	ds
   5.115 +	popf
   5.116      }
   5.117  }
     6.1 --- a/linld/stuff/src/JUMP.ASM	Thu Feb 11 17:59:34 2021 +0000
     6.2 +++ b/linld/stuff/src/JUMP.ASM	Thu Feb 18 08:56:43 2021 +0000
     6.3 @@ -23,7 +23,15 @@
     6.4  
     6.5  	macro	dos_shutdown
     6.6  		xor	si,si
     6.7 +                ifdef   QUICK_BOOT
     6.8 +		extrn	_cmdnum:dword
     6.9 +quickboot	=	(word _cmdnum+20)
    6.10 +		cmp	si,[quickboot]
    6.11  		mov	ds,si
    6.12 +		jne	skip_shutdown
    6.13 +		else
    6.14 +		mov	ds,si
    6.15 +		endif
    6.16  		ifndef	NO386
    6.17  		push	[dword si+4]		; save step
    6.18  		mov	[word si+4],offset step19
    6.19 @@ -56,6 +64,7 @@
    6.20  		xor	si,si
    6.21  		mov	ds,si
    6.22  		pop	[dword si+4]		; restore step
    6.23 +skip_shutdown:
    6.24  	endm
    6.25  	macro	step19code
    6.26  step19:
    6.27 @@ -148,7 +157,7 @@
    6.28  		push	si			; src seg=0
    6.29  		inc	cx
    6.30  		push	cx			; dst ofs hi
    6.31 -		push	si			; dst ofs lo : 64k
    6.32 +		push	si			; dst ofs lo : 64k = 0x10000
    6.33  
    6.34  		; self move
    6.35  		extrn	gdt_data
     7.1 --- a/linld/stuff/src/LINK.CMD	Thu Feb 11 17:59:34 2021 +0000
     7.2 +++ b/linld/stuff/src/LINK.CMD	Thu Feb 18 08:56:43 2021 +0000
     7.3 @@ -1,1 +1,1 @@
     7.4 -_beg.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj linld.obj _end.obj, linld
     7.5 +_beg.obj linld.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld
     8.1 --- a/linld/stuff/src/LINLD.CPP	Thu Feb 11 17:59:34 2021 +0000
     8.2 +++ b/linld/stuff/src/LINLD.CPP	Thu Feb 18 08:56:43 2021 +0000
     8.3 @@ -8,7 +8,11 @@
     8.4  
     8.5  extern char bzimagestr[];
     8.6  const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL};
     8.7 +#ifdef QUICK_BOOT
     8.8 +u32 cmdnum[7];
     8.9 +#else
    8.10  u32 cmdnum[5];
    8.11 +#endif
    8.12  
    8.13  inline void syntax() {
    8.14      die("Syntax:" NL
    8.15 @@ -51,7 +55,11 @@
    8.16  	    exit();
    8.17  	}
    8.18  	if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
    8.19 +#ifdef QUICK_BOOT
    8.20 +	if (argnum(*argv,"root|vga|mem|-b|-f*|-q*|-v*",&root_dev) >= (int) &base_himem) continue;
    8.21 +#else
    8.22  	if (argnum(*argv,"root|vga|mem|-b|-f*",&root_dev) >= (int) &base_himem) continue;
    8.23 +#endif
    8.24  	if (fileexist(*argv) != -1) {
    8.25              kernel_name=*argv;
    8.26  	    continue;
     9.1 --- a/linld/stuff/src/MEMCPY32.ASM	Thu Feb 11 17:59:34 2021 +0000
     9.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Thu Feb 18 08:56:43 2021 +0000
     9.3 @@ -156,10 +156,10 @@
     9.4                  cmp     esi,edi
     9.5                  jae     @@do_copy
     9.6                  add     esi,ecx         ;src<dst: we must do
     9.7 -                dec     esi             ;  copy backwards to avoid
     9.8 -                add     edi,ecx         ;  overwrite bug
     9.9 -                dec     edi             ;
    9.10 -                std                     ;
    9.11 +                add     edi,ecx         ;  copy backwards to avoid
    9.12 +                std                     ;  overwrite bug
    9.13 +                db      67h     	;address width override for esi/edi
    9.14 +		cmpsb			;  dec esi/edi
    9.15  @@do_copy:
    9.16                  cli
    9.17  oldGDTR		=	(pword srcseg)	; don't need src seg/ofs anymore
    10.1 --- a/linld/stuff/src/MEMTOP.ASM	Thu Feb 11 17:59:34 2021 +0000
    10.2 +++ b/linld/stuff/src/MEMTOP.ASM	Thu Feb 18 08:56:43 2021 +0000
    10.3 @@ -171,10 +171,10 @@
    10.4          proc    _hook_int15_88 near
    10.5  
    10.6  		ifndef  xmm_hook
    10.7 -                mov     ax,4300h
    10.8 -                int     2fh
    10.9 -                cmp     al,80h			; 80h = XMS driver installed
   10.10 -                je      @@skip
   10.11 +                ;mov     ax,4300h
   10.12 +                ;int     2fh
   10.13 +                ;cmp     al,80h			; 80h = XMS driver installed
   10.14 +                ;je      @@skip
   10.15  		endif
   10.16  saved15:
   10.17  		xor	bx,bx
    11.1 --- a/linld/stuff/src/VCPI.ASM	Thu Feb 11 17:59:34 2021 +0000
    11.2 +++ b/linld/stuff/src/VCPI.ASM	Thu Feb 18 08:56:43 2021 +0000
    11.3 @@ -102,21 +102,21 @@
    11.4                  ;mov     ax,0DE01h               ;get vcpi pm interface
    11.5                  int     67h
    11.6                  xchg    [si+vcpi_pm_entry-gdt_vcpi],ebx	; bx=((640*1024) shr 12)
    11.7 -                ;xor     bx,bx
    11.8  
    11.9  ; Check that mapping for low 640k is 1:1
   11.10                  pop     si			; [page0_ofs]
   11.11                  ;cld
   11.12 -                mov     cx,bx
   11.13 +		mov	cx,bx
   11.14  @@map_chk:
   11.15 -                lodsd
   11.16 -                shr     eax,12
   11.17 -		add	al,cl
   11.18 -                cmp     al,((640*1024) shr 12)
   11.19 -                loope     @@map_chk
   11.20 -; Return
   11.21 -@@bad:
   11.22 +		lodsd
   11.23 +		shr	eax,12
   11.24 +		add	ax,cx
   11.25 +		;cmp	eax,ebx			; ((640*1024) shr 12)
   11.26 +		cmp	ax,bx			; ((640*1024) shr 12)
   11.27 +		loope	@@map_chk
   11.28 +		;pop	di si
   11.29                  ret
   11.30 +
   11.31          endp    _get_vcpi_interface
   11.32  
   11.33  
   11.34 @@ -137,7 +137,7 @@
   11.35  ; Fix up base of some gdt descriptors
   11.36  ; Note: 'add [dword xx.base0],edx' actually updates 24 bit quantity!
   11.37  ; Do NOT replace with mov!
   11.38 -		mov	ebx,10000h-28h
   11.39 +		mov	bx,10000h-28h
   11.40                  add     [dword si+sw2pm_addr-gdt_vcpi],edx
   11.41                  add     [dword si+sw2pm_idtr_ptr-gdt_vcpi],edx
   11.42  @@fixup:
   11.43 @@ -146,11 +146,12 @@
   11.44  		js	@@fixup
   11.45  		mov	bh,10h
   11.46  		extrn	_heap_top:word
   11.47 -		movzx	eax,[_heap_top]
   11.48 +		;movzx	eax,[_heap_top]
   11.49 +		mov	ax,[_heap_top]
   11.50 +		add	ax,bx		; assume _heap_top < 0f000h
   11.51                  add     eax,edx
   11.52  		and	ax,0f000h       ;eax = 4k aligned linear addr of pagebuf
   11.53 -                add     eax,ebx         ;eax=page0 linear addr
   11.54 -                add     [si+sw2pm_cr3-gdt_vcpi],eax
   11.55 +                add     [si+sw2pm_cr3-gdt_vcpi],eax	;eax=page0 linear addr
   11.56                  mov     edi,eax
   11.57                  sub     edi,edx
   11.58                  mov     al,3            ;add present+writable bits
   11.59 @@ -181,7 +182,7 @@
   11.60  gdt_vcpi3       descr   <?>     ;0018
   11.61  		org	$-8
   11.62  	global	gdt_memcpy:descr
   11.63 -gdt_memcpy      descr   <?>
   11.64 +gdt_memcpy      descr   <?>	;null + gdt_abs
   11.65  descriptor      gdt_abs ,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_32),0
   11.66  ;Note: code/data segs must be flagged use16 (i.e. use ip/sp, not eip/esp)
   11.67  ;Note: base addrs will be fixed up in prepare_vcpi()
   11.68 @@ -208,7 +209,7 @@
   11.69  sw2pm_idtr_ptr  dw      offset idtr,0
   11.70  sw2pm_ldtr      dw      0       ;we don't need it
   11.71  sw2pm_tr        dw      SEL_TSS ;vcpi thinks we need it... can't set to 0
   11.72 -sw2pm_jumpaddr  dd      0
   11.73 +sw2pm_jumpaddr  dw      offset pmode,0
   11.74                  dw      SEL_CODE
   11.75  
   11.76  vcpi_pm_entry   dd      ((640*1024) shr 12)
   11.77 @@ -218,20 +219,6 @@
   11.78  idt_lim         dw      03ffh   ;we won't enable ints,
   11.79  idt_base        dd      0       ;  so let's leave it the same as for rm
   11.80  
   11.81 -;***************************************************************
   11.82 -switch_to_pm:
   11.83 -                assume  cs:DGROUP,ds:DGROUP
   11.84 -		mov	edx,esi
   11.85 -		movzx_e	si,<offset sw2pm_params>
   11.86 -		org	$-4
   11.87 -sw2pm_addr	dd	?
   11.88 -                pop	[word sw2pm_jumpaddr]	; CS:EIP of protected mode entry-point
   11.89 -               ;mov     [word sw2pm_jumpaddr+2],0
   11.90 -               ;mov     [word sw2pm_jumpaddr+4],SEL_CODE
   11.91 -                mov     ax,0DE0Ch       ; vcpi: switch to pm
   11.92 -                cli			; load GDTR LDTR TR need 16 bytes in SS:ESP
   11.93 -                int     67h		; EAX, ESI, DS, ES, FS, GS destroyed
   11.94 -
   11.95  
   11.96  ;***************************************************************
   11.97  ;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs);
   11.98 @@ -270,14 +257,26 @@
   11.99                  push    bx              ;\eip
  11.100                  push    offset vcpi_ret ;/
  11.101  
  11.102 -		call	switch_to_pm	; EAX, EDX/ESI, DS, ES, FS, GS destroyed
  11.103 +		mov	edx,esi
  11.104 +switch_to_pm:
  11.105 +		movzx_e	si,<offset sw2pm_params>
  11.106 +		org	$-4
  11.107 +sw2pm_addr	dd	?
  11.108 +                mov     ax,0DE0Ch       ; vcpi: switch to pm
  11.109 +                cli			; load GDTR LDTR TR need 16 bytes in SS:ESP
  11.110 +                int     67h		; EAX, ESI, DS, ES, FS, GS destroyed
  11.111 +pmode:
  11.112                  assume  nothing
  11.113                  assume  cs:DGROUP
  11.114  
  11.115  ; Now we are in 16-bit protected mode
  11.116 -		mov	bl,SEL_DATA
  11.117 -                mov     ss,bx
  11.118 -                lea     sp,[bp-8-9*4]
  11.119 +		push	SEL_DATA
  11.120 +		pop	ss
  11.121 +		test	bx,bx
  11.122 +		jnz	vm2rm_end
  11.123 +
  11.124 +                ;lea     sp,[bp-8-9*4]
  11.125 +                lea     sp,[bp-9*4]
  11.126  
  11.127  ; Call the routine (bp points to params on stack if any)
  11.128                  call    do_memcpy_vcpi	; set ds=all_addrspace
  11.129 @@ -287,7 +286,9 @@
  11.130                  cli     ; to be safe
  11.131                  clts    ;
  11.132  ; Go to vm86 mode. Sregs, esp, eflags (IF) restored from IRET stack
  11.133 -                jmp	[pword cs:vcpi_pm_entry]
  11.134 +                call	[pword cs:vcpi_pm_entry]
  11.135 +		ret
  11.136 +                ;jmp	[pword cs:vcpi_pm_entry]
  11.137  
  11.138  ;***************************************************************
  11.139  
  11.140 @@ -335,36 +336,37 @@
  11.141  ;***************************************************************
  11.142  ;****** Uses:   Flags
  11.143  ;***************************************************************
  11.144 -        global  _vm2rm:near
  11.145 -        proc    _vm2rm near
  11.146 +        global  _vm2rm:far
  11.147 +        proc    _vm2rm far
  11.148  
  11.149                  assume  cs:DGROUP,ds:DGROUP
  11.150 +                push	ds
  11.151 +                ifdef   QUICK_BOOT
  11.152 +		extrn	_cmdnum:dword
  11.153 +v86boot	=	(byte _cmdnum+24)
  11.154 +		cmp	[v86boot],0
  11.155 +		jnz	@vm2rm_ret
  11.156 +		endif
  11.157 +		mov	bx,offset sssp
  11.158 +                mov     [bx],sp
  11.159 +                ;mov     [bx+2],ss
  11.160  		extrn	sssp:dword
  11.161                  ifdef NO386
  11.162 -                p8086
  11.163  		extrn	_vcpi:byte
  11.164 -		mov	bx,offset sssp
  11.165  		test	[_vcpi],bh
  11.166 -		jz	vcpi_ret
  11.167                  else
  11.168 -                p386
  11.169                  smsw    ax      ;SMSW cannot be trapped! :-)
  11.170                  and     al,1	;MSW_PE
  11.171 -		jz	vcpi_ret
  11.172 -		mov	bx,offset sssp
  11.173                  endif
  11.174 -                p386
  11.175 -                pop	ax		; convert
  11.176 -                push    cs      	; near call
  11.177 -                push	ax		; to far call
  11.178 -                push	ds
  11.179 -                mov     [bx],sp
  11.180 -                ;mov     [bx+2],ss
  11.181 -
  11.182 -		call	switch_to_pm	; EAX, EDX/ESI, DS, ES, FS, GS destroyed
  11.183 +		jz	@vm2rm_ret
  11.184 +		jmp	switch_to_pm	; EAX, ESI, DS, ES, FS, GS destroyed
  11.185 +vm2rm_end:
  11.186                  assume  nothing
  11.187                  assume  cs:DGROUP
  11.188  
  11.189 +		;push	ss
  11.190 +		;pop	ds
  11.191 +
  11.192  ; Now we are in 16-bit protected mode
  11.193  ; Black magic here
  11.194                  mov     eax,cr0
  11.195 @@ -374,6 +376,7 @@
  11.196  
  11.197  ; Now we are in rm, but not yet: have to restore sregs:
  11.198                  lss     sp,[cs:bx]	; SS
  11.199 +@vm2rm_ret:
  11.200  		pop	ds		; DS
  11.201                  retf                   	; CS
  11.202  
    12.1 --- a/linld/stuff/src/XMM.ASM	Thu Feb 11 17:59:34 2021 +0000
    12.2 +++ b/linld/stuff/src/XMM.ASM	Thu Feb 18 08:56:43 2021 +0000
    12.3 @@ -6,11 +6,7 @@
    12.4                  %crefref
    12.5                  %noincl
    12.6                  %nomacs
    12.7 -		ifdef	NO386
    12.8                  p8086
    12.9 -		else
   12.10 -                p386
   12.11 -		endif
   12.12  
   12.13          group   DGROUP  _TEXT
   12.14          assume  cs:DGROUP,ds:DGROUP
   12.15 @@ -23,45 +19,33 @@
   12.16          global  _enable_a20_xmm:near
   12.17          proc    _enable_a20_xmm near
   12.18  
   12.19 -                mov     ah,03h          ;global enable a20
   12.20 +                mov     ch,03h          ;global enable a20
   12.21                  call    xmm_driver      ;
   12.22 -                mov     ah,05h          ;local enable a20
   12.23 +                mov     ch,05h          ;local enable a20
   12.24                  ;jmp     xmm_driver      ;
   12.25  
   12.26          endp    _enable_a20_xmm
   12.27  
   12.28  ;***************************************************************
   12.29 -;Call xmm driver addr or 0 if no xmm
   12.30 +;Call xmm driver addr (success: ax=1)
   12.31  ;void xmm_driver(ah)
   12.32  ;***************************************************************
   12.33          proc    xmm_driver near
   12.34  
   12.35 -		push	ax			; save cmd
   12.36 +		pop	bx			; \
   12.37 +		push	cs			; fake far call
   12.38 +		push	bx			; /
   12.39                  mov     ax,4300h		; installation check in al
   12.40                  int     2fh
   12.41 -                mov     bx,offset @@xmm_fail
   12.42 -                push    cs
   12.43 -                pop     es
   12.44                  cmp     al,80h
   12.45 -                jne     @@err
   12.46 +                jne     @@xmm_fail	
   12.47                  mov     ax,4310h		; get driver address in es:bx
   12.48                  int     2fh
   12.49 -@@err:
   12.50 -		pop	ax			; restore cmd
   12.51 +		xchg	ax,cx			; restore cmd
   12.52  
   12.53 -		push	cs			; call far
   12.54 -		call	@@jmp_esbx
   12.55 -                dec     ax			; Z=1=OK
   12.56 -                ret
   12.57 -
   12.58 -@@jmp_esbx:
   12.59 -		push	es			; \
   12.60 -		push	bx			;  > jmp far es:bx
   12.61 -		retf				; /
   12.62 -
   12.63 +		push	es			; jmp far es:bx
   12.64 +		push	bx			; avoid 08h 0Fh 12h and 8Fh functions using bx
   12.65  @@xmm_fail:
   12.66 -                xor     ax,ax
   12.67 -                cwd
   12.68                  retf
   12.69  
   12.70          endp    xmm_driver
   12.71 @@ -77,33 +61,49 @@
   12.72  
   12.73  		extrn	_cmdnum:dword
   12.74  skip_alloc	=	(byte _cmdnum+16)
   12.75 -		cmp	[skip_alloc],0
   12.76 +LARGE_XMM_ALLOC	=	1
   12.77 +		ifdef	LARGE_XMM_ALLOC
   12.78 +                mov     ch,89h          ;allocate blk of EDX kilobytes
   12.79 +		test	[skip_alloc],ch	; 89h & ('*'=2Ah) = 08h
   12.80  		jne	@@err
   12.81 -		ifndef	NO386
   12.82 +		extrn	_cpu386:byte
   12.83 +		test	[_cpu386],ch
   12.84 +		je	@@not386
   12.85 +                p386
   12.86  		mov	edx,[(image_himem si).size]		; m->size
   12.87                  ;dec     edx
   12.88                  shr     edx,10          ; to Kb
   12.89                  inc     edx
   12.90 -                mov     ah,89h          ;allocate blk of EDX kilobytes
   12.91 +                call    xmm_driver      ;
   12.92 +                dec     ax			; Z=OK
   12.93 +                jz     @@gotit
   12.94 +@@not386:
   12.95 +		mov	cl,16-10
   12.96  		else
   12.97 +		mov	cl,16-10
   12.98 +		test	[skip_alloc],cl	; 06h & ('*'=2Ah) = 02h
   12.99 +		jne	@@err
  12.100 +		endif
  12.101 +                p8086
  12.102  		;mov	ax,-1
  12.103  		;cwd
  12.104  		;add	ax,[word (image_himem si).size]		; lo m->size
  12.105  		;adc	dx,[word (image_himem si+2).size]	; hi m->size
  12.106  		les	ax,[dword (image_himem si).size]	; m->size
  12.107 -		mov	cl,16-10
  12.108  		extrn	N_LXLSH@ES:near
  12.109  		call	N_LXLSH@ES
  12.110                  inc     dx
  12.111 -                mov     ah,9h          ;allocate blk of DX kilobytes (<64Mb)
  12.112 -		endif
  12.113 +                mov     ch,9h          ;allocate blk of DX kilobytes (<64Mb)
  12.114                  call    xmm_driver      ;
  12.115 +                dec     ax			; Z=OK
  12.116                  jnz     @@err
  12.117 +@@gotit:
  12.118                                          ;now: dx=handle of the blk
  12.119 -                mov     ah,0Ch          ;lock blk
  12.120 +                mov     ch,0Ch          ;lock blk
  12.121                  call    xmm_driver      ;
  12.122                                          ;now: dx:bx=addr of blk
  12.123 -                jnz     @@err
  12.124 +                ;dec     ax			; Z=OK
  12.125 +                ;jnz     @@err
  12.126  		mov	[word (image_himem si).buf],bx		; lo m->buf
  12.127  		mov	[word (image_himem si+2).buf],dx	; hi m->buf
  12.128  @@err:
    13.1 --- a/linld/stuff/src/_BEG.ASM	Thu Feb 11 17:59:34 2021 +0000
    13.2 +++ b/linld/stuff/src/_BEG.ASM	Thu Feb 18 08:56:43 2021 +0000
    13.3 @@ -29,7 +29,7 @@
    13.4  
    13.5          segment _BSS byte public use16 'BSS'
    13.6  
    13.7 -		ifdef	BIG_CMDLINE
    13.8 +		ifdef	ISOHOOK
    13.9  	extrn	_big_cmdline:byte
   13.10  		db	254 dup(?)
   13.11  		endif
   13.12 @@ -77,7 +77,7 @@
   13.13  
   13.14  ; Check for oldies
   13.15  		push	bx		; < 286 : flags[12..15] are forced 1
   13.16 -		popf			; = 286 : flags[12..15] are forced 0
   13.17 +		popf			; = 286 : flags[12..15] are forced 0, cld
   13.18  		pushf			; > 286 : only flags[15] is forced 0
   13.19  		pop	dx
   13.20  		add	dh,bh		; NS=386+, S+NC=286, S+C=86/186
   13.21 @@ -118,15 +118,12 @@
   13.22  ;***************************************************************
   13.23  label   check_vcpi near
   13.24                  p386
   13.25 -                push    ds
   13.26 -; Check whether it is safe to call 67h (we trust only known EMM managers)
   13.27 -                push    si
   13.28 -                pop     ds
   13.29 -                mov     ax,[word 67h*4]
   13.30 -                or      ax,[word 67h*4+2]
   13.31 -                pop     ds
   13.32 +; Check whether it is safe to call 67h
   13.33 +		xor	eax,eax
   13.34 +                mov     es,ax
   13.35 +                cmp     [dword es:67h*4],eax
   13.36                  je      no_vcpi
   13.37 -                mov     ax,0DE00h       ; check for vcpi present
   13.38 +                mov     ah,0DEh		; check for vcpi present
   13.39                  int     67h
   13.40                  or	ah,ah
   13.41  		jnz	no_vcpi
   13.42 @@ -183,7 +180,7 @@
   13.43  		org	$-2
   13.44  _heap_top	dw	?
   13.45                  mov	si,80h
   13.46 -		ifdef	BIG_CMDLINE
   13.47 +		ifdef	ISOHOOK
   13.48                  mov	bx,offset _big_cmdline
   13.49  		cmp	[byte si],2
   13.50  		jnb	@@user_args
   13.51 @@ -192,7 +189,7 @@
   13.52  		endif
   13.53                  lodsb				; size 0..127
   13.54  		cbw
   13.55 -		ifdef	BIG_CMDLINE
   13.56 +		ifdef	ISOHOOK
   13.57  		inc	ax
   13.58  		jnz	short_cmdline
   13.59  		mov	si,bx
   13.60 @@ -235,43 +232,6 @@
   13.61                  inc	bx
   13.62                  dec	cx
   13.63                  jmp	arglp
   13.64 -argdone:
   13.65 -                ;mov	[word bx+di],0		; argv[argc] = 0
   13.66 -		lea	ax,[bx+di+2]
   13.67 -		mov	[_heap_top],ax
   13.68 -                push	di			; argv
   13.69 -                shr	bx,1
   13.70 -                push	bx			; argc
   13.71 -	ifndef	filearg
   13.72 -                mov	bx,[di+2]		; argv[1]
   13.73 -		extrn	openargs:near
   13.74 -		call	near openargs
   13.75 -		jc	argend
   13.76 -		pop	bx			; trash argc,  argv >> 1Kb !
   13.77 -                pop	cx			; sizemax=argv
   13.78 -read_cmdline:
   13.79 -		mov	dx,di
   13.80 -		push	dx
   13.81 -		xchg	ax,bx
   13.82 -		extrn	@read$cxdxbx:near	; read(fd=bx,buffer=dx,size=cx)
   13.83 -		call	near @read$cxdxbx
   13.84 -                pop	si			; si=buffer=argv
   13.85 -                add	di,ax
   13.86 -		ifndef	NO_CLOSE
   13.87 -		extrn	close:near
   13.88 -		call	near close
   13.89 -		endif
   13.90 -                jmp	argbuild
   13.91 -argend:
   13.92 -	endif
   13.93 -
   13.94 -;***************************************************************
   13.95 -                extrn	_main:near
   13.96 -                call	_main
   13.97 -		;never return
   13.98 -
   13.99 -;***************************************************************
  13.100 -
  13.101  
  13.102  ;***************************************************************
  13.103  ;_fastcall void set_cmdline(bx:const char *filename);
  13.104 @@ -308,6 +268,46 @@
  13.105          endp    _topseg
  13.106  		endif
  13.107  
  13.108 +;***************************************************************
  13.109 +argdone:
  13.110 +                ;mov	[word bx+di],0		; argv[argc] = 0
  13.111 +		lea	ax,[bx+di+2]
  13.112 +		mov	[_heap_top],ax
  13.113 +                ;push	di			; argv
  13.114 +                ;shr	bx,1
  13.115 +                ;push	bx			; argc
  13.116 +	ifndef	filearg
  13.117 +                mov	bx,[di+2]		; argv[1]
  13.118 +		extrn	openargs:near
  13.119 +		call	near openargs
  13.120 +		jc	argend
  13.121 +		;pop	bx			; trash argc,  argv >> 1Kb !
  13.122 +                ;pop	cx			; sizemax=argv
  13.123 +		dec	cx			; sizemax=0ffffh
  13.124 +read_cmdline:
  13.125 +		mov	dx,di
  13.126 +		push	dx
  13.127 +		xchg	ax,bx
  13.128 +		extrn	@read$cxdxbx:near	; read(fd=bx,buffer=dx,size=cx)
  13.129 +		call	near @read$cxdxbx
  13.130 +                pop	si			; si=buffer=argv
  13.131 +                add	di,ax
  13.132 +		ifndef	NO_CLOSE
  13.133 +		extrn	close:near
  13.134 +		call	near close
  13.135 +		endif
  13.136 +                jmp	argbuild
  13.137 +argend:
  13.138 +	endif
  13.139 +
  13.140 +;***************************************************************
  13.141 +;                extrn	_main:near
  13.142 +;                call	_main
  13.143 +		;never return
  13.144 +
  13.145 +;***************************************************************
  13.146 +
  13.147 +
  13.148          ends    _TEXT
  13.149  
  13.150  
    14.1 --- a/linld/stuff/src/_END.ASM	Thu Feb 11 17:59:34 2021 +0000
    14.2 +++ b/linld/stuff/src/_END.ASM	Thu Feb 18 08:56:43 2021 +0000
    14.3 @@ -15,14 +15,15 @@
    14.4          segment _DATA byte public use16 'DATA'
    14.5          ;global  _data_end:byte
    14.6          label   _data_end byte
    14.7 -		ifdef	BIG_CMDLINE
    14.8 +		ifdef	ISOHOOK
    14.9  	global	_big_cmdline:byte
   14.10  _big_cmdline	db	0
   14.11  		endif
   14.12          ends    _DATA
   14.13  
   14.14          segment _BSS word public use16 'BSS'
   14.15 -STACK_SIZE = 256
   14.16 +;STACK_SIZE = 128
   14.17 +STACK_SIZE = 512
   14.18  		db	STACK_SIZE dup(?)
   14.19          global  stktop:byte
   14.20          label   stktop byte
    15.1 --- a/linld/stuff/src/pipehole.awk	Thu Feb 11 17:59:34 2021 +0000
    15.2 +++ b/linld/stuff/src/pipehole.awk	Thu Feb 18 08:56:43 2021 +0000
    15.3 @@ -9,37 +9,27 @@
    15.4  	if (file == "" && /debug	S/) { file=$3; gsub(/\"/,"",file) }
    15.5  	if (/debug	S/) print "	%PAGESIZE 1000"
    15.6  	 if (file == "linld.cpp") {
    15.7 -	if (/add	si,2/) $0="	lodsw	; " $0
    15.8 +	if (/\[si/ || /si,/ || /,si/) sub(/si/,"di")
    15.9 +	else if (/\[di/ || /di,/ || /,di/) sub(/di/,"si")
   15.10  	if (/add	di,2/) $0="	scasw	; " $0
   15.11 -	if (/bx,offset DGROUP:s@\+26/) sub(/mov/,";mov")
   15.12 -	if (/bx,si/ || /\[bp-2\]/) next
   15.13 -	sub(/\[bx\],0/,"[si],0")
   15.14 +	if (/bx,di/ || /\[bp-2\]/) next
   15.15 +	sub(/\[bx\],0/,"[di],0")
   15.16  	if (islinld==1) {
   15.17 +		if (/,word.*/) islinld=0
   15.18  		print "; " $0
   15.19 -		if (!/word ptr/) next
   15.20 -		islinld=0
   15.21 -		sub(/,word.*/,",di	; argv")
   15.22 -		if (/di,di/) { print "; " $0; next }
   15.23 +		next
   15.24  	}
   15.25  	if (/^_main	proc/) islinld=1
   15.26 -	if (/== 0x662F/) islinld=2
   15.27 -	if (islinld==2) {
   15.28 -		if (/cpuhaslm/) islinld=0
   15.29 -		if (/bx,word/) { print "; " $0; next }
   15.30 -	}
   15.31  	if (/image\|initrd/) islinld=3
   15.32 -	if (islinld==3) {
   15.33 -		if (/bx,word ptr/) { print "; " $0; next }
   15.34 -	}
   15.35 +	if (islinld==3 && /bx,word ptr/) { print "; " $0; next }
   15.36  	if (/fileexist\$qpxzc/) islinld=4
   15.37  	if (islinld==4) {
   15.38  		if (/ax,-1/) {
   15.39  			print "	inc	ax"
   15.40 -			print "	mov	ax,word ptr [si]"
   15.41 +			print "	mov	ax,word ptr [di]"
   15.42  			next
   15.43  		}
   15.44  		if (/ax,word ptr/) next
   15.45 -		if (/\[si\]$/) { islinld=0; print "; " $0; next }
   15.46  	}
   15.47  	if (/buf_cmdline\+1/) {
   15.48  		islinld=5
   15.49 @@ -53,7 +43,7 @@
   15.50  	}
   15.51  	if (/bx,word ptr DGROUP:_cmdstr\+6/) next
   15.52  	if (/_cmdstr\+6,0/) {
   15.53 -		print "	mov	bx,word ptr [di+6]"
   15.54 +		print "	mov	bx,word ptr [si+6]"
   15.55  		$0="	or	bx,bx"
   15.56  	}
   15.57  	 } # file == "linld.cpp"
   15.58 @@ -63,7 +53,7 @@
   15.59  	if (ishimem == 1 && is386 == 0) {
   15.60  		if (/si\+8\]$/ || /si\+4\]$/ || /si\+16\]$/) next
   15.61  		if (/si\+6\]$/ || /si\+2\]$/ || /si\+14\]$/) sub(/mov	dx,/,"les	dx,d")
   15.62 -		if (/si\+12\],ax/ || /si\+16\],ax/ || /DGROUP:_himem_buf\+2,ax/) sub(/,ax/,",es")
   15.63 +		if (/si\+12\],ax/ || /si\+16\],ax/ || /di\+2\],ax/ || /DGROUP:_himem_buf\+2,ax/) sub(/,ax/,",es")
   15.64  		if (/dx,dword ptr \[si\+14\]/ || /DGROUP:_himem_buf,dx/) sub(/dx/,"ax")
   15.65  	}
   15.66  	if (ishimem == 1) {
   15.67 @@ -84,7 +74,7 @@
   15.68  		if (/i\+12/) ishimem=20
   15.69  	}
   15.70  	if (ishimem == 20) {
   15.71 -		if (/stc/ || /loadfail/) next
   15.72 +		if (/loadfail/) next
   15.73  		if (/je/) {
   15.74  			print "	extrn	jmploadfailure"
   15.75  			$0="	jne	short jmploadfailure"
   15.76 @@ -92,27 +82,10 @@
   15.77  		if (/endp/) ishimem=0
   15.78  	}
   15.79  	if (/@memcpy_image\$qp11image_himem/) next
   15.80 -	if (/far last_ditch/) {
   15.81 -		print "	extrn	memcpy_image_kernel:near"
   15.82 -		print "	extrn	memcpy_image_initrd:near"
   15.83 -		ishimem=3
   15.84 -		cpy_initrd=0
   15.85 -	}
   15.86 +	if (/far last_ditch/) ishimem=3
   15.87  	if (ishimem == 3) {
   15.88  		sub(/DGROUP:_imgs\+4,/,"[si+4],")
   15.89 -		if (/bx,di/ || /di,ax/ || /bx,30/) next
   15.90 -		if (/mov	bx,si/) {
   15.91 -			if (cpy_initrd==0) sub(/mov	bx,si/, "call	memcpy_image_kernel")
   15.92 -			else sub(/mov	bx,si/, "call	memcpy_image_initrd")
   15.93 -			cpy_initrd=1-cpy_initrd
   15.94 -		}
   15.95 -		sub(/lea	bx,\[si\+30\]/, "call	memcpy_image_initrd")
   15.96 -	}
   15.97 -	if (/m = pm2initrd/) ishimem=4
   15.98 -	if (ishimem == 4) {
   15.99 -		if (/si,30/ || /bx,di/ || /di,ax/) next
  15.100 -		sub(/\[si/,"[si+30")
  15.101 -		sub(/mov	bx,si/, "call	memcpy_image_initrd")
  15.102 +		if (/bx,di/ || /di,ax/) next
  15.103  	}
  15.104  	 } # file == "himem.cpp"
  15.105  	 if (file == "load.cpp") {
    16.1 --- a/wpa_supplicant/receipt	Thu Feb 11 17:59:34 2021 +0000
    16.2 +++ b/wpa_supplicant/receipt	Thu Feb 18 08:56:43 2021 +0000
    16.3 @@ -26,6 +26,12 @@
    16.4  	arm*) BUILD_DEPENDS="openssl-dev libcrypto-dev libnl-dev" ;;
    16.5  esac
    16.6  
    16.7 +current_version()
    16.8 +{
    16.9 +	wget -O - $WEB_SITE 2>/dev/null | \
   16.10 +	sed '/releases\//!d;s|.*/'$PACKAGE'-||;s|.t.*||;q'
   16.11 +}
   16.12 +
   16.13  # Rules to configure and make the package.
   16.14  compile_rules()
   16.15  {
   16.16 @@ -36,6 +42,8 @@
   16.17  CONFIG_AP=y
   16.18  CONFIG_BGSCAN_SIMPLE=y
   16.19  CONFIG_LIBNL20=y
   16.20 +CONFIG_USIM_SIMULATOR=y
   16.21 +CONFIG_SIM_SIMULATOR=y
   16.22  EOT
   16.23  	# Dont use DBUS on ARM arch
   16.24  	case "$ARCH" in
   16.25 @@ -86,6 +94,18 @@
   16.26  	# Startup script and cleaned up wpa_empty.conf
   16.27  	cp -a $stuff/etc $fs
   16.28  	install -m644 -oroot -groot $src/$PACKAGE/wpa_supplicant.conf $fs/etc/wpa
   16.29 +
   16.30 +	cat >> $fs/etc/wpa/wpa_supplicant.conf <<EOT
   16.31 +
   16.32 +# SIM emulation example
   16.33 +network={
   16.34 +	ssid="exampleFreeWifi_secure"
   16.35 +	key_mgmt=WPA-EAP
   16.36 +	eap=SIM
   16.37 +	identity="1232010000000000"
   16.38 +	password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581"
   16.39 +}
   16.40 +EOT
   16.41  }
   16.42  
   16.43  # Pre and post install commands for Tazpkg.