xref: /titanic_41/usr/src/uts/common/fs/proc/prdata.h (revision 990659f99ccb24bc72c7a86696662c2c09952b7b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5870619e9Sfrankho  * Common Development and Distribution License (the "License").
6870619e9Sfrankho  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
223348528fSdm120769  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
29f971a346SBryan Cantrill /*
30f971a346SBryan Cantrill  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
31f971a346SBryan Cantrill  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _SYS_PROC_PRDATA_H
347c478bd9Sstevel@tonic-gate #define	_SYS_PROC_PRDATA_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
377c478bd9Sstevel@tonic-gate #include <sys/proc.h>
387c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
397c478bd9Sstevel@tonic-gate #include <sys/prsystm.h>
407c478bd9Sstevel@tonic-gate #include <sys/model.h>
417c478bd9Sstevel@tonic-gate #include <sys/poll.h>
42870619e9Sfrankho #include <sys/list.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Test for thread being stopped, not on an event of interest,
507c478bd9Sstevel@tonic-gate  * but with a directed stop in effect.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	DSTOPPED(t)	\
537c478bd9Sstevel@tonic-gate 	((t)->t_state == TS_STOPPED && \
547c478bd9Sstevel@tonic-gate 	((t)->t_proc_flag & TP_PRSTOP))
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	round4(r)	(((r) + 3) & (~3))
577c478bd9Sstevel@tonic-gate #define	round8(r)	(((r) + 7) & (~7))
587c478bd9Sstevel@tonic-gate #define	round16(r)	(((r) + 15) & (~15))
597c478bd9Sstevel@tonic-gate #define	roundlong(r)	(((r) + sizeof (long) - 1) & (~(sizeof (long) - 1)))
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	PNSIZ	10			/* max size of /proc name entries */
627c478bd9Sstevel@tonic-gate #define	PLNSIZ	10			/* max size of /proc lwp name entries */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Common file object to which all /proc vnodes for a specific process
667c478bd9Sstevel@tonic-gate  * or lwp refer.  One for the process, one for each lwp.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate typedef struct prcommon {
697c478bd9Sstevel@tonic-gate 	kmutex_t	prc_mutex;	/* to wait for the proc/lwp to stop */
707c478bd9Sstevel@tonic-gate 	kcondvar_t	prc_wait;	/* to wait for the proc/lwp to stop */
717c478bd9Sstevel@tonic-gate 	ushort_t	prc_flags;	/* flags */
727c478bd9Sstevel@tonic-gate 	uint_t		prc_writers;	/* number of write opens of prnodes */
737c478bd9Sstevel@tonic-gate 	uint_t		prc_selfopens;	/* number of write opens by self */
747c478bd9Sstevel@tonic-gate 	pid_t		prc_pid;	/* process id */
757c478bd9Sstevel@tonic-gate 	model_t		prc_datamodel;	/* data model of the process */
767c478bd9Sstevel@tonic-gate 	proc_t		*prc_proc;	/* process being traced */
777c478bd9Sstevel@tonic-gate 	kthread_t	*prc_thread;	/* thread (lwp) being traced */
787c478bd9Sstevel@tonic-gate 	int		prc_slot;	/* procdir slot number */
797c478bd9Sstevel@tonic-gate 	id_t		prc_tid;	/* thread (lwp) id */
807c478bd9Sstevel@tonic-gate 	int		prc_tslot;	/* lwpdir slot number, -1 if reaped */
817c478bd9Sstevel@tonic-gate 	int		prc_refcnt;	/* this structure's reference count */
827c478bd9Sstevel@tonic-gate 	struct pollhead	prc_pollhead;	/* list of all pollers */
837c478bd9Sstevel@tonic-gate } prcommon_t;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /* prc_flags */
867c478bd9Sstevel@tonic-gate #define	PRC_DESTROY	0x01	/* process or lwp is being destroyed */
877c478bd9Sstevel@tonic-gate #define	PRC_LWP		0x02	/* structure refers to an lwp */
887c478bd9Sstevel@tonic-gate #define	PRC_SYS		0x04	/* process is a system process */
897c478bd9Sstevel@tonic-gate #define	PRC_POLL	0x08	/* poll() in progress on this process/lwp */
907c478bd9Sstevel@tonic-gate #define	PRC_EXCL	0x10	/* exclusive access granted (old /proc) */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Macros for mapping between i-numbers and pids.
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate #define	pmkino(tslot, pslot, nodetype)		\
967c478bd9Sstevel@tonic-gate 	(((((ino_t)(tslot) << nproc_highbit) |	\
977c478bd9Sstevel@tonic-gate 	(ino_t)(pslot)) << 6) |			\
987c478bd9Sstevel@tonic-gate 	(nodetype) + 2)
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /* for old /proc interface */
1017c478bd9Sstevel@tonic-gate #define	PRBIAS	64
1027c478bd9Sstevel@tonic-gate #define	ptoi(n) ((int)(((n) + PRBIAS)))		/* pid to i-number */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  * Node types for /proc files (directories and files contained therein).
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate typedef enum prnodetype {
1087c478bd9Sstevel@tonic-gate 	PR_PROCDIR,		/* /proc				*/
1097c478bd9Sstevel@tonic-gate 	PR_SELF,		/* /proc/self				*/
1107c478bd9Sstevel@tonic-gate 	PR_PIDDIR,		/* /proc/<pid>				*/
1117c478bd9Sstevel@tonic-gate 	PR_AS,			/* /proc/<pid>/as			*/
1127c478bd9Sstevel@tonic-gate 	PR_CTL,			/* /proc/<pid>/ctl			*/
1137c478bd9Sstevel@tonic-gate 	PR_STATUS,		/* /proc/<pid>/status			*/
1147c478bd9Sstevel@tonic-gate 	PR_LSTATUS,		/* /proc/<pid>/lstatus			*/
1157c478bd9Sstevel@tonic-gate 	PR_PSINFO,		/* /proc/<pid>/psinfo			*/
1167c478bd9Sstevel@tonic-gate 	PR_LPSINFO,		/* /proc/<pid>/lpsinfo			*/
1177c478bd9Sstevel@tonic-gate 	PR_MAP,			/* /proc/<pid>/map			*/
1187c478bd9Sstevel@tonic-gate 	PR_RMAP,		/* /proc/<pid>/rmap			*/
1197c478bd9Sstevel@tonic-gate 	PR_XMAP,		/* /proc/<pid>/xmap			*/
1207c478bd9Sstevel@tonic-gate 	PR_CRED,		/* /proc/<pid>/cred			*/
1217c478bd9Sstevel@tonic-gate 	PR_SIGACT,		/* /proc/<pid>/sigact			*/
1227c478bd9Sstevel@tonic-gate 	PR_AUXV,		/* /proc/<pid>/auxv			*/
1237c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1247c478bd9Sstevel@tonic-gate 	PR_LDT,			/* /proc/<pid>/ldt			*/
1257c478bd9Sstevel@tonic-gate #endif
1267c478bd9Sstevel@tonic-gate 	PR_USAGE,		/* /proc/<pid>/usage			*/
1277c478bd9Sstevel@tonic-gate 	PR_LUSAGE,		/* /proc/<pid>/lusage			*/
1287c478bd9Sstevel@tonic-gate 	PR_PAGEDATA,		/* /proc/<pid>/pagedata			*/
1297c478bd9Sstevel@tonic-gate 	PR_WATCH,		/* /proc/<pid>/watch			*/
1307c478bd9Sstevel@tonic-gate 	PR_CURDIR,		/* /proc/<pid>/cwd			*/
1317c478bd9Sstevel@tonic-gate 	PR_ROOTDIR,		/* /proc/<pid>/root			*/
1327c478bd9Sstevel@tonic-gate 	PR_FDDIR,		/* /proc/<pid>/fd			*/
1337c478bd9Sstevel@tonic-gate 	PR_FD,			/* /proc/<pid>/fd/nn			*/
1347c478bd9Sstevel@tonic-gate 	PR_OBJECTDIR,		/* /proc/<pid>/object			*/
1357c478bd9Sstevel@tonic-gate 	PR_OBJECT,		/* /proc/<pid>/object/xxx		*/
1367c478bd9Sstevel@tonic-gate 	PR_LWPDIR,		/* /proc/<pid>/lwp			*/
1377c478bd9Sstevel@tonic-gate 	PR_LWPIDDIR,		/* /proc/<pid>/lwp/<lwpid>		*/
1387c478bd9Sstevel@tonic-gate 	PR_LWPCTL,		/* /proc/<pid>/lwp/<lwpid>/lwpctl	*/
1397c478bd9Sstevel@tonic-gate 	PR_LWPSTATUS,		/* /proc/<pid>/lwp/<lwpid>/lwpstatus	*/
1407c478bd9Sstevel@tonic-gate 	PR_LWPSINFO,		/* /proc/<pid>/lwp/<lwpid>/lwpsinfo	*/
1417c478bd9Sstevel@tonic-gate 	PR_LWPUSAGE,		/* /proc/<pid>/lwp/<lwpid>/lwpusage	*/
1427c478bd9Sstevel@tonic-gate 	PR_XREGS,		/* /proc/<pid>/lwp/<lwpid>/xregs	*/
1437c478bd9Sstevel@tonic-gate 	PR_TMPLDIR,		/* /proc/<pid>/lwp/<lwpid>/templates	*/
1447c478bd9Sstevel@tonic-gate 	PR_TMPL,		/* /proc/<pid>/lwp/<lwpid>/templates/<id> */
145f971a346SBryan Cantrill 	PR_SPYMASTER,		/* /proc/<pid>/lwp/<lwpid>/spymaster	*/
1467c478bd9Sstevel@tonic-gate #if defined(__sparc)
1477c478bd9Sstevel@tonic-gate 	PR_GWINDOWS,		/* /proc/<pid>/lwp/<lwpid>/gwindows	*/
1487c478bd9Sstevel@tonic-gate 	PR_ASRS,		/* /proc/<pid>/lwp/<lwpid>/asrs		*/
1497c478bd9Sstevel@tonic-gate #endif
1507c478bd9Sstevel@tonic-gate 	PR_PRIV,		/* /proc/<pid>/priv			*/
1517c478bd9Sstevel@tonic-gate 	PR_PATHDIR,		/* /proc/<pid>/path			*/
1527c478bd9Sstevel@tonic-gate 	PR_PATH,		/* /proc/<pid>/path/xxx			*/
1537c478bd9Sstevel@tonic-gate 	PR_CTDIR,		/* /proc/<pid>/contracts		*/
1547c478bd9Sstevel@tonic-gate 	PR_CT,			/* /proc/<pid>/contracts/<ctid>		*/
1557c478bd9Sstevel@tonic-gate 	PR_PIDFILE,		/* old process file			*/
1567c478bd9Sstevel@tonic-gate 	PR_LWPIDFILE,		/* old lwp file				*/
1577c478bd9Sstevel@tonic-gate 	PR_OPAGEDATA,		/* old page data file			*/
1587c478bd9Sstevel@tonic-gate 	PR_NFILES		/* number of /proc node types		*/
1597c478bd9Sstevel@tonic-gate } prnodetype_t;
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate typedef struct prnode {
1627c478bd9Sstevel@tonic-gate 	vnode_t		*pr_next;	/* list of all vnodes for process */
1637c478bd9Sstevel@tonic-gate 	uint_t		pr_flags;	/* private flags */
1647c478bd9Sstevel@tonic-gate 	kmutex_t	pr_mutex;	/* locks pr_files and child pr_flags */
1657c478bd9Sstevel@tonic-gate 	prnodetype_t	pr_type;	/* node type */
1667c478bd9Sstevel@tonic-gate 	mode_t		pr_mode;	/* file mode */
1677c478bd9Sstevel@tonic-gate 	ino_t		pr_ino;		/* node id (for stat(2)) */
1687c478bd9Sstevel@tonic-gate 	uint_t		pr_hatid;	/* hat layer id for page data files */
1697c478bd9Sstevel@tonic-gate 	prcommon_t	*pr_common;	/* common data structure */
1707c478bd9Sstevel@tonic-gate 	prcommon_t	*pr_pcommon;	/* process common data structure */
1717c478bd9Sstevel@tonic-gate 	vnode_t		*pr_parent;	/* parent directory */
1727c478bd9Sstevel@tonic-gate 	vnode_t		**pr_files;	/* contained files array (directory) */
1737c478bd9Sstevel@tonic-gate 	uint_t		pr_index;	/* position within parent */
1747c478bd9Sstevel@tonic-gate 	vnode_t		*pr_pidfile;	/* substitute vnode for old /proc */
1757c478bd9Sstevel@tonic-gate 	vnode_t		*pr_realvp;	/* real vnode, file in object,fd dirs */
1767c478bd9Sstevel@tonic-gate 	proc_t		*pr_owner;	/* the process that created this node */
1777c478bd9Sstevel@tonic-gate 	vnode_t		*pr_vnode;	/* pointer to vnode */
1787c478bd9Sstevel@tonic-gate 	struct contract *pr_contract;	/* contract pointer */
1797c478bd9Sstevel@tonic-gate 	int		pr_cttype;	/* active template type */
1807c478bd9Sstevel@tonic-gate } prnode_t;
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate /*
1837c478bd9Sstevel@tonic-gate  * Values for pr_flags.
1847c478bd9Sstevel@tonic-gate  */
1857c478bd9Sstevel@tonic-gate #define	PR_INVAL	0x01		/* vnode is invalidated */
1867c478bd9Sstevel@tonic-gate #define	PR_ISSELF	0x02		/* vnode is a self-open */
1877c478bd9Sstevel@tonic-gate #define	PR_AOUT		0x04		/* vnode is for an a.out path */
188*990659f9SBryan Cantrill #define	PR_OFFMAX	0x08		/* vnode is a large file open */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * Conversion macros.
1927c478bd9Sstevel@tonic-gate  */
1937c478bd9Sstevel@tonic-gate #define	VTOP(vp)	((struct prnode *)(vp)->v_data)
1947c478bd9Sstevel@tonic-gate #define	PTOV(pnp)	((pnp)->pr_vnode)
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * Flags to prlock().
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate #define	ZNO	0	/* Fail on encountering a zombie process. */
2007c478bd9Sstevel@tonic-gate #define	ZYES	1	/* Allow zombies. */
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * Assign one set to another (possible different sizes).
2047c478bd9Sstevel@tonic-gate  *
2057c478bd9Sstevel@tonic-gate  * Assigning to a smaller set causes members to be lost.
2067c478bd9Sstevel@tonic-gate  * Assigning to a larger set causes extra members to be cleared.
2077c478bd9Sstevel@tonic-gate  */
2087c478bd9Sstevel@tonic-gate #define	prassignset(ap, sp)					\
2097c478bd9Sstevel@tonic-gate {								\
2107c478bd9Sstevel@tonic-gate 	register int _i_ = sizeof (*(ap))/sizeof (uint32_t);	\
2117c478bd9Sstevel@tonic-gate 	while (--_i_ >= 0)					\
2127c478bd9Sstevel@tonic-gate 		((uint32_t *)(ap))[_i_] =			\
2137c478bd9Sstevel@tonic-gate 		    (_i_ >= sizeof (*(sp))/sizeof (uint32_t)) ?	\
2147c478bd9Sstevel@tonic-gate 		    0 : ((uint32_t *)(sp))[_i_];		\
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * Determine whether or not a set (of arbitrary size) is empty.
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate #define	prisempty(sp) \
2217c478bd9Sstevel@tonic-gate 	setisempty((uint32_t *)(sp), \
2227c478bd9Sstevel@tonic-gate 		(uint_t)(sizeof (*(sp)) / sizeof (uint32_t)))
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * Resource usage with times as hrtime_t rather than timestruc_t.
2267c478bd9Sstevel@tonic-gate  * Each member exactly matches the corresponding member in prusage_t.
2277c478bd9Sstevel@tonic-gate  * This is for convenience of internal computation.
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate typedef struct prhusage {
2307c478bd9Sstevel@tonic-gate 	id_t		pr_lwpid;	/* lwp id.  0: process or defunct */
2317c478bd9Sstevel@tonic-gate 	int		pr_count;	/* number of contributing lwps */
2327c478bd9Sstevel@tonic-gate 	hrtime_t	pr_tstamp;	/* current time stamp */
2337c478bd9Sstevel@tonic-gate 	hrtime_t	pr_create;	/* process/lwp creation time stamp */
2347c478bd9Sstevel@tonic-gate 	hrtime_t	pr_term;	/* process/lwp termination time stamp */
2357c478bd9Sstevel@tonic-gate 	hrtime_t	pr_rtime;	/* total lwp real (elapsed) time */
2367c478bd9Sstevel@tonic-gate 	hrtime_t	pr_utime;	/* user level CPU time */
2377c478bd9Sstevel@tonic-gate 	hrtime_t	pr_stime;	/* system call CPU time */
2387c478bd9Sstevel@tonic-gate 	hrtime_t	pr_ttime;	/* other system trap CPU time */
2397c478bd9Sstevel@tonic-gate 	hrtime_t	pr_tftime;	/* text page fault sleep time */
2407c478bd9Sstevel@tonic-gate 	hrtime_t	pr_dftime;	/* data page fault sleep time */
2417c478bd9Sstevel@tonic-gate 	hrtime_t	pr_kftime;	/* kernel page fault sleep time */
2427c478bd9Sstevel@tonic-gate 	hrtime_t	pr_ltime;	/* user lock wait sleep time */
2437c478bd9Sstevel@tonic-gate 	hrtime_t	pr_slptime;	/* all other sleep time */
2447c478bd9Sstevel@tonic-gate 	hrtime_t	pr_wtime;	/* wait-cpu (latency) time */
2457c478bd9Sstevel@tonic-gate 	hrtime_t	pr_stoptime;	/* stopped time */
2467c478bd9Sstevel@tonic-gate 	hrtime_t	filltime[6];	/* filler for future expansion */
2477c478bd9Sstevel@tonic-gate 	uint64_t	pr_minf;	/* minor page faults */
2487c478bd9Sstevel@tonic-gate 	uint64_t	pr_majf;	/* major page faults */
2497c478bd9Sstevel@tonic-gate 	uint64_t	pr_nswap;	/* swaps */
2507c478bd9Sstevel@tonic-gate 	uint64_t	pr_inblk;	/* input blocks */
2517c478bd9Sstevel@tonic-gate 	uint64_t	pr_oublk;	/* output blocks */
2527c478bd9Sstevel@tonic-gate 	uint64_t	pr_msnd;	/* messages sent */
2537c478bd9Sstevel@tonic-gate 	uint64_t	pr_mrcv;	/* messages received */
2547c478bd9Sstevel@tonic-gate 	uint64_t	pr_sigs;	/* signals received */
2557c478bd9Sstevel@tonic-gate 	uint64_t	pr_vctx;	/* voluntary context switches */
2567c478bd9Sstevel@tonic-gate 	uint64_t	pr_ictx;	/* involuntary context switches */
2577c478bd9Sstevel@tonic-gate 	uint64_t	pr_sysc;	/* system calls */
2587c478bd9Sstevel@tonic-gate 	uint64_t	pr_ioch;	/* chars read and written */
2597c478bd9Sstevel@tonic-gate 	uint64_t	filler[10];	/* filler for future expansion */
2607c478bd9Sstevel@tonic-gate } prhusage_t;
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /* Exclude system processes from this test */
2657c478bd9Sstevel@tonic-gate #define	PROCESS_NOT_32BIT(p)	\
2667c478bd9Sstevel@tonic-gate 	(!((p)->p_flag & SSYS) && (p)->p_as != &kas && \
2677c478bd9Sstevel@tonic-gate 	(p)->p_model != DATAMODEL_ILP32)
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate extern	int	prnwatch;	/* number of supported watchpoints */
2707c478bd9Sstevel@tonic-gate extern	int	nproc_highbit;	/* highbit(v.v_nproc) */
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate extern	struct vnodeops	*prvnodeops;
2737c478bd9Sstevel@tonic-gate 
274870619e9Sfrankho /*
275870619e9Sfrankho  * Generic chained copyout buffers for procfs use.
276870619e9Sfrankho  * In order to prevent procfs from making huge oversize kmem_alloc calls,
277870619e9Sfrankho  * a list of smaller buffers can be concatenated and copied to userspace in
278870619e9Sfrankho  * sequence.
279870619e9Sfrankho  *
280870619e9Sfrankho  * The implementation is opaque.
281870619e9Sfrankho  *
282870619e9Sfrankho  * A user of this will perform the following steps:
283870619e9Sfrankho  *
284870619e9Sfrankho  *	list_t	listhead;
285870619e9Sfrankho  *	struct my *mp;
286870619e9Sfrankho  *
287870619e9Sfrankho  *	pr_iol_initlist(&listhead, sizeof (*mp), n);
288870619e9Sfrankho  *	while (whatever) {
289870619e9Sfrankho  *		mp = pr_iol_newbuf(&listhead, sizeof (*mp);
290870619e9Sfrankho  *		...
291870619e9Sfrankho  *		error = ...
292870619e9Sfrankho  *	}
293870619e9Sfrankho  *
294870619e9Sfrankho  * When done, depending on whether copyout() or uiomove() is supposed to
295870619e9Sfrankho  * be used for transferring the buffered data to userspace, call either:
296870619e9Sfrankho  *
297870619e9Sfrankho  *	error = pr_iol_copyout_and_free(&listhead, &cmaddr, error);
298870619e9Sfrankho  *
299870619e9Sfrankho  * or else:
300870619e9Sfrankho  *
301870619e9Sfrankho  *	error = pr_iol_uiomove_and_free(&listhead, uiop, error);
302870619e9Sfrankho  *
303870619e9Sfrankho  * These two functions will in any case kmem_free() all list items, but
304870619e9Sfrankho  * if an error occurred before they will not perform the copyout/uiomove.
305870619e9Sfrankho  * If copyout/uiomove are done, the passed target address / uio_t
306870619e9Sfrankho  * are updated. The error returned will either be the one passed in, or
307870619e9Sfrankho  * the error that occurred during copyout/uiomove.
308870619e9Sfrankho  */
309870619e9Sfrankho 
310870619e9Sfrankho extern	void	pr_iol_initlist(list_t *head, size_t itemsize, int nitems);
311870619e9Sfrankho extern	void *	pr_iol_newbuf(list_t *head, size_t itemsize);
312870619e9Sfrankho extern	int	pr_iol_copyout_and_free(list_t *head, caddr_t *tgt, int errin);
313870619e9Sfrankho extern	int	pr_iol_uiomove_and_free(list_t *head, uio_t *uiop, int errin);
314870619e9Sfrankho 
3157c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL)
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate extern	int	prwritectl32(vnode_t *, struct uio *, cred_t *);
3187c478bd9Sstevel@tonic-gate extern	void	prgetaction32(proc_t *, user_t *, uint_t, struct sigaction32 *);
3197c478bd9Sstevel@tonic-gate extern	void	prcvtusage32(struct prhusage *, prusage32_t *);
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32_IMPL */
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /* kludge to support old /proc interface */
3247c478bd9Sstevel@tonic-gate #if !defined(_SYS_OLD_PROCFS_H)
325870619e9Sfrankho extern	int	prgetmap(proc_t *, int, list_t *);
326870619e9Sfrankho extern	int	prgetxmap(proc_t *, list_t *);
3277c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL)
328870619e9Sfrankho extern	int	prgetmap32(proc_t *, int, list_t *);
329870619e9Sfrankho extern	int	prgetxmap32(proc_t *, list_t *);
3307c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32_IMPL */
3317c478bd9Sstevel@tonic-gate #endif /* !_SYS_OLD_PROCFS_H */
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate extern	proc_t	*pr_p_lock(prnode_t *);
3347c478bd9Sstevel@tonic-gate extern	kthread_t *pr_thread(prnode_t *);
3357c478bd9Sstevel@tonic-gate extern	void	pr_stop(prnode_t *);
3367c478bd9Sstevel@tonic-gate extern	int	pr_wait_stop(prnode_t *, time_t);
3377c478bd9Sstevel@tonic-gate extern	int	pr_setrun(prnode_t *, ulong_t);
3383348528fSdm120769 extern	int	pr_wait(prcommon_t *, timestruc_t *, int);
3397c478bd9Sstevel@tonic-gate extern	void	pr_wait_die(prnode_t *);
3407c478bd9Sstevel@tonic-gate extern	int	pr_setsig(prnode_t *, siginfo_t *);
3417c478bd9Sstevel@tonic-gate extern	int	pr_kill(prnode_t *, int, cred_t *);
3427c478bd9Sstevel@tonic-gate extern	int	pr_unkill(prnode_t *, int);
3437c478bd9Sstevel@tonic-gate extern	int	pr_nice(proc_t *, int, cred_t *);
3447c478bd9Sstevel@tonic-gate extern	void	pr_setentryexit(proc_t *, sysset_t *, int);
3457c478bd9Sstevel@tonic-gate extern	int	pr_set(proc_t *, long);
3467c478bd9Sstevel@tonic-gate extern	int	pr_unset(proc_t *, long);
3477c478bd9Sstevel@tonic-gate extern	void	pr_sethold(prnode_t *, sigset_t *);
3487c478bd9Sstevel@tonic-gate extern	void	pr_setfault(proc_t *, fltset_t *);
3497c478bd9Sstevel@tonic-gate extern	int	prusrio(proc_t *, enum uio_rw, struct uio *, int);
3507c478bd9Sstevel@tonic-gate extern	int	prwritectl(vnode_t *, struct uio *, cred_t *);
3517c478bd9Sstevel@tonic-gate extern	int	prlock(prnode_t *, int);
3527c478bd9Sstevel@tonic-gate extern	void	prunmark(proc_t *);
3537c478bd9Sstevel@tonic-gate extern	void	prunlock(prnode_t *);
3547c478bd9Sstevel@tonic-gate extern	size_t	prpdsize(struct as *);
3557c478bd9Sstevel@tonic-gate extern	int	prpdread(proc_t *, uint_t, struct uio *);
3567c478bd9Sstevel@tonic-gate extern	size_t	oprpdsize(struct as *);
3577c478bd9Sstevel@tonic-gate extern	int	oprpdread(struct as *, uint_t, struct uio *);
3587c478bd9Sstevel@tonic-gate extern	void	prgetaction(proc_t *, user_t *, uint_t, struct sigaction *);
3597c478bd9Sstevel@tonic-gate extern	void	prgetusage(kthread_t *, struct prhusage *);
3607c478bd9Sstevel@tonic-gate extern	void	praddusage(kthread_t *, struct prhusage *);
3617c478bd9Sstevel@tonic-gate extern	void	prcvtusage(struct prhusage *, prusage_t *);
3627c478bd9Sstevel@tonic-gate extern	void 	prscaleusage(prhusage_t *);
3637c478bd9Sstevel@tonic-gate extern	kthread_t *prchoose(proc_t *);
3647c478bd9Sstevel@tonic-gate extern	void	allsetrun(proc_t *);
3657c478bd9Sstevel@tonic-gate extern	int	setisempty(uint32_t *, uint_t);
3667c478bd9Sstevel@tonic-gate extern	int	pr_u32tos(uint32_t, char *, int);
3677c478bd9Sstevel@tonic-gate extern	vnode_t	*prlwpnode(prnode_t *, uint_t);
3687c478bd9Sstevel@tonic-gate extern	prnode_t *prgetnode(vnode_t *, prnodetype_t);
3697c478bd9Sstevel@tonic-gate extern	void	prfreenode(prnode_t *);
3707c478bd9Sstevel@tonic-gate extern	void	pr_object_name(char *, vnode_t *, struct vattr *);
3717c478bd9Sstevel@tonic-gate extern	int	set_watched_area(proc_t *, struct watched_area *);
3727c478bd9Sstevel@tonic-gate extern	int	clear_watched_area(proc_t *, struct watched_area *);
3737c478bd9Sstevel@tonic-gate extern	void	pr_free_watchpoints(proc_t *);
3747c478bd9Sstevel@tonic-gate extern	proc_t	*pr_cancel_watch(prnode_t *);
3757c478bd9Sstevel@tonic-gate extern	struct seg *break_seg(proc_t *);
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate /*
3787c478bd9Sstevel@tonic-gate  * Machine-dependent routines (defined in prmachdep.c).
3797c478bd9Sstevel@tonic-gate  */
3807c478bd9Sstevel@tonic-gate extern	void	prgetprregs(klwp_t *, prgregset_t);
3817c478bd9Sstevel@tonic-gate extern	void	prsetprregs(klwp_t *, prgregset_t, int);
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL)
3847c478bd9Sstevel@tonic-gate extern	void	prgetprregs32(klwp_t *, prgregset32_t);
3857c478bd9Sstevel@tonic-gate extern	void	prgregset_32ton(klwp_t *, prgregset32_t, prgregset_t);
3867c478bd9Sstevel@tonic-gate extern	void	prgetprfpregs32(klwp_t *, prfpregset32_t *);
3877c478bd9Sstevel@tonic-gate extern	void	prsetprfpregs32(klwp_t *, prfpregset32_t *);
3887c478bd9Sstevel@tonic-gate extern	size_t	prpdsize32(struct as *);
3897c478bd9Sstevel@tonic-gate extern	int	prpdread32(proc_t *, uint_t, struct uio *);
3907c478bd9Sstevel@tonic-gate extern	size_t	oprpdsize32(struct as *);
3917c478bd9Sstevel@tonic-gate extern	int	oprpdread32(struct as *, uint_t, struct uio *);
3927c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32_IMPL */
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate extern	void	prpokethread(kthread_t *t);
3957c478bd9Sstevel@tonic-gate extern	int	prgetrvals(klwp_t *, long *, long *);
3967c478bd9Sstevel@tonic-gate extern	void	prgetprfpregs(klwp_t *, prfpregset_t *);
3977c478bd9Sstevel@tonic-gate extern	void	prsetprfpregs(klwp_t *, prfpregset_t *);
3987c478bd9Sstevel@tonic-gate extern	void	prgetprxregs(klwp_t *, caddr_t);
3997c478bd9Sstevel@tonic-gate extern	void	prsetprxregs(klwp_t *, caddr_t);
4007c478bd9Sstevel@tonic-gate extern	int	prgetprxregsize(proc_t *);
4017c478bd9Sstevel@tonic-gate extern	int	prhasfp(void);
4027c478bd9Sstevel@tonic-gate extern	int	prhasx(proc_t *);
4037c478bd9Sstevel@tonic-gate extern	caddr_t	prgetstackbase(proc_t *);
4047c478bd9Sstevel@tonic-gate extern	caddr_t	prgetpsaddr(proc_t *);
4057c478bd9Sstevel@tonic-gate extern	int	prisstep(klwp_t *);
4067c478bd9Sstevel@tonic-gate extern	void	prsvaddr(klwp_t *, caddr_t);
4077c478bd9Sstevel@tonic-gate extern	int	prfetchinstr(klwp_t *, ulong_t *);
4087c478bd9Sstevel@tonic-gate extern	ushort_t prgetpctcpu(uint64_t);
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4137c478bd9Sstevel@tonic-gate }
4147c478bd9Sstevel@tonic-gate #endif
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate #endif	/* _SYS_PROC_PRDATA_H */
417