HD63450.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 HD63450 {
18:
19:
20:
21: public static final int DMA_DEBUG_TRACE = 0b0000;
22:
23: public static final boolean DMA_ALERT_HIMEM = true;
24:
25:
26:
27:
28:
29:
30: public static final int DMA_CSR = 0x00;
31: public static final int DMA_COC = 0b10000000;
32: public static final int DMA_BLC = 0b01000000;
33: public static final int DMA_NDT = 0b00100000;
34: public static final int DMA_ERR = 0b00010000;
35: public static final int DMA_ACT = 0b00001000;
36: public static final int DMA_DIT = 0b00000100;
37: public static final int DMA_PCT = 0b00000010;
38: public static final int DMA_PCS = 0b00000001;
39:
40:
41: public static final int DMA_CER = 0x01;
42: public static final int DMA_ERROR_CODE = 0b00011111;
43: public static final int DMA_NO_ERROR = 0b00000000;
44: public static final int DMA_CONFIGURATION_ERROR = 0b00000001;
45: public static final int DMA_TIMING_ERROR = 0b00000010;
46: public static final int DMA_MEMORY_ADDRESS_ERROR = 0b00000101;
47: public static final int DMA_DEVICE_ADDRESS_ERROR = 0b00000110;
48: public static final int DMA_BASE_ADDRESS_ERROR = 0b00000111;
49: public static final int DMA_MEMORY_BUS_ERROR = 0b00001001;
50: public static final int DMA_DEVICE_BUS_ERROR = 0b00001010;
51: public static final int DMA_BASE_BUS_ERROR = 0b00001011;
52: public static final int DMA_MEMORY_COUNT_ERROR = 0b00001101;
53: public static final int DMA_BASE_COUNT_ERROR = 0b00001111;
54: public static final int DMA_EXTERNAL_ABORT = 0b00010000;
55: public static final int DMA_SOFTWARE_ABORT = 0b00010001;
56:
57:
58: public static final int DMA_DCR = 0x04;
59: public static final int DMA_XRM = 0b11000000;
60: public static final int DMA_BURST_TRANSFER = 0b00000000;
61: public static final int DMA_NO_HOLD_CYCLE_STEAL = 0b10000000;
62: public static final int DMA_HOLD_CYCLE_STEAL = 0b11000000;
63: public static final int DMA_DTYP = 0b00110000;
64: public static final int DMA_HD68000_COMPATIBLE = 0b00000000;
65: public static final int DMA_HD6800_COMPATIBLE = 0b00010000;
66: public static final int DMA_ACK_DEVICE = 0b00100000;
67: public static final int DMA_ACK_READY_DEVICE = 0b00110000;
68: public static final int DMA_DPS = 0b00001000;
69: public static final int DMA_PORT_8_BIT = 0b00000000;
70: public static final int DMA_PORT_16_BIT = 0b00001000;
71: public static final int DMA_PCL = 0b00000011;
72: public static final int DMA_STATUS_INPUT = 0b00000000;
73: public static final int DMA_STATUS_INPUT_INTERRUPT = 0b00000001;
74: public static final int DMA_EIGHTH_START_PULSE = 0b00000010;
75: public static final int DMA_ABORT_INPUT = 0b00000011;
76:
77:
78: public static final int DMA_OCR = 0x05;
79: public static final int DMA_DIR = 0b10000000;
80: public static final int DMA_MEMORY_TO_DEVICE = 0b00000000;
81: public static final int DMA_DEVICE_TO_MEMORY = 0b10000000;
82: public static final int DMA_BTD = 0b01000000;
83: public static final int DMA_SIZE = 0b00110000;
84: public static final int DMA_BYTE_SIZE = 0b00000000;
85: public static final int DMA_WORD_SIZE = 0b00010000;
86: public static final int DMA_LONG_WORD_SIZE = 0b00100000;
87: public static final int DMA_UNPACKED_8_BIT = 0b00110000;
88: public static final int DMA_CHAIN = 0b00001100;
89: public static final int DMA_NO_CHAINING = 0b00000000;
90: public static final int DMA_ARRAY_CHAINING = 0b00001000;
91: public static final int DMA_LINK_ARRAY_CHAINING = 0b00001100;
92: public static final int DMA_REQG = 0b00000011;
93: public static final int DMA_AUTO_REQUEST = 0b00000000;
94: public static final int DMA_AUTO_REQUEST_MAX = 0b00000001;
95: public static final int DMA_EXTERNAL_REQUEST = 0b00000010;
96: public static final int DMA_DUAL_REQUEST = 0b00000011;
97:
98:
99: public static final int DMA_SCR = 0x06;
100: public static final int DMA_MAC = 0b00001100;
101: public static final int DMA_STATIC_MAR = 0b00000000;
102: public static final int DMA_INC_MAR = 0b00000100;
103: public static final int DMA_DEC_MAR = 0b00001000;
104: public static final int DMA_DAC = 0b00000011;
105: public static final int DMA_STATIC_DAR = 0b00000000;
106: public static final int DMA_INC_DAR = 0b00000001;
107: public static final int DMA_DEC_DAR = 0b00000010;
108:
109:
110: public static final int DMA_CCR = 0x07;
111: public static final int DMA_STR = 0b10000000;
112: public static final int DMA_CNT = 0b01000000;
113: public static final int DMA_HLT = 0b00100000;
114: public static final int DMA_SAB = 0b00010000;
115: public static final int DMA_ITE = 0b00001000;
116:
117:
118: public static final int DMA_MTC = 0x0a;
119: public static final int DMA_MAR = 0x0c;
120: public static final int DMA_DAR = 0x14;
121: public static final int DMA_BTC = 0x1a;
122: public static final int DMA_BAR = 0x1c;
123:
124:
125: public static final int DMA_NIV = 0x25;
126: public static final int DMA_EIV = 0x27;
127:
128:
129: public static final int DMA_MFC = 0x29;
130: public static final int DMA_FC2 = 0b00000100;
131: public static final int DMA_FC1 = 0b00000010;
132: public static final int DMA_FC0 = 0b00000001;
133:
134:
135: public static final int DMA_CPR = 0x2d;
136: public static final int DMA_CP = 0b00000011;
137:
138:
139: public static final int DMA_DFC = 0x31;
140: public static final int DMA_BFC = 0x39;
141:
142:
143: public static final int DMA_GCR = 0xff;
144: public static final int DMA_BT = 0b00001100;
145: public static final int DMA_BR = 0b00000011;
146:
147:
148:
149: public static final int[] dmaPCS = new int[4];
150: public static final int[] dmaPCT = new int[4];
151: public static final int[] dmaDIT = new int[4];
152: public static final int[] dmaACT = new int[4];
153: public static final int[] dmaERR = new int[4];
154: public static final int[] dmaNDT = new int[4];
155: public static final int[] dmaBLC = new int[4];
156: public static final int[] dmaCOC = new int[4];
157: public static final int[] dmaErrorCode = new int[4];
158: public static final int[] dmaPCL = new int[4];
159: public static final int[] dmaDPS = new int[4];
160: public static final int[] dmaDTYP = new int[4];
161: public static final int[] dmaXRM = new int[4];
162: public static final int[] dmaREQG = new int[4];
163: public static final int[] dmaCHAIN = new int[4];
164: public static final int[] dmaSIZE = new int[4];
165: public static final int[] dmaBTD = new int[4];
166: public static final int[] dmaDIR = new int[4];
167: public static final int[] dmaDAC = new int[4];
168: public static final int[] dmaDACValue = new int[4];
169: public static final int[] dmaMAC = new int[4];
170: public static final int[] dmaMACValue = new int[4];
171: public static final int[] dmaITE = new int[4];
172: public static final int[] dmaSAB = new int[4];
173: public static final int[] dmaHLT = new int[4];
174: public static final int[] dmaCNT = new int[4];
175: public static final int[] dmaSTR = new int[4];
176: public static final int[] dmaMTC = new int[4];
177: public static final int[] dmaMAR = new int[4];
178: public static final int[] dmaDAR = new int[4];
179: public static final int[] dmaBTC = new int[4];
180: public static final int[] dmaBAR = new int[4];
181: public static final int[] dmaNIV = new int[4];
182: public static final int[] dmaEIV = new int[4];
183: public static final int[] dmaMFC = new int[4];
184: public static final MemoryMappedDevice[][] dmaMFCMap = new MemoryMappedDevice[4][];
185: public static final int[] dmaCP = new int[4];
186: public static final int[] dmaDFC = new int[4];
187: public static final MemoryMappedDevice[][] dmaDFCMap = new MemoryMappedDevice[4][];
188: public static final int[] dmaBFC = new int[4];
189: public static final MemoryMappedDevice[][] dmaBFCMap = new MemoryMappedDevice[4][];
190: public static int dmaBR;
191: public static int dmaBT;
192: public static long dmaBurstSpan;
193: public static long dmaBurstInterval;
194: public static long dmaBurstStart;
195: public static long dmaBurstEnd;
196: public static long[] dmaRequestTime = new long[4];
197:
198:
199: public static final int[] dmaInnerRequest = new int[8];
200: public static final int[] dmaInnerAcknowleged = new int[8];
201:
202:
203: public static final long[] dmaInnerClock = new long[4];
204:
205:
206: public static final int[] dmaMemoryCarry = new int[4];
207: public static final int[] dmaDeviceCarry = new int[4];
208:
209:
210: public static final int[] dmaAdditionalCycles = new int[4];
211:
212:
213: public static int dmaReadCycles;
214: public static int dmaWriteCycles;
215:
216: public static final TickerQueue.Ticker[] dmaTickerArray = new TickerQueue.Ticker[] {
217: new TickerQueue.Ticker () {
218: @Override protected void tick () {
219: dmaTransfer (0);
220: }
221: },
222: new TickerQueue.Ticker () {
223: @Override protected void tick () {
224: dmaTransfer (1);
225: }
226: },
227: new TickerQueue.Ticker () {
228: @Override protected void tick () {
229: dmaTransfer (2);
230: }
231: },
232: new TickerQueue.Ticker () {
233: @Override protected void tick () {
234: dmaTransfer (3);
235: }
236: },
237: };
238:
239:
240:
241: public static void dmaInit () {
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286: dmaPCS[0] = 0;
287: dmaPCS[1] = 0;
288: dmaPCS[2] = 1;
289: dmaPCS[3] = 0;
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300: dmaReset ();
301: }
302:
303:
304: public static void dmaReset () {
305:
306: for (int i = 0; i < 4; i++) {
307:
308: dmaPCT[i] = 0;
309: dmaDIT[i] = 0;
310: dmaACT[i] = 0;
311: dmaERR[i] = 0;
312: dmaNDT[i] = 0;
313: dmaBLC[i] = 0;
314: dmaCOC[i] = 0;
315: dmaErrorCode[i] = 0;
316: dmaPCL[i] = 0;
317: dmaDPS[i] = 0;
318: dmaDTYP[i] = 0;
319: dmaXRM[i] = 0;
320: dmaREQG[i] = 0;
321: dmaCHAIN[i] = 0;
322: dmaSIZE[i] = 0;
323: dmaBTD[i] = 0;
324: dmaDIR[i] = 0;
325: dmaDAC[i] = 0;
326: dmaDACValue[i] = 0;
327: dmaMAC[i] = 0;
328: dmaMACValue[i] = 0;
329: dmaITE[i] = 0;
330: dmaSAB[i] = 0;
331: dmaHLT[i] = 0;
332: dmaCNT[i] = 0;
333: dmaSTR[i] = 0;
334: dmaMTC[i] = 0;
335: dmaMAR[i] = 0;
336: dmaDAR[i] = 0;
337: dmaBTC[i] = 0;
338: dmaBAR[i] = 0;
339: dmaNIV[i] = 0x0f;
340: dmaEIV[i] = 0x0f;
341: dmaMFC[i] = 0;
342: if (DataBreakPoint.DBP_ON) {
343: dmaMFCMap[i] = DataBreakPoint.dbpUserMap;
344: } else {
345: dmaMFCMap[i] = XEiJ.busUserMap;
346: }
347: dmaCP[i] = 0;
348: dmaDFC[i] = 0;
349: if (DataBreakPoint.DBP_ON) {
350: dmaDFCMap[i] = DataBreakPoint.dbpUserMap;
351: } else {
352: dmaDFCMap[i] = XEiJ.busUserMap;
353: }
354: dmaBFC[i] = 0;
355: if (DataBreakPoint.DBP_ON) {
356: dmaBFCMap[i] = DataBreakPoint.dbpUserMap;
357: } else {
358: dmaBFCMap[i] = XEiJ.busUserMap;
359: }
360: dmaRequestTime[i] = XEiJ.FAR_FUTURE;
361: }
362: dmaBR = 0;
363: dmaBT = 0;
364: dmaBurstSpan = XEiJ.dmaCycleUnit << (4 + (dmaBT >> 2));
365: dmaBurstInterval = dmaBurstSpan << (1 + (dmaBR & 3));
366: dmaBurstStart = XEiJ.FAR_FUTURE;
367: dmaBurstEnd = 0L;
368:
369: for (int i = 0; i < 8; i++) {
370: dmaInnerRequest[i] = 0;
371: dmaInnerAcknowleged[i] = 0;
372: }
373:
374: for (int i = 0; i < 4; i++) {
375: dmaInnerClock[i] = XEiJ.FAR_FUTURE;
376: TickerQueue.tkqRemove (dmaTickerArray[i]);
377: }
378: }
379:
380:
381:
382:
383:
384:
385: public static int dmaAcknowledge () {
386: for (int i = 0; i < 8; i++) {
387: int request = dmaInnerRequest[i];
388: if (dmaInnerAcknowleged[i] != request) {
389: dmaInnerAcknowleged[i] = request;
390: return (i & 1) == 0 ? dmaNIV[i >> 1] : dmaEIV[i >> 1];
391: }
392: }
393: return 0;
394: }
395:
396:
397:
398:
399: public static void dmaDone () {
400: for (int i = 0; i < 8; i++) {
401: if (dmaInnerRequest[i] != dmaInnerAcknowleged[i]) {
402: XEiJ.mpuIRR |= XEiJ.MPU_DMA_INTERRUPT_MASK;
403: return;
404: }
405: }
406: }
407:
408:
409:
410: public static void dmaStart (int i) {
411: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
412: System.out.printf ("%d %08x dmaStart(%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i);
413: System.out.printf ("CSR=0x%02x,CER=0x%02x,DCR=0x%02x,OCR=0x%02x,SCR=0x%02x,CCR=0x%02x,MTC=0x%04x,MAR=0x%08x,DAR=0x%08x,BTC=0x%04x,BAR=0x%08x\n",
414: dmaCOC[i] | dmaBLC[i] | dmaNDT[i] | dmaERR[i] | dmaACT[i] | dmaDIT[i] | dmaPCT[i] | dmaPCS[i],
415: dmaErrorCode[i],
416: dmaXRM[i] | dmaDTYP[i] | dmaDPS[i] | dmaPCL[i],
417: dmaDIR[i] | dmaBTD[i] | dmaSIZE[i] | dmaCHAIN[i] | dmaREQG[i],
418: dmaMAC[i] | dmaDAC[i],
419: dmaSTR[i] | dmaCNT[i] | dmaHLT[i] | dmaSAB[i] | dmaITE[i],
420: dmaMTC[i], dmaMAR[i], dmaDAR[i], dmaBTC[i], dmaBAR[i]);
421: }
422:
423: if ((dmaCOC[i] | dmaBLC[i] | dmaNDT[i] | dmaERR[i] | dmaACT[i]) != 0) {
424: dmaErrorExit (i, DMA_TIMING_ERROR);
425: return;
426: }
427:
428: if (((dmaDTYP[i] == DMA_HD68000_COMPATIBLE || dmaDTYP[i] == DMA_HD6800_COMPATIBLE) &&
429: dmaDPS[i] == DMA_PORT_16_BIT && dmaSIZE[i] == DMA_BYTE_SIZE &&
430: (dmaREQG[i] == DMA_EXTERNAL_REQUEST || dmaREQG[i] == DMA_DUAL_REQUEST)) ||
431: dmaXRM[i] == 0b01000000 || dmaMAC[i] == 0b00001100 || dmaDAC[i] == 0b00000011 || dmaCHAIN[i] == 0b00000100 ||
432: (dmaSIZE[i] == 0b00000011 && !((dmaDTYP[i] == DMA_HD68000_COMPATIBLE || dmaDTYP[i] == DMA_HD6800_COMPATIBLE) && dmaDPS[i] == DMA_PORT_8_BIT))) {
433: dmaErrorExit (i, DMA_CONFIGURATION_ERROR);
434: return;
435: }
436: if (dmaDPS[i] == DMA_PORT_16_BIT &&
437: dmaSIZE[i] == DMA_UNPACKED_8_BIT) {
438: dmaErrorExit (i, DMA_CONFIGURATION_ERROR);
439: return;
440: }
441:
442: dmaMemoryCarry[i] = -1;
443: dmaDeviceCarry[i] = -1;
444:
445:
446: dmaRequestTime[i] = XEiJ.mpuClockTime;
447: dmaACT[i] = DMA_ACT;
448: if (dmaCHAIN[i] == DMA_ARRAY_CHAINING) {
449: if (dmaBTC[i] == 0) {
450: dmaErrorExit (i, DMA_BASE_COUNT_ERROR);
451: return;
452: }
453: if ((dmaBAR[i] & 1) != 0) {
454: dmaErrorExit (i, DMA_BASE_ADDRESS_ERROR);
455: return;
456: }
457: try {
458: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.dmaWaitTime : XEiJ.dmaNoWaitTime;
459: MemoryMappedDevice[] mm = dmaBFCMap[i];
460: int a = dmaBAR[i];
461: dmaMAR[i] = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a) << 16 | mm[a + 2 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
462: dmaMTC[i] = mm[a + 4 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 4);
463: dmaBAR[i] += 6;
464: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 3;
465: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
466: } catch (M68kException e) {
467: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
468: dmaErrorExit (i, DMA_BASE_BUS_ERROR);
469: return;
470: }
471: dmaBTC[i]--;
472: } else if (dmaCHAIN[i] == DMA_LINK_ARRAY_CHAINING) {
473: if ((dmaBAR[i] & 1) != 0) {
474: dmaErrorExit (i, DMA_BASE_ADDRESS_ERROR);
475: return;
476: }
477: try {
478: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.dmaWaitTime : XEiJ.dmaNoWaitTime;
479: MemoryMappedDevice[] mm = dmaBFCMap[i];
480: int a = dmaBAR[i];
481: dmaMAR[i] = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a) << 16 | mm[a + 2 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
482: dmaMTC[i] = mm[a + 4 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 4);
483: dmaBAR[i] = mm[a + 6 >>> XEiJ.BUS_PAGE_BITS].mmdRws (a + 6) << 16 | mm[a + 8 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 8);
484: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 5;
485: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
486: } catch (M68kException e) {
487: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
488: dmaErrorExit (i, DMA_BASE_BUS_ERROR);
489: return;
490: }
491: }
492:
493:
494: if (dmaMTC[i] == 0) {
495: dmaErrorExit (i, DMA_MEMORY_COUNT_ERROR);
496: return;
497: }
498:
499:
500: dmaAdditionalCycles[i] = (dmaDPS[i] == DMA_PORT_8_BIT ?
501: dmaSIZE[i] == DMA_BYTE_SIZE ?
502: (dmaMAR[i] & 1) == 0 && dmaMACValue[i] == 0 ? 6 :
503: (dmaMAR[i] & 1) != 0 && dmaMACValue[i] == 0 ? 8 :
504: dmaDIR[i] == DMA_MEMORY_TO_DEVICE ? 8 : 10 :
505: dmaSIZE[i] == DMA_WORD_SIZE || dmaSIZE[i] == DMA_LONG_WORD_SIZE ?
506: dmaDIR[i] == DMA_MEMORY_TO_DEVICE ? 4 : 0 :
507: 0
508: :
509: dmaSIZE[i] == DMA_BYTE_SIZE ?
510: 4 +
511: ((dmaMAR[i] & 1) != 0 && dmaMACValue[i] == 0 ? 1 : 0) +
512: ((dmaDAR[i] & 1) != 0 && dmaDACValue[i] == 0 ? 1 : 0) :
513: 0);
514: if (SUK.SUK_ON) {
515: if (i == 1 &&
516: SUK.sukOn &&
517: SUK.sukDatainStage != 0 &&
518: dmaDAR[i] == (SUK.sukExpansion ? SPC.SPC_BASE_EX : SPC.SPC_BASE_IN) + SPC.SPC_DREG &&
519: dmaDIR[i] == DMA_DEVICE_TO_MEMORY &&
520: dmaCHAIN[i] == DMA_NO_CHAINING &&
521: dmaREQG[i] == DMA_AUTO_REQUEST_MAX) {
522: if (SUK.sukDatainStage == 0) {
523: System.out.printf ("%08x DMAC attempted to receive while not in data-in-phase\n", XEiJ.regPC0);
524: } else if (SUK.sukDatainStage == 1) {
525: if (SUK.SUK_DEBUG) {
526: System.out.printf ("%08x DMAC has started receiving\n", XEiJ.regPC0);
527: }
528: SUK.sukDatainStage2 ();
529: }
530: if (dmaMTC[i] <= (SUK.sukQueueWrite - SUK.sukQueueRead)) {
531: dmaTransfer (i);
532: } else {
533:
534: SUK.sukWaitQueueCounter = 0;
535: SUK.sukWaitQueueMTC = dmaMTC[i];
536: InstructionBreakPoint.ibpAddWaitPoint (XEiJ.regPC, XEiJ.regSRS, SUK.sukWaitQueueInstruction);
537:
538: dmaRequestTime[i] += XEiJ.mpuCycleUnit;
539: dmaInnerClock[i] = dmaRequestTime[i];
540: TickerQueue.tkqAdd (dmaTickerArray[i], dmaInnerClock[i]);
541: }
542: return;
543: }
544: }
545: if (dmaREQG[i] == DMA_AUTO_REQUEST) {
546: dmaBurstStart = XEiJ.mpuClockTime;
547: dmaBurstEnd = dmaBurstStart + dmaBurstSpan;
548: dmaTransfer (i);
549: } else if (dmaREQG[i] != DMA_EXTERNAL_REQUEST ||
550: dmaPCT[i] != 0) {
551: dmaTransfer (i);
552: }
553: }
554:
555:
556:
557: public static void dmaContinue (int i) {
558: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
559: System.out.printf ("%d %08x dmaContinue(%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i);
560: }
561: if (dmaREQG[i] == DMA_AUTO_REQUEST) {
562: if (XEiJ.mpuClockTime < dmaBurstEnd) {
563:
564:
565:
566: dmaInnerClock[i] = dmaRequestTime[i];
567: TickerQueue.tkqAdd (dmaTickerArray[i], dmaInnerClock[i]);
568: } else {
569: dmaBurstStart += dmaBurstInterval;
570: if (dmaBurstStart < XEiJ.mpuClockTime) {
571: dmaBurstStart = XEiJ.mpuClockTime + dmaBurstInterval;
572: }
573: dmaBurstEnd = dmaBurstStart + dmaBurstSpan;
574:
575: dmaInnerClock[i] = dmaBurstStart;
576: TickerQueue.tkqAdd (dmaTickerArray[i], dmaInnerClock[i]);
577: }
578: } else if (dmaREQG[i] == DMA_AUTO_REQUEST_MAX) {
579:
580:
581:
582: dmaInnerClock[i] = dmaRequestTime[i];
583: TickerQueue.tkqAdd (dmaTickerArray[i], dmaInnerClock[i]);
584: }
585: }
586:
587:
588:
589: public static void dmaHalt (int i, int hlt) {
590: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
591: System.out.printf ("%d %08x dmaHalt(%d,%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i, hlt);
592: }
593: if ((~dmaHLT[i] & hlt) != 0) {
594: if (dmaACT[i] == 0) {
595: dmaErrorExit (i, DMA_TIMING_ERROR);
596: return;
597: }
598: dmaHLT[i] = DMA_HLT;
599: dmaRequestTime[i] = XEiJ.FAR_FUTURE;
600: if (dmaInnerClock[i] != XEiJ.FAR_FUTURE) {
601: dmaInnerClock[i] = XEiJ.FAR_FUTURE;
602: TickerQueue.tkqRemove (dmaTickerArray[i]);
603: }
604: } else if ((dmaHLT[i] & ~hlt) != 0) {
605: dmaHLT[i] = 0;
606: if (dmaACT[i] == 0) {
607: return;
608: }
609: dmaRequestTime[i] = XEiJ.mpuClockTime;
610: if (dmaREQG[i] == DMA_AUTO_REQUEST) {
611: dmaBurstStart = XEiJ.mpuClockTime;
612: dmaBurstEnd = dmaBurstStart + dmaBurstSpan;
613: }
614: dmaContinue (i);
615: }
616: }
617:
618:
619:
620:
621: public static void dmaComplete (int i) {
622: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
623: System.out.printf ("%d %08x dmaComplete(%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i);
624: }
625: dmaRequestTime[i] = XEiJ.FAR_FUTURE;
626: dmaCOC[i] = DMA_COC;
627: dmaERR[i] = 0;
628: dmaACT[i] = 0;
629: dmaSTR[i] = 0;
630: dmaCNT[i] = 0;
631: dmaSAB[i] = 0;
632: dmaErrorCode[i] = 0;
633: if (dmaITE[i] != 0) {
634: dmaInnerRequest[i << 1]++;
635: XEiJ.mpuIRR |= XEiJ.MPU_DMA_INTERRUPT_MASK;
636: }
637: if (dmaInnerClock[i] != XEiJ.FAR_FUTURE) {
638: dmaInnerClock[i] = XEiJ.FAR_FUTURE;
639: TickerQueue.tkqRemove (dmaTickerArray[i]);
640: }
641: }
642:
643:
644:
645:
646: public static void dmaErrorExit (int i, int code) {
647: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
648: System.out.printf ("%d %08x dmaErrorExit(%d,%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i, code);
649: }
650: dmaRequestTime[i] = XEiJ.FAR_FUTURE;
651: dmaCOC[i] = DMA_COC;
652: dmaERR[i] = DMA_ERR;
653: dmaACT[i] = 0;
654: dmaSTR[i] = 0;
655: dmaCNT[i] = 0;
656: dmaHLT[i] = 0;
657: dmaSAB[i] = 0;
658: dmaErrorCode[i] = code;
659: if (dmaITE[i] != 0) {
660: dmaInnerRequest[i << 1 | 1]++;
661: XEiJ.mpuIRR |= XEiJ.MPU_DMA_INTERRUPT_MASK;
662: }
663: if (dmaInnerClock[i] != XEiJ.FAR_FUTURE) {
664: dmaInnerClock[i] = XEiJ.FAR_FUTURE;
665: TickerQueue.tkqRemove (dmaTickerArray[i]);
666: }
667: }
668:
669:
670:
671:
672: public static void dmaFallPCL (int i) {
673: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
674: System.out.printf ("%d %08x dmaFallPCL(%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i);
675: }
676: dmaPCS[i] = 0;
677: dmaPCT[i] = DMA_PCT;
678: if (dmaACT[i] != 0 &&
679: (dmaREQG[i] & (DMA_EXTERNAL_REQUEST & DMA_DUAL_REQUEST)) != 0) {
680:
681:
682: dmaInnerClock[i] = XEiJ.mpuClockTime + XEiJ.dmaCycleUnit * 1;
683: TickerQueue.tkqAdd (dmaTickerArray[i], dmaInnerClock[i]);
684: }
685: }
686:
687:
688:
689: public static void dmaRisePCL (int i) {
690: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
691: System.out.printf ("%d %08x dmaRisePCL(%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i);
692: }
693: dmaPCS[i] = DMA_PCS;
694: dmaPCT[i] = 0;
695: dmaInnerClock[i] = XEiJ.FAR_FUTURE;
696: TickerQueue.tkqRemove (dmaTickerArray[i]);
697: }
698:
699:
700:
701: @SuppressWarnings ("fallthrough") public static void dmaTransfer (int i) {
702: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
703: System.out.printf ("%d %08x dmaTransfer(%d,0x%08x,0x%08x,%d)\n", XEiJ.mpuClockTime, XEiJ.regPC0, i,
704: dmaDIR[i] == DMA_MEMORY_TO_DEVICE ? dmaMAR[i] : dmaDAR[i],
705: dmaDIR[i] == DMA_MEMORY_TO_DEVICE ? dmaDAR[i] : dmaMAR[i],
706: dmaSIZE[i] == DMA_BYTE_SIZE || dmaSIZE[i] == DMA_UNPACKED_8_BIT ? 1 : dmaSIZE[i] == DMA_WORD_SIZE ? 2 : 4);
707: }
708: if (dmaHLT[i] != 0) {
709: return;
710: }
711: transfer:
712: {
713: int code = 0;
714: try {
715: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.dmaWaitTime : XEiJ.dmaNoWaitTime;
716: switch (dmaSIZE[i]) {
717: case DMA_BYTE_SIZE:
718: if (dmaDIR[i] == DMA_MEMORY_TO_DEVICE) {
719:
720: code = DMA_MEMORY_BUS_ERROR;
721: MemoryMappedDevice[] mm = dmaMFCMap[i];
722: int a = dmaMAR[i];
723: int ac = dmaMACValue[i];
724: int data = dmaMemoryCarry[i];
725: if (0 <= data) {
726: dmaMemoryCarry[i] = -1;
727: } else if ((a & 1) == 0 && ac == 1 && 2 <= dmaMTC[i]) {
728: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
729: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
730: dmaMemoryCarry[i] = data & 255;
731: data >>= 8;
732: } else if ((a & 1) != 0 && ac == -1 && 2 <= dmaMTC[i]) {
733: data = mm[(a - 1) >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a - 1);
734: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
735: dmaMemoryCarry[i] = data >> 8;
736: data &= 255;
737: } else {
738: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
739: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
740: }
741: dmaMAR[i] = a + ac;
742:
743: code = DMA_DEVICE_BUS_ERROR;
744: mm = dmaDFCMap[i];
745: a = dmaDAR[i];
746: ac = dmaDACValue[i];
747: int carry = dmaDeviceCarry[i];
748: if (0 <= carry) {
749: if ((a & 1) != 0) {
750: data = carry << 8 | data;
751: mm[(a - 1) >>> XEiJ.BUS_PAGE_BITS].mmdWw (a - 1, data);
752: } else {
753: data = data << 8 | carry;
754: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data);
755: }
756: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
757: dmaDeviceCarry[i] = -1;
758: } else if (((a & 1) == 0 ? ac == 1 : ac == -1) && 2 <= dmaMTC[i]) {
759: dmaDeviceCarry[i] = data;
760: } else {
761: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data);
762: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
763: }
764: dmaDAR[i] = a + ac;
765: } else {
766:
767: code = DMA_DEVICE_BUS_ERROR;
768: MemoryMappedDevice[] mm = dmaDFCMap[i];
769: int a = dmaDAR[i];
770: int ac = dmaDACValue[i];
771: int data = dmaDeviceCarry[i];
772: if (0 <= data) {
773: dmaDeviceCarry[i] = -1;
774: } else if ((a & 1) == 0 && ac == 1 && 2 <= dmaMTC[i]) {
775: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
776: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
777: dmaDeviceCarry[i] = data & 255;
778: data >>= 8;
779: } else if ((a & 1) != 0 && ac == -1 && 2 <= dmaMTC[i]) {
780: data = mm[(a - 1) >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a - 1);
781: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
782: dmaDeviceCarry[i] = data >> 8;
783: data &= 255;
784: } else {
785: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
786: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
787: }
788: dmaDAR[i] = a + ac;
789:
790: code = DMA_MEMORY_BUS_ERROR;
791: mm = dmaMFCMap[i];
792: a = dmaMAR[i];
793: ac = dmaMACValue[i];
794: int carry = dmaMemoryCarry[i];
795: if (0 <= carry) {
796: if ((a & 1) != 0) {
797: data = carry << 8 | data;
798: mm[(a - 1) >>> XEiJ.BUS_PAGE_BITS].mmdWw (a - 1, data);
799: } else {
800: data = data << 8 | carry;
801: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data);
802: }
803: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
804: dmaMemoryCarry[i] = -1;
805: } else if (((a & 1) == 0 ? ac == 1 : ac == -1) && 2 <= dmaMTC[i]) {
806: dmaMemoryCarry[i] = data;
807: } else {
808: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data);
809: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
810: }
811: dmaMAR[i] = a + ac;
812: }
813: break;
814:
815: case DMA_WORD_SIZE:
816: if (dmaDIR[i] == DMA_MEMORY_TO_DEVICE) {
817:
818: code = DMA_MEMORY_BUS_ERROR;
819: MemoryMappedDevice[] mm = dmaMFCMap[i];
820: int a = dmaMAR[i];
821: int ac = dmaMACValue[i];
822: if ((a & 1) != 0) {
823: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
824: break transfer;
825: }
826: int data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
827: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
828: dmaMAR[i] = a + ac * 2;
829:
830: code = DMA_DEVICE_BUS_ERROR;
831: mm = dmaDFCMap[i];
832: a = dmaDAR[i];
833: ac = dmaDACValue[i];
834: if (dmaDPS[i] == DMA_PORT_8_BIT) {
835: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data >> 8);
836: mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdWb (a + 2, data);
837: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles * 2;
838: } else {
839: if ((a & 1) != 0) {
840: dmaErrorExit (i, DMA_DEVICE_ADDRESS_ERROR);
841: break transfer;
842: }
843: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data);
844: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
845: }
846: dmaDAR[i] = a + ac * 2;
847: } else {
848:
849: code = DMA_DEVICE_BUS_ERROR;
850: MemoryMappedDevice[] mm = dmaDFCMap[i];
851: int a = dmaDAR[i];
852: int ac = dmaDACValue[i];
853: int data;
854: if (dmaDPS[i] == DMA_PORT_8_BIT) {
855: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a) << 8;
856: data |= mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a + 2);
857: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 2;
858: } else {
859: if ((a & 1) != 0) {
860: dmaErrorExit (i, DMA_DEVICE_ADDRESS_ERROR);
861: break transfer;
862: }
863: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
864: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
865: }
866: dmaDAR[i] = a + ac * 2;
867:
868: code = DMA_MEMORY_BUS_ERROR;
869: mm = dmaMFCMap[i];
870: a = dmaMAR[i];
871: ac = dmaMACValue[i];
872: if ((a & 1) != 0) {
873: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
874: break transfer;
875: }
876: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data);
877: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
878: dmaMAR[i] = a + ac * 2;
879: }
880: break;
881:
882: case DMA_LONG_WORD_SIZE:
883: if (dmaDIR[i] == DMA_MEMORY_TO_DEVICE) {
884:
885: code = DMA_MEMORY_BUS_ERROR;
886: MemoryMappedDevice[] mm = dmaMFCMap[i];
887: int a = dmaMAR[i];
888: int ac = dmaMACValue[i];
889: if ((a & 1) != 0) {
890: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
891: break transfer;
892: }
893: int data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a) << 16;
894: data |= mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
895: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 2;
896: dmaMAR[i] = a + ac * 4;
897:
898: code = DMA_DEVICE_BUS_ERROR;
899: mm = dmaDFCMap[i];
900: a = dmaDAR[i];
901: ac = dmaDACValue[i];
902: if (dmaDPS[i] == DMA_PORT_8_BIT) {
903: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data >> 24);
904: mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdWb (a + 2, data >> 16);
905: mm[(a + 4) >>> XEiJ.BUS_PAGE_BITS].mmdWb (a + 4, data >> 8);
906: mm[(a + 6) >>> XEiJ.BUS_PAGE_BITS].mmdWb (a + 6, data);
907: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles * 4;
908: } else {
909: if ((a & 1) != 0) {
910: dmaErrorExit (i, DMA_DEVICE_ADDRESS_ERROR);
911: break transfer;
912: }
913: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data >> 16);
914: mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdWw (a + 2, data);
915: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles * 2;
916: }
917: dmaDAR[i] = a + ac * 4;
918: } else {
919:
920: code = DMA_DEVICE_BUS_ERROR;
921: MemoryMappedDevice[] mm = dmaDFCMap[i];
922: int a = dmaDAR[i];
923: int ac = dmaDACValue[i];
924: int data;
925: if (dmaDPS[i] == DMA_PORT_8_BIT) {
926: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a) << 24;
927: data |= mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a + 2) << 16;
928: data |= mm[(a + 4) >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a + 4) << 8;
929: data |= mm[(a + 6) >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a + 6);
930: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 4;
931: } else {
932: if ((a & 1) != 0) {
933: dmaErrorExit (i, DMA_DEVICE_ADDRESS_ERROR);
934: break transfer;
935: }
936: data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a) << 16;
937: data |= mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
938: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 2;
939: }
940: dmaDAR[i] = a + ac * 4;
941:
942: code = DMA_MEMORY_BUS_ERROR;
943: mm = dmaMFCMap[i];
944: a = dmaMAR[i];
945: ac = dmaMACValue[i];
946: if ((a & 1) != 0) {
947: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
948: break transfer;
949: }
950: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, data >> 16);
951: mm[(a + 2) >>> XEiJ.BUS_PAGE_BITS].mmdWw (a + 2, data);
952: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles * 2;
953: dmaMAR[i] = a + ac * 4;
954: }
955: break;
956:
957: case DMA_UNPACKED_8_BIT:
958: if (dmaDIR[i] == DMA_MEMORY_TO_DEVICE) {
959:
960: code = DMA_MEMORY_BUS_ERROR;
961: MemoryMappedDevice[] mm = dmaMFCMap[i];
962: int a = dmaMAR[i];
963: int ac = dmaMACValue[i];
964: int data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
965: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
966: dmaMAR[i] = a + ac;
967:
968: code = DMA_DEVICE_BUS_ERROR;
969: mm = dmaDFCMap[i];
970: a = dmaDAR[i];
971: ac = dmaDACValue[i];
972: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data);
973: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
974: dmaDAR[i] = a + ac;
975: } else {
976:
977: code = DMA_DEVICE_BUS_ERROR;
978: MemoryMappedDevice[] mm = dmaDFCMap[i];
979: int a = dmaDAR[i];
980: int ac = dmaDACValue[i];
981: int data = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
982: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles;
983: dmaDAR[i] = a + ac;
984:
985: code = DMA_MEMORY_BUS_ERROR;
986: mm = dmaMFCMap[i];
987: a = dmaMAR[i];
988: ac = dmaMACValue[i];
989: mm[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, data);
990: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaWriteCycles;
991: dmaMAR[i] = a + ac;
992: }
993: break;
994: }
995:
996: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaAdditionalCycles[i];
997: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
998: } catch (M68kException e) {
999: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
1000: dmaErrorExit (i, code);
1001: break transfer;
1002: }
1003: dmaMTC[i]--;
1004: if (dmaMTC[i] != 0) {
1005: dmaContinue (i);
1006: } else if (dmaCHAIN[i] == DMA_ARRAY_CHAINING) {
1007: if (dmaBTC[i] != 0) {
1008:
1009: try {
1010: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.dmaWaitTime : XEiJ.dmaNoWaitTime;
1011: MemoryMappedDevice[] mm = dmaBFCMap[i];
1012: int a = dmaBAR[i];
1013: dmaMAR[i] = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a) << 16 | mm[a + 2 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
1014: dmaMTC[i] = mm[a + 4 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 4);
1015: dmaBAR[i] += 6;
1016: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 3;
1017: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
1018: } catch (M68kException e) {
1019: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
1020: dmaErrorExit (i, DMA_BASE_BUS_ERROR);
1021: break transfer;
1022: }
1023: dmaBTC[i]--;
1024: if (dmaMTC[i] == 0) {
1025: dmaErrorExit (i, DMA_MEMORY_COUNT_ERROR);
1026: break transfer;
1027: }
1028: if ((dmaSIZE[i] == DMA_WORD_SIZE || dmaSIZE[i] == DMA_LONG_WORD_SIZE) && (dmaMAR[i] & 1) != 0) {
1029: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
1030: break transfer;
1031: }
1032: dmaContinue (i);
1033: } else {
1034: dmaBLC[i] = DMA_BLC;
1035: dmaNDT[i] = 0;
1036: dmaComplete (i);
1037: }
1038: } else if (dmaCHAIN[i] == DMA_LINK_ARRAY_CHAINING) {
1039: if (dmaBAR[i] != 0) {
1040: if ((dmaBAR[i] & 1) != 0) {
1041: dmaErrorExit (i, DMA_BASE_ADDRESS_ERROR);
1042: break transfer;
1043: }
1044: try {
1045: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.dmaWaitTime : XEiJ.dmaNoWaitTime;
1046: MemoryMappedDevice[] mm = dmaBFCMap[i];
1047: int a = dmaBAR[i];
1048: dmaMAR[i] = mm[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a) << 16 | mm[a + 2 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 2);
1049: dmaMTC[i] = mm[a + 4 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 4);
1050: dmaBAR[i] = mm[a + 6 >>> XEiJ.BUS_PAGE_BITS].mmdRws (a + 6) << 16 | mm[a + 8 >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a + 8);
1051: XEiJ.mpuClockTime += XEiJ.dmaCycleUnit * dmaReadCycles * 5;
1052: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
1053: } catch (M68kException e) {
1054: XEiJ.busWaitTime = XEiJ.busWaitCycles ? XEiJ.mpuWaitTime : XEiJ.mpuNoWaitTime;
1055: dmaErrorExit (i, DMA_BASE_BUS_ERROR);
1056: break transfer;
1057: }
1058: if (dmaMTC[i] == 0) {
1059: dmaErrorExit (i, DMA_MEMORY_COUNT_ERROR);
1060: break transfer;
1061: }
1062: if ((dmaSIZE[i] == DMA_WORD_SIZE || dmaSIZE[i] == DMA_LONG_WORD_SIZE) && (dmaMAR[i] & 1) != 0) {
1063: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
1064: break transfer;
1065: }
1066: dmaContinue (i);
1067: } else {
1068: dmaBLC[i] = DMA_BLC;
1069: dmaNDT[i] = 0;
1070: dmaComplete (i);
1071: }
1072: } else if (dmaCNT[i] != 0) {
1073: dmaBLC[i] = DMA_BLC;
1074: dmaCNT[i] = 0;
1075: if (dmaITE[i] != 0) {
1076: dmaInnerRequest[i << 1]++;
1077: XEiJ.mpuIRR |= XEiJ.MPU_DMA_INTERRUPT_MASK;
1078: }
1079: dmaMTC[i] = dmaBTC[i];
1080: dmaMAR[i] = dmaBAR[i];
1081: if (dmaMTC[i] == 0) {
1082: dmaErrorExit (i, DMA_MEMORY_COUNT_ERROR);
1083: break transfer;
1084: }
1085: if ((dmaSIZE[i] == DMA_WORD_SIZE || dmaSIZE[i] == DMA_LONG_WORD_SIZE) && (dmaMAR[i] & 1) != 0) {
1086: dmaErrorExit (i, DMA_MEMORY_ADDRESS_ERROR);
1087: break transfer;
1088: }
1089: dmaContinue (i);
1090: } else {
1091: dmaBLC[i] = 0;
1092: dmaNDT[i] = 0;
1093: dmaComplete (i);
1094: }
1095: }
1096: }
1097:
1098:
1099:
1100: public static int dmaReadByte (int a) {
1101: int d;
1102: int al = a & 0xff;
1103: if (al == DMA_GCR) {
1104: d = dmaBT | dmaBR;
1105: if (DMA_DEBUG_TRACE != 0) {
1106: System.out.printf ("%d %08x dmaRbz(0x%08x)=0x%02x\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1107: }
1108: } else {
1109: int i = al >> 6;
1110: switch (al & 0x3f) {
1111: case DMA_CSR:
1112: d = dmaCOC[i] | dmaBLC[i] | dmaNDT[i] | dmaERR[i] | dmaACT[i] | dmaDIT[i] | dmaPCT[i] | dmaPCS[i];
1113: break;
1114: case DMA_CER:
1115: d = dmaErrorCode[i];
1116: break;
1117: case DMA_DCR:
1118: d = dmaXRM[i] | dmaDTYP[i] | dmaDPS[i] | dmaPCL[i];
1119: break;
1120: case DMA_OCR:
1121: d = dmaDIR[i] | dmaBTD[i] | dmaSIZE[i] | dmaCHAIN[i] | dmaREQG[i];
1122: break;
1123: case DMA_SCR:
1124: d = dmaMAC[i] | dmaDAC[i];
1125: break;
1126: case DMA_CCR:
1127: d = dmaSTR[i] | dmaCNT[i] | dmaHLT[i] | dmaSAB[i] | dmaITE[i];
1128: break;
1129: case DMA_MTC:
1130: d = dmaMTC[i] >> 8;
1131: break;
1132: case DMA_MTC + 1:
1133: d = dmaMTC[i] & 0xff;
1134: break;
1135: case DMA_MAR:
1136: d = dmaMAR[i] >>> 24;
1137: break;
1138: case DMA_MAR + 1:
1139: d = dmaMAR[i] >> 16 & 0xff;
1140: break;
1141: case DMA_MAR + 2:
1142: d = (char) dmaMAR[i] >> 8;
1143: break;
1144: case DMA_MAR + 3:
1145: d = dmaMAR[i] & 0xff;
1146: break;
1147: case DMA_DAR:
1148: d = dmaDAR[i] >>> 24;
1149: break;
1150: case DMA_DAR + 1:
1151: d = dmaDAR[i] >> 16 & 0xff;
1152: break;
1153: case DMA_DAR + 2:
1154: d = (char) dmaDAR[i] >> 8;
1155: break;
1156: case DMA_DAR + 3:
1157: d = dmaDAR[i] & 0xff;
1158: break;
1159: case DMA_BTC:
1160: d = dmaBTC[i] >> 8;
1161: break;
1162: case DMA_BTC + 1:
1163: d = dmaBTC[i] & 0xff;
1164: break;
1165: case DMA_BAR:
1166: d = dmaBAR[i] >>> 24;
1167: break;
1168: case DMA_BAR + 1:
1169: d = dmaBAR[i] >> 16 & 0xff;
1170: break;
1171: case DMA_BAR + 2:
1172: d = (char) dmaBAR[i] >> 8;
1173: break;
1174: case DMA_BAR + 3:
1175: d = dmaBAR[i] & 0xff;
1176: break;
1177: case DMA_NIV:
1178: d = dmaNIV[i];
1179: break;
1180: case DMA_EIV:
1181: d = dmaEIV[i];
1182: break;
1183: case DMA_MFC:
1184: d = dmaMFC[i];
1185: break;
1186: case DMA_CPR:
1187: d = dmaCP[i];
1188: break;
1189: case DMA_DFC:
1190: d = dmaDFC[i];
1191: break;
1192: case DMA_BFC:
1193: d = dmaBFC[i];
1194: break;
1195: default:
1196: d = 0;
1197: }
1198: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1199: System.out.printf ("%d %08x dmaRbz(0x%08x)=0x%02x\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1200: }
1201: }
1202: return d;
1203: }
1204:
1205: public static int dmaReadWord (int a) {
1206: int d;
1207: int al = a & 0xff;
1208: int i = al >> 6;
1209: switch (al & 0x3f) {
1210: case DMA_MTC:
1211: d = dmaMTC[i];
1212: break;
1213: case DMA_MAR:
1214: d = dmaMAR[i] >>> 16;
1215: break;
1216: case DMA_MAR + 2:
1217: d = (char) dmaMAR[i];
1218: break;
1219: case DMA_DAR:
1220: d = dmaDAR[i] >>> 16;
1221: break;
1222: case DMA_DAR + 2:
1223: d = (char) dmaDAR[i];
1224: break;
1225: case DMA_BTC:
1226: d = dmaBTC[i];
1227: break;
1228: case DMA_BAR:
1229: d = dmaBAR[i] >>> 16;
1230: break;
1231: case DMA_BAR + 2:
1232: d = (char) dmaBAR[i];
1233: break;
1234: default:
1235: d = dmaReadByte (a) << 8 | dmaReadByte (a + 1);
1236: }
1237: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1238: System.out.printf ("%d %08x dmaRwz(0x%08x)=0x%04x\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1239: }
1240: return d;
1241: }
1242:
1243: public static int dmaReadLong (int a) {
1244: a &= XEiJ.BUS_MOTHER_MASK;
1245: int d;
1246: int al = a & 0xff;
1247: int i = al >> 6;
1248: switch (al & 0x3f) {
1249: case DMA_MAR:
1250: d = dmaMAR[i];
1251: break;
1252: case DMA_DAR:
1253: d = dmaDAR[i];
1254: break;
1255: case DMA_BAR:
1256: d = dmaBAR[i];
1257: break;
1258: default:
1259: d = dmaReadWord (a) << 16 | dmaReadWord (a + 2);
1260: }
1261: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1262: System.out.printf ("%d %08x dmaRls(0x%08x)=0x%08x\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1263: }
1264: return d;
1265: }
1266:
1267: public static void dmaWriteByte (int a, int d) {
1268: d &= 0xff;
1269: int al = a & 0xff;
1270: if (al == DMA_GCR) {
1271: if (DMA_DEBUG_TRACE != 0) {
1272: System.out.printf ("%d %08x dmaWb(0x%08x,0x%02x)\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1273: }
1274: dmaBT = d & DMA_BT;
1275: dmaBR = d & DMA_BR;
1276: dmaBurstSpan = XEiJ.dmaCycleUnit << (4 + (dmaBT >> 2));
1277: dmaBurstInterval = dmaBurstSpan << (1 + (dmaBR & 3));
1278: return;
1279: }
1280: int i = al >> 6;
1281: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1282: System.out.printf ("%d %08x dmaWb(0x%08x,0x%02x)\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1283: }
1284: switch (al & 0x3f) {
1285: case DMA_CSR:
1286:
1287:
1288:
1289:
1290: if ((d & DMA_COC) != 0) {
1291: dmaCOC[i] = 0;
1292: }
1293: if ((d & DMA_PCT) != 0) {
1294: dmaPCT[i] = 0;
1295: }
1296: if ((d & DMA_BLC) != 0) {
1297: dmaBLC[i] = 0;
1298: }
1299: if ((d & DMA_NDT) != 0) {
1300: dmaNDT[i] = 0;
1301: }
1302: if ((d & DMA_ERR) != 0) {
1303: dmaERR[i] = 0;
1304: dmaErrorCode[i] = 0;
1305: }
1306: if ((d & DMA_DIT) != 0) {
1307: dmaDIT[i] = 0;
1308: }
1309: return;
1310: case DMA_CER:
1311:
1312: return;
1313: case DMA_DCR:
1314: if (dmaACT[i] != 0) {
1315: dmaErrorExit (i, DMA_TIMING_ERROR);
1316: return;
1317: }
1318: dmaXRM[i] = d & DMA_XRM;
1319: dmaDTYP[i] = d & DMA_DTYP;
1320: dmaDPS[i] = d & DMA_DPS;
1321: dmaDACValue[i] = (dmaDAC[i] == DMA_INC_DAR ? 1 : dmaDAC[i] == DMA_DEC_DAR ? -1 : 0) * (dmaDPS[i] == DMA_PORT_8_BIT ? 2 : 1);
1322: dmaPCL[i] = d & DMA_PCL;
1323: return;
1324: case DMA_OCR:
1325: dmaDIR[i] = d & DMA_DIR;
1326: dmaBTD[i] = d & DMA_BTD;
1327: dmaSIZE[i] = d & DMA_SIZE;
1328: dmaCHAIN[i] = d & DMA_CHAIN;
1329: dmaREQG[i] = d & DMA_REQG;
1330: return;
1331: case DMA_SCR:
1332: if (dmaACT[i] != 0) {
1333: dmaErrorExit (i, DMA_TIMING_ERROR);
1334: return;
1335: }
1336: dmaMAC[i] = d & DMA_MAC;
1337: dmaMACValue[i] = dmaMAC[i] == DMA_INC_MAR ? 1 : dmaMAC[i] == DMA_DEC_MAR ? -1 : 0;
1338: dmaDAC[i] = d & DMA_DAC;
1339: dmaDACValue[i] = (dmaDAC[i] == DMA_INC_DAR ? 1 : dmaDAC[i] == DMA_DEC_DAR ? -1 : 0) * (dmaDPS[i] == DMA_PORT_8_BIT ? 2 : 1);
1340: return;
1341: case DMA_CCR:
1342: if (dmaHLT[i] != (d & DMA_HLT)) {
1343: dmaHalt (i, (d & DMA_HLT));
1344: }
1345: dmaITE[i] = d & DMA_ITE;
1346:
1347: if ((d & DMA_CNT) != 0) {
1348: if ((dmaACT[i] == 0 && (d & DMA_STR) == 0) || dmaBLC[i] != 0) {
1349: dmaErrorExit (i, DMA_TIMING_ERROR);
1350: return;
1351: }
1352: if (dmaCHAIN[i] != DMA_NO_CHAINING) {
1353: dmaErrorExit (i, DMA_CONFIGURATION_ERROR);
1354: return;
1355: }
1356: dmaCNT[i] = DMA_CNT;
1357: }
1358:
1359: if ((d & DMA_SAB) != 0) {
1360:
1361: dmaCOC[i] = 0;
1362: dmaBLC[i] = 0;
1363: dmaNDT[i] = 0;
1364: dmaHLT[i] = 0;
1365: dmaCNT[i] = 0;
1366: if (dmaACT[i] != 0 || (d & DMA_STR) != 0) {
1367: dmaErrorExit (i, DMA_SOFTWARE_ABORT);
1368: }
1369: return;
1370: }
1371:
1372: if ((d & DMA_STR) != 0) {
1373: dmaStart (i);
1374: }
1375: return;
1376: case DMA_MTC:
1377: if (dmaACT[i] != 0) {
1378: dmaErrorExit (i, DMA_TIMING_ERROR);
1379: return;
1380: }
1381: dmaMTC[i] = d << 8 | (dmaMTC[i] & 0xff);
1382: return;
1383: case DMA_MTC + 1:
1384: if (dmaACT[i] != 0) {
1385: dmaErrorExit (i, DMA_TIMING_ERROR);
1386: return;
1387: }
1388: dmaMTC[i] = (dmaMTC[i] & ~0xff) | d;
1389: return;
1390: case DMA_MAR:
1391: if (dmaACT[i] != 0) {
1392: dmaErrorExit (i, DMA_TIMING_ERROR);
1393: return;
1394: }
1395: dmaMAR[i] = d << 24 | (dmaMAR[i] & ~(0xff << 24));
1396: return;
1397: case DMA_MAR + 1:
1398: if (dmaACT[i] != 0) {
1399: dmaErrorExit (i, DMA_TIMING_ERROR);
1400: return;
1401: }
1402: dmaMAR[i] = d << 16 | (dmaMAR[i] & ~(0xff << 16));
1403: return;
1404: case DMA_MAR + 2:
1405: if (dmaACT[i] != 0) {
1406: dmaErrorExit (i, DMA_TIMING_ERROR);
1407: return;
1408: }
1409: dmaMAR[i] = (dmaMAR[i] & ~(0xff << 8)) | d << 8;
1410: return;
1411: case DMA_MAR + 3:
1412: if (dmaACT[i] != 0) {
1413: dmaErrorExit (i, DMA_TIMING_ERROR);
1414: return;
1415: }
1416: dmaMAR[i] = (dmaMAR[i] & ~0xff) | d;
1417: return;
1418: case DMA_DAR:
1419: if (dmaACT[i] != 0) {
1420: dmaErrorExit (i, DMA_TIMING_ERROR);
1421: return;
1422: }
1423: dmaDAR[i] = d << 24 | (dmaDAR[i] & ~(0xff << 24));
1424: return;
1425: case DMA_DAR + 1:
1426: if (dmaACT[i] != 0) {
1427: dmaErrorExit (i, DMA_TIMING_ERROR);
1428: return;
1429: }
1430: dmaDAR[i] = d << 16 | (dmaDAR[i] & ~(0xff << 16));
1431: return;
1432: case DMA_DAR + 2:
1433: if (dmaACT[i] != 0) {
1434: dmaErrorExit (i, DMA_TIMING_ERROR);
1435: return;
1436: }
1437: dmaDAR[i] = (dmaDAR[i] & ~(0xff << 8)) | d << 8;
1438: return;
1439: case DMA_DAR + 3:
1440: if (dmaACT[i] != 0) {
1441: dmaErrorExit (i, DMA_TIMING_ERROR);
1442: return;
1443: }
1444: dmaDAR[i] = (dmaDAR[i] & ~0xff) | d;
1445: return;
1446: case DMA_BTC:
1447: dmaBTC[i] = d << 8 | (dmaBTC[i] & 0xff);
1448: return;
1449: case DMA_BTC + 1:
1450: dmaBTC[i] = (dmaBTC[i] & ~0xff) | d;
1451: return;
1452: case DMA_BAR:
1453: dmaBAR[i] = d << 24 | (dmaBAR[i] & ~(0xff << 24));
1454: return;
1455: case DMA_BAR + 1:
1456: dmaBAR[i] = d << 16 | (dmaBAR[i] & ~(0xff << 16));
1457: return;
1458: case DMA_BAR + 2:
1459: dmaBAR[i] = (dmaBAR[i] & ~(0xff << 8)) | d << 8;
1460: return;
1461: case DMA_BAR + 3:
1462: dmaBAR[i] = (dmaBAR[i] & ~0xff) | d;
1463: return;
1464: case DMA_NIV:
1465: dmaNIV[i] = d;
1466: return;
1467: case DMA_EIV:
1468: dmaEIV[i] = d;
1469: return;
1470: case DMA_MFC:
1471: if (dmaACT[i] != 0) {
1472: dmaErrorExit (i, DMA_TIMING_ERROR);
1473: return;
1474: }
1475: dmaMFC[i] = d & DMA_FC2;
1476: if (DataBreakPoint.DBP_ON) {
1477: dmaMFCMap[i] = dmaMFC[i] == 0 ? DataBreakPoint.dbpUserMap : DataBreakPoint.dbpSuperMap;
1478: } else {
1479: dmaMFCMap[i] = dmaMFC[i] == 0 ? XEiJ.busUserMap : XEiJ.busSuperMap;
1480: }
1481: return;
1482: case DMA_CPR:
1483: dmaCP[i] = d & DMA_CP;
1484: return;
1485: case DMA_DFC:
1486: if (dmaACT[i] != 0) {
1487: dmaErrorExit (i, DMA_TIMING_ERROR);
1488: return;
1489: }
1490: dmaDFC[i] = d & DMA_FC2;
1491: if (DataBreakPoint.DBP_ON) {
1492: dmaDFCMap[i] = dmaDFC[i] == 0 ? DataBreakPoint.dbpUserMap : DataBreakPoint.dbpSuperMap;
1493: } else {
1494: dmaDFCMap[i] = dmaDFC[i] == 0 ? XEiJ.busUserMap : XEiJ.busSuperMap;
1495: }
1496: return;
1497: case DMA_BFC:
1498: dmaBFC[i] = d & DMA_FC2;
1499: if (DataBreakPoint.DBP_ON) {
1500: dmaBFCMap[i] = dmaBFC[i] == 0 ? DataBreakPoint.dbpUserMap : DataBreakPoint.dbpSuperMap;
1501: } else {
1502: dmaBFCMap[i] = dmaBFC[i] == 0 ? XEiJ.busUserMap : XEiJ.busSuperMap;
1503: }
1504: return;
1505: default:
1506: return;
1507: }
1508: }
1509:
1510: public static void dmaWriteWord (int a, int d) {
1511: d = (char) d;
1512: int al = a & 0xff;
1513: int i = al >> 6;
1514: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1515: System.out.printf ("%d %08x dmaWw(0x%08x,0x%04x)\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1516: }
1517: switch (al & 0x3f) {
1518: case DMA_MTC:
1519: if (dmaACT[i] != 0) {
1520: dmaErrorExit (i, DMA_TIMING_ERROR);
1521: } else {
1522: dmaMTC[i] = d;
1523: }
1524: return;
1525: case DMA_MAR:
1526: if (dmaACT[i] != 0) {
1527: dmaErrorExit (i, DMA_TIMING_ERROR);
1528: } else {
1529: dmaMAR[i] = d << 16 | (char) dmaMAR[i];
1530: }
1531: return;
1532: case DMA_MAR + 2:
1533: if (dmaACT[i] != 0) {
1534: dmaErrorExit (i, DMA_TIMING_ERROR);
1535: } else {
1536: dmaMAR[i] = (dmaMAR[i] & ~0xffff) | d;
1537: }
1538: return;
1539: case DMA_DAR:
1540: if (dmaACT[i] != 0) {
1541: dmaErrorExit (i, DMA_TIMING_ERROR);
1542: } else {
1543: dmaDAR[i] = d << 16 | (char) dmaDAR[i];
1544: }
1545: return;
1546: case DMA_DAR + 2:
1547: if (dmaACT[i] != 0) {
1548: dmaErrorExit (i, DMA_TIMING_ERROR);
1549: } else {
1550: dmaDAR[i] = (dmaDAR[i] & ~0xffff) | d;
1551: }
1552: return;
1553: case DMA_BTC:
1554: dmaBTC[i] = (char) d;
1555: return;
1556: case DMA_BAR:
1557: dmaBAR[i] = d << 16 | (char) dmaBAR[i];
1558: return;
1559: case DMA_BAR + 2:
1560: dmaBAR[i] = (dmaBAR[i] & ~0xffff) | d;
1561: return;
1562: default:
1563: dmaWriteByte (a, d >> 8);
1564: dmaWriteByte (a + 1, d);
1565: }
1566: }
1567:
1568: public static void dmaWriteLong (int a, int d) {
1569: int al = a & 0xff;
1570: int i = al >> 6;
1571: if (DMA_DEBUG_TRACE != 0 && (DMA_DEBUG_TRACE & 1 << i) != 0) {
1572: System.out.printf ("%d %08x dmaWl(0x%08x,0x%08x)\n", XEiJ.mpuClockTime, XEiJ.regPC0, a, d);
1573: }
1574: switch (al & 0x3f) {
1575: case DMA_MAR:
1576: if (dmaACT[i] != 0) {
1577: dmaErrorExit (i, DMA_TIMING_ERROR);
1578: } else {
1579: dmaMAR[i] = d;
1580: if (DMA_ALERT_HIMEM) {
1581: if ((d & 0xff000000) != 0 && Model.MPU_MC68020 <= XEiJ.currentMPU) {
1582: System.out.printf ("%08x DMA_MAR[%d]=%08X\n", XEiJ.regPC0, i, d);
1583: }
1584: }
1585: }
1586: return;
1587: case DMA_DAR:
1588: if (dmaACT[i] != 0) {
1589: dmaErrorExit (i, DMA_TIMING_ERROR);
1590: } else {
1591: dmaDAR[i] = d;
1592: if (DMA_ALERT_HIMEM) {
1593: if ((d & 0xff000000) != 0 && Model.MPU_MC68020 <= XEiJ.currentMPU) {
1594: System.out.printf ("%08x DMA_DAR[%d]=%08X\n", XEiJ.regPC0, i, d);
1595: }
1596: }
1597: }
1598: return;
1599: case DMA_BAR:
1600: dmaBAR[i] = d;
1601: if (DMA_ALERT_HIMEM) {
1602: if ((d & 0xff000000) != 0 && Model.MPU_MC68020 <= XEiJ.currentMPU) {
1603: System.out.printf ("%08x DMA_BAR[%d]=%08X\n", XEiJ.regPC0, i, d);
1604: }
1605: }
1606: return;
1607: default:
1608: dmaWriteWord (a, d >> 16);
1609: dmaWriteWord (a + 2, d);
1610: }
1611: }
1612:
1613:
1614:
1615: }
1616:
1617:
1618: