MC68901.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.lang.*;
16:
17: public class MC68901 {
18:
19: public static final boolean MFP_DELAYED_INTERRUPT = true;
20:
21:
22: public static final int MFP_GPIP_DATA = 0x00e88001;
23: public static final int MFP_AER = 0x00e88003;
24: public static final int MFP_DDR = 0x00e88005;
25: public static final int MFP_IERA = 0x00e88007;
26: public static final int MFP_IERB = 0x00e88009;
27: public static final int MFP_IPRA = 0x00e8800b;
28: public static final int MFP_IPRB = 0x00e8800d;
29: public static final int MFP_ISRA = 0x00e8800f;
30: public static final int MFP_ISRB = 0x00e88011;
31: public static final int MFP_IMRA = 0x00e88013;
32: public static final int MFP_IMRB = 0x00e88015;
33: public static final int MFP_VECTOR = 0x00e88017;
34: public static final int MFP_TACR = 0x00e88019;
35: public static final int MFP_TBCR = 0x00e8801b;
36: public static final int MFP_TCDCR = 0x00e8801d;
37:
38: public static final int MFP_TADR = 0x00e8801f;
39: public static final int MFP_TBDR = 0x00e88021;
40: public static final int MFP_TCDR = 0x00e88023;
41: public static final int MFP_TDDR = 0x00e88025;
42: public static final int MFP_SYNC_CHAR = 0x00e88027;
43: public static final int MFP_UCR = 0x00e88029;
44: public static final int MFP_RSR = 0x00e8802b;
45: public static final int MFP_TSR = 0x00e8802d;
46: public static final int MFP_UDR = 0x00e8802f;
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: public static final int MFP_GPIP_ALARM_LEVEL = 0;
65: public static final int MFP_GPIP_EXPWON_LEVEL = 1;
66: public static final int MFP_GPIP_POWER_LEVEL = 2;
67: public static final int MFP_GPIP_OPMIRQ_LEVEL = 3;
68: public static final int MFP_GPIP_VDISP_LEVEL = 4;
69: public static final int MFP_GPIP_RINT_LEVEL = 6;
70: public static final int MFP_GPIP_HSYNC_LEVEL = 7;
71:
72:
73: public static final int MFP_GPIP_ALARM_MASK = 1 << MFP_GPIP_ALARM_LEVEL;
74: public static final int MFP_GPIP_EXPWON_MASK = 1 << MFP_GPIP_EXPWON_LEVEL;
75: public static final int MFP_GPIP_POWER_MASK = 1 << MFP_GPIP_POWER_LEVEL;
76: public static final int MFP_GPIP_OPMIRQ_MASK = 1 << MFP_GPIP_OPMIRQ_LEVEL;
77: public static final int MFP_GPIP_VDISP_MASK = 1 << MFP_GPIP_VDISP_LEVEL;
78: public static final int MFP_GPIP_RINT_MASK = 1 << MFP_GPIP_RINT_LEVEL;
79: public static final int MFP_GPIP_HSYNC_MASK = 1 << MFP_GPIP_HSYNC_LEVEL;
80:
81:
82: public static final int MFP_ALARM_LEVEL = 0;
83: public static final int MFP_EXPWON_LEVEL = 1;
84: public static final int MFP_POWER_LEVEL = 2;
85: public static final int MFP_OPMIRQ_LEVEL = 3;
86: public static final int MFP_TIMER_D_LEVEL = 4;
87: public static final int MFP_TIMER_C_LEVEL = 5;
88: public static final int MFP_VDISP_LEVEL = 6;
89: public static final int MFP_TIMER_B_LEVEL = 8;
90: public static final int MFP_OUTPUT_ERROR_LEVEL = 9;
91: public static final int MFP_OUTPUT_EMPTY_LEVEL = 10;
92: public static final int MFP_INPUT_ERROR_LEVEL = 11;
93: public static final int MFP_INPUT_FULL_LEVEL = 12;
94: public static final int MFP_TIMER_A_LEVEL = 13;
95: public static final int MFP_RINT_LEVEL = 14;
96: public static final int MFP_HSYNC_LEVEL = 15;
97:
98:
99: public static final int MFP_ALARM_MASK = 1 << MFP_ALARM_LEVEL;
100: public static final int MFP_EXPWON_MASK = 1 << MFP_EXPWON_LEVEL;
101: public static final int MFP_POWER_MASK = 1 << MFP_POWER_LEVEL;
102: public static final int MFP_OPMIRQ_MASK = 1 << MFP_OPMIRQ_LEVEL;
103: public static final int MFP_TIMER_D_MASK = 1 << MFP_TIMER_D_LEVEL;
104: public static final int MFP_TIMER_C_MASK = 1 << MFP_TIMER_C_LEVEL;
105: public static final int MFP_VDISP_MASK = 1 << MFP_VDISP_LEVEL;
106: public static final int MFP_TIMER_B_MASK = 1 << MFP_TIMER_B_LEVEL;
107: public static final int MFP_OUTPUT_ERROR_MASK = 1 << MFP_OUTPUT_ERROR_LEVEL;
108: public static final int MFP_OUTPUT_EMPTY_MASK = 1 << MFP_OUTPUT_EMPTY_LEVEL;
109: public static final int MFP_INPUT_ERROR_MASK = 1 << MFP_INPUT_ERROR_LEVEL;
110: public static final int MFP_INPUT_FULL_MASK = 1 << MFP_INPUT_FULL_LEVEL;
111: public static final int MFP_TIMER_A_MASK = 1 << MFP_TIMER_A_LEVEL;
112: public static final int MFP_RINT_MASK = 1 << MFP_RINT_LEVEL;
113: public static final int MFP_HSYNC_MASK = 1 << MFP_HSYNC_LEVEL;
114:
115: public static final long MFP_OSC_FREQ = 4000000L;
116:
117:
118: public static final long MFP_DELTA[] = {
119: XEiJ.FAR_FUTURE,
120: 4 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
121: 10 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
122: 16 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
123: 50 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
124: 64 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
125: 100 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
126: 200 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
127: };
128:
129:
130: public static final int MFP_UDR_QUEUE_BITS = 4;
131: public static final int MFP_UDR_QUEUE_SIZE = 1 << MFP_UDR_QUEUE_BITS;
132: public static final int MFP_UDR_QUEUE_MASK = MFP_UDR_QUEUE_SIZE - 1;
133:
134:
135:
136:
137: public static int mfpGpipAlarm;
138: public static int mfpGpipExpwon;
139: public static int mfpGpipPower;
140: public static int mfpGpipOpmirq;
141: public static int mfpGpipVdisp;
142: public static int mfpGpipRint;
143: public static int mfpGpipHsync;
144:
145:
146:
147: public static int mfpAer;
148: public static int mfpIer;
149: public static int mfpImr;
150: public static int mfpVectorHigh;
151: public static int mfpTaPrescale;
152: public static int mfpTbPrescale;
153: public static int mfpTcPrescale;
154: public static int mfpTdPrescale;
155: public static boolean mfpTaEventcount;
156: public static boolean mfpTbEventcount;
157: public static int mfpTaInitial;
158: public static int mfpTbInitial;
159: public static int mfpTcInitial;
160: public static int mfpTdInitial;
161: public static int mfpTaCurrent;
162: public static int mfpTbCurrent;
163: public static int mfpTcCurrent;
164: public static int mfpTdCurrent;
165: public static boolean mfpTbKeyboardOn;
166:
167:
168:
169:
170: public static final int[] mfpInnerRequest = new int[16];
171: public static final int[] mfpInnerAcknowledged = new int[16];
172: public static final boolean[] mfpInnerInService = new boolean[16];
173: public static int mfpInnerLevel;
174:
175:
176: public static long mfpTaStart;
177: public static long mfpTbStart;
178: public static long mfpTcStart;
179: public static long mfpTdStart;
180: public static long mfpTaDelta;
181: public static long mfpTbDelta;
182: public static long mfpTcDelta;
183: public static long mfpTdDelta;
184: public static long mfpTaClock;
185: public static long mfpTbClock;
186: public static long mfpTcClock;
187: public static long mfpTdClock;
188:
189:
190:
191:
192:
193:
194: public static final int[] mfpUdrQueueArray = new int[MFP_UDR_QUEUE_SIZE];
195: public static int mfpUdrQueueRead;
196: public static int mfpUdrQueueWrite;
197:
198:
199:
200: public static void mfpInit () {
201:
202:
203:
204:
205: for (int i = 0; i < MFP_UDR_QUEUE_SIZE; i++) {
206: mfpUdrQueueArray[i] = 0;
207: }
208: mfpUdrQueueRead = 0;
209: mfpUdrQueueWrite = 0;
210: mfpReset ();
211: }
212:
213:
214: public static void mfpReset () {
215: mfpGpipAlarm = 0;
216: mfpGpipExpwon = MFP_GPIP_EXPWON_MASK;
217: mfpGpipPower = 0;
218: mfpGpipOpmirq = MFP_GPIP_OPMIRQ_MASK;
219: mfpGpipVdisp = 0;
220: mfpGpipRint = MFP_GPIP_RINT_MASK;
221: mfpGpipHsync = 0;
222: mfpAer = 0;
223: mfpIer = 0;
224: for (int i = 0; i < 16; i++) {
225: mfpInnerRequest[i] = 0;
226: mfpInnerAcknowledged[i] = 0;
227: mfpInnerInService[i] = false;
228: }
229: mfpImr = 0;
230: mfpVectorHigh = 0;
231: mfpTaPrescale = 0;
232: mfpTbPrescale = 0;
233: mfpTcPrescale = 0;
234: mfpTdPrescale = 0;
235: mfpTaEventcount = false;
236: mfpTbEventcount = false;
237: mfpTaInitial = 256;
238: mfpTbInitial = 256;
239: mfpTcInitial = 256;
240: mfpTdInitial = 256;
241: mfpTaCurrent = 0;
242: mfpTbCurrent = 0;
243: mfpTcCurrent = 0;
244: mfpTdCurrent = 0;
245: mfpTaStart = 0L;
246: mfpTbStart = 0L;
247: mfpTcStart = 0L;
248: mfpTdStart = 0L;
249: mfpTaClock = XEiJ.FAR_FUTURE;
250: mfpTbClock = XEiJ.FAR_FUTURE;
251: mfpTcClock = XEiJ.FAR_FUTURE;
252: mfpTdClock = XEiJ.FAR_FUTURE;
253: if (MFP_KBD_ON) {
254:
255: mfpKbdReadPointer = 0;
256: mfpKbdWritePointer = 0;
257: mfpKbdLastData = 0;
258: mfpTkClock = XEiJ.FAR_FUTURE;
259:
260: }
261: TickerQueue.tkqRemove (mfpTaTicker);
262: TickerQueue.tkqRemove (mfpTbTicker);
263: TickerQueue.tkqRemove (mfpTcTicker);
264: TickerQueue.tkqRemove (mfpTdTicker);
265: TickerQueue.tkqRemove (mfpTkTicker);
266: }
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285: public static int mfpAcknowledge () {
286: for (int i = 15; i >= 0; i--) {
287: if ((mfpImr & 1 << i) != 0) {
288: int request = mfpInnerRequest[i];
289: if (mfpInnerAcknowledged[i] != request) {
290: mfpInnerAcknowledged[i] = request;
291: mfpInnerInService[mfpInnerLevel = i] = true;
292: return mfpVectorHigh + i;
293: }
294: }
295: }
296: return 0;
297: }
298:
299:
300:
301:
302: public static void mfpDone () {
303: mfpInnerInService[mfpInnerLevel] = false;
304: for (int i = 15; i >= 0; i--) {
305: if ((mfpImr & 1 << i) != 0 && mfpInnerAcknowledged[i] != mfpInnerRequest[i]) {
306: if (MFP_DELAYED_INTERRUPT) {
307: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
308: } else {
309: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
310: }
311: return;
312: }
313: }
314: }
315:
316:
317:
318:
319: public static void mfpKeyboardInput (int scanCode) {
320: if (!mfpTbKeyboardOn) {
321: return;
322: }
323: scanCode &= 0xff;
324: int write = mfpUdrQueueWrite + 1 & MFP_UDR_QUEUE_MASK;
325: if (mfpUdrQueueRead != write) {
326: mfpUdrQueueWrite = write;
327: mfpUdrQueueArray[mfpUdrQueueWrite] = scanCode;
328: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
329: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
330: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
331: if (MFP_DELAYED_INTERRUPT) {
332: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
333: } else {
334: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
335: }
336: }
337: }
338: }
339: }
340:
341:
342:
343: public static final TickerQueue.Ticker mfpTaTicker = new TickerQueue.Ticker () {
344: @Override protected void tick () {
345: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
346: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
347: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
348: if (MFP_DELAYED_INTERRUPT) {
349: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
350: } else {
351: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
352: }
353: }
354: }
355: mfpTaClock += mfpTaDelta * mfpTaInitial;
356: TickerQueue.tkqAdd (mfpTaTicker, mfpTaClock);
357: }
358: };
359:
360:
361: public static final TickerQueue.Ticker mfpTbTicker = new TickerQueue.Ticker () {
362: @Override protected void tick () {
363: if ((mfpIer & MFP_TIMER_B_MASK) != 0) {
364: mfpInnerRequest[MFP_TIMER_B_LEVEL]++;
365: if ((mfpImr & MFP_TIMER_B_MASK) != 0) {
366: if (MFP_DELAYED_INTERRUPT) {
367: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
368: } else {
369: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
370: }
371: }
372: }
373: mfpTbClock += mfpTbDelta * mfpTbInitial;
374: TickerQueue.tkqAdd (mfpTbTicker, mfpTbClock);
375: }
376: };
377:
378:
379: public static final TickerQueue.Ticker mfpTcTicker = new TickerQueue.Ticker () {
380: @Override protected void tick () {
381: if ((mfpIer & MFP_TIMER_C_MASK) != 0) {
382: mfpInnerRequest[MFP_TIMER_C_LEVEL]++;
383: if ((mfpImr & MFP_TIMER_C_MASK) != 0) {
384: if (MFP_DELAYED_INTERRUPT) {
385: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
386: } else {
387: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
388: }
389: }
390: }
391: mfpTcClock += mfpTcDelta * mfpTcInitial;
392: TickerQueue.tkqAdd (mfpTcTicker, mfpTcClock);
393: }
394: };
395:
396:
397: public static final TickerQueue.Ticker mfpTdTicker = new TickerQueue.Ticker () {
398: @Override protected void tick () {
399: if ((mfpIer & MFP_TIMER_D_MASK) != 0) {
400: mfpInnerRequest[MFP_TIMER_D_LEVEL]++;
401: if ((mfpImr & MFP_TIMER_D_MASK) != 0) {
402: if (MFP_DELAYED_INTERRUPT) {
403: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
404: } else {
405: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
406: }
407: }
408: }
409: mfpTdClock += mfpTdDelta * mfpTdInitial;
410: TickerQueue.tkqAdd (mfpTdTicker, mfpTdClock);
411: }
412: };
413:
414:
415: public static final TickerQueue.Ticker mfpTkTicker = new TickerQueue.Ticker () {
416: @Override protected void tick () {
417: if (MFP_KBD_ON) {
418:
419:
420: long time = System.currentTimeMillis () - 10L;
421: if (time < mfpTkTime) {
422: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * (mfpTkTime - time);
423: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
424: } else {
425: if (mfpTbKeyboardOn) {
426: if (mfpKbdReadPointer != mfpKbdWritePointer) {
427: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
428: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
429: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
430:
431: if (MFP_DELAYED_INTERRUPT) {
432: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
433: } else {
434: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
435: }
436: }
437: }
438: }
439: }
440: mfpTkClock = XEiJ.FAR_FUTURE;
441: TickerQueue.tkqRemove (mfpTkTicker);
442:
443: }
444: }
445: }
446: };
447:
448:
449:
450:
451:
452: public static void mfpAlarmRise () {
453: if (mfpGpipAlarm == 0) {
454: mfpGpipAlarm = MFP_GPIP_ALARM_MASK;
455: if ((mfpAer & MFP_GPIP_ALARM_MASK) != 0 && (mfpIer & MFP_ALARM_MASK) != 0) {
456: mfpInnerRequest[MFP_ALARM_LEVEL]++;
457: if ((mfpImr & MFP_ALARM_MASK) != 0) {
458: if (MFP_DELAYED_INTERRUPT) {
459: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
460: } else {
461: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
462: }
463: }
464: }
465: }
466: }
467: public static void mfpAlarmFall () {
468: if (mfpGpipAlarm != 0) {
469: mfpGpipAlarm = 0;
470: if ((mfpAer & MFP_GPIP_ALARM_MASK) == 0 && (mfpIer & MFP_ALARM_MASK) != 0) {
471: mfpInnerRequest[MFP_ALARM_LEVEL]++;
472: if ((mfpImr & MFP_ALARM_MASK) != 0) {
473: if (MFP_DELAYED_INTERRUPT) {
474: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
475: } else {
476: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
477: }
478: }
479: }
480: }
481: }
482:
483:
484: public static void mfpExpwonRise () {
485: if (mfpGpipExpwon == 0) {
486: mfpGpipExpwon = MFP_GPIP_EXPWON_MASK;
487: if ((mfpAer & MFP_GPIP_EXPWON_MASK) != 0 && (mfpIer & MFP_EXPWON_MASK) != 0) {
488: mfpInnerRequest[MFP_EXPWON_LEVEL]++;
489: if ((mfpImr & MFP_EXPWON_MASK) != 0) {
490: if (MFP_DELAYED_INTERRUPT) {
491: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
492: } else {
493: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
494: }
495: }
496: }
497: }
498: }
499: public static void mfpExpwonFall () {
500: if (mfpGpipExpwon != 0) {
501: mfpGpipExpwon = 0;
502: if ((mfpAer & MFP_GPIP_EXPWON_MASK) == 0 && (mfpIer & MFP_EXPWON_MASK) != 0) {
503: mfpInnerRequest[MFP_EXPWON_LEVEL]++;
504: if ((mfpImr & MFP_EXPWON_MASK) != 0) {
505: if (MFP_DELAYED_INTERRUPT) {
506: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
507: } else {
508: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
509: }
510: }
511: }
512: }
513: }
514:
515:
516: public static void mfpPowerRise () {
517: if (mfpGpipPower == 0) {
518: mfpGpipPower = MFP_GPIP_POWER_MASK;
519: if ((mfpAer & MFP_GPIP_POWER_MASK) != 0 && (mfpIer & MFP_POWER_MASK) != 0) {
520: mfpInnerRequest[MFP_POWER_LEVEL]++;
521: if ((mfpImr & MFP_POWER_MASK) != 0) {
522: if (MFP_DELAYED_INTERRUPT) {
523: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
524: } else {
525: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
526: }
527: }
528: }
529: }
530: }
531: public static void mfpPowerFall () {
532: if (mfpGpipPower != 0) {
533: mfpGpipPower = 0;
534: if ((mfpAer & MFP_GPIP_POWER_MASK) == 0 && (mfpIer & MFP_POWER_MASK) != 0) {
535: mfpInnerRequest[MFP_POWER_LEVEL]++;
536: if ((mfpImr & MFP_POWER_MASK) != 0) {
537: if (MFP_DELAYED_INTERRUPT) {
538: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
539: } else {
540: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
541: }
542: }
543: }
544: }
545: }
546:
547:
548: public static void mfpOpmirqRise () {
549: if (mfpGpipOpmirq == 0) {
550: mfpGpipOpmirq = MFP_GPIP_OPMIRQ_MASK;
551: if ((mfpAer & MFP_GPIP_OPMIRQ_MASK) != 0 && (mfpIer & MFP_OPMIRQ_MASK) != 0) {
552: mfpInnerRequest[MFP_OPMIRQ_LEVEL]++;
553: if ((mfpImr & MFP_OPMIRQ_MASK) != 0) {
554: if (MFP_DELAYED_INTERRUPT) {
555: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
556: } else {
557: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
558: }
559: }
560: }
561: }
562: }
563: public static void mfpOpmirqFall () {
564: if (mfpGpipOpmirq != 0) {
565: mfpGpipOpmirq = 0;
566: if ((mfpAer & MFP_GPIP_OPMIRQ_MASK) == 0 && (mfpIer & MFP_OPMIRQ_MASK) != 0) {
567: mfpInnerRequest[MFP_OPMIRQ_LEVEL]++;
568: if ((mfpImr & MFP_OPMIRQ_MASK) != 0) {
569: if (MFP_DELAYED_INTERRUPT) {
570: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
571: } else {
572: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
573: }
574: }
575: }
576: }
577: }
578:
579:
580: public static void mfpVdispRise () {
581:
582: mfpGpipVdisp = MFP_GPIP_VDISP_MASK;
583: if ((mfpAer & MFP_GPIP_VDISP_MASK) != 0) {
584: if ((mfpIer & MFP_VDISP_MASK) != 0) {
585: mfpInnerRequest[MFP_VDISP_LEVEL]++;
586: if ((mfpImr & MFP_VDISP_MASK) != 0) {
587: if (MFP_DELAYED_INTERRUPT) {
588: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
589: } else {
590: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
591: }
592: }
593: }
594: if (mfpTaEventcount && --mfpTaCurrent <= 0) {
595: mfpTaCurrent = mfpTaInitial;
596: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
597: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
598: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
599: if (MFP_DELAYED_INTERRUPT) {
600: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
601: } else {
602: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
603: }
604: }
605: }
606: }
607: }
608:
609: }
610: public static void mfpVdispFall () {
611:
612: mfpGpipVdisp = 0;
613: if ((mfpAer & MFP_GPIP_VDISP_MASK) == 0) {
614: if ((mfpIer & MFP_VDISP_MASK) != 0) {
615: mfpInnerRequest[MFP_VDISP_LEVEL]++;
616: if ((mfpImr & MFP_VDISP_MASK) != 0) {
617: if (MFP_DELAYED_INTERRUPT) {
618: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
619: } else {
620: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
621: }
622: }
623: }
624: if (mfpTaEventcount && --mfpTaCurrent <= 0) {
625: mfpTaCurrent = mfpTaInitial;
626: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
627: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
628: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
629: if (MFP_DELAYED_INTERRUPT) {
630: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
631: } else {
632: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
633: }
634: }
635: }
636: }
637: }
638:
639: }
640:
641:
642: public static void mfpRintRise () {
643:
644: mfpGpipRint = MFP_GPIP_RINT_MASK;
645: if ((mfpAer & MFP_GPIP_RINT_MASK) != 0 && (mfpIer & MFP_RINT_MASK) != 0) {
646: mfpInnerRequest[MFP_RINT_LEVEL]++;
647: if ((mfpImr & MFP_RINT_MASK) != 0) {
648: if (MFP_DELAYED_INTERRUPT) {
649: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
650: } else {
651: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
652: }
653: }
654: }
655:
656: }
657: public static void mfpRintFall () {
658:
659: mfpGpipRint = 0;
660: if ((mfpAer & MFP_GPIP_RINT_MASK) == 0 && (mfpIer & MFP_RINT_MASK) != 0) {
661: mfpInnerRequest[MFP_RINT_LEVEL]++;
662: if ((mfpImr & MFP_RINT_MASK) != 0) {
663: if (MFP_DELAYED_INTERRUPT) {
664: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
665: } else {
666: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
667: }
668: }
669: }
670:
671: }
672:
673:
674: public static void mfpHsyncRise () {
675:
676: mfpGpipHsync = MFP_GPIP_HSYNC_MASK;
677: if ((mfpAer & MFP_GPIP_HSYNC_MASK) != 0 && (mfpIer & MFP_HSYNC_MASK) != 0) {
678: mfpInnerRequest[MFP_HSYNC_LEVEL]++;
679: if ((mfpImr & MFP_HSYNC_MASK) != 0) {
680: if (MFP_DELAYED_INTERRUPT) {
681: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
682: } else {
683: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
684: }
685: }
686: }
687:
688: }
689: public static void mfpHsyncFall () {
690:
691: mfpGpipHsync = 0;
692: if ((mfpAer & MFP_GPIP_HSYNC_MASK) == 0 && (mfpIer & MFP_HSYNC_MASK) != 0) {
693: mfpInnerRequest[MFP_HSYNC_LEVEL]++;
694: if ((mfpImr & MFP_HSYNC_MASK) != 0) {
695: if (MFP_DELAYED_INTERRUPT) {
696: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
697: } else {
698: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
699: }
700: }
701: }
702:
703: }
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761: public static final boolean MFP_KBD_ON = true;
762: public static final int MFP_KBD_LIMIT = 512;
763: public static final int[] mfpKbdBuffer = new int[MFP_KBD_LIMIT];
764: public static int mfpKbdReadPointer;
765: public static int mfpKbdWritePointer;
766: public static int mfpKbdLastData;
767: public static long mfpTkClock;
768: public static long mfpTkTime;
769:
770:
771:
772:
773:
774: public static void mfpKbdInput (int data, boolean repeat) {
775: if (!mfpTbKeyboardOn) {
776: return;
777: }
778: int w = mfpKbdWritePointer;
779: int w1 = w + 2 & MFP_KBD_LIMIT - 2;
780: if (w1 != mfpKbdReadPointer) {
781: mfpKbdBuffer[w] = data;
782: mfpKbdBuffer[w + 1] = repeat ? 1 : 0;
783: mfpKbdWritePointer = w1;
784: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
785: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
786: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
787:
788: if (MFP_DELAYED_INTERRUPT) {
789: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
790: } else {
791: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
792: }
793: }
794: }
795: }
796: }
797:
798:
799:
800: public static int mfpKbdReadData () {
801: int r = mfpKbdReadPointer;
802: int w = mfpKbdWritePointer;
803: if (r != w) {
804: int r1 = r + 2 & MFP_KBD_LIMIT - 2;
805: int s = mfpKbdBuffer[r + 1];
806: if (r1 != w && s < 0) {
807: mfpKbdReadPointer = r = r1;
808: r1 = r + 2 & MFP_KBD_LIMIT - 2;
809: s = mfpKbdBuffer[r + 1];
810: }
811: mfpKbdLastData = mfpKbdBuffer[r];
812: if (r1 != w) {
813: mfpKbdReadPointer = r1;
814: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
815: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
816: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
817:
818: if (MFP_DELAYED_INTERRUPT) {
819: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
820: } else {
821: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
822: }
823: }
824: }
825: } else if (s == 0) {
826: mfpKbdReadPointer = r1;
827: } else if (s > 0) {
828: mfpKbdBuffer[r + 1] = -1;
829: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
830: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * Keyboard.kbdRepeatDelay;
831: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
832: mfpTkTime = System.currentTimeMillis () + Keyboard.kbdRepeatDelay;
833: }
834: } else {
835: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
836: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * Keyboard.kbdRepeatInterval;
837: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
838: mfpTkTime = System.currentTimeMillis () + Keyboard.kbdRepeatInterval;
839: }
840: }
841: }
842: return mfpKbdLastData;
843: }
844:
845: }
846:
847:
848: