|
|
1.1 root 1: /*
2: * File: syscoh.c
3: *
4: * Purpose: Functions for the COHERENT-specific system call
5: *
6: * $Log: syscoh.c,v $
7: * Revision 1.2 92/08/04 12:35:17 bin
8: * changed for ker 59
9: *
10: */
11:
12: /*
13: * ----------------------------------------------------------------------
14: * Includes.
15: */
16: #include <sys/coherent.h>
17: #include <sys/con.h>
18: #include <errno.h>
19:
20: /*
21: * ----------------------------------------------------------------------
22: * Definitions.
23: * Constants.
24: * Macros with argument lists.
25: * Typedefs.
26: * Enums.
27: */
28:
29: /*
30: * ----------------------------------------------------------------------
31: * Functions.
32: * Import Functions.
33: * Export Functions.
34: * Local Functions.
35: */
36: int ucohcall();
37:
38: static int devload();
39: static int setfpe();
40:
41: /*
42: * ----------------------------------------------------------------------
43: * Global Data.
44: * Import Variables.
45: * Export Variables.
46: * Local Variables.
47: */
48:
49: /*
50: * ----------------------------------------------------------------------
51: * Code.
52: */
53:
54: /*
55: * Only allow this if running as superuser.
56: *
57: * First argument is the call type.
58: *
59: * a1 = COH_PRINTF kernel printf
60: *
61: * a1 = COH_DEVLOAD call load() routine for device with major number a2
62: *
63: * a1 = COH_SETFPE a2=0, trap on FP; a2!=0, allow FP
64: */
65: ucohcall(a1,a2,a3,a4,a5,a6)
66: {
67: int ret = 0;
68:
69: if (!super()) {
70: SET_U_ERROR(EPERM, "cohcall, must be root");
71: goto ucc_done;
72: }
73:
74: switch(a1) {
75: case COH_PRINTF:
76: printf(a2);
77: break;
78: case COH_DEVLOAD:
79: ret = devload(a2);
80: break;
81: case COH_SETFPE:
82: ret = setfpe(a2);
83: break;
84: default:
85: SET_U_ERROR(EINVAL, "bad COH function");
86: }
87: ucc_done:
88: return ret;
89: }
90:
91: /*
92: * Initialize a device.
93: */
94: int
95: devload(maj_num)
96: int maj_num;
97: {
98: int ret = -1;
99: int mask = 1<<maj_num;
100:
101: if (dev_loaded & mask) {
102: SET_U_ERROR(EIO, "already loaded");
103: goto dldone;
104: }
105:
106: if (drvl[maj_num].d_conp == 0) {
107: SET_U_ERROR(EIO, "no driver");
108: goto dldone;
109: }
110:
111: if (drvl[maj_num].d_conp->c_load) {
112: (*drvl[maj_num].d_conp->c_load)();
113: dev_loaded |= mask;
114: ret = 0;
115: }
116: dldone:
117: return ret;
118: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.