Annotation of MiNT/src/proc.h, revision 1.1.1.2

1.1       root        1: /*
                      2: 
                      3: Copyright 1990,1991,1992 Eric R. Smith. All rights reserved.
                      4: 
                      5: */
                      6: 
                      7: 
                      8: 
                      9: /* proc.h: defines for various process related things */
                     10: 
                     11: #ifndef _proc_h
                     12: 
                     13: #define _proc_h
                     14: 
                     15: 
                     16: 
                     17: #include "file.h"
                     18: 
                     19: 
                     20: 
                     21: /* a process context consists, for now, of its registers */
                     22: 
                     23: 
                     24: 
                     25: typedef struct _context {
                     26: 
                     27:        long    regs[15];       /* registers d0-d7, a0-a6 */
                     28: 
                     29:        long    usp;            /* user stack pointer (a7) */
                     30: 
                     31:        short   sr;             /* status register */
                     32: 
                     33:        long    pc;             /* program counter */
                     34: 
                     35:        long    ssp;            /* supervisor stack pointer */
                     36: 
                     37:        long    term_vec;       /* GEMDOS terminate vector (0x102) */
                     38: 
                     39: /*
                     40: 
                     41:  * AGK: if running on a TT and the user is playing with the FPU then we
                     42: 
                     43:  * must save and restore the context. We should also consider this for
                     44: 
                     45:  * I/O based co-processors, although this may be difficult due to
                     46: 
                     47:  * possibility of a context switch in the middle of an I/O handshaking
                     48: 
                     49:  * exchange.
                     50: 
                     51:  */
                     52: 
1.1.1.2 ! root       53:        unsigned char   fstate[216];    /* FPU internal state */
1.1       root       54: 
1.1.1.2 ! root       55:        long    fregs[3*8];     /* registers fp0-fp7 */
1.1       root       56: 
1.1.1.2 ! root       57:        long    fctrl[3];       /* FPCR/FPSR/FPIAR */
1.1       root       58: 
                     59: /*
                     60: 
                     61:  * AGK: for long (time-wise) co-processor instructions (FMUL etc.), the
                     62: 
                     63:  * FPU returns NULL, come-again with interrupts allowed primitives. It
                     64: 
                     65:  * is highly likely that a context switch will occur in one of these if
                     66: 
                     67:  * running a mathematically intensive application, hence we must handle
                     68: 
                     69:  * the mid-instruction interrupt stack. We do this by saving the extra
                     70: 
                     71:  * 3 long words and the stack format word here.
                     72: 
                     73:  */
                     74: 
1.1.1.2 ! root       75:        unsigned short  sfmt;   /* stack frame format identifier */
1.1       root       76: 
1.1.1.2 ! root       77:        short   internal[42];   /* internal state -- see framesizes[] for size */
1.1       root       78: 
1.1.1.2 ! root       79:        char    ptrace;         /* trace exception is pending */
1.1       root       80: 
                     81: } CONTEXT;
                     82: 
                     83: 
                     84: 
                     85: #define PROC_CTXTS     2
                     86: 
                     87: #define SYSCALL                0       /* saved context from system call       */
                     88: 
                     89: #define CURRENT                1       /* current saved context                */
                     90: 
                     91: 
                     92: 
                     93: /*
                     94: 
                     95:  * Timeout events are stored in a list; the "when" field in the event
                     96: 
                     97:  * specifies the number of milliseconds *after* the last entry in the
                     98: 
                     99:  * list that the timeout should occur, so routines that manipulate
                    100: 
                    101:  * the list only need to check the first entry.
                    102: 
                    103:  */
                    104: 
                    105: 
                    106: 
                    107: typedef struct timeout {
                    108: 
                    109:        struct timeout *next;
                    110: 
                    111:        struct proc     *proc;
                    112: 
                    113:        long    when;
                    114: 
                    115:        void    (*func) P_((struct proc *)); /* function to call at timeout */
                    116: 
                    117: } TIMEOUT;
                    118: 
                    119: 
                    120: 
1.1.1.2 ! root      121: #ifndef GENMAGIC
        !           122: 
1.1       root      123: extern TIMEOUT *tlist;
                    124: 
1.1.1.2 ! root      125: #endif
        !           126: 
1.1       root      127: 
                    128: 
                    129: #define NUM_REGIONS    64      /* max. number of memory regions for a proc */
                    130: 
                    131: #define MIN_HANDLE     (-5)    /* minimum handle number                */
                    132: 
                    133: #define MIN_OPEN       6       /* 0..MIN_OPEN-1 are reserved for system */
                    134: 
                    135: #define MAX_OPEN       32      /* max. number of open files for a proc */
                    136: 
                    137: #define SSTKSIZE       8000    /* size of supervisor stack (in bytes)  */
                    138: 
                    139: #define ISTKSIZE       2000    /* size of interrupt stack (in bytes)   */
                    140: 
                    141: #define STKSIZE                (ISTKSIZE + SSTKSIZE)
                    142: 
                    143: 
                    144: 
