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