wok-6.x rev 23863
syslinux/isoboot.s: accept user args
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Jun 19 15:46:21 2020 +0000 (2020-06-19) |
parents | f17d3e9b8ddc |
children | 06b9d6e33bee |
files | linld/stuff/src/!COMPILE.BAT linld/stuff/src/ISO9660.CPP linld/stuff/src/ISOCRTL.ASM linld/stuff/src/_ISOBEG.ASM linld/stuff/src/pipehole.awk syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/linld/stuff/src/!COMPILE.BAT Fri Jun 19 11:08:54 2020 -0400 1.2 +++ b/linld/stuff/src/!COMPILE.BAT Fri Jun 19 15:46:21 2020 +0000 1.3 @@ -3,16 +3,12 @@ 1.4 tasm /h > helptasm.log 1.5 bcc > helpbcc.log 1.6 tlink > helptlink.log 1.7 -bcc @bccopt.opt -S -mt -DISOHOOK -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log 1.8 +bcc @bccopt.opt -S -mt -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log 1.9 ren LINLD.ASM LINLD.ASO 1.10 ren LOAD.ASM LOAD.ASO 1.11 ren HIMEM.ASM HIMEM.ASO 1.12 -ren ISO9660.ASM ISO9660.ASO 1.13 mawk -f pipehole.awk LINLD.ASO > LINLD.ASM 1.14 mawk -f pipehole.awk LOAD.ASO > LOAD.ASM 1.15 mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM 1.16 -mawk -f pipehole.awk ISO9660.ASO > ISO9660.ASM 1.17 -tasm /la /m /dISOHOOK /dMOVE_SETUP /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log 1.18 +tasm /la /m /dMOVE_SETUP /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log 1.19 tlink /m /s /t @link.cmd > lnk.log 1.20 -tlink /m /s /t @link2.cmd > lnk2.log 1.21 -tlink /m /s /t @header.cmd > header.log
2.1 --- a/linld/stuff/src/ISO9660.CPP Fri Jun 19 11:08:54 2020 -0400 2.2 +++ b/linld/stuff/src/ISO9660.CPP Fri Jun 19 15:46:21 2020 +0000 2.3 @@ -11,17 +11,26 @@ 2.4 #define cpydirofs(to,from) ((to) = (from)) 2.5 #endif 2.6 2.7 +#ifdef ISOHOOK 2.8 +void isoroot(void) 2.9 +#else 2.10 int isoroot(void) 2.11 +#endif 2.12 { 2.13 static const unsigned long root = 16UL * 2048; 2.14 - struct isostate *x=&isostate; 2.15 - if (isoreadsector(&root) == -1 || strhead(x->buffer+1,"CD001") == -1) { 2.16 - //close(x->fd); 2.17 +#ifdef ISOHOOK 2.18 + isoreadsector(&root); 2.19 + setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 2.20 + isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 2.21 +#else 2.22 + if (isoreadsector(&root) == -1 || strhead(isostate.buffer+1,"CD001") == -1) { 2.23 + //close(isostate.fd); 2.24 return -1; 2.25 } 2.26 - setdirofs(x->dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 2.27 - x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 2.28 + setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 2.29 + isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 2.30 return 0; 2.31 +#endif 2.32 } 2.33 2.34 int isoreaddir(void) 2.35 @@ -121,6 +130,15 @@ 2.36 _64bits = cpuhaslm(); 2.37 #endif 2.38 do { 2.39 +#ifdef ISOHOOK 2.40 + s = (char *) x->filename2open; 2.41 + if (*s == '/') { 2.42 + s++; 2.43 + isoroot(); 2.44 + } 2.45 + name = s; 2.46 + while (*++s); 2.47 +#else 2.48 for (s = (char *) x->filename2open; *s == '/' ; s++) { 2.49 isoroot(); 2.50 } 2.51 @@ -128,6 +146,7 @@ 2.52 name = s; 2.53 do s++; while (*s && *s != '/'); 2.54 c = *s; *s = 0; 2.55 +#endif 2.56 for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) { 2.57 const char *n = name; 2.58 #define i (x->tmp) 2.59 @@ -138,11 +157,15 @@ 2.60 i += s - name; // strlen(name); 2.61 } 2.62 if (strcmp(i, n)) continue; 2.63 +#ifndef ISOHOOK 2.64 *s++ = c; 2.65 +#endif 2.66 if (IS_DIR(x->filemod)) { 2.67 cpydirofs(x->dirofs, x->fileofs); 2.68 x->dirsize = filesize2dirsize(x->filesize); 2.69 +#ifndef ISOHOOK 2.70 if (c) goto next; 2.71 +#endif 2.72 } 2.73 isolseek(&x->fileofs); 2.74 return 0;
3.1 --- a/linld/stuff/src/ISOCRTL.ASM Fri Jun 19 11:08:54 2020 -0400 3.2 +++ b/linld/stuff/src/ISOCRTL.ASM Fri Jun 19 15:46:21 2020 +0000 3.3 @@ -23,7 +23,7 @@ 3.4 3.5 public _isostate 3.6 _isostate isostate <?> 3.7 - org $-7 3.8 +; org $-7 3.9 3.10 ends _BSS 3.11 3.12 @@ -31,9 +31,14 @@ 3.13 3.14 global fold:near 3.15 fold: 3.16 - org 0F000h 3.17 + org 0EF00h 3.18 global unfold:near 3.19 unfold: 3.20 + jmp iso_open 3.21 + extrn @isoreaddir$qv 3.22 + dw @isoreaddir$qv 3.23 + jmp @readmenu$qv 3.24 + 3.25 push dx 3.26 call readfd 3.27 push ds 3.28 @@ -65,11 +70,8 @@ 3.29 iso_open: 3.30 mov [_isostate.filename2open],ax 3.31 call @_isoopen$qv 3.32 - inc ax 3.33 - jnz open_ok 3.34 - dec ax 3.35 - stc 3.36 -open_ok: 3.37 + cmp ax,1 3.38 + cmc 3.39 push bx 3.40 iso_close_hack: 3.41 pop bx 3.42 @@ -91,74 +93,12 @@ 3.43 pop cx 3.44 endm 3.45 3.46 -iso_read_hack: 3.47 - ifdef NO386 3.48 - push dx 3.49 - curseek 3.50 - mov bx,[word _isostate.filesize] 3.51 - sub bx,ax 3.52 - mov ax,[(word _isostate.filesize)+2] 3.53 - sbb ax,dx 3.54 - ja @@cxok 3.55 - je @@rem 3.56 - xor cx,cx 3.57 -@@rem: 3.58 - cmp bx,cx 3.59 - ja @@cxok 3.60 - mov cx,bx 3.61 -@@cxok: 3.62 - pop dx 3.63 - else 3.64 - p386 3.65 - push edx 3.66 - curseek 3.67 - mov edx,[_isostate.filesize] 3.68 - sub edx,eax 3.69 - jnb @@rem 3.70 - xor cx,cx 3.71 -@@rem: 3.72 - movzx eax,cx 3.73 - cmp edx,eax 3.74 - ja @@cxok 3.75 - mov cx,dx 3.76 -@@cxok: 3.77 - pop edx 3.78 - endif 3.79 - or cx,cx 3.80 - pop bx 3.81 - jmp readfd 3.82 +;*************************************************************** 3.83 +;_fastcall void readmenu(void); 3.84 +;*************************************************************** 3.85 + global @readmenu$qv:near 3.86 + proc @readmenu$qv near 3.87 3.88 -iso_lseek_hack: 3.89 - xchg ax,bx 3.90 - pop bx 3.91 - ifdef SEEK_CUR 3.92 - cmp al,1 ; current 3.93 - jne @@nocurrent 3.94 - call dosfd ; lseek(,0L,SEEK_CUR) 3.95 - jmp @doseek2 3.96 -@nocurrent: 3.97 - endif 3.98 - add dx,[word _isostate.fileofs] 3.99 - adc cx,[(word _isostate.fileofs)+2] 3.100 - cmp al,0 ; start 3.101 - je @@doseek 3.102 - add dx,[word _isostate.filesize] 3.103 - adc cx,[(word _isostate.filesize)+2] 3.104 -@@doseek: 3.105 - call lseekset ; lseek(,0L,SEEK_SET) 3.106 -@doseek2: 3.107 - sub ax,[word _isostate.fileofs] 3.108 - sbb dx,[(word _isostate.fileofs)+2] 3.109 - ret 3.110 - 3.111 -iso_cleanup_hack: 3.112 - mov ah,3Eh ; close file 3.113 - jmp dosfd 3.114 - 3.115 - 3.116 - 3.117 - global @readmenu$qv:near 3.118 -@readmenu$qv: 3.119 mov dx,18 3.120 xor cx,cx 3.121 call lseekset 3.122 @@ -167,13 +107,16 @@ 3.123 call readfd ; // read x->filemod + x->fileofs & x->filesize 3.124 mov bx,offset _isostate.fileofs 3.125 ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 3.126 - and [word bx+6],0 3.127 mov ax,7FF0h 3.128 + cwd 3.129 + mov [word bx+6],dx 3.130 sub ax,[bx+4] 3.131 - and [word bx+2],0 3.132 + mov [word bx+2],dx 3.133 mov [bx],ax 3.134 ; //magic = x->filemod; 3.135 3.136 + endp @readmenu$qv 3.137 + 3.138 ;*************************************************************** 3.139 ;_fastcall void isolseek(bx:const unsigned long *offset); 3.140 ;*************************************************************** 3.141 @@ -260,6 +203,69 @@ 3.142 3.143 endp @strcmp$qpxzct1 3.144 3.145 +iso_read_hack: 3.146 + ifdef NO386 3.147 + push dx 3.148 + curseek 3.149 + mov bx,[word _isostate.filesize] 3.150 + sub bx,ax 3.151 + mov ax,[(word _isostate.filesize)+2] 3.152 + sbb ax,dx 3.153 + ja @@cxok 3.154 + je @@rem 3.155 + xor cx,cx 3.156 +@@rem: 3.157 + cmp bx,cx 3.158 + ja @@cxok 3.159 + mov cx,bx 3.160 +@@cxok: 3.161 + pop dx 3.162 + else 3.163 + p386 3.164 + push edx 3.165 + curseek 3.166 + mov edx,[_isostate.filesize] 3.167 + sub edx,eax 3.168 + jnb @@rem 3.169 + xor cx,cx 3.170 +@@rem: 3.171 + movzx eax,cx 3.172 + cmp edx,eax 3.173 + ja @@cxok 3.174 + mov cx,dx 3.175 +@@cxok: 3.176 + pop edx 3.177 + endif 3.178 + or cx,cx 3.179 + pop bx 3.180 + jmp readfd 3.181 + 3.182 +iso_lseek_hack: 3.183 + xchg ax,bx 3.184 + pop bx 3.185 + ifdef SEEK_CUR 3.186 + cmp al,1 ; current 3.187 + jne @@nocurrent 3.188 + call dosfd ; lseek(,0L,SEEK_CUR) 3.189 + jmp @doseek2 3.190 +@nocurrent: 3.191 + endif 3.192 + add dx,[word _isostate.fileofs] 3.193 + adc cx,[(word _isostate.fileofs)+2] 3.194 + cmp al,0 ; start 3.195 + je @@doseek 3.196 + add dx,[word _isostate.filesize] 3.197 + adc cx,[(word _isostate.filesize)+2] 3.198 +@@doseek: 3.199 + call lseekset ; lseek(,0L,SEEK_SET) 3.200 +@doseek2: 3.201 + sub ax,[word _isostate.fileofs] 3.202 + sbb dx,[(word _isostate.fileofs)+2] 3.203 + ret 3.204 + 3.205 +iso_cleanup_hack: 3.206 + mov ah,3Eh ; close file 3.207 + jmp dosfd 3.208 ifdef NO386 3.209 global N_LXLSH@ES:near 3.210 N_LXLSH@ES:
4.1 --- a/linld/stuff/src/_ISOBEG.ASM Fri Jun 19 11:08:54 2020 -0400 4.2 +++ b/linld/stuff/src/_ISOBEG.ASM Fri Jun 19 15:46:21 2020 +0000 4.3 @@ -20,15 +20,8 @@ 4.4 ends _DATA 4.5 4.6 segment _BSS byte public use16 'BSS' 4.7 - 4.8 global _bss_start:byte 4.9 label _bss_start byte 4.10 -utoabuf db 6 dup(?) 4.11 - 4.12 - include "isostate.inc" 4.13 - 4.14 - extrn _isostate:isostate 4.15 - 4.16 ends _BSS 4.17 4.18 segment _TEXT byte public use16 'CODE' 4.19 @@ -37,205 +30,8 @@ 4.20 global _text_start:byte 4.21 label _text_start byte 4.22 4.23 - extrn fold 4.24 - extrn unfold 4.25 - mov si,offset fold 4.26 - mov di,offset unfold 4.27 - mov ch,4 4.28 - cld 4.29 - rep 4.30 - movsw 4.31 - 4.32 -;*************************************************************** 4.33 -; clear bss 4.34 -;*************************************************************** 4.35 - 4.36 - mov si,offset _bss_start 4.37 -clearbss: 4.38 - mov [byte si],cl ; clear bss + heap 4.39 - inc si 4.40 - jne clearbss 4.41 - 4.42 -;*************************************************************** 4.43 -; build arg 4.44 -;*************************************************************** 4.45 - 4.46 - mov si,80h 4.47 - lodsb 4.48 - cbw 4.49 - xchg ax,bx 4.50 - mov [bx+si],bh ; set EOS 4.51 -searchStart: 4.52 - lodsb 4.53 - cmp al,0 4.54 - je _abort 4.55 - cmp al,' ' 4.56 - je searchStart 4.57 - dec si 4.58 - mov di,offset filename 4.59 - push di 4.60 - mov ah,60h ; canonicalize filename 4.61 - int 21h 4.62 - jc _abort 4.63 - ifdef WITH_LONG_FILENAME 4.64 - pop si 4.65 - mov ax,716Ch 4.66 - xor bx,bx ; R/O 4.67 - ;xor cx,cx ; attributes 4.68 - cwd ; action = open 4.69 - stc 4.70 - int 21h 4.71 - jnc opened 4.72 - mov dx,si 4.73 - else 4.74 - pop dx 4.75 - endif 4.76 - mov ax,3d00h ; read-only+compatibility 4.77 - ;mov cl,0 ; attribute mask 4.78 - int 21h 4.79 - jnc opened 4.80 - 4.81 -_abort: 4.82 - mov dx,offset stopmsg 4.83 - mov ah,9 4.84 - int 21h 4.85 - int 20h 4.86 -opened: 4.87 - mov [_isostate.fd],ax 4.88 - mov ax,offset bootdir 4.89 - extrn iso_open:near 4.90 - call iso_open 4.91 -jc_abort: 4.92 - jc _abort 4.93 - 4.94 -; patch magic 4.95 -;*************************************************************** 4.96 - 4.97 - extrn @readmenu$qv:near 4.98 - call @readmenu$qv 4.99 - mov ax,[_isostate.filemod] 4.100 - mov bx,10 4.101 - xor cx,cx 4.102 -@@loop1: 4.103 - xor dx,dx 4.104 - div bx ; DX:AX = n%10:n/10 4.105 - push dx ; DL = n%10 4.106 - inc cx 4.107 - or ax,ax 4.108 - jnz @@loop1 4.109 - push ds 4.110 - pop es 4.111 - mov di,offset magic 4.112 -@@loop2: 4.113 - pop ax 4.114 - add al,'0' 4.115 - stosb 4.116 - loop @@loop2 4.117 - 4.118 -; patch initrd 4.119 -;*************************************************************** 4.120 - cwd 4.121 - or [_isostate.curdirsize],-1 4.122 - jmp patchtest 4.123 -found: 4.124 - inc dh 4.125 -patchtest: 4.126 - push dx 4.127 - extrn @isoreaddir$qv:near 4.128 - call @isoreaddir$qv 4.129 - pop dx 4.130 - push ds 4.131 - pop es 4.132 - inc ax 4.133 - jne patchlp 4.134 - cmp dx,100h 4.135 - je initrddone 4.136 - mov di,offset dotgz 4.137 - or dh,dh 4.138 - je modify 4.139 - add di,4 4.140 - mov si,offset rootfs 4.141 - mov cx,3 4.142 - rep 4.143 - movsw 4.144 -modify: 4.145 - xchg ax,dx 4.146 - mov ah,'.' 4.147 - stosw 4.148 - mov ax,'zg' 4.149 - stosw 4.150 - mov ax,'!,' 4.151 - stosw 4.152 -initrddone: 4.153 - 4.154 -;*************************************************************** 4.155 - 4.156 - mov si, offset cmdline 4.157 - mov di, 82h 4.158 -copy: 4.159 - mov ah,al 4.160 - lodsb 4.161 - cmp al,' ' 4.162 - jne docopy 4.163 - cmp al,ah 4.164 - je copy 4.165 -docopy: 4.166 - stosb 4.167 - cmp al,0 4.168 - jnz copy 4.169 - xchg di,ax 4.170 - sub al, 82h 4.171 - mov [80h],al 4.172 - 4.173 - mov ax,offset linld 4.174 - call iso_open 4.175 - jc jc_abort 4.176 - mov cx,[word _isostate.filesize] 4.177 - mov dx,100h 4.178 - jmp near unfold 4.179 - 4.180 -patchlp: 4.181 - mov si,[_isostate.filename] 4.182 - mov di,offset rootfs 4.183 - mov cx,9 4.184 - rep 4.185 - cmpsb 4.186 - jcxz found 4.187 - cmp cl,3 4.188 - ja patchtest 4.189 - dec si 4.190 - cmp dl,[si] 4.191 - ja patchtest 4.192 - mov dl,[si] 4.193 - jmp patchtest 4.194 - 4.195 -stopmsg: 4.196 - db "This program cannot be run in DOS mode$" 4.197 -bootdir: 4.198 - db "/boot",0 4.199 -linld: 4.200 - db "linld.com",0 4.201 -cmdline: 4.202 - db "-f " 4.203 - ;db "image=\boot\" 4.204 - ;db "bzImage " 4.205 - db "initrd=" 4.206 -rootfs: 4.207 - db "rootfs" 4.208 -dotgz: 4.209 - db ".gz,! " 4.210 - ; ".gz,rootfs4.gz,! " 4.211 - ;db "rw " 4.212 - db "autologin rdinit=/init.exe " 4.213 - ;db "mode=menu " 4.214 - db "magic=" 4.215 -magic: 4.216 - db "0 bootfrom=" 4.217 - ; "65535 bootfrom=" 4.218 -filename: 4.219 - 4.220 - 4.221 -;*************************************************************** 4.222 + extrn _isostate 4.223 + dw _isostate 4.224 4.225 ends _TEXT 4.226
5.1 --- a/linld/stuff/src/pipehole.awk Fri Jun 19 11:08:54 2020 -0400 5.2 +++ b/linld/stuff/src/pipehole.awk Fri Jun 19 15:46:21 2020 +0000 5.3 @@ -203,6 +203,19 @@ 5.4 } 5.5 } # file == "load.cpp" 5.6 if (file == "iso9660.cpp") { 5.7 + if (/curpos >= SECT/) isiso=10 5.8 + if (isiso == 10) { # ISO9660.LST 5.9 + if (/cmp/) { 5.10 + sub(/cmp /,"mov bx,") 5.11 + sub(/i.*/,"i]") 5.12 + print 5.13 + $0=" cmp bh,2048/256" 5.14 + } 5.15 + if (/mov/) { 5.16 + isiso=0 5.17 + next 5.18 + } 5.19 + } 5.20 if (/<< SECTORBITS/) isiso=9 5.21 if (isiso == 9) { # ISO9660.LST 5.22 if (/dx,/) next
6.1 --- a/syslinux/stuff/iso2exe/bootiso.S Fri Jun 19 11:08:54 2020 -0400 6.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Fri Jun 19 15:46:21 2020 +0000 6.3 @@ -77,7 +77,7 @@ 6.4 call readsectorX // read isolinux boot sector 6.5 cmpw (%bx), %cx 6.6 jnc puts // read fail or no isohydrid boot sector 6.7 - movw $patch,%si 6.8 + call bootpartition // assume DS=SS SI=BX=7C00 CX=0100 DL=<drive> DI=table+66 6.9 popw %es 6.10 popw %di // isolinux boot needs %es:%di and %dx 6.11 putsret: 6.12 @@ -102,10 +102,37 @@ 6.13 nobsmsg: 6.14 .asciz "No isolinux." 6.15 6.16 - .org 0x0080 6.17 + .org 0x0080,0xEE 6.18 ////////////////////////////// EXE/PE header ////////////////////////////////// 6.19 + .org 0x0178,0xFF 6.20 +////////////////////////// partition boot code //////////////////////////////// 6.21 +// assume DS=SS SI=BX=7C00 CX=0100 DL=<drive> DI=table+66 6.22 6.23 - .org 0x01A0 6.24 +bootpartition: 6.25 + movw $4,%cx 6.26 + movw $16,%ax 6.27 +next: 6.28 + subw %ax,%di 6.29 + cmpb %ch,-2(%di) // boot flag ? 6.30 + loope next 6.31 + cmpw $63,2-2(%di) // empty or isolinux partition ? 6.32 + jbe default 6.33 + .arch i486 6.34 + pushl $0 6.35 + pushl 8-2(%di) 6.36 + pushw %cs 6.37 + pushw %bx 6.38 + pushw $1 6.39 + pushw %ax 6.40 + movw %sp,%si // assume %ds = %ss 6.41 + movb $0x42,%ah 6.42 + int $0x13 6.43 + add $16,%sp 6.44 + .arch i8086 6.45 +default: 6.46 + ret 6.47 + 6.48 + .org 0x01A0,0xFF 6.49 readsectorX: // read isolinux boot sector 6.50 movb $0xA5, %cl // patched by installer 6.51 readsector1: 6.52 @@ -120,182 +147,239 @@ 6.53 movw $0x0100, %cx 6.54 movb $nobsmsg, %al 6.55 ret 6.56 - .org 0x01B8 6.57 + .org 0x01B8,0xEE // partition table 6.58 6.59 -////////////////////////// partition boot code //////////////////////////////// 6.60 -// assume DS=SS BX=7C00 CH=01 DL=<drive> SI=7DBE 6.61 + .org 0x0270,0xFF 6.62 6.63 - .org 0x7C00 6.64 - jmp bootpartition 6.65 - .org 0x7C03 6.66 - .org 0x7DBE 6.67 -table = moved+0x1BE 6.68 -patch: 6.69 - .byte 0,0,0 // head of original bs 6.70 -partcode: 6.71 - popw %si 6.72 - xchgw %si,%di 6.73 - call movepartition 6.74 - pushw %cx 6.75 - pushw %cx 6.76 - decw %di 6.77 - decw %di 6.78 - movb $4,%cl 6.79 - movw $16,%ax 6.80 -next: 6.81 - subw %ax,%di 6.82 - cmpb %ch,(%di) // boot flag ? 6.83 - loope next 6.84 - pushw 10(%di) 6.85 - pushw 8(%di) 6.86 - pushw %cs 6.87 - pushw %bx 6.88 - movb $1,%cl 6.89 - pushw %cx 6.90 - pushw %ax 6.91 - movw %sp,%si // assume %ds = %ss 6.92 - pushw %bx 6.93 - cmpw $63,2(%di) // empty or isolinux partition ? 6.94 - jbe default 6.95 - movb $0x42,%ah 6.96 - int $0x13 6.97 -default: 6.98 - ret 6.99 - .org 0x7DF0 6.100 -bootpartition: 6.101 - pushw %ds 6.102 - popw %es 6.103 - pushw %si 6.104 - movw %bx,%di 6.105 - movsw 6.106 - movsb 6.107 - movw $table-0x142,%di 6.108 - pushw %di 6.109 -movepartition: 6.110 - movb $66,%cl // 0142 and 0042 6.111 - rep 6.112 - movsb 6.113 - ret 6.114 - .org 0x7E00 6.115 - .org 0x7F40 6.116 ////////////////////////////// DOS EXE code /////////////////////////////////// 6.117 6.118 +bootdir: 6.119 + .asciz "/boot" 6.120 +linld: 6.121 + .asciz "linld.com" 6.122 +cmdline: 6.123 + .ascii "-f " 6.124 +// .ascii "image=\boot\" 6.125 +// .ascii "bzImage " 6.126 + .ascii "initrd=" 6.127 +rootfs: 6.128 + .ascii "rootfs" 6.129 +dotgz: 6.130 + .ascii ".gz,! " 6.131 +// .ascii ".gz,rootfs4.gz,! " 6.132 +args: 6.133 +// .ascii " rw " 6.134 +// .ascii " mode=menu" 6.135 + .ascii " autologin rdinit=/init.exe magic=" 6.136 +magicstr: 6.137 + .ascii "0 bootfrom=" 6.138 +// .ascii "65535 bootfrom=" 6.139 +filename: 6.140 exestart: 6.141 - movw 129, %ax 6.142 - cmpb $0x2F, %al 6.143 - je ishelp 6.144 - cmpw $0x2F20, %ax 6.145 -ishelp: 6.146 - movw $0x3000+EXESTR(help), %ax 6.147 - cwd // clear dx 6.148 - pushw %dx // dos exit() 6.149 - je abort 6.150 - int $0x21 // get DOS version 6.151 - addb $-3, %al 6.152 - movb $EXESTR(noDOS3), %al 6.153 - movw $0x100, %di 6.154 - jc tst386 6.155 -abort: 6.156 -goputs: 6.157 - mov $EXEADRS(puts), %si 6.158 - jmp *%si 6.159 + movb $0x30,%ah // get DOS version 6.160 + int $0x21 6.161 + cmpb $3,%al 6.162 + jc goabort 6.163 6.164 -tst386: 6.165 - pushw %sp 6.166 - popw %ax 6.167 - xorw %sp, %ax // clear C 6.168 - movb $EXESTR(vm86modemsg), %al 6.169 - jnz is86 // 86/186 not a 286+ 6.170 - .arch i486 6.171 -is386: 6.172 - smsww %bx // not privileged 6.173 - andb $1, %bl // clear C 6.174 - jne isvm86 6.175 - movl %cr0, %ebx // privileged 6.176 - incl %ebx 6.177 - .arch i8086 6.178 - movb $EXESTR(rmPaging), %al 6.179 - js abort 6.180 -is86: 6.181 - incw %ax 6.182 - //movb $EXESTR(realmodemsg), %al 6.183 -isvm86: 6.184 - call goputs 6.185 -//---------- 6.186 - pushw %di 6.187 -//------------- insert argv[0] in cmdline ----------------------- 6.188 - xchgw %ax,%dx // %ax = 0 6.189 + cld 6.190 + movw EXEADRS(comstart),%si 6.191 + movw $0xF000,%di 6.192 + movb $4,%ch // 2k min 6.193 + rep 6.194 + movsw // helper 6.195 + movw $129,%si 6.196 + leaw args-cmdline(%si),%di 6.197 + movb -1(%si),%cl 6.198 + pushw %si 6.199 + rep 6.200 + movsb // user args 6.201 + xchgw %ax,%di 6.202 + popw %di 6.203 + movw $EXEADRS(cmdline),%si 6.204 + movb $args-cmdline,%cl 6.205 + rep 6.206 + movsb // files 6.207 + xchgw %ax,%di 6.208 + movb $filename-args,%cl 6.209 + rep 6.210 + movsb // end 6.211 + pushw %di // filename 6.212 + 6.213 +#define ISOSTATE 0xF000 6.214 +#define ISO_OPEN iso_open 6.215 +#define ISO_READDIR *0xF004 6.216 +#define ISO_READMENU iso_readmenu 6.217 +#define RUN_LINLD run_linld 6.218 + movw ISOSTATE,%bp 6.219 + xorw %ax,%ax 6.220 + movw %bp,%di 6.221 + movb $64,%cl 6.222 + rep 6.223 + stosb // clear BSS 6.224 + 6.225 movw %ax,%di 6.226 movw 0x2C(%di),%es 6.227 - movw %sp,%cx // big enough 6.228 + decw %cx 6.229 scalp: 6.230 repne 6.231 scasb 6.232 scasb 6.233 jne scalp 6.234 - incw %di 6.235 - movw %di,%bx 6.236 - incw %di 6.237 - pushw %di // %es:%di = programme pathname 6.238 - repne 6.239 - scasb 6.240 - subw %di,%bx 6.241 - notw %bx 6.242 - movw $128,%si 6.243 - addw %bx,(%si) 6.244 - lodsb 6.245 - xchgw %ax,%cx 6.246 + scasw 6.247 + movw %di,%si // %es:%di = programme pathname 6.248 + 6.249 + pushw %es 6.250 + pushw %ds 6.251 + popw %es 6.252 + popw %ds 6.253 + popw %di // filename 6.254 + pushw %di 6.255 + movb $0x60,%ah // canonicalize filename 6.256 + int $0x21 6.257 + pushw %es 6.258 + popw %ds 6.259 +#define LONG_FILENAME 6.260 +#ifdef LONG_FILENAME 6.261 + popw %si 6.262 + pushw %si 6.263 + movw $0x716C,%ax 6.264 + xorw %bx,%bx // R/O 6.265 + xorw %cx,%cx // attributes 6.266 + cwd // action = open 6.267 + stc 6.268 + int $0x21 6.269 + jnc opened 6.270 +#endif 6.271 + popw %dx 6.272 + pushw %dx 6.273 + movw $0x3D00,%ax 6.274 +// movb $0,%cl 6.275 + int $0x21 6.276 +goabort: 6.277 + jc abort 6.278 +opened: 6.279 + movw %ax,4(%bp) // fd 6.280 + 6.281 + call ISO_READMENU 6.282 + movw 6(%bp),%ax // magic = filemod 6.283 + popw %bx 6.284 + leaw magicstr-filename(%bx),%di 6.285 + movb $10,%bl 6.286 + xorw %cx,%cx 6.287 +lp1: 6.288 + xorw %dx,%dx 6.289 + divw %bx 6.290 + pushw %dx 6.291 incw %cx 6.292 + orw %ax,%ax 6.293 + jnz lp1 6.294 +lp2: 6.295 + popw %ax 6.296 + addb $'0',%al 6.297 + stosb // store magic 6.298 + loop lp2 6.299 + 6.300 + movw $EXEADRS(bootdir),%ax 6.301 + call ISO_OPEN 6.302 + orw $-1,18(%bp) // curdirsize = -1 6.303 + xorw %ax,%ax 6.304 +found: 6.305 + incb %ah 6.306 +patchtest: 6.307 + pushw %ax 6.308 + call ISO_READDIR 6.309 + pushw %ds 6.310 + popw %es 6.311 + incw %ax 6.312 + popw %ax 6.313 + movw $EXEADRS(rootfs),%si 6.314 + je dopatch 6.315 + movw %si,%di 6.316 + movw 16(%bp),%si // filename 6.317 + movw $9,%cx 6.318 + rep 6.319 + cmpsb 6.320 + jcxz found 6.321 + cmpb $3,%cl 6.322 + ja patchtest 6.323 + decw %si 6.324 + cmpb (%si),%al 6.325 + ja patchtest 6.326 + lodsb 6.327 + jmp patchtest 6.328 +done: 6.329 + movw $128,%ax 6.330 + subw %ax,%si 6.331 + xchgw %ax,%si 6.332 + decw %ax 6.333 + movb %al,(%si) // cmdline length 6.334 + 6.335 + movw $EXEADRS(linld),%ax 6.336 + call ISO_OPEN 6.337 + jc abort 6.338 + movw 12(%bp),%cx // filesize 6.339 + movw $0x100,%dx 6.340 + call RUN_LINLD 6.341 +abort: 6.342 + movw $EXEADRS(stopmsg),%dx 6.343 + movb $9,%ah 6.344 + int $0x21 6.345 + int $0x20 6.346 +dopatch: 6.347 pushw %si 6.348 -p2lp: 6.349 + cmpw $0x200,%ax 6.350 + je initrddone 6.351 + movw $EXEADRS(dotgz),%di 6.352 + decb %ah 6.353 + je modify 6.354 + scasw 6.355 + scasw // addw $4,%di 6.356 + movsw 6.357 + movsw 6.358 + movsw 6.359 +modify: 6.360 + stosb 6.361 + movw $129+dotgz-cmdline,%si 6.362 + movsb 6.363 + movsw 6.364 + movsw 6.365 +initrddone: 6.366 + movw $129+rootfs-cmdline,%di 6.367 + popw %si 6.368 + movw $args-rootfs,%cx 6.369 + rep 6.370 + movsb 6.371 + 6.372 +shrink0: 6.373 + movw $129,%si 6.374 +shrink: 6.375 + movw %si,%di 6.376 lodsb 6.377 - movb %al,-2(%bx,%si) 6.378 - loop p2lp 6.379 - popw %si 6.380 - popw %bx 6.381 - movb $0x20,%al 6.382 -p1lp: 6.383 - movb %al,(%si) 6.384 - incw %si 6.385 - movb %es:(%bx),%al 6.386 - incw %bx 6.387 - cmpw %bx,%di 6.388 - ja p1lp 6.389 -//---------- 6.390 - popw %di 6.391 - pushw %cs 6.392 - popw %es 6.393 -//---------- 6.394 - movw comstart-end_header(%di), %si // .com address 6.395 - pushw %di 6.396 - movb $0x7C/2, %ch // 31K-31.5K, > com length 6.397 - movb $0x80, %bh 6.398 - movw $0xA5F3, (%bx) // rep movsw 6.399 - movb $0xC3, 2(%bx) // ret 6.400 - jmp *%bx 6.401 + cmpb $0,%al 6.402 + je done 6.403 + cmpb $' ',%al 6.404 + jne shrink 6.405 + cmpb (%si),%al 6.406 + jne shrink 6.407 +pack: 6.408 + lodsb 6.409 + stosb 6.410 + cmpb $0,%al 6.411 + jne pack 6.412 + jmp shrink0 6.413 + 6.414 + .org 0x0400,0xEE 6.415 + .org 0x0600,0xFF 6.416 + .org 0x0750,0xBB 6.417 +stopmsg: 6.418 + .ascii "This program cannot be run in DOS mode.$" 6.419 + .org 0x0778,0xEE 6.420 + .org 0xF002-0xC0 6.421 +iso_open: 6.422 + .word 0 6.423 + .word 0 6.424 +iso_readmenu: 6.425 + .word 0 6.426 +run_linld: 6.427 6.428 -vm86modemsg: 6.429 -// --------------- Must be in 7F40 7FFF range ------------------------ 6.430 - .ascii "v" // v86 mode 6.431 - .ascii "86" // 86 mode 6.432 - .byte EXESTR(mode) 6.433 -rmPaging: 6.434 - .ascii "X" // Xreal mode 6.435 -realmodemsg: 6.436 - .ascii "real" // real mode 6.437 -// --------------- Must be in 7FC0 7FFF range ------------------------ 6.438 -mode: 6.439 - .ascii " mode" 6.440 - .byte EXESTR(eol) 6.441 -noDOS3: 6.442 - .ascii "DOS3?" // DOS3? 6.443 - .byte EXESTR(eol) 6.444 -help: 6.445 - .ascii "SliTaz iso boot" // SliTaz iso boot 6.446 -eol: 6.447 - .ascii "\r\n" 6.448 - .byte 1 // puts will return 6.449 - 6.450 - .space 16,0 // ISO md5 6.451 - .org 0x8000 6.452 -////////////////////////// ISO9660 header ///////////////////////////////////// 6.453 + .end
7.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jun 19 11:08:54 2020 -0400 7.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Fri Jun 19 15:46:21 2020 +0000 7.3 @@ -79,7 +79,7 @@ 7.4 add_win32exe() 7.5 { 7.6 SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c) 7.7 - [ -n "$gpt" ] && n=1536 || n=512 7.8 + n=1536 7.9 SIZE=$(($SIZE+$n)) 7.10 printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE 7.11 [ -n "$gpt" ] && printf "Adding GPT at %04X (1024 bytes) ...\n" 512 7.12 @@ -93,25 +93,20 @@ 7.13 ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$(($n+$cut)) 7.14 printf "Adding bootiso head at %04X...\n" 0 7.15 $0 --get bootiso.bin 2> /dev/null > /tmp/exe$$ 7.16 - x=$(($(get 0x14 /tmp/exe$$ 1)+0x40)) 7.17 - printf "Adding bootiso DOS stub at %04X...\n" $(($n+$x)) 7.18 - ddn if=/tmp/exe$$ of=$1 bs=1 seek=$(($n+$x)) skip=$((0x7F00+$x)) count=$((256-$x)) 7.19 - x=$(($n/256+1)) 7.20 - store $((0x15)) $x /tmp/exe$$ 8 ### exe IP 7.21 - store $((0x6c)) $x /tmp/exe$$ 8 ### puts data 7.22 - ddn if=/tmp/exe$$ of=$1 bs=128 count=1 ### DOS header 7.23 - ddn if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) 7.24 - ddn if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 7.25 store 510 $((0xAA55)) $1 7.26 - i=$SIZE; OFS=$(($SIZE+512)) 7.27 - store 417 $(($i/512)) $1 8 ### isolinux boot sector 7.28 - printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $i 7.29 - ddn if=$2 bs=1 count=512 of=$1 seek=$i 7.30 - if [ $(get $((0x7C00)) /tmp/exe$$) -eq 60905 ]; then # partition boot code 7.31 - ddn if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) 7.32 - ddn if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) 7.33 - ddn if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i 7.34 - fi 7.35 + while read adrs sz; do 7.36 + ddn if=/tmp/exe$$ of=$1 bs=1 count=$((0x$sz)) seek=$((0x$adrs)) skip=$((0x$adrs)) 7.37 + done <<EOT 7.38 +0000 0080 7.39 +0178 0040 7.40 +0270 0190 7.41 +0750 0028 7.42 +EOT 7.43 + i=$((0x600)) 7.44 + store 417 $(($i/512)) $1 8 ### isolinux boot sector 7.45 + printf "Moving syslinux hybrid boot record at %04X (336 bytes) ...\n" $i 7.46 + OFS=$SIZE 7.47 + ddn if=$2 bs=1 count=336 of=$1 seek=$i 7.48 rm -f /tmp/exe$$ /tmp/coff$$ 7.49 if [ -z "$RECURSIVE_PARTITION" -a $(get 454 $1 4) -eq 0 ]; then 7.50 store 448 $((1+$i/512)) $1 8 ### 446+2 SECTOR 7.51 @@ -159,8 +154,8 @@ 7.52 SIZE=0; OFFSET=0 7.53 case "$1" in 7.54 win32.exe) [ $x -eq 2048 ] && x=10752 7.55 - [ $x -eq 1024 ] || SIZE=$(($x - 512));; 7.56 - syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$(($x - 512)); SIZE=512;; 7.57 + [ $x -eq 1024 ] || SIZE=$x;; 7.58 + syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$(($x - 512)); SIZE=336;; 7.59 flavor.info) [ $(get 22528 "$ISO") -eq 35615 ] && OFFSET=22528 7.60 [ $x -eq 2048 ] && x=$(get 0x25C "$ISO") && 7.61 SIZE=$(get 0x25E "$ISO") 7.62 @@ -308,6 +303,8 @@ 7.63 find $TMP -type f -print0 | xargs -0 chmod +x 7.64 find $TMP -print0 | xargs -0 touch -t 197001010100.00 7.65 ( cd $TMP; find dev init.exe | cpio -o -H newc ) | compress > rootfs.gz 7.66 + p=$((4-($(stat -c %s rootfs.gz)%4))) 7.67 + [ $p = 4 ] || dd if=/dev/zero bs=1 count=$p >> rootfs.gz 7.68 rm -rf $TMP 7.69 chmod 644 ${@/init/rootfs.gz} 7.70 chown root.root ${@/init/rootfs.gz}