fix: force align DMA transfers

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:53 -03:00
parent 665767c250
commit 0287c9a260
1 changed files with 4 additions and 2 deletions

View File

@ -182,10 +182,12 @@ fn DmaController(comptime id: u2) type {
const transfer_type = is_fifo or self.cnt.transfer_type.read();
const offset: u32 = if (transfer_type) @sizeOf(u32) else @sizeOf(u16);
const mask = if (transfer_type) ~@as(u32, 3) else ~@as(u32, 1);
if (transfer_type) {
cpu.bus.write(u32, self._dad, cpu.bus.read(u32, self._sad));
cpu.bus.write(u32, self._dad & mask, cpu.bus.read(u32, self._sad & mask));
} else {
cpu.bus.write(u16, self._dad, cpu.bus.read(u16, self._sad));
cpu.bus.write(u16, self._dad & mask, cpu.bus.read(u16, self._sad & mask));
}
switch (sad_adj) {