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