xref: /onnv-gate/usr/src/uts/common/sys/systm.h (revision 11389:dd00b884e84f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52267Sdp  * Common Development and Distribution License (the "License").
62267Sdp  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
220Sstevel@tonic-gate /*	  All Rights Reserved  	*/
230Sstevel@tonic-gate 
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
269160SSherry.Moore@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
270Sstevel@tonic-gate  * Use is subject to license terms.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef _SYS_SYSTM_H
310Sstevel@tonic-gate #define	_SYS_SYSTM_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <sys/t_lock.h>
350Sstevel@tonic-gate #include <sys/proc.h>
360Sstevel@tonic-gate #include <sys/dditypes.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef	__cplusplus
390Sstevel@tonic-gate extern "C" {
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * The pc_t is the type of the kernel's program counter.  In general, a
440Sstevel@tonic-gate  * pc_t is a uintptr_t -- except for a sparcv9 kernel, in which case all
450Sstevel@tonic-gate  * instruction text is below 4G, and a pc_t is thus a uint32_t.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate #ifdef __sparcv9
480Sstevel@tonic-gate typedef uint32_t pc_t;
490Sstevel@tonic-gate #else
500Sstevel@tonic-gate typedef uintptr_t pc_t;
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * Random set of variables used by more than one routine.
550Sstevel@tonic-gate  */
560Sstevel@tonic-gate 
570Sstevel@tonic-gate #ifdef _KERNEL
580Sstevel@tonic-gate #include <sys/varargs.h>
592267Sdp #include <sys/uadmin.h>
600Sstevel@tonic-gate 
610Sstevel@tonic-gate extern int hz;			/* system clock rate */
620Sstevel@tonic-gate extern struct vnode *rootdir;	/* pointer to vnode of root directory */
630Sstevel@tonic-gate extern struct vnode *devicesdir;	/* pointer to /devices vnode */
640Sstevel@tonic-gate extern int interrupts_unleashed;	/* set after the spl0() in main() */
650Sstevel@tonic-gate 
660Sstevel@tonic-gate extern char runin;		/* scheduling flag */
670Sstevel@tonic-gate extern char runout;		/* scheduling flag */
680Sstevel@tonic-gate extern char wake_sched;		/* causes clock to wake swapper on next tick */
690Sstevel@tonic-gate extern char wake_sched_sec;	/* causes clock to wake swapper after a sec */
700Sstevel@tonic-gate 
710Sstevel@tonic-gate extern pgcnt_t	maxmem;		/* max available memory (pages) */
720Sstevel@tonic-gate extern pgcnt_t	physmem;	/* physical memory (pages) on this CPU */
730Sstevel@tonic-gate extern pfn_t	physmax;	/* highest numbered physical page present */
740Sstevel@tonic-gate extern pgcnt_t	physinstalled;	/* physical pages including PROM/boot use */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate extern caddr_t	s_text;		/* start of kernel text segment */
770Sstevel@tonic-gate extern caddr_t	e_text;		/* end of kernel text segment */
780Sstevel@tonic-gate extern caddr_t	s_data;		/* start of kernel text segment */
790Sstevel@tonic-gate extern caddr_t	e_data;		/* end of kernel text segment */
800Sstevel@tonic-gate 
810Sstevel@tonic-gate extern pgcnt_t	availrmem;	/* Available resident (not swapable)	*/
820Sstevel@tonic-gate 				/* memory in pages.			*/
830Sstevel@tonic-gate extern pgcnt_t	availrmem_initial;	/* initial value of availrmem	*/
840Sstevel@tonic-gate extern pgcnt_t	segspt_minfree;	/* low water mark for availrmem in seg_spt */
850Sstevel@tonic-gate extern pgcnt_t	freemem;	/* Current free memory.			*/
860Sstevel@tonic-gate 
870Sstevel@tonic-gate extern dev_t	rootdev;	/* device of the root */
880Sstevel@tonic-gate extern struct vnode *rootvp;	/* vnode of root device */
895648Ssetje extern boolean_t root_is_svm;		/* root is a mirrored device flag */
905648Ssetje extern boolean_t root_is_ramdisk;	/* root is boot_archive ramdisk */
915648Ssetje extern uint32_t  ramdisk_size;		/* (KB) set only for sparc netboots */
920Sstevel@tonic-gate extern char *volatile panicstr;	/* panic string pointer */
930Sstevel@tonic-gate extern va_list  panicargs;	/* panic arguments */
949160SSherry.Moore@Sun.COM extern volatile int quiesce_active;	/* quiesce(9E) is in progress */
950Sstevel@tonic-gate 
960Sstevel@tonic-gate extern int	rstchown;	/* 1 ==> restrictive chown(2) semantics */
970Sstevel@tonic-gate extern int	klustsize;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate extern int	abort_enable;	/* Platform input-device abort policy */
1000Sstevel@tonic-gate 
1015753Sgww extern int	audit_active;	/* Solaris Auditing active 1, absent 0. */
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate extern int	avenrun[];	/* array of load averages */
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate extern char *isa_list;		/* For sysinfo's isalist option */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate extern int noexec_user_stack;		/* patchable via /etc/system */
1080Sstevel@tonic-gate extern int noexec_user_stack_log;	/* patchable via /etc/system */
1090Sstevel@tonic-gate 
110766Scarlsonj /*
111766Scarlsonj  * Use NFS client operations in the global zone only.  Under contract with
112766Scarlsonj  * admin/install; do not change without coordinating with that consolidation.
113766Scarlsonj  */
114766Scarlsonj extern int nfs_global_client_only;
115766Scarlsonj 
1160Sstevel@tonic-gate extern void report_stack_exec(proc_t *, caddr_t);
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate extern void startup(void);
1190Sstevel@tonic-gate extern void clkstart(void);
1200Sstevel@tonic-gate extern void post_startup(void);
1210Sstevel@tonic-gate extern void kern_setup1(void);
1220Sstevel@tonic-gate extern void ka_init(void);
1230Sstevel@tonic-gate extern void nodename_set(void);
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /*
1260Sstevel@tonic-gate  * for tod fault detection
1270Sstevel@tonic-gate  */
1280Sstevel@tonic-gate enum tod_fault_type {
1290Sstevel@tonic-gate 	TOD_REVERSED = 0,
1300Sstevel@tonic-gate 	TOD_STALLED,
1310Sstevel@tonic-gate 	TOD_JUMPED,
1320Sstevel@tonic-gate 	TOD_RATECHANGED,
1335084Sjohnlev 	TOD_RDONLY,
1340Sstevel@tonic-gate 	TOD_NOFAULT
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate extern time_t tod_validate(time_t);
1380Sstevel@tonic-gate extern void tod_fault_reset(void);
1390Sstevel@tonic-gate extern void plat_tod_fault(enum tod_fault_type);
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #ifndef _LP64
1420Sstevel@tonic-gate #ifndef min
1430Sstevel@tonic-gate int min(int, int);
1440Sstevel@tonic-gate #endif
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #ifndef max
1470Sstevel@tonic-gate int max(int, int);
1480Sstevel@tonic-gate #endif
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate uint_t umin(uint_t, uint_t);
1510Sstevel@tonic-gate uint_t umax(uint_t, uint_t);
1520Sstevel@tonic-gate #endif /* !_LP64 */
1530Sstevel@tonic-gate int grow(caddr_t);
1540Sstevel@tonic-gate int grow_internal(caddr_t, uint_t);
1550Sstevel@tonic-gate int brk_internal(caddr_t, uint_t);
1568048SMadhavan.Venkataraman@Sun.COM typedef uint64_t callout_id_t;
1570Sstevel@tonic-gate timeout_id_t timeout(void (*)(void *), void *, clock_t);
1580Sstevel@tonic-gate timeout_id_t realtime_timeout(void (*)(void *), void *, clock_t);
1590Sstevel@tonic-gate clock_t untimeout(timeout_id_t);
1608048SMadhavan.Venkataraman@Sun.COM /*
1618048SMadhavan.Venkataraman@Sun.COM  * The last argument to timeout_generic() is flags. See callo.h for the
1628048SMadhavan.Venkataraman@Sun.COM  * flags definitions.
1638048SMadhavan.Venkataraman@Sun.COM  */
1648048SMadhavan.Venkataraman@Sun.COM callout_id_t timeout_generic(int, void (*)(void *), void *, hrtime_t, hrtime_t,
1658048SMadhavan.Venkataraman@Sun.COM     int);
1668048SMadhavan.Venkataraman@Sun.COM callout_id_t timeout_default(void (*)(void *), void *, clock_t);
1678048SMadhavan.Venkataraman@Sun.COM callout_id_t realtime_timeout_default(void (*)(void *), void *, clock_t);
1688048SMadhavan.Venkataraman@Sun.COM /*
1698048SMadhavan.Venkataraman@Sun.COM  * The last argument to untimeout_generic() is flags. See callout.c for the
1708048SMadhavan.Venkataraman@Sun.COM  * use.
1718048SMadhavan.Venkataraman@Sun.COM  */
1728048SMadhavan.Venkataraman@Sun.COM hrtime_t untimeout_generic(callout_id_t, int);
1738048SMadhavan.Venkataraman@Sun.COM clock_t untimeout_default(callout_id_t, int);
1740Sstevel@tonic-gate void delay(clock_t);
1750Sstevel@tonic-gate int delay_sig(clock_t);
17610696SDavid.Hollister@Sun.COM void delay_random(clock_t);
1770Sstevel@tonic-gate int nodev();
1780Sstevel@tonic-gate int nulldev();
1790Sstevel@tonic-gate major_t getudev(void);
1800Sstevel@tonic-gate int cmpldev(dev32_t *, dev_t);
1810Sstevel@tonic-gate dev_t expldev(dev32_t);
1820Sstevel@tonic-gate int bcmp(const void *, const void *, size_t) __PURE;
1830Sstevel@tonic-gate int stoi(char **);
1840Sstevel@tonic-gate void numtos(ulong_t, char *);
18510272SMatthew.Ahrens@Sun.COM char *kmem_asprintf(const char *fmt, ...);
1860Sstevel@tonic-gate int strident_valid(const char *);
1870Sstevel@tonic-gate void strident_canon(char *, size_t);
1880Sstevel@tonic-gate int getsubopt(char **optionsp, char * const *tokens, char **valuep);
1890Sstevel@tonic-gate char *append_subopt(const char *, size_t, char *, const char *);
1902546Scarlsonj int ffs(uintmax_t);
1910Sstevel@tonic-gate int copyin(const void *, void *, size_t);
1920Sstevel@tonic-gate void copyin_noerr(const void *, void *, size_t);
1930Sstevel@tonic-gate int xcopyin(const void *, void *, size_t);
1940Sstevel@tonic-gate int xcopyin_nta(const void *, void *, size_t, int);
1950Sstevel@tonic-gate int copyout(const void *, void *, size_t);
1960Sstevel@tonic-gate void copyout_noerr(const void *, void *, size_t);
1970Sstevel@tonic-gate int xcopyout(const void *, void *, size_t);
1980Sstevel@tonic-gate int xcopyout_nta(const void *, void *, size_t, int);
1990Sstevel@tonic-gate int copyinstr(const char *, char *, size_t, size_t *);
2000Sstevel@tonic-gate int copyinstr_noerr(const char *, char *, size_t, size_t *);
2010Sstevel@tonic-gate int copyoutstr(const char *, char *, size_t, size_t *);
2020Sstevel@tonic-gate int copyoutstr_noerr(const char *, char *, size_t, size_t *);
2030Sstevel@tonic-gate int copystr(const char *, char *, size_t, size_t *);
2040Sstevel@tonic-gate void ucopy(const void *, void *, size_t);
2052712Snn35248 void ucopystr(const char *, char *, size_t, size_t *);
2060Sstevel@tonic-gate void pgcopy(const void *, void *, size_t);
2070Sstevel@tonic-gate void ovbcopy(const void *, void *, size_t);
2080Sstevel@tonic-gate void uzero(void *, size_t);
2090Sstevel@tonic-gate int kcopy(const void *, void *, size_t);
2100Sstevel@tonic-gate int kcopy_nta(const void *, void *, size_t, int);
2110Sstevel@tonic-gate int kzero(void *, size_t);
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate int fuword8(const void *, uint8_t *);
2140Sstevel@tonic-gate int fuword16(const void *, uint16_t *);
2150Sstevel@tonic-gate int fuword32(const void *, uint32_t *);
2160Sstevel@tonic-gate int fulword(const void *, ulong_t *);
2170Sstevel@tonic-gate void fuword8_noerr(const void *, uint8_t *);
2180Sstevel@tonic-gate void fuword16_noerr(const void *, uint16_t *);
2190Sstevel@tonic-gate void fuword32_noerr(const void *, uint32_t *);
2200Sstevel@tonic-gate void fulword_noerr(const void *, ulong_t *);
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate #ifdef _LP64
2230Sstevel@tonic-gate int fuword64(const void *, uint64_t *);
2240Sstevel@tonic-gate void fuword64_noerr(const void *, uint64_t *);
2250Sstevel@tonic-gate #endif
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate int subyte(void *, uint8_t);
2280Sstevel@tonic-gate int suword8(void *, uint8_t);
2290Sstevel@tonic-gate int suword16(void *, uint16_t);
2300Sstevel@tonic-gate int suword32(void *, uint32_t);
2310Sstevel@tonic-gate int sulword(void *, ulong_t);
2320Sstevel@tonic-gate void subyte_noerr(void *, uint8_t);
2330Sstevel@tonic-gate void suword8_noerr(void *, uint8_t);
2340Sstevel@tonic-gate void suword16_noerr(void *, uint16_t);
2350Sstevel@tonic-gate void suword32_noerr(void *, uint32_t);
2360Sstevel@tonic-gate void sulword_noerr(void *, ulong_t);
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate #ifdef _LP64
2390Sstevel@tonic-gate int suword64(void *, uint64_t);
2400Sstevel@tonic-gate void suword64_noerr(void *, uint64_t);
2410Sstevel@tonic-gate #endif
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate #if !defined(_BOOT)
2440Sstevel@tonic-gate int setjmp(label_t *);
2450Sstevel@tonic-gate extern void longjmp(label_t *)
2460Sstevel@tonic-gate 	__NORETURN;
2470Sstevel@tonic-gate #pragma unknown_control_flow(setjmp)
2480Sstevel@tonic-gate #endif
2490Sstevel@tonic-gate 
2509171Sxiuyan.wang@Sun.COM void prefetch_read_once(void *);
2519171Sxiuyan.wang@Sun.COM void prefetch_write_once(void *);
2529171Sxiuyan.wang@Sun.COM void prefetch_read_many(void *);
2539171Sxiuyan.wang@Sun.COM void prefetch_write_many(void *);
2540Sstevel@tonic-gate caddr_t caller(void);
2550Sstevel@tonic-gate caddr_t callee(void);
2560Sstevel@tonic-gate int getpcstack(pc_t *, int);
2570Sstevel@tonic-gate int on_fault(label_t *);
2580Sstevel@tonic-gate void no_fault(void);
2590Sstevel@tonic-gate void halt(char *);
2600Sstevel@tonic-gate int scanc(size_t, uchar_t *, uchar_t *, uchar_t);
2610Sstevel@tonic-gate int movtuc(size_t, uchar_t *, uchar_t *, uchar_t *);
2620Sstevel@tonic-gate int splr(int);
2630Sstevel@tonic-gate int splhigh(void);
2640Sstevel@tonic-gate int splhi(void);
2650Sstevel@tonic-gate int splzs(void);
2660Sstevel@tonic-gate int spl0(void);
2670Sstevel@tonic-gate int spl6(void);
2680Sstevel@tonic-gate int spl7(void);
2690Sstevel@tonic-gate int spl8(void);
2700Sstevel@tonic-gate void splx(int);
2710Sstevel@tonic-gate void set_base_spl(void);
2720Sstevel@tonic-gate int __ipltospl(int);
273*11389SAlexander.Kolbasov@Sun.COM int spl_xcall(void);
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate void softcall_init(void);
2760Sstevel@tonic-gate void softcall(void (*)(void *), void *);
2770Sstevel@tonic-gate void softint(void);
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate extern void sync_icache(caddr_t, uint_t);
2800Sstevel@tonic-gate extern void sync_data_memory(caddr_t, size_t);
2810Sstevel@tonic-gate extern void hot_patch_kernel_text(caddr_t, uint32_t, uint_t);
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate void _insque(caddr_t, caddr_t);
2840Sstevel@tonic-gate void _remque(caddr_t);
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate /* casts to keep lint happy */
2870Sstevel@tonic-gate #define	insque(q, p)	_insque((caddr_t)q, (caddr_t)p)
2880Sstevel@tonic-gate #define	remque(q)	_remque((caddr_t)q)
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate #pragma unknown_control_flow(on_fault)
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate struct timeval;
2930Sstevel@tonic-gate extern void	uniqtime(struct timeval *);
2940Sstevel@tonic-gate struct timeval32;
2950Sstevel@tonic-gate extern void	uniqtime32(struct timeval32 *);
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate uint_t page_num_pagesizes(void);
2980Sstevel@tonic-gate size_t page_get_pagesize(uint_t n);
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate extern int maxusers;
3010Sstevel@tonic-gate extern int pidmax;
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate extern void param_preset(void);
3040Sstevel@tonic-gate extern void param_calc(int);
3050Sstevel@tonic-gate extern void param_init(void);
3060Sstevel@tonic-gate extern void param_check(void);
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate #endif /* _KERNEL */
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate /*
3110Sstevel@tonic-gate  * Structure of the system-entry table.
3120Sstevel@tonic-gate  *
3130Sstevel@tonic-gate  * 	Changes to struct sysent should maintain binary compatibility with
3140Sstevel@tonic-gate  *	loadable system calls, although the interface is currently private.
3150Sstevel@tonic-gate  *
3160Sstevel@tonic-gate  *	This means it should only be expanded on the end, and flag values
3170Sstevel@tonic-gate  * 	should not be reused.
3180Sstevel@tonic-gate  *
3190Sstevel@tonic-gate  *	It is desirable to keep the size of this struct a power of 2 for quick
3200Sstevel@tonic-gate  *	indexing.
3210Sstevel@tonic-gate  */
3220Sstevel@tonic-gate struct sysent {
3230Sstevel@tonic-gate 	char		sy_narg;	/* total number of arguments */
3240Sstevel@tonic-gate #ifdef _LP64
3250Sstevel@tonic-gate 	unsigned short	sy_flags;	/* various flags as defined below */
3260Sstevel@tonic-gate #else
3270Sstevel@tonic-gate 	unsigned char	sy_flags;	/* various flags as defined below */
3280Sstevel@tonic-gate #endif
3290Sstevel@tonic-gate 	int		(*sy_call)();	/* argp, rvalp-style handler */
3300Sstevel@tonic-gate 	krwlock_t	*sy_lock;	/* lock for loadable system calls */
3310Sstevel@tonic-gate 	int64_t		(*sy_callc)();	/* C-style call hander or wrapper */
3320Sstevel@tonic-gate };
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate extern struct sysent	sysent[];
3350Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
3360Sstevel@tonic-gate extern struct sysent	sysent32[];
3370Sstevel@tonic-gate #endif
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate extern struct sysent	nosys_ent;	/* entry for invalid system call */
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate #define	NSYSCALL 	256		/* number of system calls */
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate #define	LOADABLE_SYSCALL(s)	(s->sy_flags & SE_LOADABLE)
3440Sstevel@tonic-gate #define	LOADED_SYSCALL(s)	(s->sy_flags & SE_LOADED)
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate /*
3470Sstevel@tonic-gate  * sy_flags values
3480Sstevel@tonic-gate  * 	Values 1, 2, and 4 were used previously for SETJUMP, ASYNC, and IOSYS.
3490Sstevel@tonic-gate  */
3500Sstevel@tonic-gate #define	SE_32RVAL1	0x0		/* handler returns int32_t in rval1 */
3510Sstevel@tonic-gate #define	SE_32RVAL2	0x1		/* handler returns int32_t in rval2 */
3520Sstevel@tonic-gate #define	SE_64RVAL	0x2		/* handler returns int64_t in rvals */
3530Sstevel@tonic-gate #define	SE_RVAL_MASK	0x3		/* mask of rval_t bits */
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate #define	SE_LOADABLE	0x08		/* syscall is loadable */
3560Sstevel@tonic-gate #define	SE_LOADED	0x10		/* syscall is completely loaded */
3570Sstevel@tonic-gate #define	SE_NOUNLOAD	0x20		/* syscall never needs unload */
3580Sstevel@tonic-gate #define	SE_ARGC		0x40		/* syscall takes C-style args */
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate /*
3610Sstevel@tonic-gate  * Structure of the return-value parameter passed by reference to
3620Sstevel@tonic-gate  * system entries.
3630Sstevel@tonic-gate  */
3640Sstevel@tonic-gate union rval {
3650Sstevel@tonic-gate 	struct	{
3660Sstevel@tonic-gate 		int	r_v1;
3670Sstevel@tonic-gate 		int	r_v2;
3680Sstevel@tonic-gate 	} r_v;
3690Sstevel@tonic-gate 	off_t	r_off;
3700Sstevel@tonic-gate 	offset_t r_offset;
3710Sstevel@tonic-gate 	time_t	r_time;
3720Sstevel@tonic-gate 	int64_t	r_vals;
3730Sstevel@tonic-gate };
3740Sstevel@tonic-gate #define	r_val1	r_v.r_v1
3750Sstevel@tonic-gate #define	r_val2	r_v.r_v2
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate typedef union rval rval_t;
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate #ifdef	_KERNEL
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate extern void reset_syscall_args(void);
3820Sstevel@tonic-gate extern int save_syscall_args(void);
3830Sstevel@tonic-gate extern uint_t get_syscall_args(klwp_t *lwp, long *argp, int *nargsp);
3840Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
3850Sstevel@tonic-gate extern uint_t get_syscall32_args(klwp_t *lwp, int *argp, int *nargp);
3860Sstevel@tonic-gate #endif
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate extern uint_t set_errno(uint_t error);
3890Sstevel@tonic-gate #pragma rarely_called(set_errno)
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate extern int64_t syscall_ap(void);
3920Sstevel@tonic-gate extern int64_t loadable_syscall(long, long, long, long, long, long, long, long);
3930Sstevel@tonic-gate extern int64_t nosys(void);
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate extern void swtch(void);
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate extern uint_t	kcpc_key;	/* TSD key for performance counter context */
3980Sstevel@tonic-gate 
3990Sstevel@tonic-gate /*
4002267Sdp  * initname holds the path to init and is used as a point of rendezvous
4012267Sdp  * between krtld (which processes the boot arguments) and the kernel.
4020Sstevel@tonic-gate  */
4030Sstevel@tonic-gate #define	INITNAME_SZ	32
4042267Sdp extern char initname[INITNAME_SZ];
4050Sstevel@tonic-gate 
4062267Sdp /*
4072267Sdp  * initargs holds the arguments to init (such as -v, -s, -r, -m verbose) and
4082267Sdp  * is a point of rendezvous between krtld (which processes the boot arguments)
4092267Sdp  * and the kernel.
4102267Sdp  */
4112267Sdp extern char initargs[BOOTARGS_MAX];
4120Sstevel@tonic-gate 
4132267Sdp extern int exec_init(const char *, const char *);
4142267Sdp extern int start_init_common(void);
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate #endif	/* _KERNEL */
4170Sstevel@tonic-gate 
4183446Smrj #if defined(_KERNEL) || defined(_BOOT)
4193446Smrj 
4203446Smrj size_t strlcat(char *, const char *, size_t);
4213446Smrj size_t strlen(const char *) __PURE;
4223446Smrj char *strcat(char *, const char *);
4233446Smrj char *strncat(char *, const char *, size_t);
4243446Smrj char *strcpy(char *, const char *);
4253446Smrj char *strncpy(char *, const char *, size_t);
4263446Smrj /* Need to be consistent with <string.h> C++ definitions */
4273446Smrj #if __cplusplus >= 199711L
4283446Smrj extern const char *strchr(const char *, int);
4293446Smrj #ifndef _STRCHR_INLINE
4303446Smrj #define	_STRCHR_INLINE
4313446Smrj extern "C++" {
4323446Smrj 	inline char *strchr(char *__s, int __c) {
4333446Smrj 		return (char *)strchr((const char *)__s, __c);
4343446Smrj 	}
4353446Smrj }
4363446Smrj #endif /* _STRCHR_INLINE */
4373446Smrj extern const char *strrchr(const char *, int);
4383446Smrj #ifndef	_STRRCHR_INLINE
4393446Smrj #define	_STRRCHR_INLINE
4403446Smrj extern "C++" {
4413446Smrj 	inline char *strrchr(char *__s, int __c) {
4423446Smrj 		return (char *)strrchr((const char *)__s, __c);
4433446Smrj 	}
4443446Smrj }
4453446Smrj #endif	/* _STRRCHR_INLINE */
4463446Smrj extern const char *strstr(const char *, const char *);
4473446Smrj #ifndef	_STRSTR_INLINE
4483446Smrj #define	_STRSTR_INLINE
4493446Smrj extern "C++" {
4503446Smrj 	inline char *strstr(char *__s1, const char *__s2) {
4513446Smrj 		return (char *)strstr((const char *)__s1, __s2);
4523446Smrj 	}
4533446Smrj }
4543446Smrj #endif  /* _STRSTR_INLINE */
4553446Smrj #else	/* __cplusplus >= 199711L */
4563446Smrj char *strchr(const char *, int);
4573446Smrj char *strrchr(const char *, int);
4583446Smrj char *strstr(const char *, const char *);
4593446Smrj #endif	/* __cplusplus >= 199711L */
4603446Smrj char *strnrchr(const char *, int, size_t);
4613446Smrj int strcmp(const char *, const char *) __PURE;
4623446Smrj int strncmp(const char *, const char *, size_t) __PURE;
4633446Smrj int strcasecmp(const char *, const char *) __PURE;
4643446Smrj int strncasecmp(const char *, const char *, size_t) __PURE;
4653446Smrj /* Need to be consistent with <string.h> C++ definitions */
4663446Smrj #if __cplusplus >= 199711L
4673446Smrj extern const char *strpbrk(const char *, const char *);
4683446Smrj #ifndef _STRPBRK_INLINE
4693446Smrj #define	_STRPBRK_INLINE
4703446Smrj extern "C++" {
4713446Smrj 	inline char *strpbrk(char *__s1, const char *__s2) {
4723446Smrj 		return (char *)strpbrk((const char *)__s1, __s2);
4733446Smrj 	}
4743446Smrj }
4753446Smrj #endif /* _STRPBRK_INLINE */
4763446Smrj #else /* __cplusplus >= 199711L */
4773446Smrj char *strpbrk(const char *, const char *);
4783446Smrj #endif /* __cplusplus >= 199711L */
4793446Smrj void bcopy(const void *, void *, size_t);
4803446Smrj void bzero(void *, size_t);
4813446Smrj 
4823446Smrj extern void *memset(void *, int, size_t);
4833446Smrj extern void *memcpy(void *, const void *, size_t);
4843446Smrj extern void *memmove(void *, const void *, size_t);
4853446Smrj extern int memcmp(const void *, const void *, size_t);
4863446Smrj 
4873446Smrj #ifdef __lint
4883446Smrj extern	int	__lintzero;	/* for spoofing lint */
4893446Smrj #else	/* __lint */
4903446Smrj #define	__lintzero 0
4913446Smrj #endif	/* __lint */
4923446Smrj #endif /* _KERNEL || _BOOT */
4933446Smrj 
4940Sstevel@tonic-gate #ifdef	__cplusplus
4950Sstevel@tonic-gate }
4960Sstevel@tonic-gate #endif
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate #endif	/* _SYS_SYSTM_H */
499