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