]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/user.h
Add compatible code to let 32bit libthr work on 64bit kernel.
[FreeBSD/FreeBSD.git] / sys / sys / user.h
1 /*-
2  * Copyright (c) 1982, 1986, 1989, 1991, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      @(#)user.h      8.2 (Berkeley) 9/23/93
30  * $FreeBSD$
31  */
32
33 #ifndef _SYS_USER_H_
34 #define _SYS_USER_H_
35
36 #include <machine/pcb.h>
37 #ifndef _KERNEL
38 /* stuff that *used* to be included by user.h, or is now needed */
39 #include <sys/errno.h>
40 #include <sys/time.h>
41 #include <sys/resource.h>
42 #include <sys/ucred.h>
43 #include <sys/uio.h>
44 #include <sys/queue.h>
45 #include <sys/_lock.h>
46 #include <sys/_mutex.h>
47 #include <sys/proc.h>
48 #include <vm/vm.h>              /* XXX */
49 #include <vm/vm_param.h>        /* XXX */
50 #include <vm/pmap.h>            /* XXX */
51 #include <vm/vm_map.h>          /* XXX */
52 #endif /* !_KERNEL */
53 #ifndef _SYS_RESOURCEVAR_H_
54 #include <sys/resourcevar.h>
55 #endif
56 #ifndef _SYS_SIGNALVAR_H_
57 #include <sys/signalvar.h>
58 #endif
59
60 /*
61  * KERN_PROC subtype ops return arrays of selected proc structure entries:
62  *
63  * This struct includes several arrays of spare space, with different arrays
64  * for different standard C-types.  When adding new variables to this struct,
65  * the space for byte-aligned data should be taken from the ki_sparestring,
66  * pointers from ki_spareptrs, word-aligned data from ki_spareints, and
67  * doubleword-aligned data from ki_sparelongs.  Make sure the space for new
68  * variables come from the array which matches the size and alignment of
69  * those variables on ALL hardware platforms, and then adjust the appropriate
70  * KI_NSPARE_* value(s) to match.
71  *
72  * Always verify that sizeof(struct kinfo_proc) == KINFO_PROC_SIZE on all
73  * platforms after you have added new variables.  Note that if you change
74  * the value of KINFO_PROC_SIZE, then many userland programs will stop
75  * working until they are recompiled!
76  *
77  * Once you have added the new field, you will need to add code to initialize
78  * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
79  * function kvm_proclist in lib/libkvm/kvm_proc.c .
80  */
81 #define KI_NSPARE_INT   10
82 #define KI_NSPARE_LONG  12
83 #define KI_NSPARE_PTR   7
84
85 #ifdef __amd64__
86 #define KINFO_PROC_SIZE 1088
87 #endif
88 #ifdef __arm__
89 #define KINFO_PROC_SIZE 792
90 #endif
91 #ifdef __ia64__
92 #define KINFO_PROC_SIZE 1088
93 #endif
94 #ifdef __i386__
95 #define KINFO_PROC_SIZE 768
96 #endif
97 #ifdef __powerpc__
98 #define KINFO_PROC_SIZE 768
99 #endif
100 #ifdef __sparc64__
101 #define KINFO_PROC_SIZE 1088
102 #endif
103 #ifndef KINFO_PROC_SIZE
104 #error "Unknown architecture"
105 #endif
106
107 #define WMESGLEN        8               /* size of returned wchan message */
108 #define LOCKNAMELEN     8               /* size of returned lock name */
109 #define OCOMMLEN        16              /* size of returned thread name */
110 #define COMMLEN         19              /* size of returned ki_comm name */
111 #define KI_EMULNAMELEN  16              /* size of returned ki_emul */
112 #define KI_NGROUPS      16              /* number of groups in ki_groups */
113 #define LOGNAMELEN      17              /* size of returned ki_login */
114
115 struct kinfo_proc {
116         int     ki_structsize;          /* size of this structure */
117         int     ki_layout;              /* reserved: layout identifier */
118         struct  pargs *ki_args;         /* address of command arguments */
119         struct  proc *ki_paddr;         /* address of proc */
120         struct  user *ki_addr;          /* kernel virtual addr of u-area */
121         struct  vnode *ki_tracep;       /* pointer to trace file */
122         struct  vnode *ki_textvp;       /* pointer to executable file */
123         struct  filedesc *ki_fd;        /* pointer to open file info */
124         struct  vmspace *ki_vmspace;    /* pointer to kernel vmspace struct */
125         void    *ki_wchan;              /* sleep address */
126         pid_t   ki_pid;                 /* Process identifier */
127         pid_t   ki_ppid;                /* parent process id */
128         pid_t   ki_pgid;                /* process group id */
129         pid_t   ki_tpgid;               /* tty process group id */
130         pid_t   ki_sid;                 /* Process session ID */
131         pid_t   ki_tsid;                /* Terminal session ID */
132         short   ki_jobc;                /* job control counter */
133         short   ki_spare_short1;        /* unused (just here for alignment) */
134         dev_t   ki_tdev;                /* controlling tty dev */
135         sigset_t ki_siglist;            /* Signals arrived but not delivered */
136         sigset_t ki_sigmask;            /* Current signal mask */
137         sigset_t ki_sigignore;          /* Signals being ignored */
138         sigset_t ki_sigcatch;           /* Signals being caught by user */
139         uid_t   ki_uid;                 /* effective user id */
140         uid_t   ki_ruid;                /* Real user id */
141         uid_t   ki_svuid;               /* Saved effective user id */
142         gid_t   ki_rgid;                /* Real group id */
143         gid_t   ki_svgid;               /* Saved effective group id */
144         short   ki_ngroups;             /* number of groups */
145         short   ki_spare_short2;        /* unused (just here for alignment) */
146         gid_t   ki_groups[KI_NGROUPS];  /* groups */
147         vm_size_t ki_size;              /* virtual size */
148         segsz_t ki_rssize;              /* current resident set size in pages */
149         segsz_t ki_swrss;               /* resident set size before last swap */
150         segsz_t ki_tsize;               /* text size (pages) XXX */
151         segsz_t ki_dsize;               /* data size (pages) XXX */
152         segsz_t ki_ssize;               /* stack size (pages) */
153         u_short ki_xstat;               /* Exit status for wait & stop signal */
154         u_short ki_acflag;              /* Accounting flags */
155         fixpt_t ki_pctcpu;              /* %cpu for process during ki_swtime */
156         u_int   ki_estcpu;              /* Time averaged value of ki_cpticks */
157         u_int   ki_slptime;             /* Time since last blocked */
158         u_int   ki_swtime;              /* Time swapped in or out */
159         int     ki_spareint1;           /* unused (just here for alignment) */
160         u_int64_t ki_runtime;           /* Real time in microsec */
161         struct  timeval ki_start;       /* starting time */
162         struct  timeval ki_childtime;   /* time used by process children */
163         long    ki_flag;                /* P_* flags */
164         long    ki_kiflag;              /* KI_* flags (below) */
165         int     ki_traceflag;           /* Kernel trace points */
166         char    ki_stat;                /* S* process status */
167         signed char ki_nice;            /* Process "nice" value */
168         char    ki_lock;                /* Process lock (prevent swap) count */
169         char    ki_rqindex;             /* Run queue index */
170         u_char  ki_oncpu;               /* Which cpu we are on */
171         u_char  ki_lastcpu;             /* Last cpu we were on */
172         char    ki_ocomm[OCOMMLEN+1];   /* thread name */
173         char    ki_wmesg[WMESGLEN+1];   /* wchan message */
174         char    ki_login[LOGNAMELEN+1]; /* setlogin name */
175         char    ki_lockname[LOCKNAMELEN+1]; /* lock name */
176         char    ki_comm[COMMLEN+1];     /* command name */
177         char    ki_emul[KI_EMULNAMELEN+1];  /* emulation name */
178         /*
179          * When adding new variables, take space for char-strings from the
180          * front of ki_sparestrings, and ints from the end of ki_spareints.
181          * That way the spare room from both arrays will remain contiguous.
182          */
183         char    ki_sparestrings[68];    /* spare string space */
184         int     ki_spareints[KI_NSPARE_INT];    /* spare room for growth */
185         int     ki_jid;                 /* Process jail ID */
186         int     ki_numthreads;          /* XXXKSE number of threads in total */
187         lwpid_t ki_tid;                 /* XXXKSE thread id */
188         struct  priority ki_pri;        /* process priority */
189         struct  rusage ki_rusage;       /* process rusage statistics */
190         /* XXX - most fields in ki_rusage_ch are not (yet) filled in */
191         struct  rusage ki_rusage_ch;    /* rusage of children processes */
192         struct  pcb *ki_pcb;            /* kernel virtual addr of pcb */
193         void    *ki_kstack;             /* kernel virtual addr of stack */
194         void    *ki_udata;              /* User convenience pointer */
195         /*
196          * When adding new variables, take space for pointers from the
197          * front of ki_spareptrs, and longs from the end of ki_sparelongs.
198          * That way the spare room from both arrays will remain contiguous.
199          */
200         void    *ki_spareptrs[KI_NSPARE_PTR];   /* spare room for growth */
201         long    ki_sparelongs[KI_NSPARE_LONG];  /* spare room for growth */
202         long    ki_sflag;               /* PS_* flags */
203         long    ki_tdflags;             /* XXXKSE kthread flag */
204 };
205 void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
206 /* XXX - the following two defines are temporary */
207 #define ki_childstime   ki_rusage_ch.ru_stime
208 #define ki_childutime   ki_rusage_ch.ru_utime
209
210 /* ki_sessflag values */
211 #define KI_CTTY         0x00000001      /* controlling tty vnode active */
212 #define KI_SLEADER      0x00000002      /* session leader */
213 #define KI_LOCKBLOCK    0x00000004      /* proc blocked on lock ki_lockname */
214
215 /*
216  * This used to be the per-process structure containing data that
217  * isn't needed in core when the process is swapped out, but now it
218  * remains only for the benefit of a.out core dumps.
219  */
220 struct user {
221         struct  pstats u_stats;         /* *p_stats */
222         struct  kinfo_proc u_kproc;     /* eproc */
223 };
224
225 #endif