|
|
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:
53: char fstate[216]; /* FPU internal state */
54:
55: char fregs[12*8]; /* registers fp0-fp7 */
56:
57: long fctrl[3]; /* FPCR/FPSR/FPIAR */
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:
75: short sfmt; /* stack frame format identifier */
76:
77: long iar; /* instruction address */
78:
79: short internal[4]; /* four words of internal info */
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:
121: extern TIMEOUT *tlist;
122:
123:
124:
125: #define NUM_REGIONS 64 /* max. number of memory regions for a proc */
126:
127: #define MIN_HANDLE (-5) /* minimum handle number */
128:
129: #define MIN_OPEN 6 /* 0..MIN_OPEN-1 are reserved for system */
130:
131: #define MAX_OPEN 32 /* max. number of open files for a proc */
132:
133: #define SSTKSIZE 8000 /* size of supervisor stack (in bytes) */
134:
135: #define ISTKSIZE 2000 /* size of interrupt stack (in bytes) */
136:
137: #define STKSIZE (ISTKSIZE + SSTKSIZE)
138:
139:
140:
141: #define FRAME_MAGIC 0xf4a3e000
142:
143: /* magic for signal call stack */
144:
145: #define CTXT_MAGIC 0xabcdef98
146:
147: #define CTXT2_MAGIC 0x87654321
148:
149: /* magic #'s for contexts */
150:
151:
152:
153: #define PNAMSIZ 8 /* no. of characters in a process name */
154:
155:
156:
157: #define DOM_TOS 0 /* TOS process domain */
158:
159: #define DOM_MINT 1 /* MiNT process domain */
160:
161:
162:
163: typedef struct proc {
164:
165: /* this is stuff that the public can know about */
166:
167: /* NOTE: some assembly code (in intr.s and contxt.s) makes
168:
169: * assumptions about the offsets of sysstack, ctxt[0], systime,
170:
171: * and usrtime.
172:
173: */
174:
175: long sysstack; /* must be first */
176:
177: CONTEXT ctxt[PROC_CTXTS]; /* must be second */
178:
179:
180:
181: long magic; /* validation for proc struct */
182:
183:
184:
185: BASEPAGE *base; /* process base page */
186:
187: short pid, ppid, pgrp;
188:
189: short ruid; /* process real user id */
190:
191: short rgid; /* process real group id */
192:
193: short euid, egid; /* effective user and group ids */
194:
195:
196:
197: ushort memflags; /* e.g. malloc from alternate ram */
198:
199: short pri; /* base process priority */
200:
201: short wait_q; /* current process queue */
202:
203:
204:
205: /* note: wait_cond should be unique for each kind of condition we might
206:
207: * want to wait for. Put a define below, or use an address in the
208:
209: * kernel as the wait condition to ensure uniqueness.
210:
211: */
212:
213: long wait_cond; /* condition we're waiting on */
214:
215: /* (also return code from wait) */
216:
217:
218:
219: #define WAIT_MB 0x3a140001L /* wait_cond for p_msg call */
220:
221: #define WAIT_SEMA 0x3a140003L /* wait_cond for p_semaphore */
222:
223:
224:
225: /* (all times are in milliseconds) */
226:
227: ulong systime; /* time spent in kernel */
228:
229: ulong usrtime; /* time spent out of kernel */
230:
231: ulong chldstime; /* children's kernel time */
232:
233: ulong chldutime; /* children's user time */
234:
235:
236:
237: ulong maxmem; /* max. amount of memory to use */
238:
239: ulong maxdata; /* max. data region for process */
240:
241: ulong maxcore; /* max. core memory for process */
242:
243: ulong maxcpu; /* max. cpu time to use */
244:
245:
246:
247: short domain; /* process domain (TOS or UNIX) */
248:
249:
250:
251: short curpri; /* current process priority */
252:
253: #define MIN_NICE -20
254:
255: #define MAX_NICE 20
256:
257:
258:
259: /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
260:
261: * programs should *not* try to read this stuff via the U:\PROC dir.
262:
263: */
264:
265:
266:
267: char name[PNAMSIZ+1]; /* process name */
268:
269: TIMEOUT *alarmtim; /* alarm() event */
270:
271: short slices; /* number of time slices before this
272:
273: process gets to run again */
274:
275:
276:
277: short bconmap; /* Bconmap mapping */
278:
279: FILEPTR *midiout; /* MIDI output */
280:
281: FILEPTR *midiin; /* MIDI input */
282:
283: FILEPTR *prn; /* printer */
284:
285: FILEPTR *aux; /* auxiliary tty */
286:
287: FILEPTR *control; /* control tty */
288:
289: FILEPTR *handle[MAX_OPEN]; /* file handles */
290:
291:
292:
293: uchar fdflags[MAX_OPEN]; /* file descriptor flags */
294:
295:
296:
297: ushort num_reg; /* number of memory regions allocated */
298:
299: MEMREGION **mem; /* allocated memory regions */
300:
301: virtaddr *addr; /* addresses of regions */
302:
303:
304:
305: ulong sigpending; /* pending signals */
306:
307: ulong sigmask; /* signals that are masked */
308:
309: ulong sighandle[NSIG]; /* signal handlers */
310:
311: ushort sigflags[NSIG]; /* signal flags */
312:
313: ulong sigextra[NSIG]; /* additional signals to be masked
314:
315: on delivery */
316:
317: char *mb_ptr; /* p_msg buffer ptr */
318:
319: long mb_long1, mb_long2; /* p_msg storage */
320:
321: long mb_mbid; /* p_msg id being waited for */
322:
323: short mb_mode; /* p_msg mode being waiting in */
324:
325: short mb_writer; /* p_msg pid of writer of msg */
326:
327:
328:
329: short curdrv; /* current drive */
330:
331: fcookie root[NUM_DRIVES]; /* root directories */
332:
333: fcookie curdir[NUM_DRIVES]; /* current directory */
334:
335:
336:
337: long usrdata; /* user-supplied data */
338:
339: ushort umask; /* file creation mask */
340:
341:
342:
343: DTABUF *dta; /* current DTA */
344:
345: #define NUM_SEARCH 6 /* max. number of searches */
346:
347: DTABUF *srchdta[NUM_SEARCH]; /* for Fsfirst/next */
348:
349: DIR srchdir[NUM_SEARCH]; /* for Fsfirst/next */
350:
351: long srchtim[NUM_SEARCH]; /* for Fsfirst/next */
352:
353:
354:
355: long txtsize; /* size of text region (for fork()) */
356:
357:
358:
359: long (*criticerr) P_((long)); /* critical error handler */
360:
361: void *logbase; /* logical screen base */
362:
363:
364:
365: short starttime; /* time and date when process */
366:
367: short startdate; /* was started */
368:
369:
370:
371: struct proc *q_next; /* next process on queue */
372:
373: struct proc *gl_next; /* next process in system */
374:
375: char stack[STKSIZE+4]; /* stack for system calls */
376:
377: } PROC;
378:
379:
380:
381:
382:
383: /* different process queues */
384:
385:
386:
387: #define CURPROC_Q 0
388:
389: #define READY_Q 1
390:
391: #define WAIT_Q 2
392:
393: #define IO_Q 3
394:
395: #define ZOMBIE_Q 4
396:
397: #define TSR_Q 5
398:
399: #define STOP_Q 6
400:
401: #define SELECT_Q 7
402:
403:
404:
405: #define NUM_QUEUES 8
406:
407:
408:
409: extern PROC *proclist; /* list of all active processes */
410:
411: extern PROC *curproc; /* current process */
412:
413: extern PROC *rootproc; /* pid 0 -- MiNT itself */
414:
415: extern PROC *sys_q[NUM_QUEUES]; /* process queues */
416:
417:
418:
419: #endif /* _proc_h */
420:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.