summaryrefslogtreecommitdiff
path: root/sys/arch/i386/include/biosvar.h
blob: 3c55ac79f9e8f55c9b36c5e16bb7847b65169f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*	$OpenBSD: biosvar.h,v 1.14 1997/10/03 20:56:29 deraadt Exp $	*/

/*
 * Copyright (c) 1997 Michael Shalayeff
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Michael Shalayeff.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#ifndef _I386_BIOSVAR_H_
#define _I386_BIOSVAR_H_

#define	BOOT_APIVER	0x00000001

#define BIOSNHEADS(d)	(((d)>>24)+1)
#define BIOSNSECTS(d)	((d)&0x3f)	/* sectors are 1-based */
#define BIOSNDRIVES(d)	((((d)>>16)&0x0f)+1)
#define BIOSNTRACKS(d)	(( (((d)>>8)&0xff) | (((d)&0xc0)<<2) ) +1)

/* BIOS media ID */
#define BIOSM_F320K	0xff	/* floppy ds/sd  8 spt */
#define	BIOSM_F160K	0xfe	/* floppy ss/sd  8 spt */
#define	BIOSM_F360K	0xfd	/* floppy ds/sd  9 spt */
#define	BIOSM_F180K	0xfc	/* floppy ss/sd  9 spt */
#define	BIOSM_ROMD	0xfa	/* ROM disk */
#define	BIOSM_F120M	0xf9	/* floppy ds/hd 15 spt 5.25" */
#define	BIOSM_F720K	0xf9	/* floppy ds/dd  9 spt 3.50" */
#define	BIOSM_HD	0xf8	/* hard drive */
#define	BIOSM_F144K	0xf0	/* floppy ds/hd 18 spt 3.50" */
#define	BIOSM_OTHER	0xf0	/* any other */

/* 
 * CTL_BIOS definitions.
 */
#define	BIOS_DEV		1	/* int: BIOS boot device */
#define	BIOS_GEOMETRY		2	/* int: BIOS boot device geometry */
#define	BIOS_CNVMEM		3	/* int: amount of conventional memory */
#define	BIOS_EXTMEM		4	/* int: amount of extended memory */
#define	BIOS_MAXID		5	/* number of valid machdep ids */

#define	CTL_BIOS_NAMES { \
	{ 0, 0 }, \
	{ "biosdev", CTLTYPE_INT }, \
	{ "biosgeo", CTLTYPE_INT }, \
	{ "cnvmem", CTLTYPE_INT }, \
	{ "extmem", CTLTYPE_INT }, \
}

#if defined(_KERNEL) || defined (_STANDALONE)

#ifdef _LOCORE
#define	DOINT(n)	int	$0x20+(n)
#else
#define	DOINT(n)	"int $0x20+(" #n ")"

extern struct BIOS_vars {
	/* XXX filled in assumption that last file opened is kernel */
	int	bios_dev;
	u_int	bios_geometry;

	u_int	bios_apm_detail;
	u_int	bios_apm_code32_base;
	u_int	bios_apm_code16_base;
	u_int	bios_apm_code_len;
	u_int	bios_apm_data_base;
	u_int	bios_apm_data_len;
	u_int	bios_apm_entry;

}	BIOS_vars;

extern struct BIOS_regs {
	u_int32_t	biosr_ax;
	u_int32_t	biosr_cx;
	u_int32_t	biosr_dx;
	u_int32_t	biosr_bx;
	u_int32_t	biosr_bp;
	u_int32_t	biosr_si;
	u_int32_t	biosr_di;
	u_int32_t	biosr_ds;
	u_int32_t	biosr_es;
}	BIOS_regs;

struct EDD_CB {
	u_int8_t  edd_len;   /* size of packet */
	u_int8_t  edd_res;   /* reserved */
	u_int16_t edd_nblk;  /* # of blocks to transfer */
	u_int32_t edd_buf;   /* address of buffer */
	u_int64_t edd_daddr; /* starting block */
};

#ifdef _KERNEL
#include <machine/bus.h>

struct bios_attach_args {
	char *bios_dev;
	union {
		struct {
			bus_space_tag_t _bios_iot;
			bus_space_tag_t _bios_memt;
		} bios;
		struct {
			u_int	_apm_detail;
			u_int	_apm_code32_base;
			u_int	_apm_code16_base;
			u_int	_apm_code_len;
			u_int	_apm_data_base;
			u_int	_apm_data_len;
			u_int	_apm_entry;
		} apm;
	} _;
};

#define	bios_iot	_.bios._bios_iot
#define	bios_memt	_.bios._bios_memt
#define	apm_detail	_.apm._apm_detail
#define	apm_code32_base	_.apm._apm_code32_base
#define	apm_code16_base	_.apm._apm_code16_base
#define	apm_code_len	_.apm._apm_code_len
#define	apm_data_base	_.apm._apm_data_base
#define	apm_data_len	_.apm._apm_data_len
#define	apm_entry	_.apm._apm_entry

struct consdev;
struct proc;

int bios_sysctl
	__P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));

void bioscnprobe __P((struct consdev *));
void bioscninit __P((struct consdev *));
void bioscnputc __P((dev_t, int));
int bioscngetc __P((dev_t));
void bioscnpollc __P((dev_t, int));

#endif /* _KERNEL */
#endif /* _LOCORE */
#endif /* _KERNEL || _STANDALONE */

#endif /* _I386_BIOSVAR_H_ */