biosvar.h revision 1.17
1/*	$OpenBSD: biosvar.h,v 1.17 1997/10/17 15:03:15 weingart Exp $	*/
2
3/*
4 * Copyright (c) 1997 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
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 */
34
35#ifndef _I386_BIOSVAR_H_
36#define _I386_BIOSVAR_H_
37
38#define	BOOT_APIVER	0x00000001
39
40#define BIOSNHEADS(d)	(((d)>>24)+1)
41#define BIOSNSECTS(d)	((d)&0x3f)	/* sectors are 1-based */
42#define BIOSNDRIVES(d)	((((d)>>16)&0x0f)+1)
43#define BIOSNTRACKS(d)	(( (((d)>>8)&0xff) | (((d)&0xc0)<<2) ) +1)
44
45/* BIOS media ID */
46#define BIOSM_F320K	0xff	/* floppy ds/sd  8 spt */
47#define	BIOSM_F160K	0xfe	/* floppy ss/sd  8 spt */
48#define	BIOSM_F360K	0xfd	/* floppy ds/sd  9 spt */
49#define	BIOSM_F180K	0xfc	/* floppy ss/sd  9 spt */
50#define	BIOSM_ROMD	0xfa	/* ROM disk */
51#define	BIOSM_F120M	0xf9	/* floppy ds/hd 15 spt 5.25" */
52#define	BIOSM_F720K	0xf9	/* floppy ds/dd  9 spt 3.50" */
53#define	BIOSM_HD	0xf8	/* hard drive */
54#define	BIOSM_F144K	0xf0	/* floppy ds/hd 18 spt 3.50" */
55#define	BIOSM_OTHER	0xf0	/* any other */
56
57/*
58 * BIOS memory maps
59 */
60#define	BIOS_MAP_END	0x00	/* End of array XXX - special */
61#define	BIOS_MAP_FREE	0x01	/* Usable memory */
62#define	BIOS_MAP_RES	0x02	/* Reseved memory */
63#define	BIOS_MAP_ACPI	0x03	/* ACPI Reclaim memory */
64#define	BIOS_MAP_NVS	0x04	/* ACPI NVS memory */
65
66/*
67 * CTL_BIOS definitions.
68 */
69#define	BIOS_DEV		1	/* int: BIOS boot device */
70#define	BIOS_GEOMETRY		2	/* int: BIOS boot device geometry */
71#define	BIOS_CNVMEM		3	/* int: amount of conventional memory */
72#define	BIOS_EXTMEM		4	/* int: amount of extended memory */
73#define	BIOS_MAXID		5	/* number of valid machdep ids */
74
75#define	CTL_BIOS_NAMES { \
76	{ 0, 0 }, \
77	{ "biosdev", CTLTYPE_INT }, \
78	{ "biosgeo", CTLTYPE_INT }, \
79	{ "cnvmem", CTLTYPE_INT }, \
80	{ "extmem", CTLTYPE_INT }, \
81}
82
83#if defined(_KERNEL) || defined (_STANDALONE)
84
85#ifdef _LOCORE
86#define	DOINT(n)	int	$0x20+(n)
87#else
88#define	DOINT(n)	"int $0x20+(" #n ")"
89
90extern struct BIOS_vars {
91	/* XXX filled in assumption that last file opened is kernel */
92	int	bios_dev;
93	u_int	bios_geometry;
94
95	/* APM_CONNECT returned values */
96	u_int	bios_apm_detail;
97	u_int	bios_apm_code32_base;
98	u_int	bios_apm_code16_base;
99	u_int	bios_apm_code_len;
100	u_int	bios_apm_data_base;
101	u_int	bios_apm_data_len;
102	u_int	bios_apm_entry;
103
104	void	*boot_data;
105}	BIOS_vars;
106
107extern struct BIOS_regs {
108	u_int32_t	biosr_ax;
109	u_int32_t	biosr_cx;
110	u_int32_t	biosr_dx;
111	u_int32_t	biosr_bx;
112	u_int32_t	biosr_bp;
113	u_int32_t	biosr_si;
114	u_int32_t	biosr_di;
115	u_int32_t	biosr_ds;
116	u_int32_t	biosr_es;
117}	BIOS_regs;
118
119struct EDD_CB {
120	u_int8_t  edd_len;   /* size of packet */
121	u_int8_t  edd_res;   /* reserved */
122	u_int16_t edd_nblk;  /* # of blocks to transfer */
123	u_int32_t edd_buf;   /* address of buffer */
124	u_int64_t edd_daddr; /* starting block */
125};
126
127struct BIOS_MAP {
128	u_int32_t addr;		/* Beginning of block */
129	u_int32_t size;		/* Size of block */
130	int type;		/* Type of block */
131};
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 */
141typedef struct _bios_diskinfo {
142	/* BIOS section */
143	signed int bios_number;			/* BIOS number of drive (or -1) */
144	unsigned int bios_cylinders;	/* BIOS cylinders */
145	unsigned int bios_heads;		/* BIOS heads */
146	unsigned int bios_sectors;		/* BIOS sectors */
147
148	/* BSD section */
149	signed int bsd_major;			/* Major number of driver (or -1) */
150} bios_diskinfo_t;
151
152
153#ifdef _KERNEL
154#include <machine/bus.h>
155
156struct bios_attach_args {
157	char *bios_dev;
158	union {
159		struct {
160			bus_space_tag_t _bios_iot;
161			bus_space_tag_t _bios_memt;
162		} bios;
163		struct {
164			u_int	_apm_detail;
165			u_int	_apm_code32_base;
166			u_int	_apm_code16_base;
167			u_int	_apm_code_len;
168			u_int	_apm_data_base;
169			u_int	_apm_data_len;
170			u_int	_apm_entry;
171		} apm;
172	} _;
173};
174
175#define	bios_iot	_.bios._bios_iot
176#define	bios_memt	_.bios._bios_memt
177#define	apm_detail	_.apm._apm_detail
178#define	apm_code32_base	_.apm._apm_code32_base
179#define	apm_code16_base	_.apm._apm_code16_base
180#define	apm_code_len	_.apm._apm_code_len
181#define	apm_data_base	_.apm._apm_data_base
182#define	apm_data_len	_.apm._apm_data_len
183#define	apm_entry	_.apm._apm_entry
184
185struct consdev;
186struct proc;
187
188int bios_sysctl
189	__P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
190
191void bioscnprobe __P((struct consdev *));
192void bioscninit __P((struct consdev *));
193void bioscnputc __P((dev_t, int));
194int bioscngetc __P((dev_t));
195void bioscnpollc __P((dev_t, int));
196
197#endif /* _KERNEL */
198#endif /* _LOCORE */
199#endif /* _KERNEL || _STANDALONE */
200
201#endif /* _I386_BIOSVAR_H_ */
202