home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / user.h < prev    next >
Encoding:
Text File  |  1988-06-26  |  11.7 KB  |  368 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8. /*    Copyright (c) 1987, 1988 Microsoft Corporation    */
  9. /*      All Rights Reserved    */
  10.  
  11. /*    This Module contains Proprietary Information of Microsoft  */
  12. /*    Corporation and should be treated as Confidential.       */
  13.  
  14. #ident    "@(#)head.sys:user.h    1.5.1.5"
  15.  
  16. /*
  17.  * The user structure.
  18.  * One allocated per process.
  19.  * Contains all per process data that doesn't need to be referenced
  20.  * while the process is swapped.
  21.  * The user block is p->p_usize*click bytes long; resides at virtual kernel
  22.  * address 0xE0000000 for the 386;
  23.  * contains the system stack per user for exec system call only;
  24.  * is cross referenced with the proc structure for the same process.
  25.  *
  26.  ************************   NOTE  --  NOTE  ****************************
  27.  *
  28.  *     WHEN THIS HEADER CHANGES, BOTH ml/misc.s AND ml/ttrap.s MUST BE
  29.  *       EXAMINED FOR ANY DEPENDENCIES UPON OFFSETS WITHIN THE UBLOCK.
  30.  *       IN PARTICULAR - .SET's ARE DONE ON:
  31.  *                pr_base,
  32.  *                pr_size,
  33.  *                pr_off, and
  34.  *                pr_scale
  35.  *
  36.  **********************************************************************
  37.  * 
  38.  */
  39.  
  40. #define PSARGSZ        80    /* Space in u-block for exec arguments */ 
  41.                 /* Used by ps command */
  42.  
  43. #define    PSCOMSIZ    DIRSIZ    /* For the time being set PSCOMSIZ */
  44.                 /* to DIRSIZ until we can get rid of */
  45.                 /* struct direct u_dent */
  46.  
  47. #define    SYSMASKLEN    4    /* Number of longs in syscall bit masks */
  48.  
  49. #define    KSTKSZ        4096
  50.  
  51. typedef    struct    user
  52. {
  53.     char    u_stack[KSTKSZ];/* kernel stack */
  54.     struct tss386 *u_tss;    /* pointer to user TSS */
  55.     ushort    u_sztss;    /* size of tss (including bit map) */
  56.  
  57.     char    u_sigfault;    /* catch general protection violations
  58.                    caused by user modifying his stack
  59.                    where the old state info is kept */
  60.     char    u_usigfailed;    /* allows the user to know that he caused
  61.                    a general protection violation by
  62.                    modifying his register save area used
  63.                    when the user was allowed to do his own
  64.                    signal processing */
  65.  
  66.     ulong    u_sub;        /* stack upper bound.
  67.                    The address of the first byte of
  68.                    the first page of user stack
  69.                    allocated so far */
  70.     char    u_filler1[40];    /* DON'T TOUCH--this is used by
  71.                  * conditionally-compiled code in iget.c
  72.                  * which checks consistency of inode locking
  73.                  * and unlocking.  Name change to follow in
  74.                  * a later release.
  75.                  */
  76.     
  77.     int    u_caddrflt;    /* Ptr to function to handle    */
  78.                 /* user space external memory    */
  79.                 /* faults encountered in the    */
  80.                 /* kernel.            */
  81.  
  82.     char    u_nshmseg;    /* Nbr of shared memory        */
  83.                 /* currently attached to the    */
  84.                 /* process.            */
  85.  
  86.      struct rem_ids {        /* for exec'ing REMOTE text */
  87.          ushort    ux_uid;        /* uid of exec'd file */
  88.          ushort    ux_gid;        /* group of exec'd file */
  89.          ushort    ux_mode;    /* file mode (set uid, etc. */
  90.      } u_exfile;
  91.     char    *u_comp;    /* pointer to current component */
  92.     char    *u_nextcp;    /* pointer to beginning of next */
  93.                     /* following for Distributed UNIX */
  94.     ushort         u_rflags;    /* flags for distripution */
  95.     int    u_sysabort;    /* Debugging: if set, abort syscall */
  96.     int    u_systrap;    /* Are any syscall mask bits set? */ 
  97.     int         u_syscall;    /* system call number */
  98.     int        u_mntindx;    /* mount index from sysid */
  99.     struct sndd    *u_gift;    /* gift from message      */
  100.     long     u_rcstat;     /* Client cache status flags */
  101.     ulong    u_userstack;
  102.     struct response    *u_copymsg;    /* copyout unfinished business */
  103.     struct msgb    *u_copybp;    /* copyin premeditated send    */
  104.     char         *u_msgend;    /* last byte of copymsg + 1    */
  105.                     /* end of Distributed UNIX */
  106.     
  107.     long    u_bsize;        /* block size of device */
  108.     char     u_psargs[PSARGSZ];    /* arguments from exec */    
  109.  
  110.     int    u_pgproc;    /* use by the MAU driver */
  111.     time_t    u_ageinterval;    /* pageing ageing countdown counter */
  112.     label_t    u_qsav;        /* label variable for quits and    */
  113.                 /* interrupts            */
  114.  
  115.     char    u_segflg;    /* IO flag: 0:user D; 1:system;    */
  116.                 /*          2:user I        */
  117.  
  118.     unchar    u_error;    /* return error code */
  119.  
  120.     ushort    u_uid;        /* effective user id */
  121.     ushort    u_gid;        /* effective group id */
  122.     ushort    u_ruid;        /* real user id */
  123.     ushort    u_rgid;        /* real group id */
  124.  
  125.     struct proc *u_procp;    /* pointer to proc structure */
  126.  
  127.     int    *u_ap;        /* pointer to arglist */
  128.  
  129.     union {            /* syscall return values */
  130.         struct    {
  131.             int    r_val1;
  132.             int    r_val2;
  133.         }r_reg;
  134.         off_t    r_off;
  135.         time_t    r_time;
  136.     } u_r;
  137.  
  138.     caddr_t    u_base;        /* base address for IO */
  139.     unsigned u_count;    /* bytes remaining for IO */
  140.     off_t    u_offset;    /* offset in file for IO */
  141.     short    u_fmode;    /* file mode for IO */
  142.     ushort    u_pbsize;    /* Bytes in block for IO */
  143.     ushort    u_pboff;    /* offset in block for IO */
  144.     dev_t    u_pbdev;    /* real device for IO */
  145.     daddr_t    u_rablock;    /* read ahead block address */
  146.     short    u_errcnt;    /* syscall error count */
  147.  
  148.     struct inode *u_cdir;    /* current directory */
  149.  
  150.     struct inode *u_rdir;    /* root directory */
  151.     caddr_t    u_dirp;        /* pathname pointer */
  152.     struct direct u_dent;    /* current directory entry */
  153.     struct inode *u_pdir;    /* inode of parent directory    */
  154.                 /* of dirp            */
  155.  
  156.  
  157.     char    *u_pofile;    /* Ptr to open file flag array.     */
  158.  
  159.     struct inode *u_ttyip;    /* inode of controlling tty (streams) */
  160.  
  161.     int    u_arg[6];    /* arguments to current system call */
  162.  
  163.     unsigned u_tsize;    /* text size (clicks) */
  164.     unsigned u_dsize;    /* data size (clicks) */
  165.     unsigned u_ssize;    /* stack size (clicks) */
  166.  
  167.     void (*u_signal[MAXSIG])();    /* disposition of signals */
  168.     void (*u_sigreturn)();        /* for cleanup */
  169.  
  170.     time_t    u_utime;    /* this process user time */
  171.     time_t    u_stime;    /* this process system time */
  172.     time_t    u_cutime;    /* sum of childs' utimes */
  173.     time_t    u_cstime;    /* sum of childs' stimes */
  174.  
  175.     int    *u_ar0;        /* address of users saved R0 */
  176.  
  177. /*
  178.  *    The offsets of these elements must be reflected in ttrap.s and misc.s
  179.  */
  180.  
  181.     struct {            /* profile arguments */
  182.         short    *pr_base;    /* buffer base */
  183.         unsigned pr_size;    /* buffer size */
  184.         unsigned pr_off;    /* pc offset */
  185.         unsigned pr_scale;    /* pc scaling */
  186.     } u_prof;
  187.  
  188.     short  *u_ttyp;            /* pointer to pgrp in "tty" struct */
  189.     dev_t    u_ttyd;            /* controlling tty dev */
  190.  
  191.     ulong    u_renv;            /* runtime environment.       */
  192.                     /*   for meaning of bits:      */
  193.                     /*     0-15  see x_renv (x.out.h) */
  194.                     /*    16-23  see x_cpu  (x.out.h) */
  195.                     /*    24-31  see below          */
  196.     /*
  197.      * Executable file info.
  198.      */
  199.     struct exdata {
  200.             struct    inode  *ip;
  201.             long      ux_tsize;    /* text size    */
  202.             long      ux_dsize;    /* data size    */
  203.             long      ux_bsize;    /* bss size     */
  204.             long      ux_lsize;      /* lib size     */
  205.             long      ux_nshlibs;     /* number of shared libs needed */
  206.             short     ux_mag;       /* magic number MUST be here */
  207.             long      ux_toffset;    /* file offset to raw text      */
  208.             long      ux_doffset;    /* file offset to raw data      */
  209.             long      ux_loffset;    /* file offset to lib sctn      */
  210.             long      ux_txtorg;    /* start addr. of text in mem   */
  211.             long      ux_datorg;    /* start addr. of data in mem   */
  212.             long      ux_entloc;    /* entry location               */
  213.             ulong      ux_renv;    /* runtime environment */
  214.     } u_exdata;
  215.  
  216.     long   u_execsz;
  217.  
  218.     char    u_comm[PSCOMSIZ];
  219.  
  220.     time_t    u_start;
  221.     time_t    u_ticks;
  222.     long    u_mem;
  223.     long    u_ior;
  224.     long    u_iow;
  225.     long    u_iosw;
  226.     long    u_ioch;
  227.     char    u_acflag;
  228.  
  229.     short    u_cmask;        /* mask for file creation */
  230.     daddr_t    u_limit;        /* maximum write address */
  231.  
  232.     short    u_lock;            /* process/text locking flags */
  233.  
  234.     /* floating point support variables */
  235.     char    u_fpvalid;              /* flag if saved state is valid     */
  236.     char    u_weitek;               /* flag if process uses weitek chip */
  237.     union {
  238.         struct  fpstate         /* floating point extension state   */
  239.         {
  240.             int     state[27];/* 287/387 saved state           */
  241.             int     status;   /* status word saved at exception */
  242.         } u_fpstate;
  243.         struct    fp_emul
  244.         {
  245.             char    fp_emul[246];  /* (extras for emulator) */
  246.             char    fp_epad[2];
  247.         } fp_emul;
  248.     } u_fps;
  249.     long    u_weitek_reg[33];       /* bits needed to save weitek state */
  250.                     /* NOTE: If the WEITEK is actually  */
  251.                     /* present, only 32 longs will be   */
  252.                     /* used, but if it is not, the      */
  253.                     /* emulator will need 33.           */
  254.     int     u_fpintgate[2];         /* fp intr gate descriptor image   */
  255.  
  256. #define    WEITEK_CONTEXT    0
  257. #define    WEITEK_CAE    0xFFFFFF00    /* clear accum. exception byte    */
  258.  
  259.     /* i286 emulation variables */
  260.     int    *u_callgatep;            /* pointer to call gate in gdt  */
  261.     int     u_callgate[2];          /* call gate descriptor image   */
  262.     int     u_ldtmodified;          /* if set, LDT was modified     */
  263.     ushort    u_ldtlimit;        /* current size (index) of ldt */
  264.  
  265.     /* Flag single-step of lcall for a system call. */
  266.     /* The signal is delivered after the system call*/
  267.     char    u_debugpend;            /* SIGTRAP pending for this proc */
  268.  
  269.     /* debug registers, accessible by ptrace(2) but monitored by kernel */
  270.     char    u_debugon;              /* Debug registers in use, set by kernel */
  271.     int     u_debugreg[8];
  272.     long    u_entrymask[SYSMASKLEN]; /* syscall stop-on-entry mask */
  273.     long    u_exitmask[SYSMASKLEN];    /* syscall stop-on-exit mask */
  274.  
  275.     struct file    *u_ofile[1];    /* Start of array of pointers    */
  276.                     /* to file table entries for    */
  277.                     /* open files.            */
  278. } user_t;
  279.  
  280. extern struct user u;
  281.  
  282. #define u_exuid u_exfile.ux_uid
  283. #define u_exgid u_exfile.ux_gid
  284. #define u_exmode u_exfile.ux_mode
  285.  
  286. #define    u_rval1    u_r.r_reg.r_val1
  287. #define    u_rval2    u_r.r_reg.r_val2
  288. #define    u_roff    u_r.r_off
  289. #define    u_rtime    u_r.r_time
  290.  
  291. /* rcstat values: for client caching */
  292.  
  293. #define    U_RCACHE    0x1
  294.  
  295. /* ioflag values: Read/Write, User/Kernel, Ins/Data */
  296.  
  297. #define    U_WUD    0
  298. #define    U_RUD    1
  299. #define    U_WKD    2
  300. #define    U_RKD    3
  301.  
  302. #define    EXCLOSE    01
  303.  
  304. /* distribution: values for u_rflags */
  305. #define FREMOTE    0x0002    /* file is remote  */
  306.  
  307. #define    U_RSYS        0x0004    /* system call has gone remote */
  308. #define    U_DOTDOT    0x0200
  309. #define U_RCOPY        0x0400    /* used by copyout for non-delay copy */
  310.  
  311. /* u_spop values */
  312. #define U_SPOP_MAU    0x1L
  313.  
  314. /*
  315.  * defines for bits 24-31 of u_renv and various macros for accessing
  316.  * fields of u_renv.  All bits not currently defined are reserved
  317.  * for future expansion.
  318.  */
  319. #define U_ISCOFF    0x1000000
  320. #define    U_RENVMASK    0x3000000    /* runtime environment bits */
  321.  
  322. #define    U_CPUTYPE    (XC_CPU << 16)
  323. #define    U_IS386        (XC_386 << 16)
  324. #define    U_ISWSWAP    (XC_WSWAP << 16)
  325.  
  326. /* binary types */
  327. #define    isCOFF        ((u.u_renv & U_RENVMASK) == U_ISCOFF)    /* 386 COFF */
  328. #define    isXOUT        ((u.u_renv & U_RENVMASK) == 0)        /* 386 x.out */
  329.  
  330. #define    IS386()        (((u.u_renv >> 16) & XC_CPU) == XC_386)
  331.  
  332. /*
  333.  * The following define is used to indicate that the program being
  334.  * exec'd is one of the 286 emulators.  This bit is set in u_renv.
  335.  */
  336. #define    UE_EMUL        0x4000000    /* 286 emulator */
  337. #define    is286EMUL    ((u.u_renv & UE_EMUL) == UE_EMUL)
  338.  
  339. /*
  340.  * Defines for badvise bits of u_renv and various macros for accessing
  341.  * these bits.  
  342.  */
  343.  
  344. #define UB_PRE_SV    0x8000000    /* badvise pre-System V */
  345. #define UB_XOUT        0x10000000    /* badvise x.out */
  346. #define UB_LOCKING    0x20000000    /* badvise locking() system call  */
  347.                     /*      (for kernel use only)     */
  348. #define UB_FCNTL    0x40000000    /* badvise fcntl() system call    */
  349.                     /*      (for kernel use only)     */
  350. #define UB_XSDSWTCH    0x80000000    /* badvise XENIX shared data context */
  351.                     /*    switching             */
  352.  
  353.                 /* badvise indicates x.out behavior */
  354. #define BADVISE_XOUT    ((u.u_renv & UB_XOUT) == UB_XOUT)
  355.  
  356.                 /* badvise indicates pre-System V behavior */
  357. #define BADVISE_PRE_SV    ((u.u_renv & UB_PRE_SV) == UB_PRE_SV)
  358.                 /* badvise indicates XENIX locking() call */
  359. #define ISLOCKING    ((u.u_renv & UB_LOCKING) == UB_LOCKING)
  360.                 /* badvise indicates fcntl() call */
  361. #define ISFCNTL        ((u.u_renv & UB_FCNTL) == UB_FCNTL)
  362.                 /* badvise indicates XENIX shared data
  363.                  *     context switching is enabled
  364.                  */
  365. #define BADVISE_XSDSWTCH ((u.u_renv & UB_XSDSWTCH) == UB_XSDSWTCH)
  366.                 /* x.out binary or badvise indicates x.out */
  367. #define VIRTUAL_XOUT    (isXOUT || BADVISE_XOUT)
  368.