Initial import from FreeBSD RELENG_4:
[games.git] / sys / platform / pc32 / boot / cdboot / boot.h
1 /*
2  * Mach Operating System
3  * Copyright (c) 1992, 1991 Carnegie Mellon University
4  * All Rights Reserved.
5  *
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.
11  *
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.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *      from: Mach, Revision 2.2  92/04/04  11:35:03  rpd
27  * $FreeBSD: src/sys/i386/boot/cdboot/boot.h,v 1.3 1999/08/28 00:43:17 peter Exp $
28  */
29 /*
30  * Extensions for El Torito CD-ROM booting:
31  *
32  * Copyright © 1997 Pluto Technologies International, Inc.  Boulder CO
33  * Copyright © 1997 interface business GmbH, Dresden.
34  *      All rights reserved.
35  *
36  * This code has been written by Jörg Wunsch, Dresden.
37  * Direct comments to <joerg_wunsch@interface-business.de>.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in the
46  *    documentation and/or other materials provided with the distribution.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
49  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
52  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
57  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
58  * POSSIBILITY OF SUCH DAMAGE.
59  */
60
61 #include <sys/param.h>
62 #include <sys/time.h>
63
64 /*
65  * Specification packet per El Torito, BIOS int 0x13 fn 0x4b00/0x4b01
66  */
67 struct specpacket
68 {
69         u_char size;            /* must be 0x13 */
70         u_char mediatype;       /*
71                                  * 0 - no emulation
72                                  * 1 - 1.2 MB floppy
73                                  * 2 - 1.44 MB floppy
74                                  * 3 - 2.88 MB floppy
75                                  * 4 - hard disk C:
76                                  */
77         u_char drvno;           /* emulated drive number */
78         u_char ctrlindx;        /* controller index, see El Torito */
79         u_int32_t lba;          /* LBA of emulated disk drive */
80         u_int16_t devspec;      /* device specification, see El Torito */
81         u_int16_t ubufseg;      /* user buffer segment */
82         u_int16_t loadseg;      /* load segment; 0 => use BIOS default 0x7c0 */
83         u_int16_t seccnt;       /* number of auto-loaded (virtual) sectors */
84         u_char cyls;            /* same values as in int 0x13, fn 8 */
85         u_char secs;
86         u_char heads;
87 };
88
89 /*
90  * Disk address packet for extended BIOS int 0x13 fn's 0x41...0x48.
91  */
92 struct daddrpacket
93 {
94         u_char size;            /* size of daddrpacket, must be 0x10 */
95         u_char reserved1;
96         u_char nblocks;         /*
97                                  * number of 512-byte blocks to transfer,
98                                  * must be <= 127
99                                  */
100         u_char reserved2;
101         u_int16_t boffs;        /* bseg:boffs denominate the transfer buffer */
102         u_int16_t bseg;
103         u_int32_t lba;          /* actually a 64-bit type, but 64-bit arith */
104         u_int32_t lbahigh;      /* is expensive, and we don't really need it */
105 };
106
107 #ifdef DEBUG
108 # define DPRINTF(x) printf x
109 #else
110 # define DPRINTF(x)
111 #endif
112
113
114 /* asm.S */
115 #if ASM_ONLY
116 void real_to_prot(void);
117 void prot_to_real(void);
118 #endif
119 void startprog(unsigned int physaddr, int howto, int bootdev,
120                /* XXX struct bootinfo * */ unsigned int bootinfo);
121 void pbzero(void *dst, size_t count);
122 void pcpy(const void *src, void *dst, size_t count);
123
124 /* bios.S */
125
126 int biosread(int dev, int cyl, int head, int sec, int nsec, void *offset);
127 int getbootspec(struct specpacket *offset);
128 int biosreadlba(struct daddrpacket *daddr);
129 void putc(int c);
130 int getc(void);
131 int ischar(void);
132 int get_diskinfo(int drive);
133 int memsize(int extended);
134
135 /* boot.c */
136 extern int loadflags;
137
138 void boot(int drive);
139
140 /* boot2.S */
141 void boot2(void);
142
143 /* cdrom.c */
144 extern u_int32_t sessionstart;
145
146 int devopen(u_int32_t session);
147 void seek(u_int32_t offs);
148 int read(u_char *addr, size_t size);
149 int xread(u_char *addr, size_t size);
150 int openrd(char *name);
151
152 /* io.c */
153 void gateA20(void);
154 void printf(const char *format, ...);
155 void putchar(int c);
156 void delay1ms(void);
157 int gets(char *buf);
158 int strcasecmp(const char *s1, const char *s2);
159 int strcmp(const char *s1, const char *s2);
160 void bcopy(const void *from, void *to, size_t len);
161 void twiddle(void);
162
163 /* probe_keyboard.c */
164 int probe_keyboard(void);
165
166 /* serial.S */
167 void serial_putc(int ch);
168 int serial_getc(void);
169 int serial_ischar(void);
170 void init_serial(void);
171
172 /* table.c */
173 extern char *devs[];
174 extern unsigned long tw_chars;
175
176 /* malloc.c */
177 void *malloc(size_t size);
178 void free(void *chunk);
179
180 /* linker stuff */
181 extern void end;