wok view syslinux/stuff/iso2exe/bootiso.S @ rev 17496

syslinux/iso2exe: check ISO md5 (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jan 05 12:38:18 2015 +0100 (2015-01-05)
parents 6aed6fc5819d
children 00bb1e4137c6
line source
1 .text
2 .code16
3 .org 0
5 CODESZ = 0x8000 // 16 sectors = 32Kb
6 #define EXEADRS(x) x+0xC0
7 #define EXELOC(x) x-0x40
8 #define EXESTR(x) x-0x7F40
10 .globl _start
11 _start:
12 decw %bp // Magic number: MZ
13 popw %dx
14 jmp start0 // Bytes on last page of file
15 .word (CODESZ+511)/512 // Pages in file
16 .word 0 // Relocations
17 .word (end_header-_start)/16 // Size of header in paragraphs
18 .word 4064-(CODESZ/16) // Minimum extra paragraphs needed
19 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed
20 .word 0xFFF0 // Initial (relative) SS value
21 .word 0xFFFE // Initial SP value
22 .word 0 // Checksum
23 .word EXEADRS(exestart) // Initial IP value
24 .word 0xFFF0 // Initial (relative) CS value
25 initramfssize:
26 .word 0 // File address of relocation table
27 id:
28 .word 0 // Overlay number
29 fdcnt: // File address of relocation table
30 .byte 0 // Bootstrap floppy sector count
32 /////////////////////// Master Boot Record code //////////////////////////////
34 start0:
35 pushw %dx // restore %sp
36 incw %bp // restore %bp
37 xorw %bx, %bx
38 movw %bx, %ds
39 movb $0x7C, %bh
40 pushw %bx // return address
41 pushaw
42 movw %sp, %bp
43 pushw %es // save %es:%di
44 cld
45 sti
46 pushw %ds
47 popw %es
48 call setreg
49 rep
50 movsw
51 movw $0x80, %dx
52 ljmp $0, $0x0600+start2
54 .org 60
55 .long 0x0080 // PE header offset
56 end_header:
57 chksum:
58 .word 0
59 comstart:
60 .word 0
62 .org 68
63 readsectorX: // read isolinux boot sector
64 movb $0xA5, %cl // patched by installer
65 readsector1:
66 andb $0x83, %dl // disk and floppy disk
67 movw %cx, (%bx)
68 incw %cx
69 movw $0x201, %ax
70 int $0x13
71 setreg:
72 movw %bx, %si
73 movw $0x0600, %di
74 movw $0x0100, %cx
75 return:
76 ret
77 dxloop:
78 start2:
79 call readsector1 // look for the boot device
80 repe
81 cmpsw
82 je dxfound
83 movb $0, %cl // ch = 0
84 addb $0x7D, %dl // try every hard disk
85 jno dxloop
86 dxfound:
87 call readsectorX // read isolinux boot sector
88 movw %dx, 10(%bp)
89 call checkboot
90 .asciz "No isolinux bs"
92 .org 0x0080
93 ////////////////////////////// EXE/PE header //////////////////////////////////
95 .org 0x01A0
96 checkboot:
97 cmpw %cx, (%bx)
98 popw %si
99 jc error // read fail or no isohydrid boot sector
100 popw %es
101 popa
102 putsret:
103 ret
104 putstrlp:
105 movw $7, %bx
106 movb $0xE, %ah
107 int $0x10
108 error:
109 lodsb
110 cmp $1, %al
111 jg putstrlp
112 jz putsret
113 putstr:
114 movb $0x80, %ah
115 xchgw %ax, %si
116 jnc error
117 halt:
118 hlt
119 jmp halt
120 .org 0x01BE
122 .org 0x7F10
123 ////////////////////////////// DOS EXE code ///////////////////////////////////
125 exestart:
126 cld
127 movw $0x100, %si
128 movw -127(%si), %ax
129 cmpb $0x2F, %al
130 je ishelp
131 cmpw $0x2F20, %ax
132 ishelp:
133 movw $0x3000+EXESTR(help), %ax
134 cwd // clear dx
135 pushw %dx // dos exit()
136 je abort
137 int $0x21 // get DOS version
138 cmpb $3, %al
139 movb $EXESTR(noDOS3), %al
140 jb abort
141 movw $(EXELOC(0x8000))/2, %cx
142 chklp:
143 lodsw
144 addw %ax, %dx
145 loop chklp
146 chked:
147 movw $0x1000+EXESTR(chkerr), %ax
148 je tst386 // dx == 0 ?
149 abort:
150 puts:
151 clc
152 jmp putstr
154 tst386:
155 pushfw // save flags
156 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
157 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
158 // movb $0x10, %ah
159 pushw %ax
160 popfw // < 286 : flags[12..15] are forced 1
161 pushfw // = 286 : flags[12..15] are forced 0
162 popw %bx // > 286 : only flags[15] is forced 0
163 popfw // restore flags (IOPL)
164 addb %ah, %bh // test F0 and 00 cases
165 cmpb %ah, %bh
166 movb $EXESTR(no386), %al
167 #undef NEED386
168 #ifdef NEED386
169 jbe abort // C=8086/80186, Z=80286
170 #else
171 jbe is86 // C=8086/80186, Z=80286
172 #endif
173 is386:
174 smsww %ax // not privileged
175 andb $1, %al
176 jne tstvcpi
177 movl %cr0, %eax // privileged
178 incl %eax
179 movb $EXESTR(rmPaging), %al
180 js abort
181 movb $EXESTR(realmodemsg), %al
182 realmode:
183 is86:
184 call puts
185 movw $0x0100, %di
186 movw comstart-end_header(%di), %si // .com address
187 pushw %di
188 movb $0x7C/2, %ch // 31K-31.5K, > com length
189 rep
190 movsw
191 ret
193 VersionVCPI:
194 cmpb $0x40, %dl // >= 4.0 ?
195 jb NoVCPI
196 xchgw %ax, %si // movb $EXESTR(vm86modemsg), %al
197 jmp realmode
198 tstvcpi:
199 pushw %ds
200 movw %dx, %ds // %dx = 0
201 movw 0x67*4+2, %ds
202 movw $10, %si
203 lodsw
204 xorw $0x4D45, %ax // EM(MX) or EM(MQ)
205 lodsw
206 lodsw
207 popw %ds
208 jne NoVCPI
209 xorw $0x5858, %ax // XX(X0)
210 movw $EXEADRS(CmdVCPI), %si
211 ChkVCPI:
212 NoVCPI:
213 movb $EXESTR(ERRvcpi), %al
214 jne abort
215 lodsb
216 shlw $8, %ax
217 je VersionVCPI
218 int $0x67
219 testb %ah, %ah
220 xchgw %ax, %dx
221 jmp ChkVCPI
222 CmdVCPI:
223 .byte 0x40 // status
224 .byte 0xDE // vcpi present ?
225 .byte 0x46 // version
226 .byte 0
228 vm86modemsg:
229 // --------------- Must be in 7F40 7FFF range ------------------------
230 .ascii "vm" // vm86
231 .byte EXESTR(_86)
232 ERRvcpi:
233 .ascii "No VCPI-4.0/EMM" // No VCPI-4.0/EMM386
234 .byte EXESTR(_386)
235 noDOS3:
236 .ascii "No DOS 3" // No DOS 3
237 .byte EXESTR(eol)
238 chkerr:
239 .ascii "Broken c" // Broken code
240 .byte EXESTR(ode)
241 rmPaging:
242 .ascii "Un" // Unreal mode
243 realmodemsg:
244 .ascii "real m" // real mode
245 // --------------- Must be in 7FC0 7FFF range ------------------------
246 ode:
247 .ascii "od"
248 eeol:
249 .ascii "e"
250 .byte EXESTR(eol)
251 no386:
252 .ascii "No " // No 386
253 _386:
254 .ascii "3"
255 _86:
256 .ascii "86"
257 .byte EXESTR(eol)
258 help:
259 .ascii "SliTaz boot loader" // SliTaz boot loader
260 eol:
261 .ascii "\r\n"
262 .byte 1
264 .space 16,0 // ISO md5
265 .org 0x8000
266 ////////////////////////// ISO9660 header /////////////////////////////////////