wok-next diff syslinux/stuff/iso2exe/bootiso.S @ rev 20197
syslinux: updates from rolling
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Nov 03 15:07:20 2017 +0100 (2017-11-03) |
parents | 7a16da2c93b9 |
children |
line diff
1.1 --- a/syslinux/stuff/iso2exe/bootiso.S Tue Oct 04 15:33:49 2016 +0200 1.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Fri Nov 03 15:07:20 2017 +0100 1.3 @@ -1,5 +1,6 @@ 1.4 .text 1.5 .code16 1.6 + .arch i8086 1.7 .org 0 1.8 1.9 CODESZ = 0x8000 // 16 sectors = 32Kb 1.10 @@ -19,6 +20,7 @@ 1.11 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed 1.12 .word 0xFFF0 // Initial (relative) SS value 1.13 .word 0xFFFE // Initial SP value 1.14 +magic: 1.15 .word 0 // Checksum 1.16 .word EXEADRS(exestart) // Initial IP value 1.17 .word 0xFFF0 // Initial (relative) CS value 1.18 @@ -32,14 +34,16 @@ 1.19 1.20 moved = 0x8000 1.21 start0: 1.22 - pushw %dx // restore %sp 1.23 - incw %bp // restore %bp 1.24 + //pushw %dx // restore %sp 1.25 + //incw %bp // restore %bp 1.26 xorw %bx, %bx 1.27 movw %bx, %ds 1.28 movb $0x7C, %bh 1.29 + pushw %ds 1.30 + popw %ss 1.31 + movw %bx, %sp 1.32 pushw %bx // return address 1.33 - pushaw 1.34 - movw %sp, %bp 1.35 + pushw %di 1.36 pushw %es // save %es:%di 1.37 cld 1.38 sti 1.39 @@ -47,7 +51,7 @@ 1.40 popw %es 1.41 call setreg 1.42 rep 1.43 - movsw 1.44 + movsw 1.45 movw $0x80, %dx 1.46 ljmp $0, $moved+start2 1.47 .byte 0 1.48 @@ -71,11 +75,11 @@ 1.49 1.50 dxfound: 1.51 call readsectorX // read isolinux boot sector 1.52 - movw %dx, 10(%bp) 1.53 cmpw (%bx), %cx 1.54 jnc puts // read fail or no isohydrid boot sector 1.55 + movw $patch,%si 1.56 popw %es 1.57 - popa // isolinux boot needs %es:%di and %dx 1.58 + popw %di // isolinux boot needs %es:%di and %dx 1.59 putsret: 1.60 ret 1.61 1.62 @@ -118,12 +122,67 @@ 1.63 ret 1.64 .org 0x01B8 1.65 1.66 - .org 0x7F48 1.67 +////////////////////////// partition boot code //////////////////////////////// 1.68 +// assume DS=SS BX=7C00 CH=01 DL=<drive> SI=7DBE 1.69 + 1.70 + .org 0x7C00 1.71 + jmp bootpartition 1.72 + .org 0x7C03 1.73 + .org 0x7DBE 1.74 +table = moved+0x1BE 1.75 +patch: 1.76 + .byte 0,0,0 // head of original bs 1.77 +partcode: 1.78 + popw %si 1.79 + xchgw %si,%di 1.80 + call movepartition 1.81 + pushw %cx 1.82 + pushw %cx 1.83 + decw %di 1.84 + decw %di 1.85 + movb $4,%cl 1.86 + movw $16,%ax 1.87 +next: 1.88 + subw %ax,%di 1.89 + cmpb %ch,(%di) // boot flag ? 1.90 + loope next 1.91 + pushw 10(%di) 1.92 + pushw 8(%di) 1.93 + pushw %cs 1.94 + pushw %bx 1.95 + movb $1,%cl 1.96 + pushw %cx 1.97 + pushw %ax 1.98 + movw %sp,%si // assume %ds = %ss 1.99 + pushw %bx 1.100 + cmpw $63,2(%di) // empty or isolinux partition ? 1.101 + jbe default 1.102 + movb $0x42,%ah 1.103 + int $0x13 1.104 +default: 1.105 + ret 1.106 + .org 0x7DF0 1.107 +bootpartition: 1.108 + pushw %ds 1.109 + popw %es 1.110 + pushw %si 1.111 + movw %bx,%di 1.112 + movsw 1.113 + movsb 1.114 + movw $table-0x142,%di 1.115 + pushw %di 1.116 +movepartition: 1.117 + movb $66,%cl // 0142 and 0042 1.118 + rep 1.119 + movsb 1.120 + ret 1.121 + .org 0x7E00 1.122 + 1.123 + .org 0x7F83 1.124 ////////////////////////////// DOS EXE code /////////////////////////////////// 1.125 1.126 exestart: 1.127 cld 1.128 - movw $EXEADRS(puts), %bp 1.129 movw 129, %ax 1.130 cmpb $0x2F, %al 1.131 je ishelp 1.132 @@ -135,38 +194,34 @@ 1.133 je abort 1.134 int $0x21 // get DOS version 1.135 addb $-3, %al 1.136 - movw $0xF000+EXESTR(noDOS3), %ax 1.137 + movb $EXESTR(noDOS3), %al 1.138 movw $0x100, %di 1.139 jc tst386 1.140 abort: 1.141 - jmp *%bp 1.142 +goputs: 1.143 + jmp puts 1.144 1.145 tst386: 1.146 - pushfw // save flags 1.147 - // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1.148 - // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF 1.149 - // movb $0xF0, %ah 1.150 - pushw %ax 1.151 - popfw // < 286 : flags[12..15] are forced 1 1.152 - pushfw // = 286 : flags[12..15] are forced 0 1.153 - popw %bx // > 286 : only flags[15] is forced 0 1.154 - popfw // restore flags (IOPL) 1.155 - addb %ah, %bh // test F0 and 00 cases 1.156 - js is86 // NS=386+, NC=286 1.157 + pushw %sp 1.158 + popw %ax 1.159 + xorw %sp, %ax // clear C 1.160 + movb $EXESTR(vm86modemsg), %al 1.161 + jnz is86 // 86/186 not a 286+ 1.162 + .arch i486 1.163 is386: 1.164 - smsww %ax // not privileged 1.165 - andb $1, %al 1.166 - movw $10, %si 1.167 - jne tstvcpi 1.168 - movl %cr0, %eax // privileged 1.169 - incl %eax 1.170 + smsww %bx // not privileged 1.171 + andb $1, %bl // clear C 1.172 + jne isvm86 1.173 + movl %cr0, %ebx // privileged 1.174 + incl %ebx 1.175 + .arch i8086 1.176 movb $EXESTR(rmPaging), %al 1.177 js abort 1.178 - inc %ax 1.179 +is86: 1.180 + incw %ax 1.181 //movb $EXESTR(realmodemsg), %al 1.182 -realmode: 1.183 - call *%bp 1.184 -is86: 1.185 +isvm86: 1.186 + call goputs 1.187 movw comstart-end_header(%di), %si // .com address 1.188 pushw %di 1.189 movb $0x7C/2, %ch // 31K-31.5K, > com length 1.190 @@ -174,49 +229,11 @@ 1.191 movsw 1.192 ret 1.193 1.194 -CallVCPI: 1.195 - int $0x67 1.196 - testb %ah, %ah 1.197 - xchgw %ax, %cx 1.198 - pushw %si 1.199 -ScanVCPI: 1.200 - popw %si 1.201 -ChkVCPI: 1.202 -NoVCPI: 1.203 - movb $EXESTR(ERRvcpi), %al 1.204 - jne abort 1.205 - lodsb 1.206 - shlw $8, %ax 1.207 - jne CallVCPI 1.208 -VersionVCPI: 1.209 - xchgw %ax, %si // movb $EXESTR(vm86modemsg), %al 1.210 - cmpb $0x40, %cl // EMM386 / VCPI 4.0 mini 1.211 - jnc realmode // %si = 0 1.212 -tstvcpi: 1.213 - pushw %ds 1.214 - movw %si, %ds // %si = 10 1.215 - movw (0x67*4)+2-(16*10)-0x100(%di), %ds 1.216 - lodsw 1.217 - xorw $0x4D45, %ax // EM(MX) or EM(MQ) 1.218 - lodsw 1.219 - lodsw 1.220 - popw %ds 1.221 - jne NoVCPI 1.222 - xorw $0x5858, %ax // XX(X0) 1.223 - call ScanVCPI 1.224 -CmdVCPI: 1.225 - .byte 0x40 // status 1.226 - .byte 0xDE // vcpi present ? 1.227 - .byte 0x46 // version 1.228 - .byte 0 1.229 - 1.230 vm86modemsg: 1.231 // --------------- Must be in 7F40 7FFF range ------------------------ 1.232 + .ascii "v" // v86 mode 1.233 .ascii "86" // 86 mode 1.234 .byte EXESTR(mode) 1.235 -ERRvcpi: 1.236 - .ascii "VCPI4" // VCPI4? 1.237 - .byte EXESTR(need) 1.238 rmPaging: 1.239 .ascii "X" // Xreal mode 1.240 realmodemsg: