# HG changeset patch # User Pascal Bellard # Date 1590337012 0 # Node ID d70f7cc6e3ac7bc01aa06ab49722a2d316ecd538 # Parent fabe7b490b0b874e0f48aa821c79efc96079a77b linld: add isoboot diff -r fabe7b490b0b -r d70f7cc6e3ac linld/receipt --- a/linld/receipt Sun May 24 07:34:28 2020 +0000 +++ b/linld/receipt Sun May 24 16:16:52 2020 +0000 @@ -46,6 +46,7 @@ grep '^Warning[ :]' */LNK.LOG */CPP.LOG grep '*Warning*' */*.LST cp LINLD$SUFFIX/LINLD.COM linld.com + cp LINLD$SUFFIX/ISOBOOT.COM isoboot.com cp TAZBOOT/TAZBOOT.COM tazboot.com objdump -D -b binary -mi386 -Maddr16,data16 --adjust-vma=0x100 \ linld.com > linld.lst diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/!COMPILE.BAT --- a/linld/stuff/src/!COMPILE.BAT Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/!COMPILE.BAT Sun May 24 16:16:52 2020 +0000 @@ -3,7 +3,7 @@ tasm /h > helptasm.log bcc > helpbcc.log tlink > helptlink.log -bcc @bccopt.opt -S -mt -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log +bcc @bccopt.opt -S -mt -DISOHOOK -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log ren LINLD.ASM LINLD.ASO ren LOAD.ASM LOAD.ASO ren HIMEM.ASM HIMEM.ASO diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/CRTL.ASM Sun May 24 16:16:52 2020 +0000 @@ -1009,7 +1009,7 @@ sub dx,si mov bx,[di] call @read$cxdxbx - jbe image_done + jb image_done xor cx,cx cwd ; ax < 8000h ifndef NO386 diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/CRTL.H --- a/linld/stuff/src/CRTL.H Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/CRTL.H Sun May 24 16:16:52 2020 +0000 @@ -26,10 +26,14 @@ extern _fastcall int argstr(const char *s, const char keywords[], const char **var); extern _fastcall int argnum(char *s, const char keywords[], unsigned long *var); extern _fastcall void set_cmdline(const char *filename); +#ifndef ISOHOOK #define strhead(a,b) (strstr(a,b) != (int) (a)) #else extern _fastcall int strhead(const char* a,const char* head); #endif +#else +extern _fastcall int strhead(const char* a,const char* head); +#endif extern _fastcall int fileexist(const char* name); //extern "C" int open(const char* name, int flags); extern _fastcall int open(const char* name); diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/ISO9660.CPP Sun May 24 16:16:52 2020 +0000 @@ -114,7 +114,12 @@ #define _64bits (x->_64bits) char *s; +#ifdef ISOHOOK + extern int _cpuhaslm(); + _64bits = _cpuhaslm(); +#else _64bits = cpuhaslm(); +#endif do { for (s = (char *) x->filename2open; *s == '/' ; s++) { isoroot(); diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/ISOCRTL.ASM --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linld/stuff/src/ISOCRTL.ASM Sun May 24 16:16:52 2020 +0000 @@ -0,0 +1,281 @@ +;*************************************************************** +;****** This file is distributed under GPL +;*************************************************************** + ideal + %PAGESIZE 1000 + %crefref + %noincl + %nomacs + p8086 + + group DGROUP _TEXT,_DATA,_BSS + assume cs:DGROUP,ds:DGROUP + + segment _TEXT byte public use16 'CODE' + ends _TEXT + + segment _DATA byte public use16 'DATA' + ends _DATA + + segment _BSS byte public use16 'BSS' + + include "isostate.inc" + + public _isostate +_isostate isostate + org $-7 + + ends _BSS + + segment _TEXT byte public use16 'CODE' + + global fold:near +fold: + org 0F000h + global unfold:near +unfold: + push dx + call readfd + push ds + pop es + mov di,128h ; TABLE + mov ax,offset iso_open_hack + stosw + mov ax,offset iso_read_hack + stosw + mov ax,offset iso_lseek_hack + stosw + mov ax,offset iso_close_hack + stosw + mov ax,offset iso_cleanup_hack + stosw + global @_cpuhaslm$qv:near +@_cpuhaslm$qv: + mov ax,[132h] + and al,20h + ret + +iso_open_hack: + pop ax + extrn @_isoopen$qv:near + cmp [byte bx],'!' + je @readmenu$qv + xchg ax,bx + global iso_open:near +iso_open: + mov [_isostate.filename2open],ax + call @_isoopen$qv + inc ax + jnz open_ok + dec ax + stc +open_ok: + ret + + global @readmenu$qv:near +@readmenu$qv: + mov dx,18 + xor cx,cx + call lseekset + mov dx,offset _isostate.filemod + mov cx,10 + call readfd ; // read x->filemod + x->fileofs & x->filesize + mov bx,offset _isostate.fileofs + ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); + and [word bx+6],0 + mov ax,7FF0h + sub ax,[bx+4] + and [word bx+2],0 + mov [bx],ax + ; //magic = x->filemod; + ret + + + macro curseek + push cx + xor cx,cx + xor dx,dx + mov ax,4201h + call dosfd ; lseek(,0L,SEEK_CUR) + call @doseek2 + ifndef NO386 + push dx + push ax + pop eax + endif + pop cx + endm + +iso_read_hack: + ifdef NO386 + push dx + curseek + mov bx,[word _isostate.filesize] + sub bx,ax + mov ax,[(word _isostate.filesize)+2] + sbb ax,dx + ja @@cxok + je @@rem + xor cx,cx +@@rem: + cmp bx,cx + ja @@cxok + mov cx,bx +@@cxok: + pop dx + else + p386 + push edx + curseek + mov edx,[_isostate.filesize] + sub edx,eax + jnb @@rem + xor cx,cx +@@rem: + movzx eax,cx + cmp edx,eax + ja @@cxok + mov cx,dx +@@cxok: + pop edx + endif + or cx,cx + pop bx + jmp readfd + +iso_lseek_hack: + xchg ax,bx + pop bx + ifdef SEEK_CUR + cmp al,1 ; current + jne @@nocurrent + call dosfd ; lseek(,0L,SEEK_CUR) + jmp @doseek2 +@nocurrent: + endif + add dx,[word _isostate.fileofs] + adc cx,[(word _isostate.fileofs)+2] + cmp al,0 ; start + je @@doseek + add dx,[word _isostate.filesize] + adc cx,[(word _isostate.filesize)+2] +@@doseek: + call lseekset ; lseek(,0L,SEEK_SET) +@doseek2: + sub ax,[word _isostate.fileofs] + sbb dx,[(word _isostate.fileofs)+2] + ret + +iso_close_hack: + pop bx + ret + +iso_cleanup_hack: + mov ah,3Eh ; close file + jmp dosfd + + + +;*************************************************************** +;_fastcall void isolseek(bx:const unsigned long *offset); +;*************************************************************** + global @isolseek$qpxul:near + proc @isolseek$qpxul near + +isolseek: + mov dx,[bx] + mov cx,[bx+2] +lseekset: + mov ax,4200h ; bx=fd cx:dx=offset al=whence +dosfd: + mov bx,[_isostate.fd] +dos: + int 21h +failifc: + jnc @@dosok +fail: + sbb ax,ax + cwd +@@dosok: + ret + + endp @isolseek$qpxul + +;*************************************************************** +;_fastcall int isoreadsector(bx:const unsigned long *offset); +;*************************************************************** + global @isoreadsector$qpxul:near + proc @isoreadsector$qpxul near + + call isolseek + jc fail + mov cx,2560 + mov dx,offset _isostate.buffer + global readfd:near +readfd: + mov ah,3Fh + jmp dosfd + + endp @isoreadsector$qpxul + +;*************************************************************** +;_fastcall int strhead(bx:const char* a, ax:const char* b); +;*************************************************************** + global @strhead$qpxzct1:near + proc @strhead$qpxzct1 near + +@@loop: + xchg ax,bx + mov cl,[bx] ; cl = *b++ + inc bx + or cl,cl ; clear C + jz failifc ; return 0 + xchg ax,bx + xor cl,[bx] ; cl -= *a++ + inc bx + and cl,0dfh ; case insensitive + jne fail ; return -1 + jmp @@loop + + endp @strhead$qpxzct1 + +;*************************************************************** +;_fastcall int strcmp(bx:const char* a, ax:const char* b); +;*************************************************************** + global @strcmp$qpxzct1:near + proc @strcmp$qpxzct1 near + + push si + xchg ax,si + dec bx +@@lp: + inc bx + lodsb + sub al,[bx] + jnz @@out + or al,[bx] + jnz @@lp +@@out: + cbw + pop si + ret + + endp @strcmp$qpxzct1 + + ifdef NO386 + global N_LXLSH@ES:near +N_LXLSH@ES: + mov dx,es + global N_LXLSH@:near +N_LXLSH@: + mov ch,0 +@@lp: + shl ax,1 + rcl dx,1 + loop @@lp + ret + endif + + ends _TEXT + + end diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/JUMP.ASM Sun May 24 16:16:52 2020 +0000 @@ -85,6 +85,10 @@ global _boot_kernel:near proc _boot_kernel near + ifdef ISOHOOK + extrn iso_cleanup_hack:word + call [iso_cleanup_hack] ; or ret + endif ifdef NO386 p8086 else diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/LINK2.CMD --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linld/stuff/src/LINK2.CMD Sun May 24 16:16:52 2020 +0000 @@ -0,0 +1,1 @@ +_isobeg.obj isocrtl.obj iso9660.obj _end.obj, isoboot diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/_ISOBEG.ASM --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linld/stuff/src/_ISOBEG.ASM Sun May 24 16:16:52 2020 +0000 @@ -0,0 +1,231 @@ +;*************************************************************** +;****** This file is distributed under GPL +;*************************************************************** + ideal + %PAGESIZE 1000 + %crefref + %noincl + %nomacs + p8086 + + group DGROUP _TEXT,_DATA,_BSS + assume cs:DGROUP,ds:DGROUP + + segment _TEXT byte public use16 'CODE' + ends _TEXT + + segment _DATA byte public use16 'DATA' + global _data_start:byte + label _data_start byte + ends _DATA + + segment _BSS byte public use16 'BSS' + + global _bss_start:byte + label _bss_start byte +utoabuf db 6 dup(?) + + include "isostate.inc" + + extrn _isostate:isostate + + ends _BSS + + segment _TEXT byte public use16 'CODE' + + org 100h + global _text_start:byte + label _text_start byte + + extrn fold + extrn unfold + mov si,offset fold + mov di,offset unfold + mov ch,4 + cld + rep + movsw + +;*************************************************************** +; clear bss +;*************************************************************** + + mov si,offset _bss_start +clearbss: + mov [byte si],cl ; clear bss + heap + inc si + jne clearbss + +;*************************************************************** +; build arg +;*************************************************************** + + mov bx,endbzimage-bzimage + mov si,80h + mov di,si + lodsb + add [di],bl + cbw + mov bp,-1 +skipspace: + inc bp + cmp [byte bp+si]," " + je skipspace + xchg ax,cx + add si,cx + dec si + lea di,[bx+si] + mov [di+1],bh + sub cx,bp + std + rep + movsb + push di + mov si,offset endbzimage-1 + mov cl,bl + rep + movsb + pop si + inc si + cld + + ifdef LONG_FILENAME + mov ax,716Ch + xor bx,bx ; R/O + ;xor cx,cx ; attributes + cwd ; action = open + stc + int 21h + jnc opened + endif + mov ax,3d00h ; read-only+compatibility + ;mov cl,0 ; attribute mask + mov dx,si + int 21h + jnc opened + +_abort: + mov dx,offset stopmsg + mov ah,9 + int 21h + int 20h +opened: + mov [_isostate.fd],ax + mov ax,offset bootdir + extrn iso_open:near + call iso_open +jc_abort: + jc _abort + +;*************************************************************** + +; patch magic + extrn @readmenu$qv:near + call @readmenu$qv + mov ax,[_isostate.filemod] + mov bx,10 + xor cx,cx +@@loop1: + xor dx,dx + div bx ; DX:AX = n%10:n/10 + push dx ; DL = n%10 + inc cx + or ax,ax + jnz @@loop1 + push ds + pop es + lea di,[bp+magic-bzimage+81h] +@@loop2: + pop ax + add al,'0' + stosb + loop @@loop2 + +; patch initrd + cwd + or [_isostate.curdirsize],-1 + jmp patchtest +found: + inc dh +patchtest: + push dx + extrn @isoreaddir$qv:near + call @isoreaddir$qv + pop dx + push ds + pop es + inc ax + jne patchlp + cmp dx,100h + je initrddone + lea di,[bp+rootfs-bzimage+87h] + or dh,dh + je modify + add di,4 + mov si,offset rootfs + mov cx,3 + rep + movsw +modify: + xchg ax,dx + stosb + mov si,offset dotgz + mov cl,5 + rep + movsb +initrddone: + +;*************************************************************** + + mov ax,offset linld + call iso_open + jc jc_abort + mov cx,[word _isostate.filesize] + mov dx,100h + jmp near unfold +patchlp: + mov si,[_isostate.filename] + mov di,offset rootfs + mov cx,9 + rep + cmpsb + jcxz found + cmp cl,3 + ja patchtest + dec si + cmp dl,[si] + ja patchtest + mov dl,[si] + jmp patchtest + +stopmsg: + db "This program cannot be run in DOS mode$" +bootdir: + db "/boot",0 +linld: + db "linld.com",0 +bzimage: + db "-f " + ;db "image=boot\bzImage " + db "initrd=" +rootfs: + db "rootfs" +dotgz: + db ".gz,! " + ; ".gz,rootfs4.gz,! " + ;db "rw " + db "autologin rdinit=/init.exe mode=menu magic=" +magic: + db "0 bootfrom=" + ; "65535 bootfrom=" +endbzimage: + + +;*************************************************************** + + ends _TEXT + + + end _text_start + +;###### END OF FILE ############################################ diff -r fabe7b490b0b -r d70f7cc6e3ac linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sun May 24 07:34:28 2020 +0000 +++ b/linld/stuff/src/pipehole.awk Sun May 24 16:16:52 2020 +0000 @@ -45,12 +45,14 @@ if (/ax,word ptr/) $0=" xchg ax,bx" if (/\[si\]$/) { islinld=0; print "; " $0; next } } - if (/do strcatb/) islinld=5 if (islinld==5) { if (/si/) next - $0=" lodsw" - islinld=0 + if (/buf_cmdline/) { + print " lodsw" + islinld=0 + } } + if (/do strcatb/) islinld=5 } # file == "linld.cpp" if (file == "himem.cpp") { if (/void load_image/) ishimem=1