1: #ifndef PROC_H
   2: #define PROC_H
   3: 
   4: /* Here is the declaration of the process table.  It contains the process'
   5:  * registers, memory map, accounting, and message send/receive information.
   6:  * Many assembly code routines reference fields in it.  The offsets to these
   7:  * fields are defined in the assembler include file sconst.h.  When changing
   8:  * 'proc', be sure to change sconst.h to match.
   9:  */
  10: 
  11: struct proc {
  12:   struct stackframe_s p_reg;    /* process' registers saved in stack frame */
  13: 
  14: #if (CHIP == INTEL)
  15:   reg_t p_ldt_sel;              /* selector in gdt giving ldt base and limit*/
  16:   struct segdesc_s p_ldt[4];    /* local descriptors for code and data */
  17:                                 /* 4 is LDT_SIZE - avoid include protect.h */
  18: #endif /* (CHIP == INTEL) */
  19: 
  20: #if (CHIP == M68000)
  21:   reg_t p_splow;                /* lowest observed stack value */
  22:   int p_trap;                   /* trap type (only low byte) */
  23:   char *p_crp;                  /* mmu table pointer (really struct _rpr *) */
  24:   int p_nflips;                 /* statistics */
  25: #if defined(FPP)
  26:   struct fsave p_fsave;         /* FPP state frame and registers */
  27:   int align2;                   /* make the struct size a multiple of 4 */
  28: #endif
  29: #endif /* (CHIP == M68000) */
  30: 
  31:   reg_t *p_stguard;             /* stack guard word */
  32: 
  33:   int p_nr;                     /* number of this process (for fast access) */
  34: 
  35:   char p_int_blocked;           /* nonzero if int msg blocked by busy task */
  36:   char p_int_held;              /* nonzero if int msg held by busy syscall */
  37:   struct proc *p_nextheld;      /* next in chain of held-up int processes */
  38: 
  39:   int p_flags;                  /* SENDING, RECEIVING, etc. */
  40:   struct mem_map p_map[NR_SEGS];/* memory map */
  41:   pid_t p_pid;                  /* process id passed in from MM */
  42:   int p_priority;               /* task, server, or user process */
  43: 
  44:   clock_t user_time;            /* user time in ticks */
  45:   clock_t sys_time;             /* sys time in ticks */
  46:   clock_t child_utime;          /* cumulative user time of children */
  47:   clock_t child_stime;          /* cumulative sys time of children */
  48: 
  49:   timer_t *p_exptimers;         /* list of expired timers */
  50: 
  51:   struct proc *p_callerq;       /* head of list of procs wishing to send */
  52:   struct proc *p_sendlink;      /* link to next proc wishing to send */
  53:   message *p_messbuf;           /* pointer to message buffer */
  54:   int p_getfrom;                /* from whom does process want to receive? */
  55:   int p_sendto;
  56: 
  57:   struct proc *p_nextready;     /* pointer to next ready process */
  58:   sigset_t p_pending;           /* bit map for pending signals */
  59:   unsigned p_pendcount;         /* count of pending and unfinished signals */
  60: 
  61:   char p_name[16];              /* name of the process */
  62: };
  63: 
  64: /* Guard word for task stacks. */
  65: #define STACK_GUARD     ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
  66: 
  67: /* Bits for p_flags in proc[].  A process is runnable iff p_flags == 0. */
  68: #define NO_MAP          0x01    /* keeps unmapped forked child from running */
  69: #define SENDING         0x02    /* set when process blocked trying to send */
  70: #define RECEIVING       0x04    /* set when process blocked trying to recv */
  71: #define PENDING         0x08    /* set when inform() of signal pending */
  72: #define SIG_PENDING     0x10    /* keeps to-be-signalled proc from running */
  73: #define P_STOP          0x20    /* set when process is being traced */
  74: 
  75: /* Values for p_priority */
  76: #define PPRI_NONE       0       /* Slot is not in use */
  77: #define PPRI_TASK       1       /* Part of the kernel */
  78: #define PPRI_SERVER     2       /* System process outside the kernel */
  79: #define PPRI_USER       3       /* User process */
  80: #define PPRI_IDLE       4       /* Idle process */
  81: 
  82: /* Magic process table addresses. */
  83: #define BEG_PROC_ADDR (&proc[0])
  84: #define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
  85: #define END_TASK_ADDR (&proc[NR_TASKS])
  86: #define BEG_SERV_ADDR (&proc[NR_TASKS])
  87: #define BEG_USER_ADDR (&proc[NR_TASKS + LOW_USER])
  88: 
  89: #define NIL_PROC          ((struct proc *) 0)
  90: #define isidlehardware(n) ((n) == IDLE || (n) == HARDWARE)
  91: #define isokprocn(n)      ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
  92: #define isoksrc_dest(n)   (isokprocn(n) || (n) == ANY)
  93: #define isrxhardware(n)   ((n) == ANY || (n) == HARDWARE)
  94: #define issysentn(n)      ((n) == FS_PROC_NR || (n) == MM_PROC_NR)
  95: #define isemptyp(p)       ((p)->p_priority == PPRI_NONE)
  96: #define istaskp(p)        ((p)->p_priority == PPRI_TASK)
  97: #define isservp(p)        ((p)->p_priority == PPRI_SERVER)
  98: #define isuserp(p)        ((p)->p_priority == PPRI_USER)
  99: #define proc_addr(n)      (pproc_addr + NR_TASKS)[(n)]
 100: #define cproc_addr(n)     (&(proc + NR_TASKS)[(n)])
 101: #define proc_number(p)    ((p)->p_nr)
 102: #define proc_vir2phys(p, vir) \
 103:                           (((phys_bytes)(p)->p_map[D].mem_phys << CLICK_SHIFT) \
 104:                                                         + (vir_bytes) (vir))
 105: 
 106: EXTERN struct proc proc[NR_TASKS + NR_PROCS];   /* process table */
 107: EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
 108: /* ptrs to process table slots; fast because now a process entry can be found
 109:    by indexing the pproc_addr array, while accessing an element i requires
 110:    a multiplication with sizeof(struct proc) to determine the address */
 111: EXTERN struct proc *bill_ptr;   /* ptr to process to bill for clock ticks */
 112: EXTERN struct proc *rdy_head[NQ];       /* pointers to ready list headers */
 113: EXTERN struct proc *rdy_tail[NQ];       /* pointers to ready list tails */
 114: 
 115: #endif /* PROC_H */