wok view linux/stuff/linux-header.u @ rev 19983

Up openvpn (2.3.17)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jun 22 17:37:32 2017 +0200 (2017-06-22)
parents e0cfbb41587f
children
line source
1 --- linux-3.2.53/arch/x86/boot/header.S
2 +++ linux-3.2.53/arch/x86/boot/header.S
3 @@ -7,12 +7,14 @@
4 * modified by more people than can be counted
5 *
6 * Rewritten as a common file by H. Peter Anvin (Apr 2007)
7 + * Rewritten by Pascal Bellard (Nov 2009)
8 *
9 * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
10 * addresses must be multiplied by 16 to obtain their respective linear
11 * addresses. To avoid confusion, linear addresses are written using leading
12 * hex while segment addresses are written as segment:offset.
13 *
14 + * Assume protocol 2.00+ (kernel >= 1.3.73)
15 */
17 #include <asm/segment.h>
18 @@ -27,6 +29,8 @@
20 BOOTSEG = 0x07C0 /* original address of boot-sector */
21 SYSSEG = 0x1000 /* historical load address >> 4 */
22 +INITSEG = 0x9000 /* boot address >> 4 */
23 +SETUPSEG = 0x9020 /* setup address >> 4 */
25 #ifndef SVGA_MODE
26 #define SVGA_MODE ASK_VGA
27 @@ -40,54 +44,752 @@
28 #define ROOT_RDONLY 1
29 #endif
31 +setup_sects = 497
32 +syssize = 500
33 +vgamode = 506
34 +cmd_line_ptr = 0x228
35 +
36 +/* some extra features */
37 +#define EXE_SUPPORT real mode dos .exe file support
38 +#define CMDLINE kernel >= 2.4
39 +#define OLDCMDLINE kernel < 2.4
40 +#define HELP display version for ? argument
41 +#define MORETHAN16M up to 4Gb RAM, not 16Mb
42 +#define KEYBOARDLESS_SUPPORT scan floppy swap each 5 seconds
43 +
44 +/* some limitations to reduce the code size */
45 +//#define REALMODE_NOT_CHECKED exe crash when started in vm86
46 +//#define FLOPPY_1440K_ONLY 1.44M floppies support only (no 720K, 1.68M, 2.88M...)
47 +
48 +#ifdef FLOPPY_ONLY
49 +#undef EXE_SUPPORT
50 +#undef FLOPPY_1440K_ONLY
51 +#define EDIT_CMDLINE
52 +#define CMDLINE_SUPPORT
53 +#define MOVE_CMDLINE
54 +#define INITRD_SUPPORT
55 +#define INITRD_AUTOADDR
56 +#endif
57 +
58 +#ifdef EXE_ONLY
59 +#undef KEYBOARDLESS_SUPPORT
60 +#define INITRD_SUPPORT
61 +#define INITRD_KEYWORD
62 +#define INITRD_AUTOADDR
63 +#endif
64 +
65 .code16
66 .section ".bstext", "ax"
68 .global bootsect_start
69 bootsect_start:
71 - # Normalize the start address
72 - ljmp $BOOTSEG, $start2
73 +stacktop = 0x9E00 # in 0x8000 .. 0xA000
74 +zeroed = 48+10 # gdt + zeroed registers
75 +.macro INIT_REGS
76 + movw $stacktop-zeroed, %di # stacktop is an arbitrary value >=
77 + # length of bootsect + length of
78 + # setup + room for stack;
79 + # 12 is disk parm size.
80 + pushw $INITSEG
81 + popw %ss # %ss contain INITSEG
82 + movw %di, %sp # put stack at INITSEG:stacktop-...
83 + pushw %ss
84 + popw %es # %es = %ss = INITSEG
85 + xorw %ax, %ax # %ax = 0
86 +#if defined(CMDLINE)
87 + movw $zeroed+1, %cx # clear gdt + offset, %ds, limits, cmdline=""
88 + rep # don't worry about cld
89 + stosb # already done above
90 + decw %di
91 +#else
92 + movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
93 + rep # don't worry about cld
94 + stosw # already done above
95 +#endif
96 + popw %bx # offset = 0
97 +.endm
99 -start2:
100 - movw %cs, %ax
101 - movw %ax, %ds
102 - movw %ax, %es
103 - movw %ax, %ss
104 - xorw %sp, %sp
105 - sti
106 - cld
107 +#ifdef EXE_SUPPORT
108 +#define CODESZ 0x8000
109 +#define EXEADRS(x) x+0xE0
110 + decw %bp // Magic number: MZ
111 + popw %dx
112 +#ifdef EXE_ONLY
113 + .word 512 // Bytes on last page of file
114 +#else
115 + jmp fdstart // Bytes on last page of file
116 +#endif
117 + .word (CODESZ+511)/512 // Pages in file
118 + .word 0 // Relocations
119 + .word 2 // Size of header in paragraphs
120 + .word 4096 // Minimum extra paragraphs needed
121 + .word -1 // Maximum extra paragraphs needed
122 + .word (CODESZ+15)/16 // Initial (relative) SS value
123 + .word stacktop+4 // Initial SP value (+callf)
124 + .word 0 // Checksum
125 + .word EXEADRS(comstart) // Initial IP value
126 + .word 0xFFF0 // Initial (relative) CS value
127 +#ifdef EXE_ONLY
128 +// .word 0x001C // File address of relocation table
129 +// .word 0,0,0 // Overlay number
130 + .ascii "(SliTaz)"
131 +#else
132 +swap_floppy:
133 + .ascii "Next!"
134 + .byte 7,13,0 # swap detection needs 13, 0
135 +#endif
136 +#ifdef OLDCMDLINE
137 +# ifdef CMDLINE_SUPPORT
138 + .word 0 # 0xA33F
139 + .word 0 # stacktop
140 +# else
141 + .word 0xA33F
142 + .word stacktop
143 +# endif
144 +#endif
145 +#ifndef EXE_ONLY
146 +fdstart:
147 + pushw %dx
148 +#endif
149 +#endif
151 - movw $bugger_off_msg, %si
152 +LOADSEG = 0x8000 # 0x1000 multiple, up to 512K zImage
153 +LOADSZ = 0x10000
154 +#ifdef EXE_SUPPORT
155 +A20BUFFER = 0x68000 # a20 gate / himem.sys support
156 +#define USEA20BUFFER
157 +#endif
159 -msg_loop:
160 +#ifndef EXE_ONLY
161 +# bootsect_start:
162 +#ifdef EXE_SUPPORT
163 + call initregs
164 + cwd # floppy = head = 0
165 +#else
166 + INIT_REGS
167 +#endif
168 + popw %ds # %ds = 0
169 + movb setup_sects+0x7C00, %al # read bootsector + setup
170 + incw %ax # %ax = setup_sects+bootsect
171 + popw %fs # %fs = 0
172 +
173 +# Many BIOS's default disk parameter tables will not recognize
174 +# multi-sector reads beyond the maximum sector number specified
175 +# in the default diskette parameter tables - this may mean 7
176 +# sectors in some cases.
177 +#
178 +# Since single sector reads are slow and out of the question,
179 +# we must take care of this by creating new parameter tables
180 +# (for the first disk) in RAM. We can set the maximum sector
181 +# count to 36 - the most we will encounter on an ED 2.88.
182 +#
183 +# High doesn't hurt. Low does. Let's use the max: 63
184 +
185 + ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address
186 + popw %di
187 + pushw %es
188 + pushw %di
189 +#ifdef CMDLINE_SUPPORT
190 + movw $0, %bp # patched by installer (7C22)
191 +skipcmdline:
192 +#define cmd_line_ptr 0x22
193 +#endif
194 + movb $6, %cl # copy 12 bytes
195 + rep # don't worry about cld
196 + movsw # already done above
197 + pushw %ss
198 + popw %ds # now %ds = %es = %ss = INITSEG
199 + popl %fs:0x78(%bx) # update parameter table address
200 + movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
201 + cli
202 +
203 + xchg %ax, %di # sector count
204 +#ifndef FLOPPY_1440K_ONLY
205 + popw %ax # limits = 0
206 +#endif
207 + incw %cx # cylinder 0, sector 1, clear Z
208 + call read_first_sectors # read setup
209 +#endif
210 +loadsys:
211 + movw $0x200,%si
212 +type_of_loader = 0x10
213 +loadflags = 0x11
214 +heap_end_ptr = 0x24
215 + orw $0x8020, type_of_loader(%si) # loader type = 0x20 = bootsect-loader
216 + movb $(stacktop-0x300)/256, heap_end_ptr+1(%si)
217 + call puts_version # show which kernel we are loading
218 +
219 +#ifdef CMDLINE_SUPPORT
220 +# The cmdline can be entered and modifed at boot time.
221 +# Only characters before the cursor are passed to the kernel.
222 +
223 + xorw %si, %si
224 + orw cmd_line_ptr-7(%bx), %si
225 + jz nocmdline
226 + movw $0xA33F, cmd_line_ptr-2-7(%bx)
227 + call puts
228 +#if defined(MOVE_CMDLINE) || (defined(EDIT_CMDLINE) && defined(KEYBOARDLESS_SUPPORT))
229 + pushw %di
230 +#endif
231 +#ifdef EDIT_CMDLINE
232 +cmdlp:
233 + movb $0x20, %al # clear end of line
234 +cmdlpz:
235 + call putc # with Space
236 + subb $0x18, %al # and BackSpace
237 + jnc cmdlpz
238 + decw %si
239 +cmdget:
240 +#ifdef KEYBOARDLESS_SUPPORT
241 + call wait4key
242 +#else
243 + int $0x16
244 +#endif
245 + cbw # %ah = 0, get keyboard character
246 + cmpb $8, %al # BackSpace ?
247 + je cmdbs
248 + movb %al, (%si) # store char
249 + lodsw # %si += 2
250 +cmdbs:
251 + cmpw %si, cmd_line_ptr-7(%bx)
252 + je cmdget
253 + call putc
254 + cmpb $13, %al # Enter ?
255 + jne cmdlp
256 + movb %bh,-2(%si) # set end of string and remove CR
257 +endcmdline:
258 +#endif
259 +#ifdef MOVE_CMDLINE
260 + pushw %ss
261 + popw %es
262 + movw $0x8000, %di
263 + movw %di, %si
264 + xchgw %si, cmd_line_ptr-7(%bx)
265 + movb $0x2, %ch
266 + rep
267 + movsb
268 +#endif
269 +#if defined(EDIT_CMDLINE) || (defined(MOVE_CMDLINE) && defined(KEYBOARD_TIMEOUT))
270 + popw %di
271 +#endif
272 +nocmdline:
273 +#endif
274 +
275 +# This routine loads the system at address LOADSEG, making sure
276 +# no 64kB boundaries are crossed. We try to load it as fast as
277 +# possible, loading whole tracks whenever we can.
278 +
279 +ramdisk_image = 0x0218
280 +ramdisk_size = 0x021C
281 +bootsect_src_limit = 16
282 +bootsect_dst_limit = 24
283 +bootsect_src_base = 18
284 +bootsect_dst_base = 26 # bits 0..23
285 +bootsect_dst_base_hi = 31 # bits 24..31
286 + popw %bx # clear %bx
287 + movw %sp, %si # for bootsect_gdt
288 +init_gdt:
289 + decw bootsect_src_limit(%bx,%si) # max 64Kb
290 + movw $0x9300+(LOADSEG/0x1000), bootsect_src_base+2(%bx,%si)
291 + xorb $bootsect_dst_limit-bootsect_src_limit, %bl
292 + jne init_gdt
293 +#ifdef INITRD_SUPPORT
294 +#ifdef INITRD_AUTOADDR
295 + movb $0x88, %ah
296 + int $0x15
297 + jc NeedMoreRAM
298 + cmpw $0xC000, %ax # more than 48M ?
299 + jb NeedMoreRAM
300 + movw $ramdisk_image+2, %bx
301 + cmpw $0x100, (%bx) # already above 16M ?
302 + ja NeedMoreRAM
303 + movw $0x200, (%bx) # initramfs @ 32M
304 +NeedMoreRAM:
305 +#endif
306 +#ifdef INITRD_KEYWORD
307 +#ifdef INITRD_AUTOADDR
308 + pushl -2(%bx)
309 +#else
310 + pushl ramdisk_image
311 +#endif
312 + pushw $stacktop # start of cmdline
313 +#endif
314 + movw $syssize, %bx
315 + movb $5, %cl
316 +code32_start = 0x214
317 + movw code32_start+1, %ax # destination = 0x00100000 or 0x00010000
318 +initrdlp:
319 + movl (%bx), %ebx
320 + decl %ebx
321 + shrl %cl, %ebx
322 +#else
323 +code32_start = 0x214
324 + movw code32_start+1, %ax # destination = 0x00100000 or 0x00010000
325 + movl syssize, %ebx
326 + decl %ebx
327 + shrl $5, %ebx
328 +#endif
329 +#ifdef MORETHAN16M
330 + incl %ebx
331 +#else
332 + incw %bx
333 +#endif
334 +#ifdef USEA20BUFFER
335 + movw $0x00100000>>8, %di
336 +#endif
337 +syslp:
338 +#ifdef USEA20BUFFER
339 + cmpw %ax, %di
340 + jne nota20
341 + xorw $(0x00100000+A20BUFFER)>>8, %ax
342 +nota20:
343 +#endif
344 + movw %ax, bootsect_dst_base+1(%si)
345 +#ifdef MORETHAN16M
346 + movl $LOADSZ/512, %edi # size in sectors
347 + subl %edi, %ebx
348 +#else
349 + movw $LOADSZ/512, %di # size in sectors
350 + subw %di, %bx
351 +#endif
352 + pushf
353 + jnc not_last
354 + addw %bx, %di
355 +not_last:
356 + pushw %ax
357 + pushw %si
358 + pushw %bx
359 + xorw %bx,%bx
360 + pushw $LOADSEG
361 + popw %es
362 +#ifdef EXE_ONLY
363 + call read_sectors_dos
364 +#else
365 +patchcall:
366 + call read_sectors # update %bp
367 +#endif
368 + popw %bx
369 + popw %si
370 + movw %es, %cx # word count = LOADSZ/2 (= LOADSEG)
371 + movb $0x87, %ah
372 + pushw %ss
373 + popw %es # restore es
374 + int $0x15 # max 16M, maybe more...
375 + popw %ax
376 +#ifdef MORETHAN16M
377 + addw $0x100, %ax # next dest (ax+=LOADSZ/256)
378 + adcb %cl, bootsect_dst_base_hi(%si) # breaks 16M limit ?
379 +#else
380 + incb %ah # next dest (ax+=LOADSZ/256)
381 +#endif
382 +#ifdef USEA20BUFFER
383 + movw $(LOADSZ+A20BUFFER)>>8, %di
384 +#endif
385 + popf
386 + ja syslp
387 +#ifdef INITRD_SUPPORT
388 +initrdlp2:
389 + movw ramdisk_image+1,%ax
390 + movw $ramdisk_size,%bx
391 + movb $9, %cl
392 + cmpw %ax, bootsect_dst_base+1(%si)
393 + jb initrdlp
394 +#ifdef INITRD_KEYWORD
395 + xorl %eax, %eax
396 + xchgl %eax, (%bx)
397 + addl $3, %eax
398 + addl %eax, ramdisk_image-ramdisk_size(%bx)
399 + andb $0xFC, ramdisk_image-ramdisk_size(%bx)
400 + popw %si // current ptr in cmdline
401 +kwchk:
402 + movw $kwinitrd, %di
403 +kwchk2:
404 +#if 1
405 + cmpl $0x3D616776, (%si) // look for vga=
406 + jne notvga
407 +#if 1
408 + movw $0x312C, %ax
409 + subw 4(%si), %ax // support -9 .. -1 only !
410 + xchgb %al, %ah
411 + cmpw $-8, %ax
412 + jb notvga
413 + decw %ax
414 +#else
415 + movb $'0', %al
416 + subb 5(%si), %al // support -9 .. -1 only !
417 + cbw
418 +#endif
419 + movw %ax, vgamode
420 +notvga:
421 +#endif
422 + lodsb // look for initrd=
423 + orb %al, %al
424 + jz noinitrd
425 + subb (%di), %al
426 + //andb $0xDF, %al
427 + jne kwchk
428 + incw %di
429 + cmpb (%di), %al
430 + jne kwchk2
431 + mov %si, %dx // %ds:%dx filename
432 +chkeos:
433 lodsb
434 - andb %al, %al
435 - jz bs_die
436 + cmpb $0, %al
437 + je gotoes
438 + subb $0x20, %al
439 + jne chkeos
440 +gotoes:
441 + decw %si
442 + pushw (%si)
443 + movb %al, (%si) // set eos
444 + movb $0x3D, %ah // open, access = RO
445 + int $0x21
446 + popw (%si)
447 + jc noinitrd
448 + pushw %si // save ptr in cmdline
449 + xchgw %ax, %bp // fd
450 + movw $0x4202, %ax // lseek(SEEK_END)
451 + movw %bp, %bx
452 + xorw %cx, %cx
453 + cwd
454 + int $0x21
455 + pushw %dx
456 + pushw %ax
457 + popl ramdisk_size
458 + movw $0x4200, %ax // lseek(SEEK_SET)
459 + xorw %cx, %cx
460 + cwd
461 + int $0x21 // set %ax = %dx = 0
462 + jmp initrdlp2
463 +noinitrd:
464 + popl %eax // restore initial ramdisk address
465 + movl %eax, %edx
466 + xchgl %edx, ramdisk_image-ramdisk_size(%bx)
467 + subl %eax, %edx
468 + addl %edx, (%bx)
469 +#endif
470 +#endif
471 +#ifdef USEA20BUFFER
472 +#ifdef MORETHAN16M
473 +#ifdef INITRD_SUPPORT
474 + movb $0, bootsect_dst_base_hi(%si)
475 +#else
476 + movb %cl, bootsect_dst_base_hi(%si)
477 +#endif
478 +#endif
479 + movb $0x10, bootsect_dst_base+2(%si)
480 + movw $A20BUFFER/0x100, bootsect_src_base+1(%si)
481 + movb $0x87, %ah
482 + int $0x15
483 +#endif
484 +
485 +# This procedure turns off the floppy drive motor, so
486 +# that we enter the kernel in a known state, and
487 +# don't have to worry about it later.
488 +
489 +kill_motor:
490 + xchgw %ax, %di # reset FDC (%di < 128)
491 + int $0x13
492 +
493 +# After that (everything loaded), we jump to the setup-routine
494 +# loaded directly after the bootblock:
495 +# Segments are as follows: %ds = %ss = INITSEG
496 +
497 + ljmp $SETUPSEG, $0
498 +
499 +# read_sectors reads %di sectors into %es:0 buffer.
500 +# %es:0 is updated to the next memory location.
501 +# First, sectors are read sector by sector until
502 +# sector per track count is known. Then they are
503 +# read track by track.
504 +# Assume no error on first track.
505 +
506 +#ifndef EXE_ONLY
507 +
508 +#define FLOPPY_CYLINDERS 80
509 +#define FLOPPY_HEADS 2
510 +
511 +check_limits:
512 +#ifndef FLOPPY_1440K_ONLY
513 + popw %dx
514 + cmpb %al, %cl # max sector known ?
515 + ja next_head # no -> store it
516 +#endif
517 + pushaw
518 + int $0x13 # reset controler
519 + stc
520 + call putcdot # print '-'
521 +read_sectorslp:
522 + popaw
523 +bdendlp:
524 + pushw %dx # some bios break dx...
525 +#ifndef FLOPPY_1440K_ONLY
526 + pushw %ax # limits
527 + subb %cl, %al # sectors remaining in track
528 + ja tolastsect
529 + movb $1, %al # 1 sector mini
530 +tolastsect:
531 +#else
532 +#define FLOPPY_SECTORS 18
533 + mov $FLOPPY_SECTORS+1, %al
534 + subb %cl, %al # sectors remaining in track
535 + cbw
536 +#endif
537 + cmpw %di, %ax
538 + jb more1trk
539 + movw %di, %ax # sectors to read
540 +more1trk:
541 + pushw %ax # save context
542 + movb $2, %ah # cmd: read chs
543 + int $0x13
544 +#ifndef FLOPPY_1440K_ONLY
545 + popw %dx # save %ax
546 + popw %ax # limits
547 +#else
548 + popw %ax # restore context
549 + popw %dx
550 +#endif
551 + jc check_limits
552 +#ifndef FLOPPY_1440K_ONLY
553 + xchgw %ax, %bp
554 + addw %dx,%cx # next sector
555 + movw %cx, %gs
556 + addb %dl,%bh
557 + addb %dl,%bh # next location
558 + subw %dx,%di # update sector counter
559 + popw %dx
560 + jz putcdot
561 +#else
562 + addw %ax,%cx # next sector
563 + movw %cx, %gs
564 + addb %al,%bh
565 + addb %al,%bh # next location
566 + subw %ax,%di # update sector counter
567 + jz putcdot
568 +#endif
569 +read_sectors:
570 + movw %gs, %cx
571 +#ifndef FLOPPY_1440K_ONLY
572 +# al is last sector+1
573 +# ah is 0
574 + xchgw %ax, %bp
575 +#endif
576 +#ifndef FLOPPY_1440K_ONLY
577 + cmpb %al,%cl # reach sector limit ?
578 + jne bdendlp
579 +next_head:
580 + movb %cl,%al
581 +#else
582 + cmpb $FLOPPY_SECTORS+1,%cl # reach sector limit ?
583 + jne bdendlp
584 +#endif
585 + movb $1, %cl # first sector
586 +inc_head:
587 + xorb %cl, %dh # next head
588 + jne bdendlp # reach head limit ?
589 + incb %ch # next cylinder
590 +read_first_sectors:
591 + cmpb $FLOPPY_CYLINDERS,%ch # reach cylinder limit ?
592 + jne bdendlp
593 +next_floppy:
594 + movb $0,%ch # first cylinder
595 + pushaw
596 +#ifdef FLOPPY_ONLY
597 + movw $swap_floppy_tail,%si
598 +next_digit:
599 + decw %si
600 + movb (%si), %al
601 + incw %ax
602 + aaa
603 + movb %al, (%si)
604 + jc next_digit
605 +#endif
606 + movw $swap_floppy,%si
607 +#ifdef KEYBOARDLESS_SUPPORT
608 + pushw %bx
609 + call puts
610 + popw %bx
611 +waitfloppy:
612 + call wait
613 + jne waitfloppydone
614 + pushw %dx # some bios break dx...
615 + cbw
616 + int $0x13 # reset FDC
617 + movw $0x201,%ax
618 + int $0x13 # read first sector
619 + popw %dx
620 + rclb $1,%ah # floppy changed 06=>0D no error 00
621 + cmpb -2(%si), %ah # 0D then 00
622 + jne waitfloppy # no => try again
623 + incw %si
624 + decw %ax # was 0001 ?
625 + jne waitfloppy
626 +waitfloppydone:
627 +#else
628 + call puts
629 + cbw # %ah = 0, get keyboard character
630 + int $0x16
631 +#endif
632 + jmp read_sectorslp
633 +#endif
634 +
635 +#ifdef EXE_SUPPORT
636 +read_sectors_dos:
637 + xorw %dx, %dx // write to %ds:%dx, not %es:%bx
638 + call read_sectors_dosz
639 +read_sectors_dosz:
640 + pushw %es
641 + popw %ds
642 + movb $0x3F, %ah // read
643 + movw %di, %cx
644 + shlw $8, %cx // byte count / 2
645 + movw %bp, %bx
646 + int $0x21
647 + xchgw %ax, %dx
648 + pushw %ss
649 + popw %ds
650 +#endif
651 +
652 +putcdot:
653 + movb $'.'+3, %al // . = success, - = failure
654 +putclf:
655 + sbbb $3, %al
656 +putc:
657 movb $0xe, %ah
658 - movw $7, %bx
659 - int $0x10
660 - jmp msg_loop
661 + movw $7, %bx # one dot each 64k
662 + int $0x10
663 + cmp $0xd, %al # CR ?
664 + je putclf
665 + ret
667 -bs_die:
668 - # Allow the user to press a key, then reboot
669 - xorw %ax, %ax
670 +#ifdef KEYBOARDLESS_SUPPORT
671 +clock = 0x46C
672 +wait:
673 +wait4key:
674 + movw $clock, %di
675 +#define DELAY 5
676 + movb $257-(DELAY*182)/10, %fs:(%di)
677 +waitkbd:
678 + movw $0x10D, %ax # test keyboard, timeout => CR
679 + cmpb %fs:(%di),%ah
680 + je waitdone
681 int $0x16
682 - int $0x19
683 + jz waitkbd
684 + cbw
685 + int $0x16 # eat char
686 + movw %di, %fs # disable timeout
687 + incw %di # clear Z
688 +waitdone:
689 + ret
690 +#endif
692 - # int 0x19 should never return. In case it does anyway,
693 - # invoke the BIOS reset code...
694 - ljmp $0xf000,$0xfff0
695 +#ifdef EXE_SUPPORT
696 +comstart:
697 +#ifndef EXE_ONLY
698 + call initregs
699 +#else
700 + INIT_REGS
701 +#endif
702 + movb EXEADRS(setup_sects), %al # read bootsector + setup
703 + incw %ax
704 +#ifdef CMDLINE
705 + movw $0x80, %si
706 + movb (%si), %cl
707 + incw %si
708 +# ifdef OLDCMDLINE
709 +# ifdef CMDLINE_SUPPORT
710 + jcxz nocmdline
711 + movw %di, EXEADRS(0x22)
712 + movw $0xA33F, 0x7F(%si)
713 +# endif
714 +# endif
715 + rep
716 + movsb
717 +nocmdline:
718 + xchgw %ax, %di
719 +# ifdef HELP
720 + cmpb $'?', -1(%si)
721 + movw $EXEADRS(0x200), %si
722 + je puts_version
723 +# ifndef REALMODE_NOT_CHECKED
724 + smsww %ax
725 + andb $1, %al
726 + jne puts_version // real mode only...
727 +# endif
728 +# endif
729 +#else
730 + xchgw %ax, %di
731 +#endif
732 + movw 0x2C(%bx), %ds // DOS 3.0+
733 +loop1:
734 + incw %bx
735 + cmpw %cx, (%bx)
736 + jne loop1
737 + leaw 4(%bx), %dx // %ds:%dx filename
738 +#if !defined(REALMODE_NOT_CHECKED) && defined(CMDLINE) && defined(HELP)
739 + movb $0x3D, %ah // open, access = RO
740 +#else
741 + movw $0x3D00, %ax // open, access = RO
742 +#endif
743 + int $0x21
744 + jc dosexit
745 + xchgw %ax, %bp // fd
746 + call read_sectors_dos // update %ds
747 +#ifndef EXE_ONLY
748 + addb $read_sectors_dos-read_sectors, patchcall+1
749 +#endif
750 +#ifdef CMDLINE
751 +# ifdef OLDCMDLINE
752 + movw $0x202, %bx
753 + cmpw %bx, 0x206-0x202(%bx) # new cmdline for version >= 0x202
754 + jb oldcmdline
755 + movw $INITSEG/16+stacktop/256, cmd_line_ptr+1-0x202(%bx)
756 +# else
757 + movw $INITSEG/16+stacktop/256, cmd_line_ptr+1
758 +# endif
759 +oldcmdline:
760 +#endif
761 +// ljmp $INITSEG, $loadsys
762 + pushw %ds
763 + .byte 0x6A, loadsys-bootsect_start
764 + lretw
765 +#endif
766 +
767 +#define kernel_version_offset 0xE
768 +puts_version:
769 + addw kernel_version_offset(%si),%si # starting protocol 2.00, Kernel 1.3.73
770 +puts:
771 + movb $0xd, %al # CR
772 +putcs:
773 + call putc
774 + lodsb
775 + cmpb $0, %al # end of string is any byte <= 0
776 + jg putcs
777 +dosexit:
778 + ret
780 - .section ".bsdata", "a"
781 -bugger_off_msg:
782 - .ascii "Direct booting from floppy is no longer supported.\r\n"
783 - .ascii "Please use a boot loader program instead.\r\n"
784 - .ascii "\n"
785 - .ascii "Remove disk and press any key to reboot . . .\r\n"
786 - .byte 0
787 +#if !defined(FLOPPY_ONLY) && !defined(EXE_ONLY)
788 +initregs:
789 + popw %si
790 + INIT_REGS
791 + pushw %si # use new stack
792 + ret
793 +#endif
795 +#ifndef EXE_SUPPORT
796 +swap_floppy:
797 + .ascii "Insert floppy disk 001"
798 +swap_floppy_tail:
799 + .ascii " and press any key."
800 + .byte 7,13,0 # swap detection needs 13, 0
801 +#endif
803 +#ifdef INITRD_KEYWORD
804 +kwinitrd:
805 + .ascii "initrd="
806 + .byte 0
807 +#endif
808 # Kernel attributes; used by setup. This is part 1 of the
809 # header, from the old boot sector.