IOInterrupt.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: public class IOInterrupt {
16:
17:
18: public static final boolean IOI_DEBUG_TRACE = false;
19:
20:
21: public static final int IOI_STATUS = 0x00e9c001;
22: public static final int IOI_VECTOR = 0x00e9c003;
23:
24:
25: public static final int IOI_SPC_SIGNAL = 0x4000;
26: public static final int IOI_FDC_SIGNAL = 0x0080;
27: public static final int IOI_FDD_SIGNAL = 0x0040;
28: public static final int IOI_PRN_SIGNAL = 0x0020;
29: public static final int IOI_HDC_SIGNAL = 0x0010;
30:
31:
32: public static final int IOI_SPC_REQUEST = 0x4000;
33: public static final int IOI_HDC_REQUEST = 0x0008;
34: public static final int IOI_FDC_REQUEST = 0x0004;
35: public static final int IOI_FDD_REQUEST = 0x0002;
36: public static final int IOI_PRN_REQUEST = 0x0001;
37:
38:
39: public static final int IOI_SPC_VECTOR = 0x6c;
40: public static final int IOI_FDC_VECTOR = 0x00;
41: public static final int IOI_FDD_VECTOR = 0x01;
42: public static final int IOI_HDC_VECTOR = 0x02;
43: public static final int IOI_PRN_VECTOR = 0x03;
44:
45:
46:
47:
48:
49:
50:
51:
52: public static int ioiEnable;
53:
54:
55:
56:
57:
58:
59:
60:
61: public static int ioiInService;
62:
63:
64:
65:
66:
67:
68:
69: public static int ioiRequest;
70:
71:
72:
73:
74:
75:
76:
77:
78: public static int ioiSignal;
79:
80:
81:
82: public static int ioiVector;
83:
84:
85: public static void ioiInit () {
86: }
87:
88:
89:
90: public static void ioiReset () {
91: if (IOI_DEBUG_TRACE) {
92: System.out.printf ("%08x ioiReset()\n", XEiJ.regPC0);
93: }
94: ioiEnable = IOI_SPC_REQUEST;
95: if (IOI_DEBUG_TRACE) {
96: System.out.printf ("\tioiEnable=0x%04x\n", ioiEnable);
97: }
98: ioiInService = 0;
99: if (IOI_DEBUG_TRACE) {
100: System.out.printf ("\tioiInService=0x%04x\n", ioiInService);
101: }
102: ioiRequest = 0;
103: if (IOI_DEBUG_TRACE) {
104: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
105: }
106: ioiSignal = PrinterPort.prnOnlineOn ? IOI_PRN_SIGNAL : 0;
107: if (IOI_DEBUG_TRACE) {
108: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
109: }
110: ioiVector = 0;
111: if (IOI_DEBUG_TRACE) {
112: System.out.printf ("\tioiVector=0x%04x\n", ioiVector);
113: }
114: }
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139: public static void ioiSpcFall () {
140: if ((ioiSignal & IOI_SPC_SIGNAL) != 0) {
141: if (IOI_DEBUG_TRACE) {
142: System.out.printf ("%08x ioiSpcFall()\n", XEiJ.regPC0);
143: }
144: ioiSignal &= ~IOI_SPC_SIGNAL;
145: if (IOI_DEBUG_TRACE) {
146: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
147: }
148: }
149: }
150:
151:
152:
153: public static void ioiFdcFall () {
154: if ((ioiSignal & IOI_FDC_SIGNAL) != 0) {
155: if (IOI_DEBUG_TRACE) {
156: System.out.printf ("%08x ioiFdcFall()\n", XEiJ.regPC0);
157: }
158: ioiSignal &= ~IOI_FDC_SIGNAL;
159: if (IOI_DEBUG_TRACE) {
160: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
161: }
162: }
163: }
164:
165:
166:
167: public static void ioiFddFall () {
168: if ((ioiSignal & IOI_FDD_SIGNAL) != 0) {
169: if (IOI_DEBUG_TRACE) {
170: System.out.printf ("%08x ioiFddFall()\n", XEiJ.regPC0);
171: }
172: ioiSignal &= ~IOI_FDD_SIGNAL;
173: if (IOI_DEBUG_TRACE) {
174: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
175: }
176: }
177: }
178:
179:
180:
181: public static void ioiHdcFall () {
182: if ((ioiSignal & IOI_HDC_SIGNAL) != 0) {
183: if (IOI_DEBUG_TRACE) {
184: System.out.printf ("%08x ioiHdcFall()\n", XEiJ.regPC0);
185: }
186: ioiSignal &= ~IOI_HDC_SIGNAL;
187: if (IOI_DEBUG_TRACE) {
188: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
189: }
190: }
191: }
192:
193:
194:
195: public static void ioiPrnFall () {
196: if ((ioiSignal & IOI_PRN_SIGNAL) != 0) {
197: if (IOI_DEBUG_TRACE) {
198: System.out.printf ("%08x ioiPrnFall()\n", XEiJ.regPC0);
199: }
200: ioiSignal &= ~IOI_PRN_SIGNAL;
201: if (IOI_DEBUG_TRACE) {
202: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
203: }
204: }
205: }
206:
207:
208:
209: public static void ioiSpcRise () {
210: if ((ioiSignal & IOI_SPC_SIGNAL) == 0) {
211: if (IOI_DEBUG_TRACE) {
212: System.out.printf ("%08x ioiSpcRise()\n", XEiJ.regPC0);
213: }
214: ioiSignal |= IOI_SPC_SIGNAL;
215: if (IOI_DEBUG_TRACE) {
216: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
217: }
218: if ((ioiEnable & IOI_SPC_REQUEST) != 0 &&
219: (ioiRequest & IOI_SPC_REQUEST) == 0) {
220: ioiRequest |= IOI_SPC_REQUEST;
221: if (IOI_DEBUG_TRACE) {
222: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
223: }
224: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
225: }
226: }
227: }
228:
229:
230:
231: public static void ioiFdcRise () {
232: if ((ioiSignal & IOI_FDC_SIGNAL) == 0) {
233: if (IOI_DEBUG_TRACE) {
234: System.out.printf ("%08x ioiFdcRise()\n", XEiJ.regPC0);
235: }
236: ioiSignal |= IOI_FDC_SIGNAL;
237: if (IOI_DEBUG_TRACE) {
238: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
239: }
240: if ((ioiEnable & IOI_FDC_REQUEST) != 0 &&
241: (ioiRequest & IOI_FDC_REQUEST) == 0) {
242: ioiRequest |= IOI_FDC_REQUEST;
243: if (IOI_DEBUG_TRACE) {
244: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
245: }
246: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
247: }
248: }
249: }
250:
251:
252:
253: public static void ioiFddRise () {
254: if ((ioiSignal & IOI_FDD_SIGNAL) == 0) {
255: if (IOI_DEBUG_TRACE) {
256: System.out.printf ("%08x ioiFddRise()\n", XEiJ.regPC0);
257: }
258: ioiSignal |= IOI_FDD_SIGNAL;
259: if (IOI_DEBUG_TRACE) {
260: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
261: }
262: if ((ioiEnable & IOI_FDD_REQUEST) != 0 &&
263: (ioiRequest & IOI_FDD_REQUEST) == 0) {
264: ioiRequest |= IOI_FDD_REQUEST;
265: if (IOI_DEBUG_TRACE) {
266: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
267: }
268: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
269: }
270: }
271: }
272:
273:
274:
275: public static void ioiHdcRise () {
276: if ((ioiSignal & IOI_HDC_SIGNAL) == 0) {
277: if (IOI_DEBUG_TRACE) {
278: System.out.printf ("%08x ioiHdcRise()\n", XEiJ.regPC0);
279: }
280: ioiSignal |= IOI_HDC_SIGNAL;
281: if (IOI_DEBUG_TRACE) {
282: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
283: }
284: if ((ioiEnable & IOI_HDC_REQUEST) != 0 &&
285: (ioiRequest & IOI_HDC_REQUEST) == 0) {
286: ioiRequest |= IOI_HDC_REQUEST;
287: if (IOI_DEBUG_TRACE) {
288: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
289: }
290: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
291: }
292: }
293: }
294:
295:
296:
297: public static void ioiPrnRise () {
298: if ((ioiSignal & IOI_PRN_SIGNAL) == 0) {
299: if (IOI_DEBUG_TRACE) {
300: System.out.printf ("%08x ioiPrnRise()\n", XEiJ.regPC0);
301: }
302: ioiSignal |= IOI_PRN_SIGNAL;
303: if (IOI_DEBUG_TRACE) {
304: System.out.printf ("\tioiSignal=0x%04x\n", ioiSignal);
305: }
306: if ((ioiEnable & IOI_PRN_REQUEST) != 0 &&
307: (ioiRequest & IOI_PRN_REQUEST) == 0) {
308: ioiRequest |= IOI_PRN_REQUEST;
309: if (IOI_DEBUG_TRACE) {
310: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
311: }
312: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
313: }
314: }
315: }
316:
317:
318:
319:
320:
321:
322: public static int ioiAcknowledge () {
323: int vector = 0;
324: if (IOI_DEBUG_TRACE) {
325: System.out.printf ("%08x ioiAcknowledge()\n", XEiJ.regPC0);
326: }
327: if ((ioiRequest & IOI_SPC_REQUEST) != 0) {
328: ioiInService = IOI_SPC_REQUEST;
329: vector = IOI_SPC_VECTOR;
330: } else if ((ioiRequest & IOI_FDC_REQUEST) != 0) {
331: ioiInService = IOI_FDC_REQUEST;
332: vector = ioiVector | IOI_FDC_VECTOR;
333: } else if ((ioiRequest & IOI_FDD_REQUEST) != 0) {
334: ioiInService = IOI_FDD_REQUEST;
335: vector = ioiVector | IOI_FDD_VECTOR;
336: } else if ((ioiRequest & IOI_HDC_REQUEST) != 0) {
337: ioiInService = IOI_HDC_REQUEST;
338: vector = ioiVector | IOI_HDC_VECTOR;
339: } else if ((ioiRequest & IOI_PRN_REQUEST) != 0) {
340: ioiInService = IOI_PRN_REQUEST;
341: vector = ioiVector | IOI_PRN_VECTOR;
342: }
343: if (IOI_DEBUG_TRACE) {
344: System.out.printf ("\tioiInService=0x%04x\n", ioiInService);
345: }
346: if (true) {
347: ioiRequest &= ~ioiInService;
348: if (IOI_DEBUG_TRACE) {
349: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
350: }
351: }
352: if (IOI_DEBUG_TRACE) {
353: System.out.printf ("\tvector=0x%02x\n", vector);
354: }
355: return vector;
356: }
357:
358:
359:
360:
361: public static void ioiDone () {
362: if (IOI_DEBUG_TRACE) {
363: System.out.printf ("%08x ioiDone()\n", XEiJ.regPC0);
364: }
365: if (false) {
366: ioiRequest &= ~ioiInService;
367: if (IOI_DEBUG_TRACE) {
368: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
369: }
370: }
371: ioiInService = 0;
372: if (IOI_DEBUG_TRACE) {
373: System.out.printf ("\tioiInService=0x%04x\n", ioiInService);
374: }
375: if (ioiRequest != 0) {
376: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
377: }
378: }
379:
380:
381:
382:
383: public static int ioiReadStatus () {
384: if (IOI_DEBUG_TRACE) {
385: System.out.printf ("%08x ioiReadStatus()\n", XEiJ.regPC0);
386: }
387: int d = (ioiSignal | ioiEnable) & 255;
388: if (IOI_DEBUG_TRACE) {
389: System.out.printf ("\tstatus=0x%02x\n", d);
390: }
391: return d;
392: }
393:
394:
395:
396:
397: public static int ioiReadVector () {
398: if (IOI_DEBUG_TRACE) {
399: System.out.printf ("%08x ioiReadVector()\n", XEiJ.regPC0);
400: }
401: int d = ioiVector;
402: if (IOI_DEBUG_TRACE) {
403: System.out.printf ("\tvector=0x%02x\n", d);
404: }
405: return d;
406: }
407:
408:
409:
410:
411: public static void ioiWriteEnable (int d) {
412: if (IOI_DEBUG_TRACE) {
413: System.out.printf ("%08x ioiWriteEnable(0x%02x)\n", XEiJ.regPC0, d & 255);
414: }
415: int enable = ioiEnable & ~0x0f | d & 0x0f;
416: int falled = ioiEnable & ~enable;
417: int raised = ~ioiEnable & enable;
418: ioiEnable = enable;
419: if (IOI_DEBUG_TRACE) {
420: System.out.printf ("\tioiEnable=0x%04x\n", ioiEnable);
421: }
422: int request = ioiRequest;
423: if ((falled & IOI_FDC_REQUEST) != 0) {
424: request &= ~IOI_FDC_REQUEST;
425: } else if ((raised & IOI_FDC_REQUEST) != 0 && (ioiSignal & IOI_FDC_SIGNAL) != 0) {
426: request |= IOI_FDC_REQUEST;
427: }
428: if ((falled & IOI_FDD_REQUEST) != 0) {
429: request &= ~IOI_FDD_REQUEST;
430: } else if ((raised & IOI_FDD_REQUEST) != 0 && (ioiSignal & IOI_FDD_SIGNAL) != 0) {
431: request |= IOI_FDD_REQUEST;
432: }
433: if ((falled & IOI_HDC_REQUEST) != 0) {
434: request &= ~IOI_HDC_REQUEST;
435: } else if ((raised & IOI_HDC_REQUEST) != 0 && (ioiSignal & IOI_HDC_SIGNAL) != 0) {
436: request |= IOI_HDC_REQUEST;
437: }
438: if ((falled & IOI_PRN_REQUEST) != 0) {
439: request &= ~IOI_PRN_REQUEST;
440: } else if ((raised & IOI_PRN_REQUEST) != 0 && (ioiSignal & IOI_PRN_SIGNAL) != 0) {
441: request |= IOI_PRN_REQUEST;
442: }
443: if (ioiRequest != request) {
444: ioiRequest = request;
445: if (IOI_DEBUG_TRACE) {
446: System.out.printf ("\tioiRequest=0x%04x\n", ioiRequest);
447: }
448: XEiJ.mpuIRR |= XEiJ.MPU_IOI_INTERRUPT_MASK;
449: }
450: }
451:
452:
453:
454:
455:
456: public static void ioiWriteVector (int d) {
457: if (IOI_DEBUG_TRACE) {
458: System.out.printf ("%08x ioiWriteVector(0x%02x)\n", XEiJ.regPC0, d & 255);
459: }
460: ioiVector = d & 0xfc;
461: if (IOI_DEBUG_TRACE) {
462: System.out.printf ("\tioiVector=0x%02x\n", ioiVector);
463: }
464: }
465:
466: }