wok-6.x rev 19825
linld/tazboot: can boot memtest & ipxe
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 05 13:22:08 2017 +0100 (2017-03-05) |
parents | 9facff0f7d4e |
children | 008ac2992c52 |
files | linld/stuff/src/!COMPILEX.BAT linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.ASM linld/stuff/src/CRTLX.H linld/stuff/src/ISO9660.CPP linld/stuff/src/ISO9660.H linld/stuff/src/JUMP.ASM linld/stuff/src/LINKX.CMD linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/TAZBOOT.CPP linld/stuff/src/VCPI.ASM linld/stuff/src/_BEG.ASM |
line diff
1.1 --- a/linld/stuff/src/!COMPILEX.BAT Sat Mar 04 22:10:01 2017 +0100 1.2 +++ b/linld/stuff/src/!COMPILEX.BAT Sun Mar 05 13:22:08 2017 +0100 1.3 @@ -1,7 +1,7 @@ 1.4 path ..\BC31;%PATH% 1.5 call !clean.bat 1.6 -rem tasm /la /m /dNO386 *.asm > asm.log 1.7 -tasm /la /m /dNO386 /dLARGE_IMAGES *.asm > asm.log 1.8 +rem tasm /la /m /dEXTRA /dNO386 *.asm > asm.log 1.9 +tasm /la /m /dEXTRA /dNO386 /dLARGE_IMAGES *.asm > asm.log 1.10 rem @pause 1.11 rem bcc @bccopt.opt -S -mt *.cpp 1.12 bcc @bccopt.opt -S -mt -DLARGE_IMAGES *.cpp
2.1 --- a/linld/stuff/src/CRTL.ASM Sat Mar 04 22:10:01 2017 +0100 2.2 +++ b/linld/stuff/src/CRTL.ASM Sun Mar 05 13:22:08 2017 +0100 2.3 @@ -23,6 +23,9 @@ 2.4 msg_crlf db 13,10,0 2.5 vcpi_alloc_err db "vcpi " 2.6 msg_malloc db "malloc failure",0 2.7 + ifdef EXTRA 2.8 +tazboot_cmd db "tazboot.cmd",0 2.9 + endif 2.10 2.11 ends _DATA 2.12 2.13 @@ -35,6 +38,9 @@ 2.14 ifdef LARGE_IMAGES 2.15 curdata dw ? 2.16 endif 2.17 + ifdef EXTRA 2.18 +ultoabuf db 12 dup (?) 2.19 + endif 2.20 2.21 ends _BSS 2.22 2.23 @@ -249,9 +255,9 @@ 2.24 2.25 endp _read 2.26 2.27 - 2.28 + ifdef EXTRA 2.29 ;*************************************************************** 2.30 -;long lseekset(int fd, long sz); 2.31 +;long lseekset(int fd, unsigned long sz); 2.32 ;*************************************************************** 2.33 global _lseekset:near 2.34 proc _lseekset near 2.35 @@ -262,6 +268,21 @@ 2.36 pop cx ; sz hi 2.37 push cx 2.38 push dx 2.39 + 2.40 + else 2.41 +;*************************************************************** 2.42 +;long seekset(int fd, unsigned sz); 2.43 +;*************************************************************** 2.44 + global _seekset:near 2.45 + proc _seekset near 2.46 + 2.47 + xor cx,cx 2.48 + pop ax ;caller return address 2.49 + pop bx ; fd 2.50 + pop dx ; sz 2.51 + push dx 2.52 + endif 2.53 + 2.54 push bx 2.55 push ax 2.56 global lseekset:near 2.57 @@ -278,7 +299,43 @@ 2.58 xor cx,cx 2.59 jmp dos 2.60 2.61 + ifdef EXTRA 2.62 endp _lseekset 2.63 + else 2.64 + endp _seekset 2.65 + endif 2.66 + 2.67 + ifdef EXTRA 2.68 +struc isostate ; struct isostate { 2.69 +fd dw ? ; 0 int fd; 2.70 +fileofs dd ? ; 2 unsigned long fileofs; 2.71 +filesize dd ? ; 6 unsigned long filesize; 2.72 +filemod dw ? ;10 unsigned short filemod; 2.73 +filename dw ? ;12 char *filename; 2.74 +dirofs dd ? ;14 unsigned long dirofs; 2.75 +dirsize dd ? ;16 unsigned long dirsize; 2.76 +curdirofs dd ? ;20 unsigned long curdirofs; 2.77 +curdirsize dd ? ;24 unsigned long curdirsize; 2.78 +curpos dd ? ;28 unsigned long curpos; 2.79 +ends ; } isostate; 2.80 +;*************************************************************** 2.81 +;unsigned long isolseek(const unsigned long *offset); 2.82 +;*************************************************************** 2.83 + global _isolseek:near 2.84 + proc _isolseek near 2.85 + 2.86 + pop ax 2.87 + pop bx 2.88 + push bx 2.89 + push ax 2.90 + mov dx,[bx] 2.91 + mov cx,[bx+2] 2.92 + extrn _isostate:isostate 2.93 + mov bx,[_isostate.fd] 2.94 + jmp lseekset ; (bx=fd, sz=cx:dx) 2.95 + 2.96 + endp _isolseek 2.97 + endif 2.98 2.99 2.100 ;*************************************************************** 2.101 @@ -1177,8 +1234,294 @@ 2.102 endp _topseg 2.103 endif 2.104 2.105 + ifdef EXTRA 2.106 + p8086 2.107 + 2.108 +;*************************************************************** 2.109 +;int strcmp(const char* a,const char* b); 2.110 +;*************************************************************** 2.111 + global _strcmp:near 2.112 + proc _strcmp near 2.113 + 2.114 + pop cx ;caller return address 2.115 + pop bx ; a 2.116 + pop ax ; b 2.117 + push ax 2.118 + push bx 2.119 + push cx 2.120 + push si 2.121 + xchg ax,si 2.122 + sub bx,si 2.123 +@@lp: 2.124 + mov al,[si] 2.125 + sub al,[bx+si] 2.126 + jnz @@out 2.127 + lodsb 2.128 + cmp al,0 2.129 + jne @@lp 2.130 +@@out: 2.131 + cbw 2.132 + pop si 2.133 + ret 2.134 + 2.135 + endp _strcmp 2.136 + 2.137 + 2.138 +;*************************************************************** 2.139 +;char strstr(const char* a,const char* b); 2.140 +;*************************************************************** 2.141 + global _strstr:near 2.142 + proc _strstr near 2.143 + 2.144 + pop ax ;caller return address 2.145 + pop cx ; a 2.146 + pop dx ; b 2.147 + push dx 2.148 + push cx 2.149 + push ax 2.150 + push si 2.151 +@@loop: 2.152 + xor ax,ax 2.153 + mov si,cx 2.154 + cmp [si],al ; *a 2.155 + jz @@end ; return ax = NULL 2.156 + mov bx,dx 2.157 + sub bx,si 2.158 +@@match: 2.159 + or ah,[bx+si] ; *b 2.160 + jz @@found 2.161 + lodsb 2.162 + sub ah,al 2.163 + jz @@match 2.164 + inc cx 2.165 + jmp @@loop 2.166 +@@found: 2.167 + xchg ax,cx 2.168 +@@end: 2.169 + pop si 2.170 + ret 2.171 + 2.172 + endp _strstr 2.173 + 2.174 + 2.175 +;*************************************************************** 2.176 +;char *progname(void) 2.177 +;*************************************************************** 2.178 + global _progname:near 2.179 + proc _progname near 2.180 + 2.181 + push si di es 2.182 + mov ah,30h 2.183 + int 21h 2.184 + cmp al,3 2.185 + jb @@skip 2.186 + xor di,di 2.187 + mov es,[cs:2Ch] 2.188 + mov cx,-1 2.189 + mov ax,di 2.190 +@@loop1: 2.191 + repne 2.192 + scasb 2.193 + scasb 2.194 + jne @@loop1 2.195 + lea si,[di+2] 2.196 + mov bx, si 2.197 + call strlen 2.198 + xchg ax,cx 2.199 + inc cx 2.200 + call malloc_or_die 2.201 + xchg ax,di 2.202 + push ds 2.203 + push ds 2.204 + push es 2.205 + pop ds 2.206 + pop es 2.207 + push di 2.208 +@@loop2: 2.209 + lodsb 2.210 + stosb 2.211 + or al,al 2.212 + jnz @@loop2 2.213 + pop ax 2.214 + pop ds 2.215 +@@skip: 2.216 + pop es di si 2.217 + ret 2.218 + 2.219 + endp _progname 2.220 + 2.221 + 2.222 +;*************************************************************** 2.223 +;int chdir(char *path); 2.224 +;*************************************************************** 2.225 + global _chdir:near 2.226 + proc _chdir near 2.227 + 2.228 + pop ax 2.229 + pop dx 2.230 + push dx 2.231 + push ax 2.232 +chdir: 2.233 + stc 2.234 + mov ax,713Bh 2.235 + int 21h 2.236 + jnc @@end 2.237 + mov ah,3Bh 2.238 + int 21h 2.239 +@@end: 2.240 + sbb ax,ax 2.241 + ret 2.242 + 2.243 + endp _chdir 2.244 + 2.245 + 2.246 +;*************************************************************** 2.247 +;int chdirname(char *path) 2.248 +;*************************************************************** 2.249 + global _chdirname:near 2.250 + proc _chdirname near 2.251 + 2.252 + pop ax 2.253 + pop bx 2.254 + push bx 2.255 + push ax 2.256 + 2.257 + cmp [byte bx+1],3Ah 2.258 + jne @@nodisk 2.259 + mov dl,[bx] 2.260 + or dl,20h 2.261 + sub dl,61h 2.262 + mov ah,0Eh 2.263 + push bx 2.264 + int 21h 2.265 + pop bx 2.266 + inc bx 2.267 + inc bx 2.268 +@@nodisk: 2.269 + mov dx,bx 2.270 + xor cx,cx 2.271 +@@next: 2.272 + mov al,[bx] 2.273 + cmp al,5Ch 2.274 + jne @@tsteos 2.275 + mov cx,bx 2.276 +@@tsteos: 2.277 + inc bx 2.278 + or al,al 2.279 + jnz @@next 2.280 + cbw 2.281 + jcxz @@end 2.282 + mov bx,cx 2.283 + push [word bx] 2.284 + mov [bx],al 2.285 + push bx 2.286 + call chdir 2.287 + pop bx 2.288 + pop [word bx] 2.289 +@@end: 2.290 + ret 2.291 + 2.292 + endp _chdirname 2.293 + 2.294 + 2.295 +;*************************************************************** 2.296 +;char *ultoa(unsigned long n); 2.297 +;*************************************************************** 2.298 + global _ultoa:near 2.299 + proc _ultoa near 2.300 + 2.301 + pop ax 2.302 + pop cx 2.303 + pop dx 2.304 + push dx 2.305 + push cx 2.306 + push ax ; DX:CX = n 2.307 + push si 2.308 + mov si,10 2.309 + mov bx,offset ultoabuf+11 2.310 +@@loop: 2.311 + dec bx 2.312 + xchg ax,dx 2.313 + xor dx,dx 2.314 + div si ; DX:AX = 0000:hi(n) 2.315 + xchg ax,cx ; CX = hi(n)/10 2.316 + div si ; DX:AX = hi(n)%10:lo(n) 2.317 + xchg ax,cx ; CX = lo(n/10) 2.318 + xchg ax,dx ; DX = hi(n)/10 = hi(n/10) 2.319 + add al,'0' 2.320 + mov [bx],al 2.321 + mov ax,cx 2.322 + or ax,dx 2.323 + jnz @@loop 2.324 + xchg ax,bx 2.325 + pop si 2.326 + ret 2.327 + 2.328 + endp _ultoa 2.329 + 2.330 + 2.331 +;*************************************************************** 2.332 +;unsigned long kver2ul(char *kernel_version); 2.333 +;*************************************************************** 2.334 + global _kver2ul:near 2.335 + proc _kver2ul near 2.336 + 2.337 + pop bx 2.338 + pop ax 2.339 + push ax 2.340 + push bx 2.341 + push bp si di 2.342 + xchg ax,si 2.343 + xor di,di 2.344 + push di 2.345 + push di 2.346 + mov bp,sp 2.347 + inc di 2.348 + inc di 2.349 + mov cl,4 2.350 +@@number: 2.351 + xor ax,ax 2.352 +@@digit: 2.353 + shl al,cl 2.354 + shl ax,cl 2.355 + lodsb 2.356 + sub al,30h 2.357 + cmp al,9 2.358 + jbe @@digit 2.359 + mov [bp+di],ah 2.360 + dec di 2.361 + jns @@number 2.362 + pop ax 2.363 + pop dx 2.364 + pop di si bp 2.365 +kver2ulret: 2.366 + ret 2.367 + 2.368 + endp _kver2ul 2.369 + 2.370 + 2.371 +;*************************************************************** 2.372 +;void try_default_args(); 2.373 +;*************************************************************** 2.374 + global _try_default_args:near 2.375 + proc _try_default_args near 2.376 + 2.377 + mov bx,offset tazboot_cmd 2.378 + call open 2.379 + jc kver2ulret 2.380 + mov cx,4096 2.381 + mov di,[_heap_top] 2.382 + push cx 2.383 + extrn read_cmdline:near 2.384 + jmp near read_cmdline ; read_cmdline(ax,di,cx) 2.385 + 2.386 + endp _try_default_args 2.387 + 2.388 + endif 2.389 + 2.390 ends _TEXT 2.391 2.392 end 2.393 2.394 ;###### END OF FILE ############################################ 2.395 +
3.1 --- a/linld/stuff/src/CRTL.H Sat Mar 04 22:10:01 2017 +0100 3.2 +++ b/linld/stuff/src/CRTL.H Sun Mar 05 13:22:08 2017 +0100 3.3 @@ -40,7 +40,7 @@ 3.4 extern "C" void abort(); 3.5 extern "C" int read(int fd, void* data, int sz); 3.6 extern "C" int write(int fd, const void* data, int sz); 3.7 -extern "C" long lseekset(int fd, long sz); 3.8 +extern "C" long seekset(int fd, unsigned sz); 3.9 extern "C" void* malloc(unsigned sz); 3.10 extern "C" int puts(const char* s); 3.11 extern "C" unsigned long strtol(const char *s);
4.1 --- a/linld/stuff/src/CRTLX.ASM Sat Mar 04 22:10:01 2017 +0100 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,391 +0,0 @@ 4.4 -;*************************************************************** 4.5 -;****** This file is distributed under GPL 4.6 -;*************************************************************** 4.7 - ideal 4.8 - %crefref 4.9 - %noincl 4.10 - %nomacs 4.11 - p8086 4.12 - 4.13 - group DGROUP _TEXT,_DATA,_BSS 4.14 - assume cs:DGROUP,ds:DGROUP 4.15 - 4.16 - segment _DATA byte public use16 'DATA' 4.17 - 4.18 -tazboot_cmd db "tazboot.cmd",0 4.19 - 4.20 - ends _DATA 4.21 - 4.22 - segment _BSS byte public use16 'BSS' 4.23 - 4.24 -ultoabuf db 12 dup (?) 4.25 - 4.26 - ends _BSS 4.27 - 4.28 - segment _TEXT byte public use16 'CODE' 4.29 - 4.30 -;*************************************************************** 4.31 -;int strcmp(const char* a,const char* b); 4.32 -;*************************************************************** 4.33 - global _strcmp:near 4.34 - proc _strcmp near 4.35 - 4.36 - pop cx ;caller return address 4.37 - pop bx ; a 4.38 - pop ax ; b 4.39 - push ax 4.40 - push bx 4.41 - push cx 4.42 - push si 4.43 - xchg ax,si 4.44 - sub bx,si 4.45 -@@lp: 4.46 - mov al,[si] 4.47 - sub al,[bx+si] 4.48 - jnz @@out 4.49 - lodsb 4.50 - cmp al,0 4.51 - jne @@lp 4.52 -@@out: 4.53 - cbw 4.54 - pop si 4.55 - ret 4.56 - 4.57 - endp _strcmp 4.58 - 4.59 - 4.60 -;*************************************************************** 4.61 -;char strstr(const char* a,const char* b); 4.62 -;*************************************************************** 4.63 - global _strstr:near 4.64 - proc _strstr near 4.65 - 4.66 - pop ax ;caller return address 4.67 - pop cx ; a 4.68 - pop dx ; b 4.69 - push dx 4.70 - push cx 4.71 - push ax 4.72 - push si 4.73 -@@loop: 4.74 - xor ax,ax 4.75 - mov si,cx 4.76 - cmp [si],al ; *a 4.77 - jz @@end ; return ax = NULL 4.78 - mov bx,dx 4.79 - sub bx,si 4.80 -@@match: 4.81 - or ah,[bx+si] ; *b 4.82 - jz @@found 4.83 - lodsb 4.84 - sub ah,al 4.85 - jz @@match 4.86 - inc cx 4.87 - jmp @@loop 4.88 -@@found: 4.89 - xchg ax,cx 4.90 -@@end: 4.91 - pop si 4.92 - ret 4.93 - 4.94 - endp _strstr 4.95 - 4.96 - 4.97 -macro cpuid 4.98 - db 0fh,0A2h 4.99 -endm 4.100 -;*************************************************************** 4.101 -;int cpuhaslm(void) 4.102 -;*************************************************************** 4.103 - global _cpuhaslm:near 4.104 - proc _cpuhaslm near 4.105 - 4.106 - pushf 4.107 -; Check for oldies 4.108 - mov bh, 0F0h 4.109 - push bx ; < 286 : flags[12..15] are forced 1 4.110 - popf ; = 286 : flags[12..15] are forced 0 4.111 - pushf ; > 286 : only flags[15] is forced 0 4.112 - pop dx 4.113 - popf 4.114 - add dh,bh ; NS=386+, NC=286 4.115 - clc 4.116 - js @@bad ;it is a 86/186/286, not a 386+ 4.117 - p386 4.118 - pushfd 4.119 - pop dx 4.120 - pop ax 4.121 - mov bl,al 4.122 - xor al,20h ; toggle CPUID feature bit 21 4.123 - push ax 4.124 - push dx 4.125 - popfd 4.126 - pushfd 4.127 - pop dx 4.128 - pop ax 4.129 - xor al,bl ; clear C 4.130 - je @@bad ; CPUID feature bit changed ? 4.131 - mov eax,80000001h ; Extended Processor Info and Feature Bits 4.132 - cpuid 4.133 - shr edx,1+29 ; LM feature bit ? 4.134 -@@bad: 4.135 - p8086 4.136 - sbb ax,ax 4.137 - ret 4.138 - 4.139 - endp _cpuhaslm 4.140 - 4.141 - 4.142 -;*************************************************************** 4.143 -;char *progname(void) 4.144 -;*************************************************************** 4.145 - global _progname:near 4.146 - proc _progname near 4.147 - 4.148 - push si di es 4.149 - mov ah,30h 4.150 - int 21h 4.151 - cmp al,3 4.152 - jb @@skip 4.153 - xor di,di 4.154 - mov es,[cs:2Ch] 4.155 - mov cx,-1 4.156 - mov ax,di 4.157 -@@loop1: 4.158 - repne 4.159 - scasb 4.160 - scasb 4.161 - jne @@loop1 4.162 - lea si,[di+2] 4.163 - mov bx, si 4.164 - extrn strlen:near 4.165 - call near strlen 4.166 - xchg ax,cx 4.167 - inc cx 4.168 - extrn malloc_or_die:near 4.169 - call near malloc_or_die 4.170 - xchg ax,di 4.171 - push ds 4.172 - push ds 4.173 - push es 4.174 - pop ds 4.175 - pop es 4.176 - push di 4.177 -@@loop2: 4.178 - lodsb 4.179 - stosb 4.180 - or al,al 4.181 - jnz @@loop2 4.182 - pop ax 4.183 - pop ds 4.184 -@@skip: 4.185 - pop es di si 4.186 - ret 4.187 - 4.188 - endp _progname 4.189 - 4.190 - 4.191 -;*************************************************************** 4.192 -;int chdir(char *path); 4.193 -;*************************************************************** 4.194 - global _chdir:near 4.195 - proc _chdir near 4.196 - 4.197 - pop ax 4.198 - pop dx 4.199 - push dx 4.200 - push ax 4.201 -chdir: 4.202 - stc 4.203 - mov ax,713Bh 4.204 - int 21h 4.205 - jnc @@end 4.206 - mov ah,3Bh 4.207 - int 21h 4.208 -@@end: 4.209 - sbb ax,ax 4.210 - ret 4.211 - 4.212 - endp _chdir 4.213 - 4.214 - 4.215 -;*************************************************************** 4.216 -;int chdirname(char *path) 4.217 -;*************************************************************** 4.218 - global _chdirname:near 4.219 - proc _chdirname near 4.220 - 4.221 - pop ax 4.222 - pop bx 4.223 - push bx 4.224 - push ax 4.225 - 4.226 - cmp [byte bx+1],3Ah 4.227 - jne @@nodisk 4.228 - mov dl,[bx] 4.229 - or dl,20h 4.230 - sub dl,61h 4.231 - mov ah,0Eh 4.232 - push bx 4.233 - int 21h 4.234 - pop bx 4.235 - inc bx 4.236 - inc bx 4.237 -@@nodisk: 4.238 - mov dx,bx 4.239 - xor cx,cx 4.240 -@@next: 4.241 - mov al,[bx] 4.242 - cmp al,5Ch 4.243 - jne @@tsteos 4.244 - mov cx,bx 4.245 -@@tsteos: 4.246 - inc bx 4.247 - or al,al 4.248 - jnz @@next 4.249 - cbw 4.250 - jcxz @@end 4.251 - mov bx,cx 4.252 - push [word bx] 4.253 - mov [bx],al 4.254 - push bx 4.255 - call chdir 4.256 - pop bx 4.257 - pop [word bx] 4.258 -@@end: 4.259 - ret 4.260 - 4.261 - endp _chdirname 4.262 - 4.263 - 4.264 -;*************************************************************** 4.265 -;char *ultoa(unsigned long n); 4.266 -;*************************************************************** 4.267 - global _ultoa:near 4.268 - proc _ultoa near 4.269 - 4.270 - pop ax 4.271 - pop cx 4.272 - pop dx 4.273 - push dx 4.274 - push cx 4.275 - push ax ; DX:CX = n 4.276 - push si 4.277 - mov si,10 4.278 - mov bx,offset ultoabuf+11 4.279 -@@loop: 4.280 - dec bx 4.281 - xchg ax,dx 4.282 - xor dx,dx 4.283 - div si ; DX:AX = 0000:hi(n) 4.284 - xchg ax,cx ; CX = hi(n)/10 4.285 - div si ; DX:AX = hi(n)%10:lo(n) 4.286 - xchg ax,cx ; CX = lo(n/10) 4.287 - xchg ax,dx ; DX = hi(n)/10 = hi(n/10) 4.288 - add al,'0' 4.289 - mov [bx],al 4.290 - mov ax,cx 4.291 - or ax,dx 4.292 - jnz @@loop 4.293 - xchg ax,bx 4.294 - pop si 4.295 - ret 4.296 - 4.297 - endp _ultoa 4.298 - 4.299 - 4.300 -;*************************************************************** 4.301 -;unsigned long kver2ul(char *kernel_version); 4.302 -;*************************************************************** 4.303 - global _kver2ul:near 4.304 - proc _kver2ul near 4.305 - 4.306 - pop bx 4.307 - pop ax 4.308 - push ax 4.309 - push bx 4.310 - push bp si di 4.311 - xchg ax,si 4.312 - xor di,di 4.313 - push di 4.314 - push di 4.315 - mov bp,sp 4.316 - inc di 4.317 - inc di 4.318 - mov cl,4 4.319 -@@number: 4.320 - xor ax,ax 4.321 -@@digit: 4.322 - shl al,cl 4.323 - shl ax,cl 4.324 - lodsb 4.325 - sub al,30h 4.326 - cmp al,9 4.327 - jbe @@digit 4.328 - mov [bp+di],ah 4.329 - dec di 4.330 - jns @@number 4.331 - pop ax 4.332 - pop dx 4.333 - pop di si bp 4.334 -kver2ulret: 4.335 - ret 4.336 - 4.337 - endp _kver2ul 4.338 - 4.339 - 4.340 -;*************************************************************** 4.341 -;void try_default_args(); 4.342 -;*************************************************************** 4.343 - global _try_default_args:near 4.344 - proc _try_default_args near 4.345 - 4.346 - mov bx,offset tazboot_cmd 4.347 - extrn open:near 4.348 - call near open 4.349 - jc kver2ulret 4.350 - mov cx,4096 4.351 - extrn _heap_top:word 4.352 - mov di,[_heap_top] 4.353 - push cx 4.354 - extrn read_cmdline:near 4.355 - jmp near read_cmdline ; read_cmdline(ax,di,cx) 4.356 - 4.357 - endp _try_default_args 4.358 - 4.359 -struc isostate ; struct isostate { 4.360 -fd dw ? ; 0 int fd; 4.361 -fileofs dd ? ; 2 unsigned long fileofs; 4.362 -filesize dd ? ; 6 unsigned long filesize; 4.363 -filemod dw ? ;10 unsigned short filemod; 4.364 -filename dw ? ;12 char *filename; 4.365 -dirofs dd ? ;14 unsigned long dirofs; 4.366 -dirsize dd ? ;16 unsigned long dirsize; 4.367 -curdirofs dd ? ;20 unsigned long curdirofs; 4.368 -curdirsize dd ? ;24 unsigned long curdirsize; 4.369 -curpos dd ? ;28 unsigned long curpos; 4.370 -ends ; } isostate; 4.371 -;*************************************************************** 4.372 -;unsigned long isolseek(unsigned long offset); 4.373 -;*************************************************************** 4.374 - global _isolseek:near 4.375 - proc _isolseek near 4.376 - 4.377 - pop ax 4.378 - pop dx 4.379 - pop cx 4.380 - push cx 4.381 - push dx 4.382 - push ax 4.383 - extrn _isostate:isostate 4.384 - mov bx,[_isostate.fd] 4.385 - extrn lseekset:near 4.386 - jmp near lseekset ; (bx=fd, sz=cx:dx) 4.387 - 4.388 - endp _isolseek 4.389 - 4.390 - ends _TEXT 4.391 - 4.392 - end 4.393 - 4.394 -;###### END OF FILE ############################################
5.1 --- a/linld/stuff/src/CRTLX.H Sat Mar 04 22:10:01 2017 +0100 5.2 +++ b/linld/stuff/src/CRTLX.H Sun Mar 05 13:22:08 2017 +0100 5.3 @@ -4,11 +4,13 @@ 5.4 extern "C" int strcmp(const char* a,const char* b); 5.5 extern "C" int strlen(const char* s); 5.6 extern "C" char* strstr(const char* a,const char* b); 5.7 -extern "C" int cpuhaslm(); 5.8 extern "C" char *progname(void); 5.9 extern "C" int chdir(char *path); 5.10 extern "C" int chdirname(char *path); 5.11 extern "C" unsigned long kver2ul(char *kernel_version); 5.12 extern "C" char *ultoa(unsigned long n); 5.13 extern "C" void try_default_args(); 5.14 - 5.15 +extern "C" long lseekset(int fd, unsigned long sz); 5.16 +#define seekset(fd,sz) lseekset(fd,(unsigned long) sz) 5.17 +extern long cpu_features; 5.18 +#define cpuhaslm() (((char *)&cpu_features)[3]&(char)0x20)
6.1 --- a/linld/stuff/src/ISO9660.CPP Sat Mar 04 22:10:01 2017 +0100 6.2 +++ b/linld/stuff/src/ISO9660.CPP Sun Mar 05 13:22:08 2017 +0100 6.3 @@ -8,45 +8,24 @@ 6.4 static char buffer[SECTORSZ]; 6.5 struct isostate isostate; 6.6 6.7 -static int readsector(unsigned long offset) 6.8 +static int readsector(const unsigned long *offset) 6.9 { 6.10 return (isolseek(offset) != -1 6.11 && read(isostate.fd, buffer, SECTORSZ) == SECTORSZ); 6.12 } 6.13 6.14 -int isoread(char *data, unsigned size) 6.15 -{ 6.16 - int get, n; 6.17 - 6.18 - struct isostate *x=&isostate; 6.19 - if (isolseek(x->fileofs) == -1) 6.20 - return -1; 6.21 - if (size < x->filesize) 6.22 - size = x->filesize; 6.23 - for (get = size; get; get -= n, data += n) { 6.24 - n = read(x->fd,data,get); 6.25 - if (n < 0) 6.26 - return n; 6.27 - if (n == 0) 6.28 - break; 6.29 - x->fileofs += n; 6.30 - x->filesize -= n; 6.31 - } 6.32 - return size - get; 6.33 -} 6.34 - 6.35 int isoreset(char *name) 6.36 { 6.37 + static const unsigned long root = 16UL * 2048; 6.38 struct isostate *x=&isostate; 6.39 if (name) 6.40 //x->fd = open(name, O_RDONLY); 6.41 x->fd = open(name); 6.42 - if (!readsector(16UL * 2048) || strhead(buffer+1,"CD001")) { 6.43 + if (!readsector(&root) || strhead(buffer+1,"CD001")) { 6.44 //close(x->fd); 6.45 return -1; 6.46 } 6.47 - x->dirofs = * (unsigned long *) (buffer + 0x9E); 6.48 - x->dirofs <<= SECTORBITS; 6.49 + x->dirofs = (* (unsigned long *) (buffer + 0x9E)) << SECTORBITS; 6.50 x->dirsize = * (unsigned long *) (buffer + 0xA6); 6.51 return 0; 6.52 } 6.53 @@ -68,7 +47,7 @@ 6.54 } 6.55 if (x->curpos >= SECTORSZ || * (short *) (buffer + x->curpos) == 0) { 6.56 if (x->curdirsize < SECTORSZ) return -1; 6.57 - readsector(x->curdirofs); 6.58 + readsector(&x->curdirofs); 6.59 x->curdirofs += SECTORSZ; 6.60 x->curdirsize -= SECTORSZ; 6.61 x->curpos = 0; 6.62 @@ -125,52 +104,44 @@ 6.63 return 0; 6.64 } 6.65 6.66 -#define IS_DIR(x)( ((x) & ~0777) == 040000) 6.67 -int isoopen(char *filename) 6.68 +//#define IS_DIR(x)( ((x) & ~0777) == 040000) 6.69 +#define IS_DIR(x)( (char)((x) >> 9) == (char)040) 6.70 +int isoopen(const char *filename) 6.71 { 6.72 int restart; 6.73 - char *name, *s; 6.74 - int _64bits = cpuhaslm(); 6.75 + char *name, *s, c; 6.76 + char _64bits = cpuhaslm(); 6.77 struct isostate *x=&isostate; 6.78 6.79 retry32: 6.80 - name = filename; 6.81 - while (*name == '/') { 6.82 - name++; 6.83 + for (s = (char *) filename; *s == '/' ; s++) { 6.84 isoreset(NULL); 6.85 } 6.86 - s = name; 6.87 - while (1) { 6.88 - char c; 6.89 - while (*s && *s != '/') s++; 6.90 - c = *s; 6.91 - *s = 0; 6.92 - for (restart = 1; isoreaddir(restart) == 0; restart = 0) { 6.93 - const char *n = name, *i = x->filename; 6.94 - if (_64bits) { 6.95 - if (strhead(x->filename, name)) continue; 6.96 - n = "64"; 6.97 - i += strlen(name); 6.98 - } 6.99 - if (strcmp(n, i)) continue; 6.100 - if (IS_DIR(x->filemod)) { 6.101 - x->dirofs = x->fileofs; 6.102 - x->dirsize = x->filesize; 6.103 - if (c) { 6.104 - *s++ = c; 6.105 - name = s; 6.106 - goto next; 6.107 - } 6.108 - } 6.109 - isolseek(x->fileofs); 6.110 - return 0; 6.111 + next: 6.112 + name = s; 6.113 + do s++; while (*s && *s != '/'); 6.114 + c = *s; 6.115 + *s = 0; 6.116 + for (restart = 1; isoreaddir(restart) == 0; restart = 0) { 6.117 + const char *n = name, *i = x->filename; 6.118 + if (_64bits) { 6.119 + if (strhead(i, n)) continue; 6.120 + n = "64"; 6.121 + i += s - name; // strlen(name); 6.122 } 6.123 - if (_64bits) { 6.124 - _64bits = 0; 6.125 - *s = c; 6.126 - goto retry32; 6.127 + if (strcmp(i, n)) continue; 6.128 + *s++ = c; 6.129 + if (IS_DIR(x->filemod)) { 6.130 + x->dirofs = x->fileofs; 6.131 + x->dirsize = x->filesize; 6.132 + if (c) goto next; 6.133 } 6.134 - return -1; 6.135 - next: ; 6.136 + isolseek(&x->fileofs); 6.137 + return 0; 6.138 } 6.139 + if (_64bits) { 6.140 + _64bits = 0; 6.141 + goto retry32; 6.142 + } 6.143 + return -1; 6.144 }
7.1 --- a/linld/stuff/src/ISO9660.H Sat Mar 04 22:10:01 2017 +0100 7.2 +++ b/linld/stuff/src/ISO9660.H Sun Mar 05 13:22:08 2017 +0100 7.3 @@ -16,10 +16,9 @@ 7.4 #define isofilesize isostate.filesize 7.5 #define isofilemod isostate.filemod 7.6 #define isofilename isostate.filename 7.7 -extern "C" unsigned long isolseek(unsigned long offset); 7.8 +extern "C" unsigned long isolseek(const unsigned long *offset); 7.9 extern int isoreset(char *name); 7.10 -extern int isoopen(char *name); 7.11 +extern int isoopen(const char *name); 7.12 extern int isoreaddir(int restart); 7.13 -extern int isoread(char *data, unsigned size); 7.14 #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) 7.15 #endif
8.1 --- a/linld/stuff/src/JUMP.ASM Sat Mar 04 22:10:01 2017 +0100 8.2 +++ b/linld/stuff/src/JUMP.ASM Sun Mar 05 13:22:08 2017 +0100 8.3 @@ -42,13 +42,13 @@ 8.4 push 9000h 8.5 pop es 8.6 endif 8.7 - pop cx ; ip 8.8 - pop dx ; cs 8.9 + pop dx ; ip 8.10 + pop cx ; cs 8.11 cli ; we start doing destructive things to DOS 8.12 push es 8.13 pop ss 8.14 mov sp,0A000h 8.15 - push dx cx 8.16 + push cx dx 8.17 extrn _rm_size:word 8.18 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf 8.19 lodsw
9.1 --- a/linld/stuff/src/LINKX.CMD Sat Mar 04 22:10:01 2017 +0100 9.2 +++ b/linld/stuff/src/LINKX.CMD Sun Mar 05 13:22:08 2017 +0100 9.3 @@ -1,1 +1,1 @@ 9.4 -_beg.obj memcpy32.obj jump.obj vcpi.obj himem.obj crtl.obj crtlx.obj memtop.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot 9.5 +_beg.obj memcpy32.obj jump.obj vcpi.obj himem.obj crtl.obj memtop.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot
10.1 --- a/linld/stuff/src/LINLD.CPP Sat Mar 04 22:10:01 2017 +0100 10.2 +++ b/linld/stuff/src/LINLD.CPP Sun Mar 05 13:22:08 2017 +0100 10.3 @@ -58,6 +58,7 @@ 10.4 } 10.5 if(strhead(s,"image=") == 0) { 10.6 s+=6; 10.7 + set_kernel_name: 10.8 kernel_name=s; 10.9 } 10.10 else if(strhead(s,"initrd=") == 0) { 10.11 @@ -116,8 +117,8 @@ 10.12 strcatb(_cmdline,*argv); 10.13 } 10.14 else if(i == 1 && fileattr(s) != -1) { 10.15 - kernel_name = s; 10.16 cmdline = (const char *) _cmdline; 10.17 + goto set_kernel_name; 10.18 } 10.19 else 10.20 break;
11.1 --- a/linld/stuff/src/LOAD.CPP Sat Mar 04 22:10:01 2017 +0100 11.2 +++ b/linld/stuff/src/LOAD.CPP Sun Mar 05 13:22:08 2017 +0100 11.3 @@ -155,7 +155,7 @@ 11.4 if(kernelparams->setup_sects == 0) { 11.5 #if 1 11.6 if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) { 11.7 - lseekset(pm.fd,rm_seek=0x200); 11.8 + seekset(pm.fd,rm_seek=0x200); 11.9 csip+=0xFFE00042; 11.10 } 11.11 else
12.1 --- a/linld/stuff/src/TAZBOOT.CPP Sat Mar 04 22:10:01 2017 +0100 12.2 +++ b/linld/stuff/src/TAZBOOT.CPP Sun Mar 05 13:22:08 2017 +0100 12.3 @@ -7,20 +7,23 @@ 12.4 #include "common.h" 12.5 #include "iso9660.h" 12.6 12.7 +struct initrd_info { 12.8 + u32 ofs; 12.9 + u32 size; 12.10 +}; 12.11 #define MAXINITRD 10 12.12 static struct initrd_state { 12.13 - u32 ofs[MAXINITRD]; 12.14 - u32 size[MAXINITRD]; 12.15 + struct initrd_info info[MAXINITRD]; 12.16 u16 cnt; 12.17 } initrd_state; 12.18 12.19 static void next_chunk(struct image_himem *m) 12.20 { 12.21 - struct initrd_state *p = &initrd_state; 12.22 + struct initrd_info *i = &initrd_state.info[m->state]; 12.23 m->chunk_size = 0; 12.24 - if (m->state >= p->cnt) return; 12.25 - lseekset(m->fd,p->ofs[m->state]); 12.26 - m->chunk_size = p->size[m->state]; 12.27 + if (m->state >= initrd_state.cnt) return; 12.28 + lseekset(m->fd,i->ofs); 12.29 + m->chunk_size = i->size; 12.30 m->state++; 12.31 } 12.32 12.33 @@ -31,11 +34,12 @@ 12.34 12.35 static void addinitrd() 12.36 { 12.37 - struct initrd_state *p = &initrd_state; 12.38 - if (p->cnt >= MAXINITRD) return; 12.39 - p->size[p->cnt] = isofilesize; 12.40 - p->ofs[p->cnt] = isofileofs; 12.41 - p->cnt++; 12.42 + u16 *pcnt = &initrd_state.cnt; 12.43 + struct initrd_info *i = &initrd_state.info[*pcnt]; 12.44 + if (*pcnt >= MAXINITRD) return; 12.45 + ++*pcnt; 12.46 + i->size = isofilesize; 12.47 + i->ofs = isofileofs; 12.48 initrd.size += isofilesize4round(); 12.49 } 12.50 12.51 @@ -58,13 +62,14 @@ 12.52 return load_kernel(); 12.53 } 12.54 12.55 -char _cmdline[256]; 12.56 -const char *cmdline = (const char *) _cmdline; 12.57 +char _cmdline[4096]; 12.58 +const char *cmdline = (const char *) _cmdline+1; 12.59 static void bootiso(char **iso) 12.60 { 12.61 - char *init = " rdinit=/init.exe", *mode="menu"; 12.62 - char c, rootfs[16], fallback[16]; 12.63 - int restart, isknoppix = 0; 12.64 + const char *init = " rdinit=/init.exe", *mode="menu"; 12.65 + char c; 12.66 + static char rootfs[16], fallback[16], isknoppix, noauto; 12.67 + int restart; 12.68 unsigned long magic; 12.69 struct isostate *x=&isostate; 12.70 12.71 @@ -78,15 +83,14 @@ 12.72 if (iso[1] && !strcmp(mode = iso[1], "text")) 12.73 init = ""; 12.74 do { 12.75 - if (isoopen(mode) >= 0 || // custom 12.76 - isoopen("bzImage") >= 0 || // SliTaz 12.77 - isoopen("vmlinuz") >= 0 || // misc 12.78 + if ((isoopen(mode) >= 0 && ++noauto) || // custom 12.79 + isoopen("bzImage") >= 0 || // SliTaz 12.80 + isoopen("vmlinuz") >= 0 || // misc 12.81 (isoopen("linux") >= 0 && ++isknoppix)) { 12.82 magic = kver2ul(isokernel()); 12.83 break; 12.84 } 12.85 } while (isoopen("isolinux") >= 0); // Knoppix 12.86 - fallback[0] = 0; 12.87 for (c = 0, restart = 1; isoreaddir(restart) == 0; restart = 0) { 12.88 if (strstr(x->filename, ".gz")) 12.89 strcpy(fallback, x->filename); 12.90 @@ -96,13 +100,25 @@ 12.91 c = x->filename[6]; 12.92 } 12.93 12.94 - strcpy(_cmdline,"rw root=/dev/null autologin bootfrom="); 12.95 + strcatb(_cmdline,"rw root=/dev/null autologin bootfrom="); 12.96 strcat(_cmdline,*iso); 12.97 if (magic < 0x20630) 12.98 init = ""; // Does not support multiple initramfs 12.99 12.100 - if (magic > 0) { 12.101 + if (noauto) { 12.102 + char *s; 12.103 + * (int *) _cmdline = 0; 12.104 + iso++; 12.105 + while ((s = *++iso) != NULL) { 12.106 + if (strhead(s,"initrd=")) 12.107 + strcatb(_cmdline,s); 12.108 + else if (isoopen(s+7) >= 0) 12.109 + addinitrd(); 12.110 + } 12.111 + } 12.112 + else if (magic > 0) { 12.113 char *initrd = fallback; 12.114 + static const unsigned long initrddesc = 20L; 12.115 12.116 if (rootfs[0]) { 12.117 initrd = rootfs; 12.118 @@ -112,27 +128,25 @@ 12.119 if (isoopen(initrd) >= 0) { 12.120 addinitrd(); 12.121 } 12.122 - if (*init && isolseek(20L) != -1) { 12.123 - read(x->fd, &x->fileofs, 4); 12.124 - read(x->fd, &magic, 4); 12.125 + if (*init && isolseek(&initrddesc) != -1) { 12.126 + read(x->fd, &x->fileofs, 8); // and x->filesize 12.127 x->fileofs &= 0xFFFFL; 12.128 - x->filesize = magic & 0xFFFFL; 12.129 - x->fileofs -= 0xC0L + x->filesize; 12.130 - if (x->filesize) addinitrd(); 12.131 + x->fileofs -= 0xC0L + (x->filesize &= 0xFFFF); 12.132 + if (((short *) &x->fileofs)[1] == 0) addinitrd(); 12.133 else init=""; 12.134 } 12.135 - load_initrds(); 12.136 strcat(_cmdline,init); 12.137 strcatb(_cmdline,"mode="); 12.138 strcat(_cmdline,mode); 12.139 strcatb(_cmdline,"magic="); 12.140 strcat(_cmdline,ultoa(magic)); 12.141 } 12.142 + load_initrds(); 12.143 if (isknoppix) { 12.144 - char *s; 12.145 - if (iso[0][1] == ':') 12.146 - *iso += 2; 12.147 - for (s = *iso; *s; s++) 12.148 + char *s = *iso; 12.149 + if (s[1] == ':') 12.150 + s += 2; 12.151 + for (; *s; s++) 12.152 if (*s == '\\') *s = '/'; 12.153 } 12.154 close(x->fd); 12.155 @@ -172,12 +186,12 @@ 12.156 i++; 12.157 if (!s) break; 12.158 if (strhead(s,"kernel=") == 0) { 12.159 - s += 7; 12.160 + s++; 12.161 set_kernel: 12.162 + s += 6; 12.163 kernel_name = s; 12.164 } 12.165 else if (strhead(s,"image=") == 0) { 12.166 - s += 6; 12.167 goto set_kernel; 12.168 } 12.169 else if (strhead(s,"initrd=") == 0) {
13.1 --- a/linld/stuff/src/VCPI.ASM Sat Mar 04 22:10:01 2017 +0100 13.2 +++ b/linld/stuff/src/VCPI.ASM Sun Mar 05 13:22:08 2017 +0100 13.3 @@ -411,9 +411,11 @@ 13.4 global _vm2rm:near 13.5 proc _vm2rm near 13.6 13.7 + p8086 13.8 extrn _vcpi:byte 13.9 test [_vcpi],-1 13.10 jz @@ret 13.11 + p386 13.12 push si 13.13 ;;pushf 13.14 ;;pushad
14.1 --- a/linld/stuff/src/_BEG.ASM Sat Mar 04 22:10:01 2017 +0100 14.2 +++ b/linld/stuff/src/_BEG.ASM Sun Mar 05 13:22:08 2017 +0100 14.3 @@ -12,6 +12,10 @@ 14.4 14.5 segment _TEXT byte public use16 'CODE' 14.6 14.7 + macro cpuid 14.8 + db 0fh,0A2h 14.9 + endm 14.10 + 14.11 org 100h 14.12 global _text_start:byte 14.13 label _text_start byte 14.14 @@ -46,6 +50,25 @@ 14.15 js endcpu 14.16 endif 14.17 p386 14.18 + ifdef EXTRA 14.19 + pushfd 14.20 + pop dx 14.21 + pop ax 14.22 + mov bl,al 14.23 + xor al,20h ; toggle CPUID feature bit 21 14.24 + push ax 14.25 + push dx 14.26 + popfd 14.27 + pushfd 14.28 + pop dx 14.29 + pop ax 14.30 + xor al,bl ; clear C 14.31 + je @@check_vm ; CPUID feature bit changed ? 14.32 + mov eax,80000001h ; Extended Processor Info and Feature Bits 14.33 + cpuid 14.34 + mov [_cpu_features],edx 14.35 +@@check_vm: 14.36 + endif 14.37 ; Check for vm 14.38 smsw ax ;SMSW cannot be trapped! :-) 14.39 and al,1 ;MSW_PE 14.40 @@ -58,15 +81,18 @@ 14.41 label check_vcpi near 14.42 push ds 14.43 ; Check whether it is safe to call 67h (we trust only known EMM managers) 14.44 - push 0 14.45 + xor bx,bx 14.46 + push bx 14.47 pop ds 14.48 mov ds,[word 67h*4+2] 14.49 - cmp [dword 10+4],'0XXX' 14.50 + cmp [dword bx+10+4],'0XXX' 14.51 jne skip 14.52 - mov eax,'XMME' 14.53 - xor eax,[dword 10] 14.54 + ;mov eax,'XMME' 14.55 + ;xor eax,[dword bx+10] 14.56 ; QMME also works (as told by <J.S.Peatfield@damtp.cambridge.ac.uk>) 14.57 - shl eax,8 14.58 + ;shl eax,8 14.59 + mov ax,'ME' 14.60 + xor ax,[word bx+10] 14.61 skip: 14.62 pop ds 14.63 jne no_vcpi 14.64 @@ -222,6 +248,10 @@ 14.65 segment _BSS byte public use16 'BSS' 14.66 global _bss_start:byte 14.67 label _bss_start byte 14.68 + ifdef EXTRA 14.69 + global _cpu_features:dword 14.70 +_cpu_features dd ? 14.71 + endif 14.72 ends _BSS 14.73 14.74 end _text_start