wok-next rev 20198

linld: updates from rolling
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 03 15:13:54 2017 +0100 (2017-11-03)
parents db21b68f7891
children c3d04e304a7a
files linld/receipt linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.H linld/stuff/src/HIMEM.CPP linld/stuff/src/ISO9660.H linld/stuff/src/JUMP.ASM linld/stuff/src/LINKX.CMD linld/stuff/src/LOAD.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/MEMTOP.ASM linld/stuff/src/TAZBOOT.CPP linld/stuff/src/VCPI.ASM linld/stuff/src/XMM.ASM linld/stuff/src/_BEG.ASM linld/stuff/upx.sh
line diff
     1.1 --- a/linld/receipt	Fri Nov 03 15:07:20 2017 +0100
     1.2 +++ b/linld/receipt	Fri Nov 03 15:13:54 2017 +0100
     1.3 @@ -33,12 +33,13 @@
     1.4  EOT
     1.5  	SDL_VIDEODRIVER=dummy dosbox MAKE.BAT -exit -c "mount D $src" \
     1.6  		2>&1 | grep -v 'ALSA lib'
     1.7 +	grep Error: */LNK.LOG && return 1
     1.8  	cp LINLD$SUFFIX/LINLD.COM linld.com
     1.9  	cp TAZBOOT/TAZBOOT.COM tazboot.com
    1.10  	objdump -D -b binary -mi386 -Maddr16,data16 --adjust-vma=0x100 \
    1.11  		linld.com > linld.lst
    1.12 -	sh $stuff/upx.sh linld.com
    1.13 -	sh $stuff/upx.sh tazboot.com
    1.14 +	upx -5 --8086 linld.com
    1.15 +	upx -5 --8086 tazboot.com
    1.16  	cc -o tobzimage.o -Wa,-algms=tobzimage.lst -c $stuff/tobzimage.S
    1.17  	objcopy -O binary tobzimage.o tobzimage.bin
    1.18  	cp $stuff/tobzimage .
     2.1 --- a/linld/stuff/src/COMMON.H	Fri Nov 03 15:07:20 2017 +0100
     2.2 +++ b/linld/stuff/src/COMMON.H	Fri Nov 03 15:13:54 2017 +0100
     2.3 @@ -49,7 +49,9 @@
     2.4      void (*next_chunk)(struct image_himem *);
     2.5      u16 state;
     2.6      u16 fd2close;
     2.7 -} pm, initrd;
     2.8 +} imgs[2];
     2.9 +#define pm (imgs[0])
    2.10 +#define initrd (imgs[1])
    2.11  
    2.12  extern int skip_alloc;
    2.13  extern u32 base_himem;
    2.14 @@ -76,7 +78,6 @@
    2.15  // External asm helpers
    2.16  extern "C" void memcpy32(u32, u16,u32, u32);
    2.17  extern "C" void rmcpy();
    2.18 -extern "C" void set_sregs_jump_seg_ofs(u32 csip);
    2.19  extern "C" void xmm_alloc(struct image_himem *m);
    2.20  extern u32 topmem;
    2.21  extern "C" u32 memtopz();
    2.22 @@ -99,4 +100,4 @@
    2.23  extern "C" int read_image(struct image_himem *m, void* data, int sz);
    2.24  char* load_kernel();
    2.25  void load_initrd();
    2.26 -void boot_kernel();
    2.27 +extern "C" void boot_kernel();
     3.1 --- a/linld/stuff/src/CRTL.ASM	Fri Nov 03 15:07:20 2017 +0100
     3.2 +++ b/linld/stuff/src/CRTL.ASM	Fri Nov 03 15:13:54 2017 +0100
     3.3 @@ -165,29 +165,6 @@
     3.4          endp    _puts
     3.5  
     3.6  
     3.7 -		ifdef	EXTRA
     3.8 -;***************************************************************
     3.9 -;int chdir(char *path);
    3.10 -;***************************************************************
    3.11 -        global  _chdir:near
    3.12 -        proc    _chdir near
    3.13 -
    3.14 -		pop	ax
    3.15 -		pop	dx
    3.16 -		push	dx
    3.17 -		push	ax
    3.18 -chdir:
    3.19 -		stc
    3.20 -		mov	ax,713Bh
    3.21 -		int	21h
    3.22 -		jnc	chkc
    3.23 -		mov	ah,3Bh
    3.24 -		jmp	dos
    3.25 -
    3.26 -        endp    _chdir
    3.27 -		endif
    3.28 -
    3.29 -
    3.30  ;***************************************************************
    3.31  ;int fileattr(const char* name);
    3.32  ;***************************************************************
    3.33 @@ -284,10 +261,10 @@
    3.34  
    3.35          endp    _read
    3.36  
    3.37 -		ifdef	EXTRA 
    3.38  ;***************************************************************
    3.39  ;long lseekset(int fd, unsigned long sz);
    3.40  ;***************************************************************
    3.41 +
    3.42          global  _lseekset:near
    3.43          proc    _lseekset near
    3.44  
    3.45 @@ -296,22 +273,6 @@
    3.46                  pop	dx			; sz lo
    3.47                  pop	cx			; sz hi
    3.48                  push	cx
    3.49 -                push	dx
    3.50 -
    3.51 -		else
    3.52 -;***************************************************************
    3.53 -;long seekset(int fd, unsigned sz);
    3.54 -;***************************************************************
    3.55 -        global  _seekset:near
    3.56 -        proc    _seekset near
    3.57 -
    3.58 -		xor	cx,cx
    3.59 -		pop	ax			;caller return address
    3.60 -                pop	bx			; fd
    3.61 -                pop	dx			; sz
    3.62 -                push	dx
    3.63 -		endif
    3.64 -
    3.65                  push	bx
    3.66                  push	ax
    3.67          global  lseekset:near
    3.68 @@ -328,11 +289,7 @@
    3.69  		xor	cx,cx
    3.70  		jmp	dos
    3.71  
    3.72 -		ifdef	EXTRA 
    3.73          endp    _lseekset
    3.74 -		else
    3.75 -        endp    _seekset
    3.76 -		endif
    3.77  
    3.78  		ifdef	EXTRA
    3.79  struc		isostate	; struct isostate {
    3.80 @@ -622,8 +579,8 @@
    3.81  	endif
    3.82  		shl	eax,12		; i*_4k
    3.83  ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again
    3.84 -		extrn	_pm
    3.85 -		mov	bx,offset _pm+2
    3.86 +		extrn	_imgs
    3.87 +		mov	bx,offset _imgs+2
    3.88  		push	eax
    3.89  		add	eax,[bx-2+2]
    3.90  		cmp	eax,edx		; pm.fallback+i*_4k <= edx ?
    3.91 @@ -633,8 +590,8 @@
    3.92  		jae	@@vcpi_alloc
    3.93  @@pmok:
    3.94  ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again
    3.95 -		extrn	_initrd
    3.96 -		mov	bx,offset _initrd+2
    3.97 +		extrn	_imgs
    3.98 +		mov	bx,offset _imgs+32+2
    3.99  		add	eax,[bx-2+2]	; +initrd.fallback
   3.100  		cmp	eax,edx		; initrd.fallback+i*_4k > edx ?
   3.101  		ja	@@initrdok
   3.102 @@ -1342,36 +1299,34 @@
   3.103  		push	si di es
   3.104  		mov	ah,30h
   3.105  		int	21h
   3.106 +		xor	di,di
   3.107  		cmp	al,3
   3.108 +		mov	ax,di
   3.109  		jb	@@skip
   3.110 -		xor	di,di
   3.111 -		mov	es,[cs:2Ch]
   3.112 +		;mov	es,[cs:2Ch]
   3.113 +		mov	es,[di+2Ch]
   3.114  		mov	cx,-1
   3.115 -		mov	ax,di
   3.116 -@@loop1:
   3.117 +@@loop:
   3.118  		repne
   3.119  		  scasb
   3.120  		scasb
   3.121 -		jne	@@loop1
   3.122 -		lea	si,[di+2]
   3.123 -		mov	bx, si
   3.124 -		call	strlen
   3.125 -		xchg	ax,cx
   3.126 -		inc	cx
   3.127 -		call	malloc_or_die
   3.128 -		xchg	ax,di
   3.129 -		push	ds
   3.130 +		jne	@@loop
   3.131 +		inc	di
   3.132 +		inc	di
   3.133 +		mov	si,di			; progname @es:di
   3.134 +		repne
   3.135 +		  scasb
   3.136 +		mov	cx,di
   3.137 +		sub	cx,si			; progname len
   3.138 +		call	malloc_or_die		; keep cx
   3.139 +		mov	di,ax
   3.140  		push	ds
   3.141  		push	es
   3.142  		pop	ds
   3.143  		pop	es
   3.144 -		push	di
   3.145 -@@loop2:
   3.146 -		lodsb
   3.147 -		stosb
   3.148 -		or	al,al
   3.149 -		jnz	@@loop2
   3.150 -		pop	ax
   3.151 +		rep
   3.152 +		  movsb
   3.153 +		push	es
   3.154  		pop	ds
   3.155  @@skip:
   3.156  		pop	es di si
   3.157 @@ -1381,7 +1336,7 @@
   3.158  
   3.159  
   3.160  ;***************************************************************
   3.161 -;int chdirname(char *path)
   3.162 +;void chdirname(char *path)
   3.163  ;***************************************************************
   3.164          global  _chdirname:near
   3.165          proc    _chdirname near
   3.166 @@ -1393,35 +1348,36 @@
   3.167  
   3.168  		cmp	[byte bx+1],3Ah
   3.169  		jne	@@nodisk
   3.170 -		mov	dl,[bx]
   3.171 -		or	dl,20h
   3.172 +		mov	dl,20h
   3.173 +		or	dl,[bx]
   3.174  		sub	dl,61h
   3.175  		mov	ah,0Eh
   3.176 -		push	bx
   3.177  		int	21h
   3.178 -		pop	bx
   3.179  		inc	bx
   3.180  		inc	bx
   3.181  @@nodisk:
   3.182 -		mov	dx,bx
   3.183  		xor	cx,cx
   3.184  @@next:
   3.185  		mov	al,[bx]
   3.186  		cmp	al,5Ch
   3.187  		jne	@@tsteos
   3.188 -		mov	cx,bx
   3.189 +		mov	dx,bx
   3.190 +		inc	cx
   3.191  @@tsteos:
   3.192  		inc	bx
   3.193  		or	al,al
   3.194  		jnz	@@next
   3.195 -		cbw
   3.196  		jcxz	@@end
   3.197 -		mov	bx,cx
   3.198 +		mov	bx,dx
   3.199  		push	[word bx]
   3.200  		mov	[bx],al
   3.201 -		push	bx
   3.202 -		call	chdir
   3.203 -		pop	bx
   3.204 +		stc
   3.205 +		mov	ax,713Bh		; chdir long filename
   3.206 +		int	21h
   3.207 +		mov	ah,3Bh			; chdir
   3.208 +		jnc	chdirdone
   3.209 +		int	21h
   3.210 +chdirdone:
   3.211  		pop	[word bx]
   3.212  @@end:
   3.213  		ret
     4.1 --- a/linld/stuff/src/CRTL.H	Fri Nov 03 15:07:20 2017 +0100
     4.2 +++ b/linld/stuff/src/CRTL.H	Fri Nov 03 15:13:54 2017 +0100
     4.3 @@ -36,7 +36,7 @@
     4.4  extern "C" void abort();
     4.5  extern "C" int read(int fd, void* data, int sz);
     4.6  extern "C" int write(int fd, const void* data, int sz);
     4.7 -extern "C" long seekset(int fd, unsigned sz);
     4.8 +extern "C" long lseekset(int fd, unsigned long sz);
     4.9  extern "C" void* malloc(unsigned sz);
    4.10  extern "C" int puts(const char* s);
    4.11  extern "C" unsigned long strtol(const char *s);
     5.1 --- a/linld/stuff/src/CRTLX.H	Fri Nov 03 15:07:20 2017 +0100
     5.2 +++ b/linld/stuff/src/CRTLX.H	Fri Nov 03 15:13:54 2017 +0100
     5.3 @@ -7,12 +7,9 @@
     5.4  extern "C" int strlen(const char* s);
     5.5  extern "C" char* strstr(const char* a,const char* b);
     5.6  extern "C" char *progname(void);
     5.7 -extern "C" int chdir(char *path);
     5.8 -extern "C" int chdirname(char *path);
     5.9 +extern "C" void chdirname(char *path);
    5.10  extern "C" unsigned long kver2ul(char *kernel_version);
    5.11  extern "C" char *ultoa(unsigned long n);
    5.12  extern "C" void try_default_args();
    5.13 -extern "C" long lseekset(int fd, unsigned long sz);
    5.14 -#define seekset(fd,sz)	lseekset(fd,(unsigned long) sz)
    5.15  extern char cpu_features[];
    5.16  #define cpuhaslm() (cpu_features[3]&0x20)
     6.1 --- a/linld/stuff/src/HIMEM.CPP	Fri Nov 03 15:07:20 2017 +0100
     6.2 +++ b/linld/stuff/src/HIMEM.CPP	Fri Nov 03 15:13:54 2017 +0100
     6.3 @@ -6,8 +6,7 @@
     6.4  #include "crtl.h"
     6.5  #include "common.h"
     6.6  
     6.7 -struct image_himem pm;
     6.8 -struct image_himem initrd;
     6.9 +struct image_himem imgs[2];
    6.10  int skip_alloc;
    6.11  
    6.12  // Called from inside kernel just before rm->pm
     7.1 --- a/linld/stuff/src/ISO9660.H	Fri Nov 03 15:07:20 2017 +0100
     7.2 +++ b/linld/stuff/src/ISO9660.H	Fri Nov 03 15:13:54 2017 +0100
     7.3 @@ -8,9 +8,9 @@
     7.4  #define DIRSECTORSZ	(SECTORSZ/256)
     7.5  extern struct isostate {
     7.6  	int fd;
     7.7 +	unsigned short filemod;
     7.8  	unsigned long fileofs;
     7.9  	unsigned long filesize;
    7.10 -	unsigned short filemod;
    7.11  	char *filename;
    7.12  //private
    7.13  	dirsizetype curdirsize, dirsize;
     8.1 --- a/linld/stuff/src/JUMP.ASM	Fri Nov 03 15:07:20 2017 +0100
     8.2 +++ b/linld/stuff/src/JUMP.ASM	Fri Nov 03 15:13:54 2017 +0100
     8.3 @@ -11,12 +11,18 @@
     8.4                  p386
     8.5  		endif
     8.6  
     8.7 -        group   DGROUP  _TEXT,_BSS
     8.8 +        group   DGROUP  _TEXT,_DATA,_BSS
     8.9          assume  cs:DGROUP,ds:DGROUP
    8.10  
    8.11 +        segment _DATA byte public use16 'DATA'
    8.12 +
    8.13 +overflow	db	"Loaded too close to 9000:0",0
    8.14 +
    8.15 +        ends    _DATA
    8.16 +
    8.17          segment _BSS byte public use16 'BSS'
    8.18  
    8.19 -        global  _pm:dword
    8.20 +        global  _imgs:dword
    8.21  
    8.22          ends    _BSS
    8.23  
    8.24 @@ -24,31 +30,49 @@
    8.25          segment _TEXT byte public use16 'CODE'
    8.26  
    8.27  ;***************************************************************
    8.28 -;void set_sregs_jump_seg_ofs(u32 csip);
    8.29 +;void boot_kernel();
    8.30  ;****** Never returns
    8.31  ;***************************************************************
    8.32 -        global  _set_sregs_jump_seg_ofs:near
    8.33 -        proc    _set_sregs_jump_seg_ofs near
    8.34 -
    8.35 -		extrn	dos_shutdown:near
    8.36 -
    8.37 -		pop	ax			; caller return address
    8.38 +	global	_boot_kernel:near
    8.39 +        proc    _boot_kernel near
    8.40 +        
    8.41 +; Shrink stack: we won't need much of it now and have no malloc() plans
    8.42 +		extrn	_heap_top:word
    8.43 +		mov	ax,[_heap_top]
    8.44 +		inc	ah
    8.45 +		cmp	ax,sp
    8.46 +		ja	@@samesp
    8.47 +		xchg	ax,sp
    8.48 +@@samesp:
    8.49  		ifdef	NO386
    8.50  		extrn	_topseg:near
    8.51  		call	near _topseg
    8.52  		mov	es,ax
    8.53  		xchg	ax,bx
    8.54 +		mov	cl,4
    8.55 +		mov	ax,sp
    8.56 +		shr	ax,cl
    8.57  		else
    8.58 -		push	9000h
    8.59 -		pop	es
    8.60 +		mov	bx,9000h
    8.61 +		mov	es,bx
    8.62 +		mov	ax,sp
    8.63 +		shr	ax,4
    8.64  		endif
    8.65 -		pop	dx			; ip
    8.66 -		pop	cx			; cs
    8.67 +		mov	dx,cs
    8.68 +		add	ax,dx
    8.69 +		cmp	ax,bx
    8.70 +		jb	@@nooverflow
    8.71 +; Oops! We can stomp on our toes... better stop now
    8.72 +		mov	bx,offset overflow
    8.73 +		extrn	die:near
    8.74 +		jmp	near die
    8.75 +@@nooverflow:
    8.76  		cli				; we start doing destructive things to DOS
    8.77  		push	es
    8.78  		pop	ss
    8.79  		mov	sp,0A000h
    8.80 -		push	cx dx
    8.81 +		extrn	_csip:dword
    8.82 +		push	[dword _csip]
    8.83  		extrn	_rm_size:word
    8.84  		mov	si,offset _rm_size	; _rm_size, _pm_high, _rm_buf
    8.85  		lodsw
    8.86 @@ -66,36 +90,34 @@
    8.87  		rep
    8.88  		  movsb
    8.89  		cmp	al,cl			; load high ?
    8.90 -		jne	isbzimage
    8.91 +		jne	@@isbzimage
    8.92  		ifdef	NO386
    8.93  		add	bh,9
    8.94  		push	bx			; topseg()+0x0900
    8.95  		else
    8.96 -		push	9900h			; 4096 bytes for cmdline
    8.97 -	;push	9820h			; 512 bytes for cmdline
    8.98 +		push	9800h+(4096/16)		; 4096 bytes for cmdline
    8.99  		endif
   8.100  		; finish loading
   8.101  		extrn   @last_ditch$qv:near
   8.102  		push	cs
   8.103  		call	@last_ditch$qv
   8.104 -		mov	ax,[word _pm+2+2]	; get pm->fallback high word
   8.105 +		mov	ax,[word _imgs+2+2]	; get pm->fallback high word
   8.106  		; self move
   8.107  		;cld
   8.108  		pop	es			; min 2048 bytes for stack
   8.109  		xor	si,si			;  A000 -9000 -0800(>movedend)
   8.110  		xor	di,di			; set ZF
   8.111  		mov	cx,offset movedend
   8.112 -        global  _bss_end:byte
   8.113 -	;mov	cx,offset _bss_end
   8.114  		rep
   8.115  		  movsb
   8.116  		push	es
   8.117 -		call	near doretf		; mov cs,es
   8.118 +		call	near @@doretf		; mov cs,es
   8.119  		push	ss
   8.120  		pop	es
   8.121  		push	cs
   8.122  		pop	ds
   8.123  		push	ax
   8.124 +		extrn	dos_shutdown:near
   8.125  		call	near dos_shutdown
   8.126  		;in	al,70h
   8.127  		;or	al,80h			; disable NMI
   8.128 @@ -103,12 +125,12 @@
   8.129  		pop	bx
   8.130  		; move zImage pm
   8.131  		mov	ax,8
   8.132 -		cwd
   8.133 +		cwd				; clear dx
   8.134  		cmp	bx,ax
   8.135 -		ja	bufhigh
   8.136 +		ja	@@bufhigh
   8.137  		sub	ax,bx
   8.138  		inc	ax
   8.139 -bufhigh:
   8.140 +@@bufhigh:
   8.141  		push	ax
   8.142  		push	dx			; size=up to 512k
   8.143  		push	bx			; src ofs= pm.fallback
   8.144 @@ -133,10 +155,10 @@
   8.145  		cmp	[dword 1E6h],'SKLE'
   8.146  		else
   8.147  		cmp	[word 1E6h],'LE'
   8.148 -		jne	notelks
   8.149 +		jne	@@notelks
   8.150  		cmp	[word 1E8h],'SK'
   8.151  		endif
   8.152 -		jne	notelks
   8.153 +		jne	@@notelks
   8.154  		ifdef	NO386
   8.155  		mov	cx,120h
   8.156  		push	cx
   8.157 @@ -155,10 +177,9 @@
   8.158  		push	es
   8.159  		pop	ss
   8.160  		push	cx
   8.161 -notelks:
   8.162 +@@notelks:
   8.163  		endif
   8.164 -
   8.165 -isbzimage:
   8.166 +@@isbzimage:
   8.167  		push	ss
   8.168  		pop	ds
   8.169  		;push	ss
   8.170 @@ -171,12 +192,11 @@
   8.171  		endif
   8.172  		assume	nothing
   8.173  		assume	cs:DGROUP
   8.174 -
   8.175 -doretf:
   8.176 +@@doretf:
   8.177                  retf
   8.178  
   8.179  movedend:
   8.180 -        endp    _set_sregs_jump_seg_ofs
   8.181 +        endp    _boot_kernel
   8.182  
   8.183          ends    _TEXT
   8.184  
     9.1 --- a/linld/stuff/src/LINKX.CMD	Fri Nov 03 15:07:20 2017 +0100
     9.2 +++ b/linld/stuff/src/LINKX.CMD	Fri Nov 03 15:13:54 2017 +0100
     9.3 @@ -1,1 +1,1 @@
     9.4 -_beg.obj memcpy32.obj jump.obj vcpi.obj himem.obj crtl.obj memtop.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot
     9.5 +_beg.obj memcpy32.obj memtop.obj jump.obj vcpi.obj himem.obj crtl.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot
    10.1 --- a/linld/stuff/src/LOAD.CPP	Fri Nov 03 15:07:20 2017 +0100
    10.2 +++ b/linld/stuff/src/LOAD.CPP	Fri Nov 03 15:13:54 2017 +0100
    10.3 @@ -115,14 +115,13 @@
    10.4  u8 pm_high;	// @ = @rm_size + 2, see JUMP.ASM
    10.5  u8* rm_buf;	// @ = @rm_size + 3, see JUMP.ASM
    10.6  u32 base_himem = _1m+_64k;
    10.7 -extern struct image_himem pm, initrd;
    10.8  
    10.9  // register value to launch the kernel real mode code
   10.10  #ifdef NO386
   10.11 -static u32 csip;
   10.12 +u32 csip;
   10.13  extern "C" u16 topseg();
   10.14  #else
   10.15 -static u32 csip=0x90200000;
   10.16 +u32 csip=0x90200000;
   10.17  #define topseg() 0x9000
   10.18  #endif
   10.19  
   10.20 @@ -155,7 +154,7 @@
   10.21      if(kernelparams->setup_sects == 0) {
   10.22  #if 1
   10.23          if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) {
   10.24 -            seekset(pm.fd,rm_seek=0x200);
   10.25 +            lseekset(pm.fd,rm_seek=0x200);
   10.26              csip+=0xFFE00042;
   10.27          }
   10.28          else
   10.29 @@ -246,12 +245,12 @@
   10.30  
   10.31  void load_initrd() {
   10.32      struct image_himem *m = &initrd;
   10.33 +    if (!initrd_name && !m->fd) return;
   10.34      m->errmsg = "Can't use initrd file";
   10.35 -    if (!initrd_name && !m->fd) return;
   10.36  
   10.37      open_image(initrd_name, m);
   10.38  
   10.39 -    if ((m->fallback=(memtop()-m->size)&(~PAGE_MASK)) < pm.fallback+pm.size) {
   10.40 +    if ((m->fallback=(memtop()-m->size)&(~PAGE_MASK)) < m[-1].fallback+m[-1].size) {
   10.41          close(m->fd);
   10.42          puts(m->errmsg);
   10.43          return;
   10.44 @@ -264,19 +263,3 @@
   10.45          kernelparams->initrd_size = m->size;
   10.46      }
   10.47  }
   10.48 -
   10.49 -void boot_kernel() {
   10.50 -
   10.51 -    // Shrink stack: we won't need much of it now and have no malloc() plans
   10.52 -    {
   10.53 -        u16 new_SP=u16(heap_top)+0x100;
   10.54 -        if(_SP>new_SP) _SP=new_SP;
   10.55 -    }
   10.56 -    if( (u16(_SP)>>4)+u16(_CS) >= topseg() ) {
   10.57 -        // Oops! We can stomp on our toes... better stop now
   10.58 -        die("Loaded too close to 9000:0");
   10.59 -    }
   10.60 -
   10.61 -    // Move rm loader & commandline to 0x90000, Jump to kernel rm code
   10.62 -    set_sregs_jump_seg_ofs(csip);
   10.63 -}
    11.1 --- a/linld/stuff/src/MEMCPY32.ASM	Fri Nov 03 15:07:20 2017 +0100
    11.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Fri Nov 03 15:13:54 2017 +0100
    11.3 @@ -39,15 +39,17 @@
    11.4  		push	ss
    11.5  		push	ax
    11.6  		pop	[dword cs:sssp]
    11.7 +		mov	[word bx+4],offset step19
    11.8  		else
    11.9 +		mov	ax,offset step19
   11.10 +		xchg	ax,[word bx+4]
   11.11  		push	[word bx+6]	
   11.12 -		push	[word bx+4]		; save step
   11.13 +		push	ax			; save step
   11.14  		mov	[word cs:sssp],sp
   11.15  		mov	[word cs:sssp+2],ss
   11.16  		endif
   11.17  		;cmp	[byte bx+7],0F0h
   11.18  		;jnc	notdos
   11.19 -		mov	[word bx+4],offset step19
   11.20  		mov	[bx+6],cs
   11.21  		pushf
   11.22  		pop	ax
   11.23 @@ -72,10 +74,10 @@
   11.24  		ifndef	NO386
   11.25  		lss	sp,[dword cs:sssp]
   11.26  		else
   11.27 -		lds	bx,[dword cs:sssp]
   11.28 +		lds	ax,[dword cs:sssp]
   11.29  		push	ds
   11.30  		pop	ss
   11.31 -		mov	sp,bx
   11.32 +		xchg	ax,sp
   11.33  		endif
   11.34  		xor	bx,bx
   11.35  		mov	ds,bx
   11.36 @@ -168,13 +170,16 @@
   11.37  		xor	bx,bx
   11.38  		xor	dx,dx
   11.39  		xor	si,si
   11.40 -		mov	ax,[bp+8]		; srcseg
   11.41 -		call	near N_LXLSH@4
   11.42 -		add	[bp+10],ax		; srcofs lo
   11.43 -		adc	[bp+10+2],dx		; srcofs hi
   11.44 +		mov	ax,[srcseg]
   11.45 +		mov	cl,4
   11.46 +		extrn	N_LXLSH@:near
   11.47 +		call	near N_LXLSH@
   11.48 +		add	[word srcofs],ax
   11.49 +		adc	[word srcofs+2],dx
   11.50  @@2flat:
   11.51 -		mov	ax,[bp+si+10]		; srcofs, dstofs lo
   11.52 -		mov	dx,[bp+si+10+2]		; srcofs, dstofs hi
   11.53 +		mov	ax,[word si+srcofs]	; srcofs, dstofs lo
   11.54 +		mov	dx,[word si+srcofs+2]	; srcofs, dstofs hi
   11.55 +		extrn	N_LXURSH@4:near
   11.56  		call	near N_LXURSH@4
   11.57  		or	bx,dx			; >=1mb flag
   11.58  		push	ax			; srcseg, dstseg
   11.59 @@ -182,8 +187,8 @@
   11.60  		jnz	@@2flat
   11.61  		pop	dx			; dstseg
   11.62  		pop	ax			; srcseg
   11.63 -		test	bx,bx			; <1mb ? (clear C)
   11.64 -                jnz     @@pmcopy
   11.65 +		dec	bx			; <1mb ?
   11.66 +                jns     @@pmcopy
   11.67  		push	di
   11.68  @@movlp:
   11.69  		mov	ds,ax
   11.70 @@ -260,7 +265,7 @@
   11.71                  ;db      66h     ;operand width override for ecx
   11.72                  db      67h     ;address width override for esi/edi
   11.73              rep movsb
   11.74 -		cld
   11.75 +		;cld
   11.76  
   11.77  ;****** Return to rm *******************************************
   11.78                  dec     ax              ;CR0_PE off
   11.79 @@ -298,39 +303,6 @@
   11.80  
   11.81          endp    _memcpy32
   11.82  
   11.83 -		ifdef	NO386
   11.84 -        global  N_LXURSH@:near
   11.85 -        global  N_LXURSH@4:near
   11.86 -        proc    N_LXURSH@4 near
   11.87 -
   11.88 -		mov	cl,4
   11.89 -N_LXURSH@:
   11.90 -		mov	ch,0
   11.91 -@@loop:
   11.92 -		shr	dx,1
   11.93 -		rcr	ax,1
   11.94 -		loop	@@loop
   11.95 -		ret
   11.96 -
   11.97 -        endp    N_LXURSH@4
   11.98 -
   11.99 -        global  N_LXLSH@:near
  11.100 -        global  N_LXLSH@4:near
  11.101 -        proc    N_LXLSH@4 near
  11.102 -
  11.103 -		mov	cl,4
  11.104 -N_LXLSH@:
  11.105 -		mov	ch,0
  11.106 -@@loop:
  11.107 -		shl	ax,1
  11.108 -		rcl	dx,1
  11.109 -		loop	@@loop
  11.110 -		ret
  11.111 -
  11.112 -        endp    N_LXLSH@4
  11.113 -
  11.114 -		endif
  11.115 -
  11.116          ends    _TEXT
  11.117  
  11.118          end
    12.1 --- a/linld/stuff/src/MEMTOP.ASM	Fri Nov 03 15:07:20 2017 +0100
    12.2 +++ b/linld/stuff/src/MEMTOP.ASM	Fri Nov 03 15:13:54 2017 +0100
    12.3 @@ -42,23 +42,21 @@
    12.4  ;***************************************************************
    12.5  ;        proc    _memtop_e801 near
    12.6  
    12.7 -                ;push    cx bx
    12.8                  xor     cx,cx           ;fix to work around buggy
    12.9                  xor     dx,dx           ;  BIOSes which dont clear/set
   12.10                  stc                     ;  carry on pass/error of
   12.11                  mov     ax,0E801h
   12.12                  int     15h
   12.13                  jc      @@err
   12.14 -                test    cx,cx           ;kludge to handle BIOSes
   12.15 -                jnz     @@use_cxdx      ;  which report their extended
   12.16 -                test    dx,dx           ;  memory in AX/BX rather than
   12.17 +		xchg	ax,cx
   12.18 +                push    ax              ;kludge to handle BIOSes
   12.19 +                or      ax,dx           ;  which report their extended
   12.20 +		pop	ax		;  memory in AX/BX rather than
   12.21                  jnz     @@use_cxdx      ;  CX/DX.  The spec I have read
   12.22  @@use_axbx:     mov     dx,bx           ;  seems to indicate AX/BX
   12.23 -                jmp     @@end_kludge    ;  are more reasonable anyway...
   12.24 -@@use_cxdx:     xchg    ax,cx
   12.25 -@@end_kludge:                   ;now: dx=64k units above 16m
   12.26 +                xchg	ax,cx		;  are more reasonable anyway...
   12.27 +@@use_cxdx:                     ;now: dx=64k units above 16m
   12.28                                  ;     ax=1k units above 1m below 16m (max 3c00h)
   12.29 -                ;pop     bx cx
   12.30                  test    dx,dx
   12.31                  jz      tokb            ;dx=0 here, ax=kbs above 1m
   12.32                  xor     ax,ax           ;ignore info on low 16M (assume full)
   12.33 @@ -84,28 +82,56 @@
   12.34  @@ok:
   12.35  ;                xor     dx,dx
   12.36                  test    ax,ax           ;happens on big mem systems
   12.37 -                jz      @@fail
   12.38 +                jnz      tokb
   12.39 +
   12.40 +;***************************************************************
   12.41 +;u32 memtop_cmos()
   12.42 +;***************************************************************
   12.43 +
   12.44 +;memtop_cmos:
   12.45 +                pushf
   12.46 +                cli
   12.47 +                call	rdcmos17
   12.48 +                popf
   12.49  tokb:
   12.50                  xor     dx,dx
   12.51                  add     ah,4h           ;account for 1024 low kb
   12.52                  adc     dx,dx           ;  (optimized to death)
   12.53 +		mov	cl,10		;multiply by 1024
   12.54 +        global  N_LXLSH@:near
   12.55 +N_LXLSH@:
   12.56  		ifndef	NO386
   12.57 -                shld    dx,ax,10        ;multiply by 1024
   12.58 -                shl     ax,10           ;  (kbytes -> bytes)
   12.59 +		shld    dx,ax,cl
   12.60 +		shl     ax,cl		;  (kbytes -> bytes)
   12.61  		else
   12.62 +		mov	ch,0
   12.63  @@lp:
   12.64 -		mov	cx,10
   12.65 -                shl     ax,1            ;multiply by 1024
   12.66 +		shl	ax,1
   12.67  		rcl	dx,1
   12.68  		loop	@@lp
   12.69  		endif
   12.70 -;		mov	cx,ax
   12.71 -;		or	cx,dx		;update ZF
   12.72 -;@@fail:
   12.73 -                ret
   12.74 +		ret
   12.75 +
   12.76  ;        endp    _memtop_88
   12.77  
   12.78 -@@fail:
   12.79 +		ifdef	NO386
   12.80 +        global  N_LXURSH@:near
   12.81 +        global  N_LXURSH@4:near
   12.82 +;        proc    N_LXURSH@4 near
   12.83 +N_LXURSH@4:
   12.84 +		mov	cl,4
   12.85 +N_LXURSH@:
   12.86 +		mov	ch,0
   12.87 +@@loop:
   12.88 +		shr	dx,1
   12.89 +		rcr	ax,1
   12.90 +		loop	@@loop
   12.91 +		ret
   12.92 +
   12.93 +;        endp    N_LXURSH@4
   12.94 +
   12.95 +		endif
   12.96 +
   12.97  
   12.98  ;        proc    _memtopz near
   12.99  
  12.100 @@ -113,16 +139,7 @@
  12.101  ;		jnz	@@ok
  12.102  ;                call	_memtop_88
  12.103  ;		jnz	@@ok
  12.104 -
  12.105 -;***************************************************************
  12.106 -;u32 memtop_cmos()
  12.107 -;***************************************************************
  12.108 -
  12.109 -                pushf
  12.110 -                cli
  12.111 -                call	rdcmos17
  12.112 -                popf
  12.113 -		jmp	tokb
  12.114 +;		jmp	memtop_cmos
  12.115  
  12.116  rdcmos17:       mov     al,18h		; read bytes 17-18 from CMOS
  12.117                  call    @@rdcmos
  12.118 @@ -173,38 +190,36 @@
  12.119  
  12.120  		ifndef  xmm_hook
  12.121                  mov     ax,4300h
  12.122 -		ifdef	NO386
  12.123 -		cwd
  12.124 -		endif
  12.125                  int     2fh
  12.126                  cmp     al,80h			; 80h = XMS driver installed
  12.127                  je      @@skip
  12.128  		endif
  12.129 +		xor	bx,bx
  12.130 +		mov	es,bx
  12.131  		ifndef	NO386
  12.132 -		push	0
  12.133 -		pop	es
  12.134 -		mov	bx,15*4
  12.135 -		mov	eax,[bx]
  12.136 +		push	cs
  12.137 +		push	offset int15_88
  12.138 +		pop	eax
  12.139 +		xchg	eax,[es:bx+15*4]
  12.140  		mov	[saved15],eax
  12.141  		else
  12.142 -		mov	es,dx
  12.143 -		mov	bx,15*4
  12.144 -		mov	ax,[bx]
  12.145 +		mov	ax,offset int15_88
  12.146 +		xchg	ax,[es:bx+15*4]
  12.147  		mov	[word saved15],ax
  12.148 -		mov	ax,[bx+2]
  12.149 +		mov	ax,cs
  12.150 +		xchg	ax,[es:bx+15*4+2]
  12.151  		mov	[word saved15+2],ax
  12.152  		endif
  12.153 -		mov	[word bx],offset int15_88
  12.154 -		mov	[bx+2],cs
  12.155  @@skip:
  12.156  		ret
  12.157  int15_88:
  12.158                  cmp     ah,88h
  12.159                  je      @@do88
  12.160 +@@jmp_saved15:
  12.161                  jmp     [saved15]
  12.162  @@do88:
  12.163                  pushf
  12.164 -                call    [saved15]
  12.165 +                call    @@jmp_saved15
  12.166                  test    ax,ax
  12.167                  jnz     @@iret
  12.168  
    13.1 --- a/linld/stuff/src/TAZBOOT.CPP	Fri Nov 03 15:07:20 2017 +0100
    13.2 +++ b/linld/stuff/src/TAZBOOT.CPP	Fri Nov 03 15:13:54 2017 +0100
    13.3 @@ -83,10 +83,10 @@
    13.4  	if (iso[1] && !strcmp(mode = iso[1], "text"))
    13.5  		init = "";
    13.6  	do {
    13.7 -		if ((isoopen(mode) >= 0 && ++noauto)	||	// custom
    13.8 +		if ((isoopen(mode) >= 0 && ++noauto != 0) ||	// custom
    13.9  		    isoopen("bzImage") >= 0		|| 	// SliTaz
   13.10  		    isoopen("vmlinuz") >= 0		||	// misc
   13.11 -		    (isoopen("linux") >= 0 && ++isknoppix)) {
   13.12 +		    (isoopen("linux") >= 0 && ++isknoppix != 0)) {
   13.13  			magic = kver2ul(isokernel());
   13.14  			break;
   13.15  		}
   13.16 @@ -100,7 +100,7 @@
   13.17  		c = x->filename[6];
   13.18  	}
   13.19  
   13.20 -	strcatb(_cmdline,"rw root=/dev/null autologin bootfrom=");
   13.21 +	strcatb(_cmdline," rw root=/dev/null autologin bootfrom=");
   13.22  	strcat(_cmdline,*iso);
   13.23  	if (magic < 0x20630)
   13.24  		init = ""; // Does not support multiple initramfs
   13.25 @@ -117,19 +117,20 @@
   13.26  		}
   13.27  	}
   13.28  	else if (magic > 0) {
   13.29 -		char *initrd = fallback;
   13.30 -		static const unsigned long initrddesc = 20L;
   13.31 +		char *initrdfilename = fallback;
   13.32 +		static const unsigned long initrddesc = 18L;
   13.33  
   13.34  		if (rootfs[0]) {
   13.35 -			initrd = rootfs;
   13.36 +			initrdfilename = rootfs;
   13.37  			if (rootfs[6] != '.' && isoopen("rootfs.gz") >= 0)
   13.38  				addinitrd();	// for loram
   13.39  		}
   13.40 -		if (isoopen(initrd) >= 0) {
   13.41 +		if (isoopen(initrdfilename) >= 0) {
   13.42  			addinitrd();
   13.43  		}
   13.44  		if (*init && isolseek(&initrddesc) != -1) {
   13.45 -			read(x->fd, &x->fileofs, 8); // and x->filesize
   13.46 +			read(x->fd, &x->filemod, 10); // + x->fileofs & x->filesize
   13.47 +			magic = x->filemod;
   13.48  			x->fileofs &= 0xFFFFL;
   13.49  			x->fileofs -= 0xC0L + (x->filesize &= 0xFFFF);
   13.50  			if (((short *) &x->fileofs)[1] == 0) addinitrd();
   13.51 @@ -189,6 +190,7 @@
   13.52  			s++;
   13.53  	set_kernel:
   13.54  			s += 6;
   13.55 +	set_kernelz:
   13.56  			kernel_name = s;
   13.57  		}
   13.58  		else if (strhead(s,"image=") == 0) {
   13.59 @@ -225,7 +227,7 @@
   13.60  			goto next;
   13.61  		default:
   13.62  		if(i == 1 && fileattr(s) != -1) {
   13.63 -			goto set_kernel;
   13.64 +			goto set_kernelz;
   13.65  		}
   13.66  		else {
   13.67  			if(strhead(s,"root=") == 0) {
    14.1 --- a/linld/stuff/src/VCPI.ASM	Fri Nov 03 15:07:20 2017 +0100
    14.2 +++ b/linld/stuff/src/VCPI.ASM	Fri Nov 03 15:13:54 2017 +0100
    14.3 @@ -102,7 +102,7 @@
    14.4  label sw2pm_params byte
    14.5  ;Note: base addrs will be fixed up in prepare_vcpi()
    14.6  label	pagedir_laddr   dword
    14.7 -sw2pm_cr3       dd      ?
    14.8 +sw2pm_cr3       dd      1000h
    14.9  sw2pm_gdtr_ptr  dw      offset gdtr,0
   14.10  sw2pm_idtr_ptr  dw      offset idtr,0
   14.11  sw2pm_ldtr      dw      0       ;we don't need it
   14.12 @@ -121,11 +121,6 @@
   14.13  
   14.14          segment _BSS byte public use16 'BSS'
   14.15  
   14.16 -;Pagedir/page0 addrs: linear, seg:0 and cs:ofs
   14.17 -page0_laddr     dd      ?
   14.18 -;pagedir_ofs     dw      ?
   14.19 -;page0_ofs       dw      ?
   14.20 -
   14.21  label   saved_ss_sp dword
   14.22  saved_sp        dw      ?
   14.23  saved_ss        dw      ?
   14.24 @@ -150,68 +145,44 @@
   14.25                  ;push    bx
   14.26                  ;push    ax
   14.27  prepare_vcpi:
   14.28 -                ;push    esi
   14.29 -                ;push    es
   14.30  
   14.31  ;Calculate pagedir/page0 addrs, initialize cr3 and pagedir[0]
   14.32                  xor     eax,eax
   14.33  ;    heap_top = prepare_vcpi(malloc_or_die(8*1024+4)); 
   14.34  		mov	cx,8*1024+4
   14.35                  extrn   malloc_or_die:near
   14.36 -		call	malloc_or_die
   14.37 +		call	malloc_or_die	;keep cx
   14.38  
   14.39 -		mov	cl,4
   14.40                  mov     edx,cs
   14.41                  shl     edx,cl          ;edx = linear addr of CS
   14.42                  mov     si,offset gdt_vcpi
   14.43  ; Fix up base of some gdt descriptors
   14.44  ; Note: 'add [dword xx.base0],edx' actually updates 24 bit quantity!
   14.45  ; Do NOT replace with mov!
   14.46 -		xor	ebx,ebx
   14.47 -                add     [dword bx+si+sw2pm_idtr_ptr-gdt_vcpi],edx
   14.48 +		mov	ebx,10000h-28h
   14.49 +                add     [dword bx+si+sw2pm_idtr_ptr-gdt_vcpi+28h],edx
   14.50  @@fixup:
   14.51 -                add     [dword bx+si+(gdt_code.base0)-gdt_vcpi],edx
   14.52 -		add	bl,8
   14.53 -		cmp	bl,28h
   14.54 -		jb	@@fixup
   14.55 -                ;add     [dword si+(gdt_data.base0)-gdt_vcpi],edx
   14.56 -                ;add     [dword si+(gdt_tss.base0)-gdt_vcpi],edx
   14.57 -                ;add     [dword si+gdt_base-gdt_vcpi],edx
   14.58 -                ;add     [dword si+sw2pm_gdtr_ptr-gdt_vcpi],edx
   14.59 -                ;add     [dword si+sw2pm_idtr_ptr-gdt_vcpi],edx
   14.60 +                add     [dword bx+si+(gdt_code.base0)-gdt_vcpi+28h],edx
   14.61 +		add	bx,8
   14.62 +		js	@@fixup
   14.63 +		mov	bh,10h
   14.64                  add     eax,edx
   14.65 -                mov     bx,0FFFh
   14.66 -                add     eax,ebx
   14.67 -		inc	bx		;ebx=00001000h
   14.68 -
   14.69 -                shr     eax,cl
   14.70 -                mov     al,0   ;eax = 4k aligned linear addr of pagebuf
   14.71 -                mov     es,ax           ;es:0->page0,es:1000h->pagedir
   14.72 -                shl     eax,cl          ;eax=page0 linear addr
   14.73 +		and	ax,0f000h       ;eax = 4k aligned linear addr of pagebuf
   14.74 +                add     eax,ebx         ;eax=page0 linear addr
   14.75 +                add     [si+sw2pm_cr3-gdt_vcpi],eax
   14.76 +                mov     edi,eax
   14.77 +                sub     edi,edx
   14.78                  mov     al,3            ;add present+writable bits
   14.79 -                mov     [es:bx],eax     ;stuff it into pagedir[0]
   14.80 +                mov     [bx+di],eax     ;stuff it into pagedir[0]
   14.81                  push    ds
   14.82 -                pop     es
   14.83 -
   14.84 -		mov	al,0
   14.85 -                mov     [page0_laddr],eax
   14.86 -                add     eax,ebx
   14.87 -                ;mov     [pagedir_laddr],eax
   14.88 +                pop     es              ;es:di->page0,es:di+1000h->pagedir
   14.89                          ;page directory will use only one entry (4 bytes):
   14.90                          ;cr3 => pagedir => page0  => ########
   14.91                          ;      (1 entry)  (1024   => #  4M  #
   14.92                          ;                 entries)=> # page #
   14.93                          ;                         => ########
   14.94 -                mov     [sw2pm_cr3],eax
   14.95 -                sub     eax,edx         ;ax = offset in CS of pagedir
   14.96 -                ;mov     [pagedir_ofs],ax
   14.97 -                sub     ax,bx   ;ax-=1000
   14.98 -                ;mov     [page0_ofs],ax
   14.99 -                mov     di,ax          ;ES:DI => page0
  14.100  ; Return
  14.101 -                ;pop     es
  14.102 -                ;pop     esi
  14.103 -                add     ax,1004h
  14.104 +                lea     ax,[bx+di+4]
  14.105  		extrn	_heap_top:word
  14.106  		mov	[_heap_top],ax
  14.107                  ;ret
  14.108 @@ -392,11 +363,12 @@
  14.109          ; Restore page mapping for page at 0
  14.110                 ;pop     eax             ;X
  14.111  @@set_mapping:
  14.112 -                mov     esi,[cs:page0_laddr]
  14.113 -                xchg    [esi],eax       ; restore page0[0]
  14.114 +                mov     esi,[cs:sw2pm_cr3]
  14.115 +                xchg    [esi-1000h],eax ; restore page0[0]
  14.116                  mov     ecx,cr3         ; reload TLB cache
  14.117                  mov     cr3,ecx         ;
  14.118  ; Return
  14.119 +vcpi_ret:
  14.120                  ret
  14.121  
  14.122          endp    call_pm_routine
  14.123 @@ -414,14 +386,13 @@
  14.124                  p8086
  14.125  		extrn	_vcpi:byte
  14.126  		test	[_vcpi],-1
  14.127 -		jz	@@ret
  14.128 +		jz	vcpi_ret
  14.129                  p386
  14.130 +                pop	ax
  14.131 +                push    cs      ;*
  14.132 +                push	ax
  14.133                  push	si
  14.134 -              ;;pushf
  14.135 -              ;;pushad
  14.136 -                push    cs      ;*
  14.137                  push    ds
  14.138 -                ;push    es
  14.139                  mov     [saved_ss],ss
  14.140                  mov     [saved_sp],sp
  14.141  
  14.142 @@ -439,23 +410,13 @@
  14.143                  mov     eax,cr0
  14.144                  and     eax,7ffffffeh   ; clear PG,P bits
  14.145                  mov     cr0,eax         ; look mommy, we're in rm now!
  14.146 -              ;;jmp     short $+2
  14.147 -              ;;xor     eax,eax
  14.148                  mov     cr3,eax         ; flush TLB cache
  14.149  
  14.150  ; Now we are in rm, but not yet: have to restore sregs:
  14.151                  lss     sp,[saved_ss_sp]; SS
  14.152 -                ;pop     es              ; ES
  14.153                  pop     ds              ; DS
  14.154 -               ;push    cs      ;* done earlier
  14.155 -                push    offset @@next
  14.156 +                pop	si
  14.157                  retf                    ; CS
  14.158 -@@next:
  14.159 -              ;;popad
  14.160 -              ;;popf
  14.161 -                pop	si
  14.162 -@@ret:
  14.163 -                ret             ; We don't care much about rest (FS/GS)
  14.164  
  14.165          endp    _vm2rm
  14.166  
    15.1 --- a/linld/stuff/src/XMM.ASM	Fri Nov 03 15:07:20 2017 +0100
    15.2 +++ b/linld/stuff/src/XMM.ASM	Fri Nov 03 15:13:54 2017 +0100
    15.3 @@ -43,11 +43,13 @@
    15.4          global  xmm_driver:near
    15.5          proc    xmm_driver near
    15.6  
    15.7 +		push	si
    15.8 +		mov	si,offset xmm_handler
    15.9  		ifndef	NO386
   15.10 -		cmp	[xmm_handler],0
   15.11 +		cmp	[si],0
   15.12  		else
   15.13 -		mov	ax,[word xmm_handler]
   15.14 -		or	ax,[word xmm_handler+2]
   15.15 +		mov	ax,[word si]
   15.16 +		or	ax,[word si+2]
   15.17  		endif
   15.18  		jne	@@gotit
   15.19  
   15.20 @@ -65,9 +67,10 @@
   15.21  		xchg	ax,cx			; restore cmd
   15.22  		push	es
   15.23  		push	bx
   15.24 -		pop	[xmm_handler]
   15.25 +		pop	[dword si]
   15.26  @@gotit:
   15.27 -		call	[xmm_handler]
   15.28 +		call	[dword si]
   15.29 +		pop	si
   15.30                  ret
   15.31  xmm_fail:
   15.32                  xor     ax,ax
   15.33 @@ -109,11 +112,9 @@
   15.34  		mov	dx,[bx+8]		; hi m->size
   15.35  		sub	ax,1
   15.36  		sbb	dx,0
   15.37 -		mov	cx,10
   15.38 -@@tokblp:
   15.39 -		shr	dx,1
   15.40 -		rcr	ax,1
   15.41 -		loop	@@tokblp
   15.42 +		mov	cl,10
   15.43 +		extrn	N_LXURSH@:near
   15.44 +		call	N_LXURSH@
   15.45  		endif
   15.46                  inc     dx
   15.47  		push	bx
    16.1 --- a/linld/stuff/src/_BEG.ASM	Fri Nov 03 15:07:20 2017 +0100
    16.2 +++ b/linld/stuff/src/_BEG.ASM	Fri Nov 03 15:13:54 2017 +0100
    16.3 @@ -35,14 +35,31 @@
    16.4  ;***************************************************************
    16.5  
    16.6  ; Check for oldies
    16.7 +		ifndef	EXTRA
    16.8  		push	sp
    16.9  		pop	ax
   16.10 +		sub	ax,sp
   16.11 +		 ifndef	NO386
   16.12  		mov	bx,offset msg_badcpu
   16.13 -		sub	ax,sp
   16.14 -		ifndef	NO386
   16.15                  jnz	no_vcpi   	;it is a 86/186 not a 286+
   16.16 +		 else
   16.17 +                jnz	endcpu   	;it is a 86/186 not a 286+
   16.18 +		 endif
   16.19  		else
   16.20 -		jnz	endcpu
   16.21 +		pushf
   16.22 +		mov	bh, 0F0h
   16.23 +		push	bx		; < 286 : flags[12..15] are forced 1
   16.24 +		popf			; = 286 : flags[12..15] are forced 0
   16.25 +		pushf			; > 286 : only flags[15] is forced 0
   16.26 +		pop	dx
   16.27 +		popf
   16.28 +		add	dh,bh		; NS=386+, NC=286
   16.29 +		 ifndef	NO386
   16.30 +		mov	bx,offset msg_badcpu
   16.31 +                js	no_vcpi   	;it is not a 386+
   16.32 +		 else
   16.33 +                js	endcpu   	;it is not a 386+
   16.34 +		 endif
   16.35  		endif
   16.36                  p386
   16.37  		ifdef	EXTRA
   16.38 @@ -178,7 +195,8 @@
   16.39                  or	dl,dl
   16.40                  je	arglp			; not start of string
   16.41                  dec	si
   16.42 -                jmp	newarg
   16.43 +                ;jmp	newarg
   16.44 +		db	0B9h			; mov cx,im opcode
   16.45  isargstr:
   16.46                  mov	ah,al			; expected eos
   16.47  newarg:
   16.48 @@ -233,7 +251,9 @@
   16.49          segment _DATA byte public use16 'DATA'
   16.50          global  _data_start:byte
   16.51          label   _data_start byte
   16.52 +		ifndef	NO386
   16.53  msg_badcpu      db      "I need 386+ CPU in real mode or under VCPI manager"
   16.54 +		endif
   16.55          global  _vcpi:byte
   16.56  _vcpi		db	0
   16.57  msg_badmapping  db      "VCPI: low 640k: need 1:1 mapping",0
    17.1 --- a/linld/stuff/upx.sh	Fri Nov 03 15:07:20 2017 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,8 +0,0 @@
    17.4 -#!/bin/sh
    17.5 -
    17.6 -if upx 2>&1 | grep -q "UPX 3.91" ; then
    17.7 -  upx -5 $1 && echo "0  3C E8 75 FB 89 F7 AD 86 E0 29 F8 AB |" | hexdump -R | \
    17.8 -  dd bs=1 seek=$(($(stat -c %s $1) - 15)) of=$1 conv=notrunc 2> /dev/null
    17.9 -else
   17.10 -  upx -5 --8086 $1
   17.11 -fi