|
|
1.1 root 1: /*
2: * var.c
3: *
4: * Coherent global variables.
5: */
6:
7: #include <kernel/timeout.h>
8: #include <kernel/systab.h>
9: #include <sys/coherent.h>
10: #include <sys/buf.h>
11: #include <sys/con.h>
12: #include <sys/inode.h>
13: #include <sys/mount.h>
14: #include <sys/proc.h>
15: #include <sys/ptrace.h>
16: #include <sys/seg.h>
17: #include <sys/mmu.h>
18: #include <sys/clist.h>
19:
20:
21: int debflag = 0; /* coherent.h */
22:
23: int batflag; /* coherent.h */
24: int dev_loaded; /* coherent.h */
25: int outflag; /* coherent.h */
26: int ttyflag; /* coherent.h */
27: unsigned utimer; /* coherent.h */
28: long lbolt; /* coherent.h */
29: TIM stimer; /* coherent.h */
30: unsigned asize; /* coherent.h */
31: paddr_t clistp; /* coherent.h */
32: MAKESR(blockp, _blockp); /* coherent.h */
33: MAKESR(allocp, _allocp); /* coherent.h */
34: heap_t * allkp; /* coherent.h */
35: #if USE_SLOT
36: int NSLOT = 64; /* coherent.h */
37: int slotsz = 64; /* coherent.h */
38: int * slotp; /* coherent.h */
39: #endif
40: unsigned total_mem; /* coherent.h */
41:
42: unsigned bufseqn; /* buf.h */
43: int bufneed; /* buf.h */
44: BUF swapbuf; /* buf.h */
45: BUF *bufl; /* buf.h */
46:
47: int cltwant; /* clist.h */
48: cmap_t cltfree; /* clist.h */
49:
50: INODE *inodep; /* inode.h */
51: INODE *acctip; /* inode.h */
52:
53: SYSMEM sysmem; /* mmu.h */
54: MOUNT *mountp; /* mount.h */
55:
56: #ifdef TRACER /* mwc_coherent.h */
57: unsigned t_errno = 0;
58: unsigned t_hal = 0;
59: unsigned t_piggy = 0;
60: unsigned t_vlad =0;
61: unsigned t_con =0;
62: unsigned t_msgq =0;
63: #endif /* TRACER */
64:
65: int ISTSIZE = 2048; /* sys/param.h */
66: int quantum; /* proc.h */
67: int disflag; /* proc.h */
68: int intflag; /* proc.h */
69: int cpid; /* proc.h */
70: #if QWAKEUP
71: int ntowake; /* proc.h */
72: #endif
73: GATE pnxgate; /* proc.h */
74: PROC procq; /* proc.h */
75: PROC *iprocp; /* proc.h */
76: PROC *eprocp; /* proc.h */
77: PROC *cprocp = &procq; /* proc.h */
78: PLINK linkq[NHPLINK]; /* proc.h */
79:
80: struct ptrace pts; /* ptrace.h */
81:
82: int sexflag; /* seg.h */
83: GATE seglink; /* seg.h */
84: #if MONITOR
85: int swmflag; /* seg.h */
86: #endif
87: SEG segswap; /* seg.h */
88: SEG segmq; /* seg.h */
89: SEG segdq; /* seg.h */
90: SEG segiom; /* seg.h */
91:
92: extern caddr_t aicodep;
93: extern caddr_t aicodes;
94:
95: char *icodep = (char *)&aicodep; /* coherent.h */
96: int icodes = (int)&aicodes; /* coherent.h */
97:
98: TIM * timq[256]; /* timeout.h */
99:
100: int vtactive;
101:
102: /*
103: * System call functions.
104: */
105: int unone();
106: int unull();
107: int uexit();
108: int ufork();
109: int uread();
110: int uwrite();
111: int uopen();
112: int uclose();
113: int uwait();
114: int uwait386();
115: int ucreat();
116: int ulink();
117: int uunlink();
118: int uexece();
119: int uchdir();
120: int umknod();
121: int uchmod();
122: int uchown();
123: char *ubrk();
124: int ustat();
125: long ulseek();
126: int ugetpid();
127: int umount();
128: int uumount();
129: int usetuid();
130: int ugetuid();
131: int ustime();
132: int uptrace();
133: int ualarm();
134: int ufstat();
135: int upause();
136: int uutime();
137: int ustty();
138: int ugtty();
139: int uaccess();
140: int unice();
141: int uftime();
142: int usync();
143: int ukill();
144: int udup();
145: int upipe();
146: int utimes();
147: int utime();
148: int uprofil();
149: int usetgid();
150: int ugetgid();
151: int (*usigsys())();
152: int usload();
153: int usuload();
154: int uacct();
155: int ulock();
156: int uioctl();
157: int ugetegid();
158: int uumask();
159: int uchroot();
160: int ufcntl();
161: int usetpgrp();
162: int uulimit();
163: int ufcntl();
164: int upoll();
165: int upgrp();
166: int usysi86();
167: int umsgsys();
168: int ushmsys();
169: int uutssys();
170: int usemsys();
171: int urmdir();
172: int umkdir();
173: int ugetdents();
174: int ustatfs();
175: int ufstatfs();
176: int uadmin();
177: /*
178: * Added by hal 91/10/10.
179: * These are undocumented Xenix/V7 compatibility calls.
180: */
181: int ustty();
182: int ugtty();
183:
184: /*
185: * NIGEL: These are all defined in "i386/sys1632.c" for compatibility with
186: * the i286 system calls. There were dealt with by an ugly system, now very
187: * much cleaned up.
188: */
189:
190: int obrk ();
191: int ostat ();
192: int ostime ();
193: int ofstat ();
194: int oftime ();
195: int coh286dup ();
196: int opipe ();
197: long oalarm2 ();
198: long otick ();
199: int osetpgrp ();
200: int ogetpgrp ();
201: int ogeteuid ();
202: int ogetegid ();
203: int okill ();
204: int osignal ();
205: long olseek ();
206: int ounique();
207:
208:
209: /*
210: * NIGEL: Use the following function to create static instances of system-
211: * call entry points properly. The extra cast on the function member is bad
212: * for error checking, but it's not as if there was any here before anyhow.
213: */
214:
215: #define SYSCALL(nargs,type,func) \
216: { nargs, __CONCAT (__SYSCALL_, type), (__sysfunc_t) func }
217:
218:
219: /*
220: * System call table.
221: */
222:
223: int ucohcall();
224: struct systab cohcall = SYSCALL (6, INT, ucohcall);
225:
226: struct systab sysitab [NMICALL] ={
227: SYSCALL (0, INT, unone), /* 0 = ??? */
228: SYSCALL (1, INT, uexit), /* 1 = exit */
229: SYSCALL (0, INT, ufork), /* 2 = fork */
230: SYSCALL (3, INT, uread), /* 3 = read */
231: SYSCALL (3, INT, uwrite), /* 4 = write */
232: SYSCALL (3, INT, uopen), /* 5 = open */
233: SYSCALL (1, INT, uclose), /* 6 = close */
234: SYSCALL (3, INT, uwait386), /* 7 = wait/waitpid */
235: SYSCALL (2, INT, ucreat), /* 8 = creat */
236: SYSCALL (2, INT, ulink), /* 9 = link */
237: SYSCALL (1, INT, uunlink), /* 10 = unlink */
238: SYSCALL (0, INT, unone), /* 11 = exec */
239: SYSCALL (1, INT, uchdir), /* 12 = chdir */
240: SYSCALL (0, INT, utime), /* 13 = utime */
241: SYSCALL (3, INT, umknod), /* 14 = mknod */
242: SYSCALL (2, INT, uchmod), /* 15 = chmod */
243: SYSCALL (3, INT, uchown), /* 16 = chown */
244: SYSCALL (1, INT, ubrk), /* 17 = break */
245: SYSCALL (2, INT, ustat), /* 18 = stat */
246: SYSCALL (3, LONG, ulseek), /* 19 = lseek */
247: SYSCALL (0, INT, ugetpid), /* 20 = getpid */
248: SYSCALL (3, INT, umount), /* 21 = mount */
249: SYSCALL (1, INT, uumount), /* 22 = umount */
250: SYSCALL (1, INT, usetuid), /* 23 = setuid */
251: SYSCALL (0, INT, ugetuid), /* 24 = getuid */
252: SYSCALL (1, INT, ustime), /* 25 = stime */
253: SYSCALL (4, INT, uptrace), /* 26 = ptrace */
254: SYSCALL (1, INT, ualarm), /* 27 = alarm */
255: SYSCALL (2, INT, ufstat), /* 28 = fstat */
256: SYSCALL (0, INT, upause), /* 29 = pause */
257: SYSCALL (2, INT, uutime), /* 30 = utime */
258: SYSCALL (2, INT, ustty), /* 31 = ustty */
259: SYSCALL (2, INT, ugtty), /* 32 = ugtty */
260: SYSCALL (2, INT, uaccess), /* 33 = access */
261: SYSCALL (1, INT, unice), /* 34 = nice */
262: SYSCALL (4, INT, ustatfs), /* 35 = statfs */
263: SYSCALL (0, INT, usync), /* 36 = sync */
264: SYSCALL (2, INT, ukill), /* 37 = kill */
265: SYSCALL (4, INT, ufstatfs), /* 38 = ufstatfs */
266: SYSCALL (1, INT, upgrp), /* 39 = pgrp */
267: SYSCALL (0, LONG, unone), /* 40 = ??? */
268: SYSCALL (1, INT, udup), /* 41 = dup */
269: SYSCALL (0, INT, upipe), /* 42 = pipe */
270: SYSCALL (1, INT, utimes), /* 43 = times */
271: SYSCALL (4, INT, uprofil), /* 44 = profil */
272: SYSCALL (1, INT, ulock), /* 45 = lock */
273: SYSCALL (1, INT, usetgid), /* 46 = setgid */
274: SYSCALL (0, INT, ugetgid), /* 47 = getgid */
275: SYSCALL (2, INT, usigsys), /* 48 = signal */
276: SYSCALL (6, LONG, umsgsys), /* 49 = msgsys */
277: SYSCALL (5, LONG, usysi86), /* 50 = sysi86 */
278: SYSCALL (1, INT, uacct), /* 51 = acct */
279: SYSCALL (4, INT, ushmsys), /* 52 = shmsys */
280: SYSCALL (5, INT, usemsys), /* 53 = semsys */
281: SYSCALL (3, INT, uioctl), /* 54 = ioctl */
282: SYSCALL (3, INT, uadmin), /* 55 = uadmin */
283: SYSCALL (0, INT, unone), /* 56 = ??? */
284: SYSCALL (3, INT, uutssys), /* 57 = utssys */
285: SYSCALL (0, INT, unone), /* 58 = ??? */
286: SYSCALL (3, INT, uexece), /* 59 = exec */
287: SYSCALL (1, INT, uumask), /* 60 = umask */
288: SYSCALL (1, INT, uchroot), /* 61 = chroot */
289: SYSCALL (3, INT, ufcntl), /* 62 = fcntl */
290: SYSCALL (2, INT, uulimit), /* 63 = ulimit */
291: SYSCALL (0, INT, unone), /* 64 = ??? (sload) */
292: SYSCALL (0, INT, unone), /* 65 = ??? (suload */
293: SYSCALL (0, INT, unone), /* 66 = ??? (fcntl) */
294: SYSCALL (0, INT, unone), /* 67 = ??? (poll) */
295: SYSCALL (0, INT, unone), /* 68 = ??? (msgctl) */
296: SYSCALL (0, INT, unone), /* 69 = ??? (msgget) */
297: SYSCALL (0, INT, unone), /* 70 = ??? (msgrcv) */
298: SYSCALL (0, INT, unone), /* 71 = ??? (msgsnd) */
299: SYSCALL (0, LONG, unone), /* 72 = ??? (alarm2) */
300: SYSCALL (0, LONG, unone), /* 73 = tick */
301: SYSCALL (0, INT, unone), /* 74 = ??? */
302: SYSCALL (0, INT, unone), /* 75 = ??? */
303: SYSCALL (0, INT, unone), /* 76 = ??? */
304: SYSCALL (0, INT, unone), /* 77 = ??? */
305: SYSCALL (0, INT, unone), /* 78 = ??? */
306: SYSCALL (1, INT, urmdir), /* 79 = rmdir */
307: SYSCALL (2, INT, umkdir), /* 80 = mkdir */
308: SYSCALL (3, INT, ugetdents), /* 81 = getdents */
309: SYSCALL (0, INT, unone), /* 82 = ??? */
310: SYSCALL (0, INT, unone), /* 83 = ??? */
311: SYSCALL (0, INT, unone), /* 84 = ??? */
312: SYSCALL (0, INT, unone), /* 85 = ??? */
313: SYSCALL (0, INT, unone), /* 86 = ??? */
314: SYSCALL (3, INT, upoll) /* 87 = poll */
315: };
316:
317:
318: /*
319: * Table for 286 system calls; the arguments of 286 system calls are zero-
320: * filled shorts.
321: *
322: * NIGEL: Since I built this table from the 386 table and a switch statement
323: * that dealt with the differences, we permit many calls here that are not
324: * part of the old 286 API. Of course, so did the code I based this on...
325: */
326:
327: struct systab sys286tab [NMICALL] ={
328: SYSCALL (0, INT, unone), /* 0 = ??? */
329: SYSCALL (1, INT, uexit), /* 1 = exit */
330: SYSCALL (0, INT, ufork), /* 2 = fork */
331: SYSCALL (3, INT, uread), /* 3 = read */
332: SYSCALL (3, INT, uwrite), /* 4 = write */
333: SYSCALL (3, INT, uopen), /* 5 = open */
334: SYSCALL (1, INT, uclose), /* 6 = close */
335: SYSCALL (1, INT, uwait), /* 7 = wait */
336: SYSCALL (2, INT, ucreat), /* 8 = creat */
337: SYSCALL (2, INT, ulink), /* 9 = link */
338: SYSCALL (1, INT, uunlink), /* 10 = unlink */
339: SYSCALL (3, INT, uexece), /* 11 = 286 exece */
340: SYSCALL (1, INT, uchdir), /* 12 = chdir */
341: SYSCALL (0, INT, utime), /* 13 = utime */
342: SYSCALL (3, INT, umknod), /* 14 = mknod */
343: SYSCALL (2, INT, uchmod), /* 15 = chmod */
344: SYSCALL (3, INT, uchown), /* 16 = chown */
345: SYSCALL (1, INT, obrk), /* 17 = 286 break */
346: SYSCALL (2, INT, ostat), /* 18 = 286 stat */
347: SYSCALL (4, LONG, olseek), /* 19 = 286 lseek */
348: SYSCALL (0, INT, ugetpid), /* 20 = getpid */
349: SYSCALL (3, INT, umount), /* 21 = mount */
350: SYSCALL (1, INT, uumount), /* 22 = umount */
351: SYSCALL (1, INT, usetuid), /* 23 = setuid */
352: SYSCALL (0, INT, ugetuid), /* 24 = getuid */
353: SYSCALL (1, INT, ostime), /* 25 = 286 stime */
354: SYSCALL (4, INT, uptrace), /* 26 = ptrace */
355: SYSCALL (1, INT, ualarm), /* 27 = alarm */
356: SYSCALL (2, INT, ofstat), /* 28 = 286 fstat */
357: SYSCALL (0, INT, upause), /* 29 = pause */
358: SYSCALL (2, INT, uutime), /* 30 = utime */
359: SYSCALL (2, INT, ustty), /* 31 = ustty */
360: SYSCALL (2, INT, ugtty), /* 32 = ugtty */
361: SYSCALL (2, INT, uaccess), /* 33 = access */
362: SYSCALL (1, INT, unice), /* 34 = nice */
363: SYSCALL (1, INT, oftime), /* 35 = 286 ftime */
364: SYSCALL (0, INT, usync), /* 36 = sync */
365: SYSCALL (2, INT, ukill), /* 37 = kill */
366: SYSCALL (4, INT, ufstatfs), /* 38 = ufstatfs */
367: SYSCALL (1, INT, upgrp), /* 39 = pgrp */
368: SYSCALL (0, INT, unone), /* 40 = ??? */
369: SYSCALL (2, INT, coh286dup), /* 41 = 286 dup */
370: SYSCALL (1, INT, opipe), /* 42 = 286 pipe */
371: SYSCALL (1, INT, utimes), /* 43 = times */
372: SYSCALL (4, INT, uprofil), /* 44 = profil */
373: SYSCALL (0, INT, ounique), /* 45 = unique */
374: SYSCALL (1, INT, usetgid), /* 46 = setgid */
375: SYSCALL (0, INT, ugetgid), /* 47 = getgid */
376: SYSCALL (2, INT, osignal), /* 48 = 286 signal */
377: SYSCALL (6, LONG, umsgsys), /* 49 = msgsys */
378: SYSCALL (5, LONG, usysi86), /* 50 = sysi86 */
379: SYSCALL (1, INT, uacct), /* 51 = acct */
380: SYSCALL (4, INT, ushmsys), /* 52 = shmsys */
381: SYSCALL (1, INT, ulock), /* 53 = 286 ulock */
382: SYSCALL (3, INT, uioctl), /* 54 = ioctl */
383: SYSCALL (3, INT, uadmin), /* 55 = uadmin */
384: SYSCALL (0, INT, ogetegid), /* 56 = 286 getegid */
385: SYSCALL (0, INT, ogeteuid), /* 57 = 286 geteuid */
386: SYSCALL (0, INT, unone), /* 58 = ??? */
387: SYSCALL (3, INT, uexece), /* 59 = exec */
388: SYSCALL (1, INT, uumask), /* 60 = umask */
389: SYSCALL (1, INT, uchroot), /* 61 = chroot */
390: SYSCALL (0, INT, osetpgrp), /* 62 = 286 setpgrp */
391: SYSCALL (0, INT, ogetpgrp), /* 63 = 286 getpgrp */
392: SYSCALL (0, INT, unone), /* 64 = ??? (sload) */
393: SYSCALL (0, INT, unone), /* 65 = ??? (suload */
394: SYSCALL (3, INT, ufcntl), /* 66 = 286 fcntl */
395: SYSCALL (0, INT, unone), /* 67 = ??? (poll) */
396: SYSCALL (0, INT, unone), /* 68 = ??? (msgctl) */
397: SYSCALL (0, INT, unone), /* 69 = ??? (msgget) */
398: SYSCALL (0, INT, unone), /* 70 = ??? (msgrcv) */
399: SYSCALL (0, INT, unone), /* 71 = ??? (msgsnd) */
400: SYSCALL (1, LONG, oalarm2), /* 72 = 286 alarm2 */
401: SYSCALL (0, LONG, otick), /* 73 = 286 tick */
402: SYSCALL (0, INT, unone), /* 74 = ??? */
403: SYSCALL (0, INT, unone), /* 75 = ??? */
404: SYSCALL (0, INT, unone), /* 76 = ??? */
405: SYSCALL (0, INT, unone), /* 77 = ??? */
406: SYSCALL (0, INT, unone), /* 78 = ??? */
407: SYSCALL (1, INT, urmdir), /* 79 = rmdir */
408: SYSCALL (2, INT, umkdir), /* 80 = mkdir */
409: SYSCALL (3, INT, ugetdents), /* 81 = getdents */
410: SYSCALL (0, INT, unone), /* 82 = ??? */
411: SYSCALL (0, INT, unone), /* 83 = ??? */
412: SYSCALL (0, INT, unone), /* 84 = ??? */
413: SYSCALL (0, INT, unone), /* 85 = ??? */
414: SYSCALL (0, INT, unone), /* 86 = ??? */
415: SYSCALL (3, INT, upoll) /* 87 = poll */
416: };
417:
418:
419: /*
420: * System Calls Numbers of the form 0x??28, where 0x?? >= 0x01
421: * Assists the dispatching mechanism in i386/trap.c
422: */
423:
424: int uchsize();
425: int unap();
426:
427: struct systab h28itab [H28CALL] = {
428: SYSCALL (0, INT, unone), /* 0x0128 = locking */
429: SYSCALL (0, INT, unone), /* 0x0228 = creatsem */
430: SYSCALL (0, INT, unone), /* 0x0328 = opensem */
431: SYSCALL (0, INT, unone), /* 0x0428 = sigsem */
432: SYSCALL (0, INT, unone), /* 0x0528 = waitsem */
433: SYSCALL (0, INT, unone), /* 0x0628 = nbwaitsem */
434: SYSCALL (0, INT, unone), /* 0x0728 = rdchk */
435: SYSCALL (0, INT, unone), /* 0x0828 = ??? */
436: SYSCALL (0, INT, unone), /* 0x0928 = ??? */
437: SYSCALL (2, INT, uchsize), /* 0x0A28 = chsize */
438: SYSCALL (0, INT, unone), /* 0x0B28 = ftime */
439: SYSCALL (1, INT, unap), /* 0x0C28 = nap */
440: SYSCALL (0, INT, unone), /* 0x0D28 = _sdget */
441: SYSCALL (0, INT, unone), /* 0x0E28 = sdfree */
442: SYSCALL (0, INT, unone), /* 0x0F28 = sdenter */
443: SYSCALL (0, INT, unone), /* 0x1028 = sdleave */
444: SYSCALL (0, INT, unone), /* 0x1128 = sdgetv */
445: SYSCALL (0, INT, unone), /* 0x1228 = sdwaitv */
446: SYSCALL (0, INT, unone), /* 0x1328 = ?? */
447: SYSCALL (0, INT, unone), /* 0x1428 = ?? */
448: SYSCALL (0, INT, unone), /* 0x1528 = ?? */
449: SYSCALL (0, INT, unone), /* 0x1628 = ?? */
450: SYSCALL (0, INT, unone), /* 0x1728 = ?? */
451: SYSCALL (0, INT, unone), /* 0x1828 = ?? */
452: SYSCALL (0, INT, unone), /* 0x1928 = ?? */
453: SYSCALL (0, INT, unone), /* 0x1A28 = ?? */
454: SYSCALL (0, INT, unone), /* 0x1B28 = ?? */
455: SYSCALL (0, INT, unone), /* 0x1C28 = ?? */
456: SYSCALL (0, INT, unone), /* 0x1D28 = ?? */
457: SYSCALL (0, INT, unone), /* 0x1E28 = ?? */
458: SYSCALL (0, INT, unone), /* 0x1F28 = ?? */
459: SYSCALL (0, INT, unone), /* 0x2028 = proctl */
460: SYSCALL (0, INT, unone), /* 0x2128 = execseg */
461: SYSCALL (0, INT, unone), /* 0x2228 = unexecseg */
462: SYSCALL (0, INT, unone), /* 0x2328 = ?? */
463: SYSCALL (0, INT, unone), /* 0x2428 = ?? */
464: SYSCALL (0, INT, unone), /* 0x2528 = ?? */
465: SYSCALL (0, INT, unone), /* 0x2628 = ?? */
466: SYSCALL (0, INT, unone), /* 0x2728 = sigaction */
467: SYSCALL (0, INT, unone), /* 0x2828 = sigprocmask */
468: SYSCALL (0, INT, unone), /* 0x2928 = sigpending */
469: SYSCALL (0, INT, unone), /* 0x2A28 = sigsuspend */
470: SYSCALL (0, INT, unone), /* 0x2B28 = getgroups */
471: SYSCALL (0, INT, unone), /* 0x2C28 = setgroups */
472: SYSCALL (0, INT, unone), /* 0x2D28 = sysconf */
473: SYSCALL (0, INT, unone), /* 0x2E28 = pathconf */
474: SYSCALL (0, INT, unone), /* 0x2F28 = fpathconf */
475: SYSCALL (0, INT, unone) /* 0x3028 = rename */
476: };
477:
478: extern CON nlcon;
479: int (*altclk)(); /* hook for polled devices */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.