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