bootinfo.h revision 1.13 1 /* $NetBSD: bootinfo.h,v 1.13 2008/05/02 15:26:39 ad Exp $ */
2
3 /*
4 * Copyright (c) 1997
5 * Matthias Drochner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29 #define BTINFO_BOOTPATH 0
30 #define BTINFO_ROOTDEVICE 1
31 #define BTINFO_BOOTDISK 3
32 #define BTINFO_NETIF 4
33 #define BTINFO_CONSOLE 6
34 #define BTINFO_BIOSGEOM 7
35 #define BTINFO_SYMTAB 8
36 #define BTINFO_MEMMAP 9
37 #define BTINFO_BOOTWEDGE 10
38 #define BTINFO_MODULELIST 11
39
40 #ifndef _LOCORE
41
42 struct btinfo_common {
43 int len;
44 int type;
45 };
46
47 struct btinfo_bootpath {
48 struct btinfo_common common;
49 char bootpath[80];
50 };
51
52 struct btinfo_rootdevice {
53 struct btinfo_common common;
54 char devname[16];
55 };
56
57 struct btinfo_bootdisk {
58 struct btinfo_common common;
59 int labelsector; /* label valid if != -1 */
60 struct {
61 uint16_t type, checksum;
62 char packname[16];
63 } label;
64 int biosdev;
65 int partition;
66 };
67
68 struct btinfo_bootwedge {
69 struct btinfo_common common;
70 int biosdev;
71 daddr_t startblk;
72 uint64_t nblks;
73 daddr_t matchblk;
74 uint64_t matchnblks;
75 uint8_t matchhash[16]; /* MD5 hash */
76 } __packed;
77
78 struct btinfo_netif {
79 struct btinfo_common common;
80 char ifname[16];
81 int bus;
82 #define BI_BUS_ISA 0
83 #define BI_BUS_PCI 1
84 union {
85 unsigned int iobase; /* ISA */
86 unsigned int tag; /* PCI, BIOS format */
87 } addr;
88 };
89
90 struct btinfo_console {
91 struct btinfo_common common;
92 char devname[16];
93 int addr;
94 int speed;
95 };
96
97 struct btinfo_symtab {
98 struct btinfo_common common;
99 int nsym;
100 int ssym;
101 int esym;
102 };
103
104 struct bi_memmap_entry {
105 uint64_t addr; /* beginning of block */ /* 8 */
106 uint64_t size; /* size of block */ /* 8 */
107 uint32_t type; /* type of block */ /* 4 */
108 } __packed; /* == 20 */
109
110 #define BIM_Memory 1 /* available RAM usable by OS */
111 #define BIM_Reserved 2 /* in use or reserved by the system */
112 #define BIM_ACPI 3 /* ACPI Reclaim memory */
113 #define BIM_NVS 4 /* ACPI NVS memory */
114
115 struct btinfo_memmap {
116 struct btinfo_common common;
117 int num;
118 struct bi_memmap_entry entry[1]; /* var len */
119 };
120
121 #if HAVE_NBTOOL_CONFIG_H
122 #include <nbinclude/sys/bootblock.h>
123 #else
124 #include <sys/bootblock.h>
125 #endif /* HAVE_NBTOOL_CONFIG_H */
126
127 /*
128 * Structure describing disk info as seen by the BIOS.
129 */
130 struct bi_biosgeom_entry {
131 int sec, head, cyl; /* geometry */
132 uint64_t totsec; /* LBA sectors from ext int13 */
133 int flags, dev; /* flags, BIOS device # */
134 #define BI_GEOM_INVALID 0x000001
135 #define BI_GEOM_EXTINT13 0x000002
136 #ifdef BIOSDISK_EXTINFO_V3
137 #define BI_GEOM_BADCKSUM 0x000004 /* v3.x checksum invalid */
138 #define BI_GEOM_BUS_MASK 0x00ff00 /* connecting bus type */
139 #define BI_GEOM_BUS_ISA 0x000100
140 #define BI_GEOM_BUS_PCI 0x000200
141 #define BI_GEOM_BUS_OTHER 0x00ff00
142 #define BI_GEOM_IFACE_MASK 0xff0000 /* interface type */
143 #define BI_GEOM_IFACE_ATA 0x010000
144 #define BI_GEOM_IFACE_ATAPI 0x020000
145 #define BI_GEOM_IFACE_SCSI 0x030000
146 #define BI_GEOM_IFACE_USB 0x040000
147 #define BI_GEOM_IFACE_1394 0x050000 /* Firewire */
148 #define BI_GEOM_IFACE_FIBRE 0x060000 /* Fibre channel */
149 #define BI_GEOM_IFACE_OTHER 0xff0000
150 unsigned int cksum; /* MBR checksum */
151 unsigned int interface_path; /* ISA iobase PCI bus/dev/fun */
152 uint64_t device_path;
153 int res0; /* future expansion; 0 now */
154 #else
155 unsigned int cksum; /* MBR checksum */
156 int res0, res1, res2, res3; /* future expansion; 0 now */
157 #endif
158 struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
159 } __packed;
160
161 struct btinfo_biosgeom {
162 struct btinfo_common common;
163 int num;
164 struct bi_biosgeom_entry disk[1]; /* var len */
165 };
166
167 struct bi_modulelist_entry {
168 char path[80];
169 int type;
170 int len;
171 uint32_t base;
172 };
173 #define BI_MODULE_NONE 0x00
174 #define BI_MODULE_ELF 0x01
175
176 struct btinfo_modulelist {
177 struct btinfo_common common;
178 int num;
179 uint32_t endpa;
180 /* bi_modulelist_entry list follows */
181 };
182
183 #endif /* _LOCORE */
184
185 #ifdef _KERNEL
186
187 #define BOOTINFO_MAXSIZE 4096
188
189 #ifndef _LOCORE
190 /*
191 * Structure that holds the information passed by the boot loader.
192 */
193 struct bootinfo {
194 /* Number of bootinfo_* entries in bi_data. */
195 uint32_t bi_nentries;
196
197 /* Raw data of bootinfo entries. The first one (if any) is
198 * found at bi_data[0] and can be casted to (bootinfo_common *).
199 * Once this is done, the following entry is found at 'len'
200 * offset as specified by the previous entry. */
201 uint8_t bi_data[BOOTINFO_MAXSIZE - sizeof(uint32_t)];
202 };
203
204 void *lookup_bootinfo(int);
205 #endif /* _LOCORE */
206
207 #endif /* _KERNEL */
208