rev |
line source |
pascal@20179
|
1 // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2.
|
pascal@19941
|
2
|
pascal@15188
|
3 SYSSEG = 0x1000
|
pascal@19941
|
4 setup_sects = 497
|
pascal@19941
|
5 syssize = 500
|
pascal@20179
|
6 cmd_line_ptr = 0x228
|
pascal@15188
|
7
|
pascal@15188
|
8 .text
|
pascal@15188
|
9 .code16
|
pascal@15188
|
10 .org 0
|
pascal@15188
|
11 .globl _start
|
pascal@15188
|
12 _start:
|
pascal@15188
|
13
|
pascal@19399
|
14 #define CODESZ 512 /* patched by installer */
|
pascal@15188
|
15
|
pascal@20184
|
16 // Default kernel format is 386 Image/zImage
|
pascal@20179
|
17 //#define BZIMAGE 0x207 /* setup version ; for bzImage < 512 Kb only */
|
pascal@20184
|
18 //#define ELKS /* 8086/286 linux port */
|
pascal@20179
|
19
|
pascal@15188
|
20 /* some extra features */
|
pascal@20184
|
21 #define EXE_SUPPORT real mode dos .exe file support +208/264
|
pascal@20184
|
22 #define CMDLINE dos kernel cmdline support +45
|
pascal@20184
|
23 #define VCPI VCPI 4.0 support (386+) +109
|
pascal@20184
|
24 #define SHUTDOWNDOS shutdown DOS services +29
|
pascal@15188
|
25
|
pascal@20179
|
26 /* some contraints to reduce the code size */
|
pascal@20184
|
27 //#define FLOPPY_1440K_ONLY 1.44M floppies support only -26
|
pascal@20184
|
28 //#define FLOPPY_HAS_2_SIDES hardcoded heads count to 2 -15
|
pascal@20184
|
29 //#define NO_CMDLINE_SHRINK remove heading spaces ? -6-21
|
pascal@20184
|
30 //#define NO_CMDLINE_FILE remove @cmdline file support ? -21
|
pascal@20184
|
31 //#define NO_DOTS show progression dots ? -5
|
pascal@20179
|
32 #ifndef BZIMAGE
|
pascal@20184
|
33 //#define TINY_ZIMAGE system < 64Kb ? -11
|
pascal@21983
|
34 //#define NO_MINSETUP default setup (dos only) ? -4
|
pascal@20179
|
35 //#define NO_CURSOR_DEFINITION -8
|
pascal@20179
|
36 #endif
|
pascal@15188
|
37
|
pascal@20184
|
38 #ifdef ELKS
|
pascal@20184
|
39 .arch i8086
|
pascal@20184
|
40 INITSEG = 0x0100
|
pascal@20184
|
41 SETUPSEG = 0x0120
|
pascal@20184
|
42 #define ONLY8086
|
pascal@20184
|
43 #undef BZIMAGE
|
pascal@20184
|
44 #undef VCPI
|
pascal@20184
|
45 #else
|
pascal@20184
|
46 INITSEG = 0x9000
|
pascal@20184
|
47 SETUPSEG = 0x9020
|
pascal@20184
|
48 #endif
|
pascal@20184
|
49
|
pascal@20184
|
50 .macro shlclw cnt,obj
|
pascal@20184
|
51 #ifdef ONLY8086
|
pascal@20184
|
52 movb \cnt,%cl
|
pascal@20184
|
53 shlw %cl,\obj
|
pascal@20184
|
54 #else
|
pascal@20184
|
55 shlw \cnt,\obj
|
pascal@20184
|
56 #endif
|
pascal@20184
|
57 .endm
|
pascal@20184
|
58
|
pascal@20184
|
59 .macro shrclw cnt,obj
|
pascal@20184
|
60 #ifdef ONLY8086
|
pascal@20184
|
61 movb \cnt,%cl
|
pascal@20184
|
62 shrw %cl,\obj
|
pascal@20184
|
63 #else
|
pascal@20184
|
64 shrw \cnt,\obj
|
pascal@20184
|
65 #endif
|
pascal@20184
|
66 .endm
|
pascal@20184
|
67
|
pascal@15188
|
68 #ifdef EXE_SUPPORT
|
pascal@19399
|
69 #define EXEADRS(x) (x+0xE0)
|
pascal@19941
|
70 #define FLAT20(x) (x+16*INITSEG)
|
pascal@19941
|
71
|
pascal@19941
|
72 .macro trace_int19
|
pascal@20184
|
73 #ifdef ONLY8086
|
pascal@20184
|
74 xorw %si, %si
|
pascal@20184
|
75 movw %si, %ds
|
pascal@20184
|
76 pushw 4+2(%si)
|
pascal@20184
|
77 pushw 4(%si)
|
pascal@20184
|
78 movw $step19, 4(%si)
|
pascal@20184
|
79 movw $INITSEG, 4+2(%si)
|
pascal@20184
|
80 #else
|
pascal@19941
|
81 pushl $4
|
pascal@19941
|
82 popw %si
|
pascal@19941
|
83 popw %ds
|
pascal@19400
|
84 pushl (%si)
|
pascal@19941
|
85 movl $step19+(INITSEG<<16), (%si)
|
pascal@20184
|
86 #endif
|
pascal@19399
|
87 pushfw
|
pascal@19399
|
88 popw %ax
|
pascal@19399
|
89 incb %ah # set TF
|
pascal@19399
|
90 pushw %ax
|
pascal@19399
|
91 popfw
|
pascal@19400
|
92 ljmp *4*0x19-4(%si)
|
pascal@19941
|
93 .endm
|
pascal@19941
|
94
|
pascal@19941
|
95 stacktop = 0x9E00 # in 0x8000 .. 0xA000
|
pascal@19941
|
96 decw %bp // Magic number: MZ
|
pascal@19941
|
97 popw %dx
|
pascal@19941
|
98 jmp start // Bytes on last page of file
|
pascal@19941
|
99 .word (CODESZ+511)/512 // Pages in file INSTALLER
|
pascal@19941
|
100 .word 0 // Relocations
|
pascal@19941
|
101 .word (end_header-_start)/16 // Size of header in paragraphs
|
pascal@19949
|
102 .word 4096 // Minimum extra paragraphs needed
|
pascal@19941
|
103 .word -1 // Maximum extra paragraphs needed
|
pascal@19941
|
104 .word (CODESZ+15)/16 // Initial (relative) SS value INSTALLER
|
pascal@19941
|
105 .word stacktop // Initial SP value
|
pascal@19941
|
106 .word 0 // Checksum INSTALLER?
|
pascal@19941
|
107 .word EXEADRS(comstart) // Initial IP value
|
pascal@19941
|
108 .word 0xFFF0 // Initial (relative) CS value
|
pascal@19941
|
109 // .word 0x001C // File address of relocation table
|
pascal@19941
|
110 // .word 0,0,0 // Overlay number
|
pascal@20184
|
111 #else
|
pascal@20184
|
112 #undef VCPI
|
pascal@19399
|
113 #endif
|
pascal@15188
|
114 start:
|
pascal@19941
|
115 xorw %ax, %ax # %ax = 0
|
pascal@15188
|
116 zeroed = 12 # zeroed registers
|
pascal@20179
|
117 movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
|
pascal@19941
|
118 stacktop = 0x9E00 # in 0x8000 .. 0xA000 (+zeroed+12)
|
pascal@20184
|
119 #ifdef ONLY8086
|
pascal@20184
|
120 movw $INITSEG, %bx
|
pascal@20184
|
121 #else
|
pascal@19941
|
122 pushw $INITSEG
|
pascal@20184
|
123 #endif
|
pascal@19941
|
124 end_header:
|
pascal@20179
|
125 cld # assume nothing
|
pascal@20179
|
126 #if defined(BZIMAGE) && BZIMAGE >= 0x202
|
pascal@20179
|
127 popw %es # %es contain INITSEG
|
pascal@20179
|
128 movw %es, %di
|
pascal@20179
|
129 #else
|
pascal@19941
|
130 # cmdline offset at 0x22
|
pascal@19941
|
131 movw $stacktop, %di # stacktop is an arbitrary value >=
|
pascal@15188
|
132 # length of bootsect + length of
|
pascal@15188
|
133 # setup + room for stack;
|
pascal@15188
|
134 # 12 is disk parm size.
|
pascal@20184
|
135 # ifdef ONLY8086
|
pascal@20184
|
136 pushw %bx
|
pascal@20184
|
137 # endif
|
pascal@20179
|
138 popw %es # %es contain INITSEG
|
pascal@20179
|
139 #endif
|
pascal@20179
|
140 pushw %es
|
pascal@20179
|
141 popw %ss # %es = %ss = INITSEG
|
pascal@15188
|
142 movw %di, %sp # put stack at INITSEG:stacktop-...
|
pascal@19941
|
143 #ifdef EXE_SUPPORT
|
pascal@20179
|
144 cwd # force %dx = 0 (floppy only)
|
pascal@19941
|
145 #endif
|
pascal@15188
|
146
|
pascal@15188
|
147 # Many BIOS's default disk parameter tables will not recognize
|
pascal@15188
|
148 # multi-sector reads beyond the maximum sector number specified
|
pascal@15188
|
149 # in the default diskette parameter tables - this may mean 7
|
pascal@15188
|
150 # sectors in some cases.
|
pascal@15188
|
151 #
|
pascal@15188
|
152 # Since single sector reads are slow and out of the question,
|
pascal@15188
|
153 # we must take care of this by creating new parameter tables
|
pascal@15188
|
154 # (for the first disk) in RAM. We can set the maximum sector
|
pascal@15188
|
155 # count to 36 - the most we will encounter on an ED 2.88.
|
pascal@15188
|
156 #
|
pascal@15188
|
157 # High doesn't hurt. Low does. Let's use the max: 63
|
pascal@15188
|
158
|
pascal@15188
|
159 rep # don't worry about cld
|
pascal@15188
|
160 stosw # already done above
|
pascal@15188
|
161 popw %bx # offset = 0
|
pascal@15188
|
162 popw %ds # %ds = 0
|
pascal@15188
|
163
|
pascal@15188
|
164 movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0)
|
pascal@15188
|
165 incw %ax
|
pascal@15188
|
166
|
pascal@15188
|
167 ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address
|
pascal@15188
|
168 pushw %es
|
pascal@15188
|
169 pushw %di
|
pascal@15188
|
170 movb $6, %cl # copy 12 bytes
|
pascal@15188
|
171 rep # don't worry about cld
|
pascal@15188
|
172 movsw # already done above
|
pascal@20222
|
173 movw %cx, %ds # %ds = 0
|
pascal@20184
|
174 #ifdef ONLY8086
|
pascal@20184
|
175 popw 0x78(%bx) # update parameter table address
|
pascal@20184
|
176 popw 0x78+2(%bx)
|
pascal@20184
|
177 #else
|
pascal@20184
|
178 popl 0x78(%bx) # update parameter table address
|
pascal@20184
|
179 #endif
|
pascal@15188
|
180 pushw %ss
|
pascal@15188
|
181 popw %ds # now %ds = %es = %ss = INITSEG
|
pascal@15188
|
182 movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
|
pascal@15188
|
183
|
pascal@15188
|
184 xchg %ax, %di # sector count
|
pascal@15188
|
185 popw %ax # limits = 0
|
pascal@15188
|
186 incw %cx # cylinder 0, sector 1, clear Z
|
pascal@15188
|
187 call read_first_sectors # read setup
|
pascal@15188
|
188
|
pascal@15188
|
189 # This routine loads the system at address LOADSEG, making sure
|
pascal@15188
|
190 # no 64kB boundaries are crossed. We try to load it as fast as
|
pascal@15188
|
191 # possible, loading whole tracks whenever we can.
|
pascal@15188
|
192
|
pascal@15188
|
193 movw syssize, %di
|
pascal@17223
|
194 decw %di
|
pascal@20184
|
195 shrclw $9-4, %di
|
pascal@17223
|
196 incw %di
|
pascal@15188
|
197 movw $SYSSEG, %cx
|
pascal@20179
|
198 #ifdef BZIMAGE
|
pascal@20179
|
199 push %cx
|
pascal@20179
|
200 #endif
|
pascal@15188
|
201 call read_sectorsCX
|
pascal@15188
|
202
|
pascal@15188
|
203 # This procedure turns off the floppy drive motor, so
|
pascal@15188
|
204 # that we enter the kernel in a known state, and
|
pascal@15188
|
205 # don't have to worry about it later.
|
pascal@15188
|
206
|
pascal@15188
|
207 kill_motor:
|
pascal@15188
|
208 xchgw %ax, %di # reset FDC (%di < 128)
|
pascal@15188
|
209 int $0x13
|
pascal@15188
|
210
|
pascal@15188
|
211 # After that (everything loaded), we jump to the setup-routine
|
pascal@15188
|
212 # loaded directly after the bootblock:
|
pascal@15188
|
213 # Segments are as follows: %ds = %ss = INITSEG
|
pascal@15188
|
214
|
pascal@20179
|
215 #ifdef BZIMAGE
|
pascal@20179
|
216 popw %bx
|
pascal@20179
|
217 popw %si // SYSSEG:0
|
pascal@20179
|
218 movesys: // %bx = DS, %si
|
pascal@20179
|
219 movw $16, %ax
|
pascal@20179
|
220 mulw %bx
|
pascal@20179
|
221 addw %si, %ax
|
pascal@20179
|
222 adcw $0x9300, %dx // %dx:%ax src flat address
|
pascal@20179
|
223 movw $9, %cx
|
pascal@20179
|
224 zero1:
|
pascal@20179
|
225 pushw $0 // 2E..1E
|
pascal@20179
|
226 loop zero1
|
pascal@20179
|
227 //pushl $0x93100000 // 1A: dest
|
pascal@20179
|
228 pushw $0x9310
|
pascal@20179
|
229 pushw %cx
|
pascal@20179
|
230 pushw $-1 // 18
|
pascal@20179
|
231 pushw %cx // 16
|
pascal@20179
|
232 pushw %dx // src
|
pascal@20179
|
233 pushw %ax
|
pascal@20179
|
234 pushw $-1 // 10
|
pascal@20179
|
235 movb $8, %cl
|
pascal@20179
|
236 movw %cx, %bx // will move 8*64 = 512Kb
|
pascal@20179
|
237 zero2:
|
pascal@20179
|
238 pushw $0 // 0E..00
|
pascal@20179
|
239 loop zero2
|
pascal@20179
|
240 movw %sp, %si
|
pascal@20179
|
241 pushw %ss
|
pascal@20179
|
242 popw %es
|
pascal@20179
|
243 pushw %es
|
pascal@20179
|
244 popw %ds
|
pascal@20179
|
245 syslp:
|
pascal@20179
|
246 movb $0x80, %ch
|
pascal@20179
|
247 movb $0x87, %ah
|
pascal@20179
|
248 int $0x15
|
pascal@20179
|
249 incb 0x14(%si)
|
pascal@20179
|
250 incb 0x1C(%si)
|
pascal@20179
|
251 decw %bx
|
pascal@20179
|
252 jne syslp
|
pascal@20179
|
253 #endif
|
pascal@15188
|
254 jmp_setup:
|
pascal@20184
|
255 cli
|
pascal@15188
|
256 ljmp $SETUPSEG, $0
|
pascal@15188
|
257
|
pascal@15188
|
258 #ifdef EXE_SUPPORT
|
pascal@19399
|
259 #ifdef SHUTDOWNDOS
|
pascal@19399
|
260 doiret:
|
pascal@19399
|
261 iret
|
pascal@19399
|
262 step19:
|
pascal@19399
|
263 pushw %si
|
pascal@19399
|
264 pushw %ds
|
pascal@19399
|
265 movw %sp, %si
|
pascal@19399
|
266 ldsw %ss:4(%si), %si
|
pascal@19399
|
267 cmpw $0x19CD, (%si)
|
pascal@19399
|
268 popw %ds
|
pascal@19399
|
269 popw %si
|
pascal@19399
|
270 jne doiret
|
pascal@19399
|
271 xorw %si, %si
|
pascal@19402
|
272 movw %si, %ds
|
pascal@19401
|
273 pushw %cs
|
pascal@19401
|
274 popw %ss
|
pascal@19400
|
275 movw $stacktop-4-16, %sp
|
pascal@20184
|
276 #ifdef ONLY8086
|
pascal@20184
|
277 popw 4(%si)
|
pascal@20184
|
278 popw 4+2(%si)
|
pascal@20184
|
279 popw %bp
|
pascal@20184
|
280 popw %di
|
pascal@20184
|
281 popw %si
|
pascal@20184
|
282 popw %dx
|
pascal@20184
|
283 popw %cx
|
pascal@20184
|
284 popw %bx
|
pascal@20184
|
285 popw %ax
|
pascal@20184
|
286 #else
|
pascal@19399
|
287 popl 4(%si)
|
pascal@19399
|
288 popaw
|
pascal@20184
|
289 #endif
|
pascal@20179
|
290 #ifdef BZIMAGE
|
pascal@20179
|
291 jmp movesys
|
pascal@19399
|
292 #endif
|
pascal@20179
|
293 #endif
|
pascal@20179
|
294 #ifndef BZIMAGE
|
pascal@19941
|
295 movesys: // %ax = SYSSEG, %bx = DS, %si
|
pascal@20184
|
296 shrclw $4, %si
|
pascal@19193
|
297 addw %si, %bx
|
pascal@20184
|
298 #ifdef TINY_ZIMAGE
|
pascal@20184
|
299 movw $0xFFFF, %cx
|
pascal@20184
|
300 xorw %si, %si
|
pascal@20184
|
301 xorw %di, %di
|
pascal@20184
|
302 cmpw %ax, %bx
|
pascal@21983
|
303 jnc forward
|
pascal@20184
|
304 decw %si
|
pascal@20184
|
305 decw %di
|
pascal@20184
|
306 std
|
pascal@20184
|
307 forward:
|
pascal@20184
|
308 movw %ax, %es
|
pascal@20184
|
309 movw %bx, %ds
|
pascal@20184
|
310 rep
|
pascal@20184
|
311 movsb
|
pascal@20184
|
312 cld
|
pascal@20184
|
313 #else
|
pascal@17223
|
314 subw %ax, %bx
|
pascal@15188
|
315 jnc forward
|
pascal@24045
|
316 //movw $0x8FFF, %ax
|
pascal@20179
|
317 movb $0x90, %ah
|
pascal@15188
|
318 forward:
|
pascal@15188
|
319 movw %ax, %es
|
pascal@20179
|
320 movw %ax, %di
|
pascal@20179
|
321 addw %bx, %di
|
pascal@20179
|
322 movw %di, %ds
|
pascal@20179
|
323 sbbw %di, %di // %di = 0 : -1
|
pascal@17223
|
324 cmc // C = 1 : 0
|
pascal@20179
|
325 adcw %di, %ax
|
pascal@19193
|
326 xorw %si, %si
|
pascal@15188
|
327 xorw %di, %di
|
pascal@20179
|
328 movb $0x10, %cl
|
pascal@20179
|
329 cmpb %cl, %ah // move 512k
|
pascal@15188
|
330 rep
|
pascal@20179
|
331 movsb
|
pascal@15188
|
332 jns forward
|
pascal@20184
|
333 #endif
|
pascal@15188
|
334 #ifndef NO_CURSOR_DEFINITION
|
pascal@15188
|
335 movb $1, %ah
|
pascal@15188
|
336 movb $0, %bh
|
pascal@15188
|
337 movb $0x20, %ch // 0x2000
|
pascal@15188
|
338 int $0x10
|
pascal@15188
|
339 #endif
|
pascal@15188
|
340 pushw %ss
|
pascal@15188
|
341 popw %ds
|
pascal@15188
|
342 jmp jmp_setup
|
pascal@20179
|
343 #endif
|
pascal@19941
|
344 comstart:
|
pascal@19941
|
345 cld # assume nothing
|
pascal@20184
|
346 #ifdef ONLY8086
|
pascal@20184
|
347 movw $INITSEG, %ax
|
pascal@20184
|
348 pushw %ax
|
pascal@20184
|
349 #else
|
pascal@19941
|
350 pushw $INITSEG
|
pascal@20184
|
351 #endif
|
pascal@19941
|
352 popw %es
|
pascal@19941
|
353 #ifdef CMDLINE
|
pascal@19941
|
354 movw %sp, %di
|
pascal@19941
|
355 movw $0x80, %si
|
pascal@19941
|
356 lodsb
|
pascal@19941
|
357 cbw
|
pascal@19941
|
358 xchgw %ax, %cx
|
pascal@19941
|
359 jcxz nocmdline
|
pascal@20179
|
360 # if defined(BZIMAGE) && BZIMAGE >= 0x202
|
pascal@20179
|
361 movw $INITSEG/16+stacktop/256, EXEADRS(cmd_line_ptr+1)
|
pascal@20179
|
362 # else
|
pascal@19941
|
363 movw $0xA33F, 0x7F(%si)
|
pascal@20179
|
364 # endif
|
pascal@19941
|
365 # ifndef NO_CMDLINE_SHRINK
|
pascal@19941
|
366 skipspace:
|
pascal@19941
|
367 lodsb
|
pascal@19941
|
368 cmpb $0x20, %al
|
pascal@19941
|
369 je skipspace
|
pascal@19949
|
370 # ifndef NO_CMDLINE_FILE
|
pascal@19949
|
371 movw %si,%dx
|
pascal@19941
|
372 decw %si
|
pascal@19949
|
373 subb $'@',%al
|
pascal@19949
|
374 jne notafile
|
pascal@19949
|
375 movb $0x3D,%ah
|
pascal@19949
|
376 int $0x21
|
pascal@19949
|
377 jc notafile
|
pascal@19949
|
378 xchgw %ax,%bx
|
pascal@19949
|
379 //movw %si,%dx // ~320 bytes max
|
pascal@19949
|
380 movw $EXEADRS(notafile)-130,%cx
|
pascal@19949
|
381 movb $0x3F,%ah
|
pascal@19949
|
382 int $0x21
|
pascal@19949
|
383 xchgw %ax,%cx
|
pascal@19949
|
384 notafile:
|
pascal@19949
|
385 # else
|
pascal@19949
|
386 decw %si
|
pascal@19949
|
387 # endif
|
pascal@19941
|
388 # endif
|
pascal@19941
|
389 rep
|
pascal@19941
|
390 movsb
|
pascal@19941
|
391 nocmdline:
|
pascal@20179
|
392 orb EXEADRS(setup_sects), %ch
|
pascal@20179
|
393 # ifndef NO_MINSETUP
|
pascal@20179
|
394 # ifndef BZIMAGE
|
pascal@20179
|
395 jnz setupok
|
pascal@20179
|
396 mov $4, %ch
|
pascal@20179
|
397 setupok:
|
pascal@20179
|
398 # endif
|
pascal@20179
|
399 # endif
|
pascal@20179
|
400 #else
|
pascal@20179
|
401 movb EXEADRS(setup_sects), %ch
|
pascal@15188
|
402 #endif
|
pascal@19941
|
403 movb $(512-(end_header-_start))/2, %cl
|
pascal@19941
|
404 movw $0x100, %si
|
pascal@19941
|
405 movw $end_header, %di
|
pascal@19941
|
406 rep
|
pascal@19941
|
407 movsw
|
pascal@19941
|
408 movw $SYSSEG, %ax
|
pascal@19941
|
409 movw %ds, %bx
|
pascal@19941
|
410 pushw %es
|
pascal@19941
|
411 popw %ss
|
pascal@19941
|
412 #ifndef SHUTDOWNDOS
|
pascal@19941
|
413 pushw %es
|
pascal@19941
|
414 pushw $movesys
|
pascal@15188
|
415 #endif
|
pascal@19941
|
416 #ifdef VCPI
|
pascal@19941
|
417 pushaw
|
pascal@19941
|
418 smsww %ax
|
pascal@19941
|
419 andb $1, %al
|
pascal@19941
|
420 je isrm
|
pascal@19941
|
421 movw $EXEADRS(gdt_vcpi),%si
|
pascal@20179
|
422 movw $pagebuf-0x90000,%di // %es = 0x9000
|
pascal@20179
|
423 movl $pagebuf+3,%es:0x1000(%di)
|
pascal@19941
|
424 call_vcpi:
|
pascal@19941
|
425 movb $0xDE,%ah // DE01, EBX = getiface(DS:SI, ES:DI)
|
pascal@19941
|
426 int $0x67
|
pascal@19941
|
427 movl $FLAT20(sw2pm_params),%esi
|
pascal@19941
|
428 movb $0x0C,%al // DE0C switchpm(ESI)
|
pascal@19941
|
429 jmp call_vcpi
|
pascal@19941
|
430 pm_code:
|
pascal@19941
|
431 movl %cr0,%eax
|
pascal@19941
|
432 andl $0x7FFFFFFE,%eax
|
pascal@19941
|
433 movl %eax,%cr0
|
pascal@19941
|
434 movl %eax,%cr3
|
pascal@19941
|
435 isrm:
|
pascal@19941
|
436 # ifdef SHUTDOWNDOS
|
pascal@19941
|
437 trace_int19
|
pascal@19941
|
438 # else
|
pascal@19941
|
439 lssw %cs:EXEADRS(saved_ss_sp),%sp
|
pascal@19941
|
440 popaw
|
pascal@19941
|
441 retf
|
pascal@19941
|
442 # endif
|
pascal@19941
|
443 #else
|
pascal@19941
|
444 # ifdef SHUTDOWNDOS
|
pascal@20184
|
445 # ifdef ONLY8086
|
pascal@20184
|
446 pushw %ax
|
pascal@20184
|
447 pushw %bx
|
pascal@20184
|
448 pushw %cx
|
pascal@20184
|
449 pushw %dx
|
pascal@20184
|
450 pushw %si
|
pascal@20184
|
451 pushw %di
|
pascal@20184
|
452 pushw %bp
|
pascal@20184
|
453 # else
|
pascal@19941
|
454 pushaw
|
pascal@20184
|
455 # endif
|
pascal@19941
|
456 trace_int19
|
pascal@19941
|
457 # endif
|
pascal@19941
|
458 retf
|
pascal@19941
|
459 #endif
|
pascal@19941
|
460 #endif
|
pascal@15188
|
461
|
pascal@15188
|
462 # read_sectors reads %di sectors into %es:0 buffer.
|
pascal@15188
|
463 # %es:0 is updated to the next memory location.
|
pascal@15188
|
464 # First, sectors are read sector by sector until
|
pascal@15188
|
465 # sector per track count is known. Then they are
|
pascal@15188
|
466 # read track by track.
|
pascal@15188
|
467 # Assume no error on first track.
|
pascal@15188
|
468
|
pascal@15188
|
469 #ifdef FLOPPY_1440K_ONLY
|
pascal@21984
|
470 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@19941
|
471 #define FLOPPY_HAS_2_SIDES hardcore heads count to 2
|
pascal@21984
|
472 #endif
|
pascal@15188
|
473 #define FLOPPY_SECTORS 18 /* 18 sectors */
|
pascal@15188
|
474 #else
|
pascal@15188
|
475 #define FLOPPY_HEADS 2 /* 2 heads minimum */
|
pascal@15188
|
476 #endif
|
pascal@15188
|
477
|
pascal@19941
|
478 return:
|
pascal@19941
|
479 #ifndef NO_DOTS
|
pascal@19941
|
480 movw $0xE2E,%ax
|
pascal@19941
|
481 int $0x10
|
pascal@19941
|
482 #endif
|
pascal@19941
|
483 ret
|
pascal@19941
|
484
|
pascal@15188
|
485 check_limits:
|
pascal@15188
|
486 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
487 popw %dx
|
pascal@15188
|
488 cmpb %al, %cl # max sector known ?
|
pascal@15188
|
489 ja next_head # no -> store it
|
pascal@19941
|
490 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@15188
|
491 #ifdef FLOPPY_HEADS
|
pascal@15188
|
492 cmpb $FLOPPY_HEADS, %dh # 2 heads minimum
|
pascal@15188
|
493 jb check_cylinder
|
pascal@15188
|
494 #endif
|
pascal@15188
|
495 cmpb %ah, %dh # max head known ?
|
pascal@15188
|
496 ja next_cylinder # no -> store it
|
pascal@15188
|
497 check_cylinder:
|
pascal@15188
|
498 #endif
|
pascal@20184
|
499 pushw %ax
|
pascal@15188
|
500 cbw # %ah = 0
|
pascal@20184
|
501 #else
|
pascal@20184
|
502 pushw %dx
|
pascal@15188
|
503 #endif
|
pascal@15188
|
504 int $0x13 # reset controler
|
pascal@20184
|
505 #ifndef FLOPPY_1440K_ONLY
|
pascal@20184
|
506 popw %ax
|
pascal@15188
|
507 movb $1, %al # sector by sector...
|
pascal@20184
|
508 #else
|
pascal@20184
|
509 movw $1, %ax
|
pascal@20184
|
510 jmp more1trk
|
pascal@20184
|
511 #endif
|
pascal@15188
|
512 read_sectorslp:
|
pascal@15188
|
513 pushw %dx # some bios break dx...
|
pascal@15188
|
514 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
515 pushw %ax # limits
|
pascal@15188
|
516 subb %cl, %al # sectors remaining in track
|
pascal@15188
|
517 ja tolastsect
|
pascal@20184
|
518 movb $1, %al # first track sector by sector
|
pascal@15188
|
519 tolastsect:
|
pascal@15188
|
520 #else
|
pascal@19402
|
521 movb $FLOPPY_SECTORS+1, %al
|
pascal@15188
|
522 subb %cl, %al # sectors remaining in track
|
pascal@15188
|
523 #endif
|
pascal@15188
|
524 cbw
|
pascal@15188
|
525 cmpw %di, %ax
|
pascal@15188
|
526 jb more1trk
|
pascal@15188
|
527 movw %di, %ax # sectors to read
|
pascal@15188
|
528 more1trk:
|
pascal@15188
|
529 pushw %ax # save context
|
pascal@15188
|
530 movb $2, %ah # cmd: read chs
|
pascal@15188
|
531 int $0x13
|
pascal@15188
|
532 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
533 popw %dx # save %ax
|
pascal@15188
|
534 popw %ax # limits
|
pascal@15188
|
535 #else
|
pascal@15188
|
536 popw %ax # restore context
|
pascal@15188
|
537 popw %dx
|
pascal@15188
|
538 #endif
|
pascal@15188
|
539 jc check_limits
|
pascal@15188
|
540 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
541 xchgw %ax, %bp
|
pascal@15188
|
542 addw %dx,%cx # next sector
|
pascal@20184
|
543 movw %cx, %si
|
pascal@20184
|
544 pushw %dx
|
pascal@20184
|
545 shlclw $5, %dx
|
pascal@15188
|
546 movw %es, %cx
|
pascal@15188
|
547 addw %dx, %cx
|
pascal@15188
|
548 popw %dx
|
pascal@15188
|
549 subw %dx,%di # update sector counter
|
pascal@15188
|
550 popw %dx
|
pascal@15188
|
551 #else
|
pascal@15188
|
552 addw %ax,%cx # next sector
|
pascal@20184
|
553 movw %cx, %si
|
pascal@20184
|
554 pushw %ax
|
pascal@20184
|
555 shlclw $5, %ax
|
pascal@15188
|
556 movw %es, %cx
|
pascal@15188
|
557 addw %ax, %cx
|
pascal@15188
|
558 popw %ax
|
pascal@15188
|
559 subw %ax,%di # update sector counter
|
pascal@19941
|
560 #endif
|
pascal@15188
|
561 read_sectorsCX:
|
pascal@15188
|
562 movw %cx, %es # next location
|
pascal@19941
|
563 jz return
|
pascal@15188
|
564 read_sectors:
|
pascal@20184
|
565 movw %si, %cx
|
pascal@15188
|
566 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
567 # al is last sector+1
|
pascal@20184
|
568 # ah is last head+1
|
pascal@15188
|
569 xchgw %ax, %bp
|
pascal@15188
|
570 #endif
|
pascal@15188
|
571 #ifndef FLOPPY_1440K_ONLY
|
pascal@15188
|
572 cmpb %al,%cl # reach sector limit ?
|
pascal@15188
|
573 jne bdendlp
|
pascal@15188
|
574 next_head:
|
pascal@15188
|
575 movb %cl,%al
|
pascal@15188
|
576 #else
|
pascal@15188
|
577 cmpb $FLOPPY_SECTORS+1,%cl # reach sector limit ?
|
pascal@15188
|
578 jne bdendlp
|
pascal@15188
|
579 #endif
|
pascal@19941
|
580 movb $1,%cl # first sector
|
pascal@19941
|
581 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@15188
|
582 incb %dh # next head
|
pascal@15188
|
583 cmpb %ah, %dh # reach head limit ?
|
pascal@15188
|
584 jne bdendlp
|
pascal@15188
|
585 next_cylinder:
|
pascal@15188
|
586 movb %dh,%ah
|
pascal@19941
|
587 movb $0,%dh # first head
|
pascal@15188
|
588 #else
|
pascal@19941
|
589 xorb %cl,%dh # next head
|
pascal@19941
|
590 jne bdendlp # reach head limit ?
|
pascal@15188
|
591 #endif
|
pascal@15188
|
592 # NOTE : support 256 cylinders max
|
pascal@15188
|
593 incb %ch # next cylinder
|
pascal@15188
|
594 read_first_sectors:
|
pascal@15188
|
595 bdendlp:
|
pascal@15188
|
596 jmp read_sectorslp
|
pascal@15188
|
597
|
pascal@19941
|
598 #ifdef VCPI
|
pascal@19941
|
599 pagebuf = 0x98000
|
pascal@19920
|
600 tss = gdt_abs-40
|
pascal@19920
|
601 gdt = gdt_abs-32
|
pascal@19920
|
602 gdt_null = gdt_abs-32
|
pascal@19920
|
603 gdt_vcpi = gdt_abs-24
|
pascal@19920
|
604 gdt_vcpi2 = gdt_abs-16
|
pascal@19920
|
605 gdt_vcpi3 = gdt_abs-8
|
pascal@19920
|
606 gdt_abs:
|
pascal@19941
|
607 .word 0xFFFF
|
pascal@19941
|
608 .long 0x92000000
|
pascal@19941
|
609 .byte 0xCF,0
|
pascal@19920
|
610 gdt_code:
|
pascal@19920
|
611 .word 0xFFFF
|
pascal@19920
|
612 gdt_code_base:
|
pascal@19941
|
613 .long 0x9A000000+FLAT20(0)
|
pascal@19920
|
614 .byte 0x8F,0
|
pascal@19920
|
615 gdt_tss:
|
pascal@19920
|
616 .word 0x00FF
|
pascal@19920
|
617 gdt_tss_base:
|
pascal@19941
|
618 .long 0x89000000+FLAT20(tss)
|
pascal@19920
|
619 .byte 0,0
|
pascal@19920
|
620 gdtr:
|
pascal@19920
|
621 gdt_lim:
|
pascal@19920
|
622 .word 0xFFFF
|
pascal@19920
|
623 gdt_base:
|
pascal@19941
|
624 .long FLAT20(gdt)
|
pascal@19920
|
625 sw2pm_params:
|
pascal@19920
|
626 sw2pm_cr3:
|
pascal@19920
|
627 .long pagebuf+0x1000
|
pascal@19920
|
628 sw2pm_gdtr_ptr:
|
pascal@19941
|
629 .long FLAT20(gdtr)
|
pascal@19920
|
630 sw2pm_idtr_ptr:
|
pascal@19941
|
631 .long FLAT20(idtr)
|
pascal@19920
|
632 sw2pm_ldtr:
|
pascal@19920
|
633 .word 0
|
pascal@19920
|
634 sw2pm_tr:
|
pascal@19920
|
635 SEL_TSS = gdt_tss-gdt_null
|
pascal@19920
|
636 .word SEL_TSS
|
pascal@19920
|
637 sw2pm_jumpaddr:
|
pascal@19941
|
638 .long pm_code
|
pascal@19920
|
639 SEL_CODE = gdt_code-gdt_null
|
pascal@19920
|
640 .word SEL_CODE
|
pascal@19920
|
641 idtr:
|
pascal@19920
|
642 idt_lim:
|
pascal@19920
|
643 .word 0x03FF
|
pascal@19920
|
644 idt_base:
|
pascal@19920
|
645 .long 0
|
pascal@19941
|
646 # ifndef SHUTDOWNDOS
|
pascal@19941
|
647 saved_ss_sp:
|
pascal@19941
|
648 .word stacktop-4-16-4,INITSEG
|
pascal@19941
|
649 # endif
|
pascal@19920
|
650 #endif
|
pascal@20184
|
651 #ifdef ELKS
|
pascal@20184
|
652 .org 0x1E3
|
pascal@20184
|
653 .byte 13,10,7
|
pascal@20184
|
654 .asciz "ELKS Boot"
|
pascal@20184
|
655 #endif
|