wok-6.x view syslinux/stuff/iso2exe/bootiso.S @ rev 18775

syslinux/isohybrid.exe: add -a & -i support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 01 10:53:50 2016 +0100 (2016-01-01)
parents 6a2e6eb35735
children 73cdd2cf47c4
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 fdcnt: // Overlay number
28 .byte 0 // Bootstrap floppy sector count
29 .ascii "slitaz"
31 /////////////////////// Master Boot Record code //////////////////////////////
33 moved = 0x8000
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, $moved+start2
53 .byte 0
54 // .org 60
55 // .long 0x0080 // PE header offset
56 .org 64
57 end_header:
58 comstart:
59 .word 0
61 .org 66
62 dxloop:
63 start2:
64 call readsector1 // look for the boot device
65 repe
66 cmpsw
67 je dxfound
68 movb $0, %cl // ch = 0
69 addb $0x7D, %dl // try every hard disk
70 jno dxloop
72 dxfound:
73 call readsectorX // read isolinux boot sector
74 movw %dx, 10(%bp)
75 cmpw (%bx), %cx
76 jnc puts // read fail or no isohydrid boot sector
77 popw %es
78 popa // isolinux boot needs %es:%di and %dx
79 putsret:
80 ret
82 putstrlp:
83 movw $7, %bx
84 movb $0xE, %ah
85 int $0x10
86 error:
87 lodsb
88 cmp $1, %al
89 jg putstrlp
90 jz putsret
91 puts:
92 movb $0x80, %ah
93 xchgw %ax, %si
94 jnc error
95 halt:
96 hlt
97 jmp halt
98 nobsmsg:
99 .asciz "No isolinux."
101 .org 0x0080
102 ////////////////////////////// EXE/PE header //////////////////////////////////
104 .org 0x01A0
105 readsectorX: // read isolinux boot sector
106 movb $0xA5, %cl // patched by installer
107 readsector1:
108 andb $0x83, %dl // disk and floppy disk
109 movw %cx, (%bx)
110 incw %cx
111 movw $0x201, %ax
112 int $0x13
113 setreg:
114 movw %bx, %si
115 movw $moved, %di
116 movw $0x0100, %cx
117 movb $nobsmsg, %al
118 ret
119 .org 0x01B8
121 .org 0x7F48
122 ////////////////////////////// DOS EXE code ///////////////////////////////////
124 exestart:
125 cld
126 movw 129, %ax
127 cmpb $0x2F, %al
128 je ishelp
129 cmpw $0x2F20, %ax
130 ishelp:
131 movw $0x3000+EXESTR(help), %ax
132 cwd // clear dx
133 pushw %dx // dos exit()
134 je abort
135 int $0x21 // get DOS version
136 addb $-3, %al
137 movw $0x1000+EXESTR(noDOS3), %ax
138 jc tst386
139 abort:
140 jmp puts
142 tst386:
143 pushfw // save flags
144 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
145 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
146 // movb $0x10, %ah
147 pushw %ax
148 popfw // < 286 : flags[12..15] are forced 1
149 pushfw // = 286 : flags[12..15] are forced 0
150 popw %bx // > 286 : only flags[15] is forced 0
151 popfw // restore flags (IOPL)
152 addb %ah, %bh // test F0 and 00 cases
153 cmpb %ah, %bh
154 movw $0x100, %di
155 jbe is86 // C=8086/80186, Z=80286
156 is386:
157 smsww %ax // not privileged
158 andb $1, %al
159 movw $10, %si
160 jne tstvcpi
161 movl %cr0, %eax // privileged
162 incl %eax
163 movb $EXESTR(rmPaging), %al
164 js abort
165 inc %ax
166 //movb $EXESTR(realmodemsg), %al
167 realmode:
168 call puts
169 is86:
170 movw comstart-end_header(%di), %si // .com address
171 pushw %di
172 movb $0x7C/2, %ch // 31K-31.5K, > com length
173 rep
174 movsw
175 ret
177 VersionVCPI:
178 xchgw %ax, %si // movb $EXESTR(vm86modemsg), %al
179 cmpb $0x40, %cl // EMM386 / VCPI 4.0 mini
180 jnc realmode // %si = 0
181 tstvcpi:
182 pushw %ds
183 movw %si, %ds // %si = 10
184 movw (0x67*4)+2-(16*10)-0x100(%di), %ds
185 lodsw
186 xorw $0x4D45, %ax // EM(MX) or EM(MQ)
187 lodsw
188 lodsw
189 popw %ds
190 jne NoVCPI
191 xorw $0x5858, %ax // XX(X0)
192 movw $EXEADRS(CmdVCPI), %si
193 ChkVCPI:
194 NoVCPI:
195 movb $EXESTR(ERRvcpi), %al
196 jne abort
197 lodsb
198 shlw $8, %ax
199 je VersionVCPI
200 int $0x67
201 testb %ah, %ah
202 xchgw %ax, %cx
203 jmp ChkVCPI
204 CmdVCPI:
205 .byte 0x40 // status
206 .byte 0xDE // vcpi present ?
207 .byte 0x46 // version
208 .byte 0
210 vm86modemsg:
211 // --------------- Must be in 7F40 7FFF range ------------------------
212 .ascii "86" // 86 mode
213 .byte EXESTR(mode)
214 ERRvcpi:
215 .ascii "VCPI4" // VCPI4?
216 .byte EXESTR(need)
217 rmPaging:
218 .ascii "X" // Xreal mode
219 realmodemsg:
220 .ascii "real" // real mode
221 // --------------- Must be in 7FC0 7FFF range ------------------------
222 mode:
223 .ascii " m"
224 ode:
225 .ascii "ode"
226 .byte EXESTR(eol)
227 noDOS3:
228 .ascii "DOS3" // DOS3?
229 need:
230 .ascii "?"
231 .byte EXESTR(eol)
232 help:
233 .ascii "SliTaz iso boot" // SliTaz iso boot
234 eol:
235 .ascii "\r\n"
236 .byte 1 // puts will return
238 .space 16,0 // ISO md5
239 .org 0x8000
240 ////////////////////////// ISO9660 header /////////////////////////////////////