Home | History | Annotate | Line # | Download | only in include
bootinfo.h revision 1.9.2.2
      1  1.9.2.2      yamt /*	$NetBSD: bootinfo.h,v 1.9.2.2 2008/01/21 09:40:06 yamt 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.1      fvdl #ifndef _LOCORE
     30      1.1      fvdl 
     31      1.1      fvdl struct btinfo_common {
     32      1.1      fvdl 	int len;
     33      1.1      fvdl 	int type;
     34      1.1      fvdl };
     35      1.1      fvdl 
     36      1.6   thorpej #define BTINFO_BOOTPATH		0
     37  1.9.2.1      yamt #define BTINFO_ROOTDEVICE	1
     38      1.6   thorpej #define BTINFO_BOOTDISK		3
     39      1.6   thorpej #define BTINFO_NETIF		4
     40      1.6   thorpej #define BTINFO_CONSOLE		6
     41      1.6   thorpej #define BTINFO_BIOSGEOM		7
     42      1.6   thorpej #define BTINFO_SYMTAB		8
     43      1.6   thorpej #define BTINFO_MEMMAP		9
     44      1.6   thorpej #define	BTINFO_BOOTWEDGE	10
     45      1.1      fvdl 
     46      1.1      fvdl struct btinfo_bootpath {
     47      1.1      fvdl 	struct btinfo_common common;
     48      1.1      fvdl 	char bootpath[80];
     49      1.1      fvdl };
     50      1.1      fvdl 
     51  1.9.2.1      yamt struct btinfo_rootdevice {
     52  1.9.2.1      yamt 	struct btinfo_common common;
     53  1.9.2.1      yamt 	char devname[16];
     54  1.9.2.1      yamt };
     55  1.9.2.1      yamt 
     56      1.1      fvdl struct btinfo_bootdisk {
     57      1.1      fvdl 	struct btinfo_common common;
     58      1.1      fvdl 	int labelsector; /* label valid if != -1 */
     59      1.1      fvdl 	struct {
     60      1.9  junyoung 		uint16_t type, checksum;
     61      1.1      fvdl 		char packname[16];
     62      1.1      fvdl 	} label;
     63      1.1      fvdl 	int biosdev;
     64      1.1      fvdl 	int partition;
     65      1.1      fvdl };
     66      1.1      fvdl 
     67      1.6   thorpej struct btinfo_bootwedge {
     68      1.6   thorpej 	struct btinfo_common common;
     69      1.6   thorpej 	int biosdev;
     70      1.6   thorpej 	daddr_t startblk;
     71      1.6   thorpej 	uint64_t nblks;
     72      1.6   thorpej 	daddr_t matchblk;
     73      1.6   thorpej 	uint64_t matchnblks;
     74      1.6   thorpej 	uint8_t matchhash[16];	/* MD5 hash */
     75  1.9.2.2      yamt } __packed;
     76      1.6   thorpej 
     77      1.1      fvdl struct btinfo_netif {
     78      1.1      fvdl 	struct btinfo_common common;
     79      1.1      fvdl 	char ifname[16];
     80      1.1      fvdl 	int bus;
     81      1.1      fvdl #define BI_BUS_ISA 0
     82      1.1      fvdl #define BI_BUS_PCI 1
     83      1.1      fvdl 	union {
     84      1.1      fvdl 		unsigned int iobase; /* ISA */
     85      1.1      fvdl 		unsigned int tag; /* PCI, BIOS format */
     86      1.1      fvdl 	} addr;
     87      1.1      fvdl };
     88      1.1      fvdl 
     89      1.1      fvdl struct btinfo_console {
     90      1.1      fvdl 	struct btinfo_common common;
     91      1.1      fvdl 	char devname[16];
     92      1.1      fvdl 	int addr;
     93      1.1      fvdl 	int speed;
     94      1.1      fvdl };
     95      1.1      fvdl 
     96      1.1      fvdl struct btinfo_symtab {
     97      1.1      fvdl 	struct btinfo_common common;
     98      1.1      fvdl 	int nsym;
     99      1.1      fvdl 	int ssym;
    100      1.1      fvdl 	int esym;
    101      1.1      fvdl };
    102      1.1      fvdl 
    103      1.1      fvdl struct bi_memmap_entry {
    104      1.9  junyoung 	uint64_t addr;		/* beginning of block */	/* 8 */
    105      1.9  junyoung 	uint64_t size;		/* size of block */		/* 8 */
    106      1.9  junyoung 	uint32_t type;		/* type of block */		/* 4 */
    107  1.9.2.2      yamt } __packed;				/*	== 20 */
    108      1.1      fvdl 
    109      1.1      fvdl #define	BIM_Memory	1	/* available RAM usable by OS */
    110      1.1      fvdl #define	BIM_Reserved	2	/* in use or reserved by the system */
    111      1.1      fvdl #define	BIM_ACPI	3	/* ACPI Reclaim memory */
    112      1.1      fvdl #define	BIM_NVS		4	/* ACPI NVS memory */
    113      1.1      fvdl 
    114      1.1      fvdl struct btinfo_memmap {
    115      1.1      fvdl 	struct btinfo_common common;
    116      1.1      fvdl 	int num;
    117      1.1      fvdl 	struct bi_memmap_entry entry[1]; /* var len */
    118      1.1      fvdl };
    119      1.1      fvdl 
    120      1.8    dyoung #if HAVE_NBTOOL_CONFIG_H
    121      1.8    dyoung #include <nbinclude/sys/bootblock.h>
    122      1.8    dyoung #else
    123      1.3     lukem #include <sys/bootblock.h>
    124      1.8    dyoung #endif /* HAVE_NBTOOL_CONFIG_H */
    125      1.1      fvdl 
    126      1.1      fvdl /*
    127      1.1      fvdl  * Structure describing disk info as seen by the BIOS.
    128      1.1      fvdl  */
    129      1.1      fvdl struct bi_biosgeom_entry {
    130      1.2       dsl 	int		sec, head, cyl;		/* geometry */
    131      1.9  junyoung 	uint64_t	totsec;			/* LBA sectors from ext int13 */
    132      1.2       dsl 	int		flags, dev;		/* flags, BIOS device # */
    133      1.2       dsl #define BI_GEOM_INVALID		0x000001
    134      1.2       dsl #define BI_GEOM_EXTINT13	0x000002
    135      1.9  junyoung #ifdef BIOSDISK_EXTINFO_V3
    136      1.2       dsl #define BI_GEOM_BADCKSUM	0x000004	/* v3.x checksum invalid */
    137      1.2       dsl #define BI_GEOM_BUS_MASK	0x00ff00	/* connecting bus type */
    138      1.2       dsl #define BI_GEOM_BUS_ISA		0x000100
    139      1.2       dsl #define BI_GEOM_BUS_PCI		0x000200
    140      1.2       dsl #define BI_GEOM_BUS_OTHER	0x00ff00
    141      1.2       dsl #define BI_GEOM_IFACE_MASK	0xff0000	/* interface type */
    142      1.2       dsl #define BI_GEOM_IFACE_ATA	0x010000
    143      1.2       dsl #define BI_GEOM_IFACE_ATAPI	0x020000
    144      1.2       dsl #define BI_GEOM_IFACE_SCSI	0x030000
    145      1.2       dsl #define BI_GEOM_IFACE_USB	0x040000
    146      1.2       dsl #define BI_GEOM_IFACE_1394	0x050000	/* Firewire */
    147      1.2       dsl #define BI_GEOM_IFACE_FIBRE	0x060000	/* Fibre channel */
    148      1.9  junyoung #define BI_GEOM_IFACE_OTHER	0xff0000
    149      1.2       dsl 	unsigned int	cksum;			/* MBR checksum */
    150      1.9  junyoung 	unsigned int	interface_path;		/* ISA iobase PCI bus/dev/fun */
    151      1.9  junyoung 	uint64_t	device_path;
    152      1.2       dsl 	int		res0;			/* future expansion; 0 now */
    153      1.2       dsl #else
    154      1.2       dsl 	unsigned int	cksum;			/* MBR checksum */
    155      1.2       dsl 	int		res0, res1, res2, res3;	/* future expansion; 0 now */
    156      1.2       dsl #endif
    157      1.3     lukem 	struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
    158  1.9.2.2      yamt } __packed;
    159      1.1      fvdl 
    160      1.1      fvdl struct btinfo_biosgeom {
    161      1.1      fvdl 	struct btinfo_common common;
    162      1.1      fvdl 	int num;
    163      1.1      fvdl 	struct bi_biosgeom_entry disk[1]; /* var len */
    164      1.1      fvdl };
    165      1.1      fvdl 
    166      1.1      fvdl #endif /* _LOCORE */
    167      1.1      fvdl 
    168      1.1      fvdl #ifdef _KERNEL
    169  1.9.2.1      yamt 
    170      1.1      fvdl #define BOOTINFO_MAXSIZE 4096
    171  1.9.2.1      yamt 
    172  1.9.2.1      yamt #ifndef _LOCORE
    173  1.9.2.1      yamt /*
    174  1.9.2.1      yamt  * Structure that holds the information passed by the boot loader.
    175  1.9.2.1      yamt  */
    176  1.9.2.1      yamt struct bootinfo {
    177  1.9.2.1      yamt 	/* Number of bootinfo_* entries in bi_data. */
    178  1.9.2.1      yamt 	uint32_t	bi_nentries;
    179  1.9.2.1      yamt 
    180  1.9.2.1      yamt 	/* Raw data of bootinfo entries.  The first one (if any) is
    181  1.9.2.1      yamt 	 * found at bi_data[0] and can be casted to (bootinfo_common *).
    182  1.9.2.1      yamt 	 * Once this is done, the following entry is found at 'len'
    183  1.9.2.1      yamt 	 * offset as specified by the previous entry. */
    184  1.9.2.1      yamt 	uint8_t		bi_data[BOOTINFO_MAXSIZE - sizeof(uint32_t)];
    185  1.9.2.1      yamt };
    186  1.9.2.1      yamt 
    187  1.9.2.1      yamt void *lookup_bootinfo(int);
    188  1.9.2.1      yamt #endif /* _LOCORE */
    189  1.9.2.1      yamt 
    190  1.9.2.1      yamt #endif /* _KERNEL */
    191