biosvar.h revision 1.26
1/* $OpenBSD: biosvar.h,v 1.26 2019/08/04 14:28:58 kettenis 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. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef _MACHINE_BIOSVAR_H_ 32#define _MACHINE_BIOSVAR_H_ 33 34 /* some boxes put apm data seg in the 2nd page */ 35#define BOOTARG_OFF (PAGE_SIZE * 2) 36#define BOOTARG_LEN (PAGE_SIZE * 1) 37#define BOOTBIOS_ADDR (0x7c00) 38#define BOOTBIOS_MAXSEC ((1 << 28) - 1) 39 40 /* BIOS configure flags */ 41#define BIOSF_BIOS32 0x0001 42#define BIOSF_PCIBIOS 0x0002 43#define BIOSF_PROMSCAN 0x0004 44#define BIOSF_SMBIOS 0x0006 45 46/* BIOS media ID */ 47#define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */ 48#define BIOSM_F160K 0xfe /* floppy ss/sd 8 spt */ 49#define BIOSM_F360K 0xfd /* floppy ds/sd 9 spt */ 50#define BIOSM_F180K 0xfc /* floppy ss/sd 9 spt */ 51#define BIOSM_ROMD 0xfa /* ROM disk */ 52#define BIOSM_F120M 0xf9 /* floppy ds/hd 15 spt 5.25" */ 53#define BIOSM_F720K 0xf9 /* floppy ds/dd 9 spt 3.50" */ 54#define BIOSM_HD 0xf8 /* hard drive */ 55#define BIOSM_F144K 0xf0 /* floppy ds/hd 18 spt 3.50" */ 56#define BIOSM_OTHER 0xf0 /* any other */ 57 58/* 59 * BIOS memory maps 60 */ 61#define BIOS_MAP_END 0x00 /* End of array XXX - special */ 62#define BIOS_MAP_FREE 0x01 /* Usable memory */ 63#define BIOS_MAP_RES 0x02 /* Reserved memory */ 64#define BIOS_MAP_ACPI 0x03 /* ACPI Reclaim memory */ 65#define BIOS_MAP_NVS 0x04 /* ACPI NVS memory */ 66 67/* 68 * Optional ROM header 69 */ 70typedef 71struct bios_romheader { 72 uint16_t signature; /* 0xaa55 */ 73 uint8_t len; /* length in pages (512 bytes) */ 74 uint32_t entry; /* initialization entry point */ 75 uint8_t reserved[19]; 76 uint16_t pnpheader; /* offset to PnP expansion header */ 77} __packed *bios_romheader_t; 78 79#define BIOS32_MAKESIG(a, b, c, d) \ 80 ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 81#define SMBIOS_SIGNATURE BIOS32_MAKESIG('_', 'S', 'M', '_') 82 83/* 84 * CTL_BIOS definitions. 85 */ 86#define BIOS_DEV 1 /* int: BIOS boot device */ 87#define BIOS_DISKINFO 2 /* struct: BIOS boot device info */ 88#define BIOS_CKSUMLEN 3 /* int: disk cksum block count */ 89#define BIOS_MAXID 4 /* number of valid machdep ids */ 90 91#define CTL_BIOS_NAMES { \ 92 { 0, 0 }, \ 93 { "biosdev", CTLTYPE_INT }, \ 94 { "diskinfo", CTLTYPE_STRUCT }, \ 95 { "cksumlen", CTLTYPE_INT }, \ 96} 97 98#define BOOTARG_MEMMAP 0 99typedef struct _bios_memmap { 100 uint64_t addr; /* Beginning of block */ 101 uint64_t size; /* Size of block */ 102 uint32_t type; /* Type of block */ 103} __packed bios_memmap_t; 104 105/* Info about disk from the bios, plus the mapping from 106 * BIOS numbers to BSD major (driver?) number. 107 * 108 * Also, do not bother with BIOSN*() macros, just parcel 109 * the info out, and use it like this. This makes for less 110 * of a dependence on BIOSN*() macros having to be the same 111 * across /boot, /bsd, and userland. 112 */ 113#define BOOTARG_DISKINFO 1 114typedef struct _bios_diskinfo { 115 /* BIOS section */ 116 int bios_number; /* BIOS number of drive (or -1) */ 117 u_int bios_cylinders; /* BIOS cylinders */ 118 u_int bios_heads; /* BIOS heads */ 119 u_int bios_sectors; /* BIOS sectors */ 120 int bios_edd; /* EDD support */ 121 122 /* BSD section */ 123 dev_t bsd_dev; /* BSD device */ 124 125 /* Checksum section */ 126 uint32_t checksum; /* Checksum for drive */ 127 128 /* Misc. flags */ 129 uint32_t flags; 130#define BDI_INVALID 0x00000001 /* I/O error during checksumming */ 131#define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */ 132#define BDI_BADLABEL 0x00000004 /* Had another disklabel */ 133#define BDI_EL_TORITO 0x00000008 /* 2,048-byte sectors */ 134#define BDI_HIBVALID 0x00000010 /* hibernate signature valid */ 135#define BDI_PICKED 0x80000000 /* kernel-only: cksum matched */ 136 137} __packed bios_diskinfo_t; 138 139#define BOOTARG_APMINFO 2 140typedef struct _bios_apminfo { 141 /* APM_CONNECT returned values */ 142 u_int apm_detail; 143 u_int apm_code32_base; 144 u_int apm_code16_base; 145 u_int apm_code_len; 146 u_int apm_data_base; 147 u_int apm_data_len; 148 u_int apm_entry; 149 u_int apm_code16_len; 150} __packed bios_apminfo_t; 151 152#define BOOTARG_CKSUMLEN 3 /* uint32_t */ 153 154#define BOOTARG_PCIINFO 4 155typedef struct _bios_pciinfo { 156 /* PCI BIOS v2.0+ - Installation check values */ 157 uint32_t pci_chars; /* Characteristics (%eax) */ 158 uint32_t pci_rev; /* BCD Revision (%ebx) */ 159 uint32_t pci_entry32; /* PM entry point for PCI BIOS */ 160 uint32_t pci_lastbus; /* Number of last PCI bus */ 161} __packed bios_pciinfo_t; 162 163#define BOOTARG_CONSDEV 5 164typedef struct _bios_consdev { 165 dev_t consdev; 166 int conspeed; 167 int consaddr; 168 int consfreq; 169} __packed bios_consdev_t; 170 171#define BOOTARG_BOOTMAC 7 172typedef struct _bios_bootmac { 173 char mac[6]; 174} __packed bios_bootmac_t; 175 176#define BOOTARG_DDB 8 177typedef struct _bios_ddb { 178 int db_console; 179} __packed bios_ddb_t; 180 181#define BOOTARG_BOOTDUID 9 182typedef struct _bios_bootduid { 183 u_char duid[8]; 184} __packed bios_bootduid_t; 185 186#define BOOTARG_BOOTSR 10 187#define BOOTSR_UUID_MAX 16 188#define BOOTSR_CRYPTO_MAXKEYBYTES 32 189typedef struct _bios_bootsr { 190 uint8_t uuid[BOOTSR_UUID_MAX]; 191 uint8_t maskkey[BOOTSR_CRYPTO_MAXKEYBYTES]; 192} __packed bios_bootsr_t; 193 194#define BOOTARG_EFIINFO 11 195typedef struct _bios_efiinfo { 196 uint64_t config_acpi; 197 uint64_t config_smbios; 198 uint64_t fb_addr; 199 uint64_t fb_size; 200 uint32_t fb_height; 201 uint32_t fb_width; 202 uint32_t fb_pixpsl; /* pixels per scan line */ 203 uint32_t fb_red_mask; 204 uint32_t fb_green_mask; 205 uint32_t fb_blue_mask; 206 uint32_t fb_reserved_mask; 207} __packed bios_efiinfo_t; 208 209#define BOOTARG_UCODE 12 210typedef struct _bios_ucode { 211 uint64_t uc_addr; 212 uint64_t uc_size; 213} __packed bios_ucode_t; 214 215#if defined(_KERNEL) || defined (_STANDALONE) 216 217#ifdef _LOCORE 218#define DOINT(n) int $0x20+(n) 219#else 220#define DOINT(n) "int $0x20+(" #n ")" 221 222extern volatile struct BIOS_regs { 223 uint32_t biosr_ax; 224 uint32_t biosr_cx; 225 uint32_t biosr_dx; 226 uint32_t biosr_bx; 227 uint32_t biosr_bp; 228 uint32_t biosr_si; 229 uint32_t biosr_di; 230 uint32_t biosr_ds; 231 uint32_t biosr_es; 232} __packed BIOS_regs; 233 234#ifdef _KERNEL 235#include <machine/bus.h> 236 237struct bios_attach_args { 238 char *ba_name; 239 u_int ba_func; 240 bus_space_tag_t ba_iot; 241 bus_space_tag_t ba_memt; 242 union { 243 void *_p; 244 bios_apminfo_t *_ba_apmp; 245 paddr_t _ba_acpipbase; 246 } _; 247}; 248 249#define ba_apmp _._ba_apmp 250#define ba_acpipbase _._ba_acpipbase 251 252struct consdev; 253struct proc; 254 255int bios_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); 256 257void bios_getopt(void); 258bios_diskinfo_t *bios_getdiskinfo(dev_t); 259 260extern u_int bootapiver; 261extern bios_memmap_t *bios_memmap; 262extern bios_efiinfo_t *bios_efiinfo; 263extern bios_ucode_t *bios_ucode; 264 265#endif /* _KERNEL */ 266#endif /* _LOCORE */ 267#endif /* _KERNEL || _STANDALONE */ 268 269#endif /* _MACHINE_BIOSVAR_H_ */ 270