home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / user.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  13.6 KB  |  467 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_USER_H
  11. #define _SYS_USER_H
  12.  
  13. #ident    "@(#)/usr/include/sys/user.h.sl 1.1 4.0 12/08/90 36342 AT&T-USL"
  14.  
  15. #include <sys/param.h>
  16. #include <sys/proc.h>
  17. #include <sys/signal.h> /* XXX - only needed for MAXSIG */
  18. #include <sys/siginfo.h>
  19. #include <sys/tss.h>
  20. #include <sys/seg.h>
  21. #include <sys/resource.h>
  22. #include <sys/exec.h>
  23. #include <vm/faultcatch.h>
  24.  
  25. /*
  26.  * The user structure; one allocated per process.  Contains all the
  27.  * per-process data that doesn't need to be referenced while the
  28.  * process is swapped.
  29.  *
  30.  * The user block is USIZE*click bytes long; resides at virtual kernel
  31.  * address 0xE0000000 on the 386; contains the system stack per user;
  32.  * is cross referenced with the proc structure for the same process.
  33.  *
  34.  *            NOTE  --  NOTE
  35.  *
  36.  *     WHEN THIS HEADER CHANGES, BOTH ml/misc.s AND ml/ttrap.s MUST BE
  37.  *       EXAMINED FOR ANY DEPENDENCIES UPON OFFSETS WITHIN THE UBLOCK.
  38.  *       IN PARTICULAR - .SET's ARE DONE ON:
  39.  *                pr_base,
  40.  *                pr_size,
  41.  *                pr_off, and
  42.  *                pr_scale
  43.  *
  44.  **********************************************************************
  45.  * 
  46.  */
  47.  
  48. /*
  49.  * User file descriptors are allocate dynamically, in multiples
  50.  * of NFPCHUNK.  WARNING: ml/misc.s:vstart_s knows about the
  51.  * size of struct ufchunk.  If this changes, or in NFPCHUNK is
  52.  * changed, remember to update misc.s.
  53.  */
  54.  
  55. #define NFPCHUNK 24
  56.  
  57. struct ufchunk {
  58.     struct file *uf_ofile[NFPCHUNK];
  59.     char uf_pofile[NFPCHUNK];
  60.     struct ufchunk *uf_next;
  61. };
  62.  
  63. #define UF_FDLOCK    0x2    /* file descriptor locked (SysV-style) */
  64.  
  65. #define MAXSYSARGS    8    /* Maximum # of arguments passed to a syscall */ 
  66. #define PSARGSZ        80    /* Space for exec arguments (used by ps(1)) */ 
  67.  
  68. #define    PSCOMSIZ    14
  69.  
  70. #define KSTKSZ        3712
  71.  
  72. typedef struct {        /* kernel syscall set type */
  73.     long    word[16];
  74. } k_sysset_t;
  75.  
  76. /* flags for u_sigflag field */
  77. #define SOMASK         0x001    /* use u_sigoldmask on return from signal */
  78.  
  79. typedef    struct    user {
  80.     char    u_stack[KSTKSZ];/* kernel stack */
  81.     char    u_stack_filler_1[2];
  82.     /* floating point support variables */
  83.     char    u_fpvalid;              /* flag if saved state is valid     */
  84.     char    u_weitek;               /* flag if process uses weitek chip */
  85.     union {
  86.         struct  fpstate         /* floating point extension state   */
  87.         {
  88.             int     state[27];/* 287/387 saved state           */
  89.             int     status;   /* status word saved at exception */
  90.         } u_fpstate;
  91.         struct    fp_emul
  92.         {
  93.             char    fp_emul[246];  /* (extras for emulator) */
  94.             char    fp_epad[2];
  95.         } fp_emul;
  96.     } u_fps;
  97.     long    u_weitek_reg[33];    /* bits needed to save weitek state */
  98.                     /* NOTE: If the WEITEK is actually  */
  99.                     /* present, only 32 longs will be   */
  100.                     /* used, but if it is not, the      */
  101.                     /* emulator will need 33.           */
  102.  
  103.     /* NOTE: The second page of the uarea must begin here.
  104.        That is, the offset at this point must be NBPP. */
  105.  
  106.     struct tss386 *u_tss;    /* pointer to user TSS */
  107.     ushort    u_sztss;    /* size of tss (including bit map) */
  108.  
  109.     char    u_sigfault;    /* catch general protection violations
  110.                    caused by user modifying his stack
  111.                    where the old state info is kept */
  112.     char    u_usigfailed;    /* allows the user to know that he caused
  113.                    a general protection violation by
  114.                    modifying his register save area used
  115.                    when the user was allowed to do his own
  116.                    signal processing */
  117.  
  118.     ulong    u_sub;        /* stack upper bound.
  119.                    The address of the first byte of
  120.                    the first page of user stack
  121.                    allocated so far */
  122. #ifdef DEBUG
  123.     long    u_aoutstamp;
  124.     char    u_filler1[8];
  125. #else
  126.          char    u_filler1[12];
  127. #endif
  128.  
  129.     /* the addr/size of locked memory for the raw disk async i/o */
  130.     caddr_t    u_raioaddr;
  131.     uint    u_raiosize;
  132.  
  133.     caddr_t    u_escbug;    /* address of 2nd page of hung ESC instruction;
  134.                    used in workaround for 80386 B1 stepping
  135.                    errata 17 */
  136.  
  137.     /* Segment descriptors for quick-loading */
  138.     struct seg_desc    u_tss_desc;
  139.     struct seg_desc    u_ldt_desc;
  140.  
  141.     char    u_filler2[4];
  142.  
  143.     /*
  144.      * Number of shared-memory segments currently attached.
  145.      */
  146.     char    u_nshmseg;
  147.  
  148.     /*
  149.      * The following for RFS.  u_srchan is needed because ioctls on
  150.      * the server can hit RF_SERVER() hooks in copyin and copyout,
  151.      * and rcopyin/rcopyout need the implicit parameter.
  152.      */
  153.     ushort        rfs_pad0;
  154.     ushort         rfs_pad1;
  155.     int         u_syscall;    /* system call number */
  156.     struct sndd    *u_srchan;    /* server channel back to client */
  157.     long        rfs_pad2;
  158.     ulong        u_userstack;
  159.  
  160.     long    u_bsize;        /* block size of device */
  161.  
  162.     struct execsw    *u_execsw;    /* pointer into execsw[] for the
  163.                        current executable */
  164.  
  165.     int    u_ageinterval;        /* pageing ageing countdown counter */
  166.     char     u_psargs[PSARGSZ];    /* arguments from exec */    
  167.     char    *u_tracepc;        /* Return PC if tracing enabled */
  168.  
  169.     int    u_arg[MAXSYSARGS];    /* arguments to current system call */
  170.     label_t    u_qsav;            /* longjmp label for quits and intrs */
  171.  
  172.     /*
  173.      * The following (u_segflg and u_error) are obsolete.
  174.      */
  175.     char    u_segflg;        /* 0=user D, 1=system, 2=user I */
  176.     char    u_error;        /* return error code */
  177.  
  178.     /*
  179.      * The following four fields are for backward compatibility
  180.      * with old device drivers; the actual user credentials are
  181.      * found through p_cred in struct proc. These fields may
  182.      * not support valid uid's or gid's when the system is
  183.      * configured with large user id's.
  184.      */
  185.  
  186.     o_uid_t    u_uid;        /* effective user id */
  187.     o_gid_t    u_gid;        /* effective group id */
  188.     o_uid_t    u_ruid;        /* real user id */
  189.     o_gid_t    u_rgid;        /* real group id */
  190.  
  191.     proc_t *u_procp;        /* pointer to proc structure */
  192.  
  193.     int    *u_ap;            /* pointer to arglist */
  194.  
  195.     /*
  196.      * The following (u_r through u_rablock) are all obsolete.
  197.      */
  198.     union {
  199.         struct    {
  200.             int    r_v1;
  201.             int    r_v2;
  202.         } r_reg;
  203.         off_t    r_off;
  204.         time_t    r_time;
  205.     } u_r;
  206.     caddr_t    u_base;            /* base address for IO */
  207.     unsigned u_count;        /* bytes remaining for IO */
  208.     off_t    u_offset;        /* offset in file for IO */
  209.     short    u_fmode;        /* file mode for IO */
  210.     ushort    u_pbsize;        /* Bytes in block for IO */
  211.     ushort    u_pboff;        /* offset in block for IO */
  212.     short    u_errcnt;        /* syscall error count */
  213.     daddr_t    u_rablock;        /* read ahead block address */
  214.  
  215.     int    u_sysabort;        /* Debugging: if set, abort syscall */
  216.     k_sysset_t u_entrymask;        /* syscall stop-on-entry mask */
  217.     k_sysset_t u_exitmask;        /* syscall stop-on-exit mask */
  218.  
  219.     struct vnode *u_cdir;        /* current directory */
  220.  
  221.     struct vnode *u_rdir;        /* root directory */
  222.  
  223.     struct rlimit u_rlimit[RLIM_NLIMITS];     /* resource usage limits */
  224.  
  225.     uint    u_tsize;        /* text size (clicks) */
  226.     uint    u_dsize;        /* data size (clicks) */
  227.     uint    u_ssize;        /* stack size (clicks) */
  228.  
  229.     k_siginfo_t u_siginfo;        /* debugger interface: stop-on-fault */
  230.  
  231.     int    u_systrap;        /* Are any syscall mask bits set? */ 
  232.  
  233.     int    u_execid;
  234.     long    u_execsz;
  235.  
  236.  
  237.         /* WARNING: the definitions for u_ttyp and
  238.         ** u_ttyd will be deleted at the next major
  239.         ** release following SVR4.
  240.         */
  241.  
  242.     o_pid_t  *u_ttyp;        /* for binary compatibility only ! */
  243.     o_dev_t  u_ttyd;        /* for binary compatibility only -
  244.                     ** NODEV will be assigned for large
  245.                     ** controlling terminal devices.
  246.                     */
  247.  
  248.     /*
  249.      * Flag to indicate there is a signal or event pending to
  250.      * the current process.  Used to make a quick check just
  251.      * prior to return from kernel to user mode.
  252.      */
  253.     char    u_sigevpend;
  254.  
  255.  
  256.     /*
  257.      * u_utime, u_stime, u_cutime, u_cstime have been moved to proc table
  258.      */
  259.  
  260.     clock_t    u_uservirt;        /* User virtual time */
  261.     clock_t    u_procvirt;        /* Process virtual time */
  262.  
  263.     int    *u_ar0;            /* address of user's saved R0 */
  264.  
  265.     int    u_sigflag;        /* per-process signal flags */
  266.     struct ucontext *u_oldcontext;    /* previous user context */
  267.     stack_t u_sigaltstack;        /* sp & on-stack state variable */
  268.     k_sigset_t u_signodefer;    /* signals defered when caught */
  269.     k_sigset_t u_sigonstack;    /* signals taken on alternate stack */
  270.     k_sigset_t u_sigresethand;    /* signals reset when caught */
  271.     k_sigset_t u_sigrestart;    /* signals that restart system calls */
  272.     k_sigset_t u_sigoldmask;    /* for sigsuspend */
  273.     k_sigset_t u_sigmask[MAXSIG];    /* signals held while in catcher */
  274.     void    (*u_signal[MAXSIG])();    /* Disposition of signals */
  275.     void    (*u_sigreturn)();    /* for cleanup (signal/sigset handlers)*/
  276.  
  277.     struct prof {            /* profile arguments */
  278.         u_short    *pr_base;    /* buffer base */
  279.         unsigned pr_size;    /* buffer size */
  280.         unsigned pr_off;    /* pc offset */
  281.         unsigned pr_scale;    /* pc scaling */
  282.     } u_prof;
  283.  
  284.     /* XENIX SUPPORT */
  285.  
  286.     ulong    u_renv;            /* runtime environment.       */
  287.                     /*   for meaning of bits:      */
  288.                     /*     0-15  see x_renv (x.out.h) */
  289.                     /*    16-23  see x_cpu  (x.out.h) */
  290.                     /*    24-31  see below          */
  291.  
  292.     /* End XENIX Support */
  293.  
  294.     /*
  295.      * Executable file info.
  296.      */
  297.     struct exdata {
  298.         struct    vnode  *vp;
  299.         size_t    ux_tsize;    /* text size */
  300.         size_t    ux_dsize;    /* data size */
  301.         size_t    ux_bsize;    /* bss size */
  302.         size_t    ux_lsize;      /* lib size */
  303.         long      ux_nshlibs;     /* number of shared libs needed */
  304.         short     ux_mag;       /* magic number MUST be here */
  305.         off_t     ux_toffset;    /* file offset to raw text */
  306.         off_t     ux_doffset;    /* file offset to raw data */
  307.         off_t     ux_loffset;    /* file offset to lib sctn */
  308.         caddr_t   ux_txtorg;    /* start addr of text in mem */
  309.         caddr_t   ux_datorg;    /* start addr of data in mem */
  310.         caddr_t      ux_entloc;    /* entry location */
  311.         ulong      ux_renv;    /* runtime environment */
  312.     } u_exdata;
  313.  
  314.     char    u_comm[PSCOMSIZ];
  315.  
  316.     time_t    u_start;
  317.     clock_t    u_ticks;
  318.     long    u_mem;
  319.     long    u_ior;
  320.     long    u_iow;
  321.     long    u_iosw;
  322.     long    u_ioch;
  323.     char    u_acflag;
  324.     mode_t    u_cmask;        /* mask for file creation */
  325.  
  326.     k_sigset_t    u_oldsig;    /* signals using old-style handlers
  327.                        (i.e. set by signal() or sigset()) */
  328.  
  329.     /*
  330.      * Info on how to handle failed memory faults encountered by the kernel.
  331.      * This replaces u_caddrflt.  See <vm/faultcatch.h>.
  332.      */
  333.     fault_catch_t    u_fault_catch;
  334.  
  335.     char    u_filler3[92];        /* unused */
  336.  
  337.     int     u_fpintgate[2];         /* fp intr gate descriptor image   */
  338.  
  339.     /* i286 emulation variables */
  340.     int    *u_callgatep;            /* pointer to call gate in gdt  */
  341.     int     u_callgate[2];          /* call gate descriptor image   */
  342.     int     u_ldtmodified;          /* if set, LDT was modified     */
  343.     ushort    u_ldtlimit;        /* current size (index) of ldt */
  344.  
  345.     /* Flag single-step of lcall for a system call. */
  346.     /* The signal is delivered after the system call*/
  347.     char    u_debugpend;            /* SIGTRAP pending for this proc */
  348.  
  349.     /* debug registers, accessible by ptrace(2) but monitored by kernel */
  350.     char    u_debugon;              /* Debug registers in use, set by kernel */
  351.     int     u_debugreg[8];
  352.     short    u_lock;            /* process/text locking flags */
  353.  
  354.     int u_nofiles;            /* number of open file slots */
  355.     struct ufchunk u_flist;        /* open file list */
  356. } user_t;
  357.  
  358. extern struct user u;
  359.  
  360. /* floating u area support */
  361. #define KERNSTACK    KSTKSZ
  362. struct seguser {
  363.     union {
  364.         char segu_stack[KERNSTACK];
  365.         struct user segu_u;
  366.     } segusr;
  367. };
  368. #define KUSER(seg)    (&((seg)->segusr.segu_u))
  369.  
  370.  
  371. #define    u_rval1    u_r.r_reg.r_v1
  372. #define    u_rval2    u_r.r_reg.r_v2
  373. #define    u_roff    u_r.r_off
  374. #define    u_rtime    u_r.r_time
  375.  
  376. #define    u_cred    u_procp->p_cred
  377.  
  378.  
  379. /* ioflag values: Read/Write, User/Kernel, Ins/Data */
  380.  
  381. #define    U_WUD    0
  382. #define    U_RUD    1
  383. #define    U_WKD    2
  384. #define    U_RKD    3
  385.  
  386. /* defines for Weitek */
  387.  
  388. #define    WEITEK_CONTEXT    0
  389. #define    WEITEK_CAE    0xFFFFFF00    /* clear accum. exception byte    */
  390.  
  391. /* XENIX SUPPORT */
  392.  
  393. /*
  394.  * defines for bits 24-31 of u_renv and various macros for accessing
  395.  * fields of u_renv.  All bits not currently defined are reserved
  396.  * for future expansion.
  397.  */
  398. #define U_ISCOFF    0x1000000
  399. #define U_ISELF        0x2000000
  400. #define    U_RENVMASK    0x3000000    /* runtime environment bits */
  401.  
  402. #define    U_CPUTYPE    (XC_CPU << 16)
  403. #define    U_IS386        (XC_386 << 16)
  404. #define    U_ISWSWAP    (XC_WSWAP << 16)
  405.  
  406. /* binary types */
  407. #define    isCOFF        ((u.u_renv & U_RENVMASK) == U_ISCOFF)    /* 386 COFF */
  408. #define    isXOUT        ((u.u_renv & U_RENVMASK) == 0)        /* 386 x.out */
  409.  
  410. #define    IS386()        (((u.u_renv >> 16) & XC_CPU) == XC_386)
  411.  
  412. /*
  413.  * The following define is used to indicate that the program being
  414.  * exec'd is one of the 286 emulators.  This bit is set in u_renv.
  415.  */
  416. #define    UE_EMUL        0x4000000    /* 286 emulator */
  417. #define    is286EMUL    ((u.u_renv & UE_EMUL) == UE_EMUL)
  418.  
  419. /*
  420.  * Defines for badvise bits of u_renv and various macros for accessing
  421.  * these bits.  
  422.  */
  423.  
  424. #define UB_PRE_SV    0x8000000    /* badvise pre-System V */
  425. #define UB_XOUT        0x10000000    /* badvise x.out */
  426. #define UB_LOCKING    0x20000000    /* badvise locking() system call  */
  427.                     /*      (for kernel use only)     */
  428. #define UB_FCNTL    0x40000000    /* badvise fcntl() system call    */
  429.                     /*      (for kernel use only)     */
  430. #define UB_XSDSWTCH    0x80000000    /* badvise XENIX shared data context */
  431.                     /*    switching             */
  432.  
  433.                 /* badvise indicates x.out behavior */
  434. #define BADVISE_XOUT    ((u.u_renv & UB_XOUT) == UB_XOUT)
  435.  
  436.                 /* badvise indicates pre-System V behavior */
  437. #define BADVISE_PRE_SV    ((u.u_renv & UB_PRE_SV) == UB_PRE_SV)
  438.                 /* badvise indicates XENIX locking() call */
  439. #define ISLOCKING    ((u.u_renv & UB_LOCKING) == UB_LOCKING)
  440.                 /* badvise indicates fcntl() call */
  441. #define ISFCNTL        ((u.u_renv & UB_FCNTL) == UB_FCNTL)
  442.                 /* badvise indicates XENIX shared data
  443.                  *     context switching is enabled
  444.                  */
  445. #define BADVISE_XSDSWTCH ((u.u_renv & UB_XSDSWTCH) == UB_XSDSWTCH)
  446.                 /* x.out binary or badvise indicates x.out */
  447. #define VIRTUAL_XOUT    (isXOUT || BADVISE_XOUT)
  448.  
  449. /* End XENIX Support */
  450. /* flag values for NFA */
  451. #define NFA_SERVER    0x4000    /* the NFA network server */
  452. #define NFA_CASELESS    0x8000    /* caseless support for DOS */
  453.  
  454.  
  455. #ifdef _KERNEL
  456.  
  457. #if defined(__STDC__)
  458. extern void addupc(void(*)(), int);
  459. #else
  460. extern void addupc();
  461. #endif    /* __STDC__ */
  462.  
  463. #endif    /* _KERNEL */
  464.  
  465. #endif    /* _SYS_USER_H */
  466.  
  467.