biosvar.h revision 1.13
1/*	$OpenBSD: biosvar.h,v 1.13 1997/09/29 03:42:28 mickey 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 * CTL_BIOS definitions.
59 */
60#define	BIOS_DEV		1	/* int: BIOS boot device */
61#define	BIOS_GEOMETRY		2	/* int: BIOS boot device geometry */
62#define	BIOS_CNVMEM		3	/* int: amount of conventional memory */
63#define	BIOS_EXTMEM		4	/* int: amount of extended memory */
64#define	BIOS_MAXID		5	/* number of valid machdep ids */
65
66#define	CTL_BIOS_NAMES { \
67	{ 0, 0 }, \
68	{ "biosdev", CTLTYPE_INT }, \
69	{ "biosgeo", CTLTYPE_INT }, \
70	{ "cnvmem", CTLTYPE_INT }, \
71	{ "extmem", CTLTYPE_INT }, \
72}
73
74#if defined(_KERNEL) || defined (_STANDALONE)
75
76#ifdef _LOCORE
77#define	DOINT(n)	int	$0x20+(n)
78#else
79#define	DOINT(n)	"int $0x20+(" #n ")"
80
81extern struct BIOS_vars {
82	/* XXX filled in assumption that last file opened is kernel */
83	int	bios_dev;
84	int	bios_geometry;
85
86	u_int	bios_apm_detail;
87	u_int	bios_apm_code32_base;
88	u_int	bios_apm_code16_base;
89	u_int	bios_apm_code_len;
90	u_int	bios_apm_data_base;
91	u_int	bios_apm_data_len;
92	u_int	bios_apm_entry;
93
94}	BIOS_vars;
95
96extern struct BIOS_regs {
97	u_int32_t	biosr_ax;
98	u_int32_t	biosr_cx;
99	u_int32_t	biosr_dx;
100	u_int32_t	biosr_bx;
101	u_int32_t	biosr_bp;
102	u_int32_t	biosr_si;
103	u_int32_t	biosr_di;
104	u_int32_t	biosr_ds;
105	u_int32_t	biosr_es;
106}	BIOS_regs;
107
108struct EDD_CB {
109	u_int8_t  edd_len;   /* size of packet */
110	u_int8_t  edd_res;   /* reserved */
111	u_int16_t edd_nblk;  /* # of blocks to transfer */
112	u_int32_t edd_buf;   /* address of buffer */
113	u_int64_t edd_daddr; /* starting block */
114};
115
116#ifdef _KERNEL
117#include <machine/bus.h>
118
119struct bios_attach_args {
120	char *bios_dev;
121	union {
122		struct {
123			bus_space_tag_t _bios_iot;
124			bus_space_tag_t _bios_memt;
125		} bios;
126		struct {
127			u_int	_apm_detail;
128			u_int	_apm_code32_base;
129			u_int	_apm_code16_base;
130			u_int	_apm_code_len;
131			u_int	_apm_data_base;
132			u_int	_apm_data_len;
133			u_int	_apm_entry;
134		} apm;
135	} _;
136};
137
138#define	bios_iot	_.bios._bios_iot
139#define	bios_memt	_.bios._bios_memt
140#define	apm_detail	_.apm._apm_detail
141#define	apm_code32_base	_.apm._apm_code32_base
142#define	apm_code16_base	_.apm._apm_code16_base
143#define	apm_code_len	_.apm._apm_code_len
144#define	apm_data_base	_.apm._apm_data_base
145#define	apm_data_len	_.apm._apm_data_len
146#define	apm_entry	_.apm._apm_entry
147
148struct consdev;
149struct proc;
150
151int bios_sysctl
152	__P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
153
154void bioscnprobe __P((struct consdev *));
155void bioscninit __P((struct consdev *));
156void bioscnputc __P((dev_t, int));
157int bioscngetc __P((dev_t));
158void bioscnpollc __P((dev_t, int));
159
160#endif /* _KERNEL */
161#endif /* _LOCORE */
162#endif /* _KERNEL || _STANDALONE */
163
164#endif /* _I386_BIOSVAR_H_ */
165