home *** CD-ROM | disk | FTP | other *** search
/ Internet MPEG Audio Archive / IMAA.mdf / util / dos / l3v100n / rsx / source / process.h < prev    next >
C/C++ Source or Header  |  1994-01-19  |  6KB  |  180 lines

  1. /* Copyright    Rainer Schnitker 92,93 */
  2.  
  3. #ifndef _PROCESS_H
  4. #define _PROCESS_H
  5.  
  6. #ifndef _SIGNALS_H
  7. #include "SIGNALS.H"
  8. #endif
  9.  
  10. #define P_WAIT        0
  11. #define P_NOWAIT    1
  12. #define P_OVERLAY    2
  13. #define P_DEBUG     3
  14. #define P_SESSION    4
  15. #define P_DETACH    5
  16.  
  17.  
  18. /* process status */
  19. #define PS_EMPTY        0       /* free process */
  20. #define PS_ZOMBIE    1    /* process exit, wait for father wait() */
  21. #define PS_RUN        2    /* process running */
  22. #define PS_STOP     3    /* process stopped */
  23. #define PS_SYS_SPAWN    4    /* execute spawn (waiting for child) */
  24. #define PS_SYS_PTRACE    5    /* execute ptrace (waiting for child) */
  25. #define PS_SYS_FORK    6    /* execute fork (waiting for child) */
  26. #define PS_SYS_KILL    7    /* execute kill (waiting for child term) */
  27.  
  28. /* process flags */
  29. #define PF_DEBUG    1    /* process debugged by ptrace */
  30. #define PF_MATH_USED    2    /* 387 state saving */
  31. #define PF_TERMIO    4    /* termio used */
  32. #define PF_WAIT_WAIT    8       /* wait for father wait() */
  33. #define PF_COMPRESS     16      /* compress memory for djgpp-system() call */
  34. #define PF_SPAWN_ASYNC    32    /* async spawn */
  35. #define PF_EMX_FILE    64    /* emx program */
  36. #define PF_DJGPP_FILE    128    /* djgpp program */
  37. #define PF_EXTENDER    256    /* dos extender process */
  38.  
  39. struct fpu_reg {
  40.     char sign;
  41.     char tag;
  42.         short align_fill_gcc;
  43.     long exp;
  44.         unsigned long sigl;
  45.         unsigned long sigh;
  46. };
  47.  
  48. union i387_union {
  49.     struct i387_hard_struct {
  50.         long    cwd;
  51.         long    swd;
  52.         long    twd;
  53.         long    fip;
  54.         long    fcs;
  55.         long    foo;
  56.         long    fos;
  57.                 long    st_space[20];
  58.         } hard;
  59.     struct i387_soft_struct {
  60.         long    cwd;
  61.         long    swd;
  62.         long    twd;
  63.         long    fip;
  64.         long    fcs;
  65.         long    foo;
  66.         long    fos;
  67.         long    top;
  68.                 struct fpu_reg  regs[8];
  69.                 long res1 ;
  70.                 long res2 ;
  71.                 long res3 ;
  72.     } soft;
  73. };
  74.  
  75. typedef struct tagnewprocess
  76. {
  77.     struct tagnewprocess *pptr;     /* pointer to org. parent */
  78.     struct tagnewprocess *cptr;     /* ponter to last child */
  79.     unsigned short pid;                 /* process id */
  80.     unsigned short p_status;        /* process status */
  81.     unsigned short p_flags;        /* process flags */
  82.     unsigned short wait_return;     /* return value for father wait() */
  83.     unsigned short code32sel;        /* code selector */
  84.     unsigned short data32sel;        /* data selector */
  85.     unsigned long  membytes;        /* dpmi memory for text&data&heap */
  86.     unsigned long  memhandle;           /* dpmi handle for memory */
  87.     unsigned long  memaddress;        /* dpmi start address of memory-block */
  88.     unsigned long  text_start;        /* first text address */
  89.     unsigned long  text_end;        /* last text address */
  90.     unsigned long  data_start;        /* first data address */
  91.     unsigned long  data_end;        /* last data address */
  92.     unsigned long  stacksize;        /* stack size */
  93.     unsigned long  stack_top;        /* stack top address */
  94.     unsigned long  stack_down;        /* stack bottom address */
  95.     unsigned long  stackp32;            /* stackpointer at prg start */
  96.     unsigned long  init_brk;            /* first brk value */
  97.     unsigned long  brk_value;           /* current brk value */
  98.     unsigned long  entry;               /* prg entry */
  99.     unsigned long  pagefree;            /* free memory in current page */
  100.     unsigned long  sig_raised;        /* signals raise j/n  (bits) */
  101.     unsigned long  sig_ack;             /* signals en/disabled (bits) */
  102.     unsigned long  sigs[MAX_SIGNALS];   /* signal addresses */
  103.     unsigned long  time_tic;
  104.     unsigned long  time_alarm;
  105.     REG386         regs;
  106.     union i387_union npx;
  107. } NEWPROCESS ;
  108.  
  109. typedef struct
  110. {
  111.   unsigned long  arg_off;
  112.   unsigned long  env_off;
  113.   unsigned long  fname_off;
  114.   unsigned short arg_sel;
  115.   unsigned short env_sel;
  116.   unsigned short fname_sel;
  117.   unsigned short arg_count;
  118.   unsigned short arg_size;
  119.   unsigned short env_count;
  120.   unsigned short env_size;
  121.   unsigned short mode;
  122. } PROCESS_ENV ;
  123.  
  124. #define EAX (npz->regs.eax)
  125. #define EBX (npz->regs.ebx)
  126. #define ECX (npz->regs.ecx)
  127. #define EDX (npz->regs.edx)
  128. #define ESI (npz->regs.esi)
  129. #define EDI (npz->regs.edi)
  130. #define EBP (npz->regs.ebp)
  131. #define ESP (npz->regs.esp)
  132. #define EIP (npz->regs.eip)
  133. #define ERR (npz->regs.err)
  134. #define ESPORG (npz->regs.esporg)
  135. #define EFLAGS (npz->regs.eflags)
  136. #define FAULTNO ((WORD)(npz->regs.faultno))
  137. #define CS  ((WORD)(npz->regs.cs))
  138. #define DS  ((WORD)(npz->regs.ds))
  139. #define ES  ((WORD)(npz->regs.es))
  140. #define SS  ((WORD)(npz->regs.ss))
  141. #define FS  ((WORD)(npz->regs.fs))
  142. #define GS  ((WORD)(npz->regs.gs))
  143.  
  144. #define AX ((WORD)npz->regs.eax)
  145. #define BX ((WORD)npz->regs.ebx)
  146. #define CX ((WORD)npz->regs.ecx)
  147. #define DX ((WORD)npz->regs.edx)
  148. #define SI ((WORD)npz->regs.esi)
  149. #define DI ((WORD)npz->regs.edi)
  150. #define BP ((WORD)npz->regs.ebp)
  151. #define SP ((WORD)npz->regs.esp)
  152. #define IP ((WORD)npz->regs.eip)
  153. #define FLAGS ((WORD)npz->regs.eflags)
  154.  
  155. #define N_PRZ    4
  156. #define RSX_PROCESS     process[0]
  157. #define FIRST_PROCESS    process[1]
  158. #define LAST_PROCESS    process[N_PRZ]
  159. extern NEWPROCESS process[N_PRZ+1] ;
  160. extern NEWPROCESS *npz;                /* current running process */
  161. extern unsigned current_pid;
  162.  
  163. /* process.c functions */
  164. int    send_signal ( NEWPROCESS *, int );
  165. void    init_this_process ( void );
  166. int    verify_illegal ( NEWPROCESS *, DWORD, DWORD );
  167. NEWPROCESS * find_process ( unsigned );
  168. unsigned sys_wait ( unsigned * );
  169. void    free_process ( NEWPROCESS * );
  170. void    clean_processtable( NEWPROCESS * );
  171. int    switch_to_process (NEWPROCESS *);
  172. int    realmode_prg ( char *, char **, char ** );
  173. int    sys_fork ( void );
  174. int    exec32 ( unsigned int, char *, int, char **, int, char **);
  175. void    shut_down ( int );
  176. DWORD    getmem ( DWORD ,NEWPROCESS *);
  177. int    do_exit4c ( int );
  178.  
  179. #endif
  180.