xref: /titanic_44/usr/src/uts/intel/sys/sysi86.h (revision ba2be53024c0b999e74ba9adcd7d80fec5df8c57)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
28 /*	  All Rights Reserved */
29 
30 #ifndef _SYS_SYSI86_H
31 #define	_SYS_SYSI86_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef DIRSIZ
40 #define	DIRSIZ	14
41 #endif
42 
43 /*
44  * Commands for sysi86 system call (1-?)
45  */
46 
47 #define	SI86SWPI	1	/* General swap interface. */
48 #define	SI86SYM		2	/* acquire boot-built symbol table */
49 #define	SI86CONF	4	/* acquire boot-built configuration table */
50 #define	SI86BOOT	5	/* acquire timestamp and name of program */
51 				/*	booted */
52 #define	SI86AUTO	9	/* was an auto-config boot done? */
53 #define	SI86EDT		10	/* copy contents of EDT to user */
54 #define	SI86SWAP	12	/* Declare swap space */
55 #define	SI86FPHW	40	/* what (if any?) floating-point hardware */
56 #define	SI86FPSTART	41	/* extended version of SI86FPHW */
57 
58 #define	GRNON		52	/* set green light to solid on state */
59 #define	GRNFLASH	53	/* start green light flashing */
60 #define	STIME		54	/* set internal time */
61 #define	SETNAME		56	/* rename the system */
62 #define	RNVR		58	/* read NVRAM */
63 #define	WNVR		59	/* write NVRAM */
64 #define	RTODC		60	/* read time of day clock */
65 #define	CHKSER		61	/* check soft serial number */
66 #define	SI86NVPRT	62	/* print an xtra_nvr structure */
67 #define	SANUPD		63	/* sanity update of kernel buffers */
68 #define	SI86KSTR	64	/* make a copy of a kernel string */
69 #define	SI86MEM		65	/* return the memory size of system */
70 #define	SI86TODEMON	66	/* Transfer control to firmware. */
71 #define	SI86CCDEMON	67	/* Control character access to demon. */
72 #define	SI86CACHE	68	/* Turn cache on and off. */
73 #define	SI86DELMEM	69	/* Delete available memory for testing. */
74 #define	SI86ADDMEM	70	/* Add back deleted memory. */
75 /*	71 through 74 reserved for VPIX */
76 #define	SI86V86		71	/* V86 system calls (see below) */
77 #define	SI86SLTIME	72	/* Set local time correction */
78 #define	SI86DSCR	75	/* Set a segment or gate descriptor */
79 #define	RDUBLK		76	/* Read U Block */
80 /* NFA entry point */
81 #define	SI86NFA		77	/* make nfa_sys system call */
82 #define	SI86VM86	81
83 #define	SI86VMENABLE	82
84 #define	SI86LIMUSER	91	/* license interface */
85 #define	SI86RDID	92	/* ROM BIOS Machid ID */
86 #define	SI86RDBOOT	93	/* Bootable Non-SCSI Hard Disk */
87 /* XENIX Support */
88 #define	SI86SHFIL	100	/* map a file into addr space of a proc */
89 #define	SI86PCHRGN	101	/* make globally visible change to a region */
90 #define	SI86BADVISE	102	/* badvise subcommand - see below for */
91 				/*	badvise subfunction definitions */
92 #define	SI86SHRGN	103	/* enable/disable XENIX small model shared */
93 				/*	data context switching */
94 #define	SI86CHIDT	104	/* set user level int 0xf0, ... 0xff handlers */
95 #define	SI86EMULRDA	105	/* remove special emulator read access */
96 
97 /*
98  *	NOTE: Numbers 106 - 110 have been registered and are reserved
99  *	for future use for AT&T hardware.
100  */
101 
102 /*
103  *	Commands for allowing the real time clock to keep local time.
104  */
105 
106 #define	WTODC		111	/* write tod clock */
107 #define	SGMTL		112	/* set GMT lag */
108 #define	GGMTL		113	/* get GMT lag */
109 #define	RTCSYNC		114	/* set UNIX 'time' based on RTC and GMT lag */
110 
111 #define	V86SC_IOPL	4	/* The only supported V86 system call */
112 
113 /*
114  *  The SI86DSCR subcommand of the sysi86() system call
115  *  sets a segment or gate descriptor in the kernel.
116  *  The following descriptor types are accepted:
117  *    - executable and data segments in the LDT at DPL 3
118  *    - a call gate in the GDT at DPL 3 that points to a segment in the LDT
119  *  The request structure declared below is used to pass the values
120  *  to be placed in the descriptor.  A pointer to the structure is
121  *  passed as the second argument of the system call.
122  *  If acc1 is zero, the descriptor is cleared.
123  */
124 
125 /*
126  * XX64 Do we need to support this for 64-bit apps?
127  *
128  * request structure passed by user
129  */
130 struct ssd {
131 	unsigned int	sel;   /* descriptor selector */
132 	unsigned int	bo;    /* segment base or gate offset */
133 	unsigned int	ls;    /* segment limit or gate selector */
134 	unsigned int	acc1;  /* access byte 5 */
135 	unsigned int	acc2;  /* access bits in byte 6 or gate count */
136 };
137 
138 #define	SI86SSD_TYPE(ssd)	((ssd)->acc1 & 0x1F)
139 #define	SI86SSD_DPL(ssd)	(((ssd)->acc1 >> 5) & 0x3)
140 #define	SI86SSD_PRES(ssd)	(((ssd)->acc1 >> 7) & 1)
141 #define	SI86SSD_ISUSEG(ssd)	(SI86SSD_TYPE(ssd) >= SDT_MEMRO)
142 #define	SI86SSD_ISLONG(ssd)	((ssd)->acc2 & 0x2)
143 
144 #ifdef _KERNEL
145 extern void usd_to_ssd(user_desc_t *, struct ssd *, selector_t);
146 extern int setdscr(struct ssd *);
147 #endif	/* _KERNEL */
148 
149 /*
150  *  The SI86SHFIL subcommand of the sysi86() system call
151  *  maps a file into a region in user address space.
152  *  The request structure declared below is used to pass the
153  *  system call parameters.  A pointer to the structure is
154  *  passed as the second argument of the system call.
155  */
156 struct mmf {
157 	char	*mf_filename;	/* path name of file */
158 	long	mf_filesz;	/* Size in bytes of section of file */
159 				/* from which this region is mapped. */
160 	long	mf_regsz;	/* Size of region in bytes */
161 	short	mf_flags;	/* Either 0 or RG_NOSHARE */
162 };
163 
164 /*
165  *  The SI86PCHRGN subcommand of the sysi86() system call
166  *  change the memory mapped image of a file.
167  *  The request structure declared below is used to pass the values
168  *  system call parameters.  A pointer to the structure is
169  *  passed as the second argument of the system call.
170  */
171 struct cmf {
172 	char	*cf_srcva;	/* modified image address */
173 	char	*cf_dstva;	/* location to patch */
174 	long	cf_count;	/* size of patch */
175 };
176 
177 /*
178  * The SI86BADVISE subcommand of the sysi86() system call specifies
179  * XENIX variant behavior for certain system calls and kernel routines.
180  * The 'arg' argument of sysi86() for SI86BADVISE is an integer.  Bits
181  * 8..15 specify SI86B_SET or SI86B_GET.  Bits 0..7 contain
182  * SI86B_PRE_SV, SI86B_XOUT, or SI86B_XSDSWTCH.  All these constants are
183  * defined below.  The 'arg' argument thus consists of either SI86B_SET
184  * OR'ed with zero or more of SI86B_PRE_SV, SI86B_XOUT, and SI86B_XSDSWTCH,
185  * or of SI86B_GET.
186  */
187 #define	SI86B_SET		0x0100	/* set badvise bits */
188 #define	SI86B_GET		0x0200	/* retrieve badvise bits */
189 
190 #define	SI86B_PRE_SV		0x0008	/* follow pre-System V x.out behavior */
191 #define	SI86B_XOUT		0x0010 	/* follow XENIX x.out behavior */
192 #define	SI86B_XSDSWTCH		0x0080	/* XENIX small model shared data */
193 					/*	context switching enabled */
194 
195 /*
196  *   The request structure declared below is used by the XENIX 286 emulator
197  *   (/bin/x286emul) in conjunction with the SI86SHRGN subcommand of sysi86().
198  *   The SI86SHRGN subcommand is used by the XENIX 286 emulator to support
199  *   XENIX shared data.  The second argument passed to sysi86() is a
200  *   pointer to an xsdbuf struct.
201  *
202  *   If the 'xsd_cmd' field of xsdbuf is SI86SHR_CP, the XENIX 286 emulator is
203  *   using the SI86SHRGN subcommand to set up XENIX small model shared data
204  *   context switching support for a given XENIX shared data segment.  In this
205  *   case, the xsdbuf struct contains the start addr for the shared data in
206  *   386 space, followed by the start addr for the shared data in the 286
207  *   executable's private data.
208  *
209  *   If the 'xsd_cmd' field is SI86SHR_SZ, the XENIX 286 emulator is using the
210  *   SI86SHRGN subcommand to retrieve the size of an existing XENIX shared
211  *   data segment.  In this case, the xsdbuf struct contains the start addr
212  *   for the shared data in 386 space.
213  *   The size of the shared data segment starting at 'xsd_386vaddr' will
214  *   be returned in the 'xsd_size' field by sysi86().
215  */
216 
217 #define	SI86SHR_CP	0x1	/* SI86SHRGN used for XENIX sd context switch */
218 #define	SI86SHR_SZ	0x2	/* SI86SHRGN used to get XENIX sd seg size */
219 
220 struct xsdbuf {
221 	unsigned xsd_cmd;	/* SI86SHRGN subcommand, either SI86SHR_CP */
222 				/* or SI86SHR_SZ. */
223 	char	*xsd_386vaddr;	/* Addr of "real" XENIX shared data seg in */
224 				/* the emulator. */
225 	union {
226 		char	*xsd_286vaddr;	/* Addr of XENIX shared data seg */
227 					/* in the 286 data portion of the */
228 					/* emulator. */
229 		unsigned long xsd_size;	/* Size of XENIX shared data seg */
230 	} xsd_un;
231 };
232 /* End XENIX Support */
233 
234 /*
235  * Cascade defines
236  */
237 
238 #define	C2	'E'
239 #define	C3	'F'
240 #define	C4	'G'
241 #define	C6	'K'
242 
243 /* Enterprise IDNO defines */
244 #define	E8R1	'R'
245 
246 #ifndef _KERNEL
247 #ifdef __STDC__
248 extern	int	sysi86(int, ...);
249 #else
250 extern	int	sysi86();
251 #endif	/* __STDC__ */
252 #endif	/* !_KERNEL */
253 
254 #ifdef	__cplusplus
255 }
256 #endif
257 
258 #endif	/* _SYS_SYSI86_H */
259