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