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