1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#ifndef _SYS_PROCFS_H 28#define _SYS_PROCFS_H 29 30#pragma ident "@(#)procfs.h 1.37 05/06/08 SMI" 31 32/* From Sun's procfs_isa.h */ 33/* 34 * Possible values of pr_dmodel. 35 * This isn't isa-specific, but it needs to be defined here for other reasons. 36 */ 37#define PR_MODEL_UNKNOWN 0 38#define PR_MODEL_ILP32 1 /* process data model is ILP32 */ 39#define PR_MODEL_LP64 2 /* process data model is LP64 */ 40 41/* 42 * APPLE NOTE: This is a VERY cut down copy of Sun's procfs.h. KEEP IT IN ORDER! 43 * We want to be able to diff this file against newer versions of libproc.h 44 * and see where changes have been made. 45 */ 46 47#ifdef __cplusplus 48extern "C" { 49#endif 50 51/* 52 * Control codes (long values) for messages written to ctl and lwpctl files. 53 */ 54#define PCNULL 0L /* null request, advance to next message */ 55#define PCSTOP 1L /* direct process or lwp to stop and wait for stop */ 56#define PCDSTOP 2L /* direct process or lwp to stop */ 57#define PCWSTOP 3L /* wait for process or lwp to stop, no timeout */ 58#define PCTWSTOP 4L /* wait for stop, with long millisecond timeout arg */ 59#define PCRUN 5L /* make process/lwp runnable, w/ long flags argument */ 60#define PCCSIG 6L /* clear current signal from lwp */ 61#define PCCFAULT 7L /* clear current fault from lwp */ 62#define PCSSIG 8L /* set current signal from siginfo_t argument */ 63#define PCKILL 9L /* post a signal to process/lwp, long argument */ 64#define PCUNKILL 10L /* delete a pending signal from process/lwp, long arg */ 65#define PCSHOLD 11L /* set lwp signal mask from sigset_t argument */ 66#define PCSTRACE 12L /* set traced signal set from sigset_t argument */ 67#define PCSFAULT 13L /* set traced fault set from fltset_t argument */ 68#define PCSENTRY 14L /* set traced syscall entry set from sysset_t arg */ 69#define PCSEXIT 15L /* set traced syscall exit set from sysset_t arg */ 70#define PCSET 16L /* set modes from long argument */ 71#define PCUNSET 17L /* unset modes from long argument */ 72#define PCSREG 18L /* set lwp general registers from prgregset_t arg */ 73#define PCSFPREG 19L /* set lwp floating-point registers from prfpregset_t */ 74#define PCSXREG 20L /* set lwp extra registers from prxregset_t arg */ 75#define PCNICE 21L /* set nice priority from long argument */ 76#define PCSVADDR 22L /* set %pc virtual address from long argument */ 77#define PCWATCH 23L /* set/unset watched memory area from prwatch_t arg */ 78#define PCAGENT 24L /* create agent lwp with regs from prgregset_t arg */ 79#define PCREAD 25L /* read from the address space via priovec_t arg */ 80#define PCWRITE 26L /* write to the address space via priovec_t arg */ 81#define PCSCRED 27L /* set process credentials from prcred_t argument */ 82#define PCSASRS 28L /* set ancillary state registers from asrset_t arg */ 83#define PCSPRIV 29L /* set process privileges from prpriv_t argument */ 84#define PCSZONE 30L /* set zoneid from zoneid_t argument */ 85#define PCSCREDX 31L /* as PCSCRED but with supplemental groups */ 86 87/* 88 * process status file. /proc/<pid>/status 89 */ 90typedef struct pstatus { 91 int pr_flags; /* flags (see below) */ 92// int pr_nlwp; /* number of active lwps in the process */ 93 pid_t pr_pid; /* process id */ 94// pid_t pr_ppid; /* parent process id */ 95// pid_t pr_pgid; /* process group id */ 96// pid_t pr_sid; /* session id */ 97// id_t pr_aslwpid; /* historical; now always zero */ 98// id_t pr_agentid; /* lwp id of the /proc agent lwp, if any */ 99// sigset_t pr_sigpend; /* set of process pending signals */ 100// uintptr_t pr_brkbase; /* address of the process heap */ 101// size_t pr_brksize; /* size of the process heap, in bytes */ 102// uintptr_t pr_stkbase; /* address of the process stack */ 103// size_t pr_stksize; /* size of the process stack, in bytes */ 104// timestruc_t pr_utime; /* process user cpu time */ 105// timestruc_t pr_stime; /* process system cpu time */ 106// timestruc_t pr_cutime; /* sum of children's user times */ 107// timestruc_t pr_cstime; /* sum of children's system times */ 108// sigset_t pr_sigtrace; /* set of traced signals */ 109// fltset_t pr_flttrace; /* set of traced faults */ 110// sysset_t pr_sysentry; /* set of system calls traced on entry */ 111// sysset_t pr_sysexit; /* set of system calls traced on exit */ 112 char pr_dmodel; /* data model of the process (see below) */ 113// char pr_pad[3]; 114// taskid_t pr_taskid; /* task id */ 115// projid_t pr_projid; /* project id */ 116// int pr_nzomb; /* number of zombie lwps in the process */ 117// zoneid_t pr_zoneid; /* zone id */ 118// int pr_filler[15]; /* reserved for future use */ 119// lwpstatus_t pr_lwp; /* status of the representative lwp */ 120} pstatus_t; 121 122/* 123 * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags). 124 * 125 * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag 126 * (which are both deprecated). 127 */ 128/* The following flags apply to the specific or representative lwp */ 129#define PR_STOPPED 0x00000001 /* lwp is stopped */ 130#define PR_ISTOP 0x00000002 /* lwp is stopped on an event of interest */ 131#define PR_DSTOP 0x00000004 /* lwp has a stop directive in effect */ 132#define PR_STEP 0x00000008 /* lwp has a single-step directive in effect */ 133#define PR_ASLEEP 0x00000010 /* lwp is sleeping in a system call */ 134#define PR_PCINVAL 0x00000020 /* contents of pr_instr undefined */ 135#define PR_ASLWP 0x00000040 /* obsolete flag; never set */ 136#define PR_AGENT 0x00000080 /* this lwp is the /proc agent lwp */ 137#define PR_DETACH 0x00000100 /* this is a detached lwp */ 138#define PR_DAEMON 0x00000200 /* this is a daemon lwp */ 139/* The following flags apply to the process, not to an individual lwp */ 140#define PR_ISSYS 0x00001000 /* this is a system process */ 141#define PR_VFORKP 0x00002000 /* process is the parent of a vfork()d child */ 142#define PR_ORPHAN 0x00004000 /* process's process group is orphaned */ 143/* The following process flags are modes settable by PCSET/PCUNSET */ 144#define PR_FORK 0x00100000 /* inherit-on-fork is in effect */ 145#define PR_RLC 0x00200000 /* run-on-last-close is in effect */ 146#define PR_KLC 0x00400000 /* kill-on-last-close is in effect */ 147#define PR_ASYNC 0x00800000 /* asynchronous-stop is in effect */ 148#define PR_MSACCT 0x01000000 /* micro-state usage accounting is in effect */ 149#define PR_BPTADJ 0x02000000 /* breakpoint trap pc adjustment is in effect */ 150#define PR_PTRACE 0x04000000 /* ptrace-compatibility mode is in effect */ 151#define PR_MSFORK 0x08000000 /* micro-state accounting inherited on fork */ 152#define PR_IDLE 0x10000000 /* lwp is a cpu's idle thread */ 153 154/* 155 * Memory-map interface. /proc/<pid>/map /proc/<pid>/rmap 156 */ 157// #define PRMAPSZ 64 158typedef struct prmap { 159 /* APPLE NOTE: Changed to 64 bit to handle 32 bit dtrace looking at 64 bit procs */ 160 uint64_t pr_vaddr; /* virtual address of mapping */ 161// uintptr_t pr_vaddr; /* virtual address of mapping */ 162 163// size_t pr_size; /* size of mapping in bytes */ 164// char pr_mapname[PRMAPSZ]; /* name in /proc/<pid>/object */ 165// offset_t pr_offset; /* offset into mapped object, if any */ 166 int pr_mflags; /* protection and attribute flags (see below) */ 167// int pr_pagesize; /* pagesize (bytes) for this mapping */ 168// int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ 169// int pr_filler[1]; /* filler for future expansion */ 170} prmap_t; 171 172/* Protection and attribute flags */ 173#define MA_READ 0x04 /* readable by the traced process */ 174#define MA_WRITE 0x02 /* writable by the traced process */ 175#define MA_EXEC 0x01 /* executable by the traced process */ 176#define MA_SHARED 0x08 /* changes are shared by mapped object */ 177#define MA_ANON 0x40 /* anonymous memory (e.g. /dev/zero) */ 178#define MA_ISM 0x80 /* intimate shared mem (shared MMU resources) */ 179#define MA_NORESERVE 0x100 /* mapped with MAP_NORESERVE */ 180#define MA_SHM 0x200 /* System V shared memory */ 181#define MA_RESERVED1 0x400 /* reserved for future use */ 182 183#ifdef __cplusplus 184} 185#endif 186 187#endif /* _SYS_PROCFS_H */ 188