wok-current diff linld/stuff/src/CRTL.ASM @ rev 19825

linld/tazboot: can boot memtest & ipxe
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Mar 05 13:22:08 2017 +0100 (2017-03-05)
parents 76087975885f
children 008ac2992c52
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Fri Jan 20 09:55:25 2017 +0100
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Sun Mar 05 13:22:08 2017 +0100
     1.3 @@ -23,6 +23,9 @@
     1.4  msg_crlf	db	13,10,0
     1.5  vcpi_alloc_err	db	"vcpi "
     1.6  msg_malloc      db      "malloc failure",0
     1.7 +	ifdef	EXTRA
     1.8 +tazboot_cmd	db	"tazboot.cmd",0
     1.9 +	endif
    1.10  
    1.11          ends    _DATA
    1.12  
    1.13 @@ -35,6 +38,9 @@
    1.14  	ifdef	LARGE_IMAGES
    1.15  curdata		dw	?
    1.16  	endif
    1.17 +	ifdef	EXTRA
    1.18 +ultoabuf	db	12	dup (?)
    1.19 +	endif
    1.20  
    1.21          ends    _BSS
    1.22  
    1.23 @@ -249,9 +255,9 @@
    1.24  
    1.25          endp    _read
    1.26  
    1.27 -
    1.28 +		ifdef	EXTRA 
    1.29  ;***************************************************************
    1.30 -;long lseekset(int fd, long sz);
    1.31 +;long lseekset(int fd, unsigned long sz);
    1.32  ;***************************************************************
    1.33          global  _lseekset:near
    1.34          proc    _lseekset near
    1.35 @@ -262,6 +268,21 @@
    1.36                  pop	cx			; sz hi
    1.37                  push	cx
    1.38                  push	dx
    1.39 +
    1.40 +		else
    1.41 +;***************************************************************
    1.42 +;long seekset(int fd, unsigned sz);
    1.43 +;***************************************************************
    1.44 +        global  _seekset:near
    1.45 +        proc    _seekset near
    1.46 +
    1.47 +		xor	cx,cx
    1.48 +		pop	ax			;caller return address
    1.49 +                pop	bx			; fd
    1.50 +                pop	dx			; sz
    1.51 +                push	dx
    1.52 +		endif
    1.53 +
    1.54                  push	bx
    1.55                  push	ax
    1.56          global  lseekset:near
    1.57 @@ -278,7 +299,43 @@
    1.58  		xor	cx,cx
    1.59  		jmp	dos
    1.60  
    1.61 +		ifdef	EXTRA 
    1.62          endp    _lseekset
    1.63 +		else
    1.64 +        endp    _seekset
    1.65 +		endif
    1.66 +
    1.67 +		ifdef	EXTRA
    1.68 +struc		isostate	; struct isostate {
    1.69 +fd		dw	?	; 0	int fd;
    1.70 +fileofs		dd	?	; 2	unsigned long fileofs;
    1.71 +filesize	dd	?	; 6	unsigned long filesize;
    1.72 +filemod		dw	?	;10	unsigned short filemod;
    1.73 +filename	dw	?	;12	char *filename;
    1.74 +dirofs		dd	?	;14	unsigned long dirofs;
    1.75 +dirsize		dd	?	;16	unsigned long dirsize;
    1.76 +curdirofs	dd	?	;20	unsigned long curdirofs;
    1.77 +curdirsize	dd	?	;24	unsigned long curdirsize;
    1.78 +curpos		dd	?	;28	unsigned long curpos;
    1.79 +ends				; } isostate;
    1.80 +;***************************************************************
    1.81 +;unsigned long isolseek(const unsigned long *offset);
    1.82 +;***************************************************************
    1.83 +        global  _isolseek:near
    1.84 +        proc    _isolseek near
    1.85 +
    1.86 +		pop	ax
    1.87 +		pop	bx
    1.88 +		push	bx
    1.89 +		push	ax
    1.90 +		mov	dx,[bx]
    1.91 +		mov	cx,[bx+2]
    1.92 +		extrn	_isostate:isostate
    1.93 +		mov	bx,[_isostate.fd]
    1.94 +		jmp	lseekset		; (bx=fd, sz=cx:dx)
    1.95 +		
    1.96 +        endp    _isolseek
    1.97 +		endif
    1.98  
    1.99  
   1.100  ;***************************************************************
   1.101 @@ -1177,8 +1234,294 @@
   1.102          endp    _topseg
   1.103  		endif
   1.104  
   1.105 +		ifdef	EXTRA
   1.106 +                p8086
   1.107 +
   1.108 +;***************************************************************
   1.109 +;int strcmp(const char* a,const char* b);
   1.110 +;***************************************************************
   1.111 +        global  _strcmp:near
   1.112 +        proc    _strcmp near
   1.113 +
   1.114 +		pop	cx			;caller return address
   1.115 +                pop	bx			; a
   1.116 +                pop	ax			; b
   1.117 +                push	ax
   1.118 +                push	bx
   1.119 +                push	cx
   1.120 +                push	si
   1.121 +		xchg	ax,si
   1.122 +                sub	bx,si
   1.123 +@@lp:
   1.124 +                mov	al,[si]
   1.125 +                sub	al,[bx+si]
   1.126 +		jnz	@@out
   1.127 +                lodsb
   1.128 +		cmp	al,0
   1.129 +                jne	@@lp
   1.130 +@@out:
   1.131 +		cbw
   1.132 +                pop	si
   1.133 +                ret
   1.134 +
   1.135 +        endp    _strcmp
   1.136 +
   1.137 +
   1.138 +;***************************************************************
   1.139 +;char strstr(const char* a,const char* b);
   1.140 +;***************************************************************
   1.141 +        global  _strstr:near
   1.142 +        proc    _strstr near
   1.143 +
   1.144 +		pop	ax			;caller return address
   1.145 +                pop	cx			; a
   1.146 +                pop	dx			; b
   1.147 +                push	dx
   1.148 +                push	cx
   1.149 +                push	ax
   1.150 +                push	si
   1.151 +@@loop:
   1.152 +		xor	ax,ax
   1.153 +		mov	si,cx
   1.154 +		cmp	[si],al			; *a
   1.155 +		jz	@@end			; return ax = NULL
   1.156 +		mov	bx,dx
   1.157 +		sub	bx,si
   1.158 +@@match:
   1.159 +		or	ah,[bx+si]		; *b
   1.160 +		jz	@@found
   1.161 +		lodsb
   1.162 +		sub	ah,al
   1.163 +		jz	@@match
   1.164 +		inc	cx
   1.165 +		jmp	@@loop
   1.166 +@@found:
   1.167 +		xchg	ax,cx
   1.168 +@@end:
   1.169 +                pop	si
   1.170 +		ret
   1.171 +
   1.172 +        endp    _strstr
   1.173 +
   1.174 +
   1.175 +;***************************************************************
   1.176 +;char *progname(void)
   1.177 +;***************************************************************
   1.178 +        global  _progname:near
   1.179 +        proc    _progname near
   1.180 +
   1.181 +		push	si di es
   1.182 +		mov	ah,30h
   1.183 +		int	21h
   1.184 +		cmp	al,3
   1.185 +		jb	@@skip
   1.186 +		xor	di,di
   1.187 +		mov	es,[cs:2Ch]
   1.188 +		mov	cx,-1
   1.189 +		mov	ax,di
   1.190 +@@loop1:
   1.191 +		repne
   1.192 +		  scasb
   1.193 +		scasb
   1.194 +		jne	@@loop1
   1.195 +		lea	si,[di+2]
   1.196 +		mov	bx, si
   1.197 +		call	strlen
   1.198 +		xchg	ax,cx
   1.199 +		inc	cx
   1.200 +		call	malloc_or_die
   1.201 +		xchg	ax,di
   1.202 +		push	ds
   1.203 +		push	ds
   1.204 +		push	es
   1.205 +		pop	ds
   1.206 +		pop	es
   1.207 +		push	di
   1.208 +@@loop2:
   1.209 +		lodsb
   1.210 +		stosb
   1.211 +		or	al,al
   1.212 +		jnz	@@loop2
   1.213 +		pop	ax
   1.214 +		pop	ds
   1.215 +@@skip:
   1.216 +		pop	es di si
   1.217 +		ret
   1.218 +
   1.219 +        endp    _progname
   1.220 +
   1.221 +
   1.222 +;***************************************************************
   1.223 +;int chdir(char *path);
   1.224 +;***************************************************************
   1.225 +        global  _chdir:near
   1.226 +        proc    _chdir near
   1.227 +
   1.228 +		pop	ax
   1.229 +		pop	dx
   1.230 +		push	dx
   1.231 +		push	ax
   1.232 +chdir:
   1.233 +		stc
   1.234 +		mov	ax,713Bh
   1.235 +		int	21h
   1.236 +		jnc	@@end
   1.237 +		mov	ah,3Bh
   1.238 +		int	21h
   1.239 +@@end:
   1.240 +		sbb	ax,ax
   1.241 +		ret
   1.242 +
   1.243 +        endp    _chdir
   1.244 +
   1.245 +
   1.246 +;***************************************************************
   1.247 +;int chdirname(char *path)
   1.248 +;***************************************************************
   1.249 +        global  _chdirname:near
   1.250 +        proc    _chdirname near
   1.251 +
   1.252 +		pop	ax
   1.253 +		pop	bx
   1.254 +		push	bx
   1.255 +		push	ax
   1.256 +
   1.257 +		cmp	[byte bx+1],3Ah
   1.258 +		jne	@@nodisk
   1.259 +		mov	dl,[bx]
   1.260 +		or	dl,20h
   1.261 +		sub	dl,61h
   1.262 +		mov	ah,0Eh
   1.263 +		push	bx
   1.264 +		int	21h
   1.265 +		pop	bx
   1.266 +		inc	bx
   1.267 +		inc	bx
   1.268 +@@nodisk:
   1.269 +		mov	dx,bx
   1.270 +		xor	cx,cx
   1.271 +@@next:
   1.272 +		mov	al,[bx]
   1.273 +		cmp	al,5Ch
   1.274 +		jne	@@tsteos
   1.275 +		mov	cx,bx
   1.276 +@@tsteos:
   1.277 +		inc	bx
   1.278 +		or	al,al
   1.279 +		jnz	@@next
   1.280 +		cbw
   1.281 +		jcxz	@@end
   1.282 +		mov	bx,cx
   1.283 +		push	[word bx]
   1.284 +		mov	[bx],al
   1.285 +		push	bx
   1.286 +		call	chdir
   1.287 +		pop	bx
   1.288 +		pop	[word bx]
   1.289 +@@end:
   1.290 +		ret
   1.291 +
   1.292 +        endp    _chdirname
   1.293 +
   1.294 +
   1.295 +;***************************************************************
   1.296 +;char *ultoa(unsigned long n);
   1.297 +;***************************************************************
   1.298 +        global  _ultoa:near
   1.299 +        proc    _ultoa near
   1.300 +
   1.301 +		pop	ax
   1.302 +		pop	cx
   1.303 +		pop	dx
   1.304 +		push	dx
   1.305 +		push	cx
   1.306 +		push	ax		; DX:CX = n
   1.307 +		push	si
   1.308 +		mov	si,10
   1.309 +		mov	bx,offset ultoabuf+11
   1.310 +@@loop:
   1.311 +		dec	bx
   1.312 +		xchg	ax,dx
   1.313 +		xor	dx,dx
   1.314 +		div	si		; DX:AX = 0000:hi(n)
   1.315 +		xchg	ax,cx		; CX = hi(n)/10
   1.316 +		div	si		; DX:AX = hi(n)%10:lo(n)
   1.317 +		xchg	ax,cx		; CX = lo(n/10)
   1.318 +		xchg	ax,dx		; DX = hi(n)/10 = hi(n/10)
   1.319 +		add	al,'0'
   1.320 +		mov	[bx],al
   1.321 +		mov	ax,cx
   1.322 +		or	ax,dx
   1.323 +		jnz	@@loop
   1.324 +		xchg	ax,bx
   1.325 +		pop	si
   1.326 +		ret
   1.327 +
   1.328 +        endp    _ultoa
   1.329 +
   1.330 +
   1.331 +;***************************************************************
   1.332 +;unsigned long kver2ul(char *kernel_version);
   1.333 +;***************************************************************
   1.334 +        global  _kver2ul:near
   1.335 +        proc    _kver2ul near
   1.336 +
   1.337 +		pop	bx
   1.338 +		pop	ax
   1.339 +		push	ax
   1.340 +		push	bx
   1.341 +		push	bp si di
   1.342 +		xchg	ax,si
   1.343 +		xor	di,di
   1.344 +		push	di
   1.345 +		push	di
   1.346 +		mov	bp,sp
   1.347 +		inc	di
   1.348 +		inc	di
   1.349 +		mov	cl,4
   1.350 +@@number:
   1.351 +		xor	ax,ax
   1.352 +@@digit:
   1.353 +		shl	al,cl
   1.354 +		shl	ax,cl
   1.355 +		lodsb
   1.356 +		sub	al,30h
   1.357 +		cmp	al,9
   1.358 +		jbe	@@digit
   1.359 +		mov	[bp+di],ah
   1.360 +		dec	di
   1.361 +		jns	@@number
   1.362 +		pop	ax
   1.363 +		pop	dx
   1.364 +		pop	di si bp
   1.365 +kver2ulret:
   1.366 +		ret
   1.367 +
   1.368 +        endp    _kver2ul
   1.369 +
   1.370 +
   1.371 +;***************************************************************
   1.372 +;void try_default_args();
   1.373 +;***************************************************************
   1.374 +        global  _try_default_args:near
   1.375 +        proc    _try_default_args near
   1.376 +
   1.377 +		mov	bx,offset tazboot_cmd
   1.378 +		call	open
   1.379 +		jc	kver2ulret
   1.380 +		mov	cx,4096
   1.381 +		mov	di,[_heap_top]
   1.382 +		push	cx
   1.383 +		extrn	read_cmdline:near
   1.384 +		jmp	near read_cmdline	; read_cmdline(ax,di,cx)
   1.385 +		
   1.386 +        endp    _try_default_args
   1.387 +
   1.388 +			endif
   1.389 +
   1.390          ends    _TEXT
   1.391  
   1.392          end
   1.393  
   1.394  ;###### END OF FILE ############################################
   1.395 +