--- nono/vm/mpscc.cpp 2026/04/29 17:05:25 1.1.1.5 +++ nono/vm/mpscc.cpp 2026/04/29 17:05:38 1.1.1.8 @@ -22,6 +22,7 @@ #include "bitops.h" #include "hostcom.h" #include "interrupt.h" +#include "monitor.h" #include "scheduler.h" #include "syncer.h" #include @@ -65,18 +66,6 @@ MPSCCDevice::MPSCCDevice() for (int ch = 0; ch < mpscc.chan.size(); ch++) { auto& chan = mpscc.chan[ch]; chan.Init(ch); - - // time は SetTxPeriod() でセット。 - // 名前は継承先でセットする。機種ごとに名前を使い分けているため。 - txevent[ch].dev = this; - txevent[ch].func = ToEventCallback(&MPSCCDevice::TxCallback); - txevent[ch].code = ch; - txevent[ch].Regist(); - - rxevent[ch].dev = this; - rxevent[ch].func = ToEventCallback(&MPSCCDevice::RxCallback); - rxevent[ch].code = ch; - rxevent[ch].Regist(); } // モニタは継承先で設定する @@ -116,14 +105,25 @@ MPSCCDevice::SetLogLevel(int loglevel_) bool MPSCCDevice::Init() { - if (inherited::Init() == false) { - return false; - } - interrupt = GetInterruptDevice(); scheduler->ConnectMessage(MessageID::HOSTCOM_RX, this, ToMessageCallback(&MPSCCDevice::RxMessage)); + + for (int ch = 0; ch < mpscc.chan.size(); ch++) { + // time は SetTxPeriod() でセット。 + // 名前は継承先でセットする。機種ごとに名前を使い分けているため。 + txevent[ch].dev = this; + txevent[ch].func = ToEventCallback(&MPSCCDevice::TxCallback); + txevent[ch].code = ch; + scheduler->RegistEvent(txevent[ch]); + + rxevent[ch].dev = this; + rxevent[ch].func = ToEventCallback(&MPSCCDevice::RxCallback); + rxevent[ch].code = ch; + scheduler->RegistEvent(rxevent[ch]); + } + return true; } @@ -149,6 +149,12 @@ MPSCCDevice::ResetChannelCommon(MPSCCCha ChangeInterrupt(); } +bool +MPSCCDevice::PokePort(uint32 offset, uint32 data) +{ + return false; +} + // CR0/WR0 レジスタの内容を取得 // (値の取り出しだけなら共通) /*static*/ uint8 @@ -206,7 +212,7 @@ MPSCCDevice::GetCR3(const MPSCCChan& cha data |= MPSCC::RXBITS_8; break; default: - VMPANIC("corrupted chan.rxbits=%d", chan.rxbits); + VMPANIC("corrupted chan.rxbits=%u", chan.rxbits); } if (chan.auto_enable) { data |= MPSCC::CR3_AUTO_EN; @@ -264,7 +270,7 @@ MPSCCDevice::GetCR4(const MPSCCChan& cha data |= MPSCC::CLKRATE_64; break; default: - VMPANIC("corrupted chan.clkrate=%d", chan.clkrate); + VMPANIC("corrupted chan.clkrate=%u", chan.clkrate); } data |= chan.syncmode; data |= chan.stopbits << 2; @@ -326,7 +332,7 @@ MPSCCDevice::GetCR5(const MPSCCChan& cha data |= MPSCC::TXBITS_8; break; default: - VMPANIC("corrupted chan.txbits=%d", chan.txbits); + VMPANIC("corrupted chan.txbits=%u", chan.txbits); } if (chan.nDTR) { data |= MPSCC::CR5_nDTR; @@ -395,10 +401,10 @@ MPSCCDevice::GetSR2B() const stat = 3; // VIS_321 とはビット順が逆 data &= ~0x70; - data |= bitrev(stat << 1); + data |= bitrev8(stat << 1); break; default: - VMPANIC("corrupted mpscc.vis=%d", (int)mpscc.vis); + VMPANIC("corrupted mpscc.vis=%u", (uint)mpscc.vis); } return data; @@ -517,7 +523,7 @@ MPSCCDevice::WriteCR4(MPSCCChan& chan, u putlog(2, "Channel %c Synchronous mode not supported", chan.name); } else { const char *sm[] = { "?", "1", "1.5", "2" }; - putlog(2, "Channel %c Async Mode (x%d clock, stopbit %s)", + putlog(2, "Channel %c Async Mode (x%u clock, stopbit %s)", chan.name, chan.clkrate, sm[chan.stopbits]); @@ -822,7 +828,7 @@ MPSCCDevice::GetStopBits(MPSCCChan& chan void MPSCCDevice::SetRxPeriod(MPSCCChan& chan) { - int bit; + uint bit; // 受信データビット数 bit = chan.rxbits; @@ -853,7 +859,7 @@ MPSCCDevice::SetRxPeriod(MPSCCChan& chan if (loglevel >= 2) { nsstr = string_format(" (%" PRIu64 ")", chan.bit12_ns); } - putlogn("Channel %c RX Enable, %.1f bps%s, %d bits/frame", + putlogn("Channel %c RX Enable, %.1f bps%s, %u bits/frame", chan.name, chan.baudrate, nsstr.c_str(), @@ -887,7 +893,7 @@ MPSCCDevice::SetRxPeriod(MPSCCChan& chan void MPSCCDevice::SetTxPeriod(MPSCCChan& chan) { - int bit; + uint bit; // 送信データビット数 bit = chan.txbits; @@ -918,7 +924,7 @@ MPSCCDevice::SetTxPeriod(MPSCCChan& chan if (loglevel >= 2) { nsstr = string_format(" (%" PRIu64 ")", chan.bit12_ns); } - putlogn("Channel %c TX Enable, %.1f bps%s, %d bits/frame", + putlogn("Channel %c TX Enable, %.1f bps%s, %u bits/frame", chan.name, chan.baudrate, nsstr.c_str(),