--- nono/vm/mpscc.h 2026/04/29 17:05:13 1.1.1.2 +++ nono/vm/mpscc.h 2026/04/29 17:05:59 1.1.1.9 @@ -11,9 +11,7 @@ #pragma once #include "device.h" -#include "event.h" #include "message.h" -#include "monitor.h" #include #if defined(MPSCC_SIO_LOG_HACK) @@ -29,13 +27,14 @@ #endif class HostCOMDevice; +class InterruptDevice; // 1チャンネル分の共通部分 -class MPSCCChan +class MPSCCChan final { public: MPSCCChan(); - virtual ~MPSCCChan(); + ~MPSCCChan(); void Init(int id_); @@ -95,13 +94,13 @@ class MPSCCChan // これらのレジスタは uPD7201/Z8530 で共通 // CR3/WR3 付近 - int rxbits {}; // 受信データビット数 (レジスタ値ではない) + uint rxbits {}; // 受信データビット数 (レジスタ値ではない) uint8 cr3_sync {}; // SyncMode でだけ使う bit4-1 を保存 bool auto_enable {}; bool rx_enable {}; // CR4/WR4 付近 - int clkrate {}; // クロック倍率 (レジスタ値ではない) + uint clkrate {}; // クロック倍率 (レジスタ値ではない) uint8 syncmode {}; // bit5,4 を保存 uint8 stopbits {}; // STOPBITS_* bool parity_even {}; @@ -109,7 +108,7 @@ class MPSCCChan // CR5/WR5 付近 bool nDTR {}; // ~DTR - int txbits {}; // 送信データビット数 (レジスタ値ではない) + uint txbits {}; // 送信データビット数 (レジスタ値ではない) bool sendbreak {}; bool tx_enable {}; bool crc16 {}; @@ -174,16 +173,16 @@ class MPSCCChan double baudrate {}; // 1フレームあたりの送受信のビット数 (表示用) - int txframebits {}; - int rxframebits {}; + uint txframebits {}; + uint rxframebits {}; // LUNA の場合は TxC, RxC ピンに供給されているクロック。 // X68030 の場合は Z8530 内部で生成されている基準クロック。 - // 誤差を減らすため 12 ビット分の時間 [nsec] としている。 - uint64 xc12_ns {}; + // 誤差を減らすため 12 ビット分の時間 [tsec] としている。 + uint64 xc12_tsec {}; - // 実際の 12 ビットの通信にかかる時間。xc12_ns に倍率をかけたもの。 - uint64 bit12_ns {}; + // 実際の 12 ビットの通信にかかる時間。xc12_tsec に倍率をかけたもの。 + uint64 bit12_tsec {}; }; class MPSCC @@ -510,7 +509,7 @@ class MPSCCDevice : public IODevice static const int COM_CH = 0; public: - MPSCCDevice(const std::string& objname_); + MPSCCDevice(); ~MPSCCDevice() override; bool Create() override; @@ -522,8 +521,8 @@ class MPSCCDevice : public IODevice protected: // 指定のレジスタ名を返す - virtual const char *CRName(const MPSCCChan&, int n) const = 0; - virtual const char *SRName(const MPSCCChan&, int n) const = 0; + virtual const char *CRName(const MPSCCChan&, uint n) const = 0; + virtual const char *SRName(const MPSCCChan&, uint n) const = 0; // 現在のレジスタ名を返す const char *CRName(const MPSCCChan& chan) const { return CRName(chan, chan.ptr); @@ -535,6 +534,10 @@ class MPSCCDevice : public IODevice // チャンネルリセットの共通部 void ResetChannelCommon(MPSCCChan&); + // BusIO インタフェース + static const uint32 NPORT = 4; + bool PokePort(uint32 offset, uint32 data); + // レジスタアクセス static uint8 GetCR0(const MPSCCChan&); static void SetCR3(MPSCCChan&, uint32 data); @@ -565,15 +568,15 @@ class MPSCCDevice : public IODevice virtual void Tx(int ch, uint32 data) = 0; // シリアルから1バイト受信のメッセージとイベントコールバック - void HostRxCallback(); - void RxMessageCallback(MessageID, uint32); - void RxCallback(Event&); + void HostRxCallback(uint32); + void RxMessage(MessageID, uint32); + void RxCallback(Event *); // 送受信関連 void TrySend(MPSCCChan&); void SetTxPeriod(MPSCCChan&); void SetRxPeriod(MPSCCChan&); - void TxCallback(Event&); + void TxCallback(Event *); // 割り込み void ChangeInterrupt(); @@ -589,25 +592,27 @@ class MPSCCDevice : public IODevice int GetStopBits(MPSCCChan&, bool enable); // モニタの下請け - int MonitorUpdateCR345(TextScreen&, int x, int y, uint8, uint8, uint8); - void MonitorUpdateSR1(TextScreen&, int x, int y, uint8 sr1); + int MonitorScreenCR345(TextScreen&, int x, int y, uint8, uint8, uint8); + void MonitorScreenSR1(TextScreen&, int x, int y, uint8 sr1); void MonitorReg(TextScreen&, int x, int y, uint32 reg, const char * const *names); MPSCC mpscc {}; // 送受信用イベント - std::array txevent {}; - std::array rxevent {}; + std::array txevent {}; + std::array rxevent {}; // シリアルポート。 // 本当は共通層でやることではないがどう考えても同じコードになるので。 std::unique_ptr hostcom /*{}*/; - // モニタ (更新関数は継承側で用意する) - Monitor monitor { this }; - // SR0 のログ対策 (sio.cpp::ReadCtrl 参照) int sr0_logphase {}; uint32 sr0_lastread {}; + + InterruptDevice *interrupt {}; + + // モニタ + Monitor *monitor {}; };