1 /* $OpenBSD: biosvar.h,v 1.38 2001/02/28 16:45:25 mickey Exp $ */ 2 3 /* 4 * Copyright (c) 1997-1999 Michael Shalayeff 5 * 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 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Michael Shalayeff. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef _I386_BIOSVAR_H_ 35 #define _I386_BIOSVAR_H_ 36 #pragma pack(1) 37 38 /* some boxes put apm data seg in the 2nd page */ 39 #define BOOTARG_OFF (NBPG*2) 40 #define BOOTARG_LEN (NBPG*1) 41 #define BOOTBIOS_ADDR (0x7c00) 42 43 /* BIOS configure flags */ 44 #define BIOSF_BIOS32 0x0001 45 #define BIOSF_PCIBIOS 0x0002 46 #define BIOSF_PROMSCAN 0x0004 47 48 /* BIOS media ID */ 49 #define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */ 50 #define BIOSM_F160K 0xfe /* floppy ss/sd 8 spt */ 51 #define BIOSM_F360K 0xfd /* floppy ds/sd 9 spt */ 52 #define BIOSM_F180K 0xfc /* floppy ss/sd 9 spt */ 53 #define BIOSM_ROMD 0xfa /* ROM disk */ 54 #define BIOSM_F120M 0xf9 /* floppy ds/hd 15 spt 5.25" */ 55 #define BIOSM_F720K 0xf9 /* floppy ds/dd 9 spt 3.50" */ 56 #define BIOSM_HD 0xf8 /* hard drive */ 57 #define BIOSM_F144K 0xf0 /* floppy ds/hd 18 spt 3.50" */ 58 #define BIOSM_OTHER 0xf0 /* any other */ 59 60 /* 61 * BIOS memory maps 62 */ 63 #define BIOS_MAP_END 0x00 /* End of array XXX - special */ 64 #define BIOS_MAP_FREE 0x01 /* Usable memory */ 65 #define BIOS_MAP_RES 0x02 /* Reserved memory */ 66 #define BIOS_MAP_ACPI 0x03 /* ACPI Reclaim memory */ 67 #define BIOS_MAP_NVS 0x04 /* ACPI NVS memory */ 68 69 /* 70 * Optional ROM header 71 */ 72 typedef 73 struct bios_romheader { 74 u_int16_t signature; /* 0xaa55 */ 75 u_int8_t len; /* length in pages (512 bytes) */ 76 u_int32_t entry; /* initialization entry point */ 77 u_int8_t reserved[19]; 78 u_int16_t pnpheaader; /* offset to PnP expansion header */ 79 } *bios_romheader_t; 80 81 /* 82 * BIOS32 83 */ 84 typedef 85 struct bios32_header { 86 u_int32_t signature; /* 00: signature "_32_" */ 87 u_int32_t entry; /* 04: entry point */ 88 u_int8_t rev; /* 08: revision */ 89 u_int8_t length; /* 09: header length */ 90 u_int8_t cksum; /* 0a: modulo 256 checksum */ 91 u_int8_t reserved[5]; 92 } *bios32_header_t; 93 94 typedef 95 struct bios32_entry_info { 96 paddr_t bei_base; 97 psize_t bei_size; 98 paddr_t bei_entry; 99 } *bios32_entry_info_t; 100 101 typedef 102 struct bios32_entry { 103 u_int32_t offset; 104 u_int16_t segment; 105 } *bios32_entry_t; 106 107 #define BIOS32_START 0xe0000 108 #define BIOS32_SIZE 0x20000 109 #define BIOS32_END (BIOS32_START + BIOS32_SIZE - 0x10) 110 111 #define BIOS32_MAKESIG(a, b, c, d) \ 112 ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 113 #define BIOS32_SIGNATURE BIOS32_MAKESIG('_', '3', '2', '_') 114 #define PCIBIOS_SIGNATURE BIOS32_MAKESIG('$', 'P', 'C', 'I') 115 116 /* 117 * CTL_BIOS definitions. 118 */ 119 #define BIOS_DEV 1 /* int: BIOS boot device */ 120 #define BIOS_DISKINFO 2 /* struct: BIOS boot device info */ 121 #define BIOS_CKSUMLEN 3 /* int: disk cksum block count */ 122 #define BIOS_MAXID 4 /* number of valid machdep ids */ 123 124 #define CTL_BIOS_NAMES { \ 125 { 0, 0 }, \ 126 { "biosdev", CTLTYPE_INT }, \ 127 { "diskinfo", CTLTYPE_STRUCT }, \ 128 { "cksumlen", CTLTYPE_INT }, \ 129 } 130 131 #define BOOTARG_MEMMAP 0 132 typedef struct _bios_memmap { 133 u_int64_t addr; /* Beginning of block */ 134 u_int64_t size; /* Size of block */ 135 u_int32_t type; /* Type of block */ 136 } bios_memmap_t; 137 138 /* Info about disk from the bios, plus the mapping from 139 * BIOS numbers to BSD major (driver?) number. 140 * 141 * Also, do not bother with BIOSN*() macros, just parcel 142 * the info out, and use it like this. This makes for less 143 * of a dependance on BIOSN*() macros having to be the same 144 * across /boot, /bsd, and userland. 145 */ 146 #define BOOTARG_DISKINFO 1 147 typedef struct _bios_diskinfo { 148 /* BIOS section */ 149 int bios_number; /* BIOS number of drive (or -1) */ 150 u_int bios_cylinders; /* BIOS cylinders */ 151 u_int bios_heads; /* BIOS heads */ 152 u_int bios_sectors; /* BIOS sectors */ 153 int bios_edd; /* EDD support */ 154 155 /* BSD section */ 156 dev_t bsd_dev; /* BSD device */ 157 158 /* Checksum section */ 159 u_int32_t checksum; /* Checksum for drive */ 160 161 /* Misc. flags */ 162 u_int32_t flags; 163 #define BDI_INVALID 0x00000001 /* I/O error during checksumming */ 164 #define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */ 165 #define BDI_BADLABEL 0x00000004 /* Had another disklabel */ 166 #define BDI_PICKED 0x80000000 /* kernel-only: cksum matched */ 167 168 } bios_diskinfo_t; 169 170 #define BOOTARG_APMINFO 2 171 typedef struct _bios_apminfo { 172 /* APM_CONNECT returned values */ 173 u_int apm_detail; 174 u_int apm_code32_base; 175 u_int apm_code16_base; 176 u_int apm_code_len; 177 u_int apm_data_base; 178 u_int apm_data_len; 179 u_int apm_entry; 180 u_int apm_code16_len; 181 } bios_apminfo_t; 182 183 #define BOOTARG_CKSUMLEN 3 /* u_int32_t */ 184 185 #define BOOTARG_PCIINFO 4 186 typedef struct _bios_pciinfo { 187 /* PCI BIOS v2.0+ - Installation check values */ 188 u_int32_t pci_chars; /* Characteristics (%eax) */ 189 u_int32_t pci_rev; /* BCD Revision (%ebx) */ 190 u_int32_t pci_entry32; /* PM entry point for PCI BIOS */ 191 u_int32_t pci_lastbus; /* Number of last PCI bus */ 192 } bios_pciinfo_t; 193 194 #define BOOTARG_CONSDEV 5 195 typedef struct _bios_consdev { 196 dev_t consdev; 197 int conspeed; 198 } bios_consdev_t; 199 200 #if defined(_KERNEL) || defined (_STANDALONE) 201 202 #ifdef _LOCORE 203 #define DOINT(n) int $0x20+(n) 204 #else 205 #define DOINT(n) "int $0x20+(" #n ")" 206 207 extern struct BIOS_regs { 208 u_int32_t biosr_ax; 209 u_int32_t biosr_cx; 210 u_int32_t biosr_dx; 211 u_int32_t biosr_bx; 212 u_int32_t biosr_bp; 213 u_int32_t biosr_si; 214 u_int32_t biosr_di; 215 u_int32_t biosr_ds; 216 u_int32_t biosr_es; 217 } BIOS_regs; 218 219 #ifdef _KERNEL 220 #include <machine/bus.h> 221 222 struct bios_attach_args { 223 char *bios_dev; 224 u_int bios_func; 225 bus_space_tag_t bios_iot; 226 bus_space_tag_t bios_memt; 227 union { 228 void *_p; 229 bios_apminfo_t *_bios_apmp; 230 } _; 231 }; 232 233 #define bios_apmp _._bios_apmp 234 235 struct consdev; 236 struct proc; 237 238 int bios_sysctl 239 __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *)); 240 241 void bioscnprobe __P((struct consdev *)); 242 void bioscninit __P((struct consdev *)); 243 void bioscnputc __P((dev_t, int)); 244 int bioscngetc __P((dev_t)); 245 void bioscnpollc __P((dev_t, int)); 246 void bios_getopt __P((void)); 247 248 /* bios32.c */ 249 int bios32_service __P((u_int32_t, bios32_entry_t, bios32_entry_info_t)); 250 251 extern u_int bootapiver; 252 extern bios_memmap_t *bios_memmap; 253 254 #endif /* _KERNEL */ 255 #endif /* _LOCORE */ 256 #endif /* _KERNEL || _STANDALONE */ 257 258 #pragma pack() 259 #endif /* _I386_BIOSVAR_H_ */ 260