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