xref: /onnv-gate/usr/src/uts/common/sys/systm.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef _SYS_SYSTM_H
32*0Sstevel@tonic-gate #define	_SYS_SYSTM_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #include <sys/t_lock.h>
38*0Sstevel@tonic-gate #include <sys/proc.h>
39*0Sstevel@tonic-gate #include <sys/dditypes.h>
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #ifdef	__cplusplus
42*0Sstevel@tonic-gate extern "C" {
43*0Sstevel@tonic-gate #endif
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate /*
46*0Sstevel@tonic-gate  * The pc_t is the type of the kernel's program counter.  In general, a
47*0Sstevel@tonic-gate  * pc_t is a uintptr_t -- except for a sparcv9 kernel, in which case all
48*0Sstevel@tonic-gate  * instruction text is below 4G, and a pc_t is thus a uint32_t.
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate #ifdef __sparcv9
51*0Sstevel@tonic-gate typedef uint32_t pc_t;
52*0Sstevel@tonic-gate #else
53*0Sstevel@tonic-gate typedef uintptr_t pc_t;
54*0Sstevel@tonic-gate #endif
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  * Random set of variables used by more than one routine.
58*0Sstevel@tonic-gate  */
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate #ifdef _KERNEL
61*0Sstevel@tonic-gate #include <sys/varargs.h>
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate extern int hz;			/* system clock rate */
64*0Sstevel@tonic-gate extern struct vnode *rootdir;	/* pointer to vnode of root directory */
65*0Sstevel@tonic-gate extern struct vnode *devicesdir;	/* pointer to /devices vnode */
66*0Sstevel@tonic-gate extern volatile clock_t lbolt;	/* time in HZ since last boot */
67*0Sstevel@tonic-gate extern volatile int64_t lbolt64;	/* lbolt computed as 64-bit value */
68*0Sstevel@tonic-gate extern int interrupts_unleashed;	/* set after the spl0() in main() */
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate extern char runin;		/* scheduling flag */
71*0Sstevel@tonic-gate extern char runout;		/* scheduling flag */
72*0Sstevel@tonic-gate extern char wake_sched;		/* causes clock to wake swapper on next tick */
73*0Sstevel@tonic-gate extern char wake_sched_sec;	/* causes clock to wake swapper after a sec */
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate extern pgcnt_t	maxmem;		/* max available memory (pages) */
76*0Sstevel@tonic-gate extern pgcnt_t	physmem;	/* physical memory (pages) on this CPU */
77*0Sstevel@tonic-gate extern pfn_t	physmax;	/* highest numbered physical page present */
78*0Sstevel@tonic-gate extern pgcnt_t	physinstalled;	/* physical pages including PROM/boot use */
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate extern caddr_t	s_text;		/* start of kernel text segment */
81*0Sstevel@tonic-gate extern caddr_t	e_text;		/* end of kernel text segment */
82*0Sstevel@tonic-gate extern caddr_t	s_data;		/* start of kernel text segment */
83*0Sstevel@tonic-gate extern caddr_t	e_data;		/* end of kernel text segment */
84*0Sstevel@tonic-gate #if defined(__ia64)
85*0Sstevel@tonic-gate extern caddr_t	s_sdata;	/* start of kernel small data segment */
86*0Sstevel@tonic-gate extern caddr_t	e_sdata;	/* end of kernel small data segment */
87*0Sstevel@tonic-gate #endif /* __ia64 */
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate extern pgcnt_t	availrmem;	/* Available resident (not swapable)	*/
90*0Sstevel@tonic-gate 				/* memory in pages.			*/
91*0Sstevel@tonic-gate extern pgcnt_t	availrmem_initial;	/* initial value of availrmem	*/
92*0Sstevel@tonic-gate extern pgcnt_t	segspt_minfree;	/* low water mark for availrmem in seg_spt */
93*0Sstevel@tonic-gate extern pgcnt_t	freemem;	/* Current free memory.			*/
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate extern dev_t	rootdev;	/* device of the root */
96*0Sstevel@tonic-gate extern struct vnode *rootvp;	/* vnode of root device */
97*0Sstevel@tonic-gate extern int	root_is_svm;	/* root is a mirrored device flag */
98*0Sstevel@tonic-gate extern char *volatile panicstr;	/* panic string pointer */
99*0Sstevel@tonic-gate extern va_list  panicargs;	/* panic arguments */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate extern int	rstchown;	/* 1 ==> restrictive chown(2) semantics */
102*0Sstevel@tonic-gate extern int	klustsize;
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate extern int	abort_enable;	/* Platform input-device abort policy */
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate #ifdef C2_AUDIT
107*0Sstevel@tonic-gate extern int	audit_active;	/* C2 auditing activate 1, absent 0. */
108*0Sstevel@tonic-gate #endif
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate extern int	avenrun[];	/* array of load averages */
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate extern char *isa_list;		/* For sysinfo's isalist option */
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate extern int noexec_user_stack;		/* patchable via /etc/system */
115*0Sstevel@tonic-gate extern int noexec_user_stack_log;	/* patchable via /etc/system */
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate extern void report_stack_exec(proc_t *, caddr_t);
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate extern void startup(void);
120*0Sstevel@tonic-gate extern void clkstart(void);
121*0Sstevel@tonic-gate extern void post_startup(void);
122*0Sstevel@tonic-gate extern void kern_setup1(void);
123*0Sstevel@tonic-gate extern void ka_init(void);
124*0Sstevel@tonic-gate extern void nodename_set(void);
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate /*
127*0Sstevel@tonic-gate  * for tod fault detection
128*0Sstevel@tonic-gate  */
129*0Sstevel@tonic-gate enum tod_fault_type {
130*0Sstevel@tonic-gate 	TOD_REVERSED = 0,
131*0Sstevel@tonic-gate 	TOD_STALLED,
132*0Sstevel@tonic-gate 	TOD_JUMPED,
133*0Sstevel@tonic-gate 	TOD_RATECHANGED,
134*0Sstevel@tonic-gate 	TOD_NOFAULT
135*0Sstevel@tonic-gate };
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate extern time_t tod_validate(time_t);
138*0Sstevel@tonic-gate extern void tod_fault_reset(void);
139*0Sstevel@tonic-gate extern void plat_tod_fault(enum tod_fault_type);
140*0Sstevel@tonic-gate #pragma	weak	plat_tod_fault
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate #ifndef _LP64
143*0Sstevel@tonic-gate #ifndef min
144*0Sstevel@tonic-gate int min(int, int);
145*0Sstevel@tonic-gate #endif
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate #ifndef max
148*0Sstevel@tonic-gate int max(int, int);
149*0Sstevel@tonic-gate #endif
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate uint_t umin(uint_t, uint_t);
152*0Sstevel@tonic-gate uint_t umax(uint_t, uint_t);
153*0Sstevel@tonic-gate #endif /* !_LP64 */
154*0Sstevel@tonic-gate int grow(caddr_t);
155*0Sstevel@tonic-gate int grow_internal(caddr_t, uint_t);
156*0Sstevel@tonic-gate int brk_internal(caddr_t, uint_t);
157*0Sstevel@tonic-gate timeout_id_t timeout(void (*)(void *), void *, clock_t);
158*0Sstevel@tonic-gate timeout_id_t realtime_timeout(void (*)(void *), void *, clock_t);
159*0Sstevel@tonic-gate clock_t untimeout(timeout_id_t);
160*0Sstevel@tonic-gate void delay(clock_t);
161*0Sstevel@tonic-gate int delay_sig(clock_t);
162*0Sstevel@tonic-gate int nodev();
163*0Sstevel@tonic-gate int nulldev();
164*0Sstevel@tonic-gate major_t getudev(void);
165*0Sstevel@tonic-gate int cmpldev(dev32_t *, dev_t);
166*0Sstevel@tonic-gate dev_t expldev(dev32_t);
167*0Sstevel@tonic-gate int bcmp(const void *, const void *, size_t) __PURE;
168*0Sstevel@tonic-gate int stoi(char **);
169*0Sstevel@tonic-gate void numtos(ulong_t, char *);
170*0Sstevel@tonic-gate size_t strlen(const char *) __PURE;
171*0Sstevel@tonic-gate char *strcat(char *, const char *);
172*0Sstevel@tonic-gate char *strncat(char *, const char *, size_t);
173*0Sstevel@tonic-gate char *strcpy(char *, const char *);
174*0Sstevel@tonic-gate char *strncpy(char *, const char *, size_t);
175*0Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */
176*0Sstevel@tonic-gate #if __cplusplus >= 199711L
177*0Sstevel@tonic-gate extern const char *strchr(const char *, int);
178*0Sstevel@tonic-gate #ifndef _STRCHR_INLINE
179*0Sstevel@tonic-gate #define	_STRCHR_INLINE
180*0Sstevel@tonic-gate extern "C++" {
181*0Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
182*0Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
183*0Sstevel@tonic-gate 	}
184*0Sstevel@tonic-gate }
185*0Sstevel@tonic-gate #endif /* _STRCHR_INLINE */
186*0Sstevel@tonic-gate extern const char *strrchr(const char *, int);
187*0Sstevel@tonic-gate #ifndef	_STRRCHR_INLINE
188*0Sstevel@tonic-gate #define	_STRRCHR_INLINE
189*0Sstevel@tonic-gate extern "C++" {
190*0Sstevel@tonic-gate 	inline char *strrchr(char *__s, int __c) {
191*0Sstevel@tonic-gate 		return (char *)strrchr((const char *)__s, __c);
192*0Sstevel@tonic-gate 	}
193*0Sstevel@tonic-gate }
194*0Sstevel@tonic-gate #endif	/* _STRRCHR_INLINE */
195*0Sstevel@tonic-gate extern const char *strstr(const char *, const char *);
196*0Sstevel@tonic-gate #ifndef	_STRSTR_INLINE
197*0Sstevel@tonic-gate #define	_STRSTR_INLINE
198*0Sstevel@tonic-gate extern "C++" {
199*0Sstevel@tonic-gate 	inline char *strstr(char *__s1, const char *__s2) {
200*0Sstevel@tonic-gate 		return (char *)strstr((const char *)__s1, __s2);
201*0Sstevel@tonic-gate 	}
202*0Sstevel@tonic-gate }
203*0Sstevel@tonic-gate #endif  /* _STRSTR_INLINE */
204*0Sstevel@tonic-gate #else	/* __cplusplus >= 199711L */
205*0Sstevel@tonic-gate char *strchr(const char *, int);
206*0Sstevel@tonic-gate char *strrchr(const char *, int);
207*0Sstevel@tonic-gate char *strstr(const char *, const char *);
208*0Sstevel@tonic-gate #endif	/* __cplusplus >= 199711L */
209*0Sstevel@tonic-gate char *strnrchr(const char *, int, size_t);
210*0Sstevel@tonic-gate int strcmp(const char *, const char *) __PURE;
211*0Sstevel@tonic-gate int strncmp(const char *, const char *, size_t) __PURE;
212*0Sstevel@tonic-gate int strcasecmp(const char *, const char *) __PURE;
213*0Sstevel@tonic-gate int strncasecmp(const char *, const char *, size_t) __PURE;
214*0Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */
215*0Sstevel@tonic-gate #if __cplusplus >= 199711L
216*0Sstevel@tonic-gate extern const char *strpbrk(const char *, const char *);
217*0Sstevel@tonic-gate #ifndef _STRPBRK_INLINE
218*0Sstevel@tonic-gate #define	_STRPBRK_INLINE
219*0Sstevel@tonic-gate extern "C++" {
220*0Sstevel@tonic-gate 	inline char *strpbrk(char *__s1, const char *__s2) {
221*0Sstevel@tonic-gate 		return (char *)strpbrk((const char *)__s1, __s2);
222*0Sstevel@tonic-gate 	}
223*0Sstevel@tonic-gate }
224*0Sstevel@tonic-gate #endif /* _STRPBRK_INLINE */
225*0Sstevel@tonic-gate #else /* __cplusplus >= 199711L */
226*0Sstevel@tonic-gate char *strpbrk(const char *, const char *);
227*0Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
228*0Sstevel@tonic-gate int strident_valid(const char *);
229*0Sstevel@tonic-gate void strident_canon(char *, size_t);
230*0Sstevel@tonic-gate int getsubopt(char **optionsp, char * const *tokens, char **valuep);
231*0Sstevel@tonic-gate char *append_subopt(const char *, size_t, char *, const char *);
232*0Sstevel@tonic-gate int ffs(long);
233*0Sstevel@tonic-gate int copyin(const void *, void *, size_t);
234*0Sstevel@tonic-gate void copyin_noerr(const void *, void *, size_t);
235*0Sstevel@tonic-gate int xcopyin(const void *, void *, size_t);
236*0Sstevel@tonic-gate int xcopyin_nta(const void *, void *, size_t, int);
237*0Sstevel@tonic-gate int copyout(const void *, void *, size_t);
238*0Sstevel@tonic-gate void copyout_noerr(const void *, void *, size_t);
239*0Sstevel@tonic-gate int xcopyout(const void *, void *, size_t);
240*0Sstevel@tonic-gate int xcopyout_nta(const void *, void *, size_t, int);
241*0Sstevel@tonic-gate int copyinstr(const char *, char *, size_t, size_t *);
242*0Sstevel@tonic-gate int copyinstr_noerr(const char *, char *, size_t, size_t *);
243*0Sstevel@tonic-gate int copyoutstr(const char *, char *, size_t, size_t *);
244*0Sstevel@tonic-gate int copyoutstr_noerr(const char *, char *, size_t, size_t *);
245*0Sstevel@tonic-gate int copystr(const char *, char *, size_t, size_t *);
246*0Sstevel@tonic-gate void bcopy(const void *, void *, size_t);
247*0Sstevel@tonic-gate void ucopy(const void *, void *, size_t);
248*0Sstevel@tonic-gate void pgcopy(const void *, void *, size_t);
249*0Sstevel@tonic-gate void ovbcopy(const void *, void *, size_t);
250*0Sstevel@tonic-gate void bzero(void *, size_t);
251*0Sstevel@tonic-gate void uzero(void *, size_t);
252*0Sstevel@tonic-gate int kcopy(const void *, void *, size_t);
253*0Sstevel@tonic-gate int kcopy_nta(const void *, void *, size_t, int);
254*0Sstevel@tonic-gate int kzero(void *, size_t);
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate extern void *memset(void *, int, size_t);
257*0Sstevel@tonic-gate extern void *memcpy(void *, const void *, size_t);
258*0Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
259*0Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t);
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate int fuword8(const void *, uint8_t *);
262*0Sstevel@tonic-gate int fuword16(const void *, uint16_t *);
263*0Sstevel@tonic-gate int fuword32(const void *, uint32_t *);
264*0Sstevel@tonic-gate int fulword(const void *, ulong_t *);
265*0Sstevel@tonic-gate void fuword8_noerr(const void *, uint8_t *);
266*0Sstevel@tonic-gate void fuword16_noerr(const void *, uint16_t *);
267*0Sstevel@tonic-gate void fuword32_noerr(const void *, uint32_t *);
268*0Sstevel@tonic-gate void fulword_noerr(const void *, ulong_t *);
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate #ifdef _LP64
271*0Sstevel@tonic-gate int fuword64(const void *, uint64_t *);
272*0Sstevel@tonic-gate void fuword64_noerr(const void *, uint64_t *);
273*0Sstevel@tonic-gate #endif
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate int subyte(void *, uint8_t);
276*0Sstevel@tonic-gate int suword8(void *, uint8_t);
277*0Sstevel@tonic-gate int suword16(void *, uint16_t);
278*0Sstevel@tonic-gate int suword32(void *, uint32_t);
279*0Sstevel@tonic-gate int sulword(void *, ulong_t);
280*0Sstevel@tonic-gate void subyte_noerr(void *, uint8_t);
281*0Sstevel@tonic-gate void suword8_noerr(void *, uint8_t);
282*0Sstevel@tonic-gate void suword16_noerr(void *, uint16_t);
283*0Sstevel@tonic-gate void suword32_noerr(void *, uint32_t);
284*0Sstevel@tonic-gate void sulword_noerr(void *, ulong_t);
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate #ifdef _LP64
287*0Sstevel@tonic-gate int suword64(void *, uint64_t);
288*0Sstevel@tonic-gate void suword64_noerr(void *, uint64_t);
289*0Sstevel@tonic-gate #endif
290*0Sstevel@tonic-gate 
291*0Sstevel@tonic-gate #if !defined(_BOOT)
292*0Sstevel@tonic-gate int setjmp(label_t *);
293*0Sstevel@tonic-gate extern void longjmp(label_t *)
294*0Sstevel@tonic-gate 	__NORETURN;
295*0Sstevel@tonic-gate #pragma unknown_control_flow(setjmp)
296*0Sstevel@tonic-gate #endif
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate caddr_t caller(void);
299*0Sstevel@tonic-gate caddr_t callee(void);
300*0Sstevel@tonic-gate int getpcstack(pc_t *, int);
301*0Sstevel@tonic-gate int on_fault(label_t *);
302*0Sstevel@tonic-gate void no_fault(void);
303*0Sstevel@tonic-gate void halt(char *);
304*0Sstevel@tonic-gate int scanc(size_t, uchar_t *, uchar_t *, uchar_t);
305*0Sstevel@tonic-gate int movtuc(size_t, uchar_t *, uchar_t *, uchar_t *);
306*0Sstevel@tonic-gate int splr(int);
307*0Sstevel@tonic-gate int splhigh(void);
308*0Sstevel@tonic-gate int splhi(void);
309*0Sstevel@tonic-gate int splzs(void);
310*0Sstevel@tonic-gate int spl0(void);
311*0Sstevel@tonic-gate int spl6(void);
312*0Sstevel@tonic-gate int spl7(void);
313*0Sstevel@tonic-gate int spl8(void);
314*0Sstevel@tonic-gate void splx(int);
315*0Sstevel@tonic-gate void set_base_spl(void);
316*0Sstevel@tonic-gate int __ipltospl(int);
317*0Sstevel@tonic-gate 
318*0Sstevel@tonic-gate void softcall_init(void);
319*0Sstevel@tonic-gate void softcall(void (*)(void *), void *);
320*0Sstevel@tonic-gate void softint(void);
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate extern void sync_icache(caddr_t, uint_t);
323*0Sstevel@tonic-gate extern void sync_data_memory(caddr_t, size_t);
324*0Sstevel@tonic-gate extern void hot_patch_kernel_text(caddr_t, uint32_t, uint_t);
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate void _insque(caddr_t, caddr_t);
327*0Sstevel@tonic-gate void _remque(caddr_t);
328*0Sstevel@tonic-gate 
329*0Sstevel@tonic-gate /* casts to keep lint happy */
330*0Sstevel@tonic-gate #define	insque(q, p)	_insque((caddr_t)q, (caddr_t)p)
331*0Sstevel@tonic-gate #define	remque(q)	_remque((caddr_t)q)
332*0Sstevel@tonic-gate 
333*0Sstevel@tonic-gate #pragma unknown_control_flow(on_fault)
334*0Sstevel@tonic-gate 
335*0Sstevel@tonic-gate struct timeval;
336*0Sstevel@tonic-gate extern void	uniqtime(struct timeval *);
337*0Sstevel@tonic-gate struct timeval32;
338*0Sstevel@tonic-gate extern void	uniqtime32(struct timeval32 *);
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate uint_t page_num_pagesizes(void);
341*0Sstevel@tonic-gate size_t page_get_pagesize(uint_t n);
342*0Sstevel@tonic-gate 
343*0Sstevel@tonic-gate extern int maxusers;
344*0Sstevel@tonic-gate extern int pidmax;
345*0Sstevel@tonic-gate 
346*0Sstevel@tonic-gate extern void param_preset(void);
347*0Sstevel@tonic-gate extern void param_calc(int);
348*0Sstevel@tonic-gate extern void param_init(void);
349*0Sstevel@tonic-gate extern void param_check(void);
350*0Sstevel@tonic-gate 
351*0Sstevel@tonic-gate #endif /* _KERNEL */
352*0Sstevel@tonic-gate 
353*0Sstevel@tonic-gate /*
354*0Sstevel@tonic-gate  * Structure of the system-entry table.
355*0Sstevel@tonic-gate  *
356*0Sstevel@tonic-gate  * 	Changes to struct sysent should maintain binary compatibility with
357*0Sstevel@tonic-gate  *	loadable system calls, although the interface is currently private.
358*0Sstevel@tonic-gate  *
359*0Sstevel@tonic-gate  *	This means it should only be expanded on the end, and flag values
360*0Sstevel@tonic-gate  * 	should not be reused.
361*0Sstevel@tonic-gate  *
362*0Sstevel@tonic-gate  *	It is desirable to keep the size of this struct a power of 2 for quick
363*0Sstevel@tonic-gate  *	indexing.
364*0Sstevel@tonic-gate  */
365*0Sstevel@tonic-gate struct sysent {
366*0Sstevel@tonic-gate 	char		sy_narg;	/* total number of arguments */
367*0Sstevel@tonic-gate #ifdef _LP64
368*0Sstevel@tonic-gate 	unsigned short	sy_flags;	/* various flags as defined below */
369*0Sstevel@tonic-gate #else
370*0Sstevel@tonic-gate 	unsigned char	sy_flags;	/* various flags as defined below */
371*0Sstevel@tonic-gate #endif
372*0Sstevel@tonic-gate 	int		(*sy_call)();	/* argp, rvalp-style handler */
373*0Sstevel@tonic-gate 	krwlock_t	*sy_lock;	/* lock for loadable system calls */
374*0Sstevel@tonic-gate 	int64_t		(*sy_callc)();	/* C-style call hander or wrapper */
375*0Sstevel@tonic-gate };
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate extern struct sysent	sysent[];
378*0Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
379*0Sstevel@tonic-gate extern struct sysent	sysent32[];
380*0Sstevel@tonic-gate #endif
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate extern struct sysent	nosys_ent;	/* entry for invalid system call */
383*0Sstevel@tonic-gate 
384*0Sstevel@tonic-gate #define	NSYSCALL 	256		/* number of system calls */
385*0Sstevel@tonic-gate 
386*0Sstevel@tonic-gate #define	LOADABLE_SYSCALL(s)	(s->sy_flags & SE_LOADABLE)
387*0Sstevel@tonic-gate #define	LOADED_SYSCALL(s)	(s->sy_flags & SE_LOADED)
388*0Sstevel@tonic-gate 
389*0Sstevel@tonic-gate /*
390*0Sstevel@tonic-gate  * sy_flags values
391*0Sstevel@tonic-gate  * 	Values 1, 2, and 4 were used previously for SETJUMP, ASYNC, and IOSYS.
392*0Sstevel@tonic-gate  */
393*0Sstevel@tonic-gate #define	SE_32RVAL1	0x0		/* handler returns int32_t in rval1 */
394*0Sstevel@tonic-gate #define	SE_32RVAL2	0x1		/* handler returns int32_t in rval2 */
395*0Sstevel@tonic-gate #define	SE_64RVAL	0x2		/* handler returns int64_t in rvals */
396*0Sstevel@tonic-gate #define	SE_RVAL_MASK	0x3		/* mask of rval_t bits */
397*0Sstevel@tonic-gate 
398*0Sstevel@tonic-gate #define	SE_LOADABLE	0x08		/* syscall is loadable */
399*0Sstevel@tonic-gate #define	SE_LOADED	0x10		/* syscall is completely loaded */
400*0Sstevel@tonic-gate #define	SE_NOUNLOAD	0x20		/* syscall never needs unload */
401*0Sstevel@tonic-gate #define	SE_ARGC		0x40		/* syscall takes C-style args */
402*0Sstevel@tonic-gate 
403*0Sstevel@tonic-gate /*
404*0Sstevel@tonic-gate  * Structure of the return-value parameter passed by reference to
405*0Sstevel@tonic-gate  * system entries.
406*0Sstevel@tonic-gate  */
407*0Sstevel@tonic-gate union rval {
408*0Sstevel@tonic-gate 	struct	{
409*0Sstevel@tonic-gate 		int	r_v1;
410*0Sstevel@tonic-gate 		int	r_v2;
411*0Sstevel@tonic-gate 	} r_v;
412*0Sstevel@tonic-gate 	off_t	r_off;
413*0Sstevel@tonic-gate 	offset_t r_offset;
414*0Sstevel@tonic-gate 	time_t	r_time;
415*0Sstevel@tonic-gate 	int64_t	r_vals;
416*0Sstevel@tonic-gate };
417*0Sstevel@tonic-gate #define	r_val1	r_v.r_v1
418*0Sstevel@tonic-gate #define	r_val2	r_v.r_v2
419*0Sstevel@tonic-gate 
420*0Sstevel@tonic-gate typedef union rval rval_t;
421*0Sstevel@tonic-gate 
422*0Sstevel@tonic-gate #ifdef	_KERNEL
423*0Sstevel@tonic-gate 
424*0Sstevel@tonic-gate extern void reset_syscall_args(void);
425*0Sstevel@tonic-gate extern int save_syscall_args(void);
426*0Sstevel@tonic-gate extern uint_t get_syscall_args(klwp_t *lwp, long *argp, int *nargsp);
427*0Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
428*0Sstevel@tonic-gate extern uint_t get_syscall32_args(klwp_t *lwp, int *argp, int *nargp);
429*0Sstevel@tonic-gate #endif
430*0Sstevel@tonic-gate 
431*0Sstevel@tonic-gate extern uint_t set_errno(uint_t error);
432*0Sstevel@tonic-gate #pragma rarely_called(set_errno)
433*0Sstevel@tonic-gate 
434*0Sstevel@tonic-gate extern int64_t syscall_ap(void);
435*0Sstevel@tonic-gate extern int64_t loadable_syscall(long, long, long, long, long, long, long, long);
436*0Sstevel@tonic-gate extern int64_t nosys(void);
437*0Sstevel@tonic-gate 
438*0Sstevel@tonic-gate extern void swtch(void);
439*0Sstevel@tonic-gate 
440*0Sstevel@tonic-gate extern uint_t	kcpc_key;	/* TSD key for performance counter context */
441*0Sstevel@tonic-gate 
442*0Sstevel@tonic-gate #ifdef __lint
443*0Sstevel@tonic-gate extern	int	__lintzero;	/* for spoofing lint */
444*0Sstevel@tonic-gate #endif
445*0Sstevel@tonic-gate 
446*0Sstevel@tonic-gate 
447*0Sstevel@tonic-gate /*
448*0Sstevel@tonic-gate  * initname holds the path to init.  It is defined by main.c, may be set by
449*0Sstevel@tonic-gate  * bootflags.c, and is used by main.c:exec_init().
450*0Sstevel@tonic-gate  */
451*0Sstevel@tonic-gate #define	INITNAME_SZ	32
452*0Sstevel@tonic-gate #define	INITARGS_SZ	80
453*0Sstevel@tonic-gate 
454*0Sstevel@tonic-gate extern char initname[INITNAME_SZ];
455*0Sstevel@tonic-gate extern char initargs[INITARGS_SZ];
456*0Sstevel@tonic-gate 
457*0Sstevel@tonic-gate extern int exec_init(const char *, int, const char *);
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate #endif	/* _KERNEL */
460*0Sstevel@tonic-gate 
461*0Sstevel@tonic-gate #ifdef	__cplusplus
462*0Sstevel@tonic-gate }
463*0Sstevel@tonic-gate #endif
464*0Sstevel@tonic-gate 
465*0Sstevel@tonic-gate #endif	/* _SYS_SYSTM_H */
466