2 * Mach Operating System
3 * Copyright (c) 1992, 1991 Carnegie Mellon University
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
26 * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd
31 Copyright 1988, 1989, 1990, 1991, 1992
32 by Intel Corporation, Santa Clara, California.
36 Permission to use, copy, modify, and distribute this software and
37 its documentation for any purpose and without fee is hereby
38 granted, provided that the above copyright notice appears in all
39 copies and that both the copyright notice and this permission notice
40 appear in supporting documentation, and that the name of Intel
41 not be used in advertising or publicity pertaining to distribution
42 of the software without specific, written prior permission.
44 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
45 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
46 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
47 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
48 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
49 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
50 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53 * Ported to PC-9801 by Yoshio Kimura
57 * Extensions for El Torito CD-ROM booting:
59 * Copyright © 1997 Pluto Technologies International, Inc. Boulder CO
60 * Copyright © 1997 interface business GmbH, Dresden.
61 * All rights reserved.
63 * This code has been written by Jörg Wunsch, Dresden.
64 * Direct comments to <joerg_wunsch@interface-business.de>.
66 * Redistribution and use in source and binary forms, with or without
67 * modification, are permitted provided that the following conditions
69 * 1. Redistributions of source code must retain the above copyright
70 * notice, this list of conditions and the following disclaimer.
71 * 2. Redistributions in binary form must reproduce the above copyright
72 * notice, this list of conditions and the following disclaimer in the
73 * documentation and/or other materials provided with the distribution.
75 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
76 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
79 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
80 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
81 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
82 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
83 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
84 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
85 * POSSIBILITY OF SUCH DAMAGE.
97 * PC-9801/PC-9821 SCSI MO booting
98 * 2002/06/05-07/03 Kawanobe Koh <kawanobe@st.rim.or.jp>
105 mov %bl, %cl /* UA */
109 mov (0x0482), %al /* SCSI HD equipment bits */
117 * biosread(dev, cyl, head, sec, nsec, offset)
118 * Read "nsec" sectors from disk to offset "offset" in boot segment
119 * BIOS call "INT 0x1B Function 0xn6" to read sectors from disk into memory
120 * Call with %ah = 0xd6(for floppy disk) or 0x06(for hard disk)
123 * %ch = sector size(for floppy) or cylinder(for hard)
127 * %es:%bp = segment:offset of buffer
129 * %al = 0x0 on success; err code on failure
141 mov 0x08(%ebp), %bl /* (byte) DA/UA */
142 mov 0x0C(%ebp), %ecx /* (word) cylinder */
143 mov 0x10(%ebp), %dh /* (byte) head */
144 mov 0x14(%ebp), %dl /* (byte) sector */
145 mov 0x18(%ebp), %esi /* (byte) number of sectors */
146 mov 0x1C(%ebp), %edi /* (word) destination offset */
148 /* prot_to_real will set %es to BOOTSEG */
149 call EXT(prot_to_real) /* enter real mode */
151 mov $0x06, %bh /* read data function */
152 mov %bl, %al /* DA */
154 cmp $0x30, %al /* 1440KB FD */
156 cmp $0x90, %al /* 1200KB FD */
158 cmp $0xA0, %al /* SCSI HD or MO */
163 mov %dh, %al /* change to linear sector */
164 shl $5, %al /* multiply by 32 sector per track */
166 xor %dh, %dh /* higher 16 bits into %dx */
168 mov %cl, %ch /* lower 16 bits into %cx */
170 and $0x7F, %bl /* linear access DA/UA */
173 inc %dx /* sector address begins from one */
174 mov $0x02, %ch /* 512 bytes sector */
175 mov $0xD6, %bh /* MT MFM retry seek */
177 mov %si, %ax /* number of sectors */
178 shl $9, %ax /* multiply by 512 bytes */
180 mov %di, %bp /* destination offset */
181 int $0x1B /* disk bios call */
185 mov %ax, %bx /* save return value */
189 call EXT(real_to_prot) /* back to protected mode */
192 mov %bh, %al /* return value in %eax */
206 * getbootspec(struct specpacket *offset)
208 * Read CD-ROM boot specification packet to "offset".
220 /* prot_to_real will set %es to BOOTSEG */
221 call EXT(prot_to_real) /* enter real mode */
222 movw $0x4b01, %ax /* (do not) terminate disk emulation */
223 movb $0x7f, %dl /* any drive */
229 /* save return value (actually movw %ax, %bx) */
233 call EXT(real_to_prot) /* back to protected mode */
236 movb %bh, %al /* return value in %ax */
247 * biosreadlba(struct daddrpacket *daddr)
248 * Read sectors using the BIOS "read extended" function
249 * BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory
250 * Call with %ah = 0x42
251 * %dl = drive (0x0 for floppy disk, or emulated CD)
252 * %ds:%si = ptr to disk address packet
254 * %ah = 0x0 on success; err code on failure
265 movl $0, %edx /* emulated CD is always drive 0 */
267 /* prot_to_real will set %es to BOOTSEG */
268 call EXT(prot_to_real) /* enter real mode */
269 movw $0x4200, %ax /* subfunction */
276 /* save return value (actually movw %ax, %bx) */
280 call EXT(real_to_prot) /* back to protected mode */
283 movb %bh, %al /* return value in %ax */
295 * BIOS call "INT 18H Function 00H" to read character from keyboard
296 * Call with %ah = 0x0
297 * Return: %ah = keyboard scan code
298 * %al = ASCII character
305 push %ebx /* save %ebx */
309 call EXT(prot_to_real)
315 movb %al, %bl /* real_to_prot uses %eax */
319 call EXT(real_to_prot)
331 * if there is a character pending, return it; otherwise return 0
332 * BIOS call "INT 18H Function 01H" to check whether a character is pending
333 * Call with %ah = 0x1
335 * If key waiting to be input:
336 * %ah = keyboard scan code
337 * %al = ASCII character
350 call EXT(prot_to_real) /* enter real mode */
364 call EXT(real_to_prot)
377 * get_diskinfo(): return a word that represents the
378 * max number of sectors and heads and drives for this device
388 mov 0x08(%ebp), %bl /* (byte) DA/UA */
390 call EXT(prot_to_real) /* enter real mode */
392 mov %bl, %al /* DA */
394 mov $18, %dl /* 1440KB FD sectors per track */
397 mov $15, %dl /* 1200KB FD sectors per track */
400 cmp $0xA0, %al /* SCSI HD or MO */
405 push %ds /* SCSI MO or CD ? */
408 and $0x0F, %bx /* UA */
409 shl $2, %bx /* parameter offset */
411 mov (%bx), %al /* SCSI equipment parameter[0] */
412 and $0x1F, %al /* peripheral device type */
413 cmp $7, %al /* SCSI MO */
416 mov (%bx), %al /* SCSI equipment parameter[3] */
417 test $0x30, %al /* sector length from 256 to 2048 */
419 or $0x10, %al /* forced set 512 bytes sector */
421 mov $0xA100, %dx /* refered by C language */
427 mov $0xFFFE, %cx /* virtual 65535 cylinders setting */
428 mov $0x0820, %dx /* standard 8 heads and 32 sectors */
431 mov $0x84, %ah /* ask for disk info */
434 jnc ok /* use %cx and %dx after */
436 * Urk. Call failed. It is not supported for floppies by old BIOS's.
437 * Guess it's a 15-sector floppy.
440 mov $79, %cx /* 80 cylinders 1200K and 1440K FD */
441 mov $2, %dh /* 2 heads as double side */
445 call EXT(real_to_prot) /* back to protected mode */
448 * form a longword representing all this gunk:
454 sal $16, %eax /* max cylinder number from zero */
455 mov %dx, %ax /* number of heads and sectors */
463 * memsize(i) : return the memory size in KB. i == 0 for conventional memory,
464 * i == 1 for extended memory
465 * Both have the return value in AX.
483 movb 0xA1401 - BOOTSEG * 0x10, %al
486 movw 0xA1594 - BOOTSEG * 0x10, %bx
492 movb 0xA1501 - BOOTSEG * 0x10, %al