|
|
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:
139: } TIMEOUT;
140:
141:
142:
1.1.1.2 root 143: #ifndef GENMAGIC
144:
1.1 root 145: extern TIMEOUT *tlist;
146:
1.1.1.2 root 147: #endif
148:
1.1 root 149:
150:
1.1.1.3 root 151: #define NUM_REGIONS 64 /* number of memory regions alloced at a time */
1.1 root 152:
153: #define MIN_HANDLE (-5) /* minimum handle number */
154:
155: #define MIN_OPEN 6 /* 0..MIN_OPEN-1 are reserved for system */
156:
157: #define MAX_OPEN 32 /* max. number of open files for a proc */
158:
159: #define SSTKSIZE 8000 /* size of supervisor stack (in bytes) */
160:
161: #define ISTKSIZE 2000 /* size of interrupt stack (in bytes) */
162:
163: #define STKSIZE (ISTKSIZE + SSTKSIZE)
164:
165:
166:
1.1.1.2 root 167: #define FRAME_MAGIC 0xf4a3e000UL
1.1 root 168:
169: /* magic for signal call stack */
170:
1.1.1.2 root 171: #define CTXT_MAGIC 0xabcdef98UL
1.1 root 172:
1.1.1.2 root 173: #define CTXT2_MAGIC 0x87654321UL
1.1 root 174:
175: /* magic #'s for contexts */
176:
177:
178:
179: #define PNAMSIZ 8 /* no. of characters in a process name */
180:
181:
182:
183: #define DOM_TOS 0 /* TOS process domain */
184:
185: #define DOM_MINT 1 /* MiNT process domain */
186:
187:
188:
189: typedef struct proc {
190:
191: long sysstack; /* must be first */
192:
193: CONTEXT ctxt[PROC_CTXTS]; /* must be second */
194:
195:
196:
1.1.1.3 root 197: /* this is stuff that the public can know about */
198:
1.1 root 199: long magic; /* validation for proc struct */
200:
201:
202:
203: BASEPAGE *base; /* process base page */
204:
205: short pid, ppid, pgrp;
206:
207: short ruid; /* process real user id */
208:
209: short rgid; /* process real group id */
210:
211: short euid, egid; /* effective user and group ids */
212:
213:
214:
215: ushort memflags; /* e.g. malloc from alternate ram */
216:
217: short pri; /* base process priority */
218:
219: short wait_q; /* current process queue */
220:
221:
222:
223: /* note: wait_cond should be unique for each kind of condition we might
224:
225: * want to wait for. Put a define below, or use an address in the
226:
227: * kernel as the wait condition to ensure uniqueness.
228:
229: */
230:
231: long wait_cond; /* condition we're waiting on */
232:
233: /* (also return code from wait) */
234:
235:
236:
237: #define WAIT_MB 0x3a140001L /* wait_cond for p_msg call */
238:
239: #define WAIT_SEMA 0x3a140003L /* wait_cond for p_semaphore */
240:
241:
242:
243: /* (all times are in milliseconds) */
244:
1.1.1.2 root 245: /* usrtime must always follow systime */
246:
1.1 root 247: ulong systime; /* time spent in kernel */
248:
249: ulong usrtime; /* time spent out of kernel */
250:
251: ulong chldstime; /* children's kernel time */
252:
253: ulong chldutime; /* children's user time */
254:
255:
256:
257: ulong maxmem; /* max. amount of memory to use */
258:
259: ulong maxdata; /* max. data region for process */
260:
261: ulong maxcore; /* max. core memory for process */
262:
263: ulong maxcpu; /* max. cpu time to use */
264:
265:
266:
267: short domain; /* process domain (TOS or UNIX) */
268:
269:
270:
271: short curpri; /* current process priority */
272:
273: #define MIN_NICE -20
274:
275: #define MAX_NICE 20
276:
277:
278:
279: /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
280:
281: * programs should *not* try to read this stuff via the U:\PROC dir.
282:
283: */
284:
285:
286:
1.1.1.4 root 287: /* jr: two fields to hold information passed to Pexec */
288:
289: char fname[PATH_MAX]; /* name of binary */
290:
291: char cmdlin[128]; /* original command line */
292:
293:
294:
1.1 root 295: char name[PNAMSIZ+1]; /* process name */
296:
297: TIMEOUT *alarmtim; /* alarm() event */
298:
299: short slices; /* number of time slices before this
300:
301: process gets to run again */
302:
303:
304:
305: short bconmap; /* Bconmap mapping */
306:
307: FILEPTR *midiout; /* MIDI output */
308:
309: FILEPTR *midiin; /* MIDI input */
310:
311: FILEPTR *prn; /* printer */
312:
313: FILEPTR *aux; /* auxiliary tty */
314:
315: FILEPTR *control; /* control tty */
316:
317: FILEPTR *handle[MAX_OPEN]; /* file handles */
318:
319:
320:
321: uchar fdflags[MAX_OPEN]; /* file descriptor flags */
322:
323:
324:
325: ushort num_reg; /* number of memory regions allocated */
326:
327: MEMREGION **mem; /* allocated memory regions */
328:
329: virtaddr *addr; /* addresses of regions */
330:
331:
332:
333: ulong sigpending; /* pending signals */
334:
335: ulong sigmask; /* signals that are masked */
336:
337: ulong sighandle[NSIG]; /* signal handlers */
338:
339: ushort sigflags[NSIG]; /* signal flags */
340:
341: ulong sigextra[NSIG]; /* additional signals to be masked
342:
343: on delivery */
344:
1.1.1.5 ! root 345: ulong nsigs; /* number of signals delivered */
! 346:
1.1 root 347: char *mb_ptr; /* p_msg buffer ptr */
348:
349: long mb_long1, mb_long2; /* p_msg storage */
350:
351: long mb_mbid; /* p_msg id being waited for */
352:
353: short mb_mode; /* p_msg mode being waiting in */
354:
355: short mb_writer; /* p_msg pid of writer of msg */
356:
357:
358:
359: short curdrv; /* current drive */
360:
1.1.1.5 ! root 361: ushort umask; /* file creation mask */
! 362:
1.1 root 363: fcookie root[NUM_DRIVES]; /* root directories */
364:
365: fcookie curdir[NUM_DRIVES]; /* current directory */
366:
367:
368:
369: long usrdata; /* user-supplied data */
370:
371:
372:
373: DTABUF *dta; /* current DTA */
374:
1.1.1.3 root 375: #define NUM_SEARCH 10 /* max. number of searches */
1.1 root 376:
377: DTABUF *srchdta[NUM_SEARCH]; /* for Fsfirst/next */
378:
379: DIR srchdir[NUM_SEARCH]; /* for Fsfirst/next */
380:
381: long srchtim[NUM_SEARCH]; /* for Fsfirst/next */
382:
383:
384:
1.1.1.3 root 385: DIR *searches; /* open directory searches */
386:
387:
388:
1.1 root 389: long txtsize; /* size of text region (for fork()) */
390:
391:
392:
1.1.1.2 root 393: long ARGS_ON_STACK (*criticerr) P_((long)); /* critical error handler */
1.1 root 394:
395: void *logbase; /* logical screen base */
396:
397:
398:
1.1.1.2 root 399: struct proc *ptracer; /* process which is tracing this one */
400:
401: short ptraceflags; /* flags for process tracing */
402:
1.1 root 403: short starttime; /* time and date when process */
404:
405: short startdate; /* was started */
406:
407:
408:
1.1.1.5 ! root 409: short in_dos; /* flag: 1 = process is executing a GEMDOS call */
! 410:
! 411:
! 412:
1.1.1.3 root 413: void *page_table; /* rounded page table pointer */
414:
415: void *pt_mem; /* original kmalloc'd block for above */
416:
417:
418:
419: ulong exception_pc; /* pc at time of bombs */
420:
421: ulong exception_ssp; /* ssp at time of bomb (e.g. bus error) */
422:
423: ulong exception_tbl; /* table in use at exception time */
424:
1.1.1.5 ! root 425: ulong exception_addr; /* access address from stack */
! 426:
1.1.1.3 root 427: ushort exception_mmusr; /* result from ptest insn */
428:
1.1.1.5 ! root 429:
! 430:
! 431: short fork_flag; /* flag: set to 1 if process has called Pfork() */
1.1.1.3 root 432:
433:
434:
1.1 root 435: struct proc *q_next; /* next process on queue */
436:
437: struct proc *gl_next; /* next process in system */
438:
439: char stack[STKSIZE+4]; /* stack for system calls */
440:
441: } PROC;
442:
443:
444:
445:
446:
447: /* different process queues */
448:
449:
450:
451: #define CURPROC_Q 0
452:
453: #define READY_Q 1
454:
455: #define WAIT_Q 2
456:
457: #define IO_Q 3
458:
459: #define ZOMBIE_Q 4
460:
461: #define TSR_Q 5
462:
463: #define STOP_Q 6
464:
465: #define SELECT_Q 7
466:
467:
468:
469: #define NUM_QUEUES 8
470:
471:
472:
1.1.1.2 root 473: #ifndef GENMAGIC
474:
1.1 root 475: extern PROC *proclist; /* list of all active processes */
476:
477: extern PROC *curproc; /* current process */
478:
479: extern PROC *rootproc; /* pid 0 -- MiNT itself */
480:
481: extern PROC *sys_q[NUM_QUEUES]; /* process queues */
482:
1.1.1.3 root 483:
484:
485: extern long page_table_size;
486:
487:
488:
1.1.1.2 root 489: #endif
490:
1.1 root 491:
492:
493: #endif /* _proc_h */
494:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.