biosvar.h revision 1.35
1/*	$OpenBSD: biosvar.h,v 1.35 2000/03/26 22:38:33 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
37	/* some boxes put apm data seg in the 2nd page */
38#define	BOOTARG_OFF	(NBPG*2)
39#define	BOOTARG_LEN	(NBPG*1)
40#define	BOOTBIOS_ADDR	(0x7c00)
41
42/* BIOS media ID */
43#define BIOSM_F320K	0xff	/* floppy ds/sd  8 spt */
44#define	BIOSM_F160K	0xfe	/* floppy ss/sd  8 spt */
45#define	BIOSM_F360K	0xfd	/* floppy ds/sd  9 spt */
46#define	BIOSM_F180K	0xfc	/* floppy ss/sd  9 spt */
47#define	BIOSM_ROMD	0xfa	/* ROM disk */
48#define	BIOSM_F120M	0xf9	/* floppy ds/hd 15 spt 5.25" */
49#define	BIOSM_F720K	0xf9	/* floppy ds/dd  9 spt 3.50" */
50#define	BIOSM_HD	0xf8	/* hard drive */
51#define	BIOSM_F144K	0xf0	/* floppy ds/hd 18 spt 3.50" */
52#define	BIOSM_OTHER	0xf0	/* any other */
53
54/*
55 * BIOS memory maps
56 */
57#define	BIOS_MAP_END	0x00	/* End of array XXX - special */
58#define	BIOS_MAP_FREE	0x01	/* Usable memory */
59#define	BIOS_MAP_RES	0x02	/* Reserved memory */
60#define	BIOS_MAP_ACPI	0x03	/* ACPI Reclaim memory */
61#define	BIOS_MAP_NVS	0x04	/* ACPI NVS memory */
62
63/*
64 * BIOS32
65 */
66typedef
67struct bios32_entry_info {
68	paddr_t	bei_base;
69	psize_t	bei_size;
70	paddr_t	bei_entry;
71} *bios32_entry_info_t;
72
73typedef
74struct bios32_entry {
75	caddr_t	offset;
76	u_int16_t segment;
77} __attribute__((__packed__)) *bios32_entry_t;
78
79#define	BIOS32_MAKESIG(a, b, c, d) \
80	((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
81
82/*
83 * CTL_BIOS definitions.
84 */
85#define	BIOS_DEV		1	/* int: BIOS boot device */
86#define	BIOS_DISKINFO		2	/* struct: BIOS boot device info */
87#define BIOS_CKSUMLEN		3	/* int: disk cksum block count */
88#define	BIOS_MAXID		4	/* number of valid machdep ids */
89
90#define	CTL_BIOS_NAMES { \
91	{ 0, 0 }, \
92	{ "biosdev", CTLTYPE_INT }, \
93	{ "diskinfo", CTLTYPE_STRUCT }, \
94	{ "cksumlen", CTLTYPE_INT }, \
95}
96
97#define	BOOTARG_MEMMAP 0
98typedef struct _bios_memmap {
99	u_int64_t addr;		/* Beginning of block */
100	u_int64_t size;		/* Size of block */
101	u_int32_t type;		/* Type of block */
102} bios_memmap_t;
103
104/* Info about disk from the bios, plus the mapping from
105 * BIOS numbers to BSD major (driver?) number.
106 *
107 * Also, do not bother with BIOSN*() macros, just parcel
108 * the info out, and use it like this.  This makes for less
109 * of a dependance on BIOSN*() macros having to be the same
110 * across /boot, /bsd, and userland.
111 */
112#define	BOOTARG_DISKINFO 1
113typedef struct _bios_diskinfo {
114	/* BIOS section */
115	int bios_number;	/* BIOS number of drive (or -1) */
116	u_int bios_cylinders;	/* BIOS cylinders */
117	u_int bios_heads;	/* BIOS heads */
118	u_int bios_sectors;	/* BIOS sectors */
119	int bios_edd;		/* EDD support */
120
121	/* BSD section */
122	dev_t bsd_dev;		/* BSD device */
123
124	/* Checksum section */
125	u_int32_t checksum;	/* Checksum for drive */
126
127	/* Misc. flags */
128	u_int32_t flags;
129#define BDI_INVALID	0x00000001	/* I/O error during checksumming */
130#define BDI_GOODLABEL	0x00000002	/* Had SCSI or ST506/ESDI disklabel */
131#define BDI_BADLABEL	0x00000004	/* Had another disklabel */
132#define BDI_PICKED	0x80000000	/* kernel-only: cksum matched */
133
134} bios_diskinfo_t;
135
136#define	BOOTARG_APMINFO 2
137typedef struct _bios_apminfo {
138	/* APM_CONNECT returned values */
139	u_int	apm_detail;
140	u_int	apm_code32_base;
141	u_int	apm_code16_base;
142	u_int	apm_code_len;
143	u_int	apm_data_base;
144	u_int	apm_data_len;
145	u_int	apm_entry;
146	u_int	apm_code16_len;
147} bios_apminfo_t;
148
149#define	BOOTARG_CKSUMLEN 3		/* u_int32_t */
150
151#define	BOOTARG_PCIINFO 4
152typedef struct _bios_pciinfo {
153	/* PCI BIOS v2.0+ - Installation check values */
154	u_int32_t	pci_chars;	/* Characteristics (%eax) */
155	u_int32_t	pci_rev;	/* BCD Revision (%ebx) */
156	u_int32_t	pci_entry32;	/* PM entry point for PCI BIOS */
157	u_int32_t	pci_lastbus;	/* Number of last PCI bus */
158} bios_pciinfo_t;
159
160#define	BOOTARG_CONSDEV	5
161typedef struct _bios_consdev {
162	dev_t	consdev;
163	int	conspeed;
164} bios_consdev_t;
165
166#if defined(_KERNEL) || defined (_STANDALONE)
167
168#ifdef _LOCORE
169#define	DOINT(n)	int	$0x20+(n)
170#else
171#define	DOINT(n)	"int $0x20+(" #n ")"
172
173extern struct BIOS_regs {
174	u_int32_t	biosr_ax;
175	u_int32_t	biosr_cx;
176	u_int32_t	biosr_dx;
177	u_int32_t	biosr_bx;
178	u_int32_t	biosr_bp;
179	u_int32_t	biosr_si;
180	u_int32_t	biosr_di;
181	u_int32_t	biosr_ds;
182	u_int32_t	biosr_es;
183}	BIOS_regs;
184
185#ifdef _KERNEL
186#include <machine/bus.h>
187
188struct bios_attach_args {
189	char *bios_dev;
190	u_int bios_func;
191	bus_space_tag_t bios_iot;
192	bus_space_tag_t bios_memt;
193	union {
194		void *_p;
195		bios_apminfo_t *_bios_apmp;
196	} _;
197};
198
199#define	bios_apmp	_._bios_apmp
200
201struct consdev;
202struct proc;
203
204int bios_sysctl
205	__P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
206
207void bioscnprobe __P((struct consdev *));
208void bioscninit __P((struct consdev *));
209void bioscnputc __P((dev_t, int));
210int bioscngetc __P((dev_t));
211void bioscnpollc __P((dev_t, int));
212void bios_getopt __P((void));
213
214/* bios32.c */
215void bios32_init __P((void));
216int  bios32_service __P((u_int32_t, bios32_entry_t, bios32_entry_info_t));
217
218extern u_int bootapiver;
219extern bios_memmap_t *bios_memmap;
220extern bios_pciinfo_t *bios_pciinfo;
221
222#endif /* _KERNEL */
223#endif /* _LOCORE */
224#endif /* _KERNEL || _STANDALONE */
225
226#endif /* _I386_BIOSVAR_H_ */
227