2016-02-04 10:29:08 +00:00
|
|
|
auto CPU::dmaTransfer() -> void {
|
|
|
|
//length of 0 or SRAM source address cause immediate termination
|
2016-02-04 21:18:06 +00:00
|
|
|
if(r.dmaLength == 0 || r.dmaSource.b2 == 1) {
|
|
|
|
r.dmaEnable = false;
|
2016-02-04 10:29:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wait(5);
|
2016-02-04 21:18:06 +00:00
|
|
|
while(r.dmaLength) {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(2);
|
|
|
|
uint16 data = 0;
|
|
|
|
//once DMA is started; SRAM reads still incur time penalty, but do not transfer
|
2016-02-04 21:18:06 +00:00
|
|
|
if(r.dmaSource.b2 != 1) {
|
|
|
|
data |= read(r.dmaSource + 0) << 0;
|
|
|
|
data |= read(r.dmaSource + 1) << 8;
|
|
|
|
write(r.dmaTarget + 0, data >> 0);
|
|
|
|
write(r.dmaTarget + 1, data >> 8);
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
2016-02-04 21:18:06 +00:00
|
|
|
if(r.dmaMode == 0) {
|
|
|
|
r.dmaSource += 2;
|
|
|
|
r.dmaTarget += 2;
|
2016-02-04 10:29:08 +00:00
|
|
|
} else {
|
2016-02-04 21:18:06 +00:00
|
|
|
r.dmaSource -= 2;
|
|
|
|
r.dmaTarget -= 2;
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
2016-02-04 21:18:06 +00:00
|
|
|
r.dmaLength -= 2;
|
2016-02-04 10:29:08 +00:00
|
|
|
};
|
2016-02-04 21:18:06 +00:00
|
|
|
r.dmaEnable = false;
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|