xref: /netbsd-src/sys/arch/x86/include/bootinfo.h (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1 /*	$NetBSD: bootinfo.h,v 1.9 2005/07/06 08:27:31 junyoung 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 #ifndef _LOCORE
30 
31 struct btinfo_common {
32 	int len;
33 	int type;
34 };
35 
36 #define BTINFO_BOOTPATH		0
37 #define BTINFO_BOOTDISK		3
38 #define BTINFO_NETIF		4
39 #define BTINFO_CONSOLE		6
40 #define BTINFO_BIOSGEOM		7
41 #define BTINFO_SYMTAB		8
42 #define BTINFO_MEMMAP		9
43 #define	BTINFO_BOOTWEDGE	10
44 
45 struct btinfo_bootpath {
46 	struct btinfo_common common;
47 	char bootpath[80];
48 };
49 
50 struct btinfo_bootdisk {
51 	struct btinfo_common common;
52 	int labelsector; /* label valid if != -1 */
53 	struct {
54 		uint16_t type, checksum;
55 		char packname[16];
56 	} label;
57 	int biosdev;
58 	int partition;
59 };
60 
61 struct btinfo_bootwedge {
62 	struct btinfo_common common;
63 	int biosdev;
64 	daddr_t startblk;
65 	uint64_t nblks;
66 	daddr_t matchblk;
67 	uint64_t matchnblks;
68 	uint8_t matchhash[16];	/* MD5 hash */
69 } __attribute__((packed));
70 
71 struct btinfo_netif {
72 	struct btinfo_common common;
73 	char ifname[16];
74 	int bus;
75 #define BI_BUS_ISA 0
76 #define BI_BUS_PCI 1
77 	union {
78 		unsigned int iobase; /* ISA */
79 		unsigned int tag; /* PCI, BIOS format */
80 	} addr;
81 };
82 
83 struct btinfo_console {
84 	struct btinfo_common common;
85 	char devname[16];
86 	int addr;
87 	int speed;
88 };
89 
90 struct btinfo_symtab {
91 	struct btinfo_common common;
92 	int nsym;
93 	int ssym;
94 	int esym;
95 };
96 
97 struct bi_memmap_entry {
98 	uint64_t addr;		/* beginning of block */	/* 8 */
99 	uint64_t size;		/* size of block */		/* 8 */
100 	uint32_t type;		/* type of block */		/* 4 */
101 } __attribute__((packed));				/*	== 20 */
102 
103 #define	BIM_Memory	1	/* available RAM usable by OS */
104 #define	BIM_Reserved	2	/* in use or reserved by the system */
105 #define	BIM_ACPI	3	/* ACPI Reclaim memory */
106 #define	BIM_NVS		4	/* ACPI NVS memory */
107 
108 struct btinfo_memmap {
109 	struct btinfo_common common;
110 	int num;
111 	struct bi_memmap_entry entry[1]; /* var len */
112 };
113 
114 #if HAVE_NBTOOL_CONFIG_H
115 #include <nbinclude/sys/bootblock.h>
116 #else
117 #include <sys/bootblock.h>
118 #endif /* HAVE_NBTOOL_CONFIG_H */
119 
120 /*
121  * Structure describing disk info as seen by the BIOS.
122  */
123 struct bi_biosgeom_entry {
124 	int		sec, head, cyl;		/* geometry */
125 	uint64_t	totsec;			/* LBA sectors from ext int13 */
126 	int		flags, dev;		/* flags, BIOS device # */
127 #define BI_GEOM_INVALID		0x000001
128 #define BI_GEOM_EXTINT13	0x000002
129 #ifdef BIOSDISK_EXTINFO_V3
130 #define BI_GEOM_BADCKSUM	0x000004	/* v3.x checksum invalid */
131 #define BI_GEOM_BUS_MASK	0x00ff00	/* connecting bus type */
132 #define BI_GEOM_BUS_ISA		0x000100
133 #define BI_GEOM_BUS_PCI		0x000200
134 #define BI_GEOM_BUS_OTHER	0x00ff00
135 #define BI_GEOM_IFACE_MASK	0xff0000	/* interface type */
136 #define BI_GEOM_IFACE_ATA	0x010000
137 #define BI_GEOM_IFACE_ATAPI	0x020000
138 #define BI_GEOM_IFACE_SCSI	0x030000
139 #define BI_GEOM_IFACE_USB	0x040000
140 #define BI_GEOM_IFACE_1394	0x050000	/* Firewire */
141 #define BI_GEOM_IFACE_FIBRE	0x060000	/* Fibre channel */
142 #define BI_GEOM_IFACE_OTHER	0xff0000
143 	unsigned int	cksum;			/* MBR checksum */
144 	unsigned int	interface_path;		/* ISA iobase PCI bus/dev/fun */
145 	uint64_t	device_path;
146 	int		res0;			/* future expansion; 0 now */
147 #else
148 	unsigned int	cksum;			/* MBR checksum */
149 	int		res0, res1, res2, res3;	/* future expansion; 0 now */
150 #endif
151 	struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
152 } __attribute__((packed));
153 
154 struct btinfo_biosgeom {
155 	struct btinfo_common common;
156 	int num;
157 	struct bi_biosgeom_entry disk[1]; /* var len */
158 };
159 
160 #ifdef _KERNEL
161 void *lookup_bootinfo(int);
162 #endif
163 #endif /* _LOCORE */
164 
165 #ifdef _KERNEL
166 #define BOOTINFO_MAXSIZE 4096
167 #endif
168