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