|
|
1.1 root 1: /*
2:
1.1.1.3 ! root 3: Copyright 1990,1991,1992 Eric R. Smith.
! 4:
! 5: Copyright 1992 Atari Corporation.
! 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:
287: char name[PNAMSIZ+1]; /* process name */
288:
289: TIMEOUT *alarmtim; /* alarm() event */
290:
291: short slices; /* number of time slices before this
292:
293: process gets to run again */
294:
295:
296:
297: short bconmap; /* Bconmap mapping */
298:
299: FILEPTR *midiout; /* MIDI output */
300:
301: FILEPTR *midiin; /* MIDI input */
302:
303: FILEPTR *prn; /* printer */
304:
305: FILEPTR *aux; /* auxiliary tty */
306:
307: FILEPTR *control; /* control tty */
308:
309: FILEPTR *handle[MAX_OPEN]; /* file handles */
310:
311:
312:
313: uchar fdflags[MAX_OPEN]; /* file descriptor flags */
314:
315:
316:
317: ushort num_reg; /* number of memory regions allocated */
318:
319: MEMREGION **mem; /* allocated memory regions */
320:
321: virtaddr *addr; /* addresses of regions */
322:
323:
324:
325: ulong sigpending; /* pending signals */
326:
327: ulong sigmask; /* signals that are masked */
328:
329: ulong sighandle[NSIG]; /* signal handlers */
330:
331: ushort sigflags[NSIG]; /* signal flags */
332:
333: ulong sigextra[NSIG]; /* additional signals to be masked
334:
335: on delivery */
336:
337: char *mb_ptr; /* p_msg buffer ptr */
338:
339: long mb_long1, mb_long2; /* p_msg storage */
340:
341: long mb_mbid; /* p_msg id being waited for */
342:
343: short mb_mode; /* p_msg mode being waiting in */
344:
345: short mb_writer; /* p_msg pid of writer of msg */
346:
347:
348:
349: short curdrv; /* current drive */
350:
351: fcookie root[NUM_DRIVES]; /* root directories */
352:
353: fcookie curdir[NUM_DRIVES]; /* current directory */
354:
355:
356:
357: long usrdata; /* user-supplied data */
358:
359: ushort umask; /* file creation mask */
360:
361:
362:
363: DTABUF *dta; /* current DTA */
364:
1.1.1.3 ! root 365: #define NUM_SEARCH 10 /* max. number of searches */
1.1 root 366:
367: DTABUF *srchdta[NUM_SEARCH]; /* for Fsfirst/next */
368:
369: DIR srchdir[NUM_SEARCH]; /* for Fsfirst/next */
370:
371: long srchtim[NUM_SEARCH]; /* for Fsfirst/next */
372:
373:
374:
1.1.1.3 ! root 375: DIR *searches; /* open directory searches */
! 376:
! 377:
! 378:
1.1 root 379: long txtsize; /* size of text region (for fork()) */
380:
381:
382:
1.1.1.2 root 383: long ARGS_ON_STACK (*criticerr) P_((long)); /* critical error handler */
1.1 root 384:
385: void *logbase; /* logical screen base */
386:
387:
388:
1.1.1.2 root 389: struct proc *ptracer; /* process which is tracing this one */
390:
391: short ptraceflags; /* flags for process tracing */
392:
1.1 root 393: short starttime; /* time and date when process */
394:
395: short startdate; /* was started */
396:
397:
398:
1.1.1.3 ! root 399: void *page_table; /* rounded page table pointer */
! 400:
! 401: void *pt_mem; /* original kmalloc'd block for above */
! 402:
! 403:
! 404:
! 405: ulong exception_pc; /* pc at time of bombs */
! 406:
! 407: ulong exception_ssp; /* ssp at time of bomb (e.g. bus error) */
! 408:
! 409: ulong exception_tbl; /* table in use at exception time */
! 410:
! 411: ushort exception_mmusr; /* result from ptest insn */
! 412:
! 413: ulong exception_addr; /* access address from stack */
! 414:
! 415:
! 416:
1.1 root 417: struct proc *q_next; /* next process on queue */
418:
419: struct proc *gl_next; /* next process in system */
420:
421: char stack[STKSIZE+4]; /* stack for system calls */
422:
423: } PROC;
424:
425:
426:
427:
428:
429: /* different process queues */
430:
431:
432:
433: #define CURPROC_Q 0
434:
435: #define READY_Q 1
436:
437: #define WAIT_Q 2
438:
439: #define IO_Q 3
440:
441: #define ZOMBIE_Q 4
442:
443: #define TSR_Q 5
444:
445: #define STOP_Q 6
446:
447: #define SELECT_Q 7
448:
449:
450:
451: #define NUM_QUEUES 8
452:
453:
454:
1.1.1.2 root 455: #ifndef GENMAGIC
456:
1.1 root 457: extern PROC *proclist; /* list of all active processes */
458:
459: extern PROC *curproc; /* current process */
460:
461: extern PROC *rootproc; /* pid 0 -- MiNT itself */
462:
463: extern PROC *sys_q[NUM_QUEUES]; /* process queues */
464:
1.1.1.3 ! root 465:
! 466:
! 467: extern long page_table_size;
! 468:
! 469:
! 470:
1.1.1.2 root 471: #endif
472:
1.1 root 473:
474:
475: #endif /* _proc_h */
476:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.