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