17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
53f2f09cdp * Common Development and Distribution License (the "License").
63f2f09cdp * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
215f10ef6Yuri Pankov
227c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23b4203d7Marcel Telka/*	  All Rights Reserved	*/
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate/*
268fc99e4Trevor Thompson * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
277c478bdstevel@tonic-gate * Use is subject to license terms.
285f10ef6Yuri Pankov * Copyright 2016 Nexenta Systems, Inc.
297c478bdstevel@tonic-gate */
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#ifndef _SYS_SYSTM_H
327c478bdstevel@tonic-gate#define	_SYS_SYSTM_H
337c478bdstevel@tonic-gate
344a04e8dToomas Soome#if defined(_STANDALONE)
354a04e8dToomas Soome#include <sys/cdefs.h>
364a04e8dToomas Soome#include <string.h>
374a04e8dToomas Soome#else
387c478bdstevel@tonic-gate#include <sys/types.h>
397c478bdstevel@tonic-gate#include <sys/t_lock.h>
407c478bdstevel@tonic-gate#include <sys/proc.h>
417c478bdstevel@tonic-gate#include <sys/dditypes.h>
424a04e8dToomas Soome#endif
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate#ifdef	__cplusplus
457c478bdstevel@tonic-gateextern "C" {
467c478bdstevel@tonic-gate#endif
477c478bdstevel@tonic-gate
484a04e8dToomas Soome#if !defined(_STANDALONE)
497c478bdstevel@tonic-gate/*
507c478bdstevel@tonic-gate * The pc_t is the type of the kernel's program counter.  In general, a
517c478bdstevel@tonic-gate * pc_t is a uintptr_t -- except for a sparcv9 kernel, in which case all
527c478bdstevel@tonic-gate * instruction text is below 4G, and a pc_t is thus a uint32_t.
537c478bdstevel@tonic-gate */
547c478bdstevel@tonic-gate#ifdef __sparcv9
557c478bdstevel@tonic-gatetypedef uint32_t pc_t;
567c478bdstevel@tonic-gate#else
577c478bdstevel@tonic-gatetypedef uintptr_t pc_t;
587c478bdstevel@tonic-gate#endif
597c478bdstevel@tonic-gate
607c478bdstevel@tonic-gate/*
617c478bdstevel@tonic-gate * Random set of variables used by more than one routine.
627c478bdstevel@tonic-gate */
637c478bdstevel@tonic-gate
64b819ceaGordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL)
65b819ceaGordon Ross#include <sys/types32.h>
667c478bdstevel@tonic-gate#include <sys/varargs.h>
673f2f09cdp#include <sys/uadmin.h>
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gateextern int hz;			/* system clock rate */
707c478bdstevel@tonic-gateextern struct vnode *rootdir;	/* pointer to vnode of root directory */
717c478bdstevel@tonic-gateextern struct vnode *devicesdir;	/* pointer to /devices vnode */
727c478bdstevel@tonic-gateextern int interrupts_unleashed;	/* set after the spl0() in main() */
737c478bdstevel@tonic-gate
747c478bdstevel@tonic-gateextern char runin;		/* scheduling flag */
757c478bdstevel@tonic-gateextern char runout;		/* scheduling flag */
767c478bdstevel@tonic-gateextern char wake_sched;		/* causes clock to wake swapper on next tick */
777c478bdstevel@tonic-gateextern char wake_sched_sec;	/* causes clock to wake swapper after a sec */
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gateextern pgcnt_t	maxmem;		/* max available memory (pages) */
807c478bdstevel@tonic-gateextern pgcnt_t	physmem;	/* physical memory (pages) on this CPU */
817c478bdstevel@tonic-gateextern pfn_t	physmax;	/* highest numbered physical page present */
827c478bdstevel@tonic-gateextern pgcnt_t	physinstalled;	/* physical pages including PROM/boot use */
837c478bdstevel@tonic-gate
847c478bdstevel@tonic-gateextern caddr_t	s_text;		/* start of kernel text segment */
857c478bdstevel@tonic-gateextern caddr_t	e_text;		/* end of kernel text segment */
867c478bdstevel@tonic-gateextern caddr_t	s_data;		/* start of kernel text segment */
877c478bdstevel@tonic-gateextern caddr_t	e_data;		/* end of kernel text segment */
887c478bdstevel@tonic-gate
897c478bdstevel@tonic-gateextern pgcnt_t	availrmem;	/* Available resident (not swapable)	*/
907c478bdstevel@tonic-gate				/* memory in pages.			*/
917c478bdstevel@tonic-gateextern pgcnt_t	availrmem_initial;	/* initial value of availrmem	*/
927c478bdstevel@tonic-gateextern pgcnt_t	segspt_minfree;	/* low water mark for availrmem in seg_spt */
937c478bdstevel@tonic-gateextern pgcnt_t	freemem;	/* Current free memory.			*/
947c478bdstevel@tonic-gate
957c478bdstevel@tonic-gateextern dev_t	rootdev;	/* device of the root */
967c478bdstevel@tonic-gateextern struct vnode *rootvp;	/* vnode of root device */
97986fd29setjeextern boolean_t root_is_ramdisk;	/* root is boot_archive ramdisk */
98986fd29setjeextern uint32_t  ramdisk_size;		/* (KB) set only for sparc netboots */
997c478bdstevel@tonic-gateextern char *volatile panicstr;	/* panic string pointer */
1007c478bdstevel@tonic-gateextern va_list  panicargs;	/* panic arguments */
101753a6d4Sherry Mooreextern volatile int quiesce_active;	/* quiesce(9E) is in progress */
1027c478bdstevel@tonic-gate
1037c478bdstevel@tonic-gateextern int	rstchown;	/* 1 ==> restrictive chown(2) semantics */
1047c478bdstevel@tonic-gateextern int	klustsize;
1057c478bdstevel@tonic-gate
1067c478bdstevel@tonic-gateextern int	abort_enable;	/* Platform input-device abort policy */
1077c478bdstevel@tonic-gate
108005d3feMarek Pospisilextern int	audit_active;	/* Solaris Auditing module state */
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gateextern int	avenrun[];	/* array of load averages */
1117c478bdstevel@tonic-gate
1127c478bdstevel@tonic-gateextern char *isa_list;		/* For sysinfo's isalist option */
1137c478bdstevel@tonic-gate
1147c478bdstevel@tonic-gateextern int noexec_user_stack;		/* patchable via /etc/system */
1157c478bdstevel@tonic-gateextern int noexec_user_stack_log;	/* patchable via /etc/system */
1167c478bdstevel@tonic-gate
117108322fcarlsonj/*
118108322fcarlsonj * Use NFS client operations in the global zone only.  Under contract with
119108322fcarlsonj * admin/install; do not change without coordinating with that consolidation.
120108322fcarlsonj */
121108322fcarlsonjextern int nfs_global_client_only;
122108322fcarlsonj
1237c478bdstevel@tonic-gateextern void report_stack_exec(proc_t *, caddr_t);
1247c478bdstevel@tonic-gate
1257c478bdstevel@tonic-gateextern void startup(void);
1267c478bdstevel@tonic-gateextern void clkstart(void);
1277c478bdstevel@tonic-gateextern void post_startup(void);
1287c478bdstevel@tonic-gateextern void kern_setup1(void);
1297c478bdstevel@tonic-gateextern void ka_init(void);
1307c478bdstevel@tonic-gateextern void nodename_set(void);
1317c478bdstevel@tonic-gate
1327c478bdstevel@tonic-gate/*
1337c478bdstevel@tonic-gate * for tod fault detection
1347c478bdstevel@tonic-gate */
1357c478bdstevel@tonic-gateenum tod_fault_type {
1367c478bdstevel@tonic-gate	TOD_REVERSED = 0,
1377c478bdstevel@tonic-gate	TOD_STALLED,
1387c478bdstevel@tonic-gate	TOD_JUMPED,
1397c478bdstevel@tonic-gate	TOD_RATECHANGED,
140843e198johnlev	TOD_RDONLY,
1417c478bdstevel@tonic-gate	TOD_NOFAULT
1427c478bdstevel@tonic-gate};
1437c478bdstevel@tonic-gate
1448fc99e4Trevor Thompson#define	TOD_GET_FAILED		0x1	/* TOD could not be read */
1458fc99e4Trevor Thompson#define	TOD_SET_DONE		0x2	/* TOD has been modified */
1468fc99e4Trevor Thompson#define	TOD_CPR_RESUME_DONE	0x4	/* CPR resume has occurred */
1478fc99e4Trevor Thompson#define	TOD_DR_RESUME_DONE	0x8	/* DR resume has occurred */
1488fc99e4Trevor Thompson
1497c478bdstevel@tonic-gateextern time_t tod_validate(time_t);
1508fc99e4Trevor Thompsonextern void tod_status_set(int);
1518fc99e4Trevor Thompsonextern void tod_status_clear(int);
1527c478bdstevel@tonic-gateextern void plat_tod_fault(enum tod_fault_type);
1537c478bdstevel@tonic-gate
1547c478bdstevel@tonic-gate#ifndef _LP64
1557c478bdstevel@tonic-gate#ifndef min
1567c478bdstevel@tonic-gateint min(int, int);
1577c478bdstevel@tonic-gate#endif
1587c478bdstevel@tonic-gate
1597c478bdstevel@tonic-gate#ifndef max
1607c478bdstevel@tonic-gateint max(int, int);
1617c478bdstevel@tonic-gate#endif
1627c478bdstevel@tonic-gate
1637c478bdstevel@tonic-gateuint_t umin(uint_t, uint_t);
1647c478bdstevel@tonic-gateuint_t umax(uint_t, uint_t);
1657c478bdstevel@tonic-gate#endif /* !_LP64 */
1667c478bdstevel@tonic-gateint grow(caddr_t);
1677c478bdstevel@tonic-gateint grow_internal(caddr_t, uint_t);
1687c478bdstevel@tonic-gateint brk_internal(caddr_t, uint_t);
16987a18d3Madhavan Venkataramantypedef uint64_t callout_id_t;
1707c478bdstevel@tonic-gatetimeout_id_t timeout(void (*)(void *), void *, clock_t);
1717c478bdstevel@tonic-gatetimeout_id_t realtime_timeout(void (*)(void *), void *, clock_t);
1727c478bdstevel@tonic-gateclock_t untimeout(timeout_id_t);
17387a18d3Madhavan Venkataraman/*
17487a18d3Madhavan Venkataraman * The last argument to timeout_generic() is flags. See callo.h for the
17587a18d3Madhavan Venkataraman * flags definitions.
17687a18d3Madhavan Venkataraman */
17787a18d3Madhavan Venkataramancallout_id_t timeout_generic(int, void (*)(void *), void *, hrtime_t, hrtime_t,
17887a18d3Madhavan Venkataraman    int);
17987a18d3Madhavan Venkataramancallout_id_t timeout_default(void (*)(void *), void *, clock_t);
18087a18d3Madhavan Venkataramancallout_id_t realtime_timeout_default(void (*)(void *), void *, clock_t);
18187a18d3Madhavan Venkataraman/*
18287a18d3Madhavan Venkataraman * The last argument to untimeout_generic() is flags. See callout.c for the
18387a18d3Madhavan Venkataraman * use.
18487a18d3Madhavan Venkataraman */
18587a18d3Madhavan Venkataramanhrtime_t untimeout_generic(callout_id_t, int);
18687a18d3Madhavan Venkataramanclock_t untimeout_default(callout_id_t, int);
1877c478bdstevel@tonic-gatevoid delay(clock_t);
1887c478bdstevel@tonic-gateint delay_sig(clock_t);
1894c06356dhvoid delay_random(clock_t);
1907c478bdstevel@tonic-gateint nodev();
1917c478bdstevel@tonic-gateint nulldev();
1927c478bdstevel@tonic-gatemajor_t getudev(void);
1937c478bdstevel@tonic-gateint cmpldev(dev32_t *, dev_t);
1947c478bdstevel@tonic-gatedev_t expldev(dev32_t);
1957c478bdstevel@tonic-gateint bcmp(const void *, const void *, size_t) __PURE;
1967c478bdstevel@tonic-gateint stoi(char **);
1977c478bdstevel@tonic-gatevoid numtos(ulong_t, char *);
198ae46e4cMatthew Ahrenschar *kmem_asprintf(const char *fmt, ...);
1997c478bdstevel@tonic-gateint strident_valid(const char *);
2007c478bdstevel@tonic-gatevoid strident_canon(char *, size_t);
2017c478bdstevel@tonic-gateint getsubopt(char **optionsp, char * const *tokens, char **valuep);
2027c478bdstevel@tonic-gatechar *append_subopt(const char *, size_t, char *, const char *);
203b819ceaGordon Ross#ifndef	_FAKE_KERNEL
204b819ceaGordon Ross/* conflicts with libc definition */
20569bb4bbcarlsonjint ffs(uintmax_t);
206b819ceaGordon Ross#endif
2077c478bdstevel@tonic-gateint copyin(const void *, void *, size_t);
2087c478bdstevel@tonic-gatevoid copyin_noerr(const void *, void *, size_t);
2097c478bdstevel@tonic-gateint xcopyin(const void *, void *, size_t);
2107c478bdstevel@tonic-gateint xcopyin_nta(const void *, void *, size_t, int);
2117c478bdstevel@tonic-gateint copyout(const void *, void *, size_t);
2127c478bdstevel@tonic-gatevoid copyout_noerr(const void *, void *, size_t);
2137c478bdstevel@tonic-gateint xcopyout(const void *, void *, size_t);
2147c478bdstevel@tonic-gateint xcopyout_nta(const void *, void *, size_t, int);
2157c478bdstevel@tonic-gateint copyinstr(const char *, char *, size_t, size_t *);
2167c478bdstevel@tonic-gateint copyinstr_noerr(const char *, char *, size_t, size_t *);
2177c478bdstevel@tonic-gateint copyoutstr(const char *, char *, size_t, size_t *);
2187c478bdstevel@tonic-gateint copyoutstr_noerr(const char *, char *, size_t, size_t *);
2197c478bdstevel@tonic-gateint copystr(const char *, char *, size_t, size_t *);
2207c478bdstevel@tonic-gatevoid ucopy(const void *, void *, size_t);
2219acbbeannvoid ucopystr(const char *, char *, size_t, size_t *);
2227c478bdstevel@tonic-gatevoid pgcopy(const void *, void *, size_t);
2237c478bdstevel@tonic-gatevoid ovbcopy(const void *, void *, size_t);
2247c478bdstevel@tonic-gatevoid uzero(void *, size_t);
2257c478bdstevel@tonic-gateint kcopy(const void *, void *, size_t);
2267c478bdstevel@tonic-gateint kcopy_nta(const void *, void *, size_t, int);
2277c478bdstevel@tonic-gateint kzero(void *, size_t);
2287c478bdstevel@tonic-gate
2297c478bdstevel@tonic-gateint fuword8(const void *, uint8_t *);
2307c478bdstevel@tonic-gateint fuword16(const void *, uint16_t *);
2317c478bdstevel@tonic-gateint fuword32(const void *, uint32_t *);
2327c478bdstevel@tonic-gateint fulword(const void *, ulong_t *);
2337c478bdstevel@tonic-gatevoid fuword8_noerr(const void *, uint8_t *);
2347c478bdstevel@tonic-gatevoid fuword16_noerr(const void *, uint16_t *);
2357c478bdstevel@tonic-gatevoid fuword32_noerr(const void *, uint32_t *);
2367c478bdstevel@tonic-gatevoid fulword_noerr(const void *, ulong_t *);
2377c478bdstevel@tonic-gate
2387c478bdstevel@tonic-gate#ifdef _LP64
2397c478bdstevel@tonic-gateint fuword64(const void *, uint64_t *);
2407c478bdstevel@tonic-gatevoid fuword64_noerr(const void *, uint64_t *);
2417c478bdstevel@tonic-gate#endif
2427c478bdstevel@tonic-gate
2437c478bdstevel@tonic-gateint subyte(void *, uint8_t);
2447c478bdstevel@tonic-gateint suword8(void *, uint8_t);
2457c478bdstevel@tonic-gateint suword16(void *, uint16_t);
2467c478bdstevel@tonic-gateint suword32(void *, uint32_t);
2477c478bdstevel@tonic-gateint sulword(void *, ulong_t);
2487c478bdstevel@tonic-gatevoid subyte_noerr(void *, uint8_t);
2497c478bdstevel@tonic-gatevoid suword8_noerr(void *, uint8_t);
2507c478bdstevel@tonic-gatevoid suword16_noerr(void *, uint16_t);
2517c478bdstevel@tonic-gatevoid suword32_noerr(void *, uint32_t);
2527c478bdstevel@tonic-gatevoid sulword_noerr(void *, ulong_t);
2537c478bdstevel@tonic-gate
2547c478bdstevel@tonic-gate#ifdef _LP64
2557c478bdstevel@tonic-gateint suword64(void *, uint64_t);
2567c478bdstevel@tonic-gatevoid suword64_noerr(void *, uint64_t);
2577c478bdstevel@tonic-gate#endif
2587c478bdstevel@tonic-gate
259b819ceaGordon Ross#if !defined(_BOOT) && !defined(_FAKE_KERNEL)
260b819ceaGordon Ross/* conflicts with libc definition */
2616a3e8e8Richard Loweint setjmp(label_t *) __RETURNS_TWICE;
2627c478bdstevel@tonic-gateextern void longjmp(label_t *)
2637c478bdstevel@tonic-gate	__NORETURN;
2647c478bdstevel@tonic-gate#pragma unknown_control_flow(setjmp)
2657c478bdstevel@tonic-gate#endif
2667c478bdstevel@tonic-gate
26794e7edblucy wang - Sun Microsystems - Beijing Chinavoid prefetch_read_once(void *);
26894e7edblucy wang - Sun Microsystems - Beijing Chinavoid prefetch_write_once(void *);
26994e7edblucy wang - Sun Microsystems - Beijing Chinavoid prefetch_read_many(void *);
27094e7edblucy wang - Sun Microsystems - Beijing Chinavoid prefetch_write_many(void *);
2717c478bdstevel@tonic-gatecaddr_t caller(void);
2727c478bdstevel@tonic-gatecaddr_t callee(void);
2737c478bdstevel@tonic-gateint getpcstack(pc_t *, int);
2746a3e8e8Richard Loweint on_fault(label_t *) __RETURNS_TWICE;
2757c478bdstevel@tonic-gatevoid no_fault(void);
2767c478bdstevel@tonic-gatevoid halt(char *);
2777c478bdstevel@tonic-gateint scanc(size_t, uchar_t *, uchar_t *, uchar_t);
2787c478bdstevel@tonic-gateint movtuc(size_t, uchar_t *, uchar_t *, uchar_t *);
2797c478bdstevel@tonic-gateint splr(int);
2807c478bdstevel@tonic-gateint splhigh(void);
2817c478bdstevel@tonic-gateint splhi(void);
2827c478bdstevel@tonic-gateint splzs(void);
2837c478bdstevel@tonic-gateint spl0(void);
2847c478bdstevel@tonic-gateint spl6(void);
2857c478bdstevel@tonic-gateint spl7(void);
2867c478bdstevel@tonic-gateint spl8(void);
2877c478bdstevel@tonic-gatevoid splx(int);
2887c478bdstevel@tonic-gatevoid set_base_spl(void);
2897c478bdstevel@tonic-gateint __ipltospl(int);
290b885580Alexander Kolbasovint spl_xcall(void);
2917c478bdstevel@tonic-gate
2927c478bdstevel@tonic-gatevoid softcall_init(void);
2937c478bdstevel@tonic-gatevoid softcall(void (*)(void *), void *);
2947c478bdstevel@tonic-gatevoid softint(void);
2957c478bdstevel@tonic-gate
2967c478bdstevel@tonic-gateextern void sync_icache(caddr_t, uint_t);
2977c478bdstevel@tonic-gateextern void sync_data_memory(caddr_t, size_t);
2987c478bdstevel@tonic-gateextern void hot_patch_kernel_text(caddr_t, uint32_t, uint_t);
2997c478bdstevel@tonic-gate
3007c478bdstevel@tonic-gatevoid _insque(caddr_t, caddr_t);
3017c478bdstevel@tonic-gatevoid _remque(caddr_t);
3027c478bdstevel@tonic-gate
3037c478bdstevel@tonic-gate/* casts to keep lint happy */
3047c478bdstevel@tonic-gate#define	insque(q, p)	_insque((caddr_t)q, (caddr_t)p)
3057c478bdstevel@tonic-gate#define	remque(q)	_remque((caddr_t)q)
3067c478bdstevel@tonic-gate
3077c478bdstevel@tonic-gate#pragma unknown_control_flow(on_fault)
3087c478bdstevel@tonic-gate
3097c478bdstevel@tonic-gatestruct timeval;
3107c478bdstevel@tonic-gateextern void	uniqtime(struct timeval *);
3117c478bdstevel@tonic-gatestruct timeval32;
3127c478bdstevel@tonic-gateextern void	uniqtime32(struct timeval32 *);
3137c478bdstevel@tonic-gate
3147c478bdstevel@tonic-gateuint_t page_num_pagesizes(void);
3157c478bdstevel@tonic-gatesize_t page_get_pagesize(uint_t n);
3167c478bdstevel@tonic-gate
3177c478bdstevel@tonic-gateextern int maxusers;
3187c478bdstevel@tonic-gateextern int pidmax;
3197c478bdstevel@tonic-gate
3207c478bdstevel@tonic-gateextern void param_preset(void);
3217c478bdstevel@tonic-gateextern void param_calc(int);
3227c478bdstevel@tonic-gateextern void param_init(void);
3237c478bdstevel@tonic-gateextern void param_check(void);
3247c478bdstevel@tonic-gate
3257c478bdstevel@tonic-gate#endif /* _KERNEL */
3267c478bdstevel@tonic-gate
3277c478bdstevel@tonic-gate/*
3287c478bdstevel@tonic-gate * Structure of the system-entry table.
3297c478bdstevel@tonic-gate *
330954fa1eToomas Soome *	Changes to struct sysent should maintain binary compatibility with
3317c478bdstevel@tonic-gate *	loadable system calls, although the interface is currently private.
3327c478bdstevel@tonic-gate *
3337c478bdstevel@tonic-gate *	This means it should only be expanded on the end, and flag values
334954fa1eToomas Soome *	should not be reused.
3357c478bdstevel@tonic-gate *
3367c478bdstevel@tonic-gate *	It is desirable to keep the size of this struct a power of 2 for quick
3377c478bdstevel@tonic-gate *	indexing.
3387c478bdstevel@tonic-gate */
3397c478bdstevel@tonic-gatestruct sysent {
3407c478bdstevel@tonic-gate	char		sy_narg;	/* total number of arguments */
3417c478bdstevel@tonic-gate#ifdef _LP64
3427c478bdstevel@tonic-gate	unsigned short	sy_flags;	/* various flags as defined below */
3437c478bdstevel@tonic-gate#else
3447c478bdstevel@tonic-gate	unsigned char	sy_flags;	/* various flags as defined below */
3457c478bdstevel@tonic-gate#endif
3467c478bdstevel@tonic-gate	int		(*sy_call)();	/* argp, rvalp-style handler */
3477c478bdstevel@tonic-gate	krwlock_t	*sy_lock;	/* lock for loadable system calls */
3487c478bdstevel@tonic-gate	int64_t		(*sy_callc)();	/* C-style call hander or wrapper */
3497c478bdstevel@tonic-gate};
3507c478bdstevel@tonic-gate
3517c478bdstevel@tonic-gateextern struct sysent	sysent[];
3527c478bdstevel@tonic-gate#ifdef _SYSCALL32_IMPL
3537c478bdstevel@tonic-gateextern struct sysent	sysent32[];
3547c478bdstevel@tonic-gate#endif
3557c478bdstevel@tonic-gate
3567c478bdstevel@tonic-gateextern struct sysent	nosys_ent;	/* entry for invalid system call */
3577c478bdstevel@tonic-gate
358954fa1eToomas Soome#define	NSYSCALL	256		/* number of system calls */
3597c478bdstevel@tonic-gate
3607c478bdstevel@tonic-gate#define	LOADABLE_SYSCALL(s)	(s->sy_flags & SE_LOADABLE)
3617c478bdstevel@tonic-gate#define	LOADED_SYSCALL(s)	(s->sy_flags & SE_LOADED)
3627c478bdstevel@tonic-gate
3637c478bdstevel@tonic-gate/*
3647c478bdstevel@tonic-gate * sy_flags values
365954fa1eToomas Soome *	Values 1, 2, and 4 were used previously for SETJUMP, ASYNC, and IOSYS.
3667c478bdstevel@tonic-gate */
3677c478bdstevel@tonic-gate#define	SE_32RVAL1	0x0		/* handler returns int32_t in rval1 */
3687c478bdstevel@tonic-gate#define	SE_32RVAL2	0x1		/* handler returns int32_t in rval2 */
3697c478bdstevel@tonic-gate#define	SE_64RVAL	0x2		/* handler returns int64_t in rvals */
3707c478bdstevel@tonic-gate#define	SE_RVAL_MASK	0x3		/* mask of rval_t bits */
3717c478bdstevel@tonic-gate
3727c478bdstevel@tonic-gate#define	SE_LOADABLE	0x08		/* syscall is loadable */
3737c478bdstevel@tonic-gate#define	SE_LOADED	0x10		/* syscall is completely loaded */
3747c478bdstevel@tonic-gate#define	SE_NOUNLOAD	0x20		/* syscall never needs unload */
3757c478bdstevel@tonic-gate#define	SE_ARGC		0x40		/* syscall takes C-style args */
3767c478bdstevel@tonic-gate
3777c478bdstevel@tonic-gate/*
3787c478bdstevel@tonic-gate * Structure of the return-value parameter passed by reference to
3797c478bdstevel@tonic-gate * system entries.
3807c478bdstevel@tonic-gate */
3817c478bdstevel@tonic-gateunion rval {
3827c478bdstevel@tonic-gate	struct	{
3837c478bdstevel@tonic-gate		int	r_v1;
3847c478bdstevel@tonic-gate		int	r_v2;
3857c478bdstevel@tonic-gate	} r_v;
3867c478bdstevel@tonic-gate	off_t	r_off;
3877c478bdstevel@tonic-gate	offset_t r_offset;
3887c478bdstevel@tonic-gate	time_t	r_time;
3897c478bdstevel@tonic-gate	int64_t	r_vals;
3907c478bdstevel@tonic-gate};
3917c478bdstevel@tonic-gate#define	r_val1	r_v.r_v1
3927c478bdstevel@tonic-gate#define	r_val2	r_v.r_v2
3937c478bdstevel@tonic-gate
3947c478bdstevel@tonic-gatetypedef union rval rval_t;
3957c478bdstevel@tonic-gate
396b819ceaGordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL)
3977c478bdstevel@tonic-gate
3987c478bdstevel@tonic-gateextern void reset_syscall_args(void);
3997c478bdstevel@tonic-gateextern int save_syscall_args(void);
4007c478bdstevel@tonic-gateextern uint_t get_syscall_args(klwp_t *lwp, long *argp, int *nargsp);
4017c478bdstevel@tonic-gate#ifdef _SYSCALL32_IMPL
4027c478bdstevel@tonic-gateextern uint_t get_syscall32_args(klwp_t *lwp, int *argp, int *nargp);
4037c478bdstevel@tonic-gate#endif
4047c478bdstevel@tonic-gate
4057c478bdstevel@tonic-gateextern uint_t set_errno(uint_t error);
4067c478bdstevel@tonic-gate#pragma rarely_called(set_errno)
4077c478bdstevel@tonic-gate
4087c478bdstevel@tonic-gateextern int64_t syscall_ap(void);
4097c478bdstevel@tonic-gateextern int64_t loadable_syscall(long, long, long, long, long, long, long, long);
4107c478bdstevel@tonic-gateextern int64_t nosys(void);
411954fa1eToomas Soomeextern int nosys32(void);
4127c478bdstevel@tonic-gate
4137c478bdstevel@tonic-gateextern void swtch(void);
4147c478bdstevel@tonic-gate
4157c478bdstevel@tonic-gateextern uint_t	kcpc_key;	/* TSD key for performance counter context */
4167c478bdstevel@tonic-gate
4177c478bdstevel@tonic-gate/*
4183f2f09cdp * initname holds the path to init and is used as a point of rendezvous
4193f2f09cdp * between krtld (which processes the boot arguments) and the kernel.
4207c478bdstevel@tonic-gate */
4217c478bdstevel@tonic-gate#define	INITNAME_SZ	32
4227c478bdstevel@tonic-gateextern char initname[INITNAME_SZ];
4237c478bdstevel@tonic-gate
4243f2f09cdp/*
4253f2f09cdp * initargs holds the arguments to init (such as -v, -s, -r, -m verbose) and
4263f2f09cdp * is a point of rendezvous between krtld (which processes the boot arguments)
4273f2f09cdp * and the kernel.
4283f2f09cdp */
4293f2f09cdpextern char initargs[BOOTARGS_MAX];
4303f2f09cdp
4313f2f09cdpextern int exec_init(const char *, const char *);
4323f2f09cdpextern int start_init_common(void);
4337c478bdstevel@tonic-gate
4347c478bdstevel@tonic-gate#endif	/* _KERNEL */
4357c478bdstevel@tonic-gate
436b819ceaGordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_BOOT)
437ae115bcmrj
438ae115bcmrjsize_t strlcat(char *, const char *, size_t);
439ae115bcmrjsize_t strlen(const char *) __PURE;
440ae115bcmrjchar *strcat(char *, const char *);
441ae115bcmrjchar *strncat(char *, const char *, size_t);
442ae115bcmrjchar *strcpy(char *, const char *);
443ae115bcmrjchar *strncpy(char *, const char *, size_t);
444b819ceaGordon Ross
445b819ceaGordon Rossextern size_t strlcpy(char *, const char *, size_t);
446b819ceaGordon Rossextern size_t strspn(const char *, const char *);
447b819ceaGordon Rossextern size_t strcspn(const char *, const char *);
448b819ceaGordon Rossextern char *strdup(const char *);
449b819ceaGordon Rossextern void strfree(char *);
450b819ceaGordon Ross
451ae115bcmrj/* Need to be consistent with <string.h> C++ definitions */
452ae115bcmrj#if __cplusplus >= 199711L
453ae115bcmrjextern const char *strchr(const char *, int);
454ae115bcmrj#ifndef _STRCHR_INLINE
455ae115bcmrj#define	_STRCHR_INLINE
456