wok rev 21628

linld: more ram for zImage (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 27 23:23:13 2019 +0200 (2019-05-27)
parents c3f6eea1a598
children d8351e891a67
files linld/stuff/src/CRTL.ASM linld/stuff/src/ISO9660.CPP linld/stuff/src/ISO9660.H linld/stuff/src/JUMP.ASM linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/TAZBOOT.CPP linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Mon May 27 17:32:03 2019 +0100
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Mon May 27 23:23:13 2019 +0200
     1.3 @@ -187,7 +187,6 @@
     1.4          global  openargs:near			; openargs(bx)
     1.5  openargs:
     1.6  		cmp	[byte bx],'@'
     1.7 -		stc
     1.8  		jne	fail
     1.9  		inc	bx
    1.10  
    1.11 @@ -212,20 +211,7 @@
    1.12                  mov	ax,3d00h		; read-only+compatibility
    1.13  		;mov	cl,0			; attribute mask
    1.14                  mov	dx,bx
    1.15 -dos:
    1.16 -                int	21h
    1.17 -chkc:
    1.18 -                jnc	doret
    1.19 -fail:
    1.20 -                sbb	ax,ax			; ax=-1 CF
    1.21 -		cwd
    1.22 -doret:
    1.23 -		ifndef	NO386
    1.24 -		push	dx			; see next_chunk:lseek
    1.25 -		push	ax
    1.26 -		pop	eax
    1.27 -		endif
    1.28 -                ret
    1.29 +		jmp	dos
    1.30  
    1.31          endp    @open$qpxzc
    1.32  
    1.33 @@ -288,7 +274,22 @@
    1.34                  mov	ah,3Fh
    1.35  		endif
    1.36                  jcxz	fail
    1.37 -		jmp	dos
    1.38 +dos:
    1.39 +                int	21h
    1.40 +chkc:
    1.41 +                jnc	doret
    1.42 +fail:
    1.43 +		stc
    1.44 +failifc:
    1.45 +                sbb	ax,ax			; ax=-1 CF
    1.46 +		cwd
    1.47 +doret:
    1.48 +		ifndef	NO386
    1.49 +		push	dx			; see next_chunk:lseek
    1.50 +		push	ax
    1.51 +		pop	eax
    1.52 +		endif
    1.53 +                ret
    1.54  
    1.55          endp    @read$qipvi
    1.56  
    1.57 @@ -333,7 +334,8 @@
    1.58  curdirofs	dd	?		;18	unsigned long curdirofs;
    1.59  dirofs		dd	?		;22	unsigned long dirofs;
    1.60  curpos		dw	?		;26	unsigned curpos;
    1.61 -buffer		db	2560	dup(?)	;28	char buffer[2048+512];
    1.62 +filename2open	dw	?		;28	char *filename2open;
    1.63 +buffer		db	2560	dup(?)	;30	char buffer[2048+512];
    1.64  ends					; } isostate;
    1.65  ;***************************************************************
    1.66  ;_fastcall long isolseek(bx:const unsigned long *offset);
    1.67 @@ -369,6 +371,35 @@
    1.68  
    1.69          endp    @isoreadsector$qpxul
    1.70  
    1.71 +
    1.72 +;***************************************************************
    1.73 +;_fastcall int isoreset(bx:const char *name);
    1.74 +;***************************************************************
    1.75 +        global  @isoreset$qpzc:near
    1.76 +        proc    @isoreset$qpzc near
    1.77 +
    1.78 +		or	bx,bx
    1.79 +		jz	fail
    1.80 +		call	near ptr @open$qpxzc
    1.81 +		mov	[_isostate.fd],ax
    1.82 +		extrn	@isoroot$qv:near
    1.83 +		jmp	@isoroot$qv
    1.84 +
    1.85 +	endp	@isoreset$qpzc
    1.86 +
    1.87 +
    1.88 +;***************************************************************
    1.89 +;_fastcall int isoopen(bx:const char *name);
    1.90 +;***************************************************************
    1.91 +        global  @isoopen$qpxzc:near
    1.92 +        proc    @isoopen$qpxzc near
    1.93 +
    1.94 +		extrn	@_isoopen$qv:near
    1.95 +		mov	[_isostate.filename2open],bx
    1.96 +		jmp	@_isoopen$qv
    1.97 +
    1.98 +	endp	@isoopen$qpxzc
    1.99 +
   1.100  		endif
   1.101  
   1.102  
   1.103 @@ -456,13 +487,13 @@
   1.104                  mov	cl,[bx]			; cl = *b++
   1.105                  inc	bx
   1.106  		or	cl,cl			; clear C
   1.107 -		jz	fail			; return 0
   1.108 +		jz	failifc			; return 0
   1.109  		xchg	ax,bx
   1.110                  xor	cl,[bx]			; cl -= *a++
   1.111                  inc	bx
   1.112  		and	cl,0dfh			; case insensitive
   1.113 -                jz	@@loop
   1.114 -		ret				; return b (is not 0)
   1.115 +		jne	fail			; return -1
   1.116 +                jmp	@@loop
   1.117  
   1.118  	endp	@strhead$qpxzct1
   1.119  
     2.1 --- a/linld/stuff/src/ISO9660.CPP	Mon May 27 17:32:03 2019 +0100
     2.2 +++ b/linld/stuff/src/ISO9660.CPP	Mon May 27 23:23:13 2019 +0200
     2.3 @@ -13,15 +13,11 @@
     2.4  #define cpydirofs(to,from)	((to) = (from))
     2.5  #endif
     2.6  
     2.7 -int isoreset(char *name)
     2.8 +int isoroot(void)
     2.9  {
    2.10  	static const unsigned long root = 16UL * 2048;
    2.11  	struct isostate *x=&isostate;
    2.12 -	if (name) {
    2.13 -		//x->fd = open(name, O_RDONLY);
    2.14 -		x->fd = open(name);
    2.15 -	}
    2.16 -	if (isoreadsector(&root) < 0 || strhead(x->buffer+1,"CD001")) {
    2.17 +	if (isoreadsector(&root) == -1 || strhead(x->buffer+1,"CD001") == -1) {
    2.18  		//close(x->fd);
    2.19  		return -1;
    2.20  	}
    2.21 @@ -111,15 +107,15 @@
    2.22  //#define IS_DIR(x)( (char)((x) >> 9) == (char)040)
    2.23  //#define IS_DIR(x)( (*((char*) &x + 1) & (char)0776) == (char)0100)
    2.24  #define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0)
    2.25 -int isoopen(const char *filename)
    2.26 +int _isoopen(void)
    2.27  {
    2.28  	char *name, *s, c;
    2.29  	char _64bits = cpuhaslm();
    2.30  	struct isostate *x=&isostate;
    2.31  
    2.32      do {
    2.33 -	for (s = (char *) filename; *s == '/' ; s++) {
    2.34 -		isoreset(NULL);
    2.35 +	for (s = (char *) x->filename2open; *s == '/' ; s++) {
    2.36 +		isoroot();
    2.37  	}
    2.38    next:
    2.39  	name = s;
    2.40 @@ -129,7 +125,7 @@
    2.41  	for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) {
    2.42  		const char *n = name, *i = x->filename;
    2.43  		if (_64bits) {
    2.44 -			if (strhead(i, n)) continue;
    2.45 +			if (strhead(i, n) == -1) continue;
    2.46  			n = "64";
    2.47  			i += s - name; // strlen(name);
    2.48  		}
     3.1 --- a/linld/stuff/src/ISO9660.H	Mon May 27 17:32:03 2019 +0100
     3.2 +++ b/linld/stuff/src/ISO9660.H	Mon May 27 23:23:13 2019 +0200
     3.3 @@ -16,6 +16,7 @@
     3.4  	dirsizetype curdirsize, dirsize;
     3.5  	unsigned long curdirofs, dirofs;
     3.6  	unsigned curpos;
     3.7 +	char *filename2open;
     3.8  #define SECTORSZ 2048
     3.9  #define SECTORBITS 11
    3.10  	char buffer[SECTORSZ+512];	// RR overflow
    3.11 @@ -27,8 +28,8 @@
    3.12  #define	isofilename isostate.filename
    3.13  extern _fastcall long isolseek(const unsigned long *offset);
    3.14  extern _fastcall int isoreadsector(const unsigned long *offset);
    3.15 -extern int isoreset(char *name);
    3.16 -extern int isoopen(const char *name);
    3.17 +extern _fastcall int isoreset(char *name);
    3.18 +extern _fastcall int isoopen(const char *name);
    3.19  extern int isoreaddir(void);
    3.20  #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0)
    3.21  #endif
     4.1 --- a/linld/stuff/src/JUMP.ASM	Mon May 27 17:32:03 2019 +0100
     4.2 +++ b/linld/stuff/src/JUMP.ASM	Mon May 27 23:23:13 2019 +0200
     4.3 @@ -180,7 +180,10 @@
     4.4  		xor	di,di			;  A000 -9000 -0800(>movedend)
     4.5  		rep
     4.6  		  movsb
     4.7 -		mov	ax,[word _imgs+2+2]	; get pm->fallback high word
     4.8 +		mov	si,offset _imgs+2
     4.9 +		lodsw
    4.10 +		xchg	ax,bx			; get pm->fallback low word
    4.11 +		lodsw				; get pm->fallback high word
    4.12  		push	es
    4.13  		call	near @@isbzimage	; pop cs ; ds=es=ss
    4.14  
    4.15 @@ -193,22 +196,17 @@
    4.16  @@bufhigh:
    4.17  		push	dx			; size hi
    4.18  		push	cx			; size lo=up to 512k
    4.19 -		push	ax			; src ofs ho = pm.fallback
    4.20 +		push	ax			; src ofs hi = pm.fallback
    4.21  
    4.22  		;in	al,70h
    4.23  		;or	al,80h			; disable NMI
    4.24  		;out	70h,al
    4.25  
    4.26 +		push	bx			; src ofs lo
    4.27  		xor	di,di
    4.28 -		push	di			; src ofs lo
    4.29  		push	di			; src seg=0
    4.30 -		ifdef	NO386
    4.31 -		inc	di
    4.32 -		push	di			; dst ofs hi
    4.33 -		dec	di
    4.34 -		else
    4.35 -		push	1			; dst ofs hi
    4.36 -		endif
    4.37 +		inc	cx
    4.38 +		push	cx			; dst ofs hi
    4.39  		push	di			; dst ofs lo : 64k
    4.40  		extrn   memcpy32:near
    4.41  		call	memcpy32
     5.1 --- a/linld/stuff/src/LINLD.CPP	Mon May 27 17:32:03 2019 +0100
     5.2 +++ b/linld/stuff/src/LINLD.CPP	Mon May 27 23:23:13 2019 +0200
     5.3 @@ -89,15 +89,15 @@
     5.4  	    load_initrd();
     5.5  	    boot_kernel();
     5.6  	}
     5.7 -        if(strhead(s,"image=") == 0) {
     5.8 +        if(strhead(s,"image=") != -1) {
     5.9  	    s+=6;
    5.10  	set_kernel_name:
    5.11              kernel_name=s;
    5.12          }
    5.13 -        else if(strhead(s,"initrd=") == 0) {
    5.14 +        else if(strhead(s,"initrd=") != -1) {
    5.15              initrd_name=s+7;
    5.16          }
    5.17 -        else if(strhead(s,"vga=") == 0) {
    5.18 +        else if(strhead(s,"vga=") != -1) {
    5.19              *(u16*)&vid_mode = (u16)strtol(s+7);	// support normal, extended & ask
    5.20          }
    5.21          else switch (*(u16 *)s|0x2002) {
    5.22 @@ -109,7 +109,7 @@
    5.23  	    ((u16 *)&base_himem)[1] = (u16)(strtol(*argv)>>16);
    5.24  	    goto next;
    5.25  	default:
    5.26 -	    if(strhead(s,"cl=") == 0) {
    5.27 +	    if(strhead(s,"cl=") != -1) {
    5.28  		cmdline=s+=3;
    5.29  		if (*s == '@') {
    5.30  		    static struct image_himem image;
    5.31 @@ -132,11 +132,11 @@
    5.32  		    puts(cmdline);
    5.33  		}
    5.34  	    }
    5.35 -            else if(strhead(s,"root=") == 0) {
    5.36 +            else if(strhead(s,"root=") != -1) {
    5.37  		*(u16*)&root_dev = (u16)strtol(s+5);
    5.38  		goto addincmdline;
    5.39  	    }
    5.40 -	    else if(strhead(s,"mem=") == 0) {
    5.41 +	    else if(strhead(s,"mem=") != -1) {
    5.42  		((u16 *)&topmem)[1] = (u16)(strtol(s+4)>>16);
    5.43  		goto addincmdline;
    5.44  	    }
     6.1 --- a/linld/stuff/src/LOAD.CPP	Mon May 27 17:32:03 2019 +0100
     6.2 +++ b/linld/stuff/src/LOAD.CPP	Mon May 27 23:23:13 2019 +0200
     6.3 @@ -152,7 +152,7 @@
     6.4          if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) {
     6.5              _csip+=0xFFE00042;
     6.6          }
     6.7 -        //else
     6.8 +        else
     6.9  #endif
    6.10          kernelparams->setup_sects=4;
    6.11      }
    6.12 @@ -215,8 +215,8 @@
    6.13  
    6.14    {
    6.15      struct image_himem *m = &pm;
    6.16 -    if((u16)(((m->fallback=(u32(u16(_CS)+0x1001)<<4))+m->size)>>4) >=
    6.17 -		 topseg() || _pm_high) {
    6.18 +    if((u16)(((m->fallback=(u32(u16(_CS)+0x1000)<<4))+m->size)>>16) >=
    6.19 +		 (u16)(topseg()>>12) || _pm_high) {
    6.20          m->fallback = base_himem;
    6.21      }
    6.22  
     7.1 --- a/linld/stuff/src/TAZBOOT.CPP	Mon May 27 17:32:03 2019 +0100
     7.2 +++ b/linld/stuff/src/TAZBOOT.CPP	Mon May 27 23:23:13 2019 +0200
     7.3 @@ -72,29 +72,29 @@
     7.4  	unsigned long magic;
     7.5  	struct isostate *x=&isostate;
     7.6  	
     7.7 -	if (!*iso || isoreset(*iso) < 0) return;
     7.8 +	if (isoreset(*iso) == -1) return;
     7.9  	skip_alloc++;
    7.10  	base_himem = memtop() /2;
    7.11  	//if (base_himem >= _64m) base_himem = _64m;
    7.12  	if (* ((char *) &base_himem +3) >= 4) base_himem = _64m;
    7.13 -	isoopen("boot") >= 0 ||
    7.14 -	isoopen("live") >= 0 ||	// debian
    7.15 -	isoopen("casper") >= 0;	// ubuntu
    7.16 +	isoopen("boot") != -1 ||
    7.17 +	isoopen("live") != -1 ||	// debian
    7.18 +	isoopen("casper") != -1;	// ubuntu
    7.19  	if (iso[1] && !strcmp(mode = iso[1], "text"))
    7.20  		init = "";
    7.21  	do {
    7.22 -		if ((isoopen(mode) >= 0 && ++noauto != 0) ||	// custom
    7.23 -		    isoopen("bzImage") >= 0		|| 	// SliTaz
    7.24 -		    isoopen("vmlinuz") >= 0		||	// misc
    7.25 -		    (isoopen("linux") >= 0 && ++isknoppix != 0)) {
    7.26 +		if ((isoopen(mode) != -1 && ++noauto != 0) ||	// custom
    7.27 +		    isoopen("bzImage") != -1		|| 	// SliTaz
    7.28 +		    isoopen("vmlinuz") != -1		||	// misc
    7.29 +		    (isoopen("linux") != -1 && ++isknoppix != 0)) {
    7.30  			magic = kver2ul(isokernel());
    7.31  			break;
    7.32  		}
    7.33 -	} while (isoopen("isolinux") >= 0);		// Knoppix
    7.34 +	} while (isoopen("isolinux") != -1);		// Knoppix
    7.35  	for (c = 0, x->curdirsize = 0xFFFF; isoreaddir() != -1;) {
    7.36  		if (strstr(x->filename, ".gz"))
    7.37  			strcpy(fallback, x->filename);
    7.38 -		if (strhead(x->filename, "rootfs") 
    7.39 +		if (strhead(x->filename, "rootfs") == -1
    7.40  			|| c > x->filename[6]) continue;
    7.41  		strcpy(rootfs, x->filename);
    7.42  		c = x->filename[6];
    7.43 @@ -110,9 +110,9 @@
    7.44  		* (int *) buf_cmdline = 0;
    7.45  		iso++;
    7.46  		while ((s = *++iso) != NULL) {
    7.47 -			if (strhead(s,"initrd=")) 
    7.48 +			if (strhead(s,"initrd=") == -1) 
    7.49  				strcatb(buf_cmdline,s);
    7.50 -			else if (isoopen(s+7) >= 0)
    7.51 +			else if (isoopen(s+7) != -1)
    7.52  				addinitrd();
    7.53  		}
    7.54  	}
    7.55 @@ -122,10 +122,10 @@
    7.56  
    7.57  		if (rootfs[0]) {
    7.58  			initrdfilename = rootfs;
    7.59 -			if (rootfs[6] != '.' && isoopen("rootfs.gz") >= 0)
    7.60 +			if (rootfs[6] != '.' && isoopen("rootfs.gz") != -1)
    7.61  				addinitrd();	// for loram
    7.62  		}
    7.63 -		if (isoopen(initrdfilename) >= 0) {
    7.64 +		if (isoopen(initrdfilename) != -1) {
    7.65  			addinitrd();
    7.66  		}
    7.67  		if (*init && isolseek(&initrddesc) != 0) {
    7.68 @@ -202,30 +202,30 @@
    7.69  		else strcatb(buf_cmdline,*argv);	// FIXME mem ?
    7.70  	}
    7.71  #else
    7.72 -		if (strhead(s,"kernel=") == 0) {
    7.73 +		if (strhead(s,"kernel=") != -1) {
    7.74  			s++;
    7.75  	set_kernel:
    7.76  			s += 6;
    7.77  	set_kernelz:
    7.78  			kernel_name = s;
    7.79  		}
    7.80 -		else if (strhead(s,"image=") == 0) {
    7.81 +		else if (strhead(s,"image=") != -1) {
    7.82  			goto set_kernel;
    7.83  		}
    7.84 -		else if (strhead(s,"initrd=") == 0) {
    7.85 +		else if (strhead(s,"initrd=") != -1) {
    7.86  			s += 7;
    7.87  			initrd_name = s;
    7.88  		}
    7.89 -		else if (strhead(s,"bootfrom=") == 0) {
    7.90 +		else if (strhead(s,"bootfrom=") != -1) {
    7.91  			s += 9;
    7.92  	set_iso:
    7.93  			iso = s;
    7.94  		}
    7.95 -		else if (strhead(s,"iso=") == 0) {
    7.96 +		else if (strhead(s,"iso=") != -1) {
    7.97  			s += 4;
    7.98  			goto set_iso;
    7.99  		}
   7.100 -		else if(strhead(s,"vga=") == 0) {
   7.101 +		else if(strhead(s,"vga=") != -1) {
   7.102  			*(u16*)&vid_mode = (u16)strtol(s+4);	// support normal, extended & ask
   7.103  		}
   7.104  	        else switch (*(u16 *)s|0x2002) {
   7.105 @@ -245,10 +245,10 @@
   7.106  		}
   7.107  		else {
   7.108  			strcatb(buf_cmdline,*argv);
   7.109 -			if(strhead(s,"root=") == 0) {
   7.110 +			if(strhead(s,"root=") != -1) {
   7.111  				*(u16*)&root_dev = (u16)strtol(s+5);
   7.112  			}
   7.113 -			if(strhead(s,"mem=") == 0) {
   7.114 +			if(strhead(s,"mem=") != -1) {
   7.115  				s += 4;
   7.116  			set_topmem:
   7.117  				((u16 *)&topmem)[1] = (u16)(strtol(s)>>16);
   7.118 @@ -256,9 +256,9 @@
   7.119  		}}
   7.120  	}
   7.121  #endif
   7.122 -	if (iso && isoreset(iso) >= 0) {
   7.123 +	if (isoreset(iso) != -1) {
   7.124  		char *s = (char *) initrd_name;
   7.125 -		if (isoopen((char *) kernel_name) >= 0) {
   7.126 +		if (isoopen((char *) kernel_name) != -1) {
   7.127  			isokernel();
   7.128  		}
   7.129  		if (s) {
   7.130 @@ -266,7 +266,7 @@
   7.131  				char *p, c;
   7.132  				for (p = s; *s && *s != ','; s++);
   7.133  				c = *s; *s = 0;
   7.134 -				if (isoopen(p) >= 0) {
   7.135 +				if (isoopen(p) != -1) {
   7.136  					addinitrd();
   7.137  				}
   7.138  				*s = c;
     8.1 --- a/linld/stuff/src/pipehole.awk	Mon May 27 17:32:03 2019 +0100
     8.2 +++ b/linld/stuff/src/pipehole.awk	Mon May 27 23:23:13 2019 +0200
     8.3 @@ -214,6 +214,10 @@
     8.4  	}
     8.5  	if (/^	call	near ptr @fileexist\$/ || 	# return boolean :
     8.6  	    /^	call	near ptr @isoreaddir\$/ ||	#  0=true, -1=false
     8.7 +	    /^	call	near ptr @isoreset\$/ ||
     8.8 +	    /^	call	near ptr @isoopen\$/ ||
     8.9 +	    /^	call	near ptr @isoreadsector\$/ ||
    8.10 +	    /^	call	near ptr @strhead\$/ ||
    8.11  	    /^	call	near ptr @argstr\$/ ||
    8.12  	    /^	call	near ptr @argnum\$/) { print; hold=17; next; }
    8.13  	s=$0