biosvar.h revision 1.10
1/* XXX - DSR */ 2/* $OpenBSD: biosvar.h,v 1.10 2009/04/30 01:16:56 dlg Exp $ */ 3 4/* 5 * Copyright (c) 1997-1999 Michael Shalayeff 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 * THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _I386_BIOSVAR_H_ 33#define _I386_BIOSVAR_H_ 34 35 /* some boxes put apm data seg in the 2nd page */ 36#define BOOTARG_OFF (NBPG*2) 37#define BOOTARG_LEN (NBPG*1) 38#define BOOTBIOS_ADDR (0x7c00) 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 u_int16_t signature; /* 0xaa55 */ 73 u_int8_t len; /* length in pages (512 bytes) */ 74 u_int32_t entry; /* initialization entry point */ 75 u_int8_t reserved[19]; 76 u_int16_t pnpheader; /* offset to PnP expansion header */ 77} __packed *bios_romheader_t; 78 79/* 80 * BIOS32 81 */ 82typedef 83struct bios32_header { 84 u_int32_t signature; /* 00: signature "_32_" */ 85 u_int32_t entry; /* 04: entry point */ 86 u_int8_t rev; /* 08: revision */ 87 u_int8_t length; /* 09: header length */ 88 u_int8_t cksum; /* 0a: modulo 256 checksum */ 89 u_int8_t reserved[5]; 90} __packed *bios32_header_t; 91 92typedef 93struct bios32_entry_info { 94 paddr_t bei_base; 95 psize_t bei_size; 96 paddr_t bei_entry; 97} __packed *bios32_entry_info_t; 98 99typedef 100struct bios32_entry { 101 u_int32_t offset; 102 u_int16_t segment; 103} __packed *bios32_entry_t; 104 105#define BIOS32_START 0xe0000 106#define BIOS32_SIZE 0x20000 107#define BIOS32_END (BIOS32_START + BIOS32_SIZE - 0x10) 108 109#define BIOS32_MAKESIG(a, b, c, d) \ 110 ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 111#define BIOS32_SIGNATURE BIOS32_MAKESIG('_', '3', '2', '_') 112#define PCIBIOS_SIGNATURE BIOS32_MAKESIG('$', 'P', 'C', 'I') 113#define SMBIOS_SIGNATURE BIOS32_MAKESIG('_', 'S', 'M', '_') 114 115/* 116 * CTL_BIOS definitions. 117 */ 118#define BIOS_DEV 1 /* int: BIOS boot device */ 119#define BIOS_DISKINFO 2 /* struct: BIOS boot device info */ 120#define BIOS_CKSUMLEN 3 /* int: disk cksum block count */ 121#define BIOS_MAXID 4 /* number of valid machdep ids */ 122 123#define CTL_BIOS_NAMES { \ 124 { 0, 0 }, \ 125 { "biosdev", CTLTYPE_INT }, \ 126 { "diskinfo", CTLTYPE_STRUCT }, \ 127 { "cksumlen", CTLTYPE_INT }, \ 128} 129 130#define BOOTARG_MEMMAP 0 131typedef struct _bios_memmap { 132 u_int64_t addr; /* Beginning of block */ 133 u_int64_t size; /* Size of block */ 134 u_int32_t type; /* Type of block */ 135} __packed bios_memmap_t; 136 137/* Info about disk from the bios, plus the mapping from 138 * BIOS numbers to BSD major (driver?) number. 139 * 140 * Also, do not bother with BIOSN*() macros, just parcel 141 * the info out, and use it like this. This makes for less 142 * of a dependance on BIOSN*() macros having to be the same 143 * across /boot, /bsd, and userland. 144 */ 145#define BOOTARG_DISKINFO 1 146typedef struct _bios_diskinfo { 147 /* BIOS section */ 148 int bios_number; /* BIOS number of drive (or -1) */ 149 u_int bios_cylinders; /* BIOS cylinders */ 150 u_int bios_heads; /* BIOS heads */ 151 u_int bios_sectors; /* BIOS sectors */ 152 int bios_edd; /* EDD support */ 153 154 /* BSD section */ 155 dev_t bsd_dev; /* BSD device */ 156 157 /* Checksum section */ 158 u_int32_t checksum; /* Checksum for drive */ 159 160 /* Misc. flags */ 161 u_int32_t flags; 162#define BDI_INVALID 0x00000001 /* I/O error during checksumming */ 163#define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */ 164#define BDI_BADLABEL 0x00000004 /* Had another disklabel */ 165#define BDI_EL_TORITO 0x00000008 /* 2,048-byte sectors */ 166#define BDI_PICKED 0x80000000 /* kernel-only: cksum matched */ 167 168} __packed bios_diskinfo_t; 169 170#define BOOTARG_APMINFO 2 171typedef 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} __packed bios_apminfo_t; 182 183#define BOOTARG_CKSUMLEN 3 /* u_int32_t */ 184 185#define BOOTARG_PCIINFO 4 186typedef 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} __packed bios_pciinfo_t; 193 194#define BOOTARG_CONSDEV 5 195typedef struct _bios_consdev { 196 dev_t consdev; 197 int conspeed; 198} __packed bios_consdev_t; 199 200#define BOOTARG_BOOTMAC 7 201typedef struct _bios_bootmac { 202 char mac[6]; 203} __packed bios_bootmac_t; 204 205#define BOOTARG_DDB 8 206typedef struct _bios_ddb { 207 int db_console; 208} __packed bios_ddb_t; 209 210#if defined(_KERNEL) || defined (_STANDALONE) 211 212#ifdef _LOCORE 213#define DOINT(n) int $0x20+(n) 214#else 215#define DOINT(n) "int $0x20+(" #n ")" 216 217extern volatile struct BIOS_regs { 218 u_int32_t biosr_ax; 219 u_int32_t biosr_cx; 220 u_int32_t biosr_dx; 221 u_int32_t biosr_bx; 222 u_int32_t biosr_bp; 223 u_int32_t biosr_si; 224 u_int32_t biosr_di; 225 u_int32_t biosr_ds; 226 u_int32_t biosr_es; 227} __packed BIOS_regs; 228 229#ifdef _KERNEL 230#include <machine/bus.h> 231 232struct bios_attach_args { 233 char *ba_name; 234 u_int ba_biosfunc; 235 bus_space_tag_t ba_iot; 236 bus_space_tag_t ba_memt; 237 union { 238 void *_p; 239 bios_apminfo_t *_ba_apmp; 240 paddr_t _ba_acpipbase; 241 } _; 242}; 243 244#define ba_apmp _._ba_apmp 245#define ba_acpipbase _._ba_acpipbase 246 247struct consdev; 248struct proc; 249 250int bios_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); 251 252void bioscnprobe(struct consdev *); 253void bioscninit(struct consdev *); 254void bioscnputc(dev_t, int); 255int bioscngetc(dev_t); 256void bioscnpollc(dev_t, int); 257void bios_getopt(void); 258bios_diskinfo_t *bios_getdiskinfo(dev_t); 259 260/* bios32.c */ 261int bios32_service(u_int32_t, bios32_entry_t, bios32_entry_info_t); 262 263extern u_int bootapiver; 264extern bios_memmap_t *bios_memmap; 265 266#endif /* _KERNEL */ 267#endif /* _LOCORE */ 268#endif /* _KERNEL || _STANDALONE */ 269 270#endif /* _I386_BIOSVAR_H_ */ 271