rev |
line source |
pascal@20179
|
1 // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2.
|
pascal@20179
|
2
|
pascal@20179
|
3 SYSSEG = 0x1000
|
pascal@20179
|
4 setup_sects = 497
|
pascal@20179
|
5 syssize = 500
|
pascal@20179
|
6 cmd_line_ptr = 0x228
|
pascal@20179
|
7
|
pascal@20179
|
8 .text
|
pascal@20179
|
9 .code16
|
pascal@20179
|
10 .org 0
|
pascal@20179
|
11 .globl _start
|
pascal@20179
|
12 _start:
|
pascal@20179
|
13
|
pascal@20179
|
14 #define CODESZ 512 /* patched by installer */
|
pascal@20179
|
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@20179
|
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@20179
|
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@24045
|
34 //#define NO_MINSETUP default setup (dos only) ? -4
|
pascal@20179
|
35 //#define NO_CURSOR_DEFINITION -8
|
pascal@20179
|
36 #endif
|
pascal@20179
|
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@20179
|
68 #ifdef EXE_SUPPORT
|
pascal@20179
|
69 #define EXEADRS(x) (x+0xE0)
|
pascal@20179
|
70 #define FLAT20(x) (x+16*INITSEG)
|
pascal@20179
|
71
|
pascal@20179
|
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@20179
|
81 pushl $4
|
pascal@20179
|
82 popw %si
|
pascal@20179
|
83 popw %ds
|
pascal@20179
|
84 pushl (%si)
|
pascal@20179
|
85 movl $step19+(INITSEG<<16), (%si)
|
pascal@20184
|
86 #endif
|
pascal@20179
|
87 pushfw
|
pascal@20179
|
88 popw %ax
|
pascal@20179
|
89 incb %ah # set TF
|
pascal@20179
|
90 pushw %ax
|
pascal@20179
|
91 popfw
|
pascal@20179
|
92 ljmp *4*0x19-4(%si)
|
pascal@20179
|
93 .endm
|
pascal@20179
|
94
|
pascal@20179
|
95 stacktop = 0x9E00 # in 0x8000 .. 0xA000
|
pascal@20179
|
96 decw %bp // Magic number: MZ
|
pascal@20179
|
97 popw %dx
|
pascal@20179
|
98 jmp start // Bytes on last page of file
|
pascal@20179
|
99 .word (CODESZ+511)/512 // Pages in file INSTALLER
|
pascal@20179
|
100 .word 0 // Relocations
|
pascal@20179
|
101 .word (end_header-_start)/16 // Size of header in paragraphs
|
pascal@20179
|
102 .word 4096 // Minimum extra paragraphs needed
|
pascal@20179
|
103 .word -1 // Maximum extra paragraphs needed
|
pascal@20179
|
104 .word (CODESZ+15)/16 // Initial (relative) SS value INSTALLER
|
pascal@20179
|
105 .word stacktop // Initial SP value
|
pascal@20179
|
106 .word 0 // Checksum INSTALLER?
|
pascal@20179
|
107 .word EXEADRS(comstart) // Initial IP value
|
pascal@20179
|
108 .word 0xFFF0 // Initial (relative) CS value
|
pascal@20179
|
109 // .word 0x001C // File address of relocation table
|
pascal@20179
|
110 // .word 0,0,0 // Overlay number
|
pascal@20184
|
111 #else
|
pascal@20184
|
112 #undef VCPI
|
pascal@20179
|
113 #endif
|
pascal@20179
|
114 start:
|
pascal@20179
|
115 xorw %ax, %ax # %ax = 0
|
pascal@20179
|
116 zeroed = 12 # zeroed registers
|
pascal@20179
|
117 movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
|
pascal@20179
|
118 stacktop = 0x9E00 # in 0x8000 .. 0xA000 (+zeroed+12)
|
pascal@20184
|
119 #ifdef ONLY8086
|
pascal@20184
|
120 movw $INITSEG, %bx
|
pascal@20184
|
121 #else
|
pascal@20179
|
122 pushw $INITSEG
|
pascal@20184
|
123 #endif
|
pascal@20179
|
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@20179
|
130 # cmdline offset at 0x22
|
pascal@20179
|
131 movw $stacktop, %di # stacktop is an arbitrary value >=
|
pascal@20179
|
132 # length of bootsect + length of
|
pascal@20179
|
133 # setup + room for stack;
|
pascal@20179
|
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@20179
|
142 movw %di, %sp # put stack at INITSEG:stacktop-...
|
pascal@20179
|
143 #ifdef EXE_SUPPORT
|
pascal@20179
|
144 cwd # force %dx = 0 (floppy only)
|
pascal@20179
|
145 #endif
|
pascal@20179
|
146
|
pascal@20179
|
147 # Many BIOS's default disk parameter tables will not recognize
|
pascal@20179
|
148 # multi-sector reads beyond the maximum sector number specified
|
pascal@20179
|
149 # in the default diskette parameter tables - this may mean 7
|
pascal@20179
|
150 # sectors in some cases.
|
pascal@20179
|
151 #
|
pascal@20179
|
152 # Since single sector reads are slow and out of the question,
|
pascal@20179
|
153 # we must take care of this by creating new parameter tables
|
pascal@20179
|
154 # (for the first disk) in RAM. We can set the maximum sector
|
pascal@20179
|
155 # count to 36 - the most we will encounter on an ED 2.88.
|
pascal@20179
|
156 #
|
pascal@20179
|
157 # High doesn't hurt. Low does. Let's use the max: 63
|
pascal@20179
|
158
|
pascal@20179
|
159 rep # don't worry about cld
|
pascal@20179
|
160 stosw # already done above
|
pascal@20179
|
161 popw %bx # offset = 0
|
pascal@20179
|
162 popw %ds # %ds = 0
|
pascal@20179
|
163
|
pascal@20179
|
164 movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0)
|
pascal@20179
|
165 incw %ax
|
pascal@20179
|
166
|
pascal@20179
|
167 ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address
|
pascal@20179
|
168 pushw %es
|
pascal@20179
|
169 pushw %di
|
pascal@20179
|
170 movb $6, %cl # copy 12 bytes
|
pascal@20179
|
171 rep # don't worry about cld
|
pascal@20179
|
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@20179
|
180 pushw %ss
|
pascal@20179
|
181 popw %ds # now %ds = %es = %ss = INITSEG
|
pascal@20179
|
182 movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
|
pascal@20179
|
183
|
pascal@20179
|
184 xchg %ax, %di # sector count
|
pascal@20179
|
185 popw %ax # limits = 0
|
pascal@20179
|
186 incw %cx # cylinder 0, sector 1, clear Z
|
pascal@20179
|
187 call read_first_sectors # read setup
|
pascal@20179
|
188
|
pascal@20179
|
189 # This routine loads the system at address LOADSEG, making sure
|
pascal@20179
|
190 # no 64kB boundaries are crossed. We try to load it as fast as
|
pascal@20179
|
191 # possible, loading whole tracks whenever we can.
|
pascal@20179
|
192
|
pascal@20179
|
193 movw syssize, %di
|
pascal@20179
|
194 decw %di
|
pascal@20184
|
195 shrclw $9-4, %di
|
pascal@20179
|
196 incw %di
|
pascal@20179
|
197 movw $SYSSEG, %cx
|
pascal@20179
|
198 #ifdef BZIMAGE
|
pascal@20179
|
199 push %cx
|
pascal@20179
|
200 #endif
|
pascal@20179
|
201 call read_sectorsCX
|
pascal@20179
|
202
|
pascal@20179
|
203 # This procedure turns off the floppy drive motor, so
|
pascal@20179
|
204 # that we enter the kernel in a known state, and
|
pascal@20179
|
205 # don't have to worry about it later.
|
pascal@20179
|
206
|
pascal@20179
|
207 kill_motor:
|
pascal@20179
|
208 xchgw %ax, %di # reset FDC (%di < 128)
|
pascal@20179
|
209 int $0x13
|
pascal@20179
|
210
|
pascal@20179
|
211 # After that (everything loaded), we jump to the setup-routine
|
pascal@20179
|
212 # loaded directly after the bootblock:
|
pascal@20179
|
213 # Segments are as follows: %ds = %ss = INITSEG
|
pascal@20179
|
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@20179
|
254 jmp_setup:
|
pascal@20184
|
255 cli
|
pascal@20179
|
256 ljmp $SETUPSEG, $0
|
pascal@20179
|
257
|
pascal@20179
|
258 #ifdef EXE_SUPPORT
|
pascal@20179
|
259 #ifdef SHUTDOWNDOS
|
pascal@20179
|
260 doiret:
|
pascal@20179
|
261 iret
|
pascal@20179
|
262 step19:
|
pascal@20179
|
263 pushw %si
|
pascal@20179
|
264 pushw %ds
|
pascal@20179
|
265 movw %sp, %si
|
pascal@20179
|
266 ldsw %ss:4(%si), %si
|
pascal@20179
|
267 cmpw $0x19CD, (%si)
|
pascal@20179
|
268 popw %ds
|
pascal@20179
|
269 popw %si
|
pascal@20179
|
270 jne doiret
|
pascal@20179
|
271 xorw %si, %si
|
pascal@20179
|
272 movw %si, %ds
|
pascal@20179
|
273 pushw %cs
|
pascal@20179
|
274 popw %ss
|
pascal@20179
|
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@20179
|
287 popl 4(%si)
|
pascal@20179
|
288 popaw
|
pascal@20184
|
289 #endif
|
pascal@20179
|
290 #ifdef BZIMAGE
|
pascal@20179
|
291 jmp movesys
|
pascal@20179
|
292 #endif
|
pascal@20179
|
293 #endif
|
pascal@20179
|
294 #ifndef BZIMAGE
|
pascal@20179
|
295 movesys: // %ax = SYSSEG, %bx = DS, %si
|
pascal@20184
|
296 shrclw $4, %si
|
pascal@20179
|
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@24045
|
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@20179
|
314 subw %ax, %bx
|
pascal@20179
|
315 jnc forward
|
pascal@24045
|
316 //movw $0x8FFF, %ax
|
pascal@20179
|
317 movb $0x90, %ah
|
pascal@20179
|
318 forward:
|
pascal@20179
|
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@20179
|
324 cmc // C = 1 : 0
|
pascal@20179
|
325 adcw %di, %ax
|
pascal@20179
|
326 xorw %si, %si
|
pascal@20179
|
327 xorw %di, %di
|
pascal@20179
|
328 movb $0x10, %cl
|
pascal@20179
|
329 cmpb %cl, %ah // move 512k
|
pascal@20179
|
330 rep
|
pascal@20179
|
331 movsb
|
pascal@20179
|
332 jns forward
|
pascal@20184
|
333 #endif
|
pascal@20179
|
334 #ifndef NO_CURSOR_DEFINITION
|
pascal@20179
|
335 movb $1, %ah
|
pascal@20179
|
336 movb $0, %bh
|
pascal@20179
|
337 movb $0x20, %ch // 0x2000
|
pascal@20179
|
338 int $0x10
|
pascal@20179
|
339 #endif
|
pascal@20179
|
340 pushw %ss
|
pascal@20179
|
341 popw %ds
|
pascal@20179
|
342 jmp jmp_setup
|
pascal@20179
|
343 #endif
|
pascal@20179
|
344 comstart:
|
pascal@20179
|
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@20179
|
350 pushw $INITSEG
|
pascal@20184
|
351 #endif
|
pascal@20179
|
352 popw %es
|
pascal@20179
|
353 #ifdef CMDLINE
|
pascal@20179
|
354 movw %sp, %di
|
pascal@20179
|
355 movw $0x80, %si
|
pascal@20179
|
356 lodsb
|
pascal@20179
|
357 cbw
|
pascal@20179
|
358 xchgw %ax, %cx
|
pascal@20179
|
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@20179
|
363 movw $0xA33F, 0x7F(%si)
|
pascal@20179
|
364 # endif
|
pascal@20179
|
365 # ifndef NO_CMDLINE_SHRINK
|
pascal@20179
|
366 skipspace:
|
pascal@20179
|
367 lodsb
|
pascal@20179
|
368 cmpb $0x20, %al
|
pascal@20179
|
369 je skipspace
|
pascal@20179
|
370 # ifndef NO_CMDLINE_FILE
|
pascal@20179
|
371 movw %si,%dx
|
pascal@20179
|
372 decw %si
|
pascal@20179
|
373 subb $'@',%al
|
pascal@20179
|
374 jne notafile
|
pascal@20179
|
375 movb $0x3D,%ah
|
pascal@20179
|
376 int $0x21
|
pascal@20179
|
377 jc notafile
|
pascal@20179
|
378 xchgw %ax,%bx
|
pascal@20179
|
379 //movw %si,%dx // ~320 bytes max
|
pascal@20179
|
380 movw $EXEADRS(notafile)-130,%cx
|
pascal@20179
|
381 movb $0x3F,%ah
|
pascal@20179
|
382 int $0x21
|
pascal@20179
|
383 xchgw %ax,%cx
|
pascal@20179
|
384 notafile:
|
pascal@20179
|
385 # else
|
pascal@20179
|
386 decw %si
|
pascal@20179
|
387 # endif
|
pascal@20179
|
388 # endif
|
pascal@20179
|
389 rep
|
pascal@20179
|
390 movsb
|
pascal@20179
|
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@20179
|
402 #endif
|
pascal@20179
|
403 movb $(512-(end_header-_start))/2, %cl
|
pascal@20179
|
404 movw $0x100, %si
|
pascal@20179
|
405 movw $end_header, %di
|
pascal@20179
|
406 rep
|
pascal@20179
|
407 movsw
|
pascal@20179
|
408 movw $SYSSEG, %ax
|
pascal@20179
|
409 movw %ds, %bx
|
pascal@20179
|
410 pushw %es
|
pascal@20179
|
411 popw %ss
|
pascal@20179
|
412 #ifndef SHUTDOWNDOS
|
pascal@20179
|
413 pushw %es
|
pascal@20179
|
414 pushw $movesys
|
pascal@20179
|
415 #endif
|
pascal@20179
|
416 #ifdef VCPI
|
pascal@20179
|
417 pushaw
|
pascal@20179
|
418 smsww %ax
|
pascal@20179
|
419 andb $1, %al
|
pascal@20179
|
420 je isrm
|
pascal@20179
|
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@20179
|
424 call_vcpi:
|
pascal@20179
|
425 movb $0xDE,%ah // DE01, EBX = getiface(DS:SI, ES:DI)
|
pascal@20179
|
426 int $0x67
|
pascal@20179
|
427 movl $FLAT20(sw2pm_params),%esi
|
pascal@20179
|
428 movb $0x0C,%al // DE0C switchpm(ESI)
|
pascal@20179
|
429 jmp call_vcpi
|
pascal@20179
|
430 pm_code:
|
pascal@20179
|
431 movl %cr0,%eax
|
pascal@20179
|
432 andl $0x7FFFFFFE,%eax
|
pascal@20179
|
433 movl %eax,%cr0
|
pascal@20179
|
434 movl %eax,%cr3
|
pascal@20179
|
435 isrm:
|
pascal@20179
|
436 # ifdef SHUTDOWNDOS
|
pascal@20179
|
437 trace_int19
|
pascal@20179
|
438 # else
|
pascal@20179
|
439 lssw %cs:EXEADRS(saved_ss_sp),%sp
|
pascal@20179
|
440 popaw
|
pascal@20179
|
441 retf
|
pascal@20179
|
442 # endif
|
pascal@20179
|
443 #else
|
pascal@20179
|
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@20179
|
454 pushaw
|
pascal@20184
|
455 # endif
|
pascal@20179
|
456 trace_int19
|
pascal@20179
|
457 # endif
|
pascal@20179
|
458 retf
|
pascal@20179
|
459 #endif
|
pascal@20179
|
460 #endif
|
pascal@20179
|
461
|
pascal@20179
|
462 # read_sectors reads %di sectors into %es:0 buffer.
|
pascal@20179
|
463 # %es:0 is updated to the next memory location.
|
pascal@20179
|
464 # First, sectors are read sector by sector until
|
pascal@20179
|
465 # sector per track count is known. Then they are
|
pascal@20179
|
466 # read track by track.
|
pascal@20179
|
467 # Assume no error on first track.
|
pascal@20179
|
468
|
pascal@20179
|
469 #ifdef FLOPPY_1440K_ONLY
|
pascal@24045
|
470 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@20179
|
471 #define FLOPPY_HAS_2_SIDES hardcore heads count to 2
|
pascal@24045
|
472 #endif
|
pascal@20179
|
473 #define FLOPPY_SECTORS 18 /* 18 sectors */
|
pascal@20179
|
474 #else
|
pascal@20179
|
475 #define FLOPPY_HEADS 2 /* 2 heads minimum */
|
pascal@20179
|
476 #endif
|
pascal@20179
|
477
|
pascal@20179
|
478 return:
|
pascal@20179
|
479 #ifndef NO_DOTS
|
pascal@20179
|
480 movw $0xE2E,%ax
|
pascal@20179
|
481 int $0x10
|
pascal@20179
|
482 #endif
|
pascal@20179
|
483 ret
|
pascal@20179
|
484
|
pascal@20179
|
485 check_limits:
|
pascal@20179
|
486 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
487 popw %dx
|
pascal@20179
|
488 cmpb %al, %cl # max sector known ?
|
pascal@20179
|
489 ja next_head # no -> store it
|
pascal@20179
|
490 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@20179
|
491 #ifdef FLOPPY_HEADS
|
pascal@20179
|
492 cmpb $FLOPPY_HEADS, %dh # 2 heads minimum
|
pascal@20179
|
493 jb check_cylinder
|
pascal@20179
|
494 #endif
|
pascal@20179
|
495 cmpb %ah, %dh # max head known ?
|
pascal@20179
|
496 ja next_cylinder # no -> store it
|
pascal@20179
|
497 check_cylinder:
|
pascal@20179
|
498 #endif
|
pascal@20184
|
499 pushw %ax
|
pascal@20179
|
500 cbw # %ah = 0
|
pascal@20184
|
501 #else
|
pascal@20184
|
502 pushw %dx
|
pascal@20179
|
503 #endif
|
pascal@20179
|
504 int $0x13 # reset controler
|
pascal@20184
|
505 #ifndef FLOPPY_1440K_ONLY
|
pascal@20184
|
506 popw %ax
|
pascal@20179
|
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@20179
|
512 read_sectorslp:
|
pascal@20179
|
513 pushw %dx # some bios break dx...
|
pascal@20179
|
514 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
515 pushw %ax # limits
|
pascal@20179
|
516 subb %cl, %al # sectors remaining in track
|
pascal@20179
|
517 ja tolastsect
|
pascal@20184
|
518 movb $1, %al # first track sector by sector
|
pascal@20179
|
519 tolastsect:
|
pascal@20179
|
520 #else
|
pascal@20179
|
521 movb $FLOPPY_SECTORS+1, %al
|
pascal@20179
|
522 subb %cl, %al # sectors remaining in track
|
pascal@20179
|
523 #endif
|
pascal@20179
|
524 cbw
|
pascal@20179
|
525 cmpw %di, %ax
|
pascal@20179
|
526 jb more1trk
|
pascal@20179
|
527 movw %di, %ax # sectors to read
|
pascal@20179
|
528 more1trk:
|
pascal@20179
|
529 pushw %ax # save context
|
pascal@20179
|
530 movb $2, %ah # cmd: read chs
|
pascal@20179
|
531 int $0x13
|
pascal@20179
|
532 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
533 popw %dx # save %ax
|
pascal@20179
|
534 popw %ax # limits
|
pascal@20179
|
535 #else
|
pascal@20179
|
536 popw %ax # restore context
|
pascal@20179
|
537 popw %dx
|
pascal@20179
|
538 #endif
|
pascal@20179
|
539 jc check_limits
|
pascal@20179
|
540 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
541 xchgw %ax, %bp
|
pascal@20179
|
542 addw %dx,%cx # next sector
|
pascal@20184
|
543 movw %cx, %si
|
pascal@20184
|
544 pushw %dx
|
pascal@20184
|
545 shlclw $5, %dx
|
pascal@20179
|
546 movw %es, %cx
|
pascal@20179
|
547 addw %dx, %cx
|
pascal@20179
|
548 popw %dx
|
pascal@20179
|
549 subw %dx,%di # update sector counter
|
pascal@20179
|
550 popw %dx
|
pascal@20179
|
551 #else
|
pascal@20179
|
552 addw %ax,%cx # next sector
|
pascal@20184
|
553 movw %cx, %si
|
pascal@20184
|
554 pushw %ax
|
pascal@20184
|
555 shlclw $5, %ax
|
pascal@20179
|
556 movw %es, %cx
|
pascal@20179
|
557 addw %ax, %cx
|
pascal@20179
|
558 popw %ax
|
pascal@20179
|
559 subw %ax,%di # update sector counter
|
pascal@20179
|
560 #endif
|
pascal@20179
|
561 read_sectorsCX:
|
pascal@20179
|
562 movw %cx, %es # next location
|
pascal@20179
|
563 jz return
|
pascal@20179
|
564 read_sectors:
|
pascal@20184
|
565 movw %si, %cx
|
pascal@20179
|
566 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
567 # al is last sector+1
|
pascal@20184
|
568 # ah is last head+1
|
pascal@20179
|
569 xchgw %ax, %bp
|
pascal@20179
|
570 #endif
|
pascal@20179
|
571 #ifndef FLOPPY_1440K_ONLY
|
pascal@20179
|
572 cmpb %al,%cl # reach sector limit ?
|
pascal@20179
|
573 jne bdendlp
|
pascal@20179
|
574 next_head:
|
pascal@20179
|
575 movb %cl,%al
|
pascal@20179
|
576 #else
|
pascal@20179
|
577 cmpb $FLOPPY_SECTORS+1,%cl # reach sector limit ?
|
pascal@20179
|
578 jne bdendlp
|
pascal@20179
|
579 #endif
|
pascal@20179
|
580 movb $1,%cl # first sector
|
pascal@20179
|
581 #ifndef FLOPPY_HAS_2_SIDES
|
pascal@20179
|
582 incb %dh # next head
|
pascal@20179
|
583 cmpb %ah, %dh # reach head limit ?
|
pascal@20179
|
584 jne bdendlp
|
pascal@20179
|
585 next_cylinder:
|
pascal@20179
|
586 movb %dh,%ah
|
pascal@20179
|
587 movb $0,%dh # first head
|
pascal@20179
|
588 #else
|
pascal@20179
|
589 xorb %cl,%dh # next head
|
pascal@20179
|
590 jne bdendlp # reach head limit ?
|
pascal@20179
|
591 #endif
|
pascal@20179
|
592 # NOTE : support 256 cylinders max
|
pascal@20179
|
593 incb %ch # next cylinder
|
pascal@20179
|
594 read_first_sectors:
|
pascal@20179
|
595 bdendlp:
|
pascal@20179
|
596 jmp read_sectorslp
|
pascal@20179
|
597
|
pascal@20179
|
598 #ifdef VCPI
|
pascal@20179
|
599 pagebuf = 0x98000
|
pascal@20179
|
600 tss = gdt_abs-40
|
pascal@20179
|
601 gdt = gdt_abs-32
|
pascal@20179
|
602 gdt_null = gdt_abs-32
|
pascal@20179
|
603 gdt_vcpi = gdt_abs-24
|
pascal@20179
|
604 gdt_vcpi2 = gdt_abs-16
|
pascal@20179
|
605 gdt_vcpi3 = gdt_abs-8
|
pascal@20179
|
606 gdt_abs:
|
pascal@20179
|
607 .word 0xFFFF
|
pascal@20179
|
608 .long 0x92000000
|
pascal@20179
|
609 .byte 0xCF,0
|
pascal@20179
|
610 gdt_code:
|
pascal@20179
|
611 .word 0xFFFF
|
pascal@20179
|
612 gdt_code_base:
|
pascal@20179
|
613 .long 0x9A000000+FLAT20(0)
|
pascal@20179
|
614 .byte 0x8F,0
|
pascal@20179
|
615 gdt_tss:
|
pascal@20179
|
616 .word 0x00FF
|
pascal@20179
|
617 gdt_tss_base:
|
pascal@20179
|
618 .long 0x89000000+FLAT20(tss)
|
pascal@20179
|
619 .byte 0,0
|
pascal@20179
|
620 gdtr:
|
pascal@20179
|
621 gdt_lim:
|
pascal@20179
|
622 .word 0xFFFF
|
pascal@20179
|
623 gdt_base:
|
pascal@20179
|
624 .long FLAT20(gdt)
|
pascal@20179
|
625 sw2pm_params:
|
pascal@20179
|
626 sw2pm_cr3:
|
pascal@20179
|
627 .long pagebuf+0x1000
|
pascal@20179
|
628 sw2pm_gdtr_ptr:
|
pascal@20179
|
629 .long FLAT20(gdtr)
|
pascal@20179
|
630 sw2pm_idtr_ptr:
|
pascal@20179
|
631 .long FLAT20(idtr)
|
pascal@20179
|
632 sw2pm_ldtr:
|
pascal@20179
|
633 .word 0
|
pascal@20179
|
634 sw2pm_tr:
|
pascal@20179
|
635 SEL_TSS = gdt_tss-gdt_null
|
pascal@20179
|
636 .word SEL_TSS
|
pascal@20179
|
637 sw2pm_jumpaddr:
|
pascal@20179
|
638 .long pm_code
|
pascal@20179
|
639 SEL_CODE = gdt_code-gdt_null
|
pascal@20179
|
640 .word SEL_CODE
|
pascal@20179
|
641 idtr:
|
pascal@20179
|
642 idt_lim:
|
pascal@20179
|
643 .word 0x03FF
|
pascal@20179
|
644 idt_base:
|
pascal@20179
|
645 .long 0
|
pascal@20179
|
646 # ifndef SHUTDOWNDOS
|
pascal@20179
|
647 saved_ss_sp:
|
pascal@20179
|
648 .word stacktop-4-16-4,INITSEG
|
pascal@20179
|
649 # endif
|
pascal@20179
|
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
|