summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/sys/sysi86.h
blob: 4c3c4182ff0e37934820732f33301465bf5468aa (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/*	  All Rights Reserved */

#ifndef _SYS_SYSI86_H
#define	_SYS_SYSI86_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef DIRSIZ
#define	DIRSIZ	14
#endif

/*
 * Commands for sysi86 system call (1-?)
 */

#define	SI86SWPI	1	/* General swap interface. */
#define	SI86SYM		2	/* acquire boot-built symbol table */
#define	SI86CONF	4	/* acquire boot-built configuration table */
#define	SI86BOOT	5	/* acquire timestamp and name of program */
				/*	booted */
#define	SI86AUTO	9	/* was an auto-config boot done? */
#define	SI86EDT		10	/* copy contents of EDT to user */
#define	SI86SWAP	12	/* Declare swap space */
#define	SI86FPHW	40	/* what (if any?) floating-point hardware */
#define	SI86FPSTART	41	/* extended version of SI86FPHW */

#define	GRNON		52	/* set green light to solid on state */
#define	GRNFLASH	53	/* start green light flashing */
#define	STIME		54	/* set internal time */
#define	SETNAME		56	/* rename the system */
#define	RNVR		58	/* read NVRAM */
#define	WNVR		59	/* write NVRAM */
#define	RTODC		60	/* read time of day clock */
#define	CHKSER		61	/* check soft serial number */
#define	SI86NVPRT	62	/* print an xtra_nvr structure */
#define	SANUPD		63	/* sanity update of kernel buffers */
#define	SI86KSTR	64	/* make a copy of a kernel string */
#define	SI86MEM		65	/* return the memory size of system */
#define	SI86TODEMON	66	/* Transfer control to firmware. */
#define	SI86CCDEMON	67	/* Control character access to demon. */
#define	SI86CACHE	68	/* Turn cache on and off. */
#define	SI86DELMEM	69	/* Delete available memory for testing. */
#define	SI86ADDMEM	70	/* Add back deleted memory. */
/*	71 through 74 reserved for VPIX */
#define	SI86V86		71	/* V86 system calls (see below) */
#define	SI86SLTIME	72	/* Set local time correction */
#define	SI86DSCR	75	/* Set a segment or gate descriptor */
#define	RDUBLK		76	/* Read U Block */
/* NFA entry point */
#define	SI86NFA		77	/* make nfa_sys system call */
#define	SI86VM86	81
#define	SI86VMENABLE	82
#define	SI86LIMUSER	91	/* license interface */
#define	SI86RDID	92	/* ROM BIOS Machid ID */
#define	SI86RDBOOT	93	/* Bootable Non-SCSI Hard Disk */
/* XENIX Support */
#define	SI86SHFIL	100	/* map a file into addr space of a proc */
#define	SI86PCHRGN	101	/* make globally visible change to a region */
#define	SI86BADVISE	102	/* badvise subcommand - see below for */
				/*	badvise subfunction definitions */
#define	SI86SHRGN	103	/* enable/disable XENIX small model shared */
				/*	data context switching */
#define	SI86CHIDT	104	/* set user level int 0xf0, ... 0xff handlers */
#define	SI86EMULRDA	105	/* remove special emulator read access */

/*
 *	NOTE: Numbers 106 - 110 have been registered and are reserved
 *	for future use for AT&T hardware.
 */

/*
 *	Commands for allowing the real time clock to keep local time.
 */

#define	WTODC		111	/* write tod clock */
#define	SGMTL		112	/* set GMT lag */
#define	GGMTL		113	/* get GMT lag */
#define	RTCSYNC		114	/* set UNIX 'time' based on RTC and GMT lag */

#define	V86SC_IOPL	4	/* The only supported V86 system call */

/*
 *  The SI86DSCR subcommand of the sysi86() system call
 *  sets a segment or gate descriptor in the kernel.
 *  The following descriptor types are accepted:
 *    - executable and data segments in the LDT at DPL 3
 *    - a call gate in the GDT at DPL 3 that points to a segment in the LDT
 *  The request structure declared below is used to pass the values
 *  to be placed in the descriptor.  A pointer to the structure is
 *  passed as the second argument of the system call.
 *  If acc1 is zero, the descriptor is cleared.
 */

/*
 * XX64 Do we need to support this for 64-bit apps?
 *
 * request structure passed by user
 */
struct ssd {
	unsigned int	sel;   /* descriptor selector */
	unsigned int	bo;    /* segment base or gate offset */
	unsigned int	ls;    /* segment limit or gate selector */
	unsigned int	acc1;  /* access byte 5 */
	unsigned int	acc2;  /* access bits in byte 6 or gate count */
};

#define	SI86SSD_TYPE(ssd)	((ssd)->acc1 & 0x1F)
#define	SI86SSD_DPL(ssd)	(((ssd)->acc1 >> 5) & 0x3)
#define	SI86SSD_PRES(ssd)	(((ssd)->acc1 >> 7) & 1)
#define	SI86SSD_ISUSEG(ssd)	(SI86SSD_TYPE(ssd) >= SDT_MEMRO)
#define	SI86SSD_ISLONG(ssd)	((ssd)->acc2 & 0x2)

#ifdef _KERNEL
extern void usd_to_ssd(user_desc_t *, struct ssd *, selector_t);
#endif	/* _KERNEL */

/*
 *  The SI86SHFIL subcommand of the sysi86() system call
 *  maps a file into a region in user address space.
 *  The request structure declared below is used to pass the
 *  system call parameters.  A pointer to the structure is
 *  passed as the second argument of the system call.
 */
struct mmf {
	char	*mf_filename;	/* path name of file */
	long	mf_filesz;	/* Size in bytes of section of file */
				/* from which this region is mapped. */
	long	mf_regsz;	/* Size of region in bytes */
	short	mf_flags;	/* Either 0 or RG_NOSHARE */
};

/*
 *  The SI86PCHRGN subcommand of the sysi86() system call
 *  change the memory mapped image of a file.
 *  The request structure declared below is used to pass the values
 *  system call parameters.  A pointer to the structure is
 *  passed as the second argument of the system call.
 */
struct cmf {
	char	*cf_srcva;	/* modified image address */
	char	*cf_dstva;	/* location to patch */
	long	cf_count;	/* size of patch */
};

/*
 * The SI86BADVISE subcommand of the sysi86() system call specifies
 * XENIX variant behavior for certain system calls and kernel routines.
 * The 'arg' argument of sysi86() for SI86BADVISE is an integer.  Bits
 * 8..15 specify SI86B_SET or SI86B_GET.  Bits 0..7 contain
 * SI86B_PRE_SV, SI86B_XOUT, or SI86B_XSDSWTCH.  All these constants are
 * defined below.  The 'arg' argument thus consists of either SI86B_SET
 * OR'ed with zero or more of SI86B_PRE_SV, SI86B_XOUT, and SI86B_XSDSWTCH,
 * or of SI86B_GET.
 */
#define	SI86B_SET		0x0100	/* set badvise bits */
#define	SI86B_GET		0x0200	/* retrieve badvise bits */

#define	SI86B_PRE_SV		0x0008	/* follow pre-System V x.out behavior */
#define	SI86B_XOUT		0x0010 	/* follow XENIX x.out behavior */
#define	SI86B_XSDSWTCH		0x0080	/* XENIX small model shared data */
					/*	context switching enabled */

/*
 *   The request structure declared below is used by the XENIX 286 emulator
 *   (/bin/x286emul) in conjunction with the SI86SHRGN subcommand of sysi86().
 *   The SI86SHRGN subcommand is used by the XENIX 286 emulator to support
 *   XENIX shared data.  The second argument passed to sysi86() is a
 *   pointer to an xsdbuf struct.
 *
 *   If the 'xsd_cmd' field of xsdbuf is SI86SHR_CP, the XENIX 286 emulator is
 *   using the SI86SHRGN subcommand to set up XENIX small model shared data
 *   context switching support for a given XENIX shared data segment.  In this
 *   case, the xsdbuf struct contains the start addr for the shared data in
 *   386 space, followed by the start addr for the shared data in the 286
 *   executable's private data.
 *
 *   If the 'xsd_cmd' field is SI86SHR_SZ, the XENIX 286 emulator is using the
 *   SI86SHRGN subcommand to retrieve the size of an existing XENIX shared
 *   data segment.  In this case, the xsdbuf struct contains the start addr
 *   for the shared data in 386 space.
 *   The size of the shared data segment starting at 'xsd_386vaddr' will
 *   be returned in the 'xsd_size' field by sysi86().
 */

#define	SI86SHR_CP	0x1	/* SI86SHRGN used for XENIX sd context switch */
#define	SI86SHR_SZ	0x2	/* SI86SHRGN used to get XENIX sd seg size */

struct xsdbuf {
	unsigned xsd_cmd;	/* SI86SHRGN subcommand, either SI86SHR_CP */
				/* or SI86SHR_SZ. */
	char	*xsd_386vaddr;	/* Addr of "real" XENIX shared data seg in */
				/* the emulator. */
	union {
		char	*xsd_286vaddr;	/* Addr of XENIX shared data seg */
					/* in the 286 data portion of the */
					/* emulator. */
		unsigned long xsd_size;	/* Size of XENIX shared data seg */
	} xsd_un;
};
/* End XENIX Support */

/*
 * Cascade defines
 */

#define	C2	'E'
#define	C3	'F'
#define	C4	'G'
#define	C6	'K'

/* Enterprise IDNO defines */
#define	E8R1	'R'

#ifndef _KERNEL
#ifdef __STDC__
extern	int	sysi86(int, ...);
#else
extern	int	sysi86();
#endif	/* __STDC__ */
#endif	/* !_KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_SYSI86_H */