2015-11-16 08:38:05 +00:00
|
|
|
auto MMIO::read(uint mode, uint32 addr) -> uint32 {
|
2012-04-03 00:47:28 +00:00
|
|
|
uint32 word = 0;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
2012-04-03 00:47:28 +00:00
|
|
|
addr &= ~3;
|
|
|
|
word |= read(addr + 0) << 0;
|
|
|
|
word |= read(addr + 1) << 8;
|
|
|
|
word |= read(addr + 2) << 16;
|
|
|
|
word |= read(addr + 3) << 24;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Half) {
|
2012-04-03 00:47:28 +00:00
|
|
|
addr &= ~1;
|
|
|
|
word |= read(addr + 0) << 0;
|
|
|
|
word |= read(addr + 1) << 8;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Byte) {
|
2012-04-03 00:47:28 +00:00
|
|
|
word |= read(addr + 0) << 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return word;
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto MMIO::write(uint mode, uint32 addr, uint32 word) -> void {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
2012-04-03 00:47:28 +00:00
|
|
|
addr &= ~3;
|
|
|
|
write(addr + 0, word >> 0);
|
|
|
|
write(addr + 1, word >> 8);
|
|
|
|
write(addr + 2, word >> 16);
|
|
|
|
write(addr + 3, word >> 24);
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Half) {
|
2012-04-03 00:47:28 +00:00
|
|
|
addr &= ~1;
|
|
|
|
write(addr + 0, word >> 0);
|
|
|
|
write(addr + 1, word >> 8);
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Byte) {
|
2012-04-03 00:47:28 +00:00
|
|
|
write(addr + 0, word >> 0);
|
|
|
|
}
|
|
|
|
}
|