1.1.1.2 ! root      145: #define FRAME_MAGIC    0xf4a3e000UL
1.1       root      146: 
                    147:                                /* magic for signal call stack */
                    148: 
1.1.1.2 ! root      149: #define CTXT_MAGIC     0xabcdef98UL
1.1       root      150: 
1.1.1.2 ! root      151: #define CTXT2_MAGIC    0x87654321UL
1.1       root      152: 
                    153:                                /* magic #'s for contexts */
                    154: 
                    155: 
                    156: 
                    157: #define PNAMSIZ                8       /* no. of characters in a process name */
                    158: 
                    159: 
                    160: 
                    161: #define DOM_TOS                0       /* TOS process domain */
                    162: 
                    163: #define DOM_MINT       1       /* MiNT process domain */
                    164: 
                    165: 
                    166: 
                    167: typedef struct proc {
                    168: 
                    169: /* this is stuff that the public can know about */
                    170: 
                    171:        long    sysstack;               /* must be first                */
                    172: 
                    173:        CONTEXT ctxt[PROC_CTXTS];       /* must be second               */
                    174: 
                    175: 
                    176: 
                    177:        long    magic;                  /* validation for proc struct   */
                    178: 
                    179: 
                    180: 
                    181:        BASEPAGE *base;                 /* process base page            */
                    182: 
                    183:        short   pid, ppid, pgrp;
                    184: 
                    185:        short   ruid;                   /* process real user id         */
                    186: 
                    187:        short   rgid;                   /* process real group id        */
                    188: 
                    189:        short   euid, egid;             /* effective user and group ids */
                    190: 
                    191: 
                    192: 
                    193:        ushort  memflags;               /* e.g. malloc from alternate ram */
                    194: 
                    195:        short   pri;                    /* base process priority        */
                    196: 
                    197:        short   wait_q;                 /* current process queue        */
                    198: 
                    199: 
                    200: 
                    201: /* note: wait_cond should be unique for each kind of condition we might
                    202: 
                    203:  * want to wait for. Put a define below, or use an address in the
                    204: 
                    205:  * kernel as the wait condition to ensure uniqueness.
                    206: 
                    207:  */
                    208: 
                    209:        long    wait_cond;              /* condition we're waiting on   */
                    210: 
                    211:                                        /* (also return code from wait) */
                    212: 
                    213: 
                    214: 
                    215: #define WAIT_MB                0x3a140001L     /* wait_cond for p_msg call     */
                    216: 
                    217: #define WAIT_SEMA      0x3a140003L     /* wait_cond for p_semaphore    */
                    218: 
                    219: 
                    220: 
                    221:        /* (all times are in milliseconds) */
                    222: 
1.1.1.2 ! root      223:        /* usrtime must always follow systime */
        !           224: 
1.1       root      225:        ulong   systime;                /* time spent in kernel         */
                    226: 
                    227:        ulong   usrtime;                /* time spent out of kernel     */
                    228: 
                    229:        ulong   chldstime;              /* children's kernel time       */
                    230: 
                    231:        ulong   chldutime;              /* children's user time         */
                    232: 
                    233: 
                    234: 
                    235:        ulong   maxmem;                 /* max. amount of memory to use */
                    236: 
                    237:        ulong   maxdata;                /* max. data region for process */
                    238: 
                    239:        ulong   maxcore;                /* max. core memory for process */
                    240: 
                    241:        ulong   maxcpu;                 /* max. cpu time to use         */
                    242: 
                    243: 
                    244: 
                    245:        short   domain;                 /* process domain (TOS or UNIX) */
                    246: 
                    247: 
                    248: 
                    249:        short   curpri;                 /* current process priority     */
                    250: 
                    251: #define MIN_NICE -20
                    252: 
                    253: #define MAX_NICE 20
                    254: 
                    255: 
                    256: 
                    257: /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
                    258: 
                    259:  * programs should *not* try to read this stuff via the U:\PROC dir.
                    260: 
                    261:  */
                    262: 
                    263: 
                    264: 
                    265:        char    name[PNAMSIZ+1];        /* process name                 */
                    266: 
                    267:        TIMEOUT *alarmtim;              /* alarm() event                */
                    268: 
                    269:        short   slices;                 /* number of time slices before this
                    270: 
                    271:                                           process gets to run again */
                    272: 
                    273: 
                    274: 
                    275:        short   bconmap;                /* Bconmap mapping              */
                    276: 
                    277:        FILEPTR *midiout;               /* MIDI output                  */
                    278: 
                    279:        FILEPTR *midiin;                /* MIDI input                   */
                    280: 
                    281:        FILEPTR *prn;                   /* printer                      */
                    282: 
                    283:        FILEPTR *aux;                   /* auxiliary tty                */
                    284: 
                    285:        FILEPTR *control;               /* control tty                  */
                    286: 
                    287:        FILEPTR *handle[MAX_OPEN];      /* file handles                 */
                    288: 
                    289: 
                    290: 
                    291:        uchar   fdflags[MAX_OPEN];      /* file descriptor flags        */
                    292: 
                    293: 
                    294: 
                    295:        ushort  num_reg;                /* number of memory regions allocated */
                    296: 
                    297:        MEMREGION **mem;                /* allocated memory regions     */
                    298: 
                    299:        virtaddr *addr;                 /* addresses of regions         */
                    300: 
                    301: 
                    302: 
                    303:        ulong   sigpending;             /* pending signals              */
                    304: 
                    305:        ulong   sigmask;                /* signals that are masked      */
                    306: 
                    307:        ulong   sighandle[NSIG];        /* signal handlers              */
                    308: 
                    309:        ushort  sigflags[NSIG];         /* signal flags                 */
                    310: 
                    311:        ulong   sigextra[NSIG];         /* additional signals to be masked
                    312: 
                    313:                                           on delivery  */
                    314: 
                    315:        char    *mb_ptr;                /* p_msg buffer ptr             */
                    316: 
                    317:        long    mb_long1, mb_long2;     /* p_msg storage                */
                    318: 
                    319:        long    mb_mbid;                /* p_msg id being waited for    */
                    320: 
                    321:        short   mb_mode;                /* p_msg mode being waiting in  */
                    322: 
                    323:        short   mb_writer;              /* p_msg pid of writer of msg   */
                    324: 
                    325: 
                    326: 
                    327:        short   curdrv;                 /* current drive                */
                    328: 
                    329:        fcookie root[NUM_DRIVES];       /* root directories             */
                    330: 
                    331:        fcookie curdir[NUM_DRIVES];     /* current directory            */
                    332: 
                    333: 
                    334: 
                    335:        long    usrdata;                /* user-supplied data           */
                    336: 
                    337:        ushort  umask;                  /* file creation mask           */
                    338: 
                    339: 
                    340: 
                    341:        DTABUF  *dta;                   /* current DTA                  */
                    342: 
                    343: #define NUM_SEARCH     6               /* max. number of searches      */
                    344: 
                    345:        DTABUF *srchdta[NUM_SEARCH];    /* for Fsfirst/next             */
                    346: 
                    347:        DIR     srchdir[NUM_SEARCH];    /* for Fsfirst/next             */
                    348: 
                    349:        long    srchtim[NUM_SEARCH];    /* for Fsfirst/next             */
                    350: 
                    351:        
                    352: 
                    353:        long    txtsize;                /* size of text region (for fork()) */
                    354: 
                    355: 
                    356: 
1.1.1.2 ! root      357:        long ARGS_ON_STACK (*criticerr) P_((long)); /* critical error handler   */
1.1       root      358: 
                    359:        void    *logbase;               /* logical screen base          */
                    360: 
                    361: 
                    362: 
1.1.1.2 ! root      363:        struct proc *ptracer;           /* process which is tracing this one */
        !           364: 
        !           365:        short   ptraceflags;            /* flags for process tracing */
        !           366: 
1.1       root      367:        short   starttime;              /* time and date when process   */
                    368: 
                    369:        short   startdate;              /* was started                  */
                    370: 
                    371: 
                    372: 
                    373:        struct  proc *q_next;           /* next process on queue        */
                    374: 
                    375:        struct  proc *gl_next;          /* next process in system       */
                    376: 
                    377:        char    stack[STKSIZE+4];       /* stack for system calls       */
                    378: 
                    379: } PROC;
                    380: 
                    381: 
                    382: 
                    383: 
                    384: 
                    385: /* different process queues */
                    386: 
                    387: 
                    388: 
                    389: #define CURPROC_Q      0
                    390: 
                    391: #define READY_Q                1
                    392: 
                    393: #define WAIT_Q         2
                    394: 
                    395: #define IO_Q           3
                    396: 
                    397: #define ZOMBIE_Q       4
                    398: 
                    399: #define TSR_Q          5
                    400: 
                    401: #define STOP_Q         6
                    402: 
                    403: #define SELECT_Q       7
                    404: 
                    405: 
                    406: 
                    407: #define NUM_QUEUES     8
                    408: 
                    409: 
                    410: 
1.1.1.2 ! root      411: #ifndef GENMAGIC
        !           412: 
1.1       root      413: extern PROC *proclist;                 /* list of all active processes */
                    414: 
                    415: extern PROC *curproc;                  /* current process              */
                    416: 
                    417: extern PROC *rootproc;                 /* pid 0 -- MiNT itself         */
                    418: 
                    419: extern PROC *sys_q[NUM_QUEUES];                /* process queues               */
                    420: 
1.1.1.2 ! root      421: #endif
        !           422: 
1.1       root      423: 
                    424: 
                    425: #endif /* _proc_h */
                    426: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.