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 * biosread(dev, cyl, head, sec, nsec, offset)
98 * Read "nsec" sectors from disk to offset "offset" in boot segment
99 * BIOS call "INT 0x1B Function 0xn6" to read sectors from disk into memory
100 * Call with %ah = 0xd6(for floppy disk) or 0x06(for hard disk)
103 * %ch = sector size(for floppy) or cylinder(for hard)
107 * %es:%bp = segment:offset of buffer
109 * %al = 0x0 on success; err code on failure
120 movb 0x14(%ebp), %dl /* sector */
121 movb 0x10(%ebp), %dh /* head */
122 movw 0x0c(%ebp), %cx /* cylinder */
123 movb 0x08(%ebp), %al /* DA/UA */
138 /* prot_to_real will set %es to BOOTSEG */
139 call EXT(prot_to_real) /* enter real mode */
143 movb 0x18(%ebp), %bl /* number of sectors */
160 /* save return value (actually movw %ax, %bx) */
164 call EXT(real_to_prot) /* back to protected mode */
167 movb %bh, %al /* return value in %ax */
181 * getbootspec(struct specpacket *offset)
183 * Read CD-ROM boot specification packet to "offset".
195 /* prot_to_real will set %es to BOOTSEG */
196 call EXT(prot_to_real) /* enter real mode */
197 movw $0x4b01, %ax /* (do not) terminate disk emulation */
198 movb $0x7f, %dl /* any drive */
204 /* save return value (actually movw %ax, %bx) */
208 call EXT(real_to_prot) /* back to protected mode */
211 movb %bh, %al /* return value in %ax */
222 * biosreadlba(struct daddrpacket *daddr)
223 * Read sectors using the BIOS "read extended" function
224 * BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory
225 * Call with %ah = 0x42
226 * %dl = drive (0x0 for floppy disk, or emulated CD)
227 * %ds:%si = ptr to disk address packet
229 * %ah = 0x0 on success; err code on failure
240 movl $0, %edx /* emulated CD is always drive 0 */
242 /* prot_to_real will set %es to BOOTSEG */
243 call EXT(prot_to_real) /* enter real mode */
244 movw $0x4200, %ax /* subfunction */
251 /* save return value (actually movw %ax, %bx) */
255 call EXT(real_to_prot) /* back to protected mode */
258 movb %bh, %al /* return value in %ax */
270 * BIOS call "INT 18H Function 00H" to read character from keyboard
271 * Call with %ah = 0x0
272 * Return: %ah = keyboard scan code
273 * %al = ASCII character
279 push %ebx /* save %ebx */
283 call EXT(prot_to_real)
288 movb %al, %bl /* real_to_prot uses %eax */
291 call EXT(real_to_prot)
303 * if there is a character pending, return it; otherwise return 0
304 * BIOS call "INT 18H Function 01H" to check whether a character is pending
305 * Call with %ah = 0x1
307 * If key waiting to be input:
308 * %ah = keyboard scan code
309 * %al = ASCII character
321 call EXT(prot_to_real) /* enter real mode */
333 call EXT(real_to_prot)
346 * get_diskinfo(): return a word that represents the
347 * max number of sectors and heads and drives for this device
358 movb 0x8(%ebp), %dl /* diskinfo(drive #) */
359 call EXT(prot_to_real) /* enter real mode */
361 movb %dl, %al /* ask for disk info */
375 * Urk. Call failed. It is not supported for floppies by old BIOS's.
376 * Guess it's a 15-sector floppy.
382 movb $15, %dl /* max sector */
384 subb %ah, %ah /* %ax = 0 */
386 movb %ah, %bh /* %bh = 0 */
387 movb $2, %bl /* %bl bits 0-3 = drive type,
389 movb $79, %ch /* max track */
390 movb $1, %cl /* # floppy drives installed */
391 movb $2, %dh /* max head */
392 /* es:di = parameter table */
397 call EXT(real_to_prot) /* back to protected mode */
400 * form a longword representing all this gunk:
406 sall $16,%eax /* << 16 */
407 movb %dh, %ah /* max head */
408 movb %dl, %al /* max sector (and # sectors) */
418 * memsize(i) : return the memory size in KB. i == 0 for conventional memory,
419 * i == 1 for extended memory
420 * Both have the return value in AX.
437 movb 0xA1401 - BOOTSEG * 0x10, %al
440 movw 0xA1594 - BOOTSEG * 0x10, %bx
446 movb 0xA1501 - BOOTSEG * 0x10, %al