bootinfo.h revision 1.16.4.1 1 /* $NetBSD: bootinfo.h,v 1.16.4.1 2011/03/05 20:52:27 rmind 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 #define BTINFO_FRAMEBUFFER 12
40
41 #ifndef _LOCORE
42
43 struct btinfo_common {
44 int len;
45 int type;
46 };
47
48 struct btinfo_bootpath {
49 struct btinfo_common common;
50 char bootpath[80];
51 };
52
53 struct btinfo_rootdevice {
54 struct btinfo_common common;
55 char devname[16];
56 };
57
58 struct btinfo_bootdisk {
59 struct btinfo_common common;
60 int labelsector; /* label valid if != -1 */
61 struct {
62 uint16_t type, checksum;
63 char packname[16];
64 } label;
65 int biosdev;
66 int partition;
67 };
68
69 struct btinfo_bootwedge {
70 struct btinfo_common common;
71 int biosdev;
72 daddr_t startblk;
73 uint64_t nblks;
74 daddr_t matchblk;
75 uint64_t matchnblks;
76 uint8_t matchhash[16]; /* MD5 hash */
77 } __packed;
78
79 struct btinfo_netif {
80 struct btinfo_common common;
81 char ifname[16];
82 int bus;
83 #define BI_BUS_ISA 0
84 #define BI_BUS_PCI 1
85 union {
86 unsigned int iobase; /* ISA */
87 unsigned int tag; /* PCI, BIOS format */
88 } addr;
89 };
90
91 struct btinfo_console {
92 struct btinfo_common common;
93 char devname[16];
94 int addr;
95 int speed;
96 };
97
98 struct btinfo_symtab {
99 struct btinfo_common common;
100 int nsym;
101 int ssym;
102 int esym;
103 };
104
105 struct bi_memmap_entry {
106 uint64_t addr; /* beginning of block */ /* 8 */
107 uint64_t size; /* size of block */ /* 8 */
108 uint32_t type; /* type of block */ /* 4 */
109 } __packed; /* == 20 */
110
111 #define BIM_Memory 1 /* available RAM usable by OS */
112 #define BIM_Reserved 2 /* in use or reserved by the system */
113 #define BIM_ACPI 3 /* ACPI Reclaim memory */
114 #define BIM_NVS 4 /* ACPI NVS memory */
115
116 struct btinfo_memmap {
117 struct btinfo_common common;
118 int num;
119 struct bi_memmap_entry entry[1]; /* var len */
120 };
121
122 #if HAVE_NBTOOL_CONFIG_H
123 #include <nbinclude/sys/bootblock.h>
124 #else
125 #include <sys/bootblock.h>
126 #endif /* HAVE_NBTOOL_CONFIG_H */
127
128 /*
129 * Structure describing disk info as seen by the BIOS.
130 */
131 struct bi_biosgeom_entry {
132 int sec, head, cyl; /* geometry */
133 uint64_t totsec; /* LBA sectors from ext int13 */
134 int flags, dev; /* flags, BIOS device # */
135 #define BI_GEOM_INVALID 0x000001
136 #define BI_GEOM_EXTINT13 0x000002
137 #ifdef BIOSDISK_EXTINFO_V3
138 #define BI_GEOM_BADCKSUM 0x000004 /* v3.x checksum invalid */
139 #define BI_GEOM_BUS_MASK 0x00ff00 /* connecting bus type */
140 #define BI_GEOM_BUS_ISA 0x000100
141 #define BI_GEOM_BUS_PCI 0x000200
142 #define BI_GEOM_BUS_OTHER 0x00ff00
143 #define BI_GEOM_IFACE_MASK 0xff0000 /* interface type */
144 #define BI_GEOM_IFACE_ATA 0x010000
145 #define BI_GEOM_IFACE_ATAPI 0x020000
146 #define BI_GEOM_IFACE_SCSI 0x030000
147 #define BI_GEOM_IFACE_USB 0x040000
148 #define BI_GEOM_IFACE_1394 0x050000 /* Firewire */
149 #define BI_GEOM_IFACE_FIBRE 0x060000 /* Fibre channel */
150 #define BI_GEOM_IFACE_OTHER 0xff0000
151 unsigned int cksum; /* MBR checksum */
152 unsigned int interface_path; /* ISA iobase PCI bus/dev/fun */
153 uint64_t device_path;
154 int res0; /* future expansion; 0 now */
155 #else
156 unsigned int cksum; /* MBR checksum */
157 int res0, res1, res2, res3; /* future expansion; 0 now */
158 #endif
159 struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
160 } __packed;
161
162 struct btinfo_biosgeom {
163 struct btinfo_common common;
164 int num;
165 struct bi_biosgeom_entry disk[1]; /* var len */
166 };
167
168 struct bi_modulelist_entry {
169 char path[80];
170 int type;
171 int len;
172 uint32_t base;
173 };
174 #define BI_MODULE_NONE 0x00
175 #define BI_MODULE_ELF 0x01
176 #define BI_MODULE_IMAGE 0x02
177
178 struct btinfo_modulelist {
179 struct btinfo_common common;
180 int num;
181 uint32_t endpa;
182 /* bi_modulelist_entry list follows */
183 };
184
185 struct btinfo_framebuffer {
186 struct btinfo_common common;
187 uint64_t physaddr;
188 uint32_t flags;
189 uint32_t width;
190 uint32_t height;
191 uint16_t stride;
192 uint8_t depth;
193 uint8_t rnum;
194 uint8_t gnum;
195 uint8_t bnum;
196 uint8_t rpos;
197 uint8_t gpos;
198 uint8_t bpos;
199 uint16_t vbemode;
200 uint8_t reserved[14];
201 };
202
203 #endif /* _LOCORE */
204
205 #ifdef _KERNEL
206
207 #define BOOTINFO_MAXSIZE 4096
208
209 #ifndef _LOCORE
210 /*
211 * Structure that holds the information passed by the boot loader.
212 */
213 struct bootinfo {
214 /* Number of bootinfo_* entries in bi_data. */
215 uint32_t bi_nentries;
216
217 /* Raw data of bootinfo entries. The first one (if any) is
218 * found at bi_data[0] and can be casted to (bootinfo_common *).
219 * Once this is done, the following entry is found at 'len'
220 * offset as specified by the previous entry. */
221 uint8_t bi_data[BOOTINFO_MAXSIZE - sizeof(uint32_t)];
222 };
223
224 extern struct bootinfo bootinfo;
225
226 void *lookup_bootinfo(int);
227 #endif /* _LOCORE */
228
229 #endif /* _KERNEL */
230