# HG changeset patch # User Pascal Bellard # Date 1607769689 0 # Node ID 3d19917d3a035318ab5d8c57b748df5e95e15585 # Parent a1fa13454a0cff3b514509253045aa09477da605 linld: skip xmm_alloc diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/!COMPILEX.BAT --- a/linld/stuff/src/!COMPILEX.BAT Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/!COMPILEX.BAT Sat Dec 12 10:41:29 2020 +0000 @@ -1,6 +1,6 @@ path ..\BC31;..;%PATH% call !clean.bat -bcc @bccopt.opt -S -mt -DMOVE_SETUP -DLARGE_IMAGES *.cpp > cpp.log +bcc @bccopt.opt -S -mt -DEXTRA -DMOVE_SETUP -DLARGE_IMAGES *.cpp > cpp.log ren TAZBOOT.ASM TAZBOOT.ASO ren LOAD.ASM LOAD.ASO ren HIMEM.ASM HIMEM.ASO diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/COMMON.H --- a/linld/stuff/src/COMMON.H Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/COMMON.H Sat Dec 12 10:41:29 2020 +0000 @@ -55,7 +55,6 @@ #define pm2initrd(p) (p+1) extern u8 pm_low; -extern u16 skip_alloc; extern u32 base_himem; extern u32 far *initrd_desc; @@ -80,7 +79,10 @@ extern u32 root_dev; extern u32 vid_mode; // External asm helpers +#ifdef WITH_XMM_ALLOC +extern u16 skip_alloc; extern _fastcall void xmm_alloc(struct image_himem *m); +#endif extern u32 topmem; extern "C" u32 memtop(); extern "C" void enable_a20_or_die(); diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/CRTL.ASM Sat Dec 12 10:41:29 2020 +0000 @@ -22,9 +22,6 @@ global overflow:byte overflow db "/" msg_malloc db "Out of memory",0 - ifdef EXTRA -tazboot_cmd db "tazboot.cmd",0 - endif ends _DATA @@ -61,14 +58,18 @@ global @strcatb$qpxzct1:near proc @strcatb$qpxzct1 near + ifdef EXTRA mov cl,7Fh db 0bah ; mov dx,imm opcode global @strcpy$qpxzct1:near @strcpy$qpxzct1: xor cx,cx + endif push si xchg ax,si ; b + ifdef EXTRA jcxz @@nocat + endif dec bx @@catlp: inc bx @@ -88,8 +89,10 @@ inc bx or al,al jne @@cpylp + ifdef EXTRA strfound: xchg ax,dx + endif strend: pop si global @ret:near @@ -190,12 +193,13 @@ cwd ; action = open stc int 21h - pop si bx + pop si dx jnc doret + else + mov dx,bx endif mov ax,3d00h ; read-only+compatibility ;mov cl,0 ; attribute mask - mov dx,bx jmp dos endp @open$qpxzc @@ -234,15 +238,15 @@ ;*************************************************************** -;_fastcall int readrm(bx:struct himem *m, ax:int sz); +;_fastcall int readrm(di:struct himem *m, ax:int sz); ;_fastcall int read(ax:int fd, bx:void* data, dx:int sz); ;_fastcall int write(ax:int fd, bx:const void* data, dx:int sz); ;*************************************************************** global @readrm$qp11image_himemi:near @readrm$qp11image_himemi: xchg ax,dx ; sz - mov ax,[bx] ; fd - mov bx,[bx-2] ; data + mov ax,[di] ; fd + mov bx,[di-2] ; data global @read$qipvi:near proc @read$qipvi near @@ -647,14 +651,14 @@ endif ;*************************************************************** -;_fastcall u32* malloc_bufv_or_die(bx:struct image_himem *m); +;_fastcall u32* malloc_bufv_or_die(si:struct image_himem *m); ;*************************************************************** global @malloc_bufv_or_die$qp11image_himem:near proc @malloc_bufv_or_die$qp11image_himem near p386 push si - mov si,bx + mov bx,si ifdef LARGE_IMAGES movzx eax,[word ((image_himem si).size) + 2] shr ax,4 ; pages index size = size >> 20 @@ -767,6 +771,13 @@ ;*************************************************************** ;_fastcall void memcpy_image(bx:struct image_himem *m); ;*************************************************************** + global memcpy_image_initrd:near +memcpy_image_initrd: + lea bx,[si+32] + db 0A9h ; test ax,imm + global memcpy_image_kernel:near +memcpy_image_kernel: + mov bx,si global @memcpy_image$qp11image_himem:near proc @memcpy_image$qp11image_himem near @@ -826,15 +837,15 @@ endp @memcpy_image$qp11image_himem ;*************************************************************** -;_fastcall void storepage(bx:u32 *dst); +;_fastcall void storepage(di:u32 *dst); ;*************************************************************** global @storepage$qpul:near proc @storepage$qpul near ifndef NO386 - mov edx,[bx] + mov edx,[di] else - les ax,[dword bx] + les ax,[dword di] mov dx,es endif mov cx,offset _xfer_buf @@ -861,20 +872,20 @@ ifdef LARGE_IMAGES p386 ;*************************************************************** -;_fastcall void reset_bufv(bx:u32 *p); +;_fastcall void reset_bufv(di:u32 *p); ;*************************************************************** global @reset_bufv$qpul:near proc @reset_bufv$qpul near - mov [curdata],bx - and [dword (data_himem bx).cacheidx],0 + mov [curdata],di + and [dword (data_himem di).cacheidx],0 ret endp @reset_bufv$qpul ;*************************************************************** -;u32* prev_bufv(); -;u32* prev_bufv(); +;u32* di=prev_bufv(); +;u32* di=prev_bufv(); ;*************************************************************** global _prev_bufv:near global _next_bufv:near @@ -884,32 +895,29 @@ db 73h ; jnc _next_bufv: clc - push si - mov si,0 + mov bx,0 org $-2 curdata dw ? sbb ax,ax cmc - adc ax,[(data_himem si).cacheidx] ; -1/+1 + adc ax,[(data_himem bx).cacheidx] ; -1/+1 xor ecx,ecx test ax,0fc00h jz @@gotpage push ax ; FFFF / 0400 sar ax,8 ; FFFC / 0004 and al,0fch - add [(data_himem si).pageidx],ax - mov bx,[(data_himem si).pageidx] - lea bx,[(data_himem bx+si).page] + add [(data_himem bx).pageidx],ax + mov di,[(data_himem bx).pageidx] + lea di,[(data_himem bx+di).page] mov edx,ds shl edx,4 - lea cx,[(data_himem si).cache] + lea cx,[(data_himem bx).cache] add edx,ecx - mov eax,[bx] + mov eax,[di] or eax,eax jnz @@pageok pop ax - xchg ax,bx - pop si ret @@pageok: mov cx,4096 @@ -918,15 +926,15 @@ cbw shr ax,6 ; 03FF / 0000 @@gotpage: - mov [(data_himem si).cacheidx],ax + mov [(data_himem bx).cacheidx],ax shl ax,2 - xchg ax,bx - lea ax,[(data_himem bx+si).cache] - or bx,[(data_himem si).pageidx] ; !pageidx && !cacheidx + xchg ax,di + lea ax,[(data_himem bx+di).cache] + or di,[(data_himem bx).pageidx] ; !pageidx && !cacheidx jnz @@notfirst2 - xchg ax,si ; &first + xchg ax,bx ; &first @@notfirst2: - pop si + xchg ax,di ret endp _prev_bufv @@ -1266,43 +1274,6 @@ endp @strtol$qpxzc - ifdef USE_ARGSTR -;*************************************************************** -;_fastcall void set_cmdline(bx:const char *filename); -;*************************************************************** - global @set_cmdline$qpxzc:near - proc @set_cmdline$qpxzc near - call openargs - jc strtol_ret - mov ch,15 ; cx<4096 - mov di,[_heap_top] - extrn read_cmdline:near - jmp near read_cmdline ; read_cmdline(ax,di,cx) - - endp @set_cmdline$qpxzc - endif - - - ifdef NO386 -;*************************************************************** -;u16 topseg(); -;*************************************************************** - global _topseg:near - proc _topseg near - - int 12h - jnc @@max640k - mov ax,640 ; 9000 -@@max640k: - dec ax - and al,0C0h - mov cl,6 - shl ax,cl - ret - - endp _topseg - endif - ifdef EXTRA p8086 ;*************************************************************** @@ -1361,26 +1332,6 @@ endif -;*************************************************************** -;void try_default_args(); -;*************************************************************** - ifdef EXTRA - - global _try_default_args:near - proc _try_default_args near - - mov bx,offset tazboot_cmd - call open - jc kver2ulret - mov cx,4096 - mov di,[_heap_top] - extrn read_cmdline:near - jmp near read_cmdline ; read_cmdline(ax,di,cx) - - endp _try_default_args - - endif - ends _TEXT end diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/HIMEM.CPP --- a/linld/stuff/src/HIMEM.CPP Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/HIMEM.CPP Sat Dec 12 10:41:29 2020 +0000 @@ -6,20 +6,28 @@ #include "crtl.h" #include "common.h" +#ifdef WITH_XMM_ALLOC u16 skip_alloc; +#endif static u32 buf; void load_image(struct image_himem *m) { m->remaining = m->size; m->buf = m->fallback; // set no_exit btw: die() won't return to DOS u32* bufv= &buf; +#ifdef WITH_XMM_ALLOC if(((u16 *)&m->fallback)[1] >= (skip_alloc|0x10)) { // >= _1m ? +#else + if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ? +#endif if(vcpi) { bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv } +#ifdef WITH_XMM_ALLOC else { xmm_alloc(m); // update m->buf } +#endif } buf = m->buf; do { diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/ISOCRTL.ASM --- a/linld/stuff/src/ISOCRTL.ASM Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/ISOCRTL.ASM Sat Dec 12 10:41:29 2020 +0000 @@ -95,9 +95,12 @@ ;*************************************************************** iso_read_hack: push dx + xor dx,dx + ifndef NO386 + push dx + endif push cx xor cx,cx - xor dx,dx mov al,01h call doseek ; bx = _isostate.fileofs ifdef NO386 @@ -107,26 +110,18 @@ sbb ax,dx pop ax ja @@axok - je @@rem - xor ax,ax -@@rem: - cmp cx,ax - jb @@cxok -@@axok: + cmp ax,cx else push dx push ax - pop edx - mov eax,[bx+4] ; _isostate.filesize - sub eax,edx - pop cx - ja @@rem - xor cx,cx -@@rem: - movzx ecx,cx + pop ecx + mov eax,[_isostate.filesize] + sub eax,ecx + pop ecx cmp eax,ecx + endif ja @@cxok - endif +@@axok: xchg ax,cx @@cxok: pop dx ; buffer diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/LINLD.CPP Sat Dec 12 10:41:29 2020 +0000 @@ -24,7 +24,9 @@ die("Syntax:" NL "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline]" NL "vga mode: ask,extended,normal or dec/oct/hex number" NL +#ifdef WITH_XMM_ALLOC "-f force" NL +#endif "-64 for cpu64 only" NL "Defaults:" NL "\timage=bzImage" NL @@ -36,7 +38,11 @@ "Use cl=@filename to get it from a file" #if 1 NL NL "Examples:" NL - "\tLINLD -f -b 64m " + "\tLINLD " +#ifdef WITH_XMM_ALLOC + "-f " +#endif + "-b 64m " "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz " "\"cl=root=/dev/null video=-32\"" NL NL "\tLINLD image=memtest" @@ -55,32 +61,34 @@ // Parse command line #ifdef USE_ARGSTR if (!argv[1]) syntax(); + const char **clp = &cmdline; for (;;) { - const char **clp = &cmdline; argv++; - if (!*argv) goto boot; + if (!*argv) break; if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64 if (cpuhaslm() == 0) exit(); + continue; } +#ifdef WITH_XMM_ALLOC if ((*(u16 *)*argv|0x2002) == 0x662F) { // -F /f skip_alloc--; + continue; } - else if (argstr(*argv,"cl|image|initrd",clp) != -1); - else if (fileexist(*argv) != -1) +#endif + if (argstr(*argv,"cl|image|initrd",clp) != -1 && **argv == 'c') continue; + if (fileexist(*argv) != -1) { kernel_name=*argv; - else if (argnum(*argv,"root|vga|mem|-b",&root_dev) != -1); - else { - *clp = (const char *) buf_cmdline + 1; - do strcatb((const char *) buf_cmdline,*argv++); while (*argv); - boot: - puts(*clp); - set_cmdline(*clp); - load_kernel(); - puts(version_string); - load_initrd(); - boot_kernel(); - } + continue; + } + argnum(*argv,"root|vga|mem|-b",&root_dev); + *clp = (const char *) buf_cmdline + 1; + strcatb((const char *) buf_cmdline,*argv); } + puts(*clp); + set_cmdline(*clp); + load_kernel(); + load_initrd(); + boot_kernel(); #else if (!argv[1]) syntax(); while (1) { @@ -104,9 +112,11 @@ case 0x362F: // -64 /64 if (cpuhaslm() == 0) exit(); goto next; +#ifdef WITH_XMM_ALLOC case 0x662F: // -F /f skip_alloc--; goto next; +#endif case 0x622F: // -B /b argv++; ((u16 *)&base_himem)[1] = (u16)(strtol(*argv)>>16); diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/LOAD.CPP Sat Dec 12 10:41:29 2020 +0000 @@ -178,7 +178,11 @@ hook_int15_88(); // break _ES } if (kernelparams->kernel_version) - strcpy(version_string,(char *) first1k+kernelparams->kernel_version+0x200); +#ifndef EXTRA + puts((char *) first1k+kernelparams->kernel_version+0x200); +#else + strcatb(version_string,(char *) first1k+kernelparams->kernel_version+0x200); +#endif kernelparams->type_of_loader = 0xff; // kernel do not know us (yet :-) if(kernelparams->version >= 0x201) { // * offset limit of the setup heap @@ -224,14 +228,14 @@ open_image(m, initrd_name); if ((m->fallback=(memtop()-m->size)&(~PAGE_MASK))-m[-1].fallback < m[-1].size) { + puts(m->errmsg); close(m->fd); - puts(m->errmsg); return; } load_image(m); - if (*version_string) { + /* if (pm_low == 0) */ { initrd_desc[0] = m->fallback; initrd_desc[1] = m->size; } diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/TAZBOOT.CPP Sat Dec 12 10:41:29 2020 +0000 @@ -73,7 +73,9 @@ struct isostate *x=&isostate; if (isoreset(*iso) == -1) return; +#ifdef WITH_XMM_ALLOC skip_alloc--; +#endif base_himem = memtop() /2; //if (base_himem >= _64m) base_himem = _64m; if (* ((char *) &base_himem +3) >= 4) ((short *)&base_himem)[1] = _64m/_64k; @@ -149,8 +151,11 @@ if (argc < 2) { try_default_args(); dousage: - die("Usage: tazboot [[@commands]|[-f][-b base_himem][kernel=] \ -[initrd=[,...]] [bootfrom=] ...]\n\n\ + die("Usage: tazboot [[@commands]|" +#ifdef WITH_XMM_ALLOC +"[-f]" +#endif +"[-b base_himem][kernel=] [initrd=[,...]] [bootfrom=] ...]\n\n\ Defaults: tazboot kernel=bzImage auto\n\n\ Examples for tazboot.cmd:\n\n\ bootfrom=\\isos\\slitaz-4.0.iso\n\ @@ -193,10 +198,12 @@ boot_kernel(); } #ifdef USE_ARGSTR +#ifdef WITH_XMM_ALLOC if ((*(u16 *)s|0x2002) == 0x662F) { // -F /f skip_alloc--; goto next; } +#endif if (argstr(s,"kernel/image|initrd|bootfrom/iso",&kernel_name) != -1); else if (argnum(s,"root|vga|mem/-e|-b",&root_dev) != -1); else if(i == 1 && fileexist(s) != -1) { @@ -232,9 +239,11 @@ kernel_name = s; } else switch (*(u16 *)s|0x2002) { +#ifdef WITH_XMM_ALLOC case 0x662F: // -F /f skip_alloc--; goto next; +#endif case 0x652F: // -E /e s=*++argv; goto set_topmem; diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/XMM.ASM --- a/linld/stuff/src/XMM.ASM Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/XMM.ASM Sat Dec 12 10:41:29 2020 +0000 @@ -89,16 +89,17 @@ endp xmm_driver + ifdef WITH_XMM_ALLOC include "himem.inc" ;*************************************************************** -;_fastcall void xmm_alloc(struct image_himem *m) +;_fastcall void xmm_alloc(si:struct image_himem *m) ;*************************************************************** global @xmm_alloc$qp11image_himem:near proc @xmm_alloc$qp11image_himem near ifndef NO386 - mov edx,[(image_himem bx).size] ; m->size + mov edx,[(image_himem si).size] ; m->size ;dec edx shr edx,10 ; to Kb inc edx @@ -106,16 +107,15 @@ else ;mov ax,-1 ;cwd - ;add ax,[word (image_himem bx).size] ; lo m->size - ;adc dx,[word (image_himem bx+2).size] ; hi m->size - les ax,[dword (image_himem bx).size] ; m->size + ;add ax,[word (image_himem si).size] ; lo m->size + ;adc dx,[word (image_himem si+2).size] ; hi m->size + les ax,[dword (image_himem si).size] ; m->size mov cl,16-10 extrn N_LXLSH@ES:near call N_LXLSH@ES inc dx mov ah,9h ;allocate blk of DX kilobytes (<64Mb) endif - push bx call xmm_driver ; jnz @@goerr ;now: dx=handle of the blk @@ -124,7 +124,6 @@ ;now: dx:bx=addr of blk xchg ax,bx @@goerr: - pop bx jnz @@err mov [word (image_himem bx).buf],ax ; lo m->buf mov [word (image_himem bx+2).buf],dx ; hi m->buf @@ -132,6 +131,7 @@ ret endp @xmm_alloc$qp11image_himem + endif ends _TEXT diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/_BEG.ASM Sat Dec 12 10:41:29 2020 +0000 @@ -24,6 +24,9 @@ global _vcpi:byte _vcpi db 0 endif + ifdef EXTRA +tazboot_cmd db "tazboot.cmd",0 + endif ends _DATA @@ -283,7 +286,6 @@ call near openargs jc argend pop bx ; trash argc, argv >> 1Kb ! - global read_cmdline:near pop cx ; sizemax=argv read_cmdline: mov dx,di @@ -308,6 +310,64 @@ ;*************************************************************** + + extrn _head_top:word + ifdef USE_ARGSTR +;*************************************************************** +;_fastcall void set_cmdline(bx:const char *filename); +;*************************************************************** + global @set_cmdline$qpxzc:near + proc @set_cmdline$qpxzc near + extrn openargs:near + call openargs + jc @ret + mov ch,15 ; cx<4096 + mov di,[_heap_top] + jmp read_cmdline ; read_cmdline(ax,di,cx) + + endp @set_cmdline$qpxzc + endif + +;*************************************************************** +;void try_default_args(); +;*************************************************************** + + ifdef EXTRA + global _try_default_args:near + proc _try_default_args near + + mov bx,offset tazboot_cmd + extrn @open$qpxzc:near + call @open$qpxzc + jc @ret + mov ch,15 ; cx<4096 + mov di,[_heap_top] + jmp read_cmdline ; read_cmdline(ax,di,cx) + + endp _try_default_args + endif + + ifdef NO386 +;*************************************************************** +;u16 topseg(); +;*************************************************************** + global _topseg:near + proc _topseg near + + int 12h + jnc @@max640k + mov ax,640 ; 9000 +@@max640k: + dec ax + and al,0C0h + mov cl,6 + shl ax,cl +@ret: + ret + + endp _topseg + endif + ends _TEXT diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/_END.ASM --- a/linld/stuff/src/_END.ASM Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/_END.ASM Sat Dec 12 10:41:29 2020 +0000 @@ -18,10 +18,11 @@ ends _DATA segment _BSS word public use16 'BSS' -STACK_SIZE = 1024 - + ifdef EXTRA global _version_string:byte label _version_string byte + endif +STACK_SIZE = 1024 db STACK_SIZE dup(?) global stktop:byte label stktop byte diff -r a1fa13454a0c -r 3d19917d3a03 linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sun Dec 06 10:04:52 2020 +0000 +++ b/linld/stuff/src/pipehole.awk Sat Dec 12 10:41:29 2020 +0000 @@ -33,11 +33,13 @@ if (/== 0x662F/) islinld=2 if (islinld==2) { if (/cpuhaslm/) islinld=0 - if (/mov/) { print "; " $0; next } + if (/bx,word/) { print "; " $0; next } } if (/image\|initrd/) islinld=3 if (islinld==3) { - if (/bx,word ptr/) { islinld=0; print "; " $0; next } + if (/bx,word ptr/) { print "; " $0; next } + if (/short @1@282/) print " mov bx,word ptr [si]" + if (/@fileexist\$qpxzc/) islinld=0 } if (/fileexist\$qpxzc/) islinld=4 if (islinld==4) { @@ -45,14 +47,15 @@ if (/ax,word ptr/) $0=" xchg ax,bx" if (/\[si\]$/) { islinld=0; print "; " $0; next } } + if (/buf_cmdline\+1/) { + islinld=5 + print " mov bx,offset DGROUP:buf_cmdline+1" + sub(/offset DGROUP:buf_cmdline\+1/,"bx") + } if (islinld==5) { - if (/si/ || /word ptr/) next - if (/buf_cmdline/) { - print " lodsw" - islinld=0 - } + if (/bx,offset DGROUP:buf_cmdline/) $0=" dec bx" + if (/call/) islinld=0 } - if (/do strcatb/) islinld=5 } # file == "linld.cpp" if (file == "himem.cpp") { if (/sp,bp/ || /pop bp/) next @@ -65,7 +68,6 @@ } if (ishimem == 1) { if (/do \{/) ishimem=2 - if (/byte ptr DGROUP:_vcpi,0/) print " mov bx,si" if (/bx,si/ || /push bp/ || /bp,sp/ || /push di/ || /push si/) next if (/sp,2/) next if (/bp\+4/) { @@ -74,7 +76,7 @@ } if (ishimem == 2) { if (/movzx/) print " cwde" - if (/bp-2/) next + if (/bp-2/ || /di,ax/ || /bx,di/) next if (/storepage.bufv/) { print " inc ax" print " push ax" @@ -84,8 +86,35 @@ } if (/endp/) ishimem=0 } + if (/@memcpy_image\$qp11image_himem/) next + if (/far last_ditch/) { + print " extrn memcpy_image_kernel:near" + print " extrn memcpy_image_initrd:near" + ishimem=3 + cpy_initrd=0 + } + if (ishimem == 3) { + if (/bx,di/ || /di,ax/ || /bx,32/) next + if (/mov bx,si/) { + if (cpy_initrd==0) sub(/mov bx,si/, "call memcpy_image_kernel") + else sub(/mov bx,si/, "call memcpy_image_initrd") + cpy_initrd=1-cpy_initrd + } + sub(/lea bx,\[si\+32\]/, "call memcpy_image_initrd") + } + if (/m = pm2initrd/) ishimem=4 + if (ishimem == 4) { + if (/si,32/ || /bx,di/ || /di,ax/) next + sub(/\[si/,"[si+32") + sub(/mov bx,si/, "call memcpy_image_initrd") + } } # file == "himem.cpp" if (file == "load.cpp") { + if (/readrm\(m, 0x200/) isload=15 + if (isload == 15) { # LOAD.LST + if (/bx,di/) next + if (/call/) isload=0 + } if (/load_image\(/) { if (isload == 3) isload=13 else isload=14 @@ -120,7 +149,7 @@ sub(/_imgs\+65534/,"_imgs-2") if (/m, _rm_size/) isload=10 if (isload == 10) { # LOAD.LST - if (/^ je /) next + if (/^ je / || /bx,di/) next if (/ptr @die\$qpxzc/) { $0=" jne @die@" isload=0 @@ -152,7 +181,7 @@ sub(/dx/,"ax") } } - if (/_version_string,0/) { + if (/pm_low == 0/) { print " mov ax,si" print " push di" isload=6 @@ -173,11 +202,11 @@ next } } - if (/version_string = /) isload=5 if (isload == 5) { # LOAD.LST sub(/ax,/,"bx,") - if (/_version_string,/) isload=0 + if (/strcatb/) isload=0 if (/mov bx,ax/) next + sub(/,word ptr \[si\+29\]/,",cx") } if (/_base_himem\+2/ && is386 == 0) isload=4 if (isload == 4) { # LOAD.LST @@ -192,11 +221,12 @@ sub(/cmp /,"mov cx,") } sub(/je/,"jcxz") - if (/@strcpy/) isload=0 + if (/\+0x200/) isload=5 } if (/void load_initrd\(\)/) isload=3 if (isload == 3) { # LOAD.LST if (/short @2@198/) sub(/@2@198/,"load_initrd_ret") + if (/mov ax,word ptr \[si\]/) $0=" lodsw" if( /jmp/) { print "load_initrd_ret:" print " pop si" @@ -204,7 +234,7 @@ next } sub(/\[di/,"[bx") - sub(/\di,/,"bx,") + sub(/di,/,"bx,") } if (/vid_mode = vid_mode/) isload=2 if (isload == 2) { # LOAD.LST @@ -212,7 +242,7 @@ sub(/je/,"jcxz") if (/ax,word/) next sub(/,ax/,",cx") - if (/version_string/ || /starting linux 1\.3\.73/) isload=0 + if (/starting linux 1\.3\.73/) isload=0 } if (/die\(not_kernel/ || /_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1 if (isload == 1) { # LOAD.LST @@ -894,5 +924,6 @@ if (afterjmp) print ";" $0 else print if (/^ jmp / || /^ call near ptr _boot_kernel/ || - /^ call near ptr @die$qpxzc/) afterjmp=1 + /^ call near ptr @die\$qpxzc/ || + /^ call near ptr @exit\$qv/) afterjmp=1 } diff -r a1fa13454a0c -r 3d19917d3a03 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Sun Dec 06 10:04:52 2020 +0000 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Dec 12 10:41:29 2020 +0000 @@ -158,7 +158,7 @@ linld: .asciz "linld.com" cmdline: - .ascii "-f " +// .ascii "-f " // .ascii "image=\boot\" // .ascii "bzImage " .ascii "initrd=" @@ -172,8 +172,8 @@ // .ascii " mode=menu" .ascii " autologin rdinit=/init.exe magic=" magicstr: - .ascii "0 bootfrom=" -// .ascii "65535 bootfrom=" + .ascii "0 iso=" +// .ascii "65535 iso=" filename: exestart: movb $0x30,%ah // get DOS version diff -r a1fa13454a0c -r 3d19917d3a03 syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Sun Dec 06 10:04:52 2020 +0000 +++ b/syslinux/stuff/iso2exe/init Sat Dec 12 10:41:29 2020 +0000 @@ -5,31 +5,6 @@ sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline } -myget() -{ - hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" $2 -} - -mount_proc() -{ - mount -t proc /proc /proc - mount -t sysfs /sys /sys - udevd --daemon 2>/dev/null && udevadm trigger && sleep 5 -} - -umount_proc() -{ - killall udevd 2>/dev/null - umount /sys/fs/fuse/connections 2>/dev/null - umount /sys - umount /proc -} - -checkmagic() -{ - [ -s $1 ] && [ $(getarg magic) = $(myget 18 $1 2) ] -} - media=/media/cdrom mnt=/mnt getiso() @@ -39,16 +14,16 @@ for dev in $(ls -d $dev/$(basename $dev)*); do [ "$dev" ] || continue 2 mount /dev/$(basename $dev) $mnt - if checkmagic $mnt/$ISO; then + if [ -s $mnt/$ISO ] && [ $(getarg magic) = $(hexdump -v -s 18 -n 2 -e "\"\" 1/2 \" %u\n\"" $mnt/$ISO) ]; then echo "Found $ISO on $(basename $dev)" ISO=$mnt/$ISO mount -o loop,ro $ISO $media - return 0 + return fi umount $mnt done done - return 1 + text } uncpio=uncpio64 @@ -78,46 +53,22 @@ echo -en "\"$1\" \"$2\"" } -myis_loram() -{ - [ -s /lib/modules/squashfs.ko* ] -} - -mount_loram() -{ - myis_loram || return - insmod /lib/modules/squashfs.ko* 2>/dev/null - if [ -d $media/fs ]; then - ln -s $media/fs /sqfs - else - mkdir /sqfs - losetup -o 124 /dev/loop6 $(ls -r $media/boot/rootfs?*.* | sed q) - mount -r /dev/loop6 /sqfs - fi - cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /dev - for i in /sqfs/dev/* ; do [ -b $i ] && cp -a $i /dev ; done - ln -s /sqfs/lib/* lib 2>/dev/null - ln -fs /sqfs/usr /sqfs/var / - mkdir /etc && cp /sqfs/etc/dialogrc /etc 2>/dev/null -} - -umount_loram() -{ - myis_loram || return - rm /var /usr - umount -d /sqfs - rmdir /sqfs 2>/dev/null || rm -f /sqfs - rm -rf /etc -} - dosync() { sync - umount_loram + if [ -s /lib/modules/squashfs.ko* ]; then + rm /var /usr + umount -d /sqfs + rmdir /sqfs 2>/dev/null || rm -f /sqfs + rm -rf /etc + fi umount -d $media rm -f /dev/cdrom umount $mnt - umount_proc + killall udevd 2>/dev/null + umount /sys/fs/fuse/connections 2>/dev/null + umount /sys + umount /proc } xhascustomconf=false @@ -130,11 +81,11 @@ getcustomconf /tmp > /dev/null [ -s /tmp/cmdline ] && cmdline="$cmdline $(cat /tmp/cmdline)" && - init="$(sed '/rdinit=/!d;s/.*rdinit=\([^ ]*\).*/\1/' < /tmp/cmdline)" + init="$(sed '/rdinit=/!d;s/.*rdinit=\([^ ]*\).*/\1/' /tmp/cmdline)" [ -s /tmp/initrd ] && $uncpio /tmp/initrd fi dosync - sed -i 's/ || exit//' /init + sed 's/ || exit//' -i /init exec ${init:-/init} $cmdline } @@ -176,9 +127,10 @@ } BIN=bin/mount.posixovl -[ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \ -/usr/s$BIN 2>/dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2>/dev/null -mount_proc +[ -x /usr/s$BIN ] || mv /$BIN.iso2exe /usr/s$BIN 2>/dev/null || mv /$BIN.iso2exe /$BIN 2>/dev/null +mount -t proc /proc /proc +mount -t sysfs /sys /sys +udevd --daemon 2>/dev/null && udevadm trigger && sleep 5 mdev -s 2> /dev/null || for i in /sys/block/*/dev /sys/block/*/*/dev; do [ -s "$i" ] || continue @@ -187,8 +139,22 @@ [ -e $n ] && continue mknod $n b $(sed 's/:/ /' < $i) done 2>/dev/null -ISO="$(getarg bootfrom | sed 's/.://;s|\\|/|g')" +ISO="$(getarg iso | sed 's/.://;s|\\|/|g')" getiso 2>/dev/null || text -mount_loram +if [ -s /lib/modules/squashfs.ko* ]; then + insmod /lib/modules/squashfs.ko* 2>/dev/null + if [ -d $media/fs ]; then + ln -s $media/fs /sqfs + else + mkdir /sqfs + losetup -o 124 /dev/loop6 $(ls -r $media/boot/rootfs?*.* | sed q) + mount -r /dev/loop6 /sqfs + fi + cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /dev + for i in /sqfs/dev/* ; do [ -b $i ] && cp -a $i /dev ; done + ln -s /sqfs/lib/* lib 2>/dev/null + ln -fs /sqfs/usr /sqfs/var / + mkdir /etc && cp /sqfs/etc/dialogrc /etc 2>/dev/null +fi [ -s /usr/bin/taziso ] || live . /usr/bin/taziso diff -r a1fa13454a0c -r 3d19917d3a03 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Sun Dec 06 10:04:52 2020 +0000 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Dec 12 10:41:29 2020 +0000 @@ -293,15 +293,21 @@ --build) shift TMP=/tmp/iso2exe$$ + dd if=/dev/zero bs=1k count=100 of=/tmp/fs$$ + mke2fs /tmp/fs$$ + mkdir $TMP + mount -o loop /tmp/fs$$ $TMP + rm -rf $TMP/* mkdir -p $TMP/dev cp -a /dev/tty /dev/tty0 $TMP/dev sed 's|^[ |\t]*||' init > $TMP/init.exe find $TMP -type f -print0 | xargs -0 chmod +x find $TMP -print0 | xargs -0 touch -t 197001010100.00 - ( cd $TMP; find dev init.exe | cpio -o -H newc ) | compress > rootfs.gz + ( cd $TMP; find dev init.exe | cpio -o -H newc ) | compress rootfs.gz + umount -d $TMP + rm -rf $TMP /tmp/fs$$ p=$((4-($(stat -c %s rootfs.gz)%4))) [ $p = 4 ] || dd if=/dev/zero bs=1 count=$p >> rootfs.gz - rm -rf $TMP chmod 644 ${@/init/rootfs.gz} chown root.root ${@/init/rootfs.gz} touch -t 197001010100.00 ${@/init/rootfs.gz}