1 | ; -*- fundamental -*- (asm-mode sucks) |
---|
2 | ; ----------------------------------------------------------------------- |
---|
3 | ; |
---|
4 | ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
---|
5 | ; Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin |
---|
6 | ; |
---|
7 | ; This program is free software; you can redistribute it and/or modify |
---|
8 | ; it under the terms of the GNU General Public License as published by |
---|
9 | ; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
---|
10 | ; Boston MA 02110-1301, USA; either version 2 of the License, or |
---|
11 | ; (at your option) any later version; incorporated herein by reference. |
---|
12 | ; |
---|
13 | ; ----------------------------------------------------------------------- |
---|
14 | |
---|
15 | ; |
---|
16 | ; diskfs.inc |
---|
17 | ; |
---|
18 | ; Common code for conventional disk-based filesystems |
---|
19 | ; |
---|
20 | |
---|
21 | ; |
---|
22 | ; Some semi-configurable constants... change on your own risk. |
---|
23 | ; |
---|
24 | NULLFILE equ 0 ; Null character == empty filename |
---|
25 | NULLOFFSET equ 0 ; Position in which to look |
---|
26 | retry_count equ 16 ; How patient are we with the disk? |
---|
27 | %assign HIGHMEM_SLOP 0 ; Avoid this much memory near the top |
---|
28 | LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with |
---|
29 | |
---|
30 | ; This indicates the general format of the last few bytes in the boot sector |
---|
31 | BS_MAGIC_VER equ 0x1b << 9 |
---|
32 | |
---|
33 | MIN_SECTOR_SHIFT equ 9 |
---|
34 | MIN_SECTOR_SIZE equ (1 << MIN_SECTOR_SHIFT) |
---|
35 | |
---|
36 | ; --------------------------------------------------------------------------- |
---|
37 | ; BEGIN CODE |
---|
38 | ; --------------------------------------------------------------------------- |
---|
39 | |
---|
40 | ; |
---|
41 | ; Memory below this point is reserved for the BIOS and the MBR |
---|
42 | ; |
---|
43 | section .earlybss |
---|
44 | global trackbuf:data hidden |
---|
45 | trackbufsize equ 8192 |
---|
46 | trackbuf resb trackbufsize ; Track buffer goes here |
---|
47 | ; ends at 2800h |
---|
48 | |
---|
49 | ; |
---|
50 | ; Common bootstrap code for disk-based derivatives |
---|
51 | ; |
---|
52 | %include "diskstart.inc" |
---|
53 | |
---|
54 | ; |
---|
55 | ; Now, everything is "up and running"... patch kaboom for more |
---|
56 | ; verbosity and using the full screen system |
---|
57 | ; |
---|
58 | ; E9 = JMP NEAR |
---|
59 | mov di,kaboom.patch |
---|
60 | mov al,0e9h |
---|
61 | stosb |
---|
62 | mov ax,kaboom2-2 |
---|
63 | sub ax,di |
---|
64 | stosw |
---|
65 | |
---|
66 | ; |
---|
67 | ; If we get to this point ldlinux.c32 failed to run. There's nothing |
---|
68 | ; left to do but inform that user that something went wrong. |
---|
69 | ; |
---|
70 | enter_command: |
---|
71 | auto_boot: |
---|
72 | jmp kaboom |
---|
73 | |
---|
74 | section .bss16 |
---|
75 | alignb 4 |
---|
76 | ThisKbdTo resd 1 ; Temporary holder for KbdTimeout |
---|
77 | ThisTotalTo resd 1 ; Temporary holder for TotalTimeout |
---|
78 | KernelExtPtr resw 1 ; During search, final null pointer |
---|
79 | FuncFlag resb 1 ; Escape sequences received from keyboard |
---|
80 | KernelType resb 1 ; Kernel type, from vkernel, if known |
---|
81 | global KernelName |
---|
82 | KernelName resb FILENAME_MAX ; Mangled name for kernel |
---|
83 | |
---|
84 | section .text16 |
---|
85 | ; |
---|
86 | ; COM32 vestigial data structure |
---|
87 | ; |
---|
88 | %include "com32.inc" |
---|
89 | |
---|
90 | ; |
---|
91 | ; Common local boot code |
---|
92 | ; |
---|
93 | %include "localboot.inc" |
---|
94 | |
---|
95 | ; |
---|
96 | ; kaboom2: once everything is loaded, replace the part of kaboom |
---|
97 | ; starting with "kaboom.patch" with this part |
---|
98 | |
---|
99 | kaboom2: |
---|
100 | mov si,err_bootfailed |
---|
101 | pm_call pm_writestr |
---|
102 | cmp byte [kaboom.again+1],18h ; INT 18h version? |
---|
103 | je .int18 |
---|
104 | pm_call pm_getchar |
---|
105 | pm_call syslinux_force_text_mode |
---|
106 | int 19h ; And try once more to boot... |
---|
107 | .norge: jmp short .norge ; If int 19h returned; this is the end |
---|
108 | .int18: |
---|
109 | pm_call syslinux_force_text_mode |
---|
110 | int 18h |
---|
111 | .noreg: jmp short .noreg ; Nynorsk |
---|
112 | |
---|
113 | ; ----------------------------------------------------------------------------- |
---|
114 | ; Common modules |
---|
115 | ; ----------------------------------------------------------------------------- |
---|
116 | |
---|
117 | %include "common.inc" ; Universal modules |
---|
118 | |
---|
119 | ; ----------------------------------------------------------------------------- |
---|
120 | ; Begin data section |
---|
121 | ; ----------------------------------------------------------------------------- |
---|
122 | |
---|
123 | section .data16 |
---|
124 | global copyright_str |
---|
125 | copyright_str db ' Copyright (C) 1994-' |
---|
126 | asciidec YEAR |
---|
127 | db ' H. Peter Anvin et al', CR, LF, 0 |
---|
128 | err_bootfailed db CR, LF, 'Boot failed: please change disks and press ' |
---|
129 | db 'a key to continue.', CR, LF, 0 |
---|
130 | |
---|
131 | ; |
---|
132 | ; Misc initialized (data) variables |
---|
133 | ; |
---|
134 | %ifdef debug ; This code for debugging only |
---|
135 | debug_magic dw 0D00Dh ; Debug code sentinel |
---|
136 | %endif |
---|