wok-current rev 23806
linld: add isoboot
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun May 24 16:16:52 2020 +0000 (2020-05-24) |
parents | fabe7b490b0b |
children | b6e9ec8873bb |
files | linld/receipt linld/stuff/src/!COMPILE.BAT linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/ISO9660.CPP linld/stuff/src/ISOCRTL.ASM linld/stuff/src/JUMP.ASM linld/stuff/src/LINK2.CMD linld/stuff/src/_ISOBEG.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/receipt Sun May 24 07:34:28 2020 +0000 1.2 +++ b/linld/receipt Sun May 24 16:16:52 2020 +0000 1.3 @@ -46,6 +46,7 @@ 1.4 grep '^Warning[ :]' */LNK.LOG */CPP.LOG 1.5 grep '*Warning*' */*.LST 1.6 cp LINLD$SUFFIX/LINLD.COM linld.com 1.7 + cp LINLD$SUFFIX/ISOBOOT.COM isoboot.com 1.8 cp TAZBOOT/TAZBOOT.COM tazboot.com 1.9 objdump -D -b binary -mi386 -Maddr16,data16 --adjust-vma=0x100 \ 1.10 linld.com > linld.lst
2.1 --- a/linld/stuff/src/!COMPILE.BAT Sun May 24 07:34:28 2020 +0000 2.2 +++ b/linld/stuff/src/!COMPILE.BAT Sun May 24 16:16:52 2020 +0000 2.3 @@ -3,7 +3,7 @@ 2.4 tasm /h > helptasm.log 2.5 bcc > helpbcc.log 2.6 tlink > helptlink.log 2.7 -bcc @bccopt.opt -S -mt -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log 2.8 +bcc @bccopt.opt -S -mt -DISOHOOK -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log 2.9 ren LINLD.ASM LINLD.ASO 2.10 ren LOAD.ASM LOAD.ASO 2.11 ren HIMEM.ASM HIMEM.ASO
3.1 --- a/linld/stuff/src/CRTL.ASM Sun May 24 07:34:28 2020 +0000 3.2 +++ b/linld/stuff/src/CRTL.ASM Sun May 24 16:16:52 2020 +0000 3.3 @@ -1009,7 +1009,7 @@ 3.4 sub dx,si 3.5 mov bx,[di] 3.6 call @read$cxdxbx 3.7 - jbe image_done 3.8 + jb image_done 3.9 xor cx,cx 3.10 cwd ; ax < 8000h 3.11 ifndef NO386
4.1 --- a/linld/stuff/src/CRTL.H Sun May 24 07:34:28 2020 +0000 4.2 +++ b/linld/stuff/src/CRTL.H Sun May 24 16:16:52 2020 +0000 4.3 @@ -26,10 +26,14 @@ 4.4 extern _fastcall int argstr(const char *s, const char keywords[], const char **var); 4.5 extern _fastcall int argnum(char *s, const char keywords[], unsigned long *var); 4.6 extern _fastcall void set_cmdline(const char *filename); 4.7 +#ifndef ISOHOOK 4.8 #define strhead(a,b) (strstr(a,b) != (int) (a)) 4.9 #else 4.10 extern _fastcall int strhead(const char* a,const char* head); 4.11 #endif 4.12 +#else 4.13 +extern _fastcall int strhead(const char* a,const char* head); 4.14 +#endif 4.15 extern _fastcall int fileexist(const char* name); 4.16 //extern "C" int open(const char* name, int flags); 4.17 extern _fastcall int open(const char* name);
5.1 --- a/linld/stuff/src/ISO9660.CPP Sun May 24 07:34:28 2020 +0000 5.2 +++ b/linld/stuff/src/ISO9660.CPP Sun May 24 16:16:52 2020 +0000 5.3 @@ -114,7 +114,12 @@ 5.4 #define _64bits (x->_64bits) 5.5 char *s; 5.6 5.7 +#ifdef ISOHOOK 5.8 + extern int _cpuhaslm(); 5.9 + _64bits = _cpuhaslm(); 5.10 +#else 5.11 _64bits = cpuhaslm(); 5.12 +#endif 5.13 do { 5.14 for (s = (char *) x->filename2open; *s == '/' ; s++) { 5.15 isoroot();
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/linld/stuff/src/ISOCRTL.ASM Sun May 24 16:16:52 2020 +0000 6.3 @@ -0,0 +1,281 @@ 6.4 +;*************************************************************** 6.5 +;****** This file is distributed under GPL 6.6 +;*************************************************************** 6.7 + ideal 6.8 + %PAGESIZE 1000 6.9 + %crefref 6.10 + %noincl 6.11 + %nomacs 6.12 + p8086 6.13 + 6.14 + group DGROUP _TEXT,_DATA,_BSS 6.15 + assume cs:DGROUP,ds:DGROUP 6.16 + 6.17 + segment _TEXT byte public use16 'CODE' 6.18 + ends _TEXT 6.19 + 6.20 + segment _DATA byte public use16 'DATA' 6.21 + ends _DATA 6.22 + 6.23 + segment _BSS byte public use16 'BSS' 6.24 + 6.25 + include "isostate.inc" 6.26 + 6.27 + public _isostate 6.28 +_isostate isostate <?> 6.29 + org $-7 6.30 + 6.31 + ends _BSS 6.32 + 6.33 + segment _TEXT byte public use16 'CODE' 6.34 + 6.35 + global fold:near 6.36 +fold: 6.37 + org 0F000h 6.38 + global unfold:near 6.39 +unfold: 6.40 + push dx 6.41 + call readfd 6.42 + push ds 6.43 + pop es 6.44 + mov di,128h ; TABLE 6.45 + mov ax,offset iso_open_hack 6.46 + stosw 6.47 + mov ax,offset iso_read_hack 6.48 + stosw 6.49 + mov ax,offset iso_lseek_hack 6.50 + stosw 6.51 + mov ax,offset iso_close_hack 6.52 + stosw 6.53 + mov ax,offset iso_cleanup_hack 6.54 + stosw 6.55 + global @_cpuhaslm$qv:near 6.56 +@_cpuhaslm$qv: 6.57 + mov ax,[132h] 6.58 + and al,20h 6.59 + ret 6.60 + 6.61 +iso_open_hack: 6.62 + pop ax 6.63 + extrn @_isoopen$qv:near 6.64 + cmp [byte bx],'!' 6.65 + je @readmenu$qv 6.66 + xchg ax,bx 6.67 + global iso_open:near 6.68 +iso_open: 6.69 + mov [_isostate.filename2open],ax 6.70 + call @_isoopen$qv 6.71 + inc ax 6.72 + jnz open_ok 6.73 + dec ax 6.74 + stc 6.75 +open_ok: 6.76 + ret 6.77 + 6.78 + global @readmenu$qv:near 6.79 +@readmenu$qv: 6.80 + mov dx,18 6.81 + xor cx,cx 6.82 + call lseekset 6.83 + mov dx,offset _isostate.filemod 6.84 + mov cx,10 6.85 + call readfd ; // read x->filemod + x->fileofs & x->filesize 6.86 + mov bx,offset _isostate.fileofs 6.87 + ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 6.88 + and [word bx+6],0 6.89 + mov ax,7FF0h 6.90 + sub ax,[bx+4] 6.91 + and [word bx+2],0 6.92 + mov [bx],ax 6.93 + ; //magic = x->filemod; 6.94 + ret 6.95 + 6.96 + 6.97 + macro curseek 6.98 + push cx 6.99 + xor cx,cx 6.100 + xor dx,dx 6.101 + mov ax,4201h 6.102 + call dosfd ; lseek(,0L,SEEK_CUR) 6.103 + call @doseek2 6.104 + ifndef NO386 6.105 + push dx 6.106 + push ax 6.107 + pop eax 6.108 + endif 6.109 + pop cx 6.110 + endm 6.111 + 6.112 +iso_read_hack: 6.113 + ifdef NO386 6.114 + push dx 6.115 + curseek 6.116 + mov bx,[word _isostate.filesize] 6.117 + sub bx,ax 6.118 + mov ax,[(word _isostate.filesize)+2] 6.119 + sbb ax,dx 6.120 + ja @@cxok 6.121 + je @@rem 6.122 + xor cx,cx 6.123 +@@rem: 6.124 + cmp bx,cx 6.125 + ja @@cxok 6.126 + mov cx,bx 6.127 +@@cxok: 6.128 + pop dx 6.129 + else 6.130 + p386 6.131 + push edx 6.132 + curseek 6.133 + mov edx,[_isostate.filesize] 6.134 + sub edx,eax 6.135 + jnb @@rem 6.136 + xor cx,cx 6.137 +@@rem: 6.138 + movzx eax,cx 6.139 + cmp edx,eax 6.140 + ja @@cxok 6.141 + mov cx,dx 6.142 +@@cxok: 6.143 + pop edx 6.144 + endif 6.145 + or cx,cx 6.146 + pop bx 6.147 + jmp readfd 6.148 + 6.149 +iso_lseek_hack: 6.150 + xchg ax,bx 6.151 + pop bx 6.152 + ifdef SEEK_CUR 6.153 + cmp al,1 ; current 6.154 + jne @@nocurrent 6.155 + call dosfd ; lseek(,0L,SEEK_CUR) 6.156 + jmp @doseek2 6.157 +@nocurrent: 6.158 + endif 6.159 + add dx,[word _isostate.fileofs] 6.160 + adc cx,[(word _isostate.fileofs)+2] 6.161 + cmp al,0 ; start 6.162 + je @@doseek 6.163 + add dx,[word _isostate.filesize] 6.164 + adc cx,[(word _isostate.filesize)+2] 6.165 +@@doseek: 6.166 + call lseekset ; lseek(,0L,SEEK_SET) 6.167 +@doseek2: 6.168 + sub ax,[word _isostate.fileofs] 6.169 + sbb dx,[(word _isostate.fileofs)+2] 6.170 + ret 6.171 + 6.172 +iso_close_hack: 6.173 + pop bx 6.174 + ret 6.175 + 6.176 +iso_cleanup_hack: 6.177 + mov ah,3Eh ; close file 6.178 + jmp dosfd 6.179 + 6.180 + 6.181 + 6.182 +;*************************************************************** 6.183 +;_fastcall void isolseek(bx:const unsigned long *offset); 6.184 +;*************************************************************** 6.185 + global @isolseek$qpxul:near 6.186 + proc @isolseek$qpxul near 6.187 + 6.188 +isolseek: 6.189 + mov dx,[bx] 6.190 + mov cx,[bx+2] 6.191 +lseekset: 6.192 + mov ax,4200h ; bx=fd cx:dx=offset al=whence 6.193 +dosfd: 6.194 + mov bx,[_isostate.fd] 6.195 +dos: 6.196 + int 21h 6.197 +failifc: 6.198 + jnc @@dosok 6.199 +fail: 6.200 + sbb ax,ax 6.201 + cwd 6.202 +@@dosok: 6.203 + ret 6.204 + 6.205 + endp @isolseek$qpxul 6.206 + 6.207 +;*************************************************************** 6.208 +;_fastcall int isoreadsector(bx:const unsigned long *offset); 6.209 +;*************************************************************** 6.210 + global @isoreadsector$qpxul:near 6.211 + proc @isoreadsector$qpxul near 6.212 + 6.213 + call isolseek 6.214 + jc fail 6.215 + mov cx,2560 6.216 + mov dx,offset _isostate.buffer 6.217 + global readfd:near 6.218 +readfd: 6.219 + mov ah,3Fh 6.220 + jmp dosfd 6.221 + 6.222 + endp @isoreadsector$qpxul 6.223 + 6.224 +;*************************************************************** 6.225 +;_fastcall int strhead(bx:const char* a, ax:const char* b); 6.226 +;*************************************************************** 6.227 + global @strhead$qpxzct1:near 6.228 + proc @strhead$qpxzct1 near 6.229 + 6.230 +@@loop: 6.231 + xchg ax,bx 6.232 + mov cl,[bx] ; cl = *b++ 6.233 + inc bx 6.234 + or cl,cl ; clear C 6.235 + jz failifc ; return 0 6.236 + xchg ax,bx 6.237 + xor cl,[bx] ; cl -= *a++ 6.238 + inc bx 6.239 + and cl,0dfh ; case insensitive 6.240 + jne fail ; return -1 6.241 + jmp @@loop 6.242 + 6.243 + endp @strhead$qpxzct1 6.244 + 6.245 +;*************************************************************** 6.246 +;_fastcall int strcmp(bx:const char* a, ax:const char* b); 6.247 +;*************************************************************** 6.248 + global @strcmp$qpxzct1:near 6.249 + proc @strcmp$qpxzct1 near 6.250 + 6.251 + push si 6.252 + xchg ax,si 6.253 + dec bx 6.254 +@@lp: 6.255 + inc bx 6.256 + lodsb 6.257 + sub al,[bx] 6.258 + jnz @@out 6.259 + or al,[bx] 6.260 + jnz @@lp 6.261 +@@out: 6.262 + cbw 6.263 + pop si 6.264 + ret 6.265 + 6.266 + endp @strcmp$qpxzct1 6.267 + 6.268 + ifdef NO386 6.269 + global N_LXLSH@ES:near 6.270 +N_LXLSH@ES: 6.271 + mov dx,es 6.272 + global N_LXLSH@:near 6.273 +N_LXLSH@: 6.274 + mov ch,0 6.275 +@@lp: 6.276 + shl ax,1 6.277 + rcl dx,1 6.278 + loop @@lp 6.279 + ret 6.280 + endif 6.281 + 6.282 + ends _TEXT 6.283 + 6.284 + end
7.1 --- a/linld/stuff/src/JUMP.ASM Sun May 24 07:34:28 2020 +0000 7.2 +++ b/linld/stuff/src/JUMP.ASM Sun May 24 16:16:52 2020 +0000 7.3 @@ -85,6 +85,10 @@ 7.4 global _boot_kernel:near 7.5 proc _boot_kernel near 7.6 7.7 + ifdef ISOHOOK 7.8 + extrn iso_cleanup_hack:word 7.9 + call [iso_cleanup_hack] ; or ret 7.10 + endif 7.11 ifdef NO386 7.12 p8086 7.13 else
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/linld/stuff/src/LINK2.CMD Sun May 24 16:16:52 2020 +0000 8.3 @@ -0,0 +1,1 @@ 8.4 +_isobeg.obj isocrtl.obj iso9660.obj _end.obj, isoboot
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/linld/stuff/src/_ISOBEG.ASM Sun May 24 16:16:52 2020 +0000 9.3 @@ -0,0 +1,231 @@ 9.4 +;*************************************************************** 9.5 +;****** This file is distributed under GPL 9.6 +;*************************************************************** 9.7 + ideal 9.8 + %PAGESIZE 1000 9.9 + %crefref 9.10 + %noincl 9.11 + %nomacs 9.12 + p8086 9.13 + 9.14 + group DGROUP _TEXT,_DATA,_BSS 9.15 + assume cs:DGROUP,ds:DGROUP 9.16 + 9.17 + segment _TEXT byte public use16 'CODE' 9.18 + ends _TEXT 9.19 + 9.20 + segment _DATA byte public use16 'DATA' 9.21 + global _data_start:byte 9.22 + label _data_start byte 9.23 + ends _DATA 9.24 + 9.25 + segment _BSS byte public use16 'BSS' 9.26 + 9.27 + global _bss_start:byte 9.28 + label _bss_start byte 9.29 +utoabuf db 6 dup(?) 9.30 + 9.31 + include "isostate.inc" 9.32 + 9.33 + extrn _isostate:isostate 9.34 + 9.35 + ends _BSS 9.36 + 9.37 + segment _TEXT byte public use16 'CODE' 9.38 + 9.39 + org 100h 9.40 + global _text_start:byte 9.41 + label _text_start byte 9.42 + 9.43 + extrn fold 9.44 + extrn unfold 9.45 + mov si,offset fold 9.46 + mov di,offset unfold 9.47 + mov ch,4 9.48 + cld 9.49 + rep 9.50 + movsw 9.51 + 9.52 +;*************************************************************** 9.53 +; clear bss 9.54 +;*************************************************************** 9.55 + 9.56 + mov si,offset _bss_start 9.57 +clearbss: 9.58 + mov [byte si],cl ; clear bss + heap 9.59 + inc si 9.60 + jne clearbss 9.61 + 9.62 +;*************************************************************** 9.63 +; build arg 9.64 +;*************************************************************** 9.65 + 9.66 + mov bx,endbzimage-bzimage 9.67 + mov si,80h 9.68 + mov di,si 9.69 + lodsb 9.70 + add [di],bl 9.71 + cbw 9.72 + mov bp,-1 9.73 +skipspace: 9.74 + inc bp 9.75 + cmp [byte bp+si]," " 9.76 + je skipspace 9.77 + xchg ax,cx 9.78 + add si,cx 9.79 + dec si 9.80 + lea di,[bx+si] 9.81 + mov [di+1],bh 9.82 + sub cx,bp 9.83 + std 9.84 + rep 9.85 + movsb 9.86 + push di 9.87 + mov si,offset endbzimage-1 9.88 + mov cl,bl 9.89 + rep 9.90 + movsb 9.91 + pop si 9.92 + inc si 9.93 + cld 9.94 + 9.95 + ifdef LONG_FILENAME 9.96 + mov ax,716Ch 9.97 + xor bx,bx ; R/O 9.98 + ;xor cx,cx ; attributes 9.99 + cwd ; action = open 9.100 + stc 9.101 + int 21h 9.102 + jnc opened 9.103 + endif 9.104 + mov ax,3d00h ; read-only+compatibility 9.105 + ;mov cl,0 ; attribute mask 9.106 + mov dx,si 9.107 + int 21h 9.108 + jnc opened 9.109 + 9.110 +_abort: 9.111 + mov dx,offset stopmsg 9.112 + mov ah,9 9.113 + int 21h 9.114 + int 20h 9.115 +opened: 9.116 + mov [_isostate.fd],ax 9.117 + mov ax,offset bootdir 9.118 + extrn iso_open:near 9.119 + call iso_open 9.120 +jc_abort: 9.121 + jc _abort 9.122 + 9.123 +;*************************************************************** 9.124 + 9.125 +; patch magic 9.126 + extrn @readmenu$qv:near 9.127 + call @readmenu$qv 9.128 + mov ax,[_isostate.filemod] 9.129 + mov bx,10 9.130 + xor cx,cx 9.131 +@@loop1: 9.132 + xor dx,dx 9.133 + div bx ; DX:AX = n%10:n/10 9.134 + push dx ; DL = n%10 9.135 + inc cx 9.136 + or ax,ax 9.137 + jnz @@loop1 9.138 + push ds 9.139 + pop es 9.140 + lea di,[bp+magic-bzimage+81h] 9.141 +@@loop2: 9.142 + pop ax 9.143 + add al,'0' 9.144 + stosb 9.145 + loop @@loop2 9.146 + 9.147 +; patch initrd 9.148 + cwd 9.149 + or [_isostate.curdirsize],-1 9.150 + jmp patchtest 9.151 +found: 9.152 + inc dh 9.153 +patchtest: 9.154 + push dx 9.155 + extrn @isoreaddir$qv:near 9.156 + call @isoreaddir$qv 9.157 + pop dx 9.158 + push ds 9.159 + pop es 9.160 + inc ax 9.161 + jne patchlp 9.162 + cmp dx,100h 9.163 + je initrddone 9.164 + lea di,[bp+rootfs-bzimage+87h] 9.165 + or dh,dh 9.166 + je modify 9.167 + add di,4 9.168 + mov si,offset rootfs 9.169 + mov cx,3 9.170 + rep 9.171 + movsw 9.172 +modify: 9.173 + xchg ax,dx 9.174 + stosb 9.175 + mov si,offset dotgz 9.176 + mov cl,5 9.177 + rep 9.178 + movsb 9.179 +initrddone: 9.180 + 9.181 +;*************************************************************** 9.182 + 9.183 + mov ax,offset linld 9.184 + call iso_open 9.185 + jc jc_abort 9.186 + mov cx,[word _isostate.filesize] 9.187 + mov dx,100h 9.188 + jmp near unfold 9.189 +patchlp: 9.190 + mov si,[_isostate.filename] 9.191 + mov di,offset rootfs 9.192 + mov cx,9 9.193 + rep 9.194 + cmpsb 9.195 + jcxz found 9.196 + cmp cl,3 9.197 + ja patchtest 9.198 + dec si 9.199 + cmp dl,[si] 9.200 + ja patchtest 9.201 + mov dl,[si] 9.202 + jmp patchtest 9.203 + 9.204 +stopmsg: 9.205 + db "This program cannot be run in DOS mode$" 9.206 +bootdir: 9.207 + db "/boot",0 9.208 +linld: 9.209 + db "linld.com",0 9.210 +bzimage: 9.211 + db "-f " 9.212 + ;db "image=boot\bzImage " 9.213 + db "initrd=" 9.214 +rootfs: 9.215 + db "rootfs" 9.216 +dotgz: 9.217 + db ".gz,! " 9.218 + ; ".gz,rootfs4.gz,! " 9.219 + ;db "rw " 9.220 + db "autologin rdinit=/init.exe mode=menu magic=" 9.221 +magic: 9.222 + db "0 bootfrom=" 9.223 + ; "65535 bootfrom=" 9.224 +endbzimage: 9.225 + 9.226 + 9.227 +;*************************************************************** 9.228 + 9.229 + ends _TEXT 9.230 + 9.231 + 9.232 + end _text_start 9.233 + 9.234 +;###### END OF FILE ############################################
10.1 --- a/linld/stuff/src/pipehole.awk Sun May 24 07:34:28 2020 +0000 10.2 +++ b/linld/stuff/src/pipehole.awk Sun May 24 16:16:52 2020 +0000 10.3 @@ -45,12 +45,14 @@ 10.4 if (/ax,word ptr/) $0=" xchg ax,bx" 10.5 if (/\[si\]$/) { islinld=0; print "; " $0; next } 10.6 } 10.7 - if (/do strcatb/) islinld=5 10.8 if (islinld==5) { 10.9 if (/si/) next 10.10 - $0=" lodsw" 10.11 - islinld=0 10.12 + if (/buf_cmdline/) { 10.13 + print " lodsw" 10.14 + islinld=0 10.15 + } 10.16 } 10.17 + if (/do strcatb/) islinld=5 10.18 } # file == "linld.cpp" 10.19 if (file == "himem.cpp") { 10.20 if (/void load_image/) ishimem=1