wok-6.x rev 19546

linld/tazboot: default conf in tazboot.cmd
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 06 18:49:44 2016 +0100 (2016-12-06)
parents de3143af6c92
children cefa4ef5052f
files linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.ASM linld/stuff/src/CRTLX.H linld/stuff/src/HIMEM.CPP linld/stuff/src/ISO9660.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/TAZBOOT.CPP linld/stuff/src/VCPI.ASM linld/stuff/src/_BEG.ASM
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Tue Dec 06 15:51:50 2016 +0200
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Tue Dec 06 18:49:44 2016 +0100
     1.3 @@ -12,17 +12,18 @@
     1.4  
     1.5          segment _DATA byte public use16 'DATA'
     1.6  
     1.7 -msg_hang	db      "High mem corrupted - not exiting to DOS",0
     1.8 +        global  _heap_top:word
     1.9 +	extrn	_bss_end
    1.10 +_heap_top	dw	_bss_end
    1.11 +msg_hang	db      "High mem corrupted - not exiting to DOS"
    1.12 +msg_crlf	db	13,10,0
    1.13  vcpi_alloc_err	db	"vcpi "
    1.14  msg_malloc      db      "malloc() failure",0
    1.15 -msg_crlf	db	13,10,0
    1.16  
    1.17          ends    _DATA
    1.18  
    1.19          segment _BSS byte public use16 'BSS'
    1.20  
    1.21 -        global  _heap_top:word
    1.22 -_heap_top	dw	?
    1.23          global  _no_exit:byte
    1.24  _no_exit	db	?
    1.25  filecnt		db	?		; in fact 0 minus file count...
    1.26 @@ -187,21 +188,19 @@
    1.27  
    1.28  
    1.29  ;***************************************************************
    1.30 -;int open(const char* name, int flags);
    1.31 +;int open(const char* name, int flags=O_RDONLY);
    1.32  ;***************************************************************
    1.33          global  _open:near
    1.34          proc    _open near
    1.35  
    1.36 -		pop	cx			;caller return address
    1.37 +		pop	ax			;caller return address
    1.38                  pop	bx			; name
    1.39 -                pop	ax			; flags
    1.40 +                push	bx
    1.41                  push	ax
    1.42 -                push	bx
    1.43 -                push	cx
    1.44 -        global  open:near			; open(bx,al)
    1.45 +        global  open:near			; open(bx)
    1.46  open:
    1.47                  mov	dx,bx
    1.48 -                mov	ah,3dh
    1.49 +                mov	ax,3d00h
    1.50  dos:
    1.51                  int	21h
    1.52  chkc:
    1.53 @@ -431,6 +430,19 @@
    1.54  
    1.55          endp    _die
    1.56  
    1.57 +struc   image_himem		;struct image_himem {
    1.58 +fd		dw	?	; 0    int fd;
    1.59 +fallback	dd	?	; 2    u32 fallback;
    1.60 +size		dd	?	; 6    u32 size;
    1.61 +remaining	dd	?	;10    u32 remaining;
    1.62 +buf		dd	?	;14    u32 buf;
    1.63 +bufv		dw	?	;18    u32 *bufv;
    1.64 +errmsg		dw	?	;20    char *errmsg;
    1.65 +chunk_size	dd	?	;22    u32 chunk_size;
    1.66 +next_chunk	dw	?	;26    void (*next_chunk)(struct image_himem *);
    1.67 +state		dw	?	;28    u16 state;
    1.68 +fd2close	dw	?	;30    u16 fd2close;
    1.69 +ends				;};
    1.70  
    1.71  ;***************************************************************
    1.72  ;u32* malloc_bufv_or_die(struct image_himem *m);
    1.73 @@ -444,7 +456,7 @@
    1.74  		push	bx
    1.75  		push	si
    1.76  		xchg	ax,si
    1.77 -		mov	ecx,[si+6]		; m->size
    1.78 +		mov	ecx,[(image_himem si).size]
    1.79  		dec	ecx
    1.80  		shr	ecx,12
    1.81  		inc	cx			; cnt = (m->size+PAGE_MASK)/PAGE_SIZE;
    1.82 @@ -457,7 +469,7 @@
    1.83                  pop	cx
    1.84  		push	cx			; _sort:nel
    1.85  		push	ax			; _sort:base
    1.86 -		mov	[si+18],ax		; m->bufv
    1.87 +		mov	[(image_himem si).bufv],ax
    1.88  		xchg	ax,bx
    1.89  @@vcpi_alloc:
    1.90                  xor     edx,edx
    1.91 @@ -489,8 +501,8 @@
    1.92  		shl	bx,2
    1.93  		add	bx,ax			; m->bufv
    1.94  		mov	edx,[bx]		; m->bufv[i]
    1.95 -		sub	edx,[si+2]		; m->fallback
    1.96 -		cmp	edx,[si+6]		; m->size
    1.97 +		sub	edx,[(image_himem si).fallback]
    1.98 +		cmp	edx,[(image_himem si).size]
    1.99  		jae	@@chknext
   1.100  		shr	edx,12
   1.101  		cmp	dx,cx
   1.102 @@ -524,7 +536,7 @@
   1.103  		push	bx
   1.104  		push	si di
   1.105  		xchg	ax,di
   1.106 -		mov	bx,[di]			; m->fd
   1.107 +		mov	bx,[(image_himem di).fd]
   1.108  		call	close
   1.109  		ifndef	NO386
   1.110  		xor	eax,eax
   1.111 @@ -532,8 +544,8 @@
   1.112  		xor	ax,ax
   1.113  		endif
   1.114  		cwd
   1.115 -		mov	[di],ax			; m->fd
   1.116 -		mov	bx,[di+28]		; m->state
   1.117 +		mov	[(image_himem di).fd],ax
   1.118 +		mov	bx,[(image_himem di).state]
   1.119  		cmp	al,[bx]			; ""
   1.120  		jz	@@end
   1.121  		mov	si,bx
   1.122 @@ -546,16 +558,15 @@
   1.123  		jnz	@@scan
   1.124  		dec	cx
   1.125  @@eos:
   1.126 -		mov	[di+28],cx		; m->state
   1.127 +		mov	[(image_himem di).state],cx
   1.128  		dec	si
   1.129  		push	[word si]
   1.130  		mov	[byte si],dl		; set temp eos
   1.131 -		xchg	ax,dx			; O_RDONLY
   1.132  		call	open
   1.133  		pop	[word si]		; restore string
   1.134  		jc	@@die
   1.135 -		mov	[di],ax			; m->fd
   1.136 -		mov	[di+30],ax		; m->fd2close
   1.137 +		mov	[(image_himem di).fd],ax
   1.138 +		mov	[(image_himem di).fd2close],ax
   1.139  		mov	dx,2			; SEEK_END
   1.140  		xchg	ax,bx
   1.141  		ifndef	NO386
   1.142 @@ -566,9 +577,9 @@
   1.143  		endif
   1.144  		call	lseek
   1.145  @@die:
   1.146 -		mov	bx,[di+20]		; m->errmsg
   1.147 +		mov	bx,[(image_himem di).errmsg]
   1.148  		jc	die
   1.149 -		mov	bx,[di]			; m->fd
   1.150 +		mov	bx,[(image_himem di).fd]
   1.151  		ifndef	NO386
   1.152  		push	eax
   1.153  		xor	ecx,ecx
   1.154 @@ -576,7 +587,7 @@
   1.155  		call	lseek			; rewind
   1.156  		pop	eax
   1.157  @@end:
   1.158 -		mov	[di+22],eax		; m->chunk_size
   1.159 +		mov	[(image_himem di).chunk_size],eax
   1.160  		else
   1.161  		push	ax
   1.162  		push	dx
   1.163 @@ -587,8 +598,8 @@
   1.164  		pop	dx
   1.165  		pop	ax
   1.166  @@end:
   1.167 -		mov	[di+22],ax		; m->chunk_size
   1.168 -		mov	[di+24],dx
   1.169 +		mov	[word (image_himem di).chunk_size],ax
   1.170 +		mov	[word ((image_himem di).chunk_size)+2],dx
   1.171  		endif
   1.172  		pop	di si
   1.173  		ret
   1.174 @@ -598,19 +609,6 @@
   1.175  
   1.176  ;***************************************************************
   1.177  ;void open_image(const char *name, struct image_himem *m);
   1.178 -;struct image_himem {
   1.179 -; 0    int fd;
   1.180 -; 2    u32 fallback;
   1.181 -; 6    u32 size;
   1.182 -;10    u32 remaining;
   1.183 -;14    u32 buf;
   1.184 -;18    u32 *bufv;
   1.185 -;20    char *errmsg;
   1.186 -;22    u32 chunk_size;
   1.187 -;26    void (*next_chunk)(struct image_himem *);
   1.188 -;28    u16 state;
   1.189 -;30    u16 fd2close;
   1.190 -;};
   1.191  ;***************************************************************
   1.192          global  _open_image:near
   1.193          proc    _open_image near
   1.194 @@ -627,25 +625,25 @@
   1.195                  xor	ax,ax			; 1st loop flag + eos
   1.196  		endif
   1.197                  mov	di,[m]
   1.198 -                cmp	[di],ax			; m->fd
   1.199 +		cmp	[(image_himem di).fd],ax
   1.200                  jnz	@@alreadydone
   1.201  		ifndef	NO386
   1.202 -		mov	[di+6],eax		; m->size = 0L
   1.203 +		mov	[(image_himem di).size],eax	; m->size = 0L
   1.204  		else
   1.205 -		mov	[di+6],ax		; m->size = 0L
   1.206 -		mov	[di+8],ax
   1.207 +		mov	[word (image_himem di).size],ax	; m->size = 0L
   1.208 +		mov	[word ((image_himem di).size)+2],ax
   1.209  		endif
   1.210 -		mov	[word di+26],offset _next_chunk
   1.211 +		mov	[(image_himem di).next_chunk],offset _next_chunk
   1.212                  mov	si,[fname]
   1.213 -                mov	[di+28],si		; m->state
   1.214 +                mov	[(image_himem di).state],si
   1.215  @@next:
   1.216  		push	di
   1.217 -                call	[word di+26]		; m->next_chunk()
   1.218 +                call	[(image_himem di).next_chunk]	; m->next_chunk()
   1.219  		pop	di
   1.220  		ifndef	NO386
   1.221  		add	eax,3
   1.222  		and	al,0FCh
   1.223 -		add	[di+6],eax		; m->size += m->chunk_size
   1.224 +		add	[(image_himem di).size],eax	; m->size += m->chunk_size
   1.225  		or	eax,eax
   1.226  		jnz	@@next
   1.227  		else
   1.228 @@ -654,14 +652,14 @@
   1.229  		add	ax,3
   1.230  		adc	dx,0
   1.231  		and	al,0FCh
   1.232 -		add	[di+6],ax		; m->size += m->chunk_size
   1.233 -		adc	[di+8],dx
   1.234 +		add	[word (image_himem di).size],ax	; m->size += m->chunk_size
   1.235 +		adc	[word ((image_himem di).size)+2],dx
   1.236  		inc	cx			; jcxnz
   1.237  		loop	@@next
   1.238  		endif
   1.239 -                mov	[di+28],si		; m->state
   1.240 +                mov	[(image_himem di).state],si
   1.241  		push	di
   1.242 -                call	[word di+26]		; m->next_chunk()
   1.243 +                call	[(image_himem di).next_chunk]	; m->next_chunk()
   1.244  		pop	di
   1.245  @@alreadydone:
   1.246                  push	ax
   1.247 @@ -698,17 +696,17 @@
   1.248  		xor	ecx,ecx
   1.249  		mov	cx,[word sz]
   1.250  @@chksz:
   1.251 -		mov	eax,[di+22]	; m->chunk_size
   1.252 +		mov	eax,[(image_himem di).chunk_size]
   1.253  		cmp	ecx,eax
   1.254  		jb	@@szok
   1.255  		xchg	eax,ecx
   1.256  		else
   1.257  		mov	cx,[word sz]
   1.258  @@chksz:
   1.259 -		mov	ax,[di+22]	; lo m->chunk_size
   1.260 +		mov	ax,[word (image_himem di).chunk_size]
   1.261  		cmp	cx,ax
   1.262  		jb	@@szok
   1.263 -		cmp	[word di+24],0	; hi m->chunk_size
   1.264 +		cmp	[word ((image_himem di).chunk_size)+2],0	; hi m->chunk_size
   1.265  		jne	@@szok
   1.266  		xchg	ax,cx
   1.267  		endif
   1.268 @@ -727,13 +725,13 @@
   1.269  		ifndef	NO386
   1.270  		cwde				; ax < 8000h
   1.271  		cwd
   1.272 -		sub	[di+22],eax
   1.273 +		sub	[(image_himem di).chunk_size],eax
   1.274  		else
   1.275  		cwd				; ax < 8000h
   1.276 -		sub	[di+22],ax
   1.277 -		sbb	[di+24],dx
   1.278 +		sub	[word (image_himem di).chunk_size],ax
   1.279 +		sbb	[word ((image_himem di).chunk_size)+2],dx
   1.280  		jnz	@@fill
   1.281 -		cmp	[di+22],dx
   1.282 +		cmp	[word (image_himem di).chunk_size],dx
   1.283  		endif
   1.284  		jnz	@@fill
   1.285  		dec	cx
   1.286 @@ -746,16 +744,16 @@
   1.287  		jmp	@@fill
   1.288  @@filled:
   1.289  		ifndef	NO386
   1.290 -		sub	[di+10],eax		; m->remaining
   1.291 +		sub	[(image_himem di).remaining],eax
   1.292  		else
   1.293 -		sub	[di+10],ax		; m->remaining
   1.294 -		sbb	[di+12],dx
   1.295 +		sub	[word (image_himem di).remaining],ax
   1.296 +		sbb	[word ((image_himem di).remaining)+2],dx
   1.297  		endif
   1.298  		add	[bp-4-2],ax
   1.299  		add	[word data],ax
   1.300  		sub	[word sz],ax
   1.301  		pushf
   1.302 -                and	cx,[di+26]		; m->next_chunk
   1.303 +                and	cx,[(image_himem di).next_chunk]
   1.304  		jz	@@same_chunk
   1.305  		push	di
   1.306                  call	cx			; m->next_chunk()
     2.1 --- a/linld/stuff/src/CRTL.H	Tue Dec 06 15:51:50 2016 +0200
     2.2 +++ b/linld/stuff/src/CRTL.H	Tue Dec 06 18:49:44 2016 +0100
     2.3 @@ -37,7 +37,8 @@
     2.4  extern "C" char* strcatb(const char* a,const char* b);
     2.5  extern "C" int strhead(const char* a,const char* b);
     2.6  extern "C" int fileattr(const char* name);
     2.7 -extern "C" int open(const char* name, int flags);
     2.8 +//extern "C" int open(const char* name, int flags);
     2.9 +extern "C" int open(const char* name);
    2.10  extern "C" int close(int fd);
    2.11  extern "C" void exit(int n);
    2.12  extern "C" void abort();
     3.1 --- a/linld/stuff/src/CRTLX.ASM	Tue Dec 06 15:51:50 2016 +0200
     3.2 +++ b/linld/stuff/src/CRTLX.ASM	Tue Dec 06 18:49:44 2016 +0100
     3.3 @@ -11,6 +11,9 @@
     3.4          assume  cs:DGROUP,ds:DGROUP
     3.5  
     3.6          segment _DATA byte public use16 'DATA'
     3.7 +
     3.8 +tazboot_cmd	db	"tazboot.cmd",0
     3.9 +
    3.10          ends    _DATA
    3.11  
    3.12          segment _BSS byte public use16 'BSS'
    3.13 @@ -96,14 +99,13 @@
    3.14  
    3.15  		pushf
    3.16  ; Check for oldies
    3.17 -		mov	ax, 0F000h
    3.18 -		push	ax		; < 286 : flags[12..15] are forced 1
    3.19 +		mov	bh, 0F0h
    3.20 +		push	bx		; < 286 : flags[12..15] are forced 1
    3.21  		popf			; = 286 : flags[12..15] are forced 0
    3.22  		pushf			; > 286 : only flags[15] is forced 0
    3.23  		pop	dx
    3.24  		popf
    3.25 -		add	dh,ah		; NS=386+, NC=286
    3.26 -		cbw
    3.27 +		add	dh,bh		; NS=386+, NC=286
    3.28  		clc
    3.29                  js     @@bad   		;it is a 86/186/286, not a 386+
    3.30  		pushfd
    3.31 @@ -121,7 +123,6 @@
    3.32  		jnc	@@bad
    3.33  		mov	eax,80000001h	; Extended Processor Info and Feature Bits
    3.34  		db	0Fh,0A2h	; cpuid
    3.35 -		xor	ax,ax
    3.36  		shr	edx,1+29	; LM feature bit ?
    3.37  @@bad:
    3.38  		sbb	ax,ax
    3.39 @@ -323,10 +324,31 @@
    3.40  		pop	ax
    3.41  		pop	dx
    3.42  		pop	di si bp
    3.43 +kver2ulret:
    3.44  		ret
    3.45  
    3.46          endp    _kver2ul
    3.47  
    3.48 +
    3.49 +;***************************************************************
    3.50 +;void try_default_args();
    3.51 +;***************************************************************
    3.52 +        global  _try_default_args:near
    3.53 +        proc    _try_default_args near
    3.54 +
    3.55 +		mov	bx,offset tazboot_cmd
    3.56 +		extrn	open:near
    3.57 +		call	near open
    3.58 +		jc	kver2ulret
    3.59 +		mov	cx,4096
    3.60 +		extrn	_heap_top:word
    3.61 +		mov	di,[_heap_top]
    3.62 +		push	cx
    3.63 +		extrn	read_cmdline:near
    3.64 +		jmp	near read_cmdline	; read_cmdline(ax,di,cx)
    3.65 +		
    3.66 +        endp    _try_default_args
    3.67 +
    3.68          ends    _TEXT
    3.69  
    3.70          end
     4.1 --- a/linld/stuff/src/CRTLX.H	Tue Dec 06 15:51:50 2016 +0200
     4.2 +++ b/linld/stuff/src/CRTLX.H	Tue Dec 06 18:49:44 2016 +0100
     4.3 @@ -10,3 +10,5 @@
     4.4  extern "C" int chdirname(char *path);
     4.5  extern "C" unsigned long kver2ul(char *kernel_version);
     4.6  extern "C" char *ultoa(unsigned long n);
     4.7 +extern "C" void try_default_args();
     4.8 +
     5.1 --- a/linld/stuff/src/HIMEM.CPP	Tue Dec 06 15:51:50 2016 +0200
     5.2 +++ b/linld/stuff/src/HIMEM.CPP	Tue Dec 06 18:49:44 2016 +0100
     5.3 @@ -24,7 +24,7 @@
     5.4  	u8 xfer_buf[PAGE_SIZE];
     5.5          u16 size = read_image(m, xfer_buf, PAGE_SIZE);
     5.6          if(s16(size) <= 0) break;
     5.7 -        memcpy32(*bufv, seg(xfer_buf), ofs(xfer_buf), size);
     5.8 +        memcpy32(*bufv, seg(xfer_buf), ofs(xfer_buf), PAGE_SIZE);
     5.9  	if (bufv != &buf) bufv++;
    5.10          buf += size;
    5.11      } while (*bufv);
     6.1 --- a/linld/stuff/src/ISO9660.CPP	Tue Dec 06 15:51:50 2016 +0200
     6.2 +++ b/linld/stuff/src/ISO9660.CPP	Tue Dec 06 18:49:44 2016 +0100
     6.3 @@ -42,7 +42,8 @@
     6.4  int isoreset(char *name)
     6.5  {
     6.6  	if (name)
     6.7 -		isofd = open(name, O_RDONLY);
     6.8 +		//isofd = open(name, O_RDONLY);
     6.9 +		isofd = open(name);
    6.10  	if (!readsector(16UL * 2048) || strhead(buffer+1,"CD001")) {
    6.11  		//close(isofd);
    6.12  		return -1;
     7.1 --- a/linld/stuff/src/MEMCPY32.ASM	Tue Dec 06 15:51:50 2016 +0200
     7.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Tue Dec 06 18:49:44 2016 +0100
     7.3 @@ -11,114 +11,11 @@
     7.4          assume  cs:DGROUP,ds:DGROUP
     7.5  
     7.6          segment _DATA byte public use16 'DATA'
     7.7 -msg_badcpu      db      "I need 386+ CPU in real mode or under VCPI manager",0
     7.8 -msg_badmapping  db      "VCPI: low 640k: need 1:1 mapping",0
     7.9          ends    _DATA
    7.10  
    7.11          segment _TEXT byte public use16 'CODE'
    7.12  
    7.13  ;***************************************************************
    7.14 -;int _is_vm86();
    7.15 -;****** Return: AX=1 - it is a 386+ in virtual86 mode with vcpi
    7.16 -;******         AX=0 - it is a 386+ in real mode
    7.17 -;******         otherwise abort program
    7.18 -;****** Uses:   Flags
    7.19 -;***************************************************************
    7.20 -        global  _is_vm86:near
    7.21 -        proc    _is_vm86 near
    7.22 -
    7.23 -; Check for oldies
    7.24 -		mov	ah, 0F0h
    7.25 -		pushf
    7.26 -		push	ax		; < 286 : flags[12..15] are forced 1
    7.27 -		popf			; = 286 : flags[12..15] are forced 0
    7.28 -		pushf			; > 286 : only flags[15] is forced 0
    7.29 -		pop	dx
    7.30 -		popf
    7.31 -		add	dh,ah		; NS=386+, NC=286
    7.32 -		ifndef	NO386
    7.33 -                js	@@no_vcpi   	;it is a 86/186/286, not a 386+
    7.34 -		else
    7.35 -		js	@@ret
    7.36 -		endif
    7.37 -; Check for vm
    7.38 -                smsw    ax      ;SMSW cannot be trapped! :-)
    7.39 -                and     ax,1	;MSW_PE
    7.40 -; We're in vm
    7.41 -                jnz     check_vcpi
    7.42 -
    7.43 -; It's a 386 in real mode, chk for paging (crazy but possible)
    7.44 -                mov     edx,cr0
    7.45 -                shl     edx,1   ;CR0_PG to CF
    7.46 -		jc	@@no_vcpi
    7.47 -@@ret:
    7.48 -                ret
    7.49 -
    7.50 -;***************************************************************
    7.51 -;****** Helper: checks for vcpi
    7.52 -;***************************************************************
    7.53 -label   check_vcpi near
    7.54 -                push    ds
    7.55 -; Check whether it is safe to call 67h (we trust only known EMM managers)
    7.56 -                push    0
    7.57 -                pop     ds
    7.58 -                mov     ds,[word 67h*4+2]
    7.59 -                cmp     [dword 10+4],'0XXX'
    7.60 -                jne     @@skip
    7.61 -                mov     eax,'XMME'
    7.62 -                xor     eax,[dword 10]
    7.63 -        ; QMME also works (as told by <J.S.Peatfield@damtp.cambridge.ac.uk>)
    7.64 -                shl     eax,8
    7.65 -@@skip:
    7.66 -                pop     ds
    7.67 -                jne     @@no_vcpi
    7.68 -
    7.69 -; Check emm manager status and version
    7.70 -                mov     ah,40h          ; get status
    7.71 -                int     67h
    7.72 -                test    ah,ah
    7.73 -                jnz     @@no_vcpi
    7.74 -                mov     ah,46h          ; get version
    7.75 -                int     67h
    7.76 -                test    ah,ah
    7.77 -                jnz     @@no_vcpi
    7.78 -                cmp     al,40h          ; version must be >= 4.0
    7.79 -                jb      @@no_vcpi
    7.80 -; Check vcpi manager status
    7.81 -              ;;mov     ax,5A01h        ; ALLOCATE RAW PAGES
    7.82 -              ;;mov     bx,4
    7.83 -              ;;int     67h
    7.84 -              ;;test    ah,ah
    7.85 -              ;;jnz     @@no_vcpi
    7.86 -              ;;push    dx              ;$ save handle
    7.87 -                mov     ax,0DE00h       ; check for vcpi present
    7.88 -                int     67h
    7.89 -                mov     al,1
    7.90 -                test    ah,ah
    7.91 -                jz      @@386vcpi
    7.92 -              ;;pop     dx              ;$ handle
    7.93 -              ;;mov     ax,4500h        ; DEALLOCATE PAGES
    7.94 -              ;;int     67h
    7.95 -@@no_vcpi:
    7.96 -		mov	bx,offset msg_badcpu
    7.97 -                extrn   die:near
    7.98 -godie:
    7.99 -		jmp	near die
   7.100 -@@386vcpi:
   7.101 -		mov	[_vcpi],al
   7.102 -                extrn   prepare_vcpi:near
   7.103 -		call	prepare_vcpi
   7.104 -;    get_vcpi_interface() || die("VCPI: low 640k: need 1:1 mapping");
   7.105 -                ;extrn   _get_vcpi_interface:near
   7.106 -		;call	_get_vcpi_interface
   7.107 -		mov	bx,offset msg_badmapping
   7.108 -		jz	godie
   7.109 -		ret
   7.110 -
   7.111 -        endp    _is_vm86
   7.112 -
   7.113 -
   7.114 -;***************************************************************
   7.115  ;void dos_shutdown()
   7.116  ;***************************************************************
   7.117          global  dos_shutdown:near
   7.118 @@ -386,9 +283,6 @@
   7.119                  ;       base_med  P  S D A  G ??l_hi  base_hi
   7.120                  ;                  Pl E W    D
   7.121  
   7.122 -        global  _vcpi:byte
   7.123 -_vcpi		db	0
   7.124 -
   7.125          endp    _memcpy32
   7.126  
   7.127  		ifdef	NO386
     8.1 --- a/linld/stuff/src/TAZBOOT.CPP	Tue Dec 06 15:51:50 2016 +0200
     8.2 +++ b/linld/stuff/src/TAZBOOT.CPP	Tue Dec 06 18:49:44 2016 +0100
     8.3 @@ -144,11 +144,9 @@
     8.4  	char *iso = NULL;
     8.5  	argv[0] = progname();
     8.6  	bootiso(argv);	// iso ? parsing is /init.exe stuff !
     8.7 -	if (argc >= 2)
     8.8 -		bootiso(argv + 1);
     8.9  
    8.10 -	chdirname(*argv);
    8.11  	if (argc < 2) {
    8.12 +		try_default_args();
    8.13  dousage:
    8.14  		die("Usage: tazboot [[@commands]|[-f][kernel=<bzimage>] \
    8.15  [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\r\n\n\
    8.16 @@ -161,8 +159,12 @@
    8.17    kernel=\\slitaz\\elks\r\n\
    8.18    root=/dev/bda1 ro\r\n");
    8.19  	}
    8.20 +	bootiso(argv + 1);
    8.21 +	chdirname(*argv);
    8.22  	for (int i=0;;) {
    8.23 -		char *s=*++argv;
    8.24 +		char *s;
    8.25 +		argv++;
    8.26 +		s=*argv;
    8.27  		i++;
    8.28  		if (!s) break;
    8.29  		if (strhead(s,"kernel=") == 0) {
     9.1 --- a/linld/stuff/src/VCPI.ASM	Tue Dec 06 15:51:50 2016 +0200
     9.2 +++ b/linld/stuff/src/VCPI.ASM	Tue Dec 06 18:49:44 2016 +0100
     9.3 @@ -203,6 +203,9 @@
     9.4                  mov     [bx+pagedir_ofs-page0_laddr],ax
     9.5                  sub     ax,si   ;ax-=1000
     9.6                  mov     [bx+page0_ofs-page0_laddr],ax
     9.7 +                push    ds
     9.8 +                pop     es
     9.9 +                mov     di,ax          ;ES:DI => page0
    9.10  ; Return
    9.11                  ;pop     es
    9.12                  ;pop     esi
    9.13 @@ -227,9 +230,9 @@
    9.14  
    9.15  ; Get and save VCPI pm interface
    9.16                  mov     si,offset gdt_vcpi      ;DS:DI => 3 GDT entries for VCPI
    9.17 -                mov     di,[si+page0_ofs-gdt_vcpi]          ;ES:DI => page0
    9.18 -                push    ds
    9.19 -                pop     es
    9.20 +                ;mov     di,[si+page0_ofs-gdt_vcpi]          ;ES:DI => page0
    9.21 +                ;push    ds
    9.22 +                ;pop     es
    9.23                  mov     ax,0DE01h               ;get vcpi pm interface
    9.24                  int     67h
    9.25                  mov     [vcpi_pm_entry],ebx
    10.1 --- a/linld/stuff/src/_BEG.ASM	Tue Dec 06 15:51:50 2016 +0200
    10.2 +++ b/linld/stuff/src/_BEG.ASM	Tue Dec 06 18:49:44 2016 +0100
    10.3 @@ -15,23 +15,115 @@
    10.4                  org     100h
    10.5          global  _text_start:byte
    10.6          label   _text_start byte
    10.7 -		extrn	_bss_end
    10.8 +
    10.9  ;***************************************************************
   10.10  ; clear bss
   10.11  ;***************************************************************
   10.12 -		xor	ax,ax
   10.13 -		mov	di,offset _bss_start
   10.14 +		mov	bx,offset _bss_start
   10.15  clearbss:
   10.16 -		mov	[di],al
   10.17 -		inc	di
   10.18 -		cmp	di,sp			; clear bss + heap
   10.19 -		jbe	clearbss
   10.20 -		mov	di,offset _bss_end
   10.21 +		mov	[byte bx],0		; clear bss + heap + sp
   10.22 +		inc	bx
   10.23 +		jne	clearbss
   10.24 +
   10.25 +;***************************************************************
   10.26 +; check CPU
   10.27 +;***************************************************************
   10.28 +
   10.29 +; Check for oldies
   10.30 +		mov	bh, 0F0h
   10.31 +		pushf
   10.32 +		push	bx		; < 286 : flags[12..15] are forced 1
   10.33 +		popf			; = 286 : flags[12..15] are forced 0
   10.34 +		pushf			; > 286 : only flags[15] is forced 0
   10.35 +		pop	dx
   10.36 +		popf
   10.37 +		add	dh,bh		; NS=386+, NC=286
   10.38 +		ifndef	NO386
   10.39 +                js	no_vcpi   	;it is a 86/186/286, not a 386+
   10.40 +		else
   10.41 +		js	endcpu
   10.42 +		endif
   10.43 +; Check for vm
   10.44 +                smsw    ax      ;SMSW cannot be trapped! :-)
   10.45 +                and     ax,1	;MSW_PE
   10.46 +; We're in vm
   10.47 +                jnz     check_vcpi
   10.48 +
   10.49 +; It's a 386 in real mode, chk for paging (crazy but possible)
   10.50 +                mov     edx,cr0
   10.51 +                shl     edx,1   ;CR0_PG to CF
   10.52 +		jc	no_vcpi
   10.53 +		jmp	endcpu
   10.54 +
   10.55 +;***************************************************************
   10.56 +; checks for vcpi
   10.57 +;***************************************************************
   10.58 +label   check_vcpi near
   10.59 +                push    ds
   10.60 +; Check whether it is safe to call 67h (we trust only known EMM managers)
   10.61 +                push    0
   10.62 +                pop     ds
   10.63 +                mov     ds,[word 67h*4+2]
   10.64 +                cmp     [dword 10+4],'0XXX'
   10.65 +                jne     skip
   10.66 +                mov     eax,'XMME'
   10.67 +                xor     eax,[dword 10]
   10.68 +        ; QMME also works (as told by <J.S.Peatfield@damtp.cambridge.ac.uk>)
   10.69 +                shl     eax,8
   10.70 +skip:
   10.71 +                pop     ds
   10.72 +                jne     no_vcpi
   10.73 +
   10.74 +; Check emm manager status and version
   10.75 +                mov     ah,40h          ; get status
   10.76 +                int     67h
   10.77 +                test    ah,ah
   10.78 +                jnz     no_vcpi
   10.79 +                mov     ah,46h          ; get version
   10.80 +                int     67h
   10.81 +                test    ah,ah
   10.82 +                jnz     no_vcpi
   10.83 +                cmp     al,40h          ; version must be >= 4.0
   10.84 +                jb      no_vcpi
   10.85 +; Check vcpi manager status
   10.86 +              ;;mov     ax,5A01h        ; ALLOCATE RAW PAGES
   10.87 +              ;;mov     bx,4
   10.88 +              ;;int     67h
   10.89 +              ;;test    ah,ah
   10.90 +              ;;jnz     no_vcpi
   10.91 +              ;;push    dx              ;$ save handle
   10.92 +                mov     ax,0DE00h       ; check for vcpi present
   10.93 +                int     67h
   10.94 +                mov     al,1
   10.95 +                test    ah,ah
   10.96 +                jz      is386vcpi
   10.97 +              ;;pop     dx              ;$ handle
   10.98 +              ;;mov     ax,4500h        ; DEALLOCATE PAGES
   10.99 +              ;;int     67h
  10.100 +no_vcpi:
  10.101 +		mov	bx,offset msg_badcpu
  10.102 +                extrn   die:near
  10.103 +godie:
  10.104 +		jmp	near die
  10.105 +is386vcpi:
  10.106 +		mov	[_vcpi],al
  10.107 +                extrn   prepare_vcpi:near
  10.108 +		call	prepare_vcpi
  10.109 +;    get_vcpi_interface() || die("VCPI: low 640k: need 1:1 mapping");
  10.110 +                ;extrn   _get_vcpi_interface:near
  10.111 +		;call	_get_vcpi_interface
  10.112 +		mov	bx,offset msg_badmapping
  10.113 +		jz	godie
  10.114 +endcpu:
  10.115 +
  10.116  ;***************************************************************
  10.117  ; build argv & argc
  10.118  ;***************************************************************
  10.119 -;               push	ax			; envp (int 20h do it for us)
  10.120 -                ;mov	[word di],ax		; argv[0] = 0
  10.121 +		extrn	_heap_top:word
  10.122 +		mov	di,[_heap_top]
  10.123 +		;xor	ax,ax
  10.124 +                ;push	ax			; envp (already cleared)
  10.125 +                ;mov	[word di],ax		; argv[0] = 0 (idem)
  10.126                  mov	si,80h
  10.127                  cld
  10.128                  lodsb
  10.129 @@ -39,6 +131,7 @@
  10.130                  jbe	alok
  10.131                  mov	al,7Eh
  10.132  alok:
  10.133 +		cbw
  10.134  		xchg	ax,bx
  10.135                  mov	[bx+si],bh		; set eos
  10.136  argbuild:
  10.137 @@ -73,9 +166,8 @@
  10.138                  jmp	arglp
  10.139  argdone:
  10.140                  ;mov	[word bx+di],0		; argv[argc] = 0
  10.141 -		lea	si,[bx+di+2]
  10.142 -		extrn	_heap_top:word
  10.143 -		mov	[_heap_top],si
  10.144 +		lea	ax,[bx+di+2]
  10.145 +		mov	[_heap_top],ax
  10.146                  push	di			; argv
  10.147                  shr	bx,1
  10.148                  push	bx			; argc
  10.149 @@ -83,11 +175,13 @@
  10.150                  mov	bx,[di+2]		; argv[1]
  10.151                  cmp	[byte bx],'@'
  10.152  		jne	argend
  10.153 -                inc	bx			; al=0 RDONLY
  10.154 +                inc	bx
  10.155  		extrn	open:near
  10.156  		call	near open
  10.157  		jc	argend
  10.158  		pop	bx			; trash argc,  argv >> 1Kb !
  10.159 +	global	read_cmdline:near
  10.160 +read_cmdline:
  10.161  		push	di
  10.162  		push	ax
  10.163  		extrn	_read:near
  10.164 @@ -103,10 +197,6 @@
  10.165  	endif
  10.166  
  10.167  ;***************************************************************
  10.168 -                extrn   _is_vm86:near
  10.169 -                call    _is_vm86		; load_image needs that
  10.170 -
  10.171 -;***************************************************************
  10.172                  extrn   _main:near
  10.173                  call    _main
  10.174  
  10.175 @@ -120,6 +210,11 @@
  10.176          segment _DATA byte public use16 'DATA'
  10.177          global  _data_start:byte
  10.178          label   _data_start byte
  10.179 +msg_badcpu      db      "I need 386+ CPU in real mode or under VCPI manager"
  10.180 +        global  _vcpi:byte
  10.181 +_vcpi		db	0
  10.182 +msg_badmapping  db      "VCPI: low 640k: need 1:1 mapping",0
  10.183 +
  10.184          ends    _DATA
  10.185  
  10.186          segment _BSS byte public use16 'BSS'