bios.h revision 49197
1/*-
2 * Copyright (c) 1997 Michael Smith
3 * Copyright (c) 1998 Jonathan Lemon
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 *      $Id: bios.h,v 1.2 1997/08/04 03:31:23 msmith Exp $
28 */
29
30/*
31 * Signature structure for the BIOS32 Service Directory header
32 */
33struct bios32_SDheader
34{
35    u_int8_t	sig[4];
36    u_int32_t	entry;
37    u_int8_t	revision;
38    u_int8_t	len;
39    u_int8_t	cksum;
40    u_int8_t	pad[5];
41};
42
43/*
44 * BIOS32 Service Directory entry.  Caller supplies name, bios32_SDlookup
45 * fills in the rest of the details.
46 */
47struct bios32_SDentry
48{
49    union
50    {
51	u_int8_t	name[4];	/* service identifier */
52	u_int32_t	id;		/* as a 32-bit value */
53    } ident;
54    u_int32_t	base;			/* base of service */
55    u_int32_t	len;			/* service length */
56    u_int32_t	entry;			/* entrypoint offset from base */
57};
58
59extern int		bios32_SDlookup(struct bios32_SDentry *ent);
60extern u_int32_t	bios_sigsearch(u_int32_t start, u_char *sig, int siglen,
61					 int paralen, int sigofs);
62
63#define BIOS_PADDRTOVADDR(x)	(((x) - ISA_HOLE_START) + atdevbase)
64#define BIOS_VADDRTOPADDR(x)	(((x) - atdevbase) + ISA_HOLE_START)
65
66
67/*
68 * System Management BIOS / Desktop Management Interface tables
69 */
70
71struct DMI_table
72{
73    u_int8_t	sig[5];			/* "_DMI_" */
74    u_int8_t	cksum;			/* checksum */
75    u_int16_t	st_size;		/* total length of SMBIOS table (bytes)*/
76    u_int32_t	st_base;		/* base address of the SMBIOS table (physical) */
77    u_int16_t	st_entries;		/* total number of structures present in the table */
78    u_int8_t	bcd_revision;		/* interface revision number */
79};
80
81struct SMBIOS_table
82{
83    u_int8_t	sig[4];			/* "_SM_" */
84    u_int8_t	cksum;			/* checksum */
85    u_int8_t	len;			/* structure length */
86    u_int8_t	major, minor;		/* major/minor revision numbers */
87    u_int16_t	st_maxsize;		/* largest structure size (bytes) */
88    u_int8_t	revision;		/* entrypoint revision */
89    u_int8_t	pad[5];
90    struct DMI_table dmi;		/* follows immediately */
91};
92
93
94/*
95 * Exported lookup results
96 */
97extern struct bios32_SDentry	PCIbios;
98extern struct SMBIOS_table	*SMBIOS_table;
99extern struct DMI_table		*DMI_table;
100
101struct segment_info {
102	u_int	base;
103	u_int	limit;
104};
105
106#define BIOSCODE_FLAG	0x01
107#define BIOSDATA_FLAG	0x02
108#define BIOSUTIL_FLAG	0x04
109#define BIOSARGS_FLAG	0x08
110
111struct bios_segments {
112	u_int 	generation;
113	struct	segment_info code32;		/* 32-bit code (mandatory) */
114	struct	segment_info code16;		/* 16-bit code */
115	struct	segment_info data;		/* 16-bit data */
116	struct	segment_info util;		/* 16-bit utility */
117	struct	segment_info args;		/* 16-bit args */
118};
119
120struct bios_regs {
121	u_int	eax;
122	u_int	ebx;
123	u_int	ecx;
124	u_int	edx;
125	u_int	esi;
126	u_int	edi;
127};
128
129struct bios_args {
130	u_int	entry;				/* entry point of routine */
131	struct	bios_regs r;
132	struct	bios_segments seg;
133};
134
135/*
136 * format specifiers and defines for bios16()
137 *     s	= short (16 bits)
138 *     i	= int (32 bits)
139 *     p	= pointer (converted to seg:offset)
140 *     C,D,U 	= selector (corresponding to code/data/utility segment)
141 */
142#define PNP_COUNT_DEVNODES	"sppD",		0x00
143#define PNP_GET_DEVNODE		"sppsD",	0x01
144#define PNP_SET_DEVNODE		"sppsD",	0x02
145#define PNP_GET_EVENT		"spD",		0x03
146#define PNP_SEND_MSG		"ssD",		0x04
147#define PNP_GET_DOCK_INFO	"spD",		0x05
148
149#define PNP_SEL_PRIBOOT		"ssiiisspD",	0x07
150#define PNP_GET_PRIBOOT		"sspppppD",	0x08
151#define PNP_SET_RESINFO		"spD",		0x09
152#define PNP_GET_RESINFO		"spD",		0x0A
153#define PNP_GET_APM_ID		"sppD",		0x0B
154
155#define PNP_GET_ISA_INFO	"spD",		0x40
156#define PNP_GET_ECSD_INFO	"spppD",	0x41
157#define PNP_READ_ESCD		"spUD",		0x42
158#define PNP_WRITE_ESCD		"spUD",		0x43
159
160#define PNP_GET_DMI_INFO	"spppppD",	0x50
161#define PNP_GET_DMI		"sppUD",	0x51
162
163#define PNP_BOOT_CHECK		"sp",		0x60
164#define PNP_COUNT_IPL		"sppp",		0x61
165#define PNP_GET_BOOTPRI		"spp",		0x62
166#define PNP_SET_BOOTPRI		"sp",		0x63
167#define PNP_GET_LASTBOOT	"sp",		0x64
168#define PNP_GET_BOOTFIRST	"sp",		0x65
169#define PNP_SET_BOOTFIRST	"sp",		0x66
170
171extern int bios16(struct bios_args *, char *, ...);
172extern int bios16_call(struct bios_regs *, char *);
173extern int bios32(struct bios_regs *, u_int, u_short);
174extern void set_bios_selectors(struct bios_segments *, int);
175