# HG changeset patch # User Pascal Bellard # Date 1558992193 -7200 # Node ID 0e811092e7bb388f55364fb20338daa126978d09 # Parent c3f6eea1a598d300be0deeb336968050bec83b8d linld: more ram for zImage (again) diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/CRTL.ASM Mon May 27 23:23:13 2019 +0200 @@ -187,7 +187,6 @@ global openargs:near ; openargs(bx) openargs: cmp [byte bx],'@' - stc jne fail inc bx @@ -212,20 +211,7 @@ mov ax,3d00h ; read-only+compatibility ;mov cl,0 ; attribute mask mov dx,bx -dos: - int 21h -chkc: - jnc doret -fail: - sbb ax,ax ; ax=-1 CF - cwd -doret: - ifndef NO386 - push dx ; see next_chunk:lseek - push ax - pop eax - endif - ret + jmp dos endp @open$qpxzc @@ -288,7 +274,22 @@ mov ah,3Fh endif jcxz fail - jmp dos +dos: + int 21h +chkc: + jnc doret +fail: + stc +failifc: + sbb ax,ax ; ax=-1 CF + cwd +doret: + ifndef NO386 + push dx ; see next_chunk:lseek + push ax + pop eax + endif + ret endp @read$qipvi @@ -333,7 +334,8 @@ curdirofs dd ? ;18 unsigned long curdirofs; dirofs dd ? ;22 unsigned long dirofs; curpos dw ? ;26 unsigned curpos; -buffer db 2560 dup(?) ;28 char buffer[2048+512]; +filename2open dw ? ;28 char *filename2open; +buffer db 2560 dup(?) ;30 char buffer[2048+512]; ends ; } isostate; ;*************************************************************** ;_fastcall long isolseek(bx:const unsigned long *offset); @@ -369,6 +371,35 @@ endp @isoreadsector$qpxul + +;*************************************************************** +;_fastcall int isoreset(bx:const char *name); +;*************************************************************** + global @isoreset$qpzc:near + proc @isoreset$qpzc near + + or bx,bx + jz fail + call near ptr @open$qpxzc + mov [_isostate.fd],ax + extrn @isoroot$qv:near + jmp @isoroot$qv + + endp @isoreset$qpzc + + +;*************************************************************** +;_fastcall int isoopen(bx:const char *name); +;*************************************************************** + global @isoopen$qpxzc:near + proc @isoopen$qpxzc near + + extrn @_isoopen$qv:near + mov [_isostate.filename2open],bx + jmp @_isoopen$qv + + endp @isoopen$qpxzc + endif @@ -456,13 +487,13 @@ mov cl,[bx] ; cl = *b++ inc bx or cl,cl ; clear C - jz fail ; return 0 + jz failifc ; return 0 xchg ax,bx xor cl,[bx] ; cl -= *a++ inc bx and cl,0dfh ; case insensitive - jz @@loop - ret ; return b (is not 0) + jne fail ; return -1 + jmp @@loop endp @strhead$qpxzct1 diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/ISO9660.CPP Mon May 27 23:23:13 2019 +0200 @@ -13,15 +13,11 @@ #define cpydirofs(to,from) ((to) = (from)) #endif -int isoreset(char *name) +int isoroot(void) { static const unsigned long root = 16UL * 2048; struct isostate *x=&isostate; - if (name) { - //x->fd = open(name, O_RDONLY); - x->fd = open(name); - } - if (isoreadsector(&root) < 0 || strhead(x->buffer+1,"CD001")) { + if (isoreadsector(&root) == -1 || strhead(x->buffer+1,"CD001") == -1) { //close(x->fd); return -1; } @@ -111,15 +107,15 @@ //#define IS_DIR(x)( (char)((x) >> 9) == (char)040) //#define IS_DIR(x)( (*((char*) &x + 1) & (char)0776) == (char)0100) #define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0) -int isoopen(const char *filename) +int _isoopen(void) { char *name, *s, c; char _64bits = cpuhaslm(); struct isostate *x=&isostate; do { - for (s = (char *) filename; *s == '/' ; s++) { - isoreset(NULL); + for (s = (char *) x->filename2open; *s == '/' ; s++) { + isoroot(); } next: name = s; @@ -129,7 +125,7 @@ for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) { const char *n = name, *i = x->filename; if (_64bits) { - if (strhead(i, n)) continue; + if (strhead(i, n) == -1) continue; n = "64"; i += s - name; // strlen(name); } diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/ISO9660.H --- a/linld/stuff/src/ISO9660.H Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/ISO9660.H Mon May 27 23:23:13 2019 +0200 @@ -16,6 +16,7 @@ dirsizetype curdirsize, dirsize; unsigned long curdirofs, dirofs; unsigned curpos; + char *filename2open; #define SECTORSZ 2048 #define SECTORBITS 11 char buffer[SECTORSZ+512]; // RR overflow @@ -27,8 +28,8 @@ #define isofilename isostate.filename extern _fastcall long isolseek(const unsigned long *offset); extern _fastcall int isoreadsector(const unsigned long *offset); -extern int isoreset(char *name); -extern int isoopen(const char *name); +extern _fastcall int isoreset(char *name); +extern _fastcall int isoopen(const char *name); extern int isoreaddir(void); #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) #endif diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/JUMP.ASM Mon May 27 23:23:13 2019 +0200 @@ -180,7 +180,10 @@ xor di,di ; A000 -9000 -0800(>movedend) rep movsb - mov ax,[word _imgs+2+2] ; get pm->fallback high word + mov si,offset _imgs+2 + lodsw + xchg ax,bx ; get pm->fallback low word + lodsw ; get pm->fallback high word push es call near @@isbzimage ; pop cs ; ds=es=ss @@ -193,22 +196,17 @@ @@bufhigh: push dx ; size hi push cx ; size lo=up to 512k - push ax ; src ofs ho = pm.fallback + push ax ; src ofs hi = pm.fallback ;in al,70h ;or al,80h ; disable NMI ;out 70h,al + push bx ; src ofs lo xor di,di - push di ; src ofs lo push di ; src seg=0 - ifdef NO386 - inc di - push di ; dst ofs hi - dec di - else - push 1 ; dst ofs hi - endif + inc cx + push cx ; dst ofs hi push di ; dst ofs lo : 64k extrn memcpy32:near call memcpy32 diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/LINLD.CPP Mon May 27 23:23:13 2019 +0200 @@ -89,15 +89,15 @@ load_initrd(); boot_kernel(); } - if(strhead(s,"image=") == 0) { + if(strhead(s,"image=") != -1) { s+=6; set_kernel_name: kernel_name=s; } - else if(strhead(s,"initrd=") == 0) { + else if(strhead(s,"initrd=") != -1) { initrd_name=s+7; } - else if(strhead(s,"vga=") == 0) { + else if(strhead(s,"vga=") != -1) { *(u16*)&vid_mode = (u16)strtol(s+7); // support normal, extended & ask } else switch (*(u16 *)s|0x2002) { @@ -109,7 +109,7 @@ ((u16 *)&base_himem)[1] = (u16)(strtol(*argv)>>16); goto next; default: - if(strhead(s,"cl=") == 0) { + if(strhead(s,"cl=") != -1) { cmdline=s+=3; if (*s == '@') { static struct image_himem image; @@ -132,11 +132,11 @@ puts(cmdline); } } - else if(strhead(s,"root=") == 0) { + else if(strhead(s,"root=") != -1) { *(u16*)&root_dev = (u16)strtol(s+5); goto addincmdline; } - else if(strhead(s,"mem=") == 0) { + else if(strhead(s,"mem=") != -1) { ((u16 *)&topmem)[1] = (u16)(strtol(s+4)>>16); goto addincmdline; } diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/LOAD.CPP Mon May 27 23:23:13 2019 +0200 @@ -152,7 +152,7 @@ if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) { _csip+=0xFFE00042; } - //else + else #endif kernelparams->setup_sects=4; } @@ -215,8 +215,8 @@ { struct image_himem *m = ± - if((u16)(((m->fallback=(u32(u16(_CS)+0x1001)<<4))+m->size)>>4) >= - topseg() || _pm_high) { + if((u16)(((m->fallback=(u32(u16(_CS)+0x1000)<<4))+m->size)>>16) >= + (u16)(topseg()>>12) || _pm_high) { m->fallback = base_himem; } diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/TAZBOOT.CPP Mon May 27 23:23:13 2019 +0200 @@ -72,29 +72,29 @@ unsigned long magic; struct isostate *x=&isostate; - if (!*iso || isoreset(*iso) < 0) return; + if (isoreset(*iso) == -1) return; skip_alloc++; base_himem = memtop() /2; //if (base_himem >= _64m) base_himem = _64m; if (* ((char *) &base_himem +3) >= 4) base_himem = _64m; - isoopen("boot") >= 0 || - isoopen("live") >= 0 || // debian - isoopen("casper") >= 0; // ubuntu + isoopen("boot") != -1 || + isoopen("live") != -1 || // debian + isoopen("casper") != -1; // ubuntu if (iso[1] && !strcmp(mode = iso[1], "text")) init = ""; do { - if ((isoopen(mode) >= 0 && ++noauto != 0) || // custom - isoopen("bzImage") >= 0 || // SliTaz - isoopen("vmlinuz") >= 0 || // misc - (isoopen("linux") >= 0 && ++isknoppix != 0)) { + if ((isoopen(mode) != -1 && ++noauto != 0) || // custom + isoopen("bzImage") != -1 || // SliTaz + isoopen("vmlinuz") != -1 || // misc + (isoopen("linux") != -1 && ++isknoppix != 0)) { magic = kver2ul(isokernel()); break; } - } while (isoopen("isolinux") >= 0); // Knoppix + } while (isoopen("isolinux") != -1); // Knoppix for (c = 0, x->curdirsize = 0xFFFF; isoreaddir() != -1;) { if (strstr(x->filename, ".gz")) strcpy(fallback, x->filename); - if (strhead(x->filename, "rootfs") + if (strhead(x->filename, "rootfs") == -1 || c > x->filename[6]) continue; strcpy(rootfs, x->filename); c = x->filename[6]; @@ -110,9 +110,9 @@ * (int *) buf_cmdline = 0; iso++; while ((s = *++iso) != NULL) { - if (strhead(s,"initrd=")) + if (strhead(s,"initrd=") == -1) strcatb(buf_cmdline,s); - else if (isoopen(s+7) >= 0) + else if (isoopen(s+7) != -1) addinitrd(); } } @@ -122,10 +122,10 @@ if (rootfs[0]) { initrdfilename = rootfs; - if (rootfs[6] != '.' && isoopen("rootfs.gz") >= 0) + if (rootfs[6] != '.' && isoopen("rootfs.gz") != -1) addinitrd(); // for loram } - if (isoopen(initrdfilename) >= 0) { + if (isoopen(initrdfilename) != -1) { addinitrd(); } if (*init && isolseek(&initrddesc) != 0) { @@ -202,30 +202,30 @@ else strcatb(buf_cmdline,*argv); // FIXME mem ? } #else - if (strhead(s,"kernel=") == 0) { + if (strhead(s,"kernel=") != -1) { s++; set_kernel: s += 6; set_kernelz: kernel_name = s; } - else if (strhead(s,"image=") == 0) { + else if (strhead(s,"image=") != -1) { goto set_kernel; } - else if (strhead(s,"initrd=") == 0) { + else if (strhead(s,"initrd=") != -1) { s += 7; initrd_name = s; } - else if (strhead(s,"bootfrom=") == 0) { + else if (strhead(s,"bootfrom=") != -1) { s += 9; set_iso: iso = s; } - else if (strhead(s,"iso=") == 0) { + else if (strhead(s,"iso=") != -1) { s += 4; goto set_iso; } - else if(strhead(s,"vga=") == 0) { + else if(strhead(s,"vga=") != -1) { *(u16*)&vid_mode = (u16)strtol(s+4); // support normal, extended & ask } else switch (*(u16 *)s|0x2002) { @@ -245,10 +245,10 @@ } else { strcatb(buf_cmdline,*argv); - if(strhead(s,"root=") == 0) { + if(strhead(s,"root=") != -1) { *(u16*)&root_dev = (u16)strtol(s+5); } - if(strhead(s,"mem=") == 0) { + if(strhead(s,"mem=") != -1) { s += 4; set_topmem: ((u16 *)&topmem)[1] = (u16)(strtol(s)>>16); @@ -256,9 +256,9 @@ }} } #endif - if (iso && isoreset(iso) >= 0) { + if (isoreset(iso) != -1) { char *s = (char *) initrd_name; - if (isoopen((char *) kernel_name) >= 0) { + if (isoopen((char *) kernel_name) != -1) { isokernel(); } if (s) { @@ -266,7 +266,7 @@ char *p, c; for (p = s; *s && *s != ','; s++); c = *s; *s = 0; - if (isoopen(p) >= 0) { + if (isoopen(p) != -1) { addinitrd(); } *s = c; diff -r c3f6eea1a598 -r 0e811092e7bb linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Mon May 27 17:32:03 2019 +0100 +++ b/linld/stuff/src/pipehole.awk Mon May 27 23:23:13 2019 +0200 @@ -214,6 +214,10 @@ } if (/^ call near ptr @fileexist\$/ || # return boolean : /^ call near ptr @isoreaddir\$/ || # 0=true, -1=false + /^ call near ptr @isoreset\$/ || + /^ call near ptr @isoopen\$/ || + /^ call near ptr @isoreadsector\$/ || + /^ call near ptr @strhead\$/ || /^ call near ptr @argstr\$/ || /^ call near ptr @argnum\$/) { print; hold=17; next; } s=$0