wok-current rev 23996
linld: add iso support
line diff
1.1 --- a/linld/receipt Wed Dec 16 17:23:49 2020 +0000 1.2 +++ b/linld/receipt Fri Jan 08 20:15:35 2021 +0000 1.3 @@ -33,9 +33,6 @@ 1.4 d: 1.5 cd linld$SUFFIX 1.6 $(cat LINLD$SUFFIX/!COMPILE.BAT) 1.7 -cd .. 1.8 -cd tazboot 1.9 -$(cat TAZBOOT/!COMPILEX.BAT) 1.10 EOT 1.11 SDL_VIDEODRIVER=dummy dosbox MAKE.BAT -exit -c "mount D $src" \ 1.12 2>&1 | grep -v 'ALSA lib' 1.13 @@ -46,19 +43,8 @@ 1.14 grep '^Warning[ :]' */LNK.LOG */CPP.LOG 1.15 grep '*Warning*' */*.LST 1.16 cp LINLD$SUFFIX/LINLD.COM linld.com 1.17 - cp LINLD$SUFFIX/HEADER.COM header.com 1.18 - cp TAZBOOT/TAZBOOT.COM tazboot.com 1.19 - dd count=$((0x$(sed '/ FOLD/!d;s|.*:||;s| .*||;q' LINLD$SUFFIX/ISOBOOT.MAP) - 0x100)) \ 1.20 - if=LINLD$SUFFIX/ISOBOOT.COM bs=1 > isoboot.com 1.21 - dd skip=$((0x$(sed '/ UNFOLD/!d;s|.*:||;s| .*||;q' LINLD$SUFFIX/ISOBOOT.MAP) - 0x100)) \ 1.22 - if=LINLD$SUFFIX/ISOBOOT.COM bs=1 >> isoboot.com 1.23 objdump -D -b binary -mi386 -Maddr16,data16 --adjust-vma=0x100 \ 1.24 linld.com > linld.lst 1.25 - linld=linld.com 1.26 - [ $(stat -c %s $linld) -le 4096 ] && ls -l $linld && linld= 1.27 - for f in $linld tazboot.com ; do 1.28 - upx -qq --ultra-brute --8086 $f 1.29 - done 1.30 cc -o tobzimage.o -Wa,-algms=tobzimage.lst -c $stuff/tobzimage.S 1.31 objcopy -O binary tobzimage.o tobzimage.bin 1.32 cp $stuff/tobzimage .
2.1 --- a/linld/stuff/src/!COMPILE.BAT Wed Dec 16 17:23:49 2020 +0000 2.2 +++ b/linld/stuff/src/!COMPILE.BAT Fri Jan 08 20:15:35 2021 +0000 2.3 @@ -12,7 +12,5 @@ 2.4 mawk -f pipehole.awk LOAD.ASO > LOAD.ASM 2.5 mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM 2.6 mawk -f pipehole.awk ISO9660.ASO > ISO9660.ASM 2.7 -tasm /la /m /dISOHOOK /dMOVE_SETUP /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log 2.8 +tasm /la /m /dISOHOOK /dBIG_CMDLINE /dMOVE_SETUP /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log 2.9 tlink /m /s /t @link.cmd > lnk.log 2.10 -tlink /m /s /t @link2.cmd > lnk2.log 2.11 -tlink /m /s /t @header.cmd > header.log
3.1 --- a/linld/stuff/src/!COMPILEX.BAT Wed Dec 16 17:23:49 2020 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,13 +0,0 @@ 3.4 -path ..\BC31;..;%PATH% 3.5 -call !clean.bat 3.6 -bcc @bccopt.opt -S -mt -DEXTRA -DMOVE_SETUP -DLARGE_IMAGES *.cpp > cpp.log 3.7 -ren TAZBOOT.ASM TAZBOOT.ASO 3.8 -ren LOAD.ASM LOAD.ASO 3.9 -ren HIMEM.ASM HIMEM.ASO 3.10 -ren ISO9660.ASM ISO9660.ASO 3.11 -mawk -f pipehole.awk TAZBOOT.ASO > TAZBOOT.ASM 3.12 -mawk -f pipehole.awk LOAD.ASO > LOAD.ASM 3.13 -mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM 3.14 -mawk -f pipehole.awk ISO9660.ASO > ISO9660.ASM 3.15 -tasm /la /m /dMOVE_SETUP /dEXTRA /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log 3.16 -tlink /m /s /t @linkx.cmd > lnk.log
4.1 --- a/linld/stuff/src/A20.ASM Wed Dec 16 17:23:49 2020 +0000 4.2 +++ b/linld/stuff/src/A20.ASM Fri Jan 08 20:15:35 2021 +0000 4.3 @@ -16,11 +16,13 @@ 4.4 global die:near 4.5 enable_a20_methods: 4.6 dw _enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die 4.7 -msg_a20 db "Can't use A20",0 4.8 +msg_a20 db "A20 broken",0 4.9 extrn overflow:byte 4.10 ifdef NO386 4.11 -bzimage86 db "8086 & bzImage",0 4.12 +bzimage86 db "8086 " 4.13 endif 4.14 + global _bzimagestr:byte 4.15 +_bzimagestr db "bzImage",0 4.16 global sssp:dword 4.17 global _initrd_desc:dword 4.18 _initrd_desc dd 90000218h 4.19 @@ -109,7 +111,7 @@ 4.20 mov cl,4 4.21 shr ax,cl 4.22 mov dx,cs 4.23 - add dx,ax 4.24 + add dx,ax ; last used segment 4.25 mov cx,0fffh 4.26 extrn _pm_low:byte 4.27 test [_pm_low],cl 4.28 @@ -124,7 +126,7 @@ 4.29 xchg ax,dx 4.30 cmp ax,cx 4.31 jae @sys@ok 4.32 - xchg ax,cx 4.33 + xchg ax,cx ; segment min 1000h 4.34 @sys@ok: 4.35 inc ax 4.36 extrn N_LXLSH@4:near 4.37 @@ -142,13 +144,13 @@ 4.38 sbb dx,cx 4.39 endif 4.40 mov cl,12 4.41 - shl dx,cl 4.42 - jc @jbe_overflow 4.43 + shl dx,cl ; last segment 4.44 + jc @jbe_overflow ; >= 1Mb ? 4.45 @bzimage: 4.46 extrn _topseg:near 4.47 call near _topseg 4.48 mov [word sssp+2],ax 4.49 - and ch,0 4.50 + and ch,0 ; vcpi flag 4.51 org $-1 4.52 global _vcpi:byte 4.53 _vcpi db ? 4.54 @@ -157,14 +159,14 @@ 4.55 movzx eax,[word _heap_top] 4.56 shr ax,4 4.57 mov dx,cs 4.58 - add ax,dx 4.59 + add ax,dx ; last used segment 4.60 mov cx,0fffh 4.61 extrn _pm_low:byte 4.62 test [_pm_low],cl 4.63 je @bzimage 4.64 cmp ax,cx 4.65 jae @sys@ok 4.66 - xchg ax,cx 4.67 + xchg ax,cx ; segment min 1000h 4.68 @sys@ok: 4.69 inc ax 4.70 shl eax,4 4.71 @@ -186,7 +188,7 @@ 4.72 extrn _vcpi:byte 4.73 and ch,[_vcpi] 4.74 endif 4.75 - add dh,ch ; room for malloc_bufv_or_die 4.76 + add dh,ch ; 60k room for malloc_bufv_or_die 4.77 cmp ax,dx 4.78 les cx,[bx] ; rm_size 4.79 mov si,es ; rm_buf 4.80 @@ -240,16 +242,17 @@ 4.81 mov cx,0FFFFh 4.82 mov es,cx 4.83 a20lp: 4.84 - cli 4.85 - mov ax,0AA55h 4.86 - xchg al,[bx] 4.87 - xchg ah,[es:bx+10h] 4.88 - xchg al,[bx] 4.89 - xchg ah,[es:bx+10h] 4.90 + cli ; A20 off A20 on 4.91 + mov ax,0AA55h ; al ah [bx] al ah [bx] es:[bx+10h] 4.92 + xchg al,[bx] ; ?? AA 55 ?1 AA 55 ?2 4.93 + xchg ah,[es:bx+10h] ; ?? 55 AA ?1 ?2 55 AA 4.94 + xchg al,[bx] ; AA 55 ?? 55 ?2 ?1 AA 4.95 cmp al,55h 4.96 sti 4.97 + loopne a20lp 4.98 + jne a20ko 4.99 + xchg ah,[es:bx+10h] ; AA ?? 55 55 AA ?1 ?2 4.100 a20ko: 4.101 - loopne a20lp 4.102 ;xchg ax,cx 4.103 pop ds 4.104 ;ret
5.1 --- a/linld/stuff/src/COMMON.H Wed Dec 16 17:23:49 2020 +0000 5.2 +++ b/linld/stuff/src/COMMON.H Fri Jan 08 20:15:35 2021 +0000 5.3 @@ -44,9 +44,7 @@ 5.4 u32 remaining; 5.5 u32 buf; 5.6 u32 *bufv; 5.7 - const char *errmsg; 5.8 u32 chunk_size; 5.9 - void (*next_chunk)(struct image_himem *); 5.10 u16 state; 5.11 u16 fd2close; 5.12 } imgs[2]; 5.13 @@ -55,8 +53,19 @@ 5.14 #define pm2initrd(p) (p+1) 5.15 5.16 extern u8 pm_low; 5.17 -extern u32 base_himem; 5.18 + 5.19 extern u32 far *initrd_desc; 5.20 +#define cmdline (cmdstr[0]) 5.21 +#define kernel_name (cmdstr[1]) 5.22 +#define initrd_name (cmdstr[2]) 5.23 +#define isofile (cmdstr[3]) 5.24 +extern const char* cmdstr[4]; 5.25 + 5.26 +#define root_dev (cmdnum[0]) 5.27 +#define vid_mode (cmdnum[1]) // -3 = ask, -2 = Extended VGA, -1 = Normal VGA, n = as "n" was pressed 5.28 +#define topmem (cmdnum[2]) 5.29 +#define base_himem (cmdnum[3]) 5.30 +extern u32 cmdnum[4]; 5.31 5.32 extern _fastcall void memcpy_image(struct image_himem *m); 5.33 extern _fastcall void storepage(u32 *dst); 5.34 @@ -73,17 +82,10 @@ 5.35 #endif 5.36 extern char vcpi; 5.37 extern char version_string[]; 5.38 -extern const char* kernel_name; 5.39 -extern const char* initrd_name; 5.40 -extern const char* cmdline; 5.41 -extern u32 root_dev; 5.42 -extern u32 vid_mode; 5.43 // External asm helpers 5.44 #ifdef WITH_XMM_ALLOC 5.45 -extern u16 skip_alloc; 5.46 extern _fastcall void xmm_alloc(struct image_himem *m); 5.47 #endif 5.48 -extern u32 topmem; 5.49 extern "C" u32 memtop(); 5.50 extern "C" void enable_a20_or_die(); 5.51 extern "C" void vm2rm();
6.1 --- a/linld/stuff/src/CRTL.ASM Wed Dec 16 17:23:49 2020 +0000 6.2 +++ b/linld/stuff/src/CRTL.ASM Fri Jan 08 20:15:35 2021 +0000 6.3 @@ -17,71 +17,44 @@ 6.4 6.5 segment _DATA byte public use16 'DATA' 6.6 6.7 +loaderr db "Load failure",0 6.8 msg_hang db "Himem broken",0 6.9 vcpi_alloc_err db "VCPI" 6.10 global overflow:byte 6.11 overflow db "/" 6.12 -msg_malloc db "Out of memory",0 6.13 +msg_malloc db "Out of memory" 6.14 +isorootofs dd 16*2048 6.15 6.16 ends _DATA 6.17 6.18 segment _BSS byte public use16 'BSS' 6.19 6.20 - ifdef EXTRA 6.21 include "isostate.inc" 6.22 public _isostate 6.23 _isostate isostate <?> 6.24 org $-7 6.25 - endif 6.26 _xfer_buf db 4096 dup (?) 6.27 filecnt db ? ; in fact 0 minus file count... 6.28 nextfilename dw ? 6.29 - ifdef EXTRA 6.30 -utoabuf db 6 dup (?) 6.31 - endif 6.32 6.33 ends _BSS 6.34 6.35 segment _TEXT byte public use16 'CODE' 6.36 6.37 ;*************************************************************** 6.38 -;_fastcall void strcpy(bx:const char* a, ax:const char* b); 6.39 -;_fastcall void strcat(bx:const char* a, ax:const char* b); 6.40 ;_fastcall void strcatb(bx:const char* a, ax:const char* b); 6.41 ;*************************************************************** 6.42 - ifdef EXTRA 6.43 - global @strcat$qpxzct1:near 6.44 -@strcat$qpxzct1: 6.45 - mov cx,1h 6.46 - db 0bah ; mov dx,imm opcode 6.47 - endif 6.48 global @strcatb$qpxzct1:near 6.49 proc @strcatb$qpxzct1 near 6.50 6.51 - ifdef EXTRA 6.52 - mov cl,7Fh 6.53 - db 0bah ; mov dx,imm opcode 6.54 - global @strcpy$qpxzct1:near 6.55 -@strcpy$qpxzct1: 6.56 - xor cx,cx 6.57 - endif 6.58 push si 6.59 xchg ax,si ; b 6.60 - ifdef EXTRA 6.61 - jcxz @@nocat 6.62 - endif 6.63 dec bx 6.64 @@catlp: 6.65 inc bx 6.66 cmp [byte bx],0 ; a=bx 6.67 jne @@catlp 6.68 - ifdef EXTRA 6.69 - mov al,20h 6.70 - loop @@cpyhead 6.71 - else 6.72 db 0b8h,20h ; mov ax,??20h 6.73 - endif 6.74 -@@nocat: 6.75 @@cpylp: 6.76 lodsb 6.77 @@cpyhead: 6.78 @@ -89,80 +62,51 @@ 6.79 inc bx 6.80 or al,al 6.81 jne @@cpylp 6.82 - ifdef EXTRA 6.83 -strfound: 6.84 - xchg ax,dx 6.85 - endif 6.86 strend: 6.87 pop si 6.88 - global @ret:near 6.89 @ret: 6.90 ret 6.91 6.92 endp @strcatb$qpxzct1 6.93 6.94 6.95 - ifdef EXTRA 6.96 p8086 6.97 -;*************************************************************** 6.98 -;_fastcall int strstr(bx:const char* a, ax:const char* b); 6.99 -;*************************************************************** 6.100 - global @strstr$qpxzct1:near 6.101 - proc @strstr$qpxzct1 near 6.102 6.103 - xchg ax,cx ; b 6.104 - mov dx,bx ; a 6.105 - push si 6.106 -@@loop: 6.107 - xor ax,ax 6.108 - mov si,dx 6.109 - cmp [si],al ; *a 6.110 - jz strend ; return ax = NULL 6.111 - mov bx,cx 6.112 -@@match: 6.113 - or ah,[bx] ; *b 6.114 - jz strfound 6.115 - inc bx 6.116 - lodsb 6.117 - sub ah,al 6.118 - jz @@match 6.119 - inc dx 6.120 - jmp @@loop 6.121 - 6.122 - endp @strstr$qpxzct1 6.123 - 6.124 - 6.125 -;*************************************************************** 6.126 -;_fastcall int strcmp(bx:const char* a, ax:const char* b); 6.127 -;*************************************************************** 6.128 - global @strcmp$qpxzct1:near 6.129 - proc @strcmp$qpxzct1 near 6.130 - 6.131 - ifdef USE_ARGSTR 6.132 -@@loop: 6.133 +opendos: 6.134 + ifdef LONG_FILENAME 6.135 + xchg ax,cx ; attributes 6.136 + mov ax,716Ch 6.137 + push bx si 6.138 + mov si,bx 6.139 + xor bx,bx ; R/O 6.140 + cwd ; action = open 6.141 + stc 6.142 + int 21h 6.143 + pop si dx 6.144 + jnc openok 6.145 + mov ax,3d00h ; read-only+compatibility 6.146 + else 6.147 + mov ah,3dh ; read-only+compatibility 6.148 + mov dx,bx 6.149 + endif 6.150 + ;mov cl,0 ; attribute mask 6.151 + call dos 6.152 + jc openret 6.153 +openok: 6.154 xchg ax,bx 6.155 - mov cl,[bx] ; cl = *b++ 6.156 - inc bx 6.157 + mov ax,4202h 6.158 + cwd 6.159 + xor cx,cx 6.160 + int 21h 6.161 + mov [word _isostate.filesize],ax 6.162 + mov [(word _isostate.filesize)+2],dx 6.163 xchg ax,bx 6.164 - cmp cl,[bx] ; cl ?= *a++ 6.165 - jnz fail ; return -1 6.166 - inc bx 6.167 - or cl,cl ; clear C 6.168 - jz failifc ; return 0 6.169 - jmp @@loop 6.170 - 6.171 - else 6.172 - 6.173 - call @strhead$qpxzct1 6.174 - jne closeret ; return -1 6.175 - cmp cl,[bx] 6.176 - jmp failifc ; return 0 or -1 6.177 - 6.178 - endif 6.179 - 6.180 - endp @strcmp$qpxzct1 6.181 - endif 6.182 - 6.183 + ;xor cx,cx 6.184 + cwd 6.185 + call seeksetpos0 ; filepos = 0 6.186 + xchg ax,bx ; fd 6.187 +openret: 6.188 + ret 6.189 6.190 ;*************************************************************** 6.191 ;_fastcall int open(bx:const char* name, int flags=O_RDONLY); 6.192 @@ -175,34 +119,18 @@ 6.193 inc bx 6.194 6.195 global @open$qpxzc:near 6.196 - proc @open$qpxzc near 6.197 - 6.198 -open: ; open(bx) 6.199 - ifdef ISOHOOK 6.200 - extrn iso_open_hack:word 6.201 - jmp [iso_open_hack] 6.202 - global __open:near 6.203 -__open: 6.204 - endif 6.205 - ifdef LONG_FILENAME 6.206 - mov ax,716Ch 6.207 - push bx si 6.208 - mov si,bx 6.209 - xor bx,bx ; R/O 6.210 - xor cx,cx ; attributes 6.211 - cwd ; action = open 6.212 - stc 6.213 - int 21h 6.214 - pop si dx 6.215 - jnc doret 6.216 - else 6.217 - mov dx,bx 6.218 - endif 6.219 - mov ax,3d00h ; read-only+compatibility 6.220 - ;mov cl,0 ; attribute mask 6.221 - jmp dos 6.222 - 6.223 - endp @open$qpxzc 6.224 +@open$qpxzc: 6.225 + mov ax,[_isostate.fd] 6.226 + or ax,ax 6.227 + je opendos 6.228 +openiso: 6.229 + ifdef ISOHOOK 6.230 + cmp [byte bx],'!' 6.231 + je @readmenu$qv 6.232 + endif 6.233 + extrn @_isoopen$qv:near 6.234 + mov [word _isostate.filename2open],bx 6.235 + jmp @_isoopen$qv ; filepos = 0 6.236 6.237 6.238 ;*************************************************************** 6.239 @@ -222,60 +150,53 @@ 6.240 global close:near ; close(ax) 6.241 close: 6.242 mov bh,3Eh 6.243 - ifdef ISOHOOK 6.244 - extrn iso_close_hack:word 6.245 - jmp [iso_close_hack] 6.246 - endif 6.247 - global dosbx:near 6.248 -dosbx: 6.249 - xchg ax,bx 6.250 - or bx,bx 6.251 - jnz dos 6.252 -closeret: 6.253 - ret 6.254 + mov cx,[_isostate.fd] 6.255 + jcxz dosbx 6.256 + jmp fail 6.257 6.258 endp @close$qi 6.259 6.260 6.261 ;*************************************************************** 6.262 -;_fastcall int readrm(di:struct himem *m, ax:int sz); 6.263 -;_fastcall int read(ax:int fd, bx:void* data, dx:int sz); 6.264 -;_fastcall int write(ax:int fd, bx:const void* data, dx:int sz); 6.265 +;_fastcall int readrm(si:struct himem *m, ax:int sz); 6.266 ;*************************************************************** 6.267 global @readrm$qp11image_himemi:near 6.268 @readrm$qp11image_himemi: 6.269 xchg ax,dx ; sz 6.270 - mov ax,[di] ; fd 6.271 - mov bx,[di-2] ; data 6.272 - global @read$qipvi:near 6.273 + mov ax,[si] ; fd 6.274 + mov bx,[si-2] ; data 6.275 proc @read$qipvi near 6.276 6.277 - ifdef WRITE 6.278 - stc 6.279 - db 0B0h ; mov al,im 6.280 - global @write$qipvi:near 6.281 -@write$qipvi: 6.282 - clc 6.283 - endif 6.284 @read$dxbxax: 6.285 xchg ax,bx ; fd 6.286 +@read$dxaxbx: 6.287 xchg ax,dx ; data 6.288 xchg ax,cx ; sz 6.289 - ifdef WRITE 6.290 - mov ah,40h 6.291 - sbb ah,0 6.292 - else 6.293 global @read$cxdxbx:near 6.294 @read$cxdxbx: 6.295 + push bx 6.296 + mov bx,offset _isostate.filepos 6.297 + push cx 6.298 + mov cx,[bx-4] ; filesize 6.299 + sub cx,[bx] ; filepos 6.300 + mov ax,[bx-2] 6.301 + sbb ax,[bx+2] 6.302 + pop ax 6.303 + ja @@axok 6.304 + ;je @@rem 6.305 + ;xor ax,ax 6.306 +@@rem: 6.307 + cmp cx,ax 6.308 + jb @@cxok 6.309 +@@axok: 6.310 + xchg ax,cx 6.311 +@@cxok: 6.312 + add [bx],cx 6.313 + adc [(word bx)+2],0 6.314 + pop bx 6.315 +readfd: 6.316 mov ah,3Fh 6.317 - endif 6.318 - jcxz fail 6.319 - ifdef ISOHOOK 6.320 -;_fastcall int read(bx:int fd, dx:void* data, cx:int sz, ah=3Fh); 6.321 - extrn iso_read_hack:word 6.322 - jmp [iso_read_hack] ; or ret 6.323 - endif 6.324 - global dos:near 6.325 + ;jcxz fail 6.326 dos: 6.327 int 21h 6.328 jnc doret 6.329 @@ -283,13 +204,7 @@ 6.330 stc 6.331 failifc: 6.332 sbb ax,ax ; ax=-1 CF 6.333 - cwd 6.334 doret: 6.335 - ifndef NO386 6.336 - push dx ; see next_chunk:lseek 6.337 - push ax 6.338 - pop eax 6.339 - endif 6.340 ret 6.341 6.342 endp @read$qipvi 6.343 @@ -301,99 +216,120 @@ 6.344 global @rewind$qi:near ; fd=ax 6.345 proc @rewind$qi near 6.346 6.347 - ifdef EXTRA ; catch ISO image case 6.348 - stc 6.349 - mov dx,-512 ; curpos = 512, see LOAD.CPP 6.350 - mov bl,1 6.351 - jmp lseekword 6.352 - endif 6.353 -rewind: ; rewind(ax) 6.354 - mov bl,0 6.355 -lseek0: ; lseek0(ax,bl=dir) 6.356 - xor dx,dx ; clear C 6.357 -lseekword: 6.358 - sbb cx,cx 6.359 -lseekset: 6.360 - mov bh,42h ; bx=fd cx:dx=offset al=whence 6.361 - ifdef ISOHOOK 6.362 -;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence, bh=42h); 6.363 - extrn iso_lseek_hack:word 6.364 - jmp [iso_lseek_hack] 6.365 - else 6.366 - jmp dosbx 6.367 - endif 6.368 +rewind: 6.369 + mov bx,offset _isostate.fileofs 6.370 + jmp lseek 6.371 6.372 endp @rewind$qi 6.373 6.374 - ifdef EXTRA 6.375 + 6.376 + ifdef ISOHOOK 6.377 +;*************************************************************** 6.378 +;_fastcall void readmenu(void); 6.379 +;*************************************************************** 6.380 + proc @readmenu$qv near 6.381 + 6.382 + mov dx,18 6.383 + xor cx,cx 6.384 + call seeksetpos0 ; filepos = 0 6.385 + mov dx,offset _isostate.filemod 6.386 + ; //magic = x->filemod; 6.387 + mov cl,10 6.388 + call readfd ; // read x->filemod + x->fileofs & x->filesize 6.389 + mov bx,offset _isostate.fileofs 6.390 + ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 6.391 + mov ax,7FF0h 6.392 + cwd 6.393 + mov [word bx+6],dx 6.394 + sub ax,[bx+4] 6.395 + mov [word bx+2],dx 6.396 + mov [bx],ax 6.397 + call isolseek ; filepos = 0 6.398 + xchg ax,bx ; fd 6.399 + ret 6.400 + 6.401 + endp @readmenu$qv 6.402 + endif 6.403 + 6.404 ;*************************************************************** 6.405 ;_fastcall void isolseek(bx:const unsigned long *offset); 6.406 -;_fastcall long lseekset2(ax:int fd, bx:unsigned long* offset); 6.407 ;*************************************************************** 6.408 global @isolseek$qpxul:near 6.409 proc @isolseek$qpxul near 6.410 6.411 isolseek: 6.412 mov ax,[_isostate.fd] 6.413 - global @lseekset2$qipul:near 6.414 -@lseekset2$qipul: 6.415 +lseek: 6.416 les dx,[dword bx] 6.417 mov cx,es 6.418 - mov bl,0 6.419 - jmp lseekset 6.420 +seeksetpos0: 6.421 + xor bx,bx 6.422 + mov [word _isostate.filepos],bx 6.423 + mov [(word _isostate.filepos)+2],bx 6.424 + mov bh,42h ; bx=fd cx:dx=offset al=whence 6.425 +dosbx: 6.426 + xchg ax,bx 6.427 + jmp dos 6.428 6.429 endp @isolseek$qpxul 6.430 6.431 ;*************************************************************** 6.432 ;_fastcall int isoreadsector(bx:const unsigned long *offset); 6.433 +;_fastcall int isoreadrootsector(void); 6.434 ;*************************************************************** 6.435 + global @isoreadrootsector$qv:near 6.436 +@isoreadrootsector$qv: 6.437 + mov bx,offset isorootofs 6.438 global @isoreadsector$qpxul:near 6.439 proc @isoreadsector$qpxul near 6.440 6.441 - call isolseek 6.442 + call isolseek ; filepos = 0 6.443 jc fail 6.444 - mov dx,2560 6.445 - mov bx,offset _isostate.buffer 6.446 - mov ax,[_isostate.fd] 6.447 - jmp @read$dxbxax ; read(fd,buffer,2560) 6.448 + mov dh,10 6.449 + mov ax,offset _isostate.buffer 6.450 + jmp @read$dxaxbx ; read(fd,buffer,2560+) 6.451 6.452 endp @isoreadsector$qpxul 6.453 6.454 6.455 ;*************************************************************** 6.456 -;_fastcall int isoreset(bx:const char *name); 6.457 +;_fastcall int strhead(bx:const char* a, ax:const char* b); 6.458 ;*************************************************************** 6.459 - global @isoreset$qpzc:near 6.460 - proc @isoreset$qpzc near 6.461 + global @strhead$qpxzct1:near 6.462 + proc @strhead$qpxzct1 near 6.463 6.464 - or bx,bx 6.465 - jz fail 6.466 - call near ptr @open$qpxzc 6.467 - mov [_isostate.fd],ax 6.468 - extrn @isoroot$qv:near 6.469 - jmp @isoroot$qv 6.470 +@@loop: 6.471 + xchg ax,bx 6.472 + mov dl,[bx] ; dl = *b++ 6.473 + inc bx 6.474 + xchg ax,bx 6.475 + or dl,dl ; clear C 6.476 + jz failifc ; return 0 6.477 + xor dl,[bx] ; dl -= *a++ 6.478 + jne fail ; return -1 6.479 + inc bx 6.480 + jmp @@loop 6.481 6.482 - endp @isoreset$qpzc 6.483 + endp @strhead$qpxzct1 6.484 6.485 6.486 ;*************************************************************** 6.487 -;_fastcall int isoopen(bx:const char *name); 6.488 +;_fastcall int strcmp(bx:const char* a, ax:const char* b); 6.489 ;*************************************************************** 6.490 - global @isoopen$qpxzc:near 6.491 - proc @isoopen$qpxzc near 6.492 + global @strcmp$qpxzct1:near 6.493 + proc @strcmp$qpxzct1 near 6.494 6.495 - extrn @_isoopen$qv:near 6.496 - mov [_isostate.filename2open],bx 6.497 - jmp @_isoopen$qv 6.498 + call @strhead$qpxzct1 6.499 + jne fail ; return -1 6.500 + xor dl,[bx] ; clear C 6.501 + jne fail ; return -1 6.502 + jmp failifc ; return 0 6.503 6.504 - endp @isoopen$qpxzc 6.505 + endp @strcmp$qpxzct1 6.506 6.507 - endif 6.508 6.509 - 6.510 - ifdef USE_ARGSTR 6.511 ;*************************************************************** 6.512 -;_fastcall const char ** argstr(bx:const char *s, ax:const char keywords[], dx:const char **var); 6.513 +;_fastcall const char **argstr(bx:const char *s, ax:const char keywords[], dx:const char **var); 6.514 ;_fastcall unsigned long *argnum(bx:char *s, ax:const char keywords[], dx:unsigned long *var); 6.515 ;*************************************************************** 6.516 global @argstr$qpxzcxt1ppxzc:near 6.517 @@ -428,13 +364,6 @@ 6.518 cmp [byte bx],'-' 6.519 je @@match 6.520 @@notopt: 6.521 - ifdef EXTRA 6.522 - cmp [byte bx],'/' 6.523 - jne @@notalt 6.524 - or al,al ; 1st loop ? 6.525 - js @@testalt 6.526 -@@notalt: 6.527 - endif 6.528 cmp [byte bx],'|' 6.529 je @@test 6.530 cmp [byte bx],dh 6.531 @@ -451,13 +380,12 @@ 6.532 cmp al,'=' 6.533 ;je @@found 6.534 ;cmp al,0 ; eos, si=next argv 6.535 - mov ax,-1 6.536 + xchg ax,cx ; return s if failure 6.537 jne @@nokeyword 6.538 @@found: 6.539 dec dx 6.540 dec dx 6.541 je @@done 6.542 - ;mov bx,si 6.543 call @strtol$qpxzc 6.544 xchg ax,si 6.545 mov [di+2],dx 6.546 @@ -470,30 +398,33 @@ 6.547 6.548 endp @argstr$qpxzcxt1ppxzc 6.549 6.550 - else 6.551 +;*************************************************************** 6.552 +;_fastcall void puts(bx:const char* s): 6.553 +;*************************************************************** 6.554 + global @puts$qpxzc:near 6.555 6.556 -;*************************************************************** 6.557 -;_fastcall int strhead(bx:const char* a, ax:const char* b); 6.558 -;*************************************************************** 6.559 - global @strhead$qpxzct1:near 6.560 - proc @strhead$qpxzct1 near 6.561 +; global puts:near ; puts(bx) 6.562 +@putsz: 6.563 + call @putc 6.564 +@puts$qpxzc: 6.565 +puts: 6.566 + mov dl,[bx] 6.567 + inc bx 6.568 + or dl,dl 6.569 + jne @putsz 6.570 + mov dl,10 6.571 +@putc: 6.572 + cmp dl,10 6.573 + jne @putcz 6.574 + call @putcz2 6.575 +@putcz2: 6.576 + xor dl,7 ; 10^13 1010^1101 6.577 +@putcz: 6.578 + mov ah,2 6.579 +do_int21h: 6.580 + int 21h 6.581 + ret 6.582 6.583 -@@loop: 6.584 - xchg ax,bx 6.585 - mov cl,[bx] ; cl = *b++ 6.586 - inc bx 6.587 - xchg ax,bx 6.588 - or cl,cl ; clear C 6.589 - jz failifc ; return 0 6.590 - xor cl,[bx] ; cl -= *a++ 6.591 - inc bx 6.592 - and cl,0dfh ; case insensitive 6.593 - jne fail ; return -1 6.594 - jmp @@loop 6.595 - 6.596 - endp @strhead$qpxzct1 6.597 - 6.598 - endif 6.599 6.600 include "himem.inc" 6.601 6.602 @@ -504,11 +435,9 @@ 6.603 xchg ax,[bx] 6.604 ret 6.605 6.606 - global @malloc_or_die$qui:near 6.607 proc @malloc_or_die$qui near 6.608 6.609 - global malloc_or_die:near ; ax = malloc_or_die(ax) 6.610 -malloc_or_die: 6.611 +malloc_or_die: ; ax = malloc_or_die(ax) 6.612 extrn _heap_top 6.613 mov bx,offset _heap_top 6.614 add ax,[bx] 6.615 @@ -547,98 +476,108 @@ 6.616 endp @die$qpxzc 6.617 6.618 ;*************************************************************** 6.619 -;_fastcall void puts(bx:const char* s): 6.620 +;_fastcall void open_image(si:struct image_himem *m, ax:const char *name); 6.621 ;*************************************************************** 6.622 - global @puts$qpxzc:near 6.623 6.624 -; global puts:near ; puts(bx) 6.625 -@putsz: 6.626 - call @putc 6.627 -@puts$qpxzc: 6.628 -puts: 6.629 - mov dl,[bx] 6.630 - inc bx 6.631 - or dl,dl 6.632 - jne @putsz 6.633 - mov dl,10 6.634 -@putc: 6.635 - cmp dl,10 6.636 - jne @putcz 6.637 - call @putcz2 6.638 -@putcz2: 6.639 - xor dl,7 ; 10^13 1010^1101 6.640 -@putcz: 6.641 - mov ah,2 6.642 -do_int21h: 6.643 - int 21h 6.644 - ret 6.645 + global @open_image$qp11image_himempxzc:near 6.646 + proc @open_image$qp11image_himempxzc near 6.647 + 6.648 + mov [(image_himem si).state],ax 6.649 + push ax 6.650 +@@next: 6.651 + call next_chunk 6.652 + ifndef NO386 6.653 + add eax,3 6.654 + and al,0FCh 6.655 + add [(image_himem si).size],eax ; m->size += m->chunk_size 6.656 + or eax,eax 6.657 + else 6.658 + add ax,3 6.659 + adc dx,0 6.660 + and al,0FCh 6.661 + add [word (image_himem si).size],ax ; m->size += m->chunk_size 6.662 + adc [word ((image_himem si).size)+2],dx 6.663 + or ax,dx 6.664 + endif 6.665 + jnz @@next 6.666 + pop [(image_himem si).state] 6.667 + 6.668 + endp @open_image$qp11image_himempxzc 6.669 6.670 6.671 ;*************************************************************** 6.672 -;static long next_chunk(struct image_himem *di); 6.673 +;static long next_chunk(struct image_himem *si); 6.674 ;*************************************************************** 6.675 proc next_chunk near 6.676 6.677 - push si 6.678 - mov ax,[(image_himem di).fd] 6.679 + ifndef NO_CLOSE 6.680 + mov ax,[(image_himem si).fd] 6.681 call close 6.682 + endif 6.683 ifndef NO386 6.684 xor eax,eax 6.685 else 6.686 xor ax,ax 6.687 cwd 6.688 endif 6.689 - mov [(image_himem di).fd],ax 6.690 - mov bx,[(image_himem di).state] 6.691 + mov [(image_himem si).fd],ax 6.692 + mov bx,[(image_himem si).state] 6.693 cmp al,[bx] ; "" 6.694 jz @@end 6.695 - mov si,bx 6.696 + dec bx 6.697 + push di 6.698 @@scan: 6.699 - lodsb 6.700 - mov cx,si 6.701 - cmp al,',' 6.702 + inc bx 6.703 + mov al,[bx] 6.704 + mov di,bx 6.705 + or al,al 6.706 jz @@eos 6.707 - or al,al 6.708 + sub al,',' 6.709 jnz @@scan 6.710 - dec cx ; blocked to eos 6.711 + inc bx 6.712 @@eos: 6.713 - mov [(image_himem di).state],cx 6.714 - dec si 6.715 - push [word si] 6.716 - mov [byte si],ah ; set temp eos 6.717 - call open 6.718 - pop [word si] ; restore string 6.719 - jc jcdie 6.720 - mov [(image_himem di).fd],ax 6.721 - mov [(image_himem di).fd2close],ax 6.722 - mov bl,02h ; SEEK_END 6.723 - call lseek0 6.724 -jcdie: 6.725 - mov bx,[(image_himem di).errmsg] 6.726 - jc die 6.727 + xchg [(image_himem si).state],bx ; set start of string 6.728 + mov [current_file],bx 6.729 + xchg [di],ax ; set temp eos (ax == 0) 6.730 + push ax 6.731 + call @open$qpxzc 6.732 + pop [word di] ; restore string 6.733 + pop di 6.734 + jnc @@opened 6.735 +loadfailure: 6.736 +;*************************************************************** 6.737 +;_fastcall void loadfailure(void); 6.738 +;*************************************************************** 6.739 + global @loadfailure$qv:near 6.740 +@loadfailure$qv: 6.741 + mov bx,0 6.742 + org $-2 6.743 +current_file dw ? 6.744 + call puts 6.745 + mov bx,offset loaderr 6.746 +jmpdie: 6.747 + jmp die 6.748 +@@opened: 6.749 + mov [(image_himem si).fd],ax 6.750 + ifndef NO_CLOSE 6.751 + mov [(image_himem si).fd2close],ax 6.752 + endif 6.753 ifndef NO386 6.754 - push eax 6.755 - mov ax,[(image_himem di).fd] 6.756 - call rewind 6.757 - pop eax 6.758 + mov eax,[_isostate.filesize] 6.759 @@end: 6.760 - mov [(image_himem di).chunk_size],eax 6.761 + mov [(image_himem si).chunk_size],eax 6.762 else 6.763 - push ax 6.764 - push dx 6.765 - mov ax,[(image_himem di).fd] 6.766 - call rewind 6.767 - pop dx 6.768 - pop ax 6.769 + mov ax,[word _isostate.filesize] 6.770 + mov dx,[(word _isostate.filesize)+2] 6.771 @@end: 6.772 - mov [word (image_himem di).chunk_size],ax 6.773 - mov [word ((image_himem di).chunk_size)+2],dx 6.774 + mov [word (image_himem si).chunk_size],ax 6.775 + mov [word ((image_himem si).chunk_size)+2],dx 6.776 endif 6.777 - pop si 6.778 ret 6.779 6.780 endp next_chunk 6.781 6.782 +;*************************************************************** 6.783 6.784 ifdef LARGE_IMAGES 6.785 struc data_himem ;struct data_himem { 6.786 @@ -685,12 +624,12 @@ 6.787 mov [(image_himem si).bufv],ax 6.788 xchg ax,si 6.789 @@vcpi_alloc: 6.790 - mov ax,0DE04h 6.791 + mov ax,0DE04h ; allocate a 4K page => EDX 6.792 int 67h 6.793 or ah,ah 6.794 stc 6.795 mov bx,offset vcpi_alloc_err 6.796 - jnz jcdie 6.797 + jnz jmpdie 6.798 ; for (i = cnt-1; i >= 0; i--) 6.799 ifdef LARGE_IMAGES 6.800 mov eax,ecx 6.801 @@ -712,12 +651,11 @@ 6.802 jae @@vcpi_alloc 6.803 @@pmok: 6.804 ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again 6.805 - mov bx,offset _imgs.fallback+32 6.806 - add eax,[bx-2+2] ; +initrd.fallback 6.807 + add eax,[bx-2+2+32] ; +initrd.fallback 6.808 cmp eax,edx ; initrd.fallback+i*_4k > edx ? 6.809 ja @@initrdok 6.810 - mov eax,[bx-2+6] ; initrd.size 6.811 - add eax,[bx-2+2] ; +initrd.fallback 6.812 + mov eax,[bx-2+6+32] ; initrd.size 6.813 + add eax,[bx-2+2+32] ; +initrd.fallback 6.814 cmp eax,edx ; initrd.fallback+initrd.size > edx ? 6.815 @@jnc_vcpi_alloc: 6.816 ja @@vcpi_alloc 6.817 @@ -744,8 +682,8 @@ 6.818 lea cx,[(data_himem si).cache] 6.819 ifdef NO386 6.820 push edx 6.821 + pop ax ; to dx:ax 6.822 pop dx 6.823 - pop ax 6.824 endif 6.825 call storepage ; storepage(edx,cx) 6.826 pop cx 6.827 @@ -778,7 +716,6 @@ 6.828 global memcpy_image_kernel:near 6.829 memcpy_image_kernel: 6.830 mov bx,si 6.831 - global @memcpy_image$qp11image_himem:near 6.832 proc @memcpy_image$qp11image_himem near 6.833 6.834 ifndef NO386 6.835 @@ -813,7 +750,7 @@ 6.836 xor cx,cx 6.837 push cx 6.838 call_memcpy32: 6.839 - push dx 6.840 + push dx ; push dx:ax 6.841 push ax 6.842 ifdef LARGE_IMAGES 6.843 jmp @@memcpy 6.844 @@ -846,7 +783,7 @@ 6.845 mov edx,[di] 6.846 else 6.847 les ax,[dword di] 6.848 - mov dx,es 6.849 + mov dx,es ; to dx:ax 6.850 endif 6.851 mov cx,offset _xfer_buf 6.852 storepage: ; storepage(edx,cx) 6.853 @@ -945,106 +882,48 @@ 6.854 endif 6.855 6.856 ;*************************************************************** 6.857 -;_fastcall void open_image(bx:struct image_himem *m, ax:const char *name); 6.858 -;*************************************************************** 6.859 - 6.860 - global @open_image$qp11image_himempxzc:near 6.861 - proc @open_image$qp11image_himempxzc near 6.862 - 6.863 - push di 6.864 - xchg ax,bx 6.865 - xchg ax,di 6.866 - ifdef EXTRA 6.867 - cmp [(image_himem di).fd],0 ; iso image/kernel ? 6.868 - jnz @@alreadydone 6.869 - endif 6.870 - mov [(image_himem di).state],bx 6.871 - push bx 6.872 - ifdef EXTRA 6.873 - cmp [(image_himem di).next_chunk],0 ; iso image/initrd ? 6.874 - jnz @@next 6.875 - mov [(image_himem di).next_chunk],offset next_chunk 6.876 -@@next: 6.877 - ;push di 6.878 - call [(image_himem di).next_chunk] ; m->next_chunk() 6.879 - ;pop di 6.880 - else 6.881 -@@next: 6.882 - call next_chunk 6.883 - endif 6.884 - ifndef NO386 6.885 - add eax,3 6.886 - and al,0FCh 6.887 - add [(image_himem di).size],eax ; m->size += m->chunk_size 6.888 - or eax,eax 6.889 - else 6.890 - add ax,3 6.891 - adc dx,0 6.892 - and al,0FCh 6.893 - add [word (image_himem di).size],ax ; m->size += m->chunk_size 6.894 - adc [word ((image_himem di).size)+2],dx 6.895 - or ax,dx 6.896 - endif 6.897 - jnz @@next 6.898 - pop [(image_himem di).state] 6.899 - ifdef EXTRA 6.900 - ;push di 6.901 - call [(image_himem di).next_chunk] ; m->next_chunk() 6.902 - ;pop di 6.903 - else 6.904 - call next_chunk 6.905 - endif 6.906 -@@alreadydone: 6.907 - pop di 6.908 - ret 6.909 - 6.910 - endp @open_image$qp11image_himempxzc 6.911 - 6.912 - 6.913 -;*************************************************************** 6.914 -;_fastcall int read_image(bx:struct image_himem *m); 6.915 +;_fastcall int read_image(si:struct image_himem *m); 6.916 ;*************************************************************** 6.917 global @read_image$qp11image_himem:near 6.918 proc @read_image$qp11image_himem near 6.919 6.920 - push si di 6.921 - mov di,bx 6.922 - mov si,4096 6.923 - push si ; original size 6.924 + push di 6.925 + mov di,4096 6.926 + push di ; original size 6.927 @@loop: 6.928 ifndef NO386 6.929 - movzx ecx,si 6.930 - mov eax,[(image_himem di).chunk_size] 6.931 + movzx ecx,di 6.932 + mov eax,[(image_himem si).chunk_size] 6.933 cmp ecx,eax 6.934 jb @@szok 6.935 else 6.936 - mov cx,si 6.937 - mov ax,[word (image_himem di).chunk_size] 6.938 + mov cx,di 6.939 + mov ax,[word (image_himem si).chunk_size] 6.940 cmp cx,ax 6.941 jb @@szok 6.942 - cmp [word ((image_himem di).chunk_size)+2],0 ; hi m->chunk_size 6.943 + cmp [word ((image_himem si).chunk_size)+2],0 ; hi m->chunk_size 6.944 jne @@szok 6.945 endif 6.946 xchg ax,cx 6.947 @@szok: 6.948 jcxz image_done 6.949 mov dx,offset _xfer_buf+4096 6.950 - sub dx,si 6.951 - mov bx,[di] 6.952 + sub dx,di 6.953 + mov bx,[si] 6.954 call @read$cxdxbx 6.955 jb image_done 6.956 xor cx,cx 6.957 cwd ; ax < 8000h 6.958 ifndef NO386 6.959 cwde ; ax < 8000h 6.960 - sub [(image_himem di).chunk_size],eax 6.961 + sub [(image_himem si).chunk_size],eax 6.962 xchg eax,ebx 6.963 else 6.964 - sub [word (image_himem di).chunk_size],ax 6.965 + sub [word (image_himem si).chunk_size],ax 6.966 xchg ax,bx 6.967 - sbb [word ((image_himem di).chunk_size)+2],dx 6.968 + sbb [word ((image_himem si).chunk_size)+2],dx 6.969 jnz @@fill 6.970 - cmp [word (image_himem di).chunk_size],dx 6.971 + cmp [word (image_himem si).chunk_size],dx 6.972 endif 6.973 jnz @@fill 6.974 dec cx 6.975 @@ -1056,30 +935,22 @@ 6.976 jmp @@fill 6.977 @@filled: 6.978 ifndef NO386 6.979 - sub [(image_himem di).remaining],ebx 6.980 + sub [(image_himem si).remaining],ebx 6.981 else 6.982 - sub [word (image_himem di).remaining],bx 6.983 - sbb [word ((image_himem di).remaining)+2],dx 6.984 + sub [word (image_himem si).remaining],bx 6.985 + sbb [word ((image_himem si).remaining)+2],dx 6.986 endif 6.987 - sub si,bx 6.988 + sub di,bx 6.989 pushf 6.990 - ifdef EXTRA 6.991 - and cx,[(image_himem di).next_chunk] 6.992 - jcxz @@same_chunk 6.993 - push di 6.994 - call cx 6.995 - pop cx 6.996 - else 6.997 jcxz @@same_chunk 6.998 call next_chunk 6.999 - endif 6.1000 @@same_chunk: 6.1001 popf 6.1002 jnz @@loop 6.1003 image_done: 6.1004 pop ax ; original size 6.1005 - sub ax,si 6.1006 - pop di si 6.1007 + sub ax,di 6.1008 + pop di 6.1009 ret 6.1010 6.1011 endp @read_image$qp11image_himem 6.1012 @@ -1088,21 +959,12 @@ 6.1013 ;*************************************************************** 6.1014 ;_fastcall unsigned long strtol(const char *s); 6.1015 ;*************************************************************** 6.1016 - ifndef USE_ARGSTR 6.1017 - global @strtol$qpxzc:near 6.1018 - endif 6.1019 proc @strtol$qpxzc near 6.1020 6.1021 ifndef NO386 6.1022 - ifndef USE_ARGSTR 6.1023 - push si 6.1024 - mov si,bx 6.1025 - endif 6.1026 xor ecx,ecx 6.1027 xor eax,eax 6.1028 xor ebx,ebx 6.1029 - or si,si 6.1030 - jz @@end 6.1031 lodsb 6.1032 or al,20h 6.1033 cmp al,'a' 6.1034 @@ -1173,16 +1035,7 @@ 6.1035 pop ax 6.1036 pop dx 6.1037 @@popsiret: 6.1038 - ifndef USE_ARGSTR 6.1039 - pop si 6.1040 - endif 6.1041 else 6.1042 - ifndef USE_ARGSTR 6.1043 - push si 6.1044 - mov si,bx 6.1045 - endif 6.1046 - or si,si 6.1047 - jz @@goend 6.1048 xor bx,bx 6.1049 xor cx,cx 6.1050 xor dx,dx 6.1051 @@ -1198,7 +1051,6 @@ 6.1052 @@vga: 6.1053 xchg ax,cx 6.1054 ;cwd 6.1055 -@@goend: 6.1056 jmp @@end 6.1057 @@notvga: 6.1058 mov cl,10 ; radix 6.1059 @@ -1264,9 +1116,6 @@ 6.1060 jne @@end 6.1061 inc dx 6.1062 @@end: 6.1063 - ifndef USE_ARGSTR 6.1064 - pop si 6.1065 - endif 6.1066 endif 6.1067 strtol_ret: 6.1068 ret 6.1069 @@ -1274,64 +1123,6 @@ 6.1070 endp @strtol$qpxzc 6.1071 6.1072 6.1073 - ifdef EXTRA 6.1074 - p8086 6.1075 -;*************************************************************** 6.1076 -;_fastcall char *utoa(ax:unsigned n); 6.1077 -;*************************************************************** 6.1078 - global @utoa$qui:near 6.1079 - proc @utoa$qui near 6.1080 - 6.1081 - mov cx,10 6.1082 - mov bx,offset utoabuf+5 6.1083 -@@loop: 6.1084 - dec bx 6.1085 - xor dx,dx 6.1086 - div cx ; DX:AX = n%10:n/10 6.1087 - mov [byte bx],'0' 6.1088 - add [bx],dl ; DL = n%10 6.1089 - or ax,ax 6.1090 - jnz @@loop 6.1091 - xchg ax,bx 6.1092 - ret 6.1093 - 6.1094 - endp @utoa$qui 6.1095 - 6.1096 - 6.1097 -;*************************************************************** 6.1098 -;_fastcall unsigned long kver2ul(bx:char *kernel_version); 6.1099 -;*************************************************************** 6.1100 - global @kver2ul$qpzc:near 6.1101 - proc @kver2ul$qpzc near 6.1102 - 6.1103 - push si 6.1104 - mov si,bx 6.1105 - xor bx,bx 6.1106 - mov cx,304h 6.1107 -@@number: 6.1108 - xor ax,ax 6.1109 - cwd 6.1110 -@@digit: 6.1111 - shl al,cl 6.1112 - shl ax,cl 6.1113 - lodsb 6.1114 - sub al,30h 6.1115 - cmp al,9 6.1116 - jbe @@digit 6.1117 - mov dl,bh 6.1118 - mov bh,bl 6.1119 - mov bl,ah 6.1120 - dec ch 6.1121 - jnz @@number 6.1122 - xchg ax,bx 6.1123 - pop si 6.1124 -kver2ulret: 6.1125 - ret 6.1126 - 6.1127 - endp @kver2ul$qpzc 6.1128 - 6.1129 - endif 6.1130 - 6.1131 ends _TEXT 6.1132 6.1133 end
7.1 --- a/linld/stuff/src/CRTL.H Wed Dec 16 17:23:49 2020 +0000 7.2 +++ b/linld/stuff/src/CRTL.H Fri Jan 08 20:15:35 2021 +0000 7.3 @@ -22,22 +22,19 @@ 7.4 void parse_cmdline(); 7.5 extern _fastcall void strcatb(const char* a,const char* b); 7.6 extern _fastcall void strcpy(const char* a,const char* b); 7.7 -#ifdef USE_ARGSTR 7.8 extern _fastcall int argstr(const char *s, const char keywords[], const char **var); 7.9 extern _fastcall int argnum(char *s, const char keywords[], unsigned long *var); 7.10 extern _fastcall void set_cmdline(const char *filename); 7.11 -#ifndef ISOHOOK 7.12 -#define strhead(a,b) (strstr(a,b) != (int) (a)) 7.13 -#else 7.14 -extern _fastcall int strhead(const char* a,const char* head); 7.15 -#endif 7.16 -#else 7.17 -extern _fastcall int strhead(const char* a,const char* head); 7.18 -#endif 7.19 +extern _fastcall int strcmp(const char* a,const char* b); 7.20 +extern _fastcall int strhead(const char* a,const char* b); 7.21 extern _fastcall int fileexist(const char* name); 7.22 //extern "C" int open(const char* name, int flags); 7.23 extern _fastcall int open(const char* name); 7.24 +#ifdef NO_CLOSE 7.25 +#define close(x) 7.26 +#else 7.27 extern _fastcall int close(int fd); 7.28 +#endif 7.29 extern _fastcall int moverm(unsigned short *p); 7.30 extern _fastcall int readrm(struct image_himem *m, int sz); 7.31 extern _fastcall int read(int fd, void* data, int sz); 7.32 @@ -59,3 +56,5 @@ 7.33 extern char cpu_features[]; 7.34 #define CPUMASKLM (0x20) 7.35 #define cpuhaslm() (cpu_features[3]&CPUMASKLM) 7.36 + 7.37 +extern void loadfailure(void);
8.1 --- a/linld/stuff/src/CRTLX.H Wed Dec 16 17:23:49 2020 +0000 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,11 +0,0 @@ 8.4 -// This file is distributed under GPL 8.5 -// 8.6 -extern _fastcall long lseekset2(int fd, unsigned long* whence); 8.7 -extern _fastcall void strcat(const char* a,const char* b); 8.8 -extern _fastcall int strcmp(const char* a,const char* b); 8.9 -//extern "C" char* strstr(const char* a,const char* b); 8.10 -extern _fastcall int strstr(const char* a,const char* b); 8.11 -extern _fastcall unsigned long kver2ul(char *kernel_version); 8.12 -//extern "C" char *utoa(unsigned n); 8.13 -extern _fastcall int utoa(unsigned n); 8.14 -extern "C" void try_default_args();
9.1 --- a/linld/stuff/src/HEADER.ASM Wed Dec 16 17:23:49 2020 +0000 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,69 +0,0 @@ 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 9.15 - assume cs:DGROUP,ds:DGROUP 9.16 - 9.17 - segment _TEXT byte public use16 'CODE' 9.18 - 9.19 -COMSTART = 100h 9.20 -MAXCODESZ = 0F000h ; < 64K - COMSTART - STKSZ 9.21 - 9.22 - org COMSTART 9.23 - global _text_start:byte 9.24 - label _text_start byte 9.25 - 9.26 - cld 9.27 - mov dx,offset tazboot_cmd 9.28 - mov di,80h 9.29 - cmp [byte di],dh 9.30 - ja notfound 9.31 - mov ax,3d00h ; read-only+compatibility 9.32 - ;mov cl,0 ; attribute mask 9.33 - int 21h 9.34 - jc notfound 9.35 -found: 9.36 - xchg ax,bx 9.37 - mov ah,3Eh ; close 9.38 - int 21h 9.39 - mov si,offset default_arg ; di = 0080h 9.40 - mov cx,di 9.41 - rep 9.42 - movsb 9.43 -notfound: 9.44 - mov di,MAXCODESZ+offset endcmd 9.45 - mov si,offset move 9.46 - mov cx,COMSTART 9.47 - mov ax,offset endcmd 9.48 -move: 9.49 - push di 9.50 - push cx 9.51 - rep 9.52 - movsb 9.53 - pop di 9.54 - pop cx 9.55 - ;sub cx,ax 9.56 - xchg ax,si 9.57 - push cx 9.58 - ret 9.59 - 9.60 -default_arg db endcmd-begcmd 9.61 -begcmd db " @" 9.62 -tazboot_cmd db "tazboot.cmd",0 9.63 -endcmd: 9.64 - 9.65 -;*************************************************************** 9.66 - 9.67 - ends _TEXT 9.68 - 9.69 - 9.70 - end _text_start 9.71 - 9.72 -;###### END OF FILE ############################################
10.1 --- a/linld/stuff/src/HEADER.CMD Wed Dec 16 17:23:49 2020 +0000 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,1 +0,0 @@ 10.4 -header.obj, header
11.1 --- a/linld/stuff/src/HIMEM.CPP Wed Dec 16 17:23:49 2020 +0000 11.2 +++ b/linld/stuff/src/HIMEM.CPP Fri Jan 08 20:15:35 2021 +0000 11.3 @@ -6,20 +6,13 @@ 11.4 #include "crtl.h" 11.5 #include "common.h" 11.6 11.7 -#ifdef WITH_XMM_ALLOC 11.8 -u16 skip_alloc; 11.9 -#endif 11.10 -static u32 buf; 11.11 +extern u32 himem_buf; 11.12 11.13 void load_image(struct image_himem *m) { 11.14 m->remaining = m->size; 11.15 m->buf = m->fallback; // set no_exit btw: die() won't return to DOS 11.16 - u32* bufv= &buf; 11.17 -#ifdef WITH_XMM_ALLOC 11.18 - if(((u16 *)&m->fallback)[1] >= (skip_alloc|0x10)) { // >= _1m ? 11.19 -#else 11.20 + u32* bufv= &himem_buf; 11.21 if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ? 11.22 -#endif 11.23 if(vcpi) { 11.24 bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv 11.25 } 11.26 @@ -29,15 +22,15 @@ 11.27 } 11.28 #endif 11.29 } 11.30 - buf = m->buf; 11.31 + himem_buf = m->buf; 11.32 do { 11.33 u16 size; 11.34 if(s16(size = read_image(m)) -1 < 0) break; 11.35 storepage(bufv); 11.36 - if (bufv != &buf) next(bufv); 11.37 - buf += size; 11.38 + if (bufv != &himem_buf) next(bufv); 11.39 + himem_buf += size; 11.40 } while (*bufv); 11.41 - if(m->remaining) die("Read error"); 11.42 + if(m->remaining) loadfailure(); 11.43 close(m->fd2close); 11.44 } 11.45 11.46 @@ -57,9 +50,9 @@ 11.47 pusha 11.48 # endif 11.49 } 11.50 + vm2rm(); 11.51 struct image_himem *m = ± 11.52 u32 *q; 11.53 - vm2rm(); 11.54 if(((u16 *)&m->fallback)[1] >= 0x10) // >= _1m ? 11.55 ((u16 *)&m->fallback)[1] = 0x10; 11.56 q = m->bufv;
12.1 --- a/linld/stuff/src/HIMEM.INC Wed Dec 16 17:23:49 2020 +0000 12.2 +++ b/linld/stuff/src/HIMEM.INC Fri Jan 08 20:15:35 2021 +0000 12.3 @@ -5,9 +5,7 @@ 12.4 remaining dd ? ;10 u32 remaining; 12.5 buf dd ? ;14 u32 buf; 12.6 bufv dw ? ;18 u32 *bufv; 12.7 -errmsg dw ? ;20 char *errmsg; 12.8 -chunk_size dd ? ;22 u32 chunk_size; 12.9 -next_chunk dw ? ;26 void (*next_chunk)(struct image_himem *); 12.10 -state dw ? ;28 u16 state; 12.11 -fd2close dw ? ;30 u16 fd2close; 12.12 +chunk_size dd ? ;20 u32 chunk_size; 12.13 +state dw ? ;24 u16 state; 12.14 +fd2close dw ? ;26 u16 fd2close; 12.15 ends image_himem ;};
13.1 --- a/linld/stuff/src/ISO9660.CPP Wed Dec 16 17:23:49 2020 +0000 13.2 +++ b/linld/stuff/src/ISO9660.CPP Fri Jan 08 20:15:35 2021 +0000 13.3 @@ -1,73 +1,41 @@ 13.4 #include "crtl.h" 13.5 -#include "crtlx.h" 13.6 #include "iso9660.h" 13.7 -#define __ROCKRIDGE 13.8 13.9 -#if 1 13.10 -#define setdirofs(to,sec) (*(int*)((char*)&(to)+1) = *(int*)&(sec)<<(SECTORBITS-8)) 13.11 -#define cpydirofs(to,from) (*(int*)((char*)&(to)+1) = *(int*)((char*)&(from)+1)) 13.12 -#else 13.13 -#define setdirofs(to,sec) (to = (sec)<<SECTORBITS) 13.14 -#define cpydirofs(to,from) ((to) = (from)) 13.15 -#endif 13.16 +#define setdirpage(to,sec) ((to) = *(int*)&(sec)<<(SECTORBITS-8)) 13.17 +#define cpytodirpage(to,from) ((to) = *(int*)((char*)&(from)+1)) 13.18 +#define cpyfromdirpage(to,from) (*(int*)((char*)&(to)+1) = (from)) 13.19 13.20 -#ifdef ISOHOOK 13.21 #define isoroot() \ 13.22 { \ 13.23 - static const unsigned long root = 16UL * 2048; \ 13.24 - isoreadsector(&root); \ 13.25 - setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); \ 13.26 - isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ 13.27 + extern void isoreadrootsector(void); \ 13.28 + isoreadrootsector(); \ 13.29 + setdirpage(x->dirpage, (* (unsigned long *) (isostate.buffer + 0x9E))); \ 13.30 + x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ 13.31 } 13.32 -#else 13.33 -int isoroot(void) 13.34 -{ 13.35 - static const unsigned long root = 16UL * 2048; 13.36 - if (isoreadsector(&root) == -1 || strhead(isostate.buffer+1,"CD001") == -1) { 13.37 - //close(isostate.fd); 13.38 - return -1; 13.39 - } 13.40 - setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 13.41 - isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 13.42 - return 0; 13.43 -} 13.44 -#endif 13.45 13.46 -int isoreaddir(void) 13.47 +static int isoreaddir(void) 13.48 { 13.49 char *p; 13.50 13.51 struct isostate *x=&isostate; 13.52 13.53 - if (x->curdirsize == 0xFFFF) { 13.54 - x->curdirsize = x->dirsize; 13.55 - cpydirofs(x->curdirofs, x->dirofs); 13.56 - goto restarted; 13.57 - } 13.58 if (x->curpos >= SECTORSZ || * (short *) (x->buffer + x->curpos) == 0) { 13.59 - restarted: 13.60 - if (x->curdirsize < DIRSECTORSZ) return -1; 13.61 - isoreadsector(&x->curdirofs); 13.62 + if ((x->curdirsize =- DIRSECTORSZ) < 0) return -1; 13.63 + isoreadsector(&x->curdirofs); // x->filepos = 0 13.64 //x->curdirofs += SECTORSZ; 13.65 *(int *)((char *) &x->curdirofs+1) += SECTORSZ/256; 13.66 - x->curdirsize -= DIRSECTORSZ; 13.67 x->curpos = 0; 13.68 } 13.69 p = x->buffer; p += x->curpos; 13.70 + x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; 13.71 if ((x->entrysize = * (short *) p) == 0) { 13.72 return -1; 13.73 } 13.74 - x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; 13.75 + // x->filename = ""; 13.76 x->filesize = * (unsigned long *) (p + 10); 13.77 x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41; 13.78 - //x->filemod = (p[25] & 2) ? 0040755 : 0100755; 13.79 - //x->filemod = 0100755 - ((p[25] & (char)2) << 13); 13.80 -#ifdef __ROCKRIDGE 13.81 - // p += 34 + (p[32] & -2); ? 13.82 p = x->buffer + 34 + ((p[32] + x->curpos) & -2); 13.83 -#ifdef ISOHOOK 13.84 x->curpos += x->entrysize; 13.85 -#endif 13.86 do { 13.87 register len = p[2]; 13.88 if (* (short *) p == 0x4D4E) { 13.89 @@ -76,42 +44,18 @@ 13.90 goto found; 13.91 } 13.92 p += len; 13.93 -#ifdef ISOHOOK 13.94 - } while (x->buffer + x->curpos - 2 > p); 13.95 -#else 13.96 - } while (x->buffer + x->curpos + x->entrysize - 2 > p); 13.97 -#endif 13.98 -#endif 13.99 -#ifndef ISOHOOK 13.100 - { 13.101 - p = x->buffer + 33; x->filename = p += x->curpos; 13.102 - p--; 13.103 - if (((* (short *) p) & 0xFEFF) -1 == 0) { 13.104 - x->filename = ".."; 13.105 - if (--(* (short *) p) == 0) 13.106 - x->filename++; 13.107 - } 13.108 - else { 13.109 - p += *p; p--; 13.110 - if (* (short *) (p) != 0x313B) { 13.111 - p++; p++; // no ;1 to remove 13.112 - } 13.113 - if (p[-1] == '.') p--; 13.114 - *p = 0; 13.115 - } 13.116 - } 13.117 -#endif 13.118 + } while (x->buffer + x->curpos - 3 >= p); 13.119 found: 13.120 -#ifndef ISOHOOK 13.121 - x->curpos += x->entrysize; 13.122 -#endif 13.123 return 0; 13.124 } 13.125 13.126 -//#define IS_DIR(x)( ((x) & ~0777) == 040000) 13.127 -//#define IS_DIR(x)( (char)((x) >> 9) == (char)040) 13.128 -//#define IS_DIR(x)( (*((char*) &x + 1) & (char)0776) == (char)0100) 13.129 -#define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0) 13.130 +#define isoreaddir_reset() \ 13.131 +{ \ 13.132 + x->curdirsize = x->dirsize; \ 13.133 + cpyfromdirpage(x->curdirofs, x->dirpage); \ 13.134 + x->curpos = -1; \ 13.135 +} 13.136 + 13.137 int _isoopen(void) 13.138 { 13.139 // char *name, *s, c; 13.140 @@ -123,25 +67,24 @@ 13.141 char *s; 13.142 13.143 _64bits = cpuhaslm(); 13.144 - do { 13.145 -#ifdef ISOHOOK 13.146 + _32bits: 13.147 s = (char *) x->filename2open; 13.148 if (*s == '/') { 13.149 s++; 13.150 isoroot(); 13.151 - } 13.152 - name = s; 13.153 - while (*++s); 13.154 -#else 13.155 - for (s = (char *) x->filename2open; *s == '/' ; s++) { 13.156 - isoroot(); 13.157 + //if (strncmp(x->buffer+1,"CD001,5) == -1) return -1; 13.158 + //if (*(int*)(x->buffer+1) != 0x4443) return -1; 13.159 } 13.160 next: 13.161 + isoreaddir_reset(); 13.162 name = s; 13.163 do s++; while (*s && *s != '/'); 13.164 c = *s; *s = 0; 13.165 -#endif 13.166 - for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) { 13.167 + do { 13.168 + if (isoreaddir() == -1) { 13.169 + if ((_64bits ^= CPUMASKLM) == 0) goto _32bits; 13.170 + return -1; 13.171 + } 13.172 const char *n = name; 13.173 #define i (x->tmp) 13.174 i = x->filename; 13.175 @@ -150,20 +93,15 @@ 13.176 n = "64"; 13.177 i += s - name; // strlen(name); 13.178 } 13.179 - if (strcmp(i, n) == -1) continue; 13.180 -#ifndef ISOHOOK 13.181 - *s++ = c; 13.182 -#endif 13.183 - if (IS_DIR(x->filemod)) { 13.184 - cpydirofs(x->dirofs, x->fileofs); 13.185 - x->dirsize = filesize2dirsize(x->filesize); 13.186 -#ifndef ISOHOOK 13.187 - if (c) goto next; 13.188 -#endif 13.189 - } 13.190 - isolseek(&x->fileofs); 13.191 - return 0; 13.192 + if (strcmp(i, n) != -1) break; 13.193 + } while (1); 13.194 + *s++ = c; 13.195 +#define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0) 13.196 + if (IS_DIR(x->filemod)) { 13.197 + cpytodirpage(x->dirpage, x->fileofs); 13.198 + x->dirsize = filesize2dirsize(x->filesize); 13.199 + if (c) goto next; 13.200 } 13.201 - } while ((_64bits ^= CPUMASKLM) == 0); 13.202 - return -1; 13.203 + isolseek(&x->fileofs); 13.204 + return x->fd; 13.205 }
14.1 --- a/linld/stuff/src/ISO9660.H Wed Dec 16 17:23:49 2020 +0000 14.2 +++ b/linld/stuff/src/ISO9660.H Fri Jan 08 20:15:35 2021 +0000 14.3 @@ -3,7 +3,7 @@ 14.4 //typedef unsigned long dirsizetype; 14.5 //#define filesize2dirsize(x) (x) 14.6 //#define DIRSECTORSZ SECTORSZ 14.7 -typedef unsigned dirsizetype; 14.8 +typedef short dirsizetype; 14.9 #define filesize2dirsize(x) (*(dirsizetype *)((char *)&(x)+1)) 14.10 #define DIRSECTORSZ (SECTORSZ/256) 14.11 extern struct isostate { 14.12 @@ -13,9 +13,12 @@ 14.13 unsigned short filemod; 14.14 unsigned long fileofs; 14.15 unsigned long filesize; 14.16 + unsigned long filepos; 14.17 char *filename; 14.18 dirsizetype curdirsize, dirsize; 14.19 - unsigned long curdirofs, dirofs; 14.20 +typedef unsigned dirpagetype; 14.21 + dirpagetype dirpage; 14.22 + unsigned long curdirofs; 14.23 int entrysize; 14.24 const char *tmp; 14.25 char c; 14.26 @@ -31,8 +34,8 @@ 14.27 #define isofilename isostate.filename 14.28 extern _fastcall void isolseek(const unsigned long *offset); 14.29 extern _fastcall int isoreadsector(const unsigned long *offset); 14.30 -extern _fastcall int isoreset(char *name); 14.31 -extern _fastcall int isoopen(const char *name); 14.32 +extern int _isoopen(void); 14.33 extern int isoreaddir(void); 14.34 #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) 14.35 +#define setiso(x) (isostate.fd = open(x)) 14.36 #endif
15.1 --- a/linld/stuff/src/ISOCRTL.ASM Wed Dec 16 17:23:49 2020 +0000 15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 15.3 @@ -1,263 +0,0 @@ 15.4 -;*************************************************************** 15.5 -;****** This file is distributed under GPL 15.6 -;*************************************************************** 15.7 - ideal 15.8 - %PAGESIZE 1000 15.9 - %crefref 15.10 - %noincl 15.11 - %nomacs 15.12 - ifdef NO386 15.13 - p8086 15.14 - else 15.15 - p386 15.16 - endif 15.17 - 15.18 - group DGROUP _TEXT,_DATA,_BSS 15.19 - assume cs:DGROUP,ds:DGROUP 15.20 - 15.21 - segment _TEXT byte public use16 'CODE' 15.22 - ends _TEXT 15.23 - 15.24 - segment _DATA byte public use16 'DATA' 15.25 - ends _DATA 15.26 - 15.27 - segment _BSS byte public use16 'BSS' 15.28 - 15.29 - include "isostate.inc" 15.30 - 15.31 - public _isostate 15.32 -_isostate isostate <?> 15.33 -; org $-7 15.34 - 15.35 - ends _BSS 15.36 - 15.37 - segment _TEXT byte public use16 'CODE' 15.38 - 15.39 - global fold:near 15.40 -fold: 15.41 - org 130h-100h 15.42 - global _cpu_features:dword 15.43 -_cpu_features dd ? 15.44 - org 0F000h-100h 15.45 - global unfold:near 15.46 -unfold: 15.47 - jmp iso_open 15.48 - extrn @isoreaddir$qv 15.49 - dw @isoreaddir$qv 15.50 - jmp @readmenu$qv 15.51 - 15.52 - push dx 15.53 - call readfd 15.54 - push ds 15.55 - pop es 15.56 - mov di,128h ; TABLE 15.57 - mov ax,offset iso_close_hack 15.58 - stosw 15.59 - inc ax ; iso_open_hack 15.60 - stosw 15.61 - add al,offset iso_read_hack-offset iso_open_hack 15.62 - stosw 15.63 - add al,offset iso_lseek_hack-offset iso_read_hack 15.64 - stosw 15.65 - ifdef NO386 15.66 - global N_LXLSH@ES:near 15.67 -N_LXLSH@ES: 15.68 - mov dx,es 15.69 - global N_LXLSH@:near 15.70 -N_LXLSH@: 15.71 - mov ch,0 15.72 -@@lp: 15.73 - shl ax,1 15.74 - rcl dx,1 15.75 - loop @@lp 15.76 - endif 15.77 -iso_close_hack: 15.78 - ret 15.79 - 15.80 -;*************************************************************** 15.81 -;_fastcall int open(bx:const char* name); 15.82 -;*************************************************************** 15.83 -iso_open_hack: 15.84 - extrn @_isoopen$qv:near 15.85 - cmp [byte bx],'!' 15.86 - je @readmenu$qv 15.87 - xchg ax,bx 15.88 -iso_open: 15.89 - mov [_isostate.filename2open],ax 15.90 - call @_isoopen$qv 15.91 - cmp al,1 15.92 - cmc 15.93 - ret 15.94 - 15.95 - 15.96 -;*************************************************************** 15.97 -;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz, ah=3Fh); 15.98 -;*************************************************************** 15.99 -iso_read_hack: 15.100 - push dx 15.101 - xor dx,dx 15.102 - ifndef NO386 15.103 - push dx 15.104 - endif 15.105 - push cx 15.106 - xor cx,cx 15.107 - mov al,01h 15.108 - call doseek ; bx = _isostate.fileofs 15.109 - ifdef NO386 15.110 - mov cx,[bx+4] ; _isostate.filesize 15.111 - sub cx,ax 15.112 - mov ax,[bx+6] 15.113 - sbb ax,dx 15.114 - pop ax 15.115 - ja @@axok 15.116 - cmp ax,cx 15.117 - else 15.118 - push dx 15.119 - push ax 15.120 - pop ecx 15.121 - mov eax,[_isostate.filesize] 15.122 - sub eax,ecx 15.123 - pop ecx 15.124 - cmp eax,ecx 15.125 - endif 15.126 - ja @@cxok 15.127 -@@axok: 15.128 - xchg ax,cx 15.129 -@@cxok: 15.130 - pop dx ; buffer 15.131 - jmp readfd 15.132 - 15.133 - 15.134 -;*************************************************************** 15.135 -;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence, bh=42h); 15.136 -;*************************************************************** 15.137 -iso_lseek_hack: 15.138 - xchg ax,bx 15.139 - ifdef SEEK_CUR 15.140 - cmp al,1 ; current 15.141 - je doseek 15.142 - endif 15.143 - mov bx,offset _isostate.fileofs 15.144 - add dx,[bx] 15.145 - adc cx,[bx+2] 15.146 - cmp al,0 ; start 15.147 - je doseek 15.148 - add dx,[bx+4] ; _isostate.filesize 15.149 - adc cx,[bx+6] 15.150 - mov al,0 15.151 -doseek: 15.152 - call lseek ; lseek(,,al) 15.153 -sub_fileofs: 15.154 - mov bx,offset _isostate.fileofs 15.155 - sub ax,[bx] 15.156 - sbb dx,[bx+2] 15.157 - ret 15.158 - 15.159 - 15.160 -;*************************************************************** 15.161 -;_fastcall void readmenu(void); 15.162 -;*************************************************************** 15.163 - proc @readmenu$qv near 15.164 - 15.165 - mov dx,18 15.166 - xor cx,cx 15.167 - call lseekset 15.168 - mov dx,offset _isostate.filemod 15.169 - mov cl,10 15.170 - call readfd ; // read x->filemod + x->fileofs & x->filesize 15.171 - mov bx,offset _isostate.fileofs 15.172 - ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 15.173 - mov ax,7FF0h 15.174 - cwd 15.175 - mov [word bx+6],dx 15.176 - sub ax,[bx+4] 15.177 - mov [word bx+2],dx 15.178 - mov [bx],ax 15.179 - ; //magic = x->filemod; 15.180 - 15.181 - endp @readmenu$qv 15.182 - 15.183 -;*************************************************************** 15.184 -;_fastcall void isolseek(bx:const unsigned long *offset); 15.185 -;*************************************************************** 15.186 - global @isolseek$qpxul:near 15.187 - proc @isolseek$qpxul near 15.188 - 15.189 -isolseek: 15.190 - mov dx,[bx] 15.191 - mov cx,[bx+2] 15.192 -lseekset: 15.193 - mov al,00h ; bx=fd cx:dx=offset al=whence 15.194 -lseek: 15.195 - mov ah,42h 15.196 -dosfd: 15.197 - mov bx,[_isostate.fd] 15.198 -dos: 15.199 - int 21h 15.200 -failifc: 15.201 - jnc dosok 15.202 -fail: 15.203 - sbb ax,ax 15.204 - cwd 15.205 -dosok: 15.206 - ret 15.207 - 15.208 - endp @isolseek$qpxul 15.209 - 15.210 - 15.211 -;*************************************************************** 15.212 -;_fastcall int isoreadsector(bx:const unsigned long *offset); 15.213 -;*************************************************************** 15.214 - global @isoreadsector$qpxul:near 15.215 - proc @isoreadsector$qpxul near 15.216 - 15.217 - call isolseek 15.218 - jc fail 15.219 - mov ch,9 ; < 2560 15.220 - mov dx,offset _isostate.buffer 15.221 -readfd: 15.222 - mov ah,3Fh 15.223 - jmp dosfd 15.224 - 15.225 - endp @isoreadsector$qpxul 15.226 - 15.227 - 15.228 -;*************************************************************** 15.229 -;_fastcall int strhead(bx:const char* a, ax:const char* b); 15.230 -;*************************************************************** 15.231 - global @strhead$qpxzct1:near 15.232 - proc @strhead$qpxzct1 near 15.233 - 15.234 -@@loop: 15.235 - xchg ax,bx 15.236 - mov cl,[bx] ; cl = *b++ 15.237 - inc bx 15.238 - xchg ax,bx 15.239 - or cl,cl ; clear C 15.240 - jz fail ; return 0 15.241 - xor cl,[bx] ; cl -= *a++ 15.242 - inc bx 15.243 - or cl,cl 15.244 - stc 15.245 - jne fail ; return -1 15.246 - jmp @@loop 15.247 - 15.248 - endp @strhead$qpxzct1 15.249 - 15.250 - 15.251 -;*************************************************************** 15.252 -;_fastcall int strcmp(bx:const char* a, ax:const char* b); 15.253 -;*************************************************************** 15.254 - global @strcmp$qpxzct1:near 15.255 - proc @strcmp$qpxzct1 near 15.256 - 15.257 - call @strhead$qpxzct1 15.258 - jne dosok ; return -1 15.259 - cmp cl,[bx] 15.260 - jmp fail ; return 0 or -1 15.261 - 15.262 - endp @strcmp$qpxzct1 15.263 - 15.264 - ends _TEXT 15.265 - 15.266 - end
16.1 --- a/linld/stuff/src/ISOSTATE.INC Wed Dec 16 17:23:49 2020 +0000 16.2 +++ b/linld/stuff/src/ISOSTATE.INC Fri Jan 08 20:15:35 2021 +0000 16.3 @@ -7,15 +7,16 @@ 16.4 filemod dw ? ; 6 unsigned short filemod; 16.5 fileofs dd ? ; 8 unsigned long fileofs; 16.6 filesize dd ? ;12 unsigned long filesize; 16.7 -filename dw ? ;16 char *filename; 16.8 -curdirsize dw ? ;18 dirsizetype curdirsize; 16.9 -dirsize dw ? ;20 dirsizetype dirsize; 16.10 -curdirofs dd ? ;22 unsigned long curdirofs; 16.11 -dirofs dd ? ;26 unsigned long dirofs; 16.12 +filepos dd ? ;16 unsigned long filepos; 16.13 +filename dw ? ;20 char *filename; 16.14 +curdirsize dw ? ;22 dirsizetype curdirsize; 16.15 +dirsize dw ? ;24 dirsizetype dirsize; 16.16 +dirpape dw ? ;26 unsigned short dirpage; 16.17 +curdirofs dd ? ;28 unsigned long curdirofs; 16.18 ;overlap 16.19 -entrysize dw ? ;30 int entrysize; 16.20 -tmp dw ? ;32 const char *tmp; 16.21 -c db ? ;34 char c; 16.22 -_64bits db ? ;35 char _64bits; 16.23 -buffer db ? ;36 char buffer[2048+512]; 16.24 +entrysize dw ? ;32 int entrysize; 16.25 +tmp dw ? ;34 const char *tmp; 16.26 +c db ? ;36 char c; 16.27 +_64bits db ? ;37 char _64bits; 16.28 +buffer db ? ;38 char buffer[2048+512]; 16.29 ends isostate ; } isostate;
17.1 --- a/linld/stuff/src/JUMP.ASM Wed Dec 16 17:23:49 2020 +0000 17.2 +++ b/linld/stuff/src/JUMP.ASM Fri Jan 08 20:15:35 2021 +0000 17.3 @@ -87,7 +87,8 @@ 17.4 extrn sssp:word 17.5 mov ax,[sssp+2] 17.6 mov es,ax 17.7 - extrn _cmdline:word 17.8 + extrn _cmdstr:word 17.9 +_cmdline = _cmdstr+0 17.10 mov si,[_cmdline] 17.11 mov di,8000h 17.12 mov cx,2000h ; 4k for cmdline + 4k up to sp
18.1 --- a/linld/stuff/src/LINK.CMD Wed Dec 16 17:23:49 2020 +0000 18.2 +++ b/linld/stuff/src/LINK.CMD Fri Jan 08 20:15:35 2021 +0000 18.3 @@ -1,1 +1,1 @@ 18.4 -_beg.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj linld.obj _end.obj, linld 18.5 +_beg.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj linld.obj _end.obj, linld
19.1 --- a/linld/stuff/src/LINK2.CMD Wed Dec 16 17:23:49 2020 +0000 19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 19.3 @@ -1,1 +0,0 @@ 19.4 -_isobeg.obj isocrtl.obj iso9660.obj _end.obj, isoboot
20.1 --- a/linld/stuff/src/LINKX.CMD Wed Dec 16 17:23:49 2020 +0000 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,1 +0,0 @@ 20.4 -_beg.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj tazboot.obj _end.obj, tazboot
21.1 --- a/linld/stuff/src/LINLD.CPP Wed Dec 16 17:23:49 2020 +0000 21.2 +++ b/linld/stuff/src/LINLD.CPP Fri Jan 08 20:15:35 2021 +0000 21.3 @@ -4,29 +4,16 @@ 21.4 21.5 #include "crtl.h" 21.6 #include "common.h" 21.7 +#include "iso9660.h" 21.8 21.9 -const char* cmdline = "auto"; 21.10 -const char* kernel_name = "bzImage"; 21.11 -#ifdef USE_ARGSTR 21.12 -const char* initrd_name = NULL; 21.13 -#else 21.14 -const char* initrd_name; 21.15 -#endif 21.16 -u32 root_dev; 21.17 -u32 vid_mode; // -3 = ask 21.18 - // -2 = Extended VGA 21.19 - // -1 = Normal VGA 21.20 - // n = as "n" was pressed 21.21 -u32 topmem; 21.22 -u32 base_himem; 21.23 +extern char bzimagestr[]; 21.24 +const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL}; 21.25 +u32 cmdnum[4]; 21.26 21.27 inline void syntax() { 21.28 die("Syntax:" NL 21.29 - "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline]" NL 21.30 + "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline] [iso=file]" NL 21.31 "vga mode: ask,extended,normal or dec/oct/hex number" NL 21.32 -#ifdef WITH_XMM_ALLOC 21.33 - "-f force" NL 21.34 -#endif 21.35 "-64 for cpu64 only" NL 21.36 "Defaults:" NL 21.37 "\timage=bzImage" NL 21.38 @@ -39,9 +26,6 @@ 21.39 #if 1 21.40 NL NL "Examples:" NL 21.41 "\tLINLD " 21.42 -#ifdef WITH_XMM_ALLOC 21.43 - "-f " 21.44 -#endif 21.45 "-b 64m " 21.46 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz " 21.47 "\"cl=root=/dev/null video=-32\"" 21.48 @@ -50,7 +34,7 @@ 21.49 ); 21.50 } 21.51 21.52 -static char buf_cmdline[128]; 21.53 +extern char buf_cmdline[128]; 21.54 int main(int argc, char *argv[]) { 21.55 21.56 (void) argc; 21.57 @@ -59,21 +43,14 @@ 21.58 puts("LINLD v" VERSION_STR "+"); 21.59 21.60 // Parse command line 21.61 -#ifdef USE_ARGSTR 21.62 if (!*++argv) syntax(); 21.63 const char **clp = &cmdline; 21.64 do { 21.65 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64 21.66 - if (cpuhaslm() == 0) exit(); 21.67 - continue; 21.68 + if (cpuhaslm() != 0) continue; 21.69 + exit(); 21.70 } 21.71 -#ifdef WITH_XMM_ALLOC 21.72 - if ((*(u16 *)*argv|0x2002) == 0x662F) { // -F /f 21.73 - skip_alloc--; 21.74 - continue; 21.75 - } 21.76 -#endif 21.77 - if (argstr(*argv,"cl|image|initrd",clp) == (int) clp) continue; 21.78 + if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue; 21.79 if (argnum(*argv,"root|vga|mem|-b",&root_dev) == (int) &base_himem) continue; 21.80 if (fileexist(*argv) != -1) { 21.81 kernel_name=*argv; 21.82 @@ -83,94 +60,12 @@ 21.83 strcatb((const char *) buf_cmdline,*argv); 21.84 } while (*++argv); 21.85 puts(*clp); 21.86 + if (isofile) setiso(isofile); 21.87 set_cmdline(*clp); 21.88 load_kernel(); 21.89 load_initrd(); 21.90 boot_kernel(); 21.91 -#else 21.92 - if (!argv[1]) syntax(); 21.93 - while (1) { 21.94 - char *s; 21.95 - next: 21.96 - argv++; 21.97 - s=*argv; 21.98 - if (!s) { 21.99 - load_kernel(); 21.100 - puts(version_string); 21.101 - load_initrd(); 21.102 - boot_kernel(); 21.103 - } 21.104 - if(strhead(s,"initrd=") != -1) { 21.105 - initrd_name=s+7; 21.106 - } 21.107 - else if(strhead(s,"vga=") != -1) { 21.108 - *(u16*)&vid_mode = (u16)strtol(s+7); // support normal, extended & ask 21.109 - } 21.110 - else switch (*(u16 *)s|0x2002) { 21.111 - case 0x362F: // -64 /64 21.112 - if (cpuhaslm() == 0) exit(); 21.113 - goto next; 21.114 -#ifdef WITH_XMM_ALLOC 21.115 - case 0x662F: // -F /f 21.116 - skip_alloc--; 21.117 - goto next; 21.118 -#endif 21.119 - case 0x622F: // -B /b 21.120 - argv++; 21.121 - ((u16 *)&base_himem)[1] = (u16)(strtol(*argv)>>16); 21.122 - goto next; 21.123 - default: 21.124 - if(strhead(s,"cl=") != -1) { 21.125 - cmdline=s+=3; 21.126 - if (*s == '@') { 21.127 - static struct image_himem image; 21.128 - char c; 21.129 - 21.130 - s++; 21.131 - image.errmsg = "Error in cl=@file"; 21.132 - open_image(&image, s); 21.133 - s+=read(image.fd, (void *)cmdline=s= 21.134 - (char *)malloc_or_die(image.size), image.size); 21.135 - // Strip any trailing cr/lf 21.136 - c='\0'; 21.137 - do { 21.138 - // Replace all other cr/lfs with spaces 21.139 - s--; 21.140 - if(*s>=' ') c=' '; 21.141 - else *s = c; 21.142 - } while (s>cmdline); 21.143 - puts("Kernel command line:"); 21.144 - puts(cmdline); 21.145 - } 21.146 - } 21.147 - else if(strhead(s,"root=") != -1) { 21.148 - *(u16*)&root_dev = (u16)strtol(s+5); 21.149 - goto addincmdline; 21.150 - } 21.151 - else if(strhead(s,"mem=") != -1) { 21.152 - ((u16 *)&topmem)[1] = (u16)(strtol(s+4)>>16); 21.153 - goto addincmdline; 21.154 - } 21.155 - else if(strhead(s,"image=") != -1) { 21.156 - s+=6; 21.157 - set_kernel_name: 21.158 - kernel_name=s; 21.159 - } 21.160 - else { 21.161 - addincmdline: 21.162 - if(cmdline == (const char *) buf_cmdline + 1) { 21.163 - strcatb(buf_cmdline,*argv); 21.164 - } 21.165 - else { 21.166 - if(fileexist(s) != -1) goto set_kernel_name; 21.167 - cmdline = (const char *) buf_cmdline + 1; 21.168 - goto addincmdline; 21.169 - } 21.170 - } 21.171 - } 21.172 - } 21.173 -#endif 21.174 21.175 // Let compiler be happy 21.176 - //return _AX; 21.177 + return _AX; 21.178 }
22.1 --- a/linld/stuff/src/LOAD.CPP Wed Dec 16 17:23:49 2020 +0000 22.2 +++ b/linld/stuff/src/LOAD.CPP Fri Jan 08 20:15:35 2021 +0000 22.3 @@ -60,8 +60,8 @@ 22.4 // The file-system on that floppy must be MINIX 22.5 // If rd_load() succeeds it sets the root_dev 22.6 // to the ramdisk for mounting it 22.7 - u16 vid_mode; // 01FA Video mode control 22.8 - u16 root_dev; // 01FC Default root device number 22.9 + u16 vidmode; // 01FA Video mode control 22.10 + u16 rootdev; // 01FC Default root device number 22.11 u16 boot_flag; // 01FE 0xAA55 magic number 22.12 u16 jump; // 0200 Jump instruction 22.13 u32 header; // 0202 Magic signature "HdrS" 22.14 @@ -120,8 +120,6 @@ 22.15 static u8* rm_buf; // @ = @rm_size + 2, see A20.ASM 22.16 struct image_himem imgs[2]; 22.17 22.18 -static const char kernel_file_error[] = "Can't use kernel file"; 22.19 -#define not_kernel "Not a kernel" 22.20 void load_kernel() { 22.21 22.22 struct image_himem *m = ± 22.23 @@ -133,7 +131,6 @@ 22.24 #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) 22.25 22.26 // Open kernel, read first kb, check it 22.27 - m->errmsg = kernel_file_error; 22.28 open_image(m, kernel_name); 22.29 22.30 do { 22.31 @@ -151,20 +148,20 @@ 22.32 } 22.33 if((kernelparams->setup_sects)>=(_32k/512) || // 0th sector not counted 22.34 kernelparams->boot_flag != 0xAA55) 22.35 - die(not_kernel); 22.36 + die("Not a kernel"); 22.37 _rm_size=0x200*(kernelparams->setup_sects+1); 22.38 m->size -= _rm_size; 22.39 m->chunk_size -= _rm_size; 22.40 22.41 // Read remaining rm loader 22.42 if (readrm(m, _rm_size) == _rm_size) break; 22.43 - die(kernel_file_error); 22.44 + loadfailure(); 22.45 } while (0); 22.46 22.47 // Tell rm loader some info 22.48 22.49 - if((int)vid_mode) kernelparams->vid_mode = vid_mode; 22.50 - if((int)root_dev) kernelparams->root_dev = root_dev; 22.51 + if((int)vid_mode) kernelparams->vidmode = vid_mode; 22.52 + if((int)root_dev) kernelparams->rootdev = root_dev; 22.53 22.54 if(kernelparams->header == HdrS) { // starting linux 1.3.73 22.55 if(kernelparams->loadflags & 1) { // zImage as pre 1.3.73 22.56 @@ -178,11 +175,7 @@ 22.57 hook_int15_88(); // break _ES 22.58 } 22.59 if (kernelparams->kernel_version) 22.60 -#ifndef EXTRA 22.61 puts((char *) first1k+kernelparams->kernel_version+0x200); 22.62 -#else 22.63 - strcatb(version_string,(char *) first1k+kernelparams->kernel_version+0x200); 22.64 -#endif 22.65 kernelparams->type_of_loader = 0xff; // kernel do not know us (yet :-) 22.66 if(kernelparams->version >= 0x201) { 22.67 // * offset limit of the setup heap 22.68 @@ -216,20 +209,17 @@ 22.69 // Read initrd if needed 22.70 void load_initrd() { 22.71 struct image_himem *m = &initrd; 22.72 - if (((int)initrd_name | m->fd) == 0) return; // !initrd_name && !m->fd 22.73 + if ((int)initrd_name == 0) return; 22.74 #if defined(__BORLANDC__) && defined(NO386) 22.75 #pragma option -3 22.76 asm{ 22.77 .386p 22.78 } 22.79 #endif 22.80 - m->errmsg = "Can't use initrd file"; 22.81 - 22.82 open_image(m, initrd_name); 22.83 22.84 if ((m->fallback=(memtop()-m->size)&(~PAGE_MASK))-m[-1].fallback < m[-1].size) { 22.85 - puts(m->errmsg); 22.86 - close(m->fd); 22.87 + loadfailure(); 22.88 return; 22.89 } 22.90
23.1 --- a/linld/stuff/src/MEMCPY32.ASM Wed Dec 16 17:23:49 2020 +0000 23.2 +++ b/linld/stuff/src/MEMCPY32.ASM Fri Jan 08 20:15:35 2021 +0000 23.3 @@ -15,6 +15,12 @@ 23.4 group DGROUP _TEXT 23.5 assume cs:DGROUP,ds:DGROUP 23.6 23.7 +macro lcr0 reg 23.8 + mov cr0,reg 23.9 + jmp short $+2 ;*Required*! 23.10 + ;3+ NOPs also work fine (chkd on 386) 23.11 +endm 23.12 + 23.13 segment _TEXT byte public use16 'CODE' 23.14 23.15 ;*************************************************************** 23.16 @@ -25,25 +31,16 @@ 23.17 global memcpy32:near 23.18 proc memcpy32 near 23.19 23.20 -; rm32,imm16 helper 23.21 -macro addzx_e rm,i 23.22 - db 66h 23.23 - add rm,i 23.24 - dw 0 23.25 -endm 23.26 arg dstofs :dword, \ 23.27 srcseg :word, \ 23.28 srcofs :dword, \ 23.29 sz :dword = PARAM_SIZE 23.30 23.31 - local GDTR :pword, \ 23.32 - oldGDTR :pword = TEMP_SIZE 23.33 - 23.34 ;****** Init *************************************************** 23.35 23.36 ifndef NO386 23.37 23.38 - enter TEMP_SIZE,0 23.39 + enter 0,0 23.40 ;cld 23.41 pushf 23.42 push ds es 23.43 @@ -86,7 +83,6 @@ 23.44 23.45 push bp 23.46 mov bp,sp 23.47 - sub sp,TEMP_SIZE 23.48 ;cld 23.49 pushf 23.50 push ds es 23.51 @@ -168,22 +164,16 @@ 23.52 std ; 23.53 @@do_copy: 23.54 cli 23.55 +oldGDTR = (pword srcseg) ; don't need src seg/ofs anymore 23.56 sgdt [oldGDTR] 23.57 23.58 ;****** Load gdtr ********************************************** 23.59 - mov eax,cs 23.60 - shl eax,4 23.61 - addzx_e ax,<offset GDT> 23.62 - or [word GDTR],-1 ;GDT limit = 0FFFFh 23.63 - mov [dword GDTR+2],eax ;GDT base 23.64 lgdt [GDTR] 23.65 23.66 ;****** Go into pm ********************************************* 23.67 mov eax,cr0 23.68 inc ax ;CR0_PE on 23.69 - mov cr0,eax 23.70 - jmp short $+2 ;*Required*! 23.71 - ;3+ NOPs also work fine (chkd on 386) 23.72 + lcr0 eax 23.73 ;****** Move data ********************************************** 23.74 push 0008h 23.75 pop ds ;base=0, lim = 4gb 23.76 @@ -196,10 +186,7 @@ 23.77 23.78 ;****** Return to rm ******************************************* 23.79 dec ax ;CR0_PE off 23.80 - mov cr0,eax ;ds/es limits are *not* reset to 64kb 23.81 - ; but who cares :-) 23.82 - jmp short $+2 23.83 - 23.84 + lcr0 eax 23.85 ;****** Return ************************************************* 23.86 lgdt [oldGDTR] 23.87 @@done: 23.88 @@ -212,21 +199,17 @@ 23.89 p386 23.90 leave 23.91 else 23.92 - mov sp,bp 23.93 pop bp 23.94 endif 23.95 ret 14 23.96 23.97 ;****** Const data ********************************************* 23.98 - org $-8 ;save 8 bytes - they are unused anyway 23.99 -;0000: unused 23.100 -GDT dd ?,? 23.101 -;0008: Data seg [0,FFFFFFFF] 23.102 - ; lim_lo base_lo 23.103 - dw 1111111111111111b, 0000000000000000b 23.104 - db 00000000b,10010010b,10001111b,00000000b 23.105 - ; base_med P S D A G ??l_hi base_hi 23.106 - ; Pl E W D 23.107 + 23.108 + extrn gdt_memcpy 23.109 +label GDTR pword 23.110 +gdt_limit dw 0ffffh 23.111 + global gdt_base_memcpy:word 23.112 +gdt_base_memcpy dw offset gdt_memcpy,0 23.113 23.114 endp memcpy32 23.115
24.1 --- a/linld/stuff/src/MEMTOP.ASM Wed Dec 16 17:23:49 2020 +0000 24.2 +++ b/linld/stuff/src/MEMTOP.ASM Fri Jan 08 20:15:35 2021 +0000 24.3 @@ -139,7 +139,8 @@ 24.4 ; we had trouble detecting memory size 24.5 cmp dx,cx 24.6 jb @@set 24.7 - extrn _topmem:dword 24.8 + extrn _cmdnum:dword 24.9 +_topmem = _cmdnum+8 24.10 mov cx,[word _topmem+2] 24.11 inc cx ; jcxnz 24.12 loop @@topmemset 24.13 @@ -186,11 +187,13 @@ 24.14 mov [dword saved15],eax 24.15 else 24.16 mov ax,offset int15_88 24.17 + call saved15z 24.18 + mov ax,cs 24.19 + inc bx 24.20 + inc bx 24.21 +saved15z: 24.22 xchg ax,[es:bx+15*4] 24.23 - mov [word saved15],ax 24.24 - mov ax,cs 24.25 - xchg ax,[es:bx+15*4+2] 24.26 - mov [word saved15+2],ax 24.27 + mov [word bx+saved15],ax 24.28 endif 24.29 ;push ds 24.30 ;pop es
25.1 --- a/linld/stuff/src/TAZBOOT.CPP Wed Dec 16 17:23:49 2020 +0000 25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 25.3 @@ -1,271 +0,0 @@ 25.4 -// This file is distributed under GPL 25.5 -// 25.6 -// TAZBOOT main() lives here 25.7 - 25.8 -#include "crtl.h" 25.9 -#include "crtlx.h" 25.10 -#include "common.h" 25.11 -#include "iso9660.h" 25.12 - 25.13 -struct initrd_info { 25.14 - u32 ofs; 25.15 - u32 size; 25.16 -}; 25.17 -#define MAXINITRD 10 25.18 -static struct initrd_state { 25.19 - struct initrd_info info[MAXINITRD]; 25.20 - u16 cnt; 25.21 -} initrd_state; 25.22 - 25.23 -static void next_chunk(struct image_himem *m) 25.24 -{ 25.25 - m->chunk_size = 0; 25.26 - if (m->state >= initrd_state.cnt) return; 25.27 - struct initrd_info *i = &initrd_state.info[m->state]; 25.28 - m->chunk_size = i->size; 25.29 - m->state++; 25.30 - lseekset2(m->fd,&i->ofs); 25.31 -} 25.32 - 25.33 -static u32 isofilesize4round() 25.34 -{ 25.35 - return (isofilesize+3)&-4; 25.36 -} 25.37 - 25.38 -static void addinitrd() 25.39 -{ 25.40 - u16 *pcnt = &initrd_state.cnt; 25.41 - if (*pcnt >= MAXINITRD) return; 25.42 - struct initrd_info *i = &initrd_state.info[(*pcnt)++]; 25.43 - i->size = isofilesize; 25.44 - i->ofs = isofileofs; 25.45 - initrd.size += isofilesize4round(); 25.46 -} 25.47 - 25.48 -static void load_initrds() 25.49 -{ 25.50 - struct image_himem *m = &initrd; 25.51 - if (!m->size) return; 25.52 - m->next_chunk = next_chunk; 25.53 - m->fd = isofd; 25.54 - m->state = 0; 25.55 - next_chunk(m); 25.56 - load_initrd(); 25.57 -} 25.58 - 25.59 -static char *isokernel() 25.60 -{ 25.61 - struct image_himem *m = ± 25.62 - m->chunk_size = m->size = isofilesize4round(); 25.63 - m->fd = isofd; 25.64 - load_kernel(); 25.65 - return version_string; 25.66 -} 25.67 - 25.68 -static char buf_cmdline[4096]; 25.69 -const char *cmdline = (const char *) buf_cmdline+1; 25.70 -static void bootiso(char **iso) 25.71 -{ 25.72 - const char *init = " rdinit=/init.exe", *mode="menu"; 25.73 - char c; 25.74 - static char rootfs[16], fallback[16], noauto; 25.75 - unsigned long magic; 25.76 - struct isostate *x=&isostate; 25.77 - 25.78 - if (isoreset(*iso) == -1) return; 25.79 -#ifdef WITH_XMM_ALLOC 25.80 - skip_alloc--; 25.81 -#endif 25.82 - base_himem = memtop() /2; 25.83 - //if (base_himem >= _64m) base_himem = _64m; 25.84 - if (* ((char *) &base_himem +3) >= 4) ((short *)&base_himem)[1] = _64m/_64k; 25.85 - isoopen("boot"); 25.86 - if (iso[1] && !strcmp(mode = iso[1], "text")) 25.87 - init = ""; 25.88 - if (isoopen(mode) == -1 || ++noauto == 0) // custom 25.89 - isoopen("bzImage"); // SliTaz 25.90 - magic = kver2ul(isokernel()); 25.91 - for (c = 0, x->curdirsize = 0xFFFF; isoreaddir() != -1;) { 25.92 - if (strstr(x->filename, ".gz")) 25.93 - strcpy(fallback, x->filename); 25.94 - if (strhead(x->filename, "rootfs") == -1 25.95 - || c > x->filename[6]) continue; 25.96 - c = x->filename[6]; 25.97 - strcpy(rootfs, x->filename); 25.98 - } 25.99 - 25.100 - strcatb(buf_cmdline,"autologin bootfrom="); 25.101 - strcat(buf_cmdline,*iso); 25.102 - if (magic < 0x20630) 25.103 - init = ""; // Does not support multiple initramfs 25.104 - 25.105 - if (noauto) { 25.106 - char *s; 25.107 - * (int *) buf_cmdline = 0; 25.108 - iso++; 25.109 - while ((s = *++iso) != NULL) { 25.110 - if (strhead(s,"initrd=") == -1) 25.111 - strcatb(buf_cmdline,s); 25.112 - else if (isoopen(s+7) != -1) 25.113 - addinitrd(); 25.114 - } 25.115 - } 25.116 - else if (magic != 0) { 25.117 - static const unsigned long initrddesc = 18L; 25.118 - 25.119 - if (isoopen("rootfs.gz") != -1 || 25.120 - isoopen(rootfs[0] ? rootfs : fallback) != -1) { 25.121 - addinitrd(); 25.122 - } 25.123 - if (*init) { 25.124 - isolseek(&initrddesc); 25.125 - read(x->fd, &x->filemod, 10); // + x->fileofs & x->filesize 25.126 - magic = x->filemod; 25.127 - x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 25.128 - if (((short *) &x->fileofs)[1] == 0) addinitrd(); 25.129 - else init=""; 25.130 - } 25.131 - strcat(buf_cmdline,init); 25.132 - strcatb(buf_cmdline,"mode="); 25.133 - strcat(buf_cmdline,mode); 25.134 - strcatb(buf_cmdline,"magic="); 25.135 - strcat(buf_cmdline,(char *)utoa(magic)); 25.136 - } 25.137 - load_initrds(); 25.138 - close(x->fd); 25.139 - boot_kernel(); 25.140 -} 25.141 - 25.142 -u32 root_dev; 25.143 -u32 vid_mode; 25.144 -u32 topmem; 25.145 -u32 base_himem; 25.146 -const char* kernel_name = "bzImage"; 25.147 -const char* initrd_name; 25.148 -static char* iso; 25.149 - 25.150 -int main(int argc, char *argv[]) 25.151 -{ 25.152 - ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k 25.153 - 25.154 - if (argc < 2) { 25.155 - try_default_args(); 25.156 -dousage: 25.157 - die("Usage: tazboot [[@commands]|" 25.158 -#ifdef WITH_XMM_ALLOC 25.159 -"[-f]" 25.160 -#endif 25.161 -"[-b base_himem][kernel=<bzImage>] [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\n\n\ 25.162 -Defaults: tazboot kernel=bzImage auto\n\n\ 25.163 -Examples for tazboot.cmd:\n\n\ 25.164 - bootfrom=\\isos\\slitaz-4.0.iso\n\ 25.165 - kernel=boot/bzImage\n\ 25.166 - initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz,\\slitaz\\extrafs.gz\n\ 25.167 - root=/dev/null vga=normal autologin\n\n\ 25.168 - kernel=\\slitaz\\elks\n\ 25.169 - root=/dev/bda1 ro\n"); 25.170 - } 25.171 - bootiso(argv + 1); // iso ? parsing is /init.exe stuff ! 25.172 - for (int i=0;;) { 25.173 - char *s; 25.174 - next: argv++; 25.175 - s=*argv; 25.176 - i++; 25.177 - if (!s) { 25.178 - if (isoreset(iso) != -1) { 25.179 - s = (char *) initrd_name; 25.180 - if (isoopen((char *) kernel_name) != -1) { 25.181 - isokernel(); 25.182 - } 25.183 - if (s) { 25.184 - do { 25.185 - char *p, c; 25.186 - for (p = s; *s && *s != ','; s++); 25.187 - c = *s; *s = 0; 25.188 - if (isoopen(p) != -1) { 25.189 - addinitrd(); 25.190 - } 25.191 - *s = c; 25.192 - if (c) s++; 25.193 - } while (*s); 25.194 - load_initrds(); 25.195 - } 25.196 - } 25.197 - else { 25.198 - load_kernel(); 25.199 - load_initrd(); 25.200 - } 25.201 - boot_kernel(); 25.202 - } 25.203 -#ifdef USE_ARGSTR 25.204 -#ifdef WITH_XMM_ALLOC 25.205 - if ((*(u16 *)s|0x2002) == 0x662F) { // -F /f 25.206 - skip_alloc--; 25.207 - goto next; 25.208 - } 25.209 -#endif 25.210 - if (argstr(s,"kernel/image|initrd|bootfrom/iso",&kernel_name) != -1); 25.211 - else if (argnum(s,"root|vga|mem/-e|-b",&root_dev) != -1); 25.212 - else if(i == 1 && fileexist(s) != -1) { 25.213 - kernel_name = s; 25.214 - } 25.215 - else strcatb(buf_cmdline,*argv); // FIXME mem ? 25.216 - } 25.217 -#else 25.218 - if (strhead(s,"initrd=") != -1) { 25.219 - s += 7; 25.220 - initrd_name = s; 25.221 - } 25.222 - else if (strhead(s,"bootfrom=") != -1) { 25.223 - s += 9; 25.224 - goto set_iso; 25.225 - } 25.226 - else if (strhead(s,"iso=") != -1) { 25.227 - s += 4; 25.228 - set_iso: 25.229 - iso = s; 25.230 - } 25.231 - else if (strhead(s,"image=") != -1) { 25.232 - goto set_kernel; 25.233 - } 25.234 - else if(strhead(s,"vga=") != -1) { 25.235 - *(u16*)&vid_mode = (u16)strtol(s+4); // support normal, extended & ask 25.236 - } 25.237 - else if (strhead(s,"kernel=") != -1) { 25.238 - s++; 25.239 - set_kernel: 25.240 - s += 6; 25.241 - set_kernelz: 25.242 - kernel_name = s; 25.243 - } 25.244 - else switch (*(u16 *)s|0x2002) { 25.245 -#ifdef WITH_XMM_ALLOC 25.246 - case 0x662F: // -F /f 25.247 - skip_alloc--; 25.248 - goto next; 25.249 -#endif 25.250 - case 0x652F: // -E /e 25.251 - s=*++argv; 25.252 - goto set_topmem; 25.253 - case 0x622F: // -B /b 25.254 - argv++; 25.255 - ((u16 *)&base_himem)[1] = (u16)(strtol(*argv)>>16); 25.256 - goto next; 25.257 - default: 25.258 - if(i == 1 && fileexist(s) != -1) { 25.259 - goto set_kernelz; 25.260 - } 25.261 - else { 25.262 - strcatb(buf_cmdline,*argv); 25.263 - if(strhead(s,"root=") != -1) { 25.264 - *(u16*)&root_dev = (u16)strtol(s+5); 25.265 - } 25.266 - if(strhead(s,"mem=") != -1) { 25.267 - s += 4; 25.268 - set_topmem: 25.269 - ((u16 *)&topmem)[1] = (u16)(strtol(s)>>16); 25.270 - } 25.271 - }} 25.272 - } 25.273 -#endif 25.274 -}
26.1 --- a/linld/stuff/src/VCPI.ASM Wed Dec 16 17:23:49 2020 +0000 26.2 +++ b/linld/stuff/src/VCPI.ASM Fri Jan 08 20:15:35 2021 +0000 26.3 @@ -1,421 +1,424 @@ 26.4 -;*************************************************************** 26.5 -;****** This file is distributed under GPL 26.6 -;*************************************************************** 26.7 -;VDPI init: 26.8 -;Call char* prepare_vcpi(void *pagebuf) first to 26.9 -;initialize paging tables needed for vm86. 26.10 -;pagebuf needs to be 8k+4 bytes. Returns ptr to 1st unused byte. 26.11 -;Then call int get_vcpi_interface(). Returns 1 if ok, 0 if bad. 26.12 -; 26.13 -;VCPI use: 26.14 -;u32* malloc_vcpi(u32 size) - source in HIMEM.CPP 26.15 -; Returns ptr to mallocated zero-terminated list of 4k page addrs 26.16 -; Addresses are sorted in ascending order 26.17 -; Never fails (will die if not enough mem) 26.18 -;void read2vcpi(int fd, u32* vp, u32 size, 26.19 -;void* xfer_buf, u16 xfer_size) - source in HIMEM.CPP 26.20 -; Reads opened fd data into malloc_vcpi'ed memory 26.21 -; Dies if file isn't exactly 'size' bytes long 26.22 -; Needs intermediate buffer of exactly Nx4k bytes 26.23 -;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs) 26.24 -; copies 4k from conventional memory to VCPI 26.25 -;void _vm2rm() 26.26 -; switches you from vm86 to plain real mode 26.27 - 26.28 - 26.29 - ideal 26.30 - %PAGESIZE 1000 26.31 - %crefref 26.32 - %noincl 26.33 - %nomacs 26.34 - p386 26.35 - 26.36 -;****** Stuff for declaring descriptors 26.37 -struc descr 26.38 -limit dw ? 26.39 -base0 dw ? 26.40 -base16 db ? 26.41 -type db ? 26.42 -limit16 db ? 26.43 -base24 db ? 26.44 -ends descr 26.45 -macro descriptor name,typ,plevel,present,limit,gran,base 26.46 - ;;name descr <limit and 0ffffh,base and 0ffffh,low (base shr 16),typ or plevel or present,(limit shr 16) or gran,high (base shr 16)> 26.47 - name descr <limit and 0ffffh,base ,0 ,typ or plevel or present,(limit shr 16) or gran,0 > 26.48 -endm 26.49 -; decriptor types (bit0..4 of descr.type ) 26.50 -tss386_avail = 09h 26.51 -data_seg = 00010000b ; data segment 26.52 - expand_down = 00000100b ; =1 limit counts down from base 26.53 - writable = 00000010b ; =1 if write access allowed to data segment 26.54 -code_seg = 00011000b ; code segment 26.55 - conforming = 00000100b ; =1 code can be accesses and executed at any PL 26.56 - readable = 00000010b ; =1 if code also can be read (cannot be ovwritten) 26.57 -; privilege levels (bit5..6 of descr.type ) 26.58 -priv0 = 00000000b 26.59 -priv1 = 00100000b 26.60 -priv2 = 01000000b 26.61 -priv3 = 01100000b 26.62 -; segment present bit (bit7 of descr.type ) 26.63 -is_present = 10000000b 26.64 -not_present = 00000000b 26.65 -;definition of granularity ( bits6..7 in descr.limit16 ) 26.66 -gran_byte = 00000000b 26.67 -gran_page = 10000000b ; 4k granularity 26.68 -use_16 = 00000000b 26.69 -use_32 = 01000000b 26.70 - 26.71 -;****** rm32,imm16 helpers 26.72 -macro addzx_e rm,i 26.73 - db 66h 26.74 - add rm,i 26.75 - dw 0 26.76 -endm 26.77 - 26.78 - 26.79 - group DGROUP _TEXT,_BSS 26.80 - assume cs:DGROUP,ds:DGROUP 26.81 - 26.82 - segment _BSS byte public use16 'BSS' 26.83 - 26.84 -tss dd ?,? ;enough, we'll never use it anyway 26.85 - 26.86 - ends _BSS 26.87 - 26.88 - segment _TEXT byte public use16 'CODE' 26.89 - 26.90 -label gdt byte 26.91 -gdt_null descr <?> ;0000 26.92 -gdt_vcpi descr <?> ;0008 26.93 -gdt_vcpi2 descr <?> ;0010 26.94 -gdt_vcpi3 descr <?> ;0018 26.95 -descriptor gdt_abs ,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_32),0 26.96 -;Note: code/data segs must be flagged use16 (i.e. use ip/sp, not eip/esp) 26.97 -;Note: base addrs will be fixed up in prepare_vcpi() 26.98 -descriptor gdt_code,(code_seg+readable),priv0,is_present,0fffffh,(gran_page+use_16),0 26.99 +;*************************************************************** 26.100 +;****** This file is distributed under GPL 26.101 +;*************************************************************** 26.102 +;VDPI init: 26.103 +;Call char* prepare_vcpi(void *pagebuf) first to 26.104 +;initialize paging tables needed for vm86. 26.105 +;pagebuf needs to be 8k+4 bytes. Returns ptr to 1st unused byte. 26.106 +;Then call int get_vcpi_interface(). Returns 1 if ok, 0 if bad. 26.107 +; 26.108 +;VCPI use: 26.109 +;u32* malloc_vcpi(u32 size) - source in HIMEM.CPP 26.110 +; Returns ptr to mallocated zero-terminated list of 4k page addrs 26.111 +; Addresses are sorted in ascending order 26.112 +; Never fails (will die if not enough mem) 26.113 +;void read2vcpi(int fd, u32* vp, u32 size, 26.114 +;void* xfer_buf, u16 xfer_size) - source in HIMEM.CPP 26.115 +; Reads opened fd data into malloc_vcpi'ed memory 26.116 +; Dies if file isn't exactly 'size' bytes long 26.117 +; Needs intermediate buffer of exactly Nx4k bytes 26.118 +;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs) 26.119 +; copies 4k from conventional memory to VCPI 26.120 +;void _vm2rm() 26.121 +; switches you from vm86 to plain real mode 26.122 + 26.123 + 26.124 + ideal 26.125 + %PAGESIZE 1000 26.126 + %crefref 26.127 + %noincl 26.128 + %nomacs 26.129 + p386 26.130 + 26.131 +;****** Stuff for declaring descriptors 26.132 +struc descr 26.133 +limit dw ? 26.134 +base0 dw ? 26.135 +base16 db ? 26.136 +type db ? 26.137 +limit16 db ? 26.138 +base24 db ? 26.139 +ends descr 26.140 +macro descriptor name,typ,plevel,present,limit,gran,base 26.141 + ;;name descr <limit and 0ffffh,base and 0ffffh,low (base shr 16),typ or plevel or present,(limit shr 16) or gran,high (base shr 16)> 26.142 + name descr <limit and 0ffffh,base ,0 ,typ or plevel or present,(limit shr 16) or gran,0 > 26.143 +endm 26.144 +; decriptor types (bit0..4 of descr.type ) 26.145 +tss386_avail = 09h 26.146 +data_seg = 00010000b ; data segment 26.147 + expand_down = 00000100b ; =1 limit counts down from base 26.148 + writable = 00000010b ; =1 if write access allowed to data segment 26.149 +code_seg = 00011000b ; code segment 26.150 + conforming = 00000100b ; =1 code can be accesses and executed at any PL 26.151 + readable = 00000010b ; =1 if code also can be read (cannot be ovwritten) 26.152 +; privilege levels (bit5..6 of descr.type ) 26.153 +priv0 = 00000000b 26.154 +priv1 = 00100000b 26.155 +priv2 = 01000000b 26.156 +priv3 = 01100000b 26.157 +; segment present bit (bit7 of descr.type ) 26.158 +is_present = 10000000b 26.159 +not_present = 00000000b 26.160 +;definition of granularity ( bits6..7 in descr.limit16 ) 26.161 +gran_byte = 00000000b 26.162 +gran_page = 10000000b ; 4k granularity 26.163 +use_16 = 00000000b 26.164 +use_32 = 01000000b 26.165 + 26.166 +;****** rm32,imm16 helper 26.167 +macro movzx_e rm,i 26.168 + db 66h 26.169 + mov rm,i 26.170 + dw 0 26.171 +endm 26.172 + 26.173 +macro pushd v 26.174 + db 66h 26.175 + push v 26.176 +endm 26.177 + 26.178 + group DGROUP _TEXT 26.179 + assume cs:DGROUP,ds:DGROUP 26.180 + 26.181 + segment _TEXT byte public use16 'CODE' 26.182 + 26.183 +;*************************************************************** 26.184 +;int get_vcpi_interface(); 26.185 +;****** Return: Z - page mapping for low 640k is 1:1 26.186 +;****** NZ - otherwise (it's bad) 26.187 +;****** Uses: Flags 26.188 +;*************************************************************** 26.189 + ;global _get_vcpi_interface:near 26.190 + proc _get_vcpi_interface near 26.191 + 26.192 + ;push si di 26.193 + 26.194 +; Get and save VCPI pm interface 26.195 + ;mov si,offset gdt_vcpi ;DS:DI => 3 GDT entries for VCPI 26.196 + ;mov di,[si+page0_ofs-gdt_vcpi] ;ES:DI => page0 26.197 + ;push ds 26.198 + ;pop es 26.199 + ;push di 26.200 + ;mov ax,0DE01h ;get vcpi pm interface 26.201 + int 67h 26.202 + xchg [si+vcpi_pm_entry-gdt_vcpi],ebx ; bx=((640*1024) shr 12) 26.203 + ;xor bx,bx 26.204 + 26.205 +; Check that mapping for low 640k is 1:1 26.206 + pop si ; [page0_ofs] 26.207 + ;cld 26.208 + mov cx,bx 26.209 +@@map_chk: 26.210 + lodsd 26.211 + shr eax,12 26.212 + add al,cl 26.213 + cmp al,((640*1024) shr 12) 26.214 + loope @@map_chk 26.215 +; Return 26.216 +@@bad: 26.217 + ret 26.218 + endp _get_vcpi_interface 26.219 + 26.220 + 26.221 +;*************************************************************** 26.222 +;char* prepare_vcpi(void *pagebuf); 26.223 +;****** Return: AX=>first unused byte in pagebuf 26.224 +;****** Uses: Flags 26.225 +;*************************************************************** 26.226 + global prepare_vcpi:near 26.227 + proc prepare_vcpi near 26.228 + 26.229 +;Calculate pagedir/page0 addrs, initialize cr3 and pagedir[0] 26.230 +; heap_top = prepare_vcpi(malloc_or_die(8*1024+4)); 26.231 + 26.232 + ;mov edx,cs 26.233 + ;shl edx,4 ;edx = linear addr of CS 26.234 + mov si,offset gdt_vcpi 26.235 +; Fix up base of some gdt descriptors 26.236 +; Note: 'add [dword xx.base0],edx' actually updates 24 bit quantity! 26.237 +; Do NOT replace with mov! 26.238 + mov ebx,10000h-28h 26.239 + add [dword si+sw2pm_addr-gdt_vcpi],edx 26.240 + add [dword si+sw2pm_idtr_ptr-gdt_vcpi],edx 26.241 +@@fixup: 26.242 + add [dword bx+si+(gdt_code.base0)-gdt_vcpi+28h],edx 26.243 + add bx,8 26.244 + js @@fixup 26.245 + mov bh,10h 26.246 + extrn _heap_top:word 26.247 + movzx eax,[_heap_top] 26.248 + add eax,edx 26.249 + and ax,0f000h ;eax = 4k aligned linear addr of pagebuf 26.250 + add eax,ebx ;eax=page0 linear addr 26.251 + add [si+sw2pm_cr3-gdt_vcpi],eax 26.252 + mov edi,eax 26.253 + sub edi,edx 26.254 + mov al,3 ;add present+writable bits 26.255 + mov [bx+di],eax ;stuff it into pagedir[0] 26.256 + push ds 26.257 + pop es ;es:di->page0,es:di+1000h->pagedir 26.258 + ;page directory will use only one entry (4 bytes): 26.259 + ;cr3 => pagedir => page0 => ######## 26.260 + ; (1 entry) (1024 => # 4M # 26.261 + ; entries)=> # page # 26.262 + ; => ######## 26.263 +; Return 26.264 + lea ax,[bx+di+4] 26.265 + mov [_heap_top],ax 26.266 + ;ret 26.267 + push di 26.268 + mov ax,0DE01h ;get vcpi pm interface 26.269 + jmp _get_vcpi_interface 26.270 + 26.271 + endp prepare_vcpi 26.272 + 26.273 + org $-40 26.274 +tss dd ?,? ;enough, we'll never use it anyway 26.275 +label gdt byte 26.276 +gdt_null descr <?> ;0000 26.277 +gdt_vcpi descr <?> ;0008 26.278 +gdt_vcpi2 descr <?> ;0010 26.279 +gdt_vcpi3 descr <?> ;0018 26.280 + org $-8 26.281 + global gdt_memcpy:descr 26.282 +gdt_memcpy descr <?> 26.283 +descriptor gdt_abs ,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_32),0 26.284 +;Note: code/data segs must be flagged use16 (i.e. use ip/sp, not eip/esp) 26.285 +;Note: base addrs will be fixed up in prepare_vcpi() 26.286 +descriptor gdt_code,(code_seg+readable),priv0,is_present,0fffffh,(gran_page+use_16),0 26.287 global gdt_data:descr 26.288 -descriptor gdt_data,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_16),0 26.289 -descriptor gdt_tss ,tss386_avail ,priv0,is_present,0ffh ,gran_byte ,<offset tss> 26.290 -SEL_VCPI = (gdt_vcpi - gdt_null) 26.291 -SEL_TSS = (gdt_tss - gdt_null) 26.292 -SEL_ABS = (gdt_abs - gdt_null) 26.293 -SEL_CODE = (gdt_code - gdt_null) 26.294 -SEL_DATA = (gdt_data - gdt_null) 26.295 - 26.296 -label gdtr pword 26.297 -gdt_lim dw 0ffffh 26.298 -gdt_base dw offset gdt,0 26.299 - 26.300 -;Note: layout dictated by vcpi api, don't rearrange! 26.301 -label sw2pm_params byte 26.302 -;Note: base addrs will be fixed up in prepare_vcpi() 26.303 -label pagedir_laddr dword 26.304 -sw2pm_cr3 dd 1000h 26.305 -sw2pm_gdtr_ptr dw offset gdtr,0 26.306 -sw2pm_idtr_ptr dw offset idtr,0 26.307 -sw2pm_ldtr dw 0 ;we don't need it 26.308 -sw2pm_tr dw SEL_TSS ;vcpi thinks we need it... can't set to 0 26.309 -sw2pm_jumpaddr dd 0 26.310 - dw SEL_CODE 26.311 - 26.312 -vcpi_pm_entry dd 0 26.313 - dw SEL_VCPI 26.314 - 26.315 -label idtr pword 26.316 -idt_lim dw 03ffh ;we won't enable ints, 26.317 -idt_base dd 0 ; so let's leave it the same as for rm 26.318 - 26.319 - 26.320 -;*************************************************************** 26.321 -;char* prepare_vcpi(void *pagebuf); 26.322 -;****** Return: AX=>first unused byte in pagebuf 26.323 -;****** Uses: Flags 26.324 -;*************************************************************** 26.325 - global prepare_vcpi:near 26.326 - proc prepare_vcpi near 26.327 - 26.328 - ;pop ax 26.329 - ;pop bx ;pgbuf 26.330 - ;push bx 26.331 - ;push ax 26.332 - 26.333 -;Calculate pagedir/page0 addrs, initialize cr3 and pagedir[0] 26.334 -; heap_top = prepare_vcpi(malloc_or_die(8*1024+4)); 26.335 - 26.336 - mov edx,cs 26.337 - shl edx,4 ;edx = linear addr of CS 26.338 - mov si,offset gdt_vcpi 26.339 -; Fix up base of some gdt descriptors 26.340 -; Note: 'add [dword xx.base0],edx' actually updates 24 bit quantity! 26.341 -; Do NOT replace with mov! 26.342 - mov ebx,10000h-28h 26.343 - add [dword bx+si+sw2pm_idtr_ptr-gdt_vcpi+28h],edx 26.344 -@@fixup: 26.345 - add [dword bx+si+(gdt_code.base0)-gdt_vcpi+28h],edx 26.346 - add bx,8 26.347 - js @@fixup 26.348 - mov bh,10h 26.349 - extrn _heap_top:word 26.350 - movzx eax,[_heap_top] 26.351 - add eax,edx 26.352 - and ax,0f000h ;eax = 4k aligned linear addr of pagebuf 26.353 - add eax,ebx ;eax=page0 linear addr 26.354 - add [si+sw2pm_cr3-gdt_vcpi],eax 26.355 - mov edi,eax 26.356 - sub edi,edx 26.357 - mov al,3 ;add present+writable bits 26.358 - mov [bx+di],eax ;stuff it into pagedir[0] 26.359 - push ds 26.360 - pop es ;es:di->page0,es:di+1000h->pagedir 26.361 - ;page directory will use only one entry (4 bytes): 26.362 - ;cr3 => pagedir => page0 => ######## 26.363 - ; (1 entry) (1024 => # 4M # 26.364 - ; entries)=> # page # 26.365 - ; => ######## 26.366 -; Return 26.367 - lea ax,[bx+di+4] 26.368 - mov [_heap_top],ax 26.369 - ;ret 26.370 - 26.371 - endp prepare_vcpi 26.372 - 26.373 - 26.374 -;*************************************************************** 26.375 -;int get_vcpi_interface(); 26.376 -;****** Return: Z - page mapping for low 640k is 1:1 26.377 -;****** NZ - otherwise (it's bad) 26.378 -;****** Uses: Flags 26.379 -;*************************************************************** 26.380 - ;global _get_vcpi_interface:near 26.381 - proc _get_vcpi_interface near 26.382 - 26.383 - ;push si di 26.384 - 26.385 -; Get and save VCPI pm interface 26.386 - ;mov si,offset gdt_vcpi ;DS:DI => 3 GDT entries for VCPI 26.387 - ;mov di,[si+page0_ofs-gdt_vcpi] ;ES:DI => page0 26.388 - ;push ds 26.389 - ;pop es 26.390 - push di 26.391 - mov ax,0DE01h ;get vcpi pm interface 26.392 - int 67h 26.393 - xchg [vcpi_pm_entry],ebx ;clear ebx 26.394 - ;xor bx,bx 26.395 - 26.396 -; Check that mapping for low 640k is 1:1 26.397 - pop si ; [page0_ofs] 26.398 - ;cld 26.399 -@@map_chk: 26.400 - lodsd 26.401 - shr eax,12 26.402 - cmp ax,bx 26.403 - jne @@bad 26.404 - inc bx 26.405 - cmp al,((640*1024) shr 12)-1 26.406 - jne @@map_chk 26.407 -; Return 26.408 -@@bad: 26.409 - ret 26.410 - endp _get_vcpi_interface 26.411 - 26.412 - 26.413 -;*************************************************************** 26.414 -;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs); 26.415 -;*************************************************************** 26.416 -;****** Copies PAGE_SIZE bytes 26.417 -;****** Uses: Flags 26.418 -;*************************************************************** 26.419 - global vcpi_pm_copy_routine:near 26.420 - proc vcpi_pm_copy_routine near 26.421 - 26.422 - arg dstofs :dword, \ 26.423 - srcseg :word, \ 26.424 - srcofs :dword = PARAM_SIZE 26.425 - 26.426 -struc pm_regs 26.427 -$$retaddr dw ? 26.428 -$$edi dd ? 26.429 -$$esi dd ? 26.430 -$$ebp dd ? 26.431 -$$esp dd ? 26.432 -$$ebx dd ? 26.433 -$$edx dd ? 26.434 -$$ecx dd ? 26.435 -$$eax dd ? 26.436 -ends 26.437 - 26.438 -;*************************************************************** 26.439 -;****** Helper: goes into 16bit pm and calls routine (addr on stk) 26.440 -;*************************************************************** 26.441 - mov bp,sp ; ss:bp => struct pm_regs 26.442 - 26.443 - xor ax,ax ; IRET stack for return to vm 26.444 - push ax gs ; (9 dwords) 26.445 - push ax fs ; 26.446 - push ax ds ; 26.447 - push ax es ; 26.448 - push ax ss ; 26.449 - push ebp ; esp 26.450 - pushfd ; eflags: IF saved here 26.451 - push ax cs ; 26.452 - push ax ;\eip 26.453 - push offset @@vm_ret ;/ 26.454 - 26.455 - ;;mov [saved_xx],xx ;use if your vcpi trashes bp/etc 26.456 - 26.457 - call switch_to_pm 26.458 - 26.459 -; Now we are in 16-bit protected mode 26.460 - mov ax,SEL_DATA 26.461 - mov ss,ax 26.462 - ;;mov ds,ax 26.463 - ;;mov es,ax 26.464 - ;;mov fs,ax 26.465 - ;;mov gs,ax 26.466 - assume nothing 26.467 - assume cs:DGROUP 26.468 - 26.469 - ;;mov xx,[saved_xx] ;use if your vcpi trashes bp/etc 26.470 - lea sp,[bp-9*4] ;else we can do this trick with bp 26.471 - 26.472 -; Call the routine (bp points to params on stack if any) 26.473 - mov bp,[word (pm_regs bp).$$ebp] ;ss:bp => params 26.474 - call do_memcpy_vcpi 26.475 - 26.476 -; Ok, let's return to vm 26.477 - mov ax,0DE0Ch ; maybe we need whole eax? 26.478 - cli ; to be safe 26.479 - clts ; 26.480 - ;;push SEL_ABS ; vcpi wants ds=all_addrspace 26.481 - ;;pop ds ; 26.482 - call [pword cs:vcpi_pm_entry] 26.483 -@@vm_ret: 26.484 -; Now we are in vm86 mode. Sregs, esp, eflags (IF) restored from IRET stack 26.485 - ret 26.486 - 26.487 -;*************************************************************** 26.488 -switch_to_pm: 26.489 - assume cs:DGROUP,ds:DGROUP 26.490 - pop [word sw2pm_jumpaddr] 26.491 - ;mov [word sw2pm_jumpaddr+2],0 26.492 - ;mov [word sw2pm_jumpaddr+4],SEL_CODE 26.493 - mov esi,cs 26.494 - shl esi,4 26.495 - addzx_e si,<offset sw2pm_params> 26.496 - mov ax,0DE0Ch ; vcpi: switch to pm 26.497 - cli 26.498 - int 67h 26.499 - 26.500 -;*************************************************************** 26.501 -;****** Helper: This is where real copy is done 26.502 -;*************************************************************** 26.503 -label do_memcpy_vcpi near 26.504 - 26.505 -; Note: ss:bp => params 26.506 -; Move data 26.507 - mov al,SEL_ABS 26.508 - mov ds,ax 26.509 - mov es,ax 26.510 - assume nothing 26.511 - assume cs:DGROUP 26.512 - 26.513 - ; Set up target addr: 26.514 - ; replace page mapping for page at 0 so 26.515 - ; that it points to dstofs 26.516 - mov eax,[dstofs] 26.517 - mov al,03h ; writeable, present 26.518 - call @@set_mapping 26.519 - ;push eax ;X we'll need to restore mapping... 26.520 - xor edi,edi ;es:edi => remapped page 26.521 - 26.522 - ; Set up source addr 26.523 - mov esi,[srcofs] 26.524 - 26.525 - ; Do copying 26.526 - xor ecx,ecx 26.527 - mov ch,4096/256 26.528 - ;cld 26.529 -;; cmp esi,edi 26.530 -;; jae @@do_copy 26.531 -;; add esi,ecx ;src<dst: we must do 26.532 -;; dec esi ; copy backwards to avoid 26.533 -;; add edi,ecx ; overwrite bug 26.534 -;; dec edi ; 26.535 -;; std ; 26.536 -;;@@do_copy: 26.537 - db 67h ;address width override for esi/edi 26.538 - rep movsb 26.539 -;; cld 26.540 - 26.541 - ; Restore page mapping for page at 0 26.542 - ;pop eax ;X 26.543 -@@set_mapping: 26.544 - mov esi,[cs:sw2pm_cr3] 26.545 - xchg [esi-1000h],eax ; restore page0[0] 26.546 - mov ecx,cr3 ; reload TLB cache 26.547 - mov cr3,ecx ; 26.548 -; Return 26.549 +descriptor gdt_data,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_16),0 26.550 +descriptor gdt_tss ,tss386_avail ,priv0,is_present,0ffh ,gran_byte ,<offset tss> 26.551 +SEL_VCPI = (gdt_vcpi - gdt_null) 26.552 +SEL_TSS = (gdt_tss - gdt_null) 26.553 +SEL_ABS = (gdt_abs - gdt_null) 26.554 +SEL_CODE = (gdt_code - gdt_null) 26.555 +SEL_DATA = (gdt_data - gdt_null) 26.556 + 26.557 +label gdtr pword 26.558 +gdt_lim dw 0ffffh 26.559 +gdt_base dw offset gdt,0 26.560 + 26.561 +;Note: layout dictated by vcpi api, don't rearrange! 26.562 +label sw2pm_params byte 26.563 +;Note: base addrs will be fixed up in prepare_vcpi() 26.564 +label pagedir_laddr dword 26.565 +sw2pm_cr3 dd 1000h 26.566 +sw2pm_gdtr_ptr dw offset gdtr,0 26.567 +sw2pm_idtr_ptr dw offset idtr,0 26.568 +sw2pm_ldtr dw 0 ;we don't need it 26.569 +sw2pm_tr dw SEL_TSS ;vcpi thinks we need it... can't set to 0 26.570 +sw2pm_jumpaddr dd 0 26.571 + dw SEL_CODE 26.572 + 26.573 +vcpi_pm_entry dd ((640*1024) shr 12) 26.574 + dw SEL_VCPI 26.575 + 26.576 +label idtr pword 26.577 +idt_lim dw 03ffh ;we won't enable ints, 26.578 +idt_base dd 0 ; so let's leave it the same as for rm 26.579 + 26.580 +;*************************************************************** 26.581 +switch_to_pm: 26.582 + assume cs:DGROUP,ds:DGROUP 26.583 + mov edx,esi 26.584 + movzx_e si,<offset sw2pm_params> 26.585 + org $-4 26.586 +sw2pm_addr dd ? 26.587 + pop [word sw2pm_jumpaddr] ; CS:EIP of protected mode entry-point 26.588 + ;mov [word sw2pm_jumpaddr+2],0 26.589 + ;mov [word sw2pm_jumpaddr+4],SEL_CODE 26.590 + mov ax,0DE0Ch ; vcpi: switch to pm 26.591 + cli ; load GDTR LDTR TR need 16 bytes in SS:ESP 26.592 + int 67h ; EAX, ESI, DS, ES, FS, GS destroyed 26.593 + 26.594 + 26.595 +;*************************************************************** 26.596 +;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs); 26.597 +;*************************************************************** 26.598 +;****** Copies PAGE_SIZE bytes 26.599 +;****** Uses: Flags 26.600 +;*************************************************************** 26.601 + global vcpi_pm_copy_routine:near 26.602 + proc vcpi_pm_copy_routine near 26.603 + 26.604 +struc pm_regs 26.605 +$$retaddr dw ? 26.606 +$$edi dd ? 26.607 +$$esi dd ? 26.608 +$$ebp dd ? 26.609 +$$esp dd ? 26.610 +$$ebx dd ? 26.611 +$$edx dd ? 26.612 +$$ecx dd ? 26.613 +$$eax dd ? 26.614 +ends 26.615 + 26.616 +;*************************************************************** 26.617 +;****** Helper: goes into 16bit pm and calls routine (addr on stk) 26.618 +;*************************************************************** 26.619 + mov bp,sp ; ss:bp => struct pm_regs 26.620 + 26.621 + pushd gs ; IRET stack for return to vm 26.622 + pushd fs ; (9 dwords) 26.623 + pushd ds ; 26.624 + pushd es ; 26.625 + pushd ss ; 26.626 + push ebp ; esp 26.627 + pushfd ; eflags: IF saved here 26.628 + pushd cs ; 26.629 + push 0 ;\eip 26.630 + push offset @@vm_ret ;/ 26.631 + 26.632 + ;;mov [saved_xx],xx ;use if your vcpi trashes bp/etc 26.633 + 26.634 + call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed 26.635 + assume nothing 26.636 + assume cs:DGROUP 26.637 + 26.638 +; Now we are in 16-bit protected mode 26.639 + ;push SEL_DATA 26.640 + ;pop ss 26.641 + mov ax,SEL_DATA 26.642 + mov ss,ax 26.643 + ;;mov ds,ax 26.644 + ;;mov es,ax 26.645 + ;;mov fs,ax 26.646 + ;;mov gs,ax 26.647 + 26.648 + ;;mov xx,[saved_xx] ;use if your vcpi trashes bp/etc 26.649 + lea sp,[bp-9*4] ;else we can do this trick with bp 26.650 + 26.651 +; Call the routine (bp points to params on stack if any) 26.652 + call do_memcpy_vcpi 26.653 + 26.654 +; Ok, let's return to vm 26.655 + mov ax,0DE0Ch ; maybe we need whole eax? 26.656 + cli ; to be safe 26.657 + clts ; 26.658 + ;;push SEL_ABS ; vcpi wants ds=all_addrspace 26.659 + ;;pop ds ; (done by do_memcpy_vcpi) 26.660 + call [pword cs:vcpi_pm_entry] 26.661 +@@vm_ret: 26.662 +; Now we are in vm86 mode. Sregs, esp, eflags (IF) restored from IRET stack 26.663 + ret 26.664 + 26.665 +;*************************************************************** 26.666 + 26.667 +;*************************************************************** 26.668 +;****** Helper: This is where real copy is done 26.669 +;*************************************************************** 26.670 +label do_memcpy_vcpi near 26.671 + 26.672 +; Note: ss:bp => params 26.673 +; Move data 26.674 + push SEL_ABS 26.675 + pop ds 26.676 + push ds 26.677 + pop es 26.678 + assume nothing 26.679 + assume cs:DGROUP 26.680 + 26.681 + ; Set up target addr: 26.682 + ; replace page mapping for page at 0 so 26.683 + ; that it points to dstofs 26.684 + xchg eax,edi 26.685 + mov al,03h ; writeable, present 26.686 + call @@set_mapping 26.687 + ;push eax ;X we'll need to restore mapping... 26.688 + xor edi,edi ;es:edi => remapped page 26.689 + 26.690 + ; Set up source addr 26.691 + mov esi,edx 26.692 + 26.693 + ; Do copying 26.694 +; xor ecx,ecx 26.695 +; mov ch,4096/256 26.696 + ;cld 26.697 +;; cmp esi,edi 26.698 +;; jae @@do_copy 26.699 +;; add esi,ecx ;src<dst: we must do 26.700 +;; dec esi ; copy backwards to avoid 26.701 +;; add edi,ecx ; overwrite bug 26.702 +;; dec edi ; 26.703 +;; std ; 26.704 +;;@@do_copy: 26.705 + db 67h ;address width override for esi/edi 26.706 + rep movsb 26.707 +;; cld 26.708 + 26.709 + ; Restore page mapping for page at 0 26.710 + ;pop eax ;X 26.711 +@@set_mapping: 26.712 + mov esi,[cs:sw2pm_cr3] 26.713 + xchg [esi-1000h],eax ; restore page0[0] 26.714 + mov esi,cr3 ; reload TLB cache 26.715 + mov cr3,esi ; 26.716 +; Return 26.717 vcpi_ret: 26.718 - ret 26.719 - 26.720 - endp vcpi_pm_copy_routine 26.721 - assume cs:DGROUP,ds:DGROUP 26.722 - 26.723 - 26.724 -;*************************************************************** 26.725 -;void _vm2rm(); 26.726 -;*************************************************************** 26.727 -;****** Uses: Flags 26.728 -;*************************************************************** 26.729 - global _vm2rm:near 26.730 - proc _vm2rm near 26.731 - 26.732 - ifdef NO386 26.733 - p8086 26.734 - extrn _vcpi:byte 26.735 - test [_vcpi],-1 26.736 - else 26.737 - p386 26.738 - smsw ax ;SMSW cannot be trapped! :-) 26.739 - and al,1 ;MSW_PE 26.740 - endif 26.741 - jz vcpi_ret 26.742 - p386 26.743 - pop ax 26.744 - push cs ;* 26.745 - push ax 26.746 - push si 26.747 - push ds 26.748 - extrn sssp:word 26.749 - mov [sssp],sp 26.750 - ;mov [sssp+2],ss 26.751 - 26.752 - call switch_to_pm 26.753 - 26.754 -; Now we are in 16-bit protected mode 26.755 - mov ax,SEL_DATA ; load data sregs with limit >=64k 26.756 - mov ss,ax ; or you may get limit violations 26.757 - mov ds,ax ; later in rm 26.758 - ;mov es,ax ; (actually I prefer 4gig limits :-) 26.759 - ;mov fs,ax ; 26.760 - ;mov gs,ax ; 26.761 - 26.762 -; Black magic here 26.763 - mov eax,cr0 26.764 - and eax,7ffffffeh ; clear PG,P bits 26.765 - mov cr0,eax ; look mommy, we're in rm now! 26.766 - mov cr3,eax ; flush TLB cache 26.767 - 26.768 -; Now we are in rm, but not yet: have to restore sregs: 26.769 - lss sp,[dword sssp]; SS 26.770 - pop ds ; DS 26.771 - pop si 26.772 - retf ; CS 26.773 - 26.774 - endp _vm2rm 26.775 - 26.776 - ends _TEXT 26.777 - 26.778 - end 26.779 - 26.780 -;###### END OF FILE ############################################ 26.781 + ret 26.782 + 26.783 + endp vcpi_pm_copy_routine 26.784 + 26.785 + 26.786 +;*************************************************************** 26.787 +;void _vm2rm(); 26.788 +;*************************************************************** 26.789 +;****** Uses: Flags 26.790 +;*************************************************************** 26.791 + global _vm2rm:near 26.792 + proc _vm2rm near 26.793 + 26.794 + assume cs:DGROUP,ds:DGROUP 26.795 + extrn sssp:dword 26.796 + ifdef NO386 26.797 + p8086 26.798 + extrn _vcpi:byte 26.799 + mov bx,offset sssp 26.800 + test [_vcpi],bh 26.801 + jz vcpi_ret 26.802 + else 26.803 + p386 26.804 + smsw ax ;SMSW cannot be trapped! :-) 26.805 + and al,1 ;MSW_PE 26.806 + jz vcpi_ret 26.807 + mov bx,offset sssp 26.808 + endif 26.809 + p386 26.810 + pop ax 26.811 + push cs ;* 26.812 + push ax 26.813 + push ds 26.814 + mov [bx],sp 26.815 + ;mov [bx+2],ss 26.816 + 26.817 + call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed 26.818 + assume nothing 26.819 + assume cs:DGROUP 26.820 + 26.821 +; Now we are in 16-bit protected mode 26.822 + ;mov ax,SEL_DATA ; load data sregs with limit >=64k 26.823 + ;mov ss,ax ; or you may get limit violations 26.824 + ;mov ds,ax ; later in rm 26.825 + ;mov es,ax ; (actually I prefer 4gig limits :-) 26.826 + ;mov fs,ax ; 26.827 + ;mov gs,ax ; 26.828 + 26.829 +; Black magic here 26.830 + mov eax,cr0 26.831 + and eax,7ffffffeh ; clear PG,P bits 26.832 + mov cr0,eax ; look mommy, we're in rm now! 26.833 + mov cr3,eax ; flush TLB cache 26.834 + 26.835 +; Now we are in rm, but not yet: have to restore sregs: 26.836 + lss sp,[cs:bx] ; SS 26.837 + pop ds ; DS 26.838 + retf ; CS 26.839 + 26.840 + endp _vm2rm 26.841 + 26.842 + ends _TEXT 26.843 + 26.844 + end 26.845 + 26.846 +;###### END OF FILE ############################################
27.1 --- a/linld/stuff/src/XMM.ASM Wed Dec 16 17:23:49 2020 +0000 27.2 +++ b/linld/stuff/src/XMM.ASM Fri Jan 08 20:15:35 2021 +0000 27.3 @@ -12,15 +12,9 @@ 27.4 p386 27.5 endif 27.6 27.7 - group DGROUP _TEXT,_BSS 27.8 + group DGROUP _TEXT 27.9 assume cs:DGROUP,ds:DGROUP 27.10 27.11 - segment _BSS byte public use16 'BSS' 27.12 - 27.13 -xmm_handler dd ? 27.14 - 27.15 - ends _BSS 27.16 - 27.17 segment _TEXT byte public use16 'CODE' 27.18 27.19 ;*************************************************************** 27.20 @@ -42,47 +36,30 @@ 27.21 ;*************************************************************** 27.22 proc xmm_driver near 27.23 27.24 - push si 27.25 - mov si,offset xmm_handler 27.26 - ifndef NO386 27.27 - cmp [dword si],0 27.28 - jne @@gotit 27.29 push ax ; save cmd 27.30 mov ax,4300h ; installation check in al 27.31 - else 27.32 - push ax ; save cmd 27.33 - lodsw 27.34 - or ax,[word si] 27.35 - jne @@gotit 27.36 - mov ah,43h ; installation check in al 27.37 - endif 27.38 - 27.39 int 2fh 27.40 - mov bx,offset xmm_fail 27.41 - push ds 27.42 + mov bx,offset @@xmm_fail 27.43 + push cs 27.44 pop es 27.45 cmp al,80h 27.46 jne @@err 27.47 mov ax,4310h ; get driver address in es:bx 27.48 int 2fh 27.49 @@err: 27.50 - ifndef NO386 27.51 pop ax ; restore cmd 27.52 - mov [si],bx 27.53 - mov [si+2],es 27.54 -@@gotit: 27.55 - call [dword si] ; far ptr [si] 27.56 - else 27.57 - mov [si-2],bx 27.58 - mov [si],es 27.59 -@@gotit: 27.60 - pop ax ; restore cmd 27.61 - call [dword si-2] ; far ptr [si-2] 27.62 - endif 27.63 + 27.64 + push cs ; call far 27.65 + call @@jmp_esbx 27.66 dec ax ; Z=1=OK 27.67 - pop si 27.68 ret 27.69 -xmm_fail: 27.70 + 27.71 +@@jmp_esbx: 27.72 + push es ; \ 27.73 + push bx ; > jmp far es:bx 27.74 + retf ; / 27.75 + 27.76 +@@xmm_fail: 27.77 xor ax,ax 27.78 cwd 27.79 retf
28.1 --- a/linld/stuff/src/_BEG.ASM Wed Dec 16 17:23:49 2020 +0000 28.2 +++ b/linld/stuff/src/_BEG.ASM Fri Jan 08 20:15:35 2021 +0000 28.3 @@ -15,7 +15,7 @@ 28.4 ends _TEXT 28.5 28.6 segment _DATA byte public use16 'DATA' 28.7 - global _data_start:byte 28.8 + ;global _data_start:byte 28.9 label _data_start byte 28.10 ifndef NO386 28.11 msg_badcpu db "I need 386+ CPU in real mode w/o paging" 28.12 @@ -24,18 +24,18 @@ 28.13 global _vcpi:byte 28.14 _vcpi db 0 28.15 endif 28.16 - ifdef EXTRA 28.17 -tazboot_cmd db "tazboot.cmd",0 28.18 - endif 28.19 28.20 ends _DATA 28.21 28.22 segment _BSS byte public use16 'BSS' 28.23 28.24 - global _bss_start:byte 28.25 + ifdef BIG_CMDLINE 28.26 + extrn _big_cmdline:byte 28.27 + db 254 dup(?) 28.28 + endif 28.29 + ;global _bss_start:byte 28.30 label _bss_start byte 28.31 global stktop:byte 28.32 - ifndef ISOHOOK 28.33 ifdef NO386 28.34 global _cpu386:byte 28.35 _cpu386 db ? 28.36 @@ -43,7 +43,6 @@ 28.37 endif 28.38 global _cpu_features:dword 28.39 _cpu_features dd ? 28.40 - endif 28.41 ends _BSS 28.42 28.43 segment _TEXT byte public use16 'CODE' 28.44 @@ -53,21 +52,23 @@ 28.45 endm 28.46 28.47 org 100h 28.48 - global _text_start:byte 28.49 + ;global _text_start:byte 28.50 label _text_start byte 28.51 28.52 ;*************************************************************** 28.53 ; clear bss 28.54 ;*************************************************************** 28.55 mov sp,offset stktop 28.56 + mov bx, 0F000h ; cld ; cli & empty string 28.57 + org $-4-2 28.58 + global _himem_buf:dword 28.59 +_himem_buf dd ? 28.60 + global _buf_cmdline:word 28.61 +_buf_cmdline dw ? ; 128 bytes, must start with 00 28.62 mov si,offset _bss_start 28.63 - mov bx, 0F000h ; cld ; cli & empty string 28.64 clearbss: 28.65 mov [si],bl ; clear bss + heap 28.66 inc si 28.67 - ifdef ISOHOOK 28.68 - cmp si,bx 28.69 - endif 28.70 jne clearbss 28.71 28.72 ;*************************************************************** 28.73 @@ -87,6 +88,10 @@ 28.74 js endcpu86 ;it is not a 386+, try ELKS & co 28.75 endif 28.76 p386 28.77 + mov edx,cs 28.78 + shl edx,4 ; edx for prepare_vcpi 28.79 + extrn gdt_base_memcpy:word ; gdt_base for memcpy32 28.80 + add [dword gdt_base_memcpy],edx 28.81 ; Check for vm 28.82 smsw ax ;SMSW cannot be trapped! :-) 28.83 and al,1 ;MSW_PE 28.84 @@ -102,32 +107,11 @@ 28.85 p8086 28.86 extrn die:near 28.87 godie: 28.88 -no_vcpi: 28.89 call near die 28.90 else 28.91 jmp endcpu86 28.92 endif 28.93 28.94 - ifdef ISOHOOK 28.95 - global iso_close_hack 28.96 -iso_close_hack dw dosbx 28.97 - global iso_open_hack 28.98 - extrn __open:near 28.99 -iso_open_hack dw __open 28.100 - global iso_read_hack 28.101 - extrn dos:near 28.102 -iso_read_hack dw dos 28.103 - global iso_lseek_hack 28.104 - extrn dosbx:near 28.105 -iso_lseek_hack dw dosbx 28.106 - global _cpu_features:dword 28.107 -_cpu_features dd ? ; default _cpu_features+3=1Fh/8Eh (bit5=0, not 64bits) 28.108 - org $-4 28.109 - ifdef NO386 28.110 - global _cpu386:byte 28.111 -_cpu386 db 0 28.112 - endif 28.113 - endif 28.114 28.115 ;*************************************************************** 28.116 ; checks for vcpi 28.117 @@ -138,38 +122,13 @@ 28.118 ; Check whether it is safe to call 67h (we trust only known EMM managers) 28.119 push si 28.120 pop ds 28.121 - mov ds,[word 67h*4+2] 28.122 - cmp [dword si+10+4],'0XXX' 28.123 - jne skip 28.124 - ;mov eax,'XMME' 28.125 - ;xor eax,[dword si+10] 28.126 - ; QMME also works (as told by <J.S.Peatfield@damtp.cambridge.ac.uk>) 28.127 - ;shl eax,8 28.128 - mov ax,'ME' 28.129 - xor ax,[word si+10] 28.130 -skip: 28.131 + mov ax,[word 67h*4] 28.132 + or ax,[word 67h*4+2] 28.133 pop ds 28.134 - jne no_vcpi 28.135 - 28.136 -; Check emm manager status and version 28.137 - ;mov ah,40h ; get status 28.138 - ;int 67h 28.139 - ;inc ax 28.140 - ;js no_vcpi 28.141 - mov ah,46h ; get version 28.142 - int 67h 28.143 - cmp ax,40h ; version must be >= 4.0 28.144 - jl no_vcpi ; btw check ax.15 28.145 -; Check vcpi manager status 28.146 - ;;mov ax,5A01h ; ALLOCATE RAW PAGES 28.147 - ;;mov bx,4 28.148 - ;;int 67h 28.149 - ;;inc ax 28.150 - ;;js no_vcpi 28.151 - ;;push dx ;$ save handle 28.152 + je no_vcpi 28.153 mov ax,0DE00h ; check for vcpi present 28.154 int 67h 28.155 - test ah,ah 28.156 + or ah,ah 28.157 jnz no_vcpi 28.158 is386vcpi: 28.159 extrn prepare_vcpi:near 28.160 @@ -186,13 +145,14 @@ 28.161 extrn _vcpi:byte 28.162 dec [byte _vcpi] 28.163 endif 28.164 +no_vcpi: 28.165 endcpu386: 28.166 pushfd 28.167 pop dx 28.168 pop ax 28.169 mov bl,al 28.170 - xor al,20h ; toggle CPUID feature bit 21 28.171 - push ax 28.172 + xor al,20h ; toggle CPUID feature bit 21 (=> pentium+) 28.173 + push ax ; (toggle AC: bit 18 => 486+) 28.174 push dx 28.175 popfd 28.176 pushfd 28.177 @@ -202,12 +162,11 @@ 28.178 je @@no_cpuid ; CPUID feature bit changed ? 28.179 mov eax,80000001h ; Extended Processor Info and Feature Bits 28.180 cpuid 28.181 + mov dl,-1 ; set 386 flag (assume cpuid => fpu:bit0=1 ?) 28.182 ifdef NO386 28.183 - mov dl,-1 ; set 386 flag 28.184 db 66h ; mov [_cpu_features],edx 28.185 @@no_cpuid: 28.186 mov [word _cpu_features],dx ; dl != 0 28.187 -no_vcpi: 28.188 else 28.189 mov [_cpu_features],edx 28.190 @@no_cpuid: 28.191 @@ -223,27 +182,30 @@ 28.192 global _heap_top 28.193 org $-2 28.194 _heap_top dw ? 28.195 - ;xor ax,ax 28.196 - ;push ax ; envp (already cleared) 28.197 - ;mov [word di],ax ; argv[0] = 0 (idem) 28.198 mov si,80h 28.199 - lodsb 28.200 - cmp al,7Eh 28.201 - jbe alok 28.202 - mov al,7Eh 28.203 -alok: 28.204 + ifdef BIG_CMDLINE 28.205 + mov bx,offset _big_cmdline 28.206 + cmp [byte si],2 28.207 + jnb @@user_args 28.208 + call @set_cmdline$qpxzc 28.209 +@@user_args: 28.210 + endif 28.211 + lodsb ; size 0..127 28.212 cbw 28.213 + ifdef BIG_CMDLINE 28.214 + inc ax 28.215 + jnz short_cmdline 28.216 + mov si,bx 28.217 + lodsb ; size 0..254 28.218 +short_cmdline: 28.219 + dec ax 28.220 + endif 28.221 xchg ax,bx 28.222 mov [bx+si],bh ; set eos 28.223 + ;xor dx,dx 28.224 + ;push dx ; envp (already cleared) 28.225 + ;mov [word di],dx ; argv[0] = 0 (idem) 28.226 argbuild: 28.227 - ifdef DEBUG 28.228 - p386 28.229 - pusha 28.230 - mov bx,si 28.231 - extrn puts:near 28.232 - call puts 28.233 - popa 28.234 - endif 28.235 mov bx,2 ; argc * 2 28.236 argeos: 28.237 mov cx,1 ; look for a start of string 28.238 @@ -290,15 +252,15 @@ 28.239 read_cmdline: 28.240 mov dx,di 28.241 push dx 28.242 - push ax 28.243 xchg ax,bx 28.244 extrn @read$cxdxbx:near ; read(fd=bx,buffer=dx,size=cx) 28.245 call near @read$cxdxbx 28.246 - pop bx ; fd for close 28.247 pop si ; si=buffer=argv 28.248 add di,ax 28.249 + ifndef NO_CLOSE 28.250 extrn close:near 28.251 call near close 28.252 + endif 28.253 jmp argbuild 28.254 argend: 28.255 endif 28.256 @@ -311,7 +273,6 @@ 28.257 ;*************************************************************** 28.258 28.259 28.260 - extrn _head_top:word 28.261 ifdef USE_ARGSTR 28.262 ;*************************************************************** 28.263 ;_fastcall void set_cmdline(bx:const char *filename); 28.264 @@ -328,25 +289,6 @@ 28.265 endp @set_cmdline$qpxzc 28.266 endif 28.267 28.268 -;*************************************************************** 28.269 -;void try_default_args(); 28.270 -;*************************************************************** 28.271 - 28.272 - ifdef EXTRA 28.273 - global _try_default_args:near 28.274 - proc _try_default_args near 28.275 - 28.276 - mov bx,offset tazboot_cmd 28.277 - extrn @open$qpxzc:near 28.278 - call @open$qpxzc 28.279 - jc @ret 28.280 - mov ch,15 ; cx<4096 28.281 - mov di,[_heap_top] 28.282 - jmp read_cmdline ; read_cmdline(ax,di,cx) 28.283 - 28.284 - endp _try_default_args 28.285 - endif 28.286 - 28.287 ifdef NO386 28.288 ;*************************************************************** 28.289 ;u16 topseg();
29.1 --- a/linld/stuff/src/_END.ASM Wed Dec 16 17:23:49 2020 +0000 29.2 +++ b/linld/stuff/src/_END.ASM Fri Jan 08 20:15:35 2021 +0000 29.3 @@ -1,35 +1,35 @@ 29.4 -;*************************************************************** 29.5 -;****** This file is distributed under GPL 29.6 -;*************************************************************** 29.7 - ideal 29.8 - %crefref 29.9 - %noincl 29.10 - %nomacs 29.11 - p386 29.12 - 29.13 - segment _TEXT byte public use16 'CODE' 29.14 - global _text_end:byte 29.15 - label _text_end byte 29.16 - ends _TEXT 29.17 - 29.18 - segment _DATA byte public use16 'DATA' 29.19 - global _data_end:byte 29.20 - label _data_end byte 29.21 - ends _DATA 29.22 - 29.23 - segment _BSS word public use16 'BSS' 29.24 - ifdef EXTRA 29.25 - global _version_string:byte 29.26 - label _version_string byte 29.27 - endif 29.28 -STACK_SIZE = 1024 29.29 - db STACK_SIZE dup(?) 29.30 - global stktop:byte 29.31 - label stktop byte 29.32 - global _bss_end:byte 29.33 - label _bss_end byte 29.34 - ends _BSS 29.35 - 29.36 - end 29.37 - 29.38 -;###### END OF FILE ############################################ 29.39 +;*************************************************************** 29.40 +;****** This file is distributed under GPL 29.41 +;*************************************************************** 29.42 + ideal 29.43 + %crefref 29.44 + %noincl 29.45 + %nomacs 29.46 + p386 29.47 + 29.48 + segment _TEXT byte public use16 'CODE' 29.49 + ;global _text_end:byte 29.50 + label _text_end byte 29.51 + ends _TEXT 29.52 + 29.53 + segment _DATA byte public use16 'DATA' 29.54 + ;global _data_end:byte 29.55 + label _data_end byte 29.56 + ifdef BIG_CMDLINE 29.57 + global _big_cmdline:byte 29.58 +_big_cmdline db 0 29.59 + endif 29.60 + ends _DATA 29.61 + 29.62 + segment _BSS word public use16 'BSS' 29.63 +STACK_SIZE = 256 29.64 + db STACK_SIZE dup(?) 29.65 + global stktop:byte 29.66 + label stktop byte 29.67 + global _bss_end:byte 29.68 + label _bss_end byte 29.69 + ends _BSS 29.70 + 29.71 + end 29.72 + 29.73 +;###### END OF FILE ############################################
30.1 --- a/linld/stuff/src/_ISOBEG.ASM Wed Dec 16 17:23:49 2020 +0000 30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 30.3 @@ -1,41 +0,0 @@ 30.4 -;*************************************************************** 30.5 -;****** This file is distributed under GPL 30.6 -;*************************************************************** 30.7 - ideal 30.8 - %PAGESIZE 1000 30.9 - %crefref 30.10 - %noincl 30.11 - %nomacs 30.12 - p8086 30.13 - 30.14 - group DGROUP _TEXT,_DATA,_BSS 30.15 - assume cs:DGROUP,ds:DGROUP 30.16 - 30.17 - segment _TEXT byte public use16 'CODE' 30.18 - ends _TEXT 30.19 - 30.20 - segment _DATA byte public use16 'DATA' 30.21 - global _data_start:byte 30.22 - label _data_start byte 30.23 - ends _DATA 30.24 - 30.25 - segment _BSS byte public use16 'BSS' 30.26 - global _bss_start:byte 30.27 - label _bss_start byte 30.28 - ends _BSS 30.29 - 30.30 - segment _TEXT byte public use16 'CODE' 30.31 - 30.32 - org 100h 30.33 - global _text_start:byte 30.34 - label _text_start byte 30.35 - 30.36 - extrn _isostate 30.37 - dw _isostate 30.38 - 30.39 - ends _TEXT 30.40 - 30.41 - 30.42 - end _text_start 30.43 - 30.44 -;###### END OF FILE ############################################
31.1 --- a/linld/stuff/src/pipehole.awk Wed Dec 16 17:23:49 2020 +0000 31.2 +++ b/linld/stuff/src/pipehole.awk Fri Jan 08 20:15:35 2021 +0000 31.3 @@ -8,16 +8,6 @@ 31.4 if (/^ \.386p$/) is386=1 31.5 if (file == "" && /debug S/) { file=$3; gsub(/\"/,"",file) } 31.6 if (/debug S/) print " %PAGESIZE 1000" 31.7 - if (file == "tazboot.cpp") { 31.8 - if (/add si,2/) $0=" lodsw ; " $0 31.9 - if (/add si,4/) { print " lodsw"; $0=" lodsw ; " $0 } 31.10 - if (/add di,2/) $0=" scasw ; " $0 31.11 - if (/int argc/) istazboot=1 31.12 - if (istazboot == 1) { 31.13 - if (/push.*i$/) $0="; " $0 31.14 - if (/word ptr/) { istazboot=0; $0="; " $0 } 31.15 - } 31.16 - } # file == "tazboot.cpp" 31.17 if (file == "linld.cpp") { 31.18 if (/add si,2/) $0=" lodsw ; " $0 31.19 if (/add di,2/) $0=" scasw ; " $0 31.20 @@ -53,14 +43,19 @@ 31.21 } 31.22 if (/buf_cmdline\+1/) { 31.23 islinld=5 31.24 - print " mov bx,offset DGROUP:buf_cmdline+1" 31.25 - sub(/offset DGROUP:buf_cmdline\+1/,"bx") 31.26 + print " mov bx,offset DGROUP:_buf_cmdline+1" 31.27 + sub(/offset DGROUP:_buf_cmdline\+1/,"bx") 31.28 } 31.29 if (islinld==5) { 31.30 - if (/bx,offset DGROUP:buf_cmdline/) $0=" dec bx" 31.31 + if (/bx,offset DGROUP:_buf_cmdline/) $0=" dec bx" 31.32 if (/ax,word ptr/) next 31.33 if (/call/) islinld=0 31.34 } 31.35 + if (/bx,word ptr DGROUP:_cmdstr\+6/) next 31.36 + if (/_cmdstr\+6,0/) { 31.37 + print " mov bx,word ptr [di+6]" 31.38 + $0=" or bx,bx" 31.39 + } 31.40 } # file == "linld.cpp" 31.41 if (file == "himem.cpp") { 31.42 if (/sp,bp/ || /pop bp/) next 31.43 @@ -68,20 +63,17 @@ 31.44 if (ishimem == 1 && is386 == 0) { 31.45 if (/si\+8\]$/ || /si\+4\]$/ || /si\+16\]$/) next 31.46 if (/si\+6\]$/ || /si\+2\]$/ || /si\+14\]$/) sub(/mov dx,/,"les dx,d") 31.47 - if (/si\+12\],ax/ || /si\+16\],ax/ || /DGROUP:buf\+2,ax/) sub(/,ax/,",es") 31.48 - if (/dx,dword ptr \[si\+14\]/ || /DGROUP:buf,dx/) sub(/dx/,"ax") 31.49 + if (/si\+12\],ax/ || /si\+16\],ax/ || /DGROUP:_himem_buf\+2,ax/) sub(/,ax/,",es") 31.50 + if (/dx,dword ptr \[si\+14\]/ || /DGROUP:_himem_buf,dx/) sub(/dx/,"ax") 31.51 } 31.52 if (ishimem == 1) { 31.53 if (/do \{/) ishimem=2 31.54 if (/bx,si/ || /push bp/ || /bp,sp/ || /push di/ || /push si/) next 31.55 - if (/sp,2/) next 31.56 - if (/bp\+4/) { 31.57 - $0=" xchg ax,si" 31.58 - } 31.59 + if (/sp,2/ || /bp\+4/) next 31.60 } 31.61 if (ishimem == 2) { 31.62 if (/movzx/) print " cwde" 31.63 - if (/bp-2/ || /di,ax/ || /bx,di/) next 31.64 + if (/bp-2/ || /di,ax/ || /bx,di/ || /bx,si/) next 31.65 if (/storepage.bufv/) { 31.66 print " inc ax" 31.67 print " push ax" 31.68 @@ -89,6 +81,14 @@ 31.69 if (/buf \+= size;/) { 31.70 print " pop ax" 31.71 } 31.72 + if (/i\+12/) ishimem=20 31.73 + } 31.74 + if (ishimem == 20) { 31.75 + if (/stc/ || /loadfail/) next 31.76 + if (/je/) { 31.77 + print " extrn jmploadfailure" 31.78 + $0=" jne short jmploadfailure" 31.79 + } 31.80 if (/endp/) ishimem=0 31.81 } 31.82 if (/@memcpy_image\$qp11image_himem/) next 31.83 @@ -99,25 +99,33 @@ 31.84 cpy_initrd=0 31.85 } 31.86 if (ishimem == 3) { 31.87 - if (/bx,di/ || /di,ax/ || /bx,32/) next 31.88 + sub(/DGROUP:_imgs\+4,/,"[si+4],") 31.89 + if (/bx,di/ || /di,ax/ || /bx,30/) next 31.90 if (/mov bx,si/) { 31.91 if (cpy_initrd==0) sub(/mov bx,si/, "call memcpy_image_kernel") 31.92 else sub(/mov bx,si/, "call memcpy_image_initrd") 31.93 cpy_initrd=1-cpy_initrd 31.94 } 31.95 - sub(/lea bx,\[si\+32\]/, "call memcpy_image_initrd") 31.96 + sub(/lea bx,\[si\+30\]/, "call memcpy_image_initrd") 31.97 } 31.98 if (/m = pm2initrd/) ishimem=4 31.99 if (ishimem == 4) { 31.100 - if (/si,32/ || /bx,di/ || /di,ax/) next 31.101 - sub(/\[si/,"[si+32") 31.102 + if (/si,30/ || /bx,di/ || /di,ax/) next 31.103 + sub(/\[si/,"[si+30") 31.104 sub(/mov bx,si/, "call memcpy_image_initrd") 31.105 } 31.106 } # file == "himem.cpp" 31.107 if (file == "load.cpp") { 31.108 + if (isload != 3 && isload != 6) { # LOAD.LST 31.109 + if (/,si/ || /si,/ || /\[si/) sub(/si/,"di") 31.110 + else if (/,di/ || /di,/ || /\[di/) sub(/di/,"si") 31.111 + } 31.112 + if (/moverm\(/) isload=16 31.113 + if (isload != 16 && /bx,si/) next 31.114 + if (/@moverm/) isload=0 31.115 if (/readrm\(m, 0x200/) isload=15 31.116 if (isload == 15) { # LOAD.LST 31.117 - if (/bx,di/) next 31.118 + if (/bx,si/) next 31.119 if (/call/) isload=0 31.120 } 31.121 if (/load_image\(/) { 31.122 @@ -125,10 +133,7 @@ 31.123 else isload=14 31.124 } 31.125 if (isload == 14) { # LOAD.LST 31.126 - if (/call/) { 31.127 - print " xchg ax,di" 31.128 - $0=" jmp short load_imagez" 31.129 - } 31.130 + if (/call/) $0=" jmp short load_imagez" 31.131 if (/ret/) isload=0 31.132 if (/pop/ || /ret/ || /push/) next 31.133 } 31.134 @@ -152,24 +157,11 @@ 31.135 sub(/jb/,"ja") 31.136 } 31.137 sub(/_imgs\+65534/,"_imgs-2") 31.138 - if (/m, _rm_size/) isload=10 31.139 - if (isload == 10) { # LOAD.LST 31.140 - if (/^ je / || /bx,di/) next 31.141 - if (/ptr @die\$qpxzc/) { 31.142 - $0=" jne @die@" 31.143 - isload=0 31.144 - } 31.145 - } 31.146 if (/setup_sects == 0/) isload=9 31.147 if (isload == 9) { # LOAD.LST 31.148 sub(/,0/,",al") 31.149 if (/jne/) isload=0 31.150 } 31.151 - if (/fallback\)\[1\] == 0/) isload=8 31.152 - if (isload == 8) { # LOAD.LST 31.153 - if (/load_image/) isload=0 31.154 - else next 31.155 - } 31.156 if (/cmd_line_ptr =/ && is386 == 0) isload=7 31.157 if (isload == 7) { # LOAD.LST 31.158 if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/ || /,ax/) next 31.159 @@ -187,8 +179,8 @@ 31.160 } 31.161 } 31.162 if (/pm_low == 0/) { 31.163 - print " mov ax,si" 31.164 print " push di" 31.165 + print " push si" 31.166 isload=6 31.167 } 31.168 if (isload == 6) { # LOAD.LST 31.169 @@ -203,21 +195,22 @@ 31.170 print " movsw" 31.171 print " movsw" 31.172 print " movsw" 31.173 + print " pop si" 31.174 print "load_imagez:" 31.175 next 31.176 } 31.177 } 31.178 if (isload == 5) { # LOAD.LST 31.179 sub(/ax,/,"bx,") 31.180 - if (/strcatb/) isload=0 31.181 + if (/@puts\$qpxzc/) isload=0 31.182 if (/mov bx,ax/) next 31.183 - sub(/,word ptr \[si\+29\]/,",cx") 31.184 + sub(/,word ptr \[di\+29\]/,",cx") 31.185 } 31.186 - if (/_base_himem\+2/ && is386 == 0) isload=4 31.187 + if (/_cmdnum\+14/ && is386 == 0) isload=4 31.188 if (isload == 4) { # LOAD.LST 31.189 - if (/_base_himem\+2/) next 31.190 - if (/_base_himem$/) { 31.191 - sub(/mov dx,/,"les dx,d") 31.192 + if (/_cmdnum\+14/) next 31.193 + if (/_cmdnum\+12$/) { 31.194 + $0=" les dx,dword ptr [bx+12]" 31.195 } 31.196 sub(/,ax/,",es") 31.197 if (/add ax,word ptr/) $0=" add ax,cx" 31.198 @@ -226,10 +219,17 @@ 31.199 sub(/cmp /,"mov cx,") 31.200 } 31.201 sub(/je/,"jcxz") 31.202 + if (/@strcpy/) isload=0 31.203 if (/\+0x200/) isload=5 31.204 } 31.205 - if (/void load_initrd\(\)/) isload=3 31.206 + if (/void load_initrd\(\)/) { isload=3; isload2=0 } 31.207 if (isload == 3) { # LOAD.LST 31.208 + if (/cmdstr\+4,0/) { 31.209 + isload2++ 31.210 + print " mov ax,word ptr DGROUP:_cmdstr+4" 31.211 + $0=" or ax,ax" 31.212 + } 31.213 + if (isload2 && /DGROUP:_cmdstr\+4/) $0=";" $0 31.214 if (/je short @2@.*/) sub(/@2@.*/,"load_initrd_ret") 31.215 if (/mov ax,word ptr \[si\]/) $0=" lodsw" 31.216 if( /jmp/) { 31.217 @@ -238,18 +238,23 @@ 31.218 print " ret" 31.219 next 31.220 } 31.221 + if (/@loadfailure/) { 31.222 + print " global jmploadfailure:near" 31.223 + print "jmploadfailure:" 31.224 + } 31.225 sub(/\[di/,"[bx") 31.226 sub(/di,/,"bx,") 31.227 } 31.228 - if (/vid_mode = vid_mode/) isload=2 31.229 + if (/mode = vid_mode/) { isload=2; print " mov bx,offset _cmdnum" } 31.230 if (isload == 2) { # LOAD.LST 31.231 + if (/DGROUP:_cmdnum/) { sub(/DGROUP:_cmdnum/,"[bx"); $0=$0 "]"} 31.232 sub(/,0/,""); sub(/cmp /,"mov cx,") 31.233 sub(/je/,"jcxz") 31.234 if (/ax,word/) next 31.235 sub(/,ax/,",cx") 31.236 if (/starting linux 1\.3\.73/) isload=0 31.237 } 31.238 - if (/die\(not_kernel/ || /_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1 31.239 + if (/_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1 31.240 if (isload == 1) { # LOAD.LST 31.241 if (/ptr .die\$qpxzc/) $0="@die@:\n" $0 31.242 if (/mov al,byte ptr/ && is386) { 31.243 @@ -264,38 +269,101 @@ 31.244 } 31.245 } # file == "load.cpp" 31.246 if (file == "iso9660.cpp") { 31.247 - if (/x->curpos \+= x->entrysize/) isiso=14 31.248 + if (/ptr \[si\+10\],dx/) next 31.249 + if (/ptr \[si\+8\],ax/) next 31.250 + if (/si\+32/) next 31.251 + if (/add word ptr \[si\],ax/) $0=" add word ptr [si],cx" 31.252 + if (/ax,word ptr \[si\+24\]/) sub(/mov ax,/,"les ax,d") 31.253 + if (/ax,word ptr \[si\+26\]/) next 31.254 + if (/word ptr \[si\+29\],ax/) sub(/ax/,"es") 31.255 + if (/\[si\],-1/) $0=" not word ptr [si]" 31.256 + sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]") 31.257 + if (isiso == 19) { # ISO9660.LST 31.258 + if (/short @2@282/) $0=" jc restoreC" 31.259 + if (/bp-2/ || /si\+34/ || /ax,dx/ || /cmp ax,-1/) next 31.260 + sub(/dx,/,"bx,") 31.261 + if (/short @2@282/) sub(/je/,"jnc") 31.262 + if (/\[si\+37\],0/) sub(/,0/,",ch") 31.263 + if (/@strcmp\$qpxzct1/) { 31.264 + print 31.265 + print "restoreC:" 31.266 + $0=" mov byte ptr [di],cl ; c" 31.267 + isiso=1 31.268 + } 31.269 + } 31.270 + if (/ax,-8/) { isiso=18; next } 31.271 + if (isiso == 18) { # ISO9660.LST 31.272 + if (/ax,ax/) { isiso=0;next } 31.273 + sub(/mov/,"sub") 31.274 + sub(/,ax/,",8") 31.275 + } 31.276 + if (isiso == 17) { # ISO9660.LST 31.277 + if (/inc di/) $0="; " $0 31.278 + if (/_isostate\+205/) { 31.279 + print 31.280 + $0=" jmp setdirofsnsz" 31.281 + } 31.282 + else sub(/ax/,"bx") 31.283 + if (/si\+24/) isiso=0 31.284 + if (/,bx/) next 31.285 + if (/isoreadrootsector/) { 31.286 + print 31.287 + print " cmp word ptr [si+39],17475" 31.288 + print " stc" 31.289 + $0=" jne returnC" 31.290 + } 31.291 + } 31.292 + if (/cpytodirpage.x->dirpage/) isiso=16 31.293 + if (isiso == 16) { # ISO9660.LST 31.294 + if (/filesize2dirsize/) { 31.295 + print " mov bx,word ptr [si+9]" 31.296 + print " mov ax,word ptr [si+13]" 31.297 + print "setdirofsnsz:" 31.298 + print " mov word ptr [si+26],bx" 31.299 + } 31.300 + if (/ax,/ || /si\+13/ || /si\+26/) next 31.301 + if (/si\+24/) isiso=1 31.302 + } 31.303 + if (/found:/) isiso=15 31.304 + if (/short @1@394/) sub(/@1@394/,"@1@422") 31.305 + if (isiso != 15 && /si,offset DGROUP:_isostate/) $0=";" $0 31.306 + if (isiso == 15) { # ISO9660.LST 31.307 + if (/xor/) { 31.308 + print "returnNotC:" 31.309 + print " cmc" 31.310 + print "returnC:" 31.311 + print "@1@422:" 31.312 + print " sbb ax,ax" 31.313 + print "return:" 31.314 + next 31.315 + } 31.316 + if (/@1@422:/ || /bp$/ || /bp,sp/ || /sp,2/) next 31.317 + if (/\[di\],47/) isiso=17 31.318 + } 31.319 + if (/short @1@142/) { isiso=14; next } 31.320 if (isiso == 14) { # ISO9660.LST 31.321 - if (/ax,ax/) { 31.322 - print "return0:" 31.323 - isiso=0 31.324 - } 31.325 + if (/ax,-1/) next 31.326 + if (/jmp @1@422/) sub(/jmp/,"jb") 31.327 } 31.328 if (/p = x->buffer \+ 34/) isiso=13 31.329 if (isiso == 13) { # ISO9660.LST 31.330 if (/di,si/) $0=" xchg ax,bx" 31.331 - if (/di,ax/) $0=" lea di,[si+bx+70]" 31.332 - if (/di,70/) { 31.333 + if (/di,ax/) $0=" lea di,[si+bx+72]" 31.334 + if (/di,72/) { 31.335 isiso=0 31.336 next 31.337 } 31.338 } 31.339 if (/register len/) isiso=12 31.340 if (isiso == 12) { # ISO9660.LST 31.341 - sub(/mov dx,ax/,"xchg ax,bx") 31.342 + if (/di\+2/) sub(/al/,"bl") 31.343 + if (/cbw/) next 31.344 + sub(/dx,ax/,"bh,0") 31.345 if (/bx,dx/) next 31.346 sub(/i,dx/,"i,bx") 31.347 + sub(/bx\+di\],0/,"bx+di],bh") 31.348 if (/while/) isiso=0 31.349 } 31.350 - if (/while \(\*\+\+s/) isiso=11 31.351 - if (isiso == 11) { # ISO9660.LST 31.352 - if (/cmp/ || /filename2open/) isiso=0 31.353 - if (/cmp/) next 31.354 - if (/mov/) { 31.355 - sub(/mov bx,/,"cmp byte ptr [") 31.356 - sub(/i$/,"i],0") 31.357 - } 31.358 - } 31.359 if (/curpos >= SECT/) isiso=10 31.360 if (isiso == 10) { # ISO9660.LST 31.361 if (/cmp/) { 31.362 @@ -311,7 +379,7 @@ 31.363 } 31.364 if (/<< SECTORBITS/) isiso=9 31.365 if (isiso == 9) { # ISO9660.LST 31.366 - if (/dx,/) next 31.367 + if (/dx,/) next 31.368 sub(/mov ax,/,"les ax,d") 31.369 if (/^ call/) { 31.370 print " extrn N_LXLSH@ES:near" 31.371 @@ -326,277 +394,50 @@ 31.372 sub(/,ax/,",es") 31.373 if (/filemod/) isiso=0 31.374 } 31.375 - if (/CD001/) isiso=7 31.376 - if (isiso == 7) { # ISO9660.LST 31.377 - sub(/mov ax,-1/,"dec ax") 31.378 - if (/jmp/) isiso=0 31.379 - } 31.380 - if (/int len =/) isiso=6 31.381 - if (isiso == 6) { # ISO9660.LST 31.382 - if (/dx,ax/) next 31.383 - sub(/ax/,"dx") 31.384 - sub(/cx,di/,"bx,di") 31.385 - sub(/cx,dx/,"bx,ax") 31.386 - sub(/di,dx/,"di,ax") 31.387 - if (/while/) isiso=2 31.388 - } 31.389 if (/entrysize =/) isiso=5 31.390 if (isiso == 5) { # ISO9660.LST 31.391 if (/ax,ax/) next 31.392 sub(/ax/,"cx") 31.393 sub(/je/,"jcxz") 31.394 + if (/jcxz/) { 31.395 + hold=0 31.396 + print s 31.397 + sub(/@1@114/,"@1@394") 31.398 + print 31.399 + print " mov word ptr [si+10],dx" 31.400 + $0=" mov word ptr [si+8],ax" 31.401 + } 31.402 if (/return/) isiso=0 31.403 } 31.404 - if (/x->curdirsize == 0xFFFF/) isiso=4 31.405 - if (isiso == 4) { # ISO9660.LST 31.406 - sub(/DGROUP:_isostate\+18/,"[si+18]") 31.407 - sub(/DGROUP:_isostate\+20/,"[si+20]") 31.408 - if (/goto restarted/) isiso=0 31.409 - } 31.410 - } # file == "iso9660.cpp" 31.411 - if (file == "iso9660.cpp" || file == "tazboot.cpp") { 31.412 if (/do s\+\+; while/) isiso=3 31.413 - if (/for \(p = s; \*s && \*s \!=/) isiso=3 # tazboot/main 31.414 - if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST 31.415 + if (isiso == 3) { # ISO9660.LST 31.416 sub(/cmp byte ptr \[.i\]/,"sub al") 31.417 - if (/mov byte ptr \[bp-5\],al/) $0=" push ax" 31.418 - if (/mov al,byte ptr \[bp-5\]/) $0=" pop ax" 31.419 if (/inc /) { r=$2; print; next } 31.420 if (/al,0/) print " mov al,[" r "]" 31.421 - if (/al,byte ptr/) sub(/mov/,"xchg") 31.422 + if (/al,byte ptr/) next 31.423 if (/byte ptr \[.*\],0/) next 31.424 - if (/jmp/) { 31.425 - print " mov bx,si" 31.426 - $0=" db 0A8h ; test al,xx instead of " $0 31.427 + } 31.428 + if (/ptr .isoreaddir/) isiso=1 31.429 + if (isiso == 1) { # ISO9660.LST 31.430 + if (/n = name;/) { 31.431 + isiso=19 31.432 + print " xchg ax,cx" 31.433 + print " xchg cl,byte ptr [di] ; c" 31.434 } 31.435 - if (/word ptr \[bp-4\]/) next 31.436 - if (/\) s\+\+;/ || /\],-1/) isiso=0 31.437 + if (/short @2@366/) sub(/jne/,"jnc") 31.438 + if (/short @2@282/) sub(/je/,"jc") 31.439 + if (/short @2@562/) sub(/@2@562/,"returnNotC") 31.440 + if (/short @2@534/) { print; $0=" inc cx" } 31.441 + if (/ax,word ptr \[si\+4\]/) $0=" xchg ax,bx ; " $0 31.442 + if (/\[di\],al/) next 31.443 + if (/@2@310/) next 31.444 + if (/ax,-1/) next 31.445 + if (/inc di/ || /@@0/) next 31.446 + if (/@2@142$/) { print " inc di"; sub(/jmp/,"loop") } 31.447 } 31.448 - } # file == "iso9660.cpp" || file == "tazboot.cpp" 31.449 - if (file == "iso9660.cpp") { 31.450 - if (/endname = NULL/) isiso=2 31.451 - if (isiso == 2) { # ISO9660.LST 31.452 - if (/mov bx,cx/) next 31.453 - gsub(/cx/,"bx") 31.454 - sub(/DGROUP:_isostate\+35/,"[si+35]") 31.455 - } 31.456 - if (/const char \*n = name/) isiso=1 31.457 - if (isiso == 1) { # ISO9660.LST 31.458 - if ((/mov word ptr \[si\+32\],ax/ ) || 31.459 - (/mov ax,word ptr \[si\+2\]/) || 31.460 - (/bx,word ptr \[si\+32\]/) || (/ax,dx/)) next 31.461 - if (/dx,/) sub(/dx/,"ax") 31.462 - if ((/sub ax,word ptr \[si\+2\]/) || 31.463 - (/\[si\+16\]/) || (/ax,di/)) sub(/ax/,"bx") 31.464 - if (/add word ptr \[si\+32\],ax/) $0=" add bx,word ptr [si+16]" 31.465 - if (/al,/ || /,al/) sub(/al/,"cl") 31.466 - if (/cmp byte ptr \[si\+34\],0/) $0=" or cl,cl" 31.467 - if (/ax,ax/) next 31.468 - if (/short @.@506/) $0=" jmp return0" 31.469 - if (/jne @@0$/) next 31.470 - if (/jmp @.@58$/) sub(/jmp/,"je") 31.471 - sub(/mov ax,-1/,"dec ax") 31.472 - } 31.473 + if (/i\+36\]/) next 31.474 + sub(/DGROUP:_isostate\[bx/,"[bx+si") 31.475 } # file == "iso9660.cpp" 31.476 - if (/endp/) { xlabel = ""; goto2=0 } 31.477 - if (/isoopen\(s\+7\)/ && xlabel == "") goto2=1 # tazboot/bootiso 31.478 - if (/_vid_mode,ax/ && xlabel == "") goto2=1 # tazboot/main 31.479 - if (/_initrd_name,si/ && xlabel == "") goto2=1 # tazboot/main 31.480 - if (/_base_himem\+2,/ && xlabel == "@") goto2=1 # tazboot/bootiso tazboot/main 31.481 - if (/DGROUP:_skip_alloc/ && xlabel == "@") goto2=1 # tazboot/bootiso tazboot/main 31.482 - if (/puts\(cmdline\)/ && xlabel == "@@") goto2=1 31.483 - if (goto2 == 1 && /jmp/) { # TAZBOOT.LST && LINLD.LST 31.484 - print $NF xlabel "@:" 31.485 - label=$NF 31.486 - } 31.487 - if (goto2 > 0 && label == $NF) { 31.488 - $0=$0 xlabel 31.489 - if (goto2++ == 1) xlabel=xlabel "@" 31.490 - } 31.491 - if (file == "tazboot.cpp" && /close\(x/) isotazboot=16 31.492 - if (isotazboot == 160) { # TAZBOOT.LST 31.493 - $0="; " $0 31.494 - if (/ret/) isotazboot=0 31.495 - } 31.496 - if (isotazboot == 16) { # TAZBOOT.LST 31.497 - if (/@.@/) { 31.498 - isotazboot=160 31.499 - next 31.500 - } 31.501 - } 31.502 - if (file == "tazboot.cpp" && /jne @@2/) isotazboot=15 31.503 - if (isotazboot == 15) { # TAZBOOT.LST 31.504 - if (/@.@/) { 31.505 - print " pop di" 31.506 - print " pop si" 31.507 - print " mov sp,bp" 31.508 - print " pop bp" 31.509 - print " ret" 31.510 - next 31.511 - } 31.512 - if (/skip_alloc/) isotazboot=0 31.513 - } 31.514 - if (/if\(\*s>=/) isotazboot=14 31.515 - if (isotazboot == 14) { # LINLD.LST 31.516 - if (/jmp/) { 31.517 - $0=" db 0A9h ; test ax,xxxx instead of " $0 31.518 - isotazboot=0 31.519 - } 31.520 - } 31.521 - if (file == "tazboot.cpp" && /; s \+= 4/) isotazboot=13 # tazboot/main 31.522 - if (isotazboot == 13) { # TAZBOOT.LST 31.523 - if (/si,4/) $0=" lea bx,[si+4]" 31.524 - if (/bx,si/) next 31.525 - if (/DGROUP:_topmem/ || /set_iso/) isotazboot=0 31.526 - } 31.527 - if (file == "tazboot.cpp" && /case 0x652F:/) isotazboot=12 # tazboot/main 31.528 - if (isotazboot == 12) { # TAZBOOT.LST 31.529 - sub(/si,word/,"bx,word") 31.530 - if (/short/) isotazboot=0 31.531 - } 31.532 - if (/return load_kernel/) isotazboot=11 # tazboot/isokernel 31.533 - if (isotazboot == 11) { # TAZBOOT.LST 31.534 - sub(/call/,"jmp") 31.535 - if (/ret/ || /pop/) next 31.536 - if (/endp/) isotazboot=0 31.537 - } 31.538 - if (/cmdline=s\+=3/ || /magic \!= 0/ || /&root_dev =/) { isotazboot=10; j="" } # ,tazboot/bootiso,tazboot/main 31.539 - if (isotazboot == 10) { # TAZBOOT.LST && LINLD.LST 31.540 - if (/je/ || /jne/) { j=$1; next } 31.541 - if (/jmp/) { 31.542 - if (j=="jne") sub(/jmp/,"je") 31.543 - else if (j=="je") sub(/jmp/,"jne") 31.544 - isotazboot=0 31.545 - } 31.546 - } 31.547 - if (/static const unsigned long initrddesc = 18L/) isotazboot=9 # tazboot/bootiso 31.548 - if (isotazboot == 9) { # TAZBOOT.LST 31.549 - if (/,0/) { 31.550 - split($4,y,",") 31.551 - print " mov bx,offset " y[1] 31.552 - sub(/DGROUP:.*,/,"[bx],") 31.553 - } 31.554 - if (/mov/ && $3 == y[1]) next 31.555 - if (/je/) next 31.556 - if (/jmp/) sub(/jmp/,"jne") 31.557 - sub(/ax,offset/,"bx,offset") 31.558 - if (/bx,ax/) { isotazboot=0; next } 31.559 - } 31.560 - if (/isoopen\(s\+7\) != -1/) isotazboot=8 # tazboot/bootiso 31.561 - if (isotazboot == 8) { # TAZBOOT.LST 31.562 - sub(/\[bx/,"[si") 31.563 - if (/bx,si/) next 31.564 - if (/magic/) isotazboot=0 31.565 - } 31.566 - if (/isoopen\(\"bzImage\"\)/) isotazboot=7 # tazboot/bootiso 31.567 - if (isotazboot == 7) { # TAZBOOT.LST 31.568 - if (/inc/ || /,al/) next 31.569 - if (/al,byte/) sub (/mov al,/,"inc ") 31.570 - if (/isokernel/) isotazboot=0 31.571 - } 31.572 - if (/if \(c\) s\+\+;/) isotazboot=6 # tazboot/main 31.573 - if (isotazboot == 6) { # TAZBOOT.LST 31.574 - if (/cmp/) { 31.575 - $0=" cmp al,0" 31.576 - isotazboot=0 31.577 - } 31.578 - } 31.579 - if (/static void next_chunk/) isotazboot=5 # tazboot/next_chunk 31.580 - if (isotazboot == 501) { 31.581 - if (/ret/) { 31.582 - print "@1@86:" 31.583 - isotazboot=0 31.584 - } 31.585 - } 31.586 - if (isotazboot == 5 || isotazboot == 500) { # TAZBOOT.LST 31.587 - if (/cx,ax/) $0=" xchg ax,bx" 31.588 - if (/ax,word ptr \[si\+28\]/ && isotazboot == 500) next 31.589 - if (/bx,cx/) next 31.590 - if (/push/ || /pop/ || /bp,sp/ || /si,/) next 31.591 - sub(/\[si/,"[di") 31.592 - if (/initrd_info/) isotazboot=500 31.593 - if (/bx\+6\]/) next 31.594 - if (/bx\+4\]/) sub(/mov dx,/,"les dx,d") 31.595 - sub(/di\+24\],ax/,"di+24],es") 31.596 - sub(/call/,"jmp") 31.597 - if (/ret/ || /pop/ || /^@1@86:/) next 31.598 - if (/_isostate\+14/) next 31.599 - if (/_isostate\+12/) { 31.600 - sub(/mov ax,/,"les ax,d") 31.601 - print 31.602 - print " mov dx,es" 31.603 - next 31.604 - } 31.605 - if (/ax,-4/) isotazboot++ 31.606 - } 31.607 - if (/0x7FF0/) isotazboot=4 # tazboot/bootiso 31.608 - if (isotazboot == 4) { # TAZBOOT.LST 31.609 - if (/ax,word ptr/) { 31.610 - print " mov ax,32752" 31.611 - print " cwd" 31.612 - sub(/mov/,"sub") 31.613 - } 31.614 - if (/bx,/ || /cx,/ || /dx,/) next 31.615 - sub(/,0/,",dx") 31.616 - sub(/,bx/,",dx") 31.617 - sub(/,cx/,",ax") 31.618 - if (/@addinitrd\$qv/) isotazboot=0 31.619 - } 31.620 - if (/c = x->filename/) isotazboot=3 # tazboot/bootiso 31.621 - if (isotazboot == 3) { # TAZBOOT.LST 31.622 - if (/ax,/) $0=" xchg ax,bx" 31.623 - if (/\]$/) next 31.624 - if (/@strcpy\$qpxzct1/) isotazboot=0 31.625 - } 31.626 - if (/base_himem = memtop/) isotazboot=2 # tazboot/bootiso 31.627 - if (isotazboot == 2) { # TAZBOOT.LST 31.628 - if (/word ptr \[si\+2\],0/) { 31.629 - print s; hold=0 31.630 - print " mov bx,word ptr [si+2]" 31.631 - $0=" or bx,bx" 31.632 - } 31.633 - if (/\[bp-4\],ax/) sub(/ax/,"bx") 31.634 - if (/ax,word ptr \[si\+2\]/ || /bx,ax/) next 31.635 - if (/_base_himem\+2,dx/) { 31.636 - print " mov bx,offset DGROUP:_base_himem+2" 31.637 - } 31.638 - sub(/DGROUP:_base_himem,/,"[bx-2],") 31.639 - sub(/DGROUP:_base_himem\+2,/,"[bx],") 31.640 - sub(/DGROUP:_base_himem\+3,/,"[bx+1],") 31.641 - if (/@strcmp\$qpxzct1/) isotazboot=0 31.642 - } 31.643 - if (/static void addinitrd/) isotazboot=100 # tazboot/addinitrd 31.644 - if (isotazboot == 100) { # TAZBOOT.LST 31.645 - if (/cx,ax/) { 31.646 - print " mov si,offset _isostate+8" 31.647 - print " push ds" 31.648 - print " pop es" 31.649 - print " xchg ax,di" 31.650 - print " movsw" 31.651 - print " movsw" 31.652 - print " movsw" 31.653 - print " movsw" 31.654 - $0=" xchg ax,di" 31.655 - } 31.656 - if (/mov/ && !/si/ && !/cl/) next 31.657 - if (/void load_initrds/) isotazboot=101 31.658 - } 31.659 - if (isotazboot == 101 || isotazboot == 102) { # TAZBOOT.LST 31.660 - sub(/\[si/,"[di"); sub(/si,/,"di,"); sub(/si$/,"di") 31.661 - sub(/DGROUP:_imgs\+38$/,"[di+38-32]") 31.662 - sub(/DGROUP:_imgs\+40$/,"[di+40-32]") 31.663 - if (/isofd/) isotazboot=102 31.664 - if (/push/ && isotazboot == 102) next 31.665 - if (/pop/ && isotazboot == 102) next 31.666 - if (/load_initrd/) isotazboot=101 31.667 - if (/isokernel/) isotazboot=103 31.668 - } 31.669 - if (isotazboot > 102) { # TAZBOOT.LST 31.670 - if (/push/ || /pop/) next 31.671 - sub(/\[si/,"[bx") 31.672 - sub(/si,/,"bx,") 31.673 - if (/static void bootiso/) isotazboot=0 31.674 - } 31.675 if (wascall) { 31.676 if (rcall != "") { 31.677 if (/,ax$/) print " mov " rcall ",ax"
32.1 --- a/syslinux/stuff/iso2exe/bootiso.S Wed Dec 16 17:23:49 2020 +0000 32.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Fri Jan 08 20:15:35 2021 +0000 32.3 @@ -153,71 +153,30 @@ 32.4 32.5 ////////////////////////////// DOS EXE code /////////////////////////////////// 32.6 32.7 -bootdir: 32.8 - .asciz "/boot" 32.9 -linld: 32.10 - .asciz "linld.com" 32.11 cmdline: 32.12 -// .ascii "-f " 32.13 -// .ascii "image=\boot\" 32.14 -// .ascii "bzImage " 32.15 - .ascii "initrd=" 32.16 -rootfs: 32.17 - .ascii "rootfs" 32.18 -dotgz: 32.19 - .ascii ".gz,! " 32.20 -// .ascii ".gz,rootfs4.gz,! " 32.21 -args: 32.22 -// .ascii " rw " 32.23 -// .ascii " mode=menu" 32.24 - .ascii " autologin rdinit=/init.exe magic=" 32.25 -magicstr: 32.26 - .ascii "0 iso=" 32.27 -// .ascii "65535 iso=" 32.28 -filename: 32.29 + .ds.b 128,0 32.30 +linldofs: // offset of linld.com in iso 32.31 + .long 0 // Updated by iso2exe 32.32 +linldsz: // size-1 32.33 + .word 0 // Updated by iso2exe 32.34 exestart: 32.35 movb $0x30,%ah // get DOS version 32.36 int $0x21 32.37 cmpb $3,%al 32.38 - jc goabort 32.39 + jc abort 32.40 + 32.41 +// load linld.com 32.42 32.43 cld 32.44 - movw EXEADRS(comstart),%si 32.45 - movw $0xF000,%di 32.46 - movb $4,%ch // 2k min 32.47 +linldbuf = 0x8000 32.48 +isopath = 0x7000 32.49 + movw $0x8000,%cx // clear 8000-FFFF 32.50 + movw %cx,%di 32.51 + movb %cl,%al 32.52 rep 32.53 - movsw // helper 32.54 - movw $129,%si 32.55 - leaw args-cmdline(%si),%di 32.56 - movb -1(%si),%cl 32.57 - pushw %si 32.58 - rep 32.59 - movsb // user args 32.60 - xchgw %ax,%di 32.61 - popw %di 32.62 - movw $EXEADRS(cmdline),%si 32.63 - movb $args-cmdline,%cl 32.64 - rep 32.65 - movsb // files 32.66 - xchgw %ax,%di 32.67 - movb $filename-args,%cl 32.68 - rep 32.69 - movsb // end 32.70 - pushw %di // filename 32.71 + stosb 32.72 32.73 -#define ISOSTATE 0xF000 32.74 -#define ISO_OPEN iso_open 32.75 -#define ISO_READDIR *0xF004 32.76 -#define ISO_READMENU iso_readmenu 32.77 -#define RUN_LINLD run_linld 32.78 - movw ISOSTATE,%bp 32.79 - xorw %ax,%ax 32.80 - movw %bp,%di 32.81 - movb $64,%cl 32.82 - rep 32.83 - stosb // clear BSS 32.84 - 32.85 - movw %ax,%di 32.86 + movw %di,%ax 32.87 movw 0x2C(%di),%es 32.88 decw %cx 32.89 scalp: 32.90 @@ -225,22 +184,23 @@ 32.91 scasb 32.92 scasb 32.93 jne scalp 32.94 - scasw 32.95 - movw %di,%si // %es:%di = programme pathname 32.96 - 32.97 + scasw // %es:%di = programme pathname 32.98 pushw %es 32.99 - pushw %ds 32.100 + pushw %cs 32.101 popw %es 32.102 popw %ds 32.103 - popw %di // filename 32.104 - pushw %di 32.105 +#define CONONICALIZE_FILENAME insert obsolute path 32.106 +#ifdef CONONICALIZE_FILENAME 32.107 + movw %di,%si // %ds:%si = programme pathname 32.108 + movw $EXEADRS(isopath),%di // to filename %es:%di 32.109 movb $0x60,%ah // canonicalize filename 32.110 int $0x21 32.111 pushw %es 32.112 popw %ds 32.113 +#endif 32.114 + movw %di,%si // %ds:%si = programme pathname 32.115 #define LONG_FILENAME 32.116 #ifdef LONG_FILENAME 32.117 - popw %si 32.118 pushw %si 32.119 movw $0x716C,%ax 32.120 xorw %bx,%bx // R/O 32.121 @@ -249,126 +209,133 @@ 32.122 stc 32.123 int $0x21 32.124 jnc opened 32.125 + popw %dx 32.126 +#else 32.127 + movw %si,%dx 32.128 #endif 32.129 - popw %dx 32.130 - pushw %dx 32.131 + pushw %si 32.132 movw $0x3D00,%ax 32.133 // movb $0,%cl 32.134 int $0x21 32.135 -goabort: 32.136 - jc abort 32.137 + jc popNabort 32.138 opened: 32.139 - movw %ax,4(%bp) // fd 32.140 - 32.141 - call ISO_READMENU 32.142 - movw 6(%bp),%ax // magic = filemod 32.143 - popw %bx 32.144 - leaw magicstr-filename(%bx),%di 32.145 - movb $10,%bl 32.146 - xorw %cx,%cx 32.147 -lp1: 32.148 - xorw %dx,%dx 32.149 - divw %bx 32.150 - pushw %dx 32.151 - incw %cx 32.152 - orw %ax,%ax 32.153 - jnz lp1 32.154 -lp2: 32.155 - popw %ax 32.156 - addb $'0',%al 32.157 - stosb // store magic 32.158 - loop lp2 32.159 - 32.160 - movw $EXEADRS(bootdir),%ax 32.161 - call ISO_OPEN 32.162 - orw $-1,18(%bp) // curdirsize = -1 32.163 - xorw %ax,%ax 32.164 -found: 32.165 - incb %ah 32.166 -patchtest: 32.167 - pushw %ax 32.168 - call ISO_READDIR 32.169 - pushw %ds 32.170 - popw %es 32.171 - incw %ax 32.172 - popw %ax 32.173 - movw $EXEADRS(rootfs),%si 32.174 - je dopatch 32.175 - movw %si,%di 32.176 - movw 16(%bp),%si // filename 32.177 - movw $9,%cx 32.178 - rep 32.179 - cmpsb 32.180 - jcxz found 32.181 - cmpb $3,%cl 32.182 - ja patchtest 32.183 - decw %si 32.184 - cmpb (%si),%al 32.185 - ja patchtest 32.186 - lodsb 32.187 - jmp patchtest 32.188 -done: 32.189 - movw $128,%ax 32.190 - subw %ax,%si 32.191 - xchgw %ax,%si 32.192 - decw %ax 32.193 - movb %al,(%si) // cmdline length 32.194 - 32.195 - movw $EXEADRS(linld),%ax 32.196 - call ISO_OPEN 32.197 - jc abort 32.198 - movw 12(%bp),%cx // filesize 32.199 - movw $0x100,%dx 32.200 - call RUN_LINLD 32.201 + xchgw %ax,%bx // fd = %bx 32.202 + movw $32,%cx 32.203 + movw $EXEADRS(headbuf),%dx 32.204 + movb $0x3F,%ah 32.205 + int $0x21 // read(%bx,%dx,%cx) 32.206 + jc popNabort 32.207 + les EXEADRS(linldofs),%dx 32.208 + movw %es,%cx 32.209 + movw $0x4200,%ax // lseek(%bx,%cx:%dx,SEEK_SET) 32.210 + int $0x21 32.211 + jc popNabort 32.212 + movw EXEADRS(linldsz),%cx 32.213 + jcxz popNabort 32.214 + movw $EXEADRS(linldbuf),%dx 32.215 + movw %cx,%di 32.216 + addw %dx,%di 32.217 + movb $0x3F,%ah 32.218 + int $0x21 // read(%bx,%dx,%cx) 32.219 + jnc copycmdline 32.220 +popNabort: 32.221 + popw %si 32.222 abort: 32.223 movw $EXEADRS(stopmsg),%dx 32.224 movb $9,%ah 32.225 int $0x21 32.226 int $0x20 32.227 -dopatch: 32.228 - pushw %si 32.229 - cmpw $0x200,%ax 32.230 - je initrddone 32.231 - movw $EXEADRS(dotgz),%di 32.232 - decb %ah 32.233 - je modify 32.234 - scasw 32.235 - scasw // addw $4,%di 32.236 - movsw 32.237 - movsw 32.238 - movsw 32.239 -modify: 32.240 + 32.241 +// installed args (ex: image=/boot/bzImage initrd=rootfs4.gz,! autologin rdinit=/init.exe) 32.242 + 32.243 +copycmdline: 32.244 + pushw %ds 32.245 + popw %es 32.246 + movw $EXEADRS(cmdline),%si 32.247 + movw %di,%bx 32.248 + 32.249 +copylp: 32.250 + lodsb 32.251 stosb 32.252 - movw $129+dotgz-cmdline,%si 32.253 - movsb 32.254 - movsw 32.255 - movsw 32.256 -initrddone: 32.257 - movw $129+rootfs-cmdline,%di 32.258 - popw %si 32.259 - movw $args-rootfs,%cx 32.260 + orb %al,%al 32.261 + jnz copylp 32.262 + 32.263 +// magic=<magic> arg 32.264 + 32.265 + decw %di 32.266 + movw $7,%cx 32.267 + movw $EXEADRS(magicstr),%si 32.268 rep 32.269 movsb 32.270 + movw EXEADRS(headbuf+18),%ax // magic 32.271 + movw $10,%si 32.272 +magiclp1: 32.273 + xorw %dx,%dx 32.274 + divw %si 32.275 + pushw %dx 32.276 + incw %cx 32.277 + orw %ax,%ax 32.278 + jnz magiclp1 32.279 +magiclp2: 32.280 + popw %ax 32.281 + addb $'0',%al 32.282 + stosb // store magic 32.283 + loop magiclp2 32.284 32.285 -shrink0: 32.286 - movw $129,%si 32.287 -shrink: 32.288 - movw %si,%di 32.289 - lodsb 32.290 - cmpb $0,%al 32.291 - je done 32.292 - cmpb $' ',%al 32.293 - jne shrink 32.294 - cmpb (%si),%al 32.295 - jne shrink 32.296 -pack: 32.297 +// iso=<file> arg 32.298 + 32.299 + movb $5,%cl 32.300 + movw $EXEADRS(isostr),%si 32.301 + rep 32.302 + movsb 32.303 + popw %si 32.304 +isolp: 32.305 lodsb 32.306 stosb 32.307 - cmpb $0,%al 32.308 - jne pack 32.309 - jmp shrink0 32.310 - 32.311 + orb %al,%al 32.312 + jne isolp 32.313 + decw %di 32.314 + 32.315 +// append user args 32.316 + 32.317 + movw $0x80,%si 32.318 + lodsb 32.319 + movb $0xFF,-1(%si) // long cmdline flag 32.320 + cbw 32.321 + xchgw %ax,%cx 32.322 + rep 32.323 + movsb 32.324 + movb $0,(%di) 32.325 + 32.326 +// set cmdline size 32.327 + 32.328 + movw %di,%ax 32.329 + subw %bx,%ax 32.330 + incw %ax 32.331 + movb %al,-1(%bx) 32.332 + 32.333 +// run linld.com 32.334 + 32.335 + movw $EXEADRS(mvNjump),%si 32.336 + incw %di 32.337 + movb $endmvNjump-mvNjump,%cl 32.338 +mvNjump: 32.339 + pushw %di 32.340 + rep 32.341 + movsb 32.342 + movw $EXEADRS(linldbuf),%si 32.343 + movw $0x0100,%di 32.344 + popw %cx 32.345 + pushw %cx 32.346 + subw %si,%cx 32.347 + ret 32.348 +endmvNjump: 32.349 + 32.350 +magicstr: .ascii " magic=" 32.351 +isostr: .ascii " iso=" 32.352 + 32.353 .org 0x0400,0xEE 32.354 +headbuf: 32.355 .org 0x0600,0xFF 32.356 isolinux: 32.357 32.358 @@ -632,12 +599,5 @@ 32.359 stopmsg: 32.360 .ascii "This program cannot be run in DOS mode.$" 32.361 .org 0x0778,0xEE 32.362 - .org 0xF002-0xC0 32.363 -iso_open: 32.364 - .word 0 32.365 - .word 0 32.366 -iso_readmenu: 32.367 - .word 0 32.368 -run_linld: 32.369 32.370 .end
33.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Wed Dec 16 17:23:49 2020 +0000 33.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Fri Jan 08 20:15:35 2021 +0000 33.3 @@ -51,15 +51,6 @@ 33.4 rm -rf $TMP 33.5 } 33.6 33.7 -add_doscom() 33.8 -{ 33.9 - SIZE=$($0 --get boot.com | wc -c) 33.10 - OFS=$(( $OFS - $SIZE )) 33.11 - printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE 33.12 - $0 --get boot.com | ddn of=$1 bs=1 seek=$OFS 33.13 - store 64 $(($OFS+0xC0)) $1 33.14 -} 33.15 - 33.16 add_tazlito_info() 33.17 { 33.18 HOLE=$OFS 33.19 @@ -110,6 +101,20 @@ 33.20 store 454 $(($i/512)) $1 32 ### 446+8 OFFSET 33.21 store 458 $(($(stat -c %s $1)/512)) $1 32 ### 446+12 SIZE 33.22 fi 33.23 + mkdir /tmp/mnt$$ 33.24 + mount -o loop,ro $1 /tmp/mnt$$ 33.25 + if [ -s /tmp/mnt$$/boot/linld.com ]; then 33.26 + i=$(($(get 20 $1)-0xC0)) 33.27 + store $(($i-6)) $(($(stat -m /tmp/mnt$$/boot/linld.com | sed q)*2048)) $1 32 33.28 + store $(($i-2)) $(stat -c %s /tmp/mnt$$/boot/linld.com) $1 33.29 + r0="$(cd /tmp/mnt$$/boot/ ; ls rootfs.gz 2> /dev/null)" 33.30 + r1="$(cd /tmp/mnt$$/boot/ ; ls -r rootfs?*.gz 2> /dev/null | sed q)" 33.31 + [ "$r0" -a "$r1" ] && r0="$r0," 33.32 + echo -n "image=/boot/bzImage initrd=$r0$r1,! autologin rdinit=/init.exe" | \ 33.33 + ddn bs=1 of=$1 conv=notrunc seek=$(($i-134)) 33.34 + fi 33.35 + umount /tmp/mnt$$ 33.36 + rmdir /tmp/mnt$$ 33.37 } 33.38 33.39 add_fdbootstrap() 33.40 @@ -293,8 +298,8 @@ 33.41 --build) 33.42 shift 33.43 TMP=/tmp/iso2exe$$ 33.44 - dd if=/dev/zero bs=1k count=100 of=/tmp/fs$$ 33.45 - mke2fs /tmp/fs$$ 33.46 + ddq if=/dev/zero bs=1k count=100 of=/tmp/fs$$ 33.47 + mke2fs /tmp/fs$$ > /dev/null 33.48 mkdir $TMP 33.49 mount -o loop /tmp/fs$$ $TMP 33.50 rm -rf $TMP/* 33.51 @@ -307,7 +312,7 @@ 33.52 umount -d $TMP 33.53 rm -rf $TMP /tmp/fs$$ 33.54 p=$((4-($(stat -c %s rootfs.gz)%4))) 33.55 - [ $p = 4 ] || dd if=/dev/zero bs=1 count=$p >> rootfs.gz 33.56 + [ $p = 4 ] || ddq if=/dev/zero bs=1 count=$p >> rootfs.gz 33.57 chmod 644 ${@/init/rootfs.gz} 33.58 chown root.root ${@/init/rootfs.gz} 33.59 touch -t 197001010100.00 ${@/init/rootfs.gz} 33.60 @@ -328,7 +333,6 @@ 33.61 add_win32exe $DATA $2 > /dev/null 33.62 HSZ=$OFS 33.63 add_rootfs $DATA > /dev/null 33.64 - add_doscom $DATA > /dev/null 33.65 add_fdbootstrap $DATA > /dev/null 33.66 name=${3:-bootiso} 33.67 BOOTISOSZ=$((0x8000 - $OFS + $HSZ)) 33.68 @@ -574,7 +578,6 @@ 33.69 33.70 # keep the largest room for the tazlito info file 33.71 add_rootfs $1 33.72 - add_doscom $1 33.73 add_fdbootstrap $1 33.74 printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS 33.75 store 440 $(date +%s) $1 32
34.1 --- a/syslinux/stuff/iso2exe/taziso Wed Dec 16 17:23:49 2020 +0000 34.2 +++ b/syslinux/stuff/iso2exe/taziso Fri Jan 08 20:15:35 2021 +0000 34.3 @@ -44,16 +44,14 @@ 34.4 gettazboot() 34.5 { 34.6 echo -e "\nCreating $(basename $1) ..." 34.7 - S=$((32+HEADERSZ)) 34.8 + gotcdfile linld.com 34.9 + S=$(($(stat -c %s $file)+12)) 34.10 P=$((($S+511)/512)) 34.11 E=$((4096-(32*$P))) 34.12 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 -16 \ 34.13 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 34.14 - uudecode - >> $1 << EOT 34.15 -HEADERCODE 34.16 -EOT 34.17 - gotcdfile linld.com 34.18 - ddq if=$file >> $1 34.19 + dd if=$file bs=1 count=$(($(stat -c %s $file)-1)) >> $1 2> /dev/null 34.20 + echo -en '@tazboot.cmd\0' >> $1 34.21 } 34.22 34.23 maybe64() 34.24 @@ -1370,8 +1368,6 @@ 34.25 } 34.26 34.27 if [ "$1" = "--build" ]; then #install-begin 34.28 - uuencode -m - < header.com | sed -e '/^HEADERCODE$/r/dev/stdin' \ 34.29 - -e "s|HEADERSZ|$(size header.com)|" -e '/^HEADERCODE$/d' -i $0 34.30 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \ 34.31 -e '/^ifmemcode$/d' -i $0 34.32 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/web-applications/stuff/applications/gemini.desktop Fri Jan 08 20:15:35 2021 +0000 35.3 @@ -0,0 +1,9 @@ 35.4 +[Desktop Entry] 35.5 +Type=Application 35.6 +Name=Gemini project 35.7 +Name[fr]=Projet Gemini 35.8 +TryExec=browser 35.9 +Exec=browser https://proxy.vulpes.one/gemini/gemini.circumlunar.space/ 35.10 +#Exec=browser https://portal.mozz.us/gemini/gemini.circumlunar.space/ 35.11 +Icon=applications-internet 35.12 +Categories=Network;