rev |
line source |
slaxemulator@8085
|
1 --- linux-2.6.30.6/arch/x86/boot/header.S
|
slaxemulator@8085
|
2 +++ linux-2.6.30.6/arch/x86/boot/header.S
|
slaxemulator@8085
|
3 @@ -6,7 +6,7 @@
|
slaxemulator@8085
|
4 * Based on bootsect.S and setup.S
|
slaxemulator@8085
|
5 * modified by more people than can be counted
|
slaxemulator@8085
|
6 *
|
slaxemulator@8085
|
7 - * Rewritten as a common file by H. Peter Anvin (Apr 2007)
|
slaxemulator@8085
|
8 + * Rewritten Pascal Bellard (Nov 2009)
|
slaxemulator@8085
|
9 *
|
slaxemulator@8085
|
10 * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
|
slaxemulator@8085
|
11 * addresses must be multiplied by 16 to obtain their respective linear
|
slaxemulator@8085
|
12 @@ -27,6 +27,8 @@
|
slaxemulator@8085
|
13
|
slaxemulator@8085
|
14 BOOTSEG = 0x07C0 /* original address of boot-sector */
|
slaxemulator@8085
|
15 SYSSEG = 0x1000 /* historical load address >> 4 */
|
slaxemulator@8085
|
16 +INITSEG = 0x9000 /* boot address >> 4 */
|
slaxemulator@8085
|
17 +SETUPSEG = 0x9020 /* setup address >> 4 */
|
slaxemulator@8085
|
18
|
slaxemulator@8085
|
19 #ifndef SVGA_MODE
|
slaxemulator@8085
|
20 #define SVGA_MODE ASK_VGA
|
slaxemulator@8085
|
21 @@ -40,53 +42,412 @@
|
slaxemulator@8085
|
22 #define ROOT_RDONLY 1
|
slaxemulator@8085
|
23 #endif
|
slaxemulator@8085
|
24
|
slaxemulator@8085
|
25 +/* some extra features */
|
slaxemulator@8085
|
26 +#define EDIT_CMDLINE on hotkey
|
slaxemulator@8085
|
27 +#define SHOW_REGS show int13 status & parameters
|
slaxemulator@8085
|
28 +
|
slaxemulator@8085
|
29 .code16
|
slaxemulator@8085
|
30 .section ".bstext", "ax"
|
slaxemulator@8085
|
31
|
slaxemulator@8085
|
32 .global bootsect_start
|
slaxemulator@8085
|
33 bootsect_start:
|
slaxemulator@8085
|
34 + cld # assume nothing
|
slaxemulator@8085
|
35 +stacktop = 0x9E00 # in 0x8000 .. 0xA000
|
slaxemulator@8085
|
36 +zeroed = 48+10 # gdt + zeroed registers
|
slaxemulator@8085
|
37 + movw $stacktop-12-zeroed, %di # stacktop is an arbitrary value >=
|
slaxemulator@8085
|
38 + # length of bootsect + length of
|
slaxemulator@8085
|
39 + # setup + room for stack;
|
slaxemulator@8085
|
40 + # 12 is disk parm size.
|
slaxemulator@8085
|
41 + pushw $INITSEG
|
slaxemulator@8085
|
42 + popw %es # %es = INITSEG
|
slaxemulator@8085
|
43 +
|
slaxemulator@8085
|
44 + pushw %es
|
slaxemulator@8085
|
45 + popw %ss # %ss and %es already contain INITSEG
|
slaxemulator@8085
|
46 + movw %di, %sp # put stack at INITSEG:stacktop-...
|
slaxemulator@8085
|
47 +
|
slaxemulator@8085
|
48 +# Many BIOS's default disk parameter tables will not recognize
|
slaxemulator@8085
|
49 +# multi-sector reads beyond the maximum sector number specified
|
slaxemulator@8085
|
50 +# in the default diskette parameter tables - this may mean 7
|
slaxemulator@8085
|
51 +# sectors in some cases.
|
slaxemulator@8085
|
52 +#
|
slaxemulator@8085
|
53 +# Since single sector reads are slow and out of the question,
|
slaxemulator@8085
|
54 +# we must take care of this by creating new parameter tables
|
slaxemulator@8085
|
55 +# (for the first disk) in RAM. We can set the maximum sector
|
slaxemulator@8085
|
56 +# count to 36 - the most we will encounter on an ED 2.88.
|
slaxemulator@8085
|
57 +#
|
slaxemulator@8085
|
58 +# High doesn't hurt. Low does. Let's use the max: 63
|
slaxemulator@8085
|
59 +#
|
slaxemulator@8085
|
60 +# Segments are as follows: %es = %ss = INITSEG,
|
slaxemulator@8085
|
61 +
|
slaxemulator@8085
|
62 + xorw %ax, %ax # %ax = 0
|
slaxemulator@8085
|
63 + movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
|
slaxemulator@8085
|
64 + rep # don't worry about cld
|
slaxemulator@8085
|
65 + stosw # already done above
|
slaxemulator@8085
|
66 + popw %bx # offset = 0
|
slaxemulator@8085
|
67 + popw %ds # %ds = 0
|
slaxemulator@8085
|
68 + popw %gs # %gs = 0
|
slaxemulator@8085
|
69 +
|
slaxemulator@8085
|
70 + movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0)
|
slaxemulator@8085
|
71 + incw %ax
|
slaxemulator@8085
|
72 +
|
slaxemulator@8085
|
73 + pushw %es
|
slaxemulator@8085
|
74 + pushw %di # %ds:%bx+0x78 is parameter table address
|
slaxemulator@8085
|
75 + ldsw 0x78(%bx), %si # %ds:%si is source
|
slaxemulator@8085
|
76 + movb $6, %cl # copy 12 bytes
|
slaxemulator@8085
|
77 + rep # don't worry about cld
|
slaxemulator@8085
|
78 + movsw # already done above
|
slaxemulator@8085
|
79 + popl %gs:0x78(%bx) # update parameter table address
|
slaxemulator@8085
|
80 + pushw %es
|
slaxemulator@8085
|
81 + popw %ds # now %ds = %es = %ss = INITSEG
|
slaxemulator@8085
|
82 + movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
|
slaxemulator@8085
|
83 + cli
|
slaxemulator@8085
|
84 +
|
slaxemulator@8085
|
85 + xchg %ax, %di # sector count
|
slaxemulator@8085
|
86 + popw %ax # limits = 0
|
slaxemulator@8085
|
87 + incw %cx # cylinder 0, sector 1
|
slaxemulator@8085
|
88 + call read_first_sectors # read setup
|
slaxemulator@8085
|
89 +
|
slaxemulator@8085
|
90 +offset_version = 0xE
|
slaxemulator@8085
|
91 + movw $0x200,%si
|
slaxemulator@8085
|
92 + addw offset_version(%si),%si # starting protocol 2.00, Kernel 1.3.73
|
slaxemulator@8085
|
93 + call putstr # show which kernel we are loading
|
slaxemulator@8085
|
94 +
|
slaxemulator@8085
|
95 +# The cmdline can be entered and modifed at boot time.
|
slaxemulator@8085
|
96 +# Only characters before the cursor are passed to the kernel.
|
slaxemulator@8085
|
97 + popw %bx # clear %bx
|
slaxemulator@8085
|
98 + orw cmd_line_ptr, %bx
|
slaxemulator@8085
|
99 + jz nocmdline
|
slaxemulator@8085
|
100 + pushw %bx
|
slaxemulator@8085
|
101 + incw %di
|
slaxemulator@8085
|
102 + call read_sectors
|
slaxemulator@8085
|
103 + popw %si
|
slaxemulator@8085
|
104 + call putstr
|
slaxemulator@8085
|
105 +#ifdef EDIT_CMDLINE
|
slaxemulator@8085
|
106 +cmdlp:
|
slaxemulator@8085
|
107 + movb $0x20, %al # clear end of line
|
slaxemulator@8085
|
108 + int $0x10 # with Space
|
slaxemulator@8085
|
109 + movb $8, %al # and BackSpace
|
slaxemulator@8085
|
110 + int $0x10
|
slaxemulator@8085
|
111 + decw %si
|
slaxemulator@8085
|
112 +cmdget:
|
slaxemulator@8085
|
113 + call wait4key
|
slaxemulator@8085
|
114 + cmpb $8, %al # BackSpace ?
|
slaxemulator@8085
|
115 + je cmdbs
|
slaxemulator@8085
|
116 + movb %al, (%si) # store char
|
slaxemulator@8085
|
117 + lodsw # %si += 2
|
slaxemulator@8085
|
118 +cmdbs:
|
slaxemulator@8085
|
119 +#if 1
|
slaxemulator@8085
|
120 + cmpw %si,cmd_line_ptr
|
slaxemulator@8085
|
121 + je cmdget
|
slaxemulator@8085
|
122 +#endif
|
slaxemulator@8085
|
123 + call putc # set %ah and %bx
|
slaxemulator@8085
|
124 + cmpb $10, %al # Enter ?
|
slaxemulator@8085
|
125 + jne cmdlp
|
slaxemulator@8085
|
126 + movb %bh,-2(%si) # set end of string and remove CR
|
slaxemulator@8085
|
127 +endcmdline:
|
slaxemulator@8085
|
128 +#endif
|
slaxemulator@8085
|
129 +nocmdline:
|
slaxemulator@8085
|
130
|
slaxemulator@8085
|
131 - # Normalize the start address
|
slaxemulator@8085
|
132 - ljmp $BOOTSEG, $start2
|
slaxemulator@8085
|
133 -
|
slaxemulator@8085
|
134 -start2:
|
slaxemulator@8085
|
135 - movw %cs, %ax
|
slaxemulator@8085
|
136 - movw %ax, %ds
|
slaxemulator@8085
|
137 - movw %ax, %es
|
slaxemulator@8085
|
138 - movw %ax, %ss
|
slaxemulator@8085
|
139 - xorw %sp, %sp
|
slaxemulator@8085
|
140 - sti
|
slaxemulator@8085
|
141 - cld
|
slaxemulator@8085
|
142 -
|
slaxemulator@8085
|
143 - movw $bugger_off_msg, %si
|
slaxemulator@8085
|
144 +# This routine loads the system at address SYSSEG, making sure
|
slaxemulator@8085
|
145 +# no 64kB boundaries are crossed. We try to load it as fast as
|
slaxemulator@8085
|
146 +# possible, loading whole tracks whenever we can.
|
slaxemulator@8085
|
147 +
|
slaxemulator@8085
|
148 +ramdisk_image = 0x0218
|
slaxemulator@8085
|
149 +ramdisk_size = 0x021C
|
slaxemulator@8085
|
150 + movw %sp, %si # for bootsect_gdt
|
slaxemulator@8085
|
151 + decw 16(%si) # bootsect_src = 64Kb
|
slaxemulator@8085
|
152 + decw 24(%si) # bootsect_dst = 64Kb
|
slaxemulator@8085
|
153 + movw $syssize, %di
|
slaxemulator@8085
|
154 +type_of_loader = 0x210
|
slaxemulator@8085
|
155 +loadflags = 0x211
|
slaxemulator@8085
|
156 +heap_end_ptr = 0x224
|
slaxemulator@8085
|
157 +ksyssize = 500
|
slaxemulator@8085
|
158 + orw $0x80FF, type_of_loader-ksyssize(%di) # loader type = 0xFF
|
slaxemulator@8085
|
159 + movw $stacktop-0x200, heap_end_ptr-ksyssize(%di)
|
slaxemulator@8085
|
160 + movb $0x10, %al # destination = 0x100000
|
slaxemulator@8085
|
161 + movb $5, %cl
|
slaxemulator@8085
|
162 +initrdlp:
|
slaxemulator@8085
|
163 + decw %ax
|
slaxemulator@8085
|
164 + movb $0x93,%ah
|
slaxemulator@8085
|
165 + movw %ax, 28(%si) # bootsect_dst_base+2
|
slaxemulator@8085
|
166 + movb $(SYSSEG/4096), %al # source = SYSSEG
|
slaxemulator@8085
|
167 + movw %ax, 20(%si) # bootsect_src_base+2
|
slaxemulator@8085
|
168 + cbw
|
slaxemulator@8085
|
169 + cwde
|
slaxemulator@8085
|
170 + shlw %cl, %ax
|
slaxemulator@8085
|
171 + decw %ax
|
slaxemulator@8085
|
172 + addl (%di),%eax
|
slaxemulator@8085
|
173 + shrl %cl, %eax
|
slaxemulator@8085
|
174 +syslp:
|
slaxemulator@8085
|
175 + pushw $SYSSEG
|
slaxemulator@8085
|
176 + popw %es
|
slaxemulator@8085
|
177 + movw $128,%di # 64Kb
|
slaxemulator@8085
|
178 + subw %di, %ax # max 32M > int 15 limit
|
slaxemulator@8085
|
179 + pushf
|
slaxemulator@8085
|
180 + jnc not_last
|
slaxemulator@8085
|
181 + addw %ax, %di
|
slaxemulator@8085
|
182 +not_last:
|
slaxemulator@8085
|
183 + xorw %bx, %bx # clear %bx
|
slaxemulator@8085
|
184 + pushw %ax
|
slaxemulator@8085
|
185 +#if defined(SHOW_REGS)
|
slaxemulator@8085
|
186 + pushw %si
|
slaxemulator@8085
|
187 + call read_sectors
|
slaxemulator@8085
|
188 + popw %si
|
slaxemulator@8085
|
189 +#else
|
slaxemulator@8085
|
190 + call read_sectors
|
slaxemulator@8085
|
191 +#endif
|
slaxemulator@8085
|
192 + movw $0x8000, %cx # full 64K
|
slaxemulator@8085
|
193 + movb $0x87, %ah
|
slaxemulator@8085
|
194 + incb 28(%si) # bootsect_dst_base+2
|
slaxemulator@8085
|
195 + int $0x15 # max 16M
|
slaxemulator@8085
|
196 + popw %ax
|
slaxemulator@8085
|
197 + popf
|
slaxemulator@8085
|
198 + ja syslp
|
slaxemulator@8085
|
199 + movw ramdisk_image+2,%ax
|
slaxemulator@8085
|
200 + movw $ramdisk_size,%di
|
slaxemulator@8085
|
201 + movb $9, %cl
|
slaxemulator@8085
|
202 + cmpb %al,28(%si)
|
slaxemulator@8085
|
203 + jb initrdlp
|
slaxemulator@8085
|
204 +
|
slaxemulator@8085
|
205 +# This procedure turns off the floppy drive motor, so
|
slaxemulator@8085
|
206 +# that we enter the kernel in a known state, and
|
slaxemulator@8085
|
207 +# don't have to worry about it later.
|
slaxemulator@8085
|
208 +
|
slaxemulator@8085
|
209 +#if 1
|
slaxemulator@8085
|
210 +kill_motor:
|
slaxemulator@8085
|
211 + xchgw %ax, %bx # reset FDC
|
slaxemulator@8085
|
212 + int $0x13
|
slaxemulator@8085
|
213 +#else
|
slaxemulator@8085
|
214 +kill_motor:
|
slaxemulator@8085
|
215 + movw $0x3f2, %dx
|
slaxemulator@8085
|
216 + xchgw %ax, %bx
|
slaxemulator@8085
|
217 + outb %al, %dx
|
slaxemulator@8085
|
218 +#endif
|
slaxemulator@8085
|
219
|
slaxemulator@8085
|
220 -msg_loop:
|
slaxemulator@8085
|
221 - lodsb
|
slaxemulator@8085
|
222 - andb %al, %al
|
slaxemulator@8085
|
223 - jz bs_die
|
slaxemulator@8085
|
224 - movb $0xe, %ah
|
slaxemulator@8085
|
225 - movw $7, %bx
|
slaxemulator@8085
|
226 +# After that (everything loaded), we jump to the setup-routine
|
slaxemulator@8085
|
227 +# loaded directly after the bootblock:
|
slaxemulator@8085
|
228 +# Segments are as follows: %ds = %ss = INITSEG
|
slaxemulator@8085
|
229 +
|
slaxemulator@8085
|
230 + ljmp $SETUPSEG, $0
|
slaxemulator@8085
|
231 +
|
slaxemulator@8085
|
232 +# read_sectors reads %di sectors into %es:0 buffer.
|
slaxemulator@8085
|
233 +# %es:0 is updated to the next memory location.
|
slaxemulator@8085
|
234 +# First, sectors are read sector by sector until
|
slaxemulator@8085
|
235 +# sector per track count is known. Then they are
|
slaxemulator@8085
|
236 +# read track by track.
|
slaxemulator@8085
|
237 +# Assume no error on first track.
|
slaxemulator@8085
|
238 +
|
slaxemulator@8085
|
239 +#define FLOPPY_CYLINDERS 80 /* 80 cylinders minimum */
|
slaxemulator@8085
|
240 +#define FLOPPY_HEADS 2 /* 2 heads minimum */
|
slaxemulator@8085
|
241 +#define FLOPPY_SECTORS 18 /* 18 sectors minimum */
|
slaxemulator@8085
|
242 +
|
slaxemulator@8085
|
243 +#ifdef SHOW_REGS
|
slaxemulator@8085
|
244 +print_loop:
|
slaxemulator@8085
|
245 + movb $0x6 + 'A' - 1, %al
|
slaxemulator@8085
|
246 + subb %cl, %al
|
slaxemulator@8085
|
247 + movw $regs, %si # caller %si is saved
|
slaxemulator@8085
|
248 + call putcs # putc(%al) + putstr(%si)
|
slaxemulator@8085
|
249 +# it will print out all of the registers.
|
slaxemulator@8085
|
250 + popw %bp # load word into %si
|
slaxemulator@8085
|
251 + jmp print_all # print %bp (status)
|
slaxemulator@8085
|
252 +#endif
|
slaxemulator@8085
|
253 +check_limits:
|
slaxemulator@8085
|
254 +#ifndef SHOW_REGS
|
slaxemulator@8085
|
255 + popw %dx
|
slaxemulator@8085
|
256 +#endif
|
slaxemulator@8085
|
257 + cmpb $FLOPPY_SECTORS+1, %cl # 18 sectors minimum
|
slaxemulator@8085
|
258 + jb check_head
|
slaxemulator@8085
|
259 + cmpb %al, %cl # max sector known ?
|
slaxemulator@8085
|
260 + ja next_head # no -> store it
|
slaxemulator@8085
|
261 +check_head:
|
slaxemulator@8085
|
262 + cmpb $FLOPPY_HEADS, %dh # 2 heads minimum
|
slaxemulator@8085
|
263 + jb check_cylinder
|
slaxemulator@8085
|
264 + cmpb %ah, %dh # max head known ?
|
slaxemulator@8085
|
265 + ja next_cylinder # no -> store it
|
slaxemulator@8085
|
266 +check_cylinder:
|
slaxemulator@8085
|
267 + pushaw
|
slaxemulator@8085
|
268 +#ifdef SHOW_REGS
|
slaxemulator@8085
|
269 + cmpw $0x600,%bp # disk changed ?
|
slaxemulator@8085
|
270 + je reset_floppy
|
slaxemulator@8085
|
271 + pushw %es # print %es (named EX)
|
slaxemulator@8085
|
272 + pushw %dx # print %dx
|
slaxemulator@8085
|
273 + pushw %cx # print %cx
|
slaxemulator@8085
|
274 + pushw %bx # print %bx
|
slaxemulator@8085
|
275 + xchgw %ax, %si
|
slaxemulator@8085
|
276 + movb $2,%ah
|
slaxemulator@8085
|
277 + pushw %ax # print %ax
|
slaxemulator@8085
|
278 + movb $6,%cl
|
slaxemulator@8085
|
279 +print_all:
|
slaxemulator@8085
|
280 + movb $4, %ch # 4 hex digits
|
slaxemulator@8085
|
281 +print_digit:
|
slaxemulator@8085
|
282 + rolw $4, %bp # rotate to use low 4 bits
|
slaxemulator@8085
|
283 + movb $0x0f, %al
|
slaxemulator@8085
|
284 + andw %bp, %ax # %al = mask for nybble
|
slaxemulator@8085
|
285 + addb $0x90, %al # convert %al to ascii hex
|
slaxemulator@8085
|
286 + daa # in only four instructions!
|
slaxemulator@8085
|
287 + adcb $0x40, %al
|
slaxemulator@8085
|
288 + daa
|
slaxemulator@8085
|
289 + call putc # set %ah and %bx
|
slaxemulator@8085
|
290 + decb %ch
|
slaxemulator@8085
|
291 + jnz print_digit
|
slaxemulator@8085
|
292 + movb $0x20, %al # SPACE
|
slaxemulator@8085
|
293 int $0x10
|
slaxemulator@8085
|
294 - jmp msg_loop
|
slaxemulator@8085
|
295 -
|
slaxemulator@8085
|
296 -bs_die:
|
slaxemulator@8085
|
297 - # Allow the user to press a key, then reboot
|
slaxemulator@8085
|
298 - xorw %ax, %ax
|
slaxemulator@8085
|
299 + loop print_loop
|
slaxemulator@8085
|
300 + call wait
|
slaxemulator@8085
|
301 + cbw # %ah = 0
|
slaxemulator@8085
|
302 +reset_floppy:
|
slaxemulator@8085
|
303 +#else
|
slaxemulator@8085
|
304 + cbw # %ah = 0
|
slaxemulator@8085
|
305 +#endif
|
slaxemulator@8085
|
306 + int $0x13 # reset controler
|
slaxemulator@8085
|
307 + popaw
|
slaxemulator@8085
|
308 +read_sectorslp:
|
slaxemulator@8085
|
309 + pushw %dx # some bios break dx...
|
slaxemulator@8085
|
310 + pushw %ax # limits
|
slaxemulator@8085
|
311 + subb %cl, %al # sectors remaining in track
|
slaxemulator@8085
|
312 + ja tolastsect
|
slaxemulator@8085
|
313 + movb $1, %al # 1 sector mini
|
slaxemulator@8085
|
314 +tolastsect:
|
slaxemulator@8085
|
315 + cbw
|
slaxemulator@8085
|
316 + cmpw %di, %ax
|
slaxemulator@8085
|
317 + jb more1trk
|
slaxemulator@8085
|
318 + movw %di, %ax # sectors to read
|
slaxemulator@8085
|
319 +more1trk:
|
slaxemulator@8085
|
320 + pushw %ax # save context
|
slaxemulator@8085
|
321 + movb $2, %ah # cmd: read chs
|
slaxemulator@8085
|
322 + int $0x13
|
slaxemulator@8085
|
323 +#ifdef SHOW_REGS
|
slaxemulator@8085
|
324 + xchgw %ax, %bp # status
|
slaxemulator@8085
|
325 +#endif
|
slaxemulator@8085
|
326 +# ifdef SHOW_REGS
|
slaxemulator@8085
|
327 + popw %si # save %ax
|
slaxemulator@8085
|
328 + popw %ax # limits
|
slaxemulator@8085
|
329 + popw %dx
|
slaxemulator@8085
|
330 +# else
|
slaxemulator@8085
|
331 + popw %dx # save %ax
|
slaxemulator@8085
|
332 + popw %ax # limits
|
slaxemulator@8085
|
333 +# endif
|
slaxemulator@8085
|
334 + jc check_limits
|
slaxemulator@8085
|
335 + xchgw %ax, %bp
|
slaxemulator@8085
|
336 +# ifdef SHOW_REGS
|
slaxemulator@8085
|
337 +update_regs:
|
slaxemulator@8085
|
338 + incw %cx # next sector
|
slaxemulator@8085
|
339 + movw %cx, %fs
|
slaxemulator@8085
|
340 + addb $2,%bh # next location
|
slaxemulator@8085
|
341 + decw %di # update sector counter
|
slaxemulator@8085
|
342 + jz putcdot
|
slaxemulator@8085
|
343 + decw %si
|
slaxemulator@8085
|
344 + jnz update_regs
|
slaxemulator@8085
|
345 +# else
|
slaxemulator@8085
|
346 + addw %dx,%cx # next sector
|
slaxemulator@8085
|
347 + addb %dl,%bh
|
slaxemulator@8085
|
348 + addb %dl,%bh # next location
|
slaxemulator@8085
|
349 + subw %dx,%di # update sector counter
|
slaxemulator@8085
|
350 + popw %dx
|
slaxemulator@8085
|
351 + jz putcdot
|
slaxemulator@8085
|
352 +# endif
|
slaxemulator@8085
|
353 +read_sectors:
|
slaxemulator@8085
|
354 + movw %fs, %cx
|
slaxemulator@8085
|
355 + xchgw %ax, %bp
|
slaxemulator@8085
|
356 + cmpb %al,%cl # reach sector limit ?
|
slaxemulator@8085
|
357 + jne bdendlp
|
slaxemulator@8085
|
358 +next_head:
|
slaxemulator@8085
|
359 + movb %cl,%al
|
slaxemulator@8085
|
360 + incb %dh # next head
|
slaxemulator@8085
|
361 + movb $1,%cl # first sector
|
slaxemulator@8085
|
362 + cmpb %ah, %dh # reach head limit ?
|
slaxemulator@8085
|
363 + jne bdendlp
|
slaxemulator@8085
|
364 +next_cylinder:
|
slaxemulator@8085
|
365 + movb %dh,%ah
|
slaxemulator@8085
|
366 +# NOTE : support 256 cylinders max
|
slaxemulator@8085
|
367 + incb %ch # next cylinder
|
slaxemulator@8085
|
368 +read_first_sectors:
|
slaxemulator@8085
|
369 + movb $0,%dh # first head
|
slaxemulator@8085
|
370 +cylinder_count = 496
|
slaxemulator@8085
|
371 + cmpb $FLOPPY_CYLINDERS,%ch # reach cylinder limit ?
|
slaxemulator@8085
|
372 + jb bdendlp
|
slaxemulator@8085
|
373 + cmpb cylinder_count, %ch
|
slaxemulator@8085
|
374 + jb bdendlp
|
slaxemulator@8085
|
375 +next_floppy:
|
slaxemulator@8085
|
376 + movb $0,%ch # first cylinder
|
slaxemulator@8085
|
377 + pushaw
|
slaxemulator@8085
|
378 + movw $swap_floppy,%si
|
slaxemulator@8085
|
379 + incb 12(%si)
|
slaxemulator@8085
|
380 + pushw %bx
|
slaxemulator@8085
|
381 + call putstr
|
slaxemulator@8085
|
382 + popw %bx
|
slaxemulator@8085
|
383 +waitfloppy:
|
slaxemulator@8085
|
384 + call wait
|
slaxemulator@8085
|
385 + jne waitfloppydone
|
slaxemulator@8085
|
386 + pushw %dx # some bios break dx...
|
slaxemulator@8085
|
387 + cbw
|
slaxemulator@8085
|
388 + int $0x13 # reset FDC
|
slaxemulator@8085
|
389 + movw $0x201,%ax
|
slaxemulator@8085
|
390 +# cwd
|
slaxemulator@8085
|
391 +# movw $1,%cx
|
slaxemulator@8085
|
392 + int $0x13 # read first sector
|
slaxemulator@8085
|
393 + popw %dx
|
slaxemulator@8085
|
394 + rclb $1,%ah # floppy changed 06=>0D no error 00
|
slaxemulator@8085
|
395 + cmpb -2(%si), %ah # 0D then 00
|
slaxemulator@8085
|
396 + jne waitfloppy # no => try again
|
slaxemulator@8085
|
397 + incw %si
|
slaxemulator@8085
|
398 + orb %ah,%ah # was 00 ?
|
slaxemulator@8085
|
399 + jne waitfloppy
|
slaxemulator@8085
|
400 +waitfloppydone:
|
slaxemulator@8085
|
401 + popaw
|
slaxemulator@8085
|
402 +bdendlp:
|
slaxemulator@8085
|
403 + jmp read_sectorslp
|
slaxemulator@8085
|
404 +
|
slaxemulator@8085
|
405 +putcdot:
|
slaxemulator@8085
|
406 + pushw %ss
|
slaxemulator@8085
|
407 + popw %es # restore es
|
slaxemulator@8085
|
408 + movb $0x2e+3, %al # loading... message 2e = .
|
slaxemulator@8085
|
409 +putclf:
|
slaxemulator@8085
|
410 + subb $3, %al
|
slaxemulator@8085
|
411 +putc:
|
slaxemulator@8085
|
412 + movb $0xe, %ah
|
slaxemulator@8085
|
413 + movw $7, %bx # one dot each 64k
|
slaxemulator@8085
|
414 + int $0x10
|
slaxemulator@8085
|
415 + cmp $0xd, %al # CR ?
|
slaxemulator@8085
|
416 + je putclf
|
slaxemulator@8085
|
417 + ret
|
slaxemulator@8085
|
418 +
|
slaxemulator@8085
|
419 +putstr:
|
slaxemulator@8085
|
420 + movb $0xd, %al # CR
|
slaxemulator@8085
|
421 +putcs:
|
slaxemulator@8085
|
422 + call putc
|
slaxemulator@8085
|
423 + lodsb
|
slaxemulator@8085
|
424 + orb %al,%al # end of string is \0
|
slaxemulator@8085
|
425 + jnz putcs
|
slaxemulator@8085
|
426 + ret
|
slaxemulator@8085
|
427 +
|
slaxemulator@8085
|
428 +clock = 0x46C
|
slaxemulator@8085
|
429 +wait:
|
slaxemulator@8085
|
430 +wait4key:
|
slaxemulator@8085
|
431 + movw $clock, %di
|
slaxemulator@8085
|
432 +#define DELAY 5
|
slaxemulator@8085
|
433 + movb $(DELAY*182)/10,%cl
|
slaxemulator@8085
|
434 + addb %gs:(%di),%cl
|
slaxemulator@8085
|
435 +waitkbd:
|
slaxemulator@8085
|
436 + movw $0x10D, %ax # test keyboard, timeout => CR
|
slaxemulator@8085
|
437 + cmpb %gs:(%di),%cl
|
slaxemulator@8085
|
438 + je waitdone
|
slaxemulator@8085
|
439 int $0x16
|
slaxemulator@8085
|
440 - int $0x19
|
slaxemulator@8085
|
441 + jz waitkbd
|
slaxemulator@8085
|
442 + cbw
|
slaxemulator@8085
|
443 + int $0x16 # eat char
|
slaxemulator@8085
|
444 + movw %di, %gs # disable timeout
|
slaxemulator@8085
|
445 + incw %di # clear Z
|
slaxemulator@8085
|
446 +waitdone:
|
slaxemulator@8085
|
447 + ret
|
slaxemulator@8085
|
448
|
slaxemulator@8085
|
449 - # int 0x19 should never return. In case it does anyway,
|
slaxemulator@8085
|
450 - # invoke the BIOS reset code...
|
slaxemulator@8085
|
451 - ljmp $0xf000,$0xfff0
|
slaxemulator@8085
|
452 -
|
slaxemulator@8085
|
453 - .section ".bsdata", "a"
|
slaxemulator@8085
|
454 -bugger_off_msg:
|
slaxemulator@8085
|
455 - .ascii "Direct booting from floppy is no longer supported.\r\n"
|
slaxemulator@8085
|
456 - .ascii "Please use a boot loader program instead.\r\n"
|
slaxemulator@8085
|
457 - .ascii "\n"
|
slaxemulator@8085
|
458 - .ascii "Remove disk and press any key to reboot . . .\r\n"
|
slaxemulator@8085
|
459 - .byte 0
|
slaxemulator@8085
|
460 +#ifdef SHOW_REGS
|
slaxemulator@8085
|
461 +regs: .asciz "X:"
|
slaxemulator@8085
|
462 +#endif
|
slaxemulator@8085
|
463
|
slaxemulator@8085
|
464 +swap_floppy: .ascii "Insert disk 1"
|
slaxemulator@8085
|
465 + .ascii "."
|
slaxemulator@8085
|
466 + .byte 7,13,0
|
slaxemulator@8085
|
467
|
slaxemulator@8085
|
468 # Kernel attributes; used by setup. This is part 1 of the
|
slaxemulator@8085
|
469 # header, from the old boot sector.
|