--- nono/vm/dmac.cpp 2026/04/29 17:04:32 1.1.1.2 +++ nono/vm/dmac.cpp 2026/04/29 17:04:35 1.1.1.3 @@ -1,9 +1,12 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #include "dmac.h" +#include "bus.h" +#include "mpu680x0.h" #include "mystring.h" std::unique_ptr gDMAC; @@ -39,14 +42,14 @@ DMACDevice::~DMACDevice() } uint64 -DMACDevice::Read8(uint32 addr) +DMACDevice::Read(uint32 addr) { uint8 data; int ch; - ch = (addr - baseaddr) / 0x40; + ch = addr / 0x40; DMAC::Channel *chan = &dmac.chan[ch]; - int n = (addr - baseaddr) % 0x40; + int n = addr % 0x40; switch (n) { case DMAC::CSR: data = chan->PeekCSR(); @@ -196,13 +199,13 @@ DMACDevice::Read8(uint32 addr) } uint64 -DMACDevice::Write8(uint32 addr, uint32 data) +DMACDevice::Write(uint32 addr, uint32 data) { int ch; - ch = (addr - baseaddr) / 0x40; + ch = addr / 0x40; DMAC::Channel *chan = &dmac.chan[ch]; - int n = (addr - baseaddr) % 0x40; + int n = addr % 0x40; switch (n) { case DMAC::CSR: chan->WriteCSR(data); @@ -345,14 +348,14 @@ DMACDevice::Write8(uint32 addr, uint32 d } uint64 -DMACDevice::Peek8(uint32 addr) +DMACDevice::Peek(uint32 addr) { uint8 data; int ch; - ch = (addr - baseaddr) / 0x40; + ch = addr / 0x40; const DMAC::Channel *chan = &dmac.chan[ch]; - int n = (addr - baseaddr) % 0x40; + int n = addr % 0x40; switch (n) { case DMAC::CSR: data = chan->PeekCSR(); @@ -481,32 +484,32 @@ DMACDevice::MonitorUpdate() monitor.Clear(); y = 1; - monitor.Print(0, y++, "CSR"); + monitor.Puts(0, y++, "CSR"); y += 2; - monitor.Print(0, y++, "CER"); - monitor.Print(0, y++, "DCR:XRM"); - monitor.Print(0, y++, "DCR:DTYP"); - monitor.Print(0, y++, "DCR:DPS"); - monitor.Print(0, y++, "DCR:PCL"); - monitor.Print(0, y++, "OCR:DIR"); - monitor.Print(0, y++, "OCR:SIZE"); - monitor.Print(0, y++, "OCR:CHAIN"); - monitor.Print(0, y++, "OCR:REQG"); - monitor.Print(0, y++, "SCR:MAC"); - monitor.Print(0, y++, "SCR:DAC"); - monitor.Print(0, y++, "CCR"); + monitor.Puts(0, y++, "CER"); + monitor.Puts(0, y++, "DCR:XRM"); + monitor.Puts(0, y++, "DCR:DTYP"); + monitor.Puts(0, y++, "DCR:DPS"); + monitor.Puts(0, y++, "DCR:PCL"); + monitor.Puts(0, y++, "OCR:DIR"); + monitor.Puts(0, y++, "OCR:SIZE"); + monitor.Puts(0, y++, "OCR:CHAIN"); + monitor.Puts(0, y++, "OCR:REQG"); + monitor.Puts(0, y++, "SCR:MAC"); + monitor.Puts(0, y++, "SCR:DAC"); + monitor.Puts(0, y++, "CCR"); y += 2; - monitor.Print(0, y++, "MTC"); - monitor.Print(0, y++, "MAR"); - monitor.Print(0, y++, "DAR"); - monitor.Print(0, y++, "BTC"); - monitor.Print(0, y++, "BAR"); - monitor.Print(0, y++, "NIV"); - monitor.Print(0, y++, "EIV"); - monitor.Print(0, y++, "MFC"); - monitor.Print(0, y++, "CPR"); - monitor.Print(0, y++, "DFC"); - monitor.Print(0, y++, "BFC"); + monitor.Puts(0, y++, "MTC"); + monitor.Puts(0, y++, "MAR"); + monitor.Puts(0, y++, "DAR"); + monitor.Puts(0, y++, "BTC"); + monitor.Puts(0, y++, "BAR"); + monitor.Puts(0, y++, "NIV"); + monitor.Puts(0, y++, "EIV"); + monitor.Puts(0, y++, "MFC"); + monitor.Puts(0, y++, "CPR"); + monitor.Puts(0, y++, "DFC"); + monitor.Puts(0, y++, "BFC"); for (int ch = 0; ch < 4; ch++) { DMAC::Channel *chan = &dmac.chan[ch]; @@ -515,7 +518,7 @@ DMACDevice::MonitorUpdate() y = 0; // 地味だけど有効なチャンネルをハイライトしてみる - monitor.Print(x, y++, (chan->active ? TA::Em : TA::Off), + monitor.Print(x, y++, (chan->active ? TA::Em : TA::Normal), "#%d (%s)", chan->ch, chan->desc); // CSR @@ -691,8 +694,7 @@ DMACDevice::MonitorReg4(int x, int y, ui { for (int i = 0; i < 4; i++) { bool b = reg & (1 << (3 - i)); - uint attr = b ? TA::On : TA::Off; - monitor.Print(x + i * 4, y, attr, "%s", names[i]); + monitor.Puts(x + i * 4, y, TA::OnOff(b), names[i]); } } @@ -816,7 +818,7 @@ DMAC::Channel::SetINT(uint32 val) } else { vector = niv; } - gMPU680x0->Interrupt(3, vector); + gMPU680x0->Interrupt(parent, 3, vector); } }