--- nono/vm/sio.cpp 2026/04/29 17:05:13 1.1.1.10 +++ nono/vm/sio.cpp 2026/04/29 17:05:17 1.1.1.11 @@ -14,14 +14,14 @@ #include "keyboard.h" #include "mainapp.h" -// グローバル参照用 -SIODevice *gSIO; - // コンストラクタ SIODevice::SIODevice() - : inherited("SIO") + : inherited() { - devaddr = 0x51000000; + SetName("SIO"); + ClearAlias(); + AddAlias("SIO"); + AddAlias("MPSCC"); mpscc.chan[0].desc = "Serial Console"; mpscc.chan[1].desc = "Keyboard"; @@ -30,7 +30,7 @@ SIODevice::SIODevice() // デバイス自身は自分が配置されるアドレスを知らなくてよい構造になって // いるが、直接アクセスしたりする場合などに毎回アドレスを確認するのが // 面倒なので(全機種で向きと間隔が異なる)、モニタで表示されてほしい。 - if (gMainApp.GetVMType() == VMType::LUNA1) { + if (gMainApp.IsLUNA1()) { mpscc.chan[0].dataaddr = 0x51000000; mpscc.chan[0].ctrladdr = 0x51000002; mpscc.chan[1].dataaddr = 0x51000004; @@ -63,7 +63,19 @@ SIODevice::SIODevice() // デストラクタ SIODevice::~SIODevice() { - gSIO = NULL; +} + +// 初期化 +bool +SIODevice::Init() +{ + if (inherited::Init() == false) { + return false; + } + + keyboard = GetKeyboard(); + + return true; } // リセット @@ -142,7 +154,7 @@ SIODevice::Read(uint32 offset) data = ReadCtrl(mpscc.chan[1]); break; default: - __unreachable(); + VMPANIC("corrupted offset=%d", offset); } return data; } @@ -164,7 +176,7 @@ SIODevice::Write(uint32 offset, uint32 d WriteCtrl(mpscc.chan[1], data); break; default: - __unreachable(); + VMPANIC("corrupted offset=%d", offset); } return 0; } @@ -188,7 +200,8 @@ SIODevice::Peek(uint32 offset) data = PeekCtrl(mpscc.chan[1]); break; default: - __unreachable(); + data = 0xff; + break; } return data; } @@ -335,7 +348,7 @@ SIODevice::WriteCtrl(MPSCCChan& chan, ui WriteCR7(chan, data); break; default: - __unreachable(); + VMPANIC("corrupted chan.ptr=%d", chan.ptr); } // アクセス後は CR0 へ戻す chan.ptr = 0; @@ -497,7 +510,7 @@ SIODevice::WriteCR0(MPSCCChan& chan, uin } break; default: - __unreachable(); + VMPANIC("corrupted chan.cmd=%d", chan.cmd); } } @@ -756,7 +769,7 @@ SIODevice::MonitorUpdateCh(TextScreen& s screen.Print(x, y++, "DataAddr: $%08x", chan.dataaddr); screen.Print(x, y++, "CtrlAddr: $%08x", chan.ctrladdr); y++; - screen.Print(x, y++, "Param: %12s", GetParamStr(chan).c_str()); + screen.Print(x, y++, "Param:%13s", GetParamStr(chan).c_str()); screen.Print(x, y++, "Rx Bits/Frame: %2d", chan.rxframebits); screen.Print(x, y++, "Tx Bits/Frame: %2d", chan.txframebits); } @@ -809,10 +822,10 @@ SIODevice::Tx(int ch, uint32 data) hostcom->Tx(data); break; case 1: - gKeyboard->Command(data); + keyboard->Command(data); break; default: - __unreachable(); + VMPANIC("corrupted ch=%d", ch); } }