rev |
line source |
pascal@12556
|
1 --- linux-3.2.14/arch/x86/boot/header.S
|
pascal@12556
|
2 +++ linux-3.2.14/arch/x86/boot/header.S
|
pascal@15203
|
3 @@ -7,12 +7,14 @@
|
slaxemulator@8085
|
4 * modified by more people than can be counted
|
slaxemulator@8085
|
5 *
|
pascal@12556
|
6 * Rewritten as a common file by H. Peter Anvin (Apr 2007)
|
slaxemulator@8085
|
7 + * Rewritten Pascal Bellard (Nov 2009)
|
slaxemulator@8085
|
8 *
|
slaxemulator@8085
|
9 * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
|
slaxemulator@8085
|
10 * addresses must be multiplied by 16 to obtain their respective linear
|
pascal@15203
|
11 * addresses. To avoid confusion, linear addresses are written using leading
|
pascal@15203
|
12 * hex while segment addresses are written as segment:offset.
|
pascal@15203
|
13 *
|
pascal@15203
|
14 + * Assume protocol 2.00+ (kernel >= 1.3.73)
|
pascal@15203
|
15 */
|
pascal@15203
|
16
|
pascal@15203
|
17 #include <asm/segment.h>
|
pascal@15203
|
18 @@ -27,6 +29,8 @@
|
slaxemulator@8085
|
19
|
slaxemulator@8085
|
20 BOOTSEG = 0x07C0 /* original address of boot-sector */
|
slaxemulator@8085
|
21 SYSSEG = 0x1000 /* historical load address >> 4 */
|
slaxemulator@8085
|
22 +INITSEG = 0x9000 /* boot address >> 4 */
|
slaxemulator@8085
|
23 +SETUPSEG = 0x9020 /* setup address >> 4 */
|
slaxemulator@8085
|
24
|
slaxemulator@8085
|
25 #ifndef SVGA_MODE
|
slaxemulator@8085
|
26 #define SVGA_MODE ASK_VGA
|
pascal@15206
|
27 @@ -40,53 +44,480 @@
|
pascal@15203
|
28 #define ROOT_RDONLY 1
|
slaxemulator@8085
|
29 #endif
|
pascal@15203
|
30
|
pascal@15203
|
31 +setup_sects = 497
|
pascal@15203
|
32 +syssize = 500
|
pascal@15203
|
33 +cmd_line_ptr = 0x228
|
pascal@15203
|
34 +
|
pascal@15203
|
35 +/* some extra features */
|
pascal@15203
|
36 +#define EXE_SUPPORT real mode dos .exe file support (no himem.sys)
|
pascal@15203
|
37 +#define CMDLINE kernel >= 2.4
|
pascal@15203
|
38 +#define OLDCMDLINE kernel < 2.4
|
pascal@15203
|
39 +#define HELP display version for ? argument
|
pascal@15203
|
40 +#define MORETHAN16M up to 4Gb RAM, not 16Mb
|
pascal@15203
|
41 +#define KEYBOARDLESS_SUPPORT scan floppy swap each 5 seconds
|
pascal@15203
|
42 +#define FULL_ZIMAGE Up to 512K system zImage
|
pascal@15203
|
43 +
|
pascal@15203
|
44 +/* some limitations to reduce code size */
|
pascal@15203
|
45 +//#define FLOPPY_1440K_ONLY 1.44M floppies support only
|
pascal@15203
|
46 +
|
pascal@15203
|
47 .code16
|
pascal@15203
|
48 .section ".bstext", "ax"
|
slaxemulator@8085
|
49
|
slaxemulator@8085
|
50 .global bootsect_start
|
slaxemulator@8085
|
51 bootsect_start:
|
pascal@15203
|
52
|
pascal@15203
|
53 - # Normalize the start address
|
pascal@15203
|
54 - ljmp $BOOTSEG, $start2
|
pascal@15203
|
55 +#ifdef EXE_SUPPORT
|
pascal@15203
|
56 +#define CODESZ 0x8000
|
pascal@15203
|
57 +#define EXEADRS(x) x+0xE0
|
pascal@15203
|
58 +stacktop = 0x9E00 # in 0x8000 .. 0xA000
|
pascal@15203
|
59 + decw %bp // Magic number: MZ
|
pascal@15203
|
60 + popw %dx
|
pascal@15273
|
61 + jmp fdstart // Bytes on last page of file
|
pascal@15203
|
62 + .word (CODESZ+511)/512 // Pages in file
|
pascal@15203
|
63 + .word 0 // Relocations
|
pascal@15203
|
64 + .word 2 // Size of header in paragraphs
|
pascal@15203
|
65 + .word 4096 // Minimum extra paragraphs needed
|
pascal@15203
|
66 + .word -1 // Maximum extra paragraphs needed
|
pascal@15203
|
67 + .word (CODESZ+15)/16 // Initial (relative) SS value
|
pascal@15203
|
68 + .word stacktop // Initial SP value
|
pascal@15203
|
69 + .word 0 // Checksum
|
pascal@15203
|
70 + .word EXEADRS(comstart) // Initial IP value
|
pascal@15203
|
71 + .word 0xFFF0 // Initial (relative) CS value
|
pascal@15203
|
72 +// .word 0x001C // File address of relocation table
|
pascal@15203
|
73 +// .word 0,0,0 // Overlay number
|
pascal@15203
|
74 +swap_floppy:
|
pascal@15203
|
75 + .ascii "Next!"
|
pascal@15203
|
76 + .byte 7,13,0 # swap detection needs 13, 0
|
pascal@15203
|
77 +#ifdef OLDCMDLINE
|
pascal@15203
|
78 + .word 0xA33F
|
pascal@15203
|
79 + .word stacktop
|
pascal@15203
|
80 +#endif
|
pascal@15273
|
81 +fdstart:
|
pascal@15203
|
82 + pushw %dx
|
pascal@15203
|
83 +#endif
|
pascal@15203
|
84
|
pascal@15203
|
85 -start2:
|
pascal@15203
|
86 - movw %cs, %ax
|
pascal@15203
|
87 - movw %ax, %ds
|
pascal@15203
|
88 - movw %ax, %es
|
pascal@15203
|
89 - movw %ax, %ss
|
pascal@15203
|
90 - xorw %sp, %sp
|
pascal@15203
|
91 - sti
|
pascal@15203
|
92 - cld
|
pascal@15203
|
93 +#ifdef FULL_ZIMAGE
|
pascal@15203
|
94 +#define LOADSEG 0x8800 // Up to 512K zImage
|
pascal@15203
|
95 +#else
|
pascal@15203
|
96 +#define LOADSEG 0x8000 // 0x1000 multiple, up to 480K zImage
|
pascal@15203
|
97 +#endif
|
pascal@15203
|
98 +#define LOADSZ 0x8000
|
pascal@15203
|
99
|
pascal@15203
|
100 - movw $bugger_off_msg, %si
|
pascal@15273
|
101 +oldstart:
|
slaxemulator@8085
|
102 + cld # assume nothing
|
slaxemulator@8085
|
103 +stacktop = 0x9E00 # in 0x8000 .. 0xA000
|
pascal@12556
|
104 +zeroed = 48+12 # gdt + zeroed registers
|
slaxemulator@8085
|
105 + movw $stacktop-12-zeroed, %di # stacktop is an arbitrary value >=
|
slaxemulator@8085
|
106 + # length of bootsect + length of
|
slaxemulator@8085
|
107 + # setup + room for stack;
|
slaxemulator@8085
|
108 + # 12 is disk parm size.
|
slaxemulator@8085
|
109 + pushw $INITSEG
|
pascal@12556
|
110 + popw %ss # %ss contain INITSEG
|
slaxemulator@8085
|
111 + movw %di, %sp # put stack at INITSEG:stacktop-...
|
pascal@15203
|
112 +
|
slaxemulator@8085
|
113 +# Many BIOS's default disk parameter tables will not recognize
|
slaxemulator@8085
|
114 +# multi-sector reads beyond the maximum sector number specified
|
slaxemulator@8085
|
115 +# in the default diskette parameter tables - this may mean 7
|
slaxemulator@8085
|
116 +# sectors in some cases.
|
slaxemulator@8085
|
117 +#
|
slaxemulator@8085
|
118 +# Since single sector reads are slow and out of the question,
|
slaxemulator@8085
|
119 +# we must take care of this by creating new parameter tables
|
slaxemulator@8085
|
120 +# (for the first disk) in RAM. We can set the maximum sector
|
slaxemulator@8085
|
121 +# count to 36 - the most we will encounter on an ED 2.88.
|
slaxemulator@8085
|
122 +#
|
slaxemulator@8085
|
123 +# High doesn't hurt. Low does. Let's use the max: 63
|
pascal@15203
|
124 +
|
pascal@12556
|
125 + pushw %ss
|
pascal@12556
|
126 + popw %es # %es = %ss = INITSEG
|
slaxemulator@8085
|
127 + xorw %ax, %ax # %ax = 0
|
pascal@15203
|
128 +#ifdef EXE_SUPPORT
|
pascal@15203
|
129 + cwd # floppy = head = 0
|
pascal@15203
|
130 +#endif
|
slaxemulator@8085
|
131 + movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
|
slaxemulator@8085
|
132 + rep # don't worry about cld
|
slaxemulator@8085
|
133 + stosw # already done above
|
slaxemulator@8085
|
134 + popw %bx # offset = 0
|
slaxemulator@8085
|
135 + popw %ds # %ds = 0
|
pascal@12556
|
136 + popw %fs # %fs = 0
|
pascal@15203
|
137 +
|
slaxemulator@8085
|
138 + movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0)
|
slaxemulator@8085
|
139 + incw %ax
|
pascal@15203
|
140 +
|
pascal@12556
|
141 + ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address
|
slaxemulator@8085
|
142 + pushw %es
|
pascal@12556
|
143 + pushw %di
|
slaxemulator@8085
|
144 + movb $6, %cl # copy 12 bytes
|
slaxemulator@8085
|
145 + rep # don't worry about cld
|
slaxemulator@8085
|
146 + movsw # already done above
|
pascal@12556
|
147 + pushw %ss
|
slaxemulator@8085
|
148 + popw %ds # now %ds = %es = %ss = INITSEG
|
pascal@12556
|
149 + popl %fs:0x78(%bx) # update parameter table address
|
slaxemulator@8085
|
150 + movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
|
slaxemulator@8085
|
151 + cli
|
slaxemulator@8085
|
152 +
|
slaxemulator@8085
|
153 + xchg %ax, %di # sector count
|
slaxemulator@8085
|
154 + popw %ax # limits = 0
|
pascal@12556
|
155 + incw %cx # cylinder 0, sector 1, clear Z
|
slaxemulator@8085
|
156 + call read_first_sectors # read setup
|
pascal@15203
|
157 +loadsys:
|
slaxemulator@8085
|
158 + movw $0x200,%si
|
pascal@12556
|
159 +type_of_loader = 0x10
|
pascal@12556
|
160 +loadflags = 0x11
|
pascal@12556
|
161 +heap_end_ptr = 0x24
|
pascal@12556
|
162 + orw $0x8020, type_of_loader(%si) # loader type = 0x20 = bootsect-loader
|
pascal@12556
|
163 + movb $(stacktop-0x300)/256, heap_end_ptr+1(%si)
|
pascal@15203
|
164 + call puts_version # show which kernel we are loading
|
slaxemulator@8085
|
165 +
|
pascal@12556
|
166 +# This routine loads the system at address LOADSEG, making sure
|
slaxemulator@8085
|
167 +# no 64kB boundaries are crossed. We try to load it as fast as
|
slaxemulator@8085
|
168 +# possible, loading whole tracks whenever we can.
|
pascal@15203
|
169 +
|
slaxemulator@8085
|
170 +ramdisk_image = 0x0218
|
slaxemulator@8085
|
171 +ramdisk_size = 0x021C
|
pascal@12556
|
172 +bootsect_src_limit = 16
|
pascal@12556
|
173 +bootsect_dst_limit = 24
|
pascal@12556
|
174 +bootsect_src_base = 18
|
pascal@15203
|
175 +bootsect_dst_base = 26 # bits 0..23
|
pascal@15203
|
176 +bootsect_dst_base_hi = 31 # bits 24..31
|
pascal@12556
|
177 + popw %bx # clear %bx
|
slaxemulator@8085
|
178 + movw %sp, %si # for bootsect_gdt
|
pascal@12556
|
179 +init_gdt:
|
pascal@12556
|
180 + decw bootsect_src_limit(%bx,%si) # max 64Kb
|
pascal@15203
|
181 +#if LOADSEG % 0x1000 == 0
|
pascal@15203
|
182 + movw $0x9300+(LOADSEG/0x1000), bootsect_src_base+2(%bx,%si)
|
pascal@15203
|
183 +#else
|
pascal@15203
|
184 + movl $0x93000000+(LOADSEG*0x10), bootsect_src_base(%bx,%si)
|
pascal@15203
|
185 +#endif
|
pascal@12556
|
186 + xorb $bootsect_dst_limit-bootsect_src_limit, %bl
|
pascal@12556
|
187 + jne init_gdt
|
pascal@12556
|
188 +code32_start = 0x214
|
pascal@15203
|
189 +#ifdef MORETHAN16M
|
pascal@15203
|
190 + movb code32_start+3, %al # destination = 0x00100000 or 0x00010000
|
pascal@15203
|
191 + movb %al, bootsect_dst_base_hi(%si) # load high (> 16M) ?
|
pascal@15203
|
192 +#endif
|
pascal@12556
|
193 + movw code32_start+1, %ax # destination = 0x00100000 or 0x00010000
|
pascal@15203
|
194 + movl syssize, %ebx
|
pascal@12556
|
195 + decl %ebx
|
pascal@15203
|
196 + shrl $5, %ebx
|
pascal@15203
|
197 + incl %ebx
|
slaxemulator@8085
|
198 +syslp:
|
pascal@12556
|
199 + movw %ax, bootsect_dst_base+1(%si)
|
pascal@15203
|
200 + movw $LOADSZ/512, %di # size in sectors
|
pascal@15203
|
201 + subl $LOADSZ/512, %ebx
|
slaxemulator@8085
|
202 + pushf
|
slaxemulator@8085
|
203 + jnc not_last
|
pascal@12556
|
204 + addw %bx, %di
|
slaxemulator@8085
|
205 +not_last:
|
slaxemulator@8085
|
206 + pushw %ax
|
slaxemulator@8085
|
207 + pushw %si
|
pascal@12556
|
208 + pushw %bx
|
pascal@12556
|
209 + xorw %bx,%bx
|
pascal@15203
|
210 + pushw $LOADSEG
|
pascal@15203
|
211 + popw %es
|
pascal@15203
|
212 +patchcall:
|
pascal@12556
|
213 + call read_sectors # update %bp
|
pascal@12556
|
214 + popw %bx
|
slaxemulator@8085
|
215 + popw %si
|
pascal@15203
|
216 + movw $LOADSZ/2, %cx # word count
|
slaxemulator@8085
|
217 + movb $0x87, %ah
|
pascal@12556
|
218 + pushw %ss
|
pascal@12556
|
219 + popw %es # restore es
|
pascal@15203
|
220 + int $0x15 # max 16M, maybe more...
|
slaxemulator@8085
|
221 + popw %ax
|
pascal@15203
|
222 + addw $LOADSZ/256, %ax # next dest
|
pascal@15203
|
223 +#ifdef MORETHAN16M
|
pascal@15203
|
224 + adcb %cl, bootsect_dst_base_hi(%si) # breaks 16M limit ?
|
pascal@15203
|
225 +#endif
|
slaxemulator@8085
|
226 + popf
|
slaxemulator@8085
|
227 + ja syslp
|
pascal@12556
|
228
|
pascal@15203
|
229 -msg_loop:
|
pascal@15203
|
230 - lodsb
|
pascal@15203
|
231 - andb %al, %al
|
pascal@15203
|
232 - jz bs_die
|
pascal@15203
|
233 - movb $0xe, %ah
|
pascal@15203
|
234 - movw $7, %bx
|
pascal@15203
|
235 - int $0x10
|
pascal@15203
|
236 - jmp msg_loop
|
pascal@15203
|
237 -
|
pascal@15203
|
238 -bs_die:
|
pascal@15203
|
239 - # Allow the user to press a key, then reboot
|
pascal@15203
|
240 - xorw %ax, %ax
|
slaxemulator@8085
|
241 +# This procedure turns off the floppy drive motor, so
|
slaxemulator@8085
|
242 +# that we enter the kernel in a known state, and
|
slaxemulator@8085
|
243 +# don't have to worry about it later.
|
pascal@15203
|
244 +
|
pascal@12556
|
245 +kill_motor:
|
pascal@12556
|
246 + xchgw %ax, %di # reset FDC (%di < 128)
|
pascal@12556
|
247 + int $0x13
|
slaxemulator@8085
|
248 +
|
slaxemulator@8085
|
249 +# After that (everything loaded), we jump to the setup-routine
|
slaxemulator@8085
|
250 +# loaded directly after the bootblock:
|
slaxemulator@8085
|
251 +# Segments are as follows: %ds = %ss = INITSEG
|
slaxemulator@8085
|
252 +
|
slaxemulator@8085
|
253 + ljmp $SETUPSEG, $0
|
slaxemulator@8085
|
254 +
|
slaxemulator@8085
|
255 +# read_sectors reads %di sectors into %es:0 buffer.
|
slaxemulator@8085
|
256 +# %es:0 is updated to the next memory location.
|
slaxemulator@8085
|
257 +# First, sectors are read sector by sector until
|
slaxemulator@8085
|
258 +# sector per track count is known. Then they are
|
slaxemulator@8085
|
259 +# read track by track.
|
slaxemulator@8085
|
260 +# Assume no error on first track.
|
slaxemulator@8085
|
261 +
|
slaxemulator@8085
|
262 +#define FLOPPY_CYLINDERS 80 /* 80 cylinders minimum */
|
slaxemulator@8085
|
263 +#define FLOPPY_HEADS 2 /* 2 heads minimum */
|
slaxemulator@8085
|
264 +#define FLOPPY_SECTORS 18 /* 18 sectors minimum */
|
slaxemulator@8085
|
265 +
|
slaxemulator@8085
|
266 +check_limits:
|
pascal@15203
|
267 +#ifndef FLOPPY_1440K_ONLY
|
pascal@15203
|
268 + popw %dx
|
slaxemulator@8085
|
269 + cmpb $FLOPPY_SECTORS+1, %cl # 18 sectors minimum
|
slaxemulator@8085
|
270 + jb check_head
|
slaxemulator@8085
|
271 + cmpb %al, %cl # max sector known ?
|
slaxemulator@8085
|
272 + ja next_head # no -> store it
|
slaxemulator@8085
|
273 +check_head:
|
slaxemulator@8085
|
274 + cmpb $FLOPPY_HEADS, %dh # 2 heads minimum
|
slaxemulator@8085
|
275 + jb check_cylinder
|
slaxemulator@8085
|
276 + cmpb %ah, %dh # max head known ?
|
slaxemulator@8085
|
277 + ja next_cylinder # no -> store it
|
slaxemulator@8085
|
278 +check_cylinder:
|
pascal@15203
|
279 +#endif
|
slaxemulator@8085
|
280 + pushaw
|
pascal@15203
|
281 +#ifndef FLOPPY_1440K_ONLY
|
slaxemulator@8085
|
282 + cbw # %ah = 0
|
pascal@15203
|
283 +#endif
|
slaxemulator@8085
|
284 + int $0x13 # reset controler
|
pascal@15203
|
285 + stc
|
pascal@15203
|
286 + call putcdot # print '-'
|
pascal@15203
|
287 +read_sectorslp:
|
slaxemulator@8085
|
288 + popaw
|
pascal@15203
|
289 +bdendlp:
|
slaxemulator@8085
|
290 + pushw %dx # some bios break dx...
|
pascal@15203
|
291 +#ifndef FLOPPY_1440K_ONLY
|
slaxemulator@8085
|
292 + pushw %ax # limits
|
slaxemulator@8085
|
293 + subb %cl, %al # sectors remaining in track
|
slaxemulator@8085
|
294 + ja tolastsect
|
slaxemulator@8085
|
295 + movb $1, %al # 1 sector mini
|
slaxemulator@8085
|
296 +tolastsect:
|
pascal@15203
|
297 +#else
|
pascal@15203
|
298 + mov $FLOPPY_SECTORS+1, %al
|
pascal@15203
|
299 + subb %cl, %al # sectors remaining in track
|
pascal@15203
|
300 +#endif
|
slaxemulator@8085
|
301 + cbw
|
slaxemulator@8085
|
302 + cmpw %di, %ax
|
slaxemulator@8085
|
303 + jb more1trk
|
slaxemulator@8085
|
304 + movw %di, %ax # sectors to read
|
slaxemulator@8085
|
305 +more1trk:
|
slaxemulator@8085
|
306 + pushw %ax # save context
|
slaxemulator@8085
|
307 + movb $2, %ah # cmd: read chs
|
slaxemulator@8085
|
308 + int $0x13
|
pascal@15203
|
309 +#ifndef FLOPPY_1440K_ONLY
|
pascal@15203
|
310 + popw %dx # save %ax
|
slaxemulator@8085
|
311 + popw %ax # limits
|
pascal@15203
|
312 +#else
|
pascal@15203
|
313 + popw %ax # restore context
|
slaxemulator@8085
|
314 + popw %dx
|
pascal@15203
|
315 +#endif
|
slaxemulator@8085
|
316 + jc check_limits
|
pascal@15203
|
317 +#ifndef FLOPPY_1440K_ONLY
|
slaxemulator@8085
|
318 + xchgw %ax, %bp
|
pascal@15203
|
319 + addw %dx,%cx # next sector
|
pascal@12556
|
320 + movw %cx, %gs
|
pascal@15203
|
321 + addb %dl,%bh
|
pascal@15203
|
322 + addb %dl,%bh # next location
|
pascal@15203
|
323 + subw %dx,%di # update sector counter
|
pascal@15203
|
324 + popw %dx
|
slaxemulator@8085
|
325 + jz putcdot
|
pascal@15203
|
326 +#else
|
pascal@15203
|
327 + addw %ax,%cx # next sector
|
pascal@15203
|
328 + movw %cx, %gs
|
pascal@15203
|
329 + addb %al,%bh
|
pascal@15203
|
330 + addb %al,%bh # next location
|
pascal@15203
|
331 + subw %ax,%di # update sector counter
|
pascal@15203
|
332 + jz putcdot
|
pascal@15203
|
333 +#endif
|
slaxemulator@8085
|
334 +read_sectors:
|
pascal@12556
|
335 + movw %gs, %cx
|
pascal@15203
|
336 +#ifndef FLOPPY_1440K_ONLY
|
pascal@12556
|
337 +# al is last sector+1
|
pascal@12556
|
338 +# ah is last cylinder+1
|
slaxemulator@8085
|
339 + xchgw %ax, %bp
|
pascal@15203
|
340 +#endif
|
pascal@15203
|
341 +#ifndef FLOPPY_1440K_ONLY
|
slaxemulator@8085
|
342 + cmpb %al,%cl # reach sector limit ?
|
slaxemulator@8085
|
343 + jne bdendlp
|
slaxemulator@8085
|
344 +next_head:
|
slaxemulator@8085
|
345 + movb %cl,%al
|
pascal@15203
|
346 +#else
|
pascal@15203
|
347 + cmpb $FLOPPY_SECTORS+1,%cl # reach sector limit ?
|
pascal@15203
|
348 + jne bdendlp
|
pascal@15203
|
349 +#endif
|
slaxemulator@8085
|
350 + incb %dh # next head
|
slaxemulator@8085
|
351 + movb $1,%cl # first sector
|
pascal@15203
|
352 +#ifndef FLOPPY_1440K_ONLY
|
slaxemulator@8085
|
353 + cmpb %ah, %dh # reach head limit ?
|
slaxemulator@8085
|
354 + jne bdendlp
|
slaxemulator@8085
|
355 +next_cylinder:
|
slaxemulator@8085
|
356 + movb %dh,%ah
|
pascal@15203
|
357 +#else
|
pascal@15203
|
358 + cmpb %cl,%dh # reach head limit ?
|
pascal@15203
|
359 + je bdendlp
|
pascal@15203
|
360 +#endif
|
slaxemulator@8085
|
361 +# NOTE : support 256 cylinders max
|
slaxemulator@8085
|
362 + incb %ch # next cylinder
|
slaxemulator@8085
|
363 +read_first_sectors:
|
pascal@15203
|
364 + cmpb $FLOPPY_CYLINDERS,%ch # reach cylinder limit ?
|
slaxemulator@8085
|
365 + movb $0,%dh # first head
|
pascal@12556
|
366 + jne bdendlp
|
slaxemulator@8085
|
367 +next_floppy:
|
slaxemulator@8085
|
368 + movb $0,%ch # first cylinder
|
slaxemulator@8085
|
369 + pushaw
|
slaxemulator@8085
|
370 + movw $swap_floppy,%si
|
pascal@15203
|
371 +#ifdef KEYBOARDLESS_SUPPORT
|
slaxemulator@8085
|
372 + pushw %bx
|
pascal@12556
|
373 + call puts
|
slaxemulator@8085
|
374 + popw %bx
|
slaxemulator@8085
|
375 +waitfloppy:
|
slaxemulator@8085
|
376 + call wait
|
slaxemulator@8085
|
377 + jne waitfloppydone
|
slaxemulator@8085
|
378 + pushw %dx # some bios break dx...
|
slaxemulator@8085
|
379 + cbw
|
slaxemulator@8085
|
380 + int $0x13 # reset FDC
|
slaxemulator@8085
|
381 + movw $0x201,%ax
|
slaxemulator@8085
|
382 + int $0x13 # read first sector
|
slaxemulator@8085
|
383 + popw %dx
|
slaxemulator@8085
|
384 + rclb $1,%ah # floppy changed 06=>0D no error 00
|
slaxemulator@8085
|
385 + cmpb -2(%si), %ah # 0D then 00
|
slaxemulator@8085
|
386 + jne waitfloppy # no => try again
|
slaxemulator@8085
|
387 + incw %si
|
pascal@15203
|
388 + decw %ax # was 0001 ?
|
slaxemulator@8085
|
389 + jne waitfloppy
|
slaxemulator@8085
|
390 +waitfloppydone:
|
pascal@15203
|
391 +#else
|
pascal@15203
|
392 + call puts
|
pascal@15203
|
393 + cbw # %ah = 0, get keyboard character
|
pascal@15203
|
394 int $0x16
|
pascal@15203
|
395 - int $0x19
|
pascal@15203
|
396 +#endif
|
slaxemulator@8085
|
397 + jmp read_sectorslp
|
slaxemulator@8085
|
398 +
|
pascal@15203
|
399 +#ifdef EXE_SUPPORT
|
pascal@15203
|
400 +read_sectors_dos:
|
pascal@15203
|
401 + pushw %es
|
pascal@15203
|
402 + popw %ds
|
pascal@15203
|
403 + movb $0x3F, %ah // read
|
pascal@15203
|
404 + cwd // write to %ds:%dx, not %es:%bx
|
pascal@15203
|
405 + movw %di, %cx
|
pascal@15203
|
406 + shlw $9, %cx // byte count
|
pascal@15203
|
407 + movw %bp, %bx
|
pascal@15203
|
408 + int $0x21
|
pascal@15203
|
409 + pushw %ss
|
pascal@15203
|
410 + popw %ds
|
pascal@15203
|
411 +#endif
|
pascal@15203
|
412
|
pascal@15203
|
413 - # int 0x19 should never return. In case it does anyway,
|
pascal@15203
|
414 - # invoke the BIOS reset code...
|
pascal@15203
|
415 - ljmp $0xf000,$0xfff0
|
pascal@15203
|
416 -
|
pascal@15203
|
417 - .section ".bsdata", "a"
|
pascal@15203
|
418 -bugger_off_msg:
|
pascal@15203
|
419 - .ascii "Direct booting from floppy is no longer supported.\r\n"
|
pascal@15203
|
420 - .ascii "Please use a boot loader program instead.\r\n"
|
pascal@15203
|
421 - .ascii "\n"
|
pascal@15203
|
422 - .ascii "Remove disk and press any key to reboot . . .\r\n"
|
pascal@15203
|
423 - .byte 0
|
slaxemulator@8085
|
424 +putcdot:
|
pascal@15203
|
425 + movb $'.'+3, %al // . = success, - = failure
|
slaxemulator@8085
|
426 +putclf:
|
pascal@15203
|
427 + sbbb $3, %al
|
slaxemulator@8085
|
428 +putc:
|
slaxemulator@8085
|
429 + movb $0xe, %ah
|
slaxemulator@8085
|
430 + movw $7, %bx # one dot each 64k
|
slaxemulator@8085
|
431 + int $0x10
|
slaxemulator@8085
|
432 + cmp $0xd, %al # CR ?
|
slaxemulator@8085
|
433 + je putclf
|
slaxemulator@8085
|
434 + ret
|
slaxemulator@8085
|
435 +
|
pascal@15203
|
436 +#ifdef KEYBOARDLESS_SUPPORT
|
slaxemulator@8085
|
437 +clock = 0x46C
|
slaxemulator@8085
|
438 +wait:
|
slaxemulator@8085
|
439 +wait4key:
|
slaxemulator@8085
|
440 + movw $clock, %di
|
slaxemulator@8085
|
441 +#define DELAY 5
|
pascal@15203
|
442 + movb $257-(DELAY*182)/10, %fs:(%di)
|
slaxemulator@8085
|
443 +waitkbd:
|
slaxemulator@8085
|
444 + movw $0x10D, %ax # test keyboard, timeout => CR
|
pascal@15203
|
445 + cmpb %fs:(%di),%ah
|
slaxemulator@8085
|
446 + je waitdone
|
pascal@12556
|
447 + int $0x16
|
slaxemulator@8085
|
448 + jz waitkbd
|
slaxemulator@8085
|
449 + cbw
|
slaxemulator@8085
|
450 + int $0x16 # eat char
|
pascal@12556
|
451 + movw %di, %fs # disable timeout
|
slaxemulator@8085
|
452 + incw %di # clear Z
|
slaxemulator@8085
|
453 +waitdone:
|
slaxemulator@8085
|
454 + ret
|
pascal@15203
|
455 +#endif
|
pascal@15203
|
456
|
pascal@15203
|
457 +#ifdef EXE_SUPPORT
|
pascal@15203
|
458 +comstart:
|
pascal@15203
|
459 + cld # assume nothing
|
pascal@15203
|
460 + pushw $INITSEG
|
pascal@15203
|
461 + popw %es
|
pascal@15203
|
462 + pushw %es
|
pascal@15203
|
463 + popw %ss
|
pascal@15203
|
464 +#ifdef CMDLINE
|
pascal@15203
|
465 + movw %sp, %di
|
pascal@15203
|
466 + movw $0x80, %si
|
pascal@15203
|
467 + lodsb
|
pascal@15203
|
468 + cbw
|
pascal@15203
|
469 + xchgw %ax, %cx
|
pascal@15203
|
470 + rep
|
pascal@15203
|
471 + movsb
|
pascal@15203
|
472 + movb $(48+2)/2, %cl
|
pascal@15203
|
473 + xorw %bx, %bx
|
pascal@15203
|
474 +clearstacklp:
|
pascal@15203
|
475 + pushw %bx
|
pascal@15203
|
476 + loop clearstacklp
|
pascal@15203
|
477 +# ifdef HELP
|
pascal@15203
|
478 + cmpb $'?', -1(%si)
|
pascal@15203
|
479 + movw $EXEADRS(0x200), %si
|
pascal@15203
|
480 + movw setup_sects-0x200(%si), %di // bits 0..6
|
pascal@15203
|
481 + je puts_version
|
pascal@15203
|
482 + smsww %ax
|
pascal@15203
|
483 + andb $1, %al
|
pascal@15203
|
484 + jne puts_version // real mode only...
|
pascal@15203
|
485 +# endif
|
pascal@15203
|
486 +#else
|
pascal@15203
|
487 + movw $(48+2)/2, %cx
|
pascal@15203
|
488 + xorw %bx, %bx
|
pascal@15203
|
489 +clearstacklp:
|
pascal@15203
|
490 + pushw %bx
|
pascal@15203
|
491 + loop clearstacklp
|
pascal@15203
|
492 +#endif
|
pascal@15203
|
493 +#if !defined(CMDLINE) || !defined(HELP)
|
pascal@15203
|
494 + movw EXEADRS(setup_sects), %di // bits 0..6
|
pascal@15203
|
495 + movb $0, %al // access = RO
|
pascal@15203
|
496 +#endif
|
pascal@15203
|
497 + movw 0x2C(%bx), %ds // DOS 3.0+
|
pascal@15203
|
498 +loop1:
|
pascal@15203
|
499 + incw %bx
|
pascal@15203
|
500 + cmpw %cx, (%bx)
|
pascal@15203
|
501 + jne loop1
|
pascal@15203
|
502 + leaw 4(%bx), %dx // %ds:%dx filename
|
pascal@15203
|
503 + movb $0x3D, %ah // open, access = RO
|
pascal@15203
|
504 + int $0x21
|
pascal@15203
|
505 + jc dosexit
|
pascal@15203
|
506 + xchgw %ax, %bp // fd
|
pascal@15203
|
507 + incw %di
|
pascal@15203
|
508 + call read_sectors_dos // update %ds
|
pascal@15203
|
509 + addb $read_sectors_dos-read_sectors, patchcall+1
|
pascal@15203
|
510 +#ifdef CMDLINE
|
pascal@15203
|
511 +# ifdef OLDCMDLINE
|
pascal@15203
|
512 + movw $0x202, %bx
|
pascal@15203
|
513 + cmpw %bx, 0x206-0x202(%bx)
|
pascal@15203
|
514 + jb oldcmdline
|
pascal@15203
|
515 + movw $INITSEG/16+stacktop/256, cmd_line_ptr+1-0x202(%bx)
|
pascal@15203
|
516 +oldcmdline:
|
pascal@15203
|
517 +# else
|
pascal@15203
|
518 + movw $INITSEG/16+stacktop/256, cmd_line_ptr+1
|
pascal@15203
|
519 +# endif
|
pascal@15203
|
520 +#endif
|
pascal@15203
|
521 + ljmp $INITSEG, $loadsys
|
pascal@15206
|
522 +#else
|
pascal@15206
|
523 +swap_floppy:
|
pascal@15206
|
524 + .ascii "Next!"
|
pascal@15206
|
525 + .byte 7,13,0 # swap detection needs 13, 0
|
pascal@15203
|
526 +#endif
|
pascal@15203
|
527 +
|
pascal@15203
|
528 +#define kernel_version 0xE
|
pascal@15203
|
529 +puts_version:
|
pascal@15203
|
530 + addw kernel_version(%si),%si # starting protocol 2.00, Kernel 1.3.73
|
pascal@15203
|
531 +puts:
|
pascal@15203
|
532 + movb $0xd, %al # CR
|
pascal@15203
|
533 +putcs:
|
pascal@15203
|
534 + call putc
|
pascal@15203
|
535 + lodsb
|
pascal@15203
|
536 + cmpb $0, %al # end of string is any byte <= 0
|
pascal@15203
|
537 + jg putcs
|
pascal@15203
|
538 +dosexit:
|
pascal@15203
|
539 + ret
|
slaxemulator@8085
|
540
|
slaxemulator@8085
|
541 # Kernel attributes; used by setup. This is part 1 of the
|
slaxemulator@8085
|
542 # header, from the old boot sector.
|