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