1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19:
20:
21: #include "cmdsvc.h"
22: #include <sys/rominfo.h>
23:
24: 25: 26: 27: 28: 29: 30: 31:
32: typedef BOOL (*ESVCFUNC)( W fno, W p1, W p2, W p3, W *er );
33:
34: 35: 36: 37: 38:
39: #ifdef __GNUC__
40: #define WEAK __attribute__ ((weak))
41: #else
42: #define WEAK
43: #endif
44:
45: 46: 47:
48: IMPORT BOOL memDiskSVC( W fno, W p1, W p2, W p3, W *er ) WEAK;
49: IMPORT BOOL pciSVC( W fno, W p1, W p2, W p3, W *er ) WEAK;
50: IMPORT BOOL usbSVC( W fno, W p1, W p2, W p3, W *er ) WEAK;
51: IMPORT BOOL sysExtSVC( W fno, W p1, W p2, W p3, W *er ) WEAK;
52:
53: 54: 55:
56: LOCAL BOOL callSubModuleSVC( ESVCFUNC func, W fno, W p1, W p2, W p3, W *er )
57: {
58: if ( func == NULL ) return FALSE;
59:
60: return (*func)(fno, p1, p2, p3, er);
61: }
62:
63: #define CALL_ESVC(func) callSubModuleSVC(func, fno, p1, p2, p3, &er)
64:
65: 66: 67:
68: LOCAL W procExtSVC( W fno, W p1, W p2, W p3 )
69: {
70: W er;
71:
72: switch ( fno ) {
73: case TMEF_PORTBPS:
74: er = ConPortBps;
75: break;
76:
77: case TMEF_DIPSW:
78: er = getDipSw();
79: break;
80:
81: case TMEF_WROM:
82: er = writeFrom(p1, p2, p3, 0);
83: break;
84:
85: default:
86: CALL_ESVC(sysExtSVC) ||
87: CALL_ESVC(usbSVC) ||
88: CALL_ESVC(pciSVC) ||
89: CALL_ESVC(memDiskSVC) ||
90: (er = E_PAR);
91: }
92:
93: return er;
94: }
95:
96:
97:
98: 99: 100:
101: EXPORT W procSVC( W fno, W p1, W p2, W p3, W p4 )
102: {
103: W er = E_OK;
104: W n;
105:
106: switch ( fno ) {
107: case TM_MONITOR:
108: procCommand(NULL, 0);
109: break;
110:
111: case TM_GETCHAR:
112: er = getChar(p1);
113: break;
114:
115: case TM_PUTCHAR:
116: er = putChar(p1);
117: break;
118:
119: case TM_GETLINE:
120: er = getString(wrkBuf);
121: if ( er < 0 ) break;
122: n = er + 1;
123: if ( writeMem(p1, wrkBuf, n, 1) != n ) er = E_MACV;
124: break;
125:
126: case TM_PUTSTRING:
127: n = readMemStr(p1, wrkBuf, WRKBUF_SZ);
128: if ( n < 0 ) { er = E_MACV; break; }
129: er = putString(wrkBuf);
130: break;
131:
132: case TM_COMMAND:
133: n = readMemStr(p1, lineBuf, L_LINE);
134: if ( n < 0 ) { er = E_MACV; break; }
135: procCommand(( n == 0 )? NULL: lineBuf, 1);
136: break;
137:
138: case TM_READDISK:
139: case TM_WRITEDISK:
140: case TM_INFODISK:
141: 142: 143: 144:
145: n = readMemStr(p1, lineBuf, L_LINE);
146: if ( n < 0 ) { er = E_MACV; break; }
147:
148: if ( fno == TM_INFODISK ) {
149: er = infoDisk(lineBuf, (UW*)p2, (UW*)p3);
150: } else {
151: n = ( fno == TM_READDISK )? 0: 1;
152: er = rwDisk(lineBuf, p2, p3, (void*)p4, n);
153: }
154: break;
155:
156: case TM_EXIT:
157: sysExit(p1);
158: break;
159:
160: case TM_EXTSVC:
161:
162: er = procExtSVC(p1, p2, p3, p4);
163: break;
164:
165: default:
166: er = E_PAR;
167: }
168:
169: return er;
170: }