mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-09 04:24:58 +00:00
Mapping the DMA's channels to the bus
This commit is contained in:
@@ -3,3 +3,57 @@
|
||||
//
|
||||
|
||||
#include "DMA.hpp"
|
||||
#include "../../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
namespace ComSquare::CPU
|
||||
{
|
||||
uint8_t DMA::read(uint8_t addr)
|
||||
{
|
||||
switch (addr) {
|
||||
case 0x0:
|
||||
return this->controlRegister.raw;
|
||||
case 0x1:
|
||||
return this->port;
|
||||
case 0x2:
|
||||
return this->aAddress.bytes[0];
|
||||
case 0x3:
|
||||
return this->aAddress.bytes[1];
|
||||
case 0x4:
|
||||
return this->aAddress.bytes[2];
|
||||
case 0x5:
|
||||
return this->count.bytes[0];
|
||||
case 0x6:
|
||||
return this->count.bytes[1];
|
||||
default:
|
||||
throw InvalidAddress("DMA read", addr);
|
||||
}
|
||||
}
|
||||
|
||||
void DMA::write(uint8_t addr, uint8_t data)
|
||||
{
|
||||
switch (addr) {
|
||||
case 0x0:
|
||||
this->controlRegister.raw = data;
|
||||
break;
|
||||
case 0x1:
|
||||
this->port = data;
|
||||
break;
|
||||
case 0x2:
|
||||
this->aAddress.bytes[0] = data;
|
||||
break;
|
||||
case 0x3:
|
||||
this->aAddress.bytes[1] = data;
|
||||
case 0x4:
|
||||
this->aAddress.bytes[2] = data;
|
||||
break;
|
||||
case 0x5:
|
||||
this->count.bytes[0] = data;
|
||||
break;
|
||||
case 0x6:
|
||||
this->count.bytes[1] = data;
|
||||
break;
|
||||
default:
|
||||
throw InvalidAddress("DMA read", addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user