rev |
line source |
pascal@13691
|
1 .text
|
pascal@13691
|
2 .code16
|
pascal@19828
|
3 .arch i8086
|
pascal@13691
|
4 .org 0
|
pascal@13691
|
5
|
pascal@13691
|
6 CODESZ = 0x8000 // 16 sectors = 32Kb
|
pascal@13972
|
7 #define EXEADRS(x) x+0xC0
|
pascal@14261
|
8 #define EXELOC(x) x-0x40
|
pascal@14261
|
9 #define EXESTR(x) x-0x7F40
|
pascal@13691
|
10
|
pascal@13691
|
11 .globl _start
|
pascal@13691
|
12 _start:
|
pascal@13691
|
13 decw %bp // Magic number: MZ
|
pascal@13691
|
14 popw %dx
|
pascal@13972
|
15 jmp start0 // Bytes on last page of file
|
pascal@13691
|
16 .word (CODESZ+511)/512 // Pages in file
|
pascal@13691
|
17 .word 0 // Relocations
|
pascal@13691
|
18 .word (end_header-_start)/16 // Size of header in paragraphs
|
pascal@13691
|
19 .word 4064-(CODESZ/16) // Minimum extra paragraphs needed
|
pascal@13691
|
20 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed
|
pascal@13691
|
21 .word 0xFFF0 // Initial (relative) SS value
|
pascal@13691
|
22 .word 0xFFFE // Initial SP value
|
pascal@13691
|
23 .word 0 // Checksum
|
pascal@13729
|
24 .word EXEADRS(exestart) // Initial IP value
|
pascal@13691
|
25 .word 0xFFF0 // Initial (relative) CS value
|
pascal@13972
|
26 initramfssize:
|
pascal@13972
|
27 .word 0 // File address of relocation table
|
pascal@17810
|
28 fdcnt: // Overlay number
|
pascal@14257
|
29 .byte 0 // Bootstrap floppy sector count
|
pascal@17810
|
30 .ascii "slitaz"
|
pascal@13691
|
31
|
pascal@13691
|
32 /////////////////////// Master Boot Record code //////////////////////////////
|
pascal@13691
|
33
|
pascal@17810
|
34 moved = 0x8000
|
pascal@17496
|
35 start0:
|
pascal@19827
|
36 //pushw %dx // restore %sp
|
pascal@19827
|
37 //incw %bp // restore %bp
|
pascal@17496
|
38 xorw %bx, %bx
|
pascal@17496
|
39 movw %bx, %ds
|
pascal@17496
|
40 movb $0x7C, %bh
|
pascal@19827
|
41 pushw %ds
|
pascal@19827
|
42 popw %ss
|
pascal@19827
|
43 movw %bx, %sp
|
pascal@17496
|
44 pushw %bx // return address
|
pascal@19827
|
45 pushw %di
|
pascal@17496
|
46 pushw %es // save %es:%di
|
pascal@13972
|
47 cld
|
pascal@17496
|
48 sti
|
pascal@13972
|
49 pushw %ds
|
pascal@13972
|
50 popw %es
|
pascal@13691
|
51 call setreg
|
pascal@13691
|
52 rep
|
pascal@19827
|
53 movsw
|
pascal@13972
|
54 movw $0x80, %dx
|
pascal@17810
|
55 ljmp $0, $moved+start2
|
pascal@17810
|
56 .byte 0
|
pascal@17810
|
57 // .org 60
|
pascal@17810
|
58 // .long 0x0080 // PE header offset
|
pascal@17810
|
59 .org 64
|
pascal@13972
|
60 end_header:
|
pascal@13972
|
61 comstart:
|
pascal@13972
|
62 .word 0
|
pascal@13691
|
63
|
pascal@17810
|
64 .org 66
|
pascal@17810
|
65 dxloop:
|
pascal@17810
|
66 start2:
|
pascal@17810
|
67 call readsector1 // look for the boot device
|
pascal@17810
|
68 repe
|
pascal@17810
|
69 cmpsw
|
pascal@17810
|
70 je dxfound
|
pascal@17810
|
71 movb $0, %cl // ch = 0
|
pascal@17810
|
72 addb $0x7D, %dl // try every hard disk
|
pascal@17810
|
73 jno dxloop
|
pascal@17810
|
74
|
pascal@17810
|
75 dxfound:
|
pascal@17810
|
76 call readsectorX // read isolinux boot sector
|
pascal@17810
|
77 cmpw (%bx), %cx
|
pascal@17810
|
78 jnc puts // read fail or no isohydrid boot sector
|
pascal@19827
|
79 movw $patch,%si
|
pascal@17810
|
80 popw %es
|
pascal@19827
|
81 popw %di // isolinux boot needs %es:%di and %dx
|
pascal@17810
|
82 putsret:
|
pascal@17810
|
83 ret
|
pascal@17810
|
84
|
pascal@17810
|
85 putstrlp:
|
pascal@17810
|
86 movw $7, %bx
|
pascal@17810
|
87 movb $0xE, %ah
|
pascal@17810
|
88 int $0x10
|
pascal@17810
|
89 error:
|
pascal@17810
|
90 lodsb
|
pascal@17810
|
91 cmp $1, %al
|
pascal@17810
|
92 jg putstrlp
|
pascal@17810
|
93 jz putsret
|
pascal@17810
|
94 puts:
|
pascal@17810
|
95 movb $0x80, %ah
|
pascal@17810
|
96 xchgw %ax, %si
|
pascal@17810
|
97 jnc error
|
pascal@17810
|
98 halt:
|
pascal@17810
|
99 hlt
|
pascal@17810
|
100 jmp halt
|
pascal@17810
|
101 nobsmsg:
|
pascal@17810
|
102 .asciz "No isolinux."
|
pascal@17810
|
103
|
pascal@17810
|
104 .org 0x0080
|
pascal@17810
|
105 ////////////////////////////// EXE/PE header //////////////////////////////////
|
pascal@17810
|
106
|
pascal@17810
|
107 .org 0x01A0
|
pascal@17496
|
108 readsectorX: // read isolinux boot sector
|
pascal@17496
|
109 movb $0xA5, %cl // patched by installer
|
pascal@13699
|
110 readsector1:
|
pascal@17496
|
111 andb $0x83, %dl // disk and floppy disk
|
pascal@13699
|
112 movw %cx, (%bx)
|
pascal@13699
|
113 incw %cx
|
pascal@13699
|
114 movw $0x201, %ax
|
pascal@13699
|
115 int $0x13
|
pascal@13691
|
116 setreg:
|
pascal@13699
|
117 movw %bx, %si
|
pascal@17810
|
118 movw $moved, %di
|
pascal@13691
|
119 movw $0x0100, %cx
|
pascal@17810
|
120 movb $nobsmsg, %al
|
pascal@13691
|
121 ret
|
pascal@17810
|
122 .org 0x01B8
|
pascal@14267
|
123
|
pascal@19827
|
124 ////////////////////////// partition boot code ////////////////////////////////
|
pascal@19842
|
125 // assume DS=SS BX=7C00 CH=01 DL=<drive> SI=7DBE
|
pascal@19827
|
126
|
pascal@19827
|
127 .org 0x7C00
|
pascal@19827
|
128 jmp bootpartition
|
pascal@19827
|
129 .org 0x7C03
|
pascal@19827
|
130 .org 0x7DBE
|
pascal@19827
|
131 table = moved+0x1BE
|
pascal@19827
|
132 patch:
|
pascal@19827
|
133 .byte 0,0,0 // head of original bs
|
pascal@19827
|
134 partcode:
|
pascal@19837
|
135 popw %si
|
pascal@19837
|
136 xchgw %si,%di
|
pascal@19827
|
137 call movepartition
|
pascal@19837
|
138 pushw %cx
|
pascal@19837
|
139 pushw %cx
|
pascal@19842
|
140 decw %di
|
pascal@19842
|
141 decw %di
|
pascal@19827
|
142 movb $4,%cl
|
pascal@19842
|
143 movw $16,%ax
|
pascal@19827
|
144 next:
|
pascal@19842
|
145 subw %ax,%di
|
pascal@19827
|
146 cmpb %ch,(%di) // boot flag ?
|
pascal@19827
|
147 loope next
|
pascal@19828
|
148 pushw 10(%di)
|
pascal@19828
|
149 pushw 8(%di)
|
pascal@19837
|
150 pushw %cs
|
pascal@19827
|
151 pushw %bx
|
pascal@19828
|
152 movb $1,%cl
|
pascal@19828
|
153 pushw %cx
|
pascal@19828
|
154 pushw %ax
|
pascal@19827
|
155 movw %sp,%si // assume %ds = %ss
|
pascal@19828
|
156 pushw %bx
|
pascal@19837
|
157 cmpw $63,2(%di) // empty or isolinux partition ?
|
pascal@19828
|
158 jbe default
|
pascal@19827
|
159 movb $0x42,%ah
|
pascal@19827
|
160 int $0x13
|
pascal@19827
|
161 default:
|
pascal@19827
|
162 ret
|
pascal@19828
|
163 .org 0x7DF0
|
pascal@19827
|
164 bootpartition:
|
pascal@19827
|
165 pushw %ds
|
pascal@19827
|
166 popw %es
|
pascal@19827
|
167 pushw %si
|
pascal@19827
|
168 movw %bx,%di
|
pascal@19827
|
169 movsw
|
pascal@19827
|
170 movsb
|
pascal@19837
|
171 movw $table-0x142,%di
|
pascal@19827
|
172 pushw %di
|
pascal@19827
|
173 movepartition:
|
pascal@19828
|
174 movb $66,%cl // 0142 and 0042
|
pascal@19827
|
175 rep
|
pascal@19828
|
176 movsb
|
pascal@19827
|
177 ret
|
pascal@19827
|
178 .org 0x7E00
|
pascal@19827
|
179
|
pascal@19863
|
180 .org 0x7F85
|
pascal@13691
|
181 ////////////////////////////// DOS EXE code ///////////////////////////////////
|
pascal@13691
|
182
|
pascal@13729
|
183 exestart:
|
pascal@13699
|
184 cld
|
pascal@17810
|
185 movw 129, %ax
|
pascal@17473
|
186 cmpb $0x2F, %al
|
pascal@17473
|
187 je ishelp
|
pascal@17473
|
188 cmpw $0x2F20, %ax
|
pascal@17473
|
189 ishelp:
|
pascal@17473
|
190 movw $0x3000+EXESTR(help), %ax
|
pascal@13729
|
191 cwd // clear dx
|
pascal@17454
|
192 pushw %dx // dos exit()
|
pascal@17454
|
193 je abort
|
pascal@17454
|
194 int $0x21 // get DOS version
|
pascal@17562
|
195 addb $-3, %al
|
pascal@19849
|
196 movb $EXESTR(noDOS3), %al
|
pascal@19435
|
197 movw $0x100, %di
|
pascal@17810
|
198 jc tst386
|
pascal@13691
|
199 abort:
|
pascal@19849
|
200 goputs:
|
pascal@19849
|
201 jmp puts
|
pascal@13691
|
202
|
pascal@17160
|
203 tst386:
|
pascal@19849
|
204 pushw %sp
|
pascal@19849
|
205 popw %ax
|
pascal@19849
|
206 subw %sp, %ax
|
pascal@19849
|
207 jnz is86 // 86/186 not a 286+
|
pascal@19828
|
208 .arch i486
|
pascal@13691
|
209 is386:
|
pascal@17906
|
210 smsww %ax // not privileged
|
pascal@13691
|
211 andb $1, %al
|
pascal@19863
|
212 movb $EXESTR(vm86modemsg), %al
|
pascal@19863
|
213 jne isvm86
|
pascal@17906
|
214 movl %cr0, %eax // privileged
|
pascal@14150
|
215 incl %eax
|
pascal@19863
|
216 .arch i8086
|
pascal@13713
|
217 movb $EXESTR(rmPaging), %al
|
pascal@14150
|
218 js abort
|
pascal@17810
|
219 inc %ax
|
pascal@17810
|
220 //movb $EXESTR(realmodemsg), %al
|
pascal@19863
|
221 isvm86:
|
pascal@19849
|
222 call goputs
|
pascal@17160
|
223 is86:
|
pascal@14261
|
224 movw comstart-end_header(%di), %si // .com address
|
pascal@13691
|
225 pushw %di
|
pascal@17906
|
226 movb $0x7C/2, %ch // 31K-31.5K, > com length
|
pascal@13691
|
227 rep
|
pascal@17473
|
228 movsw
|
pascal@13691
|
229 ret
|
pascal@13713
|
230
|
pascal@17496
|
231 vm86modemsg:
|
pascal@17473
|
232 // --------------- Must be in 7F40 7FFF range ------------------------
|
pascal@17810
|
233 .ascii "86" // 86 mode
|
pascal@17562
|
234 .byte EXESTR(mode)
|
pascal@14261
|
235 rmPaging:
|
pascal@17810
|
236 .ascii "X" // Xreal mode
|
pascal@14261
|
237 realmodemsg:
|
pascal@17562
|
238 .ascii "real" // real mode
|
pascal@17473
|
239 // --------------- Must be in 7FC0 7FFF range ------------------------
|
pascal@17562
|
240 mode:
|
pascal@17562
|
241 .ascii " m"
|
pascal@17496
|
242 ode:
|
pascal@17562
|
243 .ascii "ode"
|
pascal@14261
|
244 .byte EXESTR(eol)
|
pascal@17562
|
245 noDOS3:
|
pascal@17810
|
246 .ascii "DOS3" // DOS3?
|
pascal@17562
|
247 need:
|
pascal@17810
|
248 .ascii "?"
|
pascal@17496
|
249 .byte EXESTR(eol)
|
pascal@17473
|
250 help:
|
pascal@19435
|
251 .ascii "SliTaz iso boot." // SliTaz iso boot.
|
pascal@17473
|
252 eol:
|
pascal@17496
|
253 .ascii "\r\n"
|
pascal@17810
|
254 .byte 1 // puts will return
|
pascal@14261
|
255
|
pascal@17496
|
256 .space 16,0 // ISO md5
|
pascal@14261
|
257 .org 0x8000
|
pascal@14261
|
258 ////////////////////////// ISO9660 header /////////////////////////////////////
|