home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / user.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-13  |  10.3 KB  |  312 lines

  1.  
  2. /*
  3.  *    @(#) user.h 2.6 88/07/13 
  4.  *
  5.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
  6.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
  7.  *    This Module contains Proprietary Information of
  8.  *    The Santa Cruz Operation, Microsoft Corporation
  9.  *    and AT&T, and should be treated as Confidential.
  10.  */
  11.  
  12. #ifndef X_MAGIC
  13. #include "a.out.h"
  14. #endif
  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 USIZE*click bytes long; resides at virtual kernel
  22.  * SPTADDR, contains the system stack per user; is cross referenced
  23.  * with the proc structure for the same process.
  24.  */
  25.  
  26. #define PSARGSZ    40    /* Space in u-block for exec arguments */
  27.             /* Used by ps command */
  28. #define SHLBMAX  2      /* maximum # of shared libraries per process */
  29. #define SHLBPDES 2      /* maximum # of page directory entries per shlib */
  30.  
  31. #ifdef M_I386
  32. typedef    char    *faddr_u;
  33. #else /* M_I8086 or M_I286 */
  34. typedef union {
  35.         char far *fu_far;
  36.         char     *fu_near;
  37. } faddr_u;
  38. #endif 
  39.  
  40. struct    user
  41. {
  42.     char u_kstack[KSSIZE];        /* kernel stack, per process */
  43.     label_t    u_rsav;            /* save info when exchanging stacks */
  44.     label_t    u_qsav;            /* label variable for quits and interrupts */
  45.     label_t    u_ssav;            /* label variable for swapping */
  46.     char    u_segflg;        /* IO flag: 0:user D; 1:system; 2:user I */
  47.     uchar_t    u_error;        /* return error code */
  48.     ushort    u_uid;            /* effective user id */
  49.     ushort    u_gid;            /* effective group id */
  50.     ushort    u_ruid;            /* real user id */
  51.     ushort    u_rgid;            /* real group id */
  52.     struct proc *u_procp;        /* pointer to proc structure */
  53.     int    *u_ap;            /* pointer to arglist */
  54.     union {                /* syscall return values */
  55.         struct    {
  56.             int    r_val1;
  57.             int    r_val2;
  58.         }r_reg;
  59.         off_t    r_off;
  60.         time_t    r_time;
  61.         long    r_long;
  62.         faddr_t    r_faddr;
  63. #ifndef M_I386
  64.         char far *r_far;
  65. #endif
  66.     } u_r;
  67.     faddr_u    u_baseu;        /* base address for IO */
  68.     unsigned u_count;        /* bytes remaining for IO */
  69.     off_t    u_offset;        /* offset in file for IO */
  70.     short    u_fmode;        /* file mode for IO */
  71.     daddr_t    u_rablock;        /* read ahead block addr */
  72.     short    u_errcnt;        /* syscall error count */
  73.     inodep_t u_cdir;        /* current directory of process */
  74.     inodep_t u_rdir;        /* root directory of process */
  75.     faddr_u    u_dirpu;        /* pathname pointer */
  76.     struct direct u_dent;        /* current directory entry */
  77.     inodep_t u_pdir;        /* inode of parent directory of dirp */
  78.     filep_t u_ofile[NOFILE];    /* pointers to open file structures */
  79.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  80.     int    u_arg[10];        /* arguments to current system call */
  81.     unsigned u_tsize;        /* text size */
  82.     unsigned u_dsize;        /* data size */
  83.     unsigned u_ssize;        /* stack size */
  84. #ifdef M_I386
  85.     int    (*u_signal[MAXSIG])();    /* disposition of signals */
  86.     int    (*u_sigreturn)();    /* for cleanup */
  87. #else
  88.     int (far *u_signal[NSIG])();    /* disposition of signals */
  89. #endif
  90.     time_t    u_utime;        /* this process user time */
  91.     time_t    u_stime;        /* this process system time */
  92.     time_t    u_cutime;        /* sum of childs' utimes */
  93.     time_t    u_cstime;        /* sum of childs' stimes */
  94.     int    *u_ar0;            /* address of users saved R0 */
  95.     char    u_psargs[PSARGSZ];    /* args from exec system call */
  96.     struct {                        /* profile arguments */
  97.         faddr_u  pr_baseu;      /* buffer base */
  98.         unsigned pr_size;       /* buffer size */
  99.         long     pr_off;        /* pc offset */
  100.         unsigned pr_scale;      /* pc scaling */
  101.         faddr_u  pr_syspcu;     /* address of user pc during syscall */
  102.     } u_prof;
  103.     char    u_intflg;           /* catch intr from sys */
  104.     char    u_sep;              /* flag for I and D separation */
  105.     char    u_osvers;        /* version of binary (SYS2, 3, 5, etc) */
  106.     char    u_hugex;        /* allows exec of proc > swapper when set */
  107.     char    u_lock;            /* for plock() system call */
  108.     char    u_cpu;            /* cpu type for this program */
  109.     unsigned short    u_renv;        /* runtime environment */ 
  110.     struct tty *u_ttyp;            /* pointer to pgrp in tty structure */
  111.     dev_t   u_ttyd;             /* controlling tty dev */
  112.     struct u_exdata {        /* header information */
  113.         long    x_text;        /* size of text segment(s) */
  114.         long    x_data;        /* size of initialized data segment(s) */
  115.         long    x_bss;        /* size of uninitialized data segment(s) */
  116.         long    x_stack;    /* size of stack (if XE_FS set) */
  117.         long    x_entry;    /* entry offset */
  118.         unsigned short x_eseg;    /* entry segment */
  119.         unsigned short x_renv;    /* run-time environment */
  120.         char    x_osvers;
  121.         char    x_cpu;        /* cpu type */
  122. #ifdef M_I386
  123.         char    x_excoff;    /* flags for exec'ing coff binary */
  124.         char    x_coff;        /* flag for coff binary */
  125. #endif
  126.         long    x_segsize;    /* segment table size */
  127.         long    x_segpos;    /* segment table position */
  128.     } u_exdata;
  129.     char    u_comm[DIRSIZ];     
  130.     time_t  u_start;            
  131.     time_t  u_ticks;           
  132.     long    u_mem;            
  133.     long    u_ior;           
  134.     long    u_iow;          
  135.     long    u_iosw;        
  136.     long    u_ioch;       
  137.     char    u_acflag;    
  138.     char    u_nfsflgs;            /* reserved for future use */
  139.     short   u_cmask;            /* mask for file creation */
  140.     daddr_t u_limit;            /* maximum write address */
  141.     short    u_t[32];        /* used to be int u_t[32] */
  142. #ifdef M_I386
  143.     unsigned u_lsize;        /* library size in bytes */
  144.     inodep_t u_ip[SHLBMAX+1];
  145.     inodep_t u_exip[SHLBMAX+1];
  146.     char    u_nshlibs;
  147.     char    u_exnshlibs;
  148.     short   u_spare;         
  149.     short   u_shlpdindex[SHLBMAX*SHLBPDES];
  150.     struct tabent 
  151.         u_shlpdent[SHLBMAX*SHLBPDES];
  152.     struct ldtinfo *u_shlinfo;
  153. #endif
  154.     inodep_t u_ttyip;        /* stream controlling tty */
  155.     int     u_sdsaved;          /* we have saved the shared data */
  156. /* machine dependent fields */
  157.     int     u_fper;             /* FP error register */
  158.     char    u_fpsaved;          /* FP regs saved for this proc */
  159.     char    u_fpused;           /* FP used for this process    */
  160. #ifdef M_I386
  161.     char    u_fpad[2];
  162.     struct u_fps {                  /* 80287 save status */
  163.         struct fp_hardware {
  164.             unsigned int    fp_cntrl;    /* control word    */
  165.             unsigned int    fp_stat;    /* status word    */
  166.             unsigned int    fp_tag;        /* tag word    */
  167.             unsigned long    fp_ip;        /* instruction pointer*/
  168.             unsigned short    fp_cs;        /* code selector */
  169.             unsigned short    fp_ds;        /* data selector */
  170.             unsigned long    fp_op;        /* operand offset */
  171.             unsigned long    fp_rsvd;
  172.             unsigned char   fp_regs[80];    /* register stack */
  173.             unsigned short    fp_new_status;
  174.             unsigned char    fp_pad[6];
  175.         } fp_hardware;
  176.         struct fp_emul {
  177.             char    fp_emul[214];  /*   (extras for emulator)  */
  178.             char    fp_epad[2];
  179.         } fp_emul;
  180.     } u_fps;
  181. #else
  182.     struct {                    /* 80287 save status */
  183.         int    fp_cntrl;    /* control word */
  184.         int    fp_stat;    /* status word */
  185.         int    fp_tag;        /* tag word */
  186.         int    fp_ip[2];    /* instruction pointer */
  187.         int    fp_op[2];    /* operand pointer */
  188.         char    fp_regs[100];   /* temporary registers */
  189.         int     fp_spare;       /*   (2 xtra for emulator)      */
  190.     } u_fps;
  191. #endif
  192.     unsigned short  u_lxrw;     /* R/W access of text segments */ 
  193.     faddr_u     u_stkbotu;        /* start or bottom of user stack */
  194. #ifdef M_I386
  195.     caddr_t    u_stktop;        /* end or top of user stack */
  196. #endif
  197.     faddr_u     u_edatau;        /* end of user data before brks
  198.                        seg:off for 286, 32 bit addr for 386 */
  199.     caddr_t     u_sdata;        /* start of user data */    
  200. #ifndef M_I386
  201.     struct segtmp far *u_segoff;    /* ptr to segoff array used by exec */
  202. #endif
  203. #ifdef M_I8086
  204.     /* following are 8086 only fields */
  205.     short    u_usegs[NSEG];        /* segments table for mem management*/
  206.     caddr_t    u_topstk;        /* user data address of stack top*/
  207.     caddr_t u_botstk;        /*   "   "     "      "   bottom*/
  208.     unsigned u_flags;        /* misc flags */
  209.     caddr_t u_seginfo;        /* seginfo table pointer */
  210.     unsigned u_curbrk;        /* current break val: brkctl */
  211.     unsigned u_hdrsiz;        /* 8086 only x.out hdr size */
  212.     struct   ex86 {    
  213.         long    x_reloc;
  214.         long    x_syms;
  215.         unsigned short x_ext;
  216.         char    x_relsym;
  217.         char    x_res;
  218.     } u_ex86;
  219. #endif
  220. #ifdef M_I386
  221. #ifdef VPIX
  222.     struct    tss *u_tss;        /* pointer to tss for proc (if any) */
  223.     short    u_tsslimit;        /* tss size */
  224.     short    u_weitek;        /* was, reserved 1 */
  225. #else
  226.     int     u_res0;            /* reserved 0 */
  227.     short    u_res1;            /* reserved 1 */
  228.     short    u_weitek;        /* was, reserved 1 */
  229. #endif
  230.     struct tabent u_tpdent[TXTPDENT]; /* text page directory entries */
  231.     struct tabent u_dpdent[DATAPDENT]; /* data page directory entries */
  232.     struct tabent u_shmpdent[SHMPDENT]; /* shared data page dir entries */
  233.     int u_dtime;            /* time spent on this data segment */
  234.     struct ldtinfo *u_ldtinfo;    /* pointer to ldtinfo array for exec */
  235.     unsigned short u_ldtlimit;    /* current size(index) of ldt */
  236.     short u_physmap;        /* was: char u_lpad[2] */
  237.     struct descriptor u_ldt[1];    /* ldt grows up from here */
  238. #endif
  239. };
  240. extern struct user u;
  241.  
  242. #define    u_rval1    u_r.r_reg.r_val1
  243. #define    u_rval2    u_r.r_reg.r_val2
  244. #define    u_roff    u_r.r_off
  245. #define    u_rtime    u_r.r_time
  246. #define    u_rlong    u_r.r_long
  247. #define    u_rfaddr u_r.r_faddr
  248. #define    u_rfar   u_r.r_far
  249.  
  250. #define    IS386() ((u.u_cpu & XC_386) == XC_386)
  251. #define    ISCOFF() ((u.u_exdata.x_coff & XCB_COFF) == XCB_COFF)
  252. #define    ISCOFFEXEC() ((u.u_exdata.x_excoff & XCB_COFF) == XCB_COFF)
  253. #define IS_5_3() ((u.u_renv & XE_5_3 ) == XE_5_3 )
  254.  
  255. #ifdef M_I286 
  256. #  define     u_base         u_baseu.fu_far
  257. #  define     u_dirp         u_dirpu.fu_far
  258. #  define     u_stkbot    u_stkbotu.fu_far
  259. #  define     u_edata     u_edatau.fu_far
  260. #endif /* M_I286 */
  261.  
  262. #ifdef M_I8086
  263. #  define     u_base         u_baseu.fu_near
  264. #  define     u_dirp         u_dirpu.fu_near
  265. #  define     u_stkbot    u_stkbotu.fu_near
  266. #  define     u_edata     u_edatau.fu_near
  267. #endif /* M_I8086 */
  268.  
  269. #ifdef M_I386
  270. #  define     u_base         u_baseu
  271. #  define     u_dirp         u_dirpu
  272. #  define     u_stkbot    u_stkbotu
  273. #  define     u_edata     u_edatau
  274. #endif /* M_I386 */
  275.  
  276. #ifdef M_I386
  277. #define        pr_base        pr_baseu
  278. #define        pr_syspc    pr_syspcu
  279. #else
  280. #define        pr_base        pr_baseu.fu_far
  281. #define        pr_syspc    pr_syspcu.fu_far
  282. #endif
  283.  
  284. #define U_WRITE    0
  285. #define U_READ    1
  286.  
  287. /* segflg values */
  288. #define U_UD    0    /* user data */
  289. #define U_KD    1    /* kernel data */
  290. #define U_UI    2    /* user code */
  291.  
  292. /* ioflag values: Read/Write, User/Kernel, Ins/Data */
  293. #define    U_WUD    0
  294. #define    U_RUD    1
  295. #define    U_WKD    2
  296. #define    U_RKD    3
  297. #define    U_WUI    4
  298. #define    U_RUI    5
  299.  
  300. #define    EXCLOSE    01
  301.  
  302. /* values for u_nfsflgs (all bits reserved for NFS) */
  303. #define NFSNEGO   0x01        /* core negotiate wanted or not */
  304. #define NFSNOCASE 0x80        /* caseless compare needed (core server proc)*/
  305.  
  306. /* u_flags */
  307. #define UF_WSWAP    0x1    /* Words in longs swapped relative to kernel */
  308.  
  309. /* values for u_hugex flag */
  310. #define HX_SMALL  0x01        /* not currently bigger than swap area */
  311. #define HX_BIG      0x02        /* proc is bigger than swap area*/
  312.