--- nono/host/hostcom.cpp 2026/04/29 17:05:30 1.1.1.4 +++ nono/host/hostcom.cpp 2026/04/29 17:05:39 1.1.1.6 @@ -12,14 +12,12 @@ // // VM thread : Host thread // -// 各シリアルデバイス::Tx() : -// | -// SerialDevice::Tx() : +// 各デバイス::Tx() : // | // HostCOMDevice::Tx() : HostDevice::ThreadRun // | -// +-------------->| queue |----+ -// +-------------->| pipe |----+ +// +-------------->| queue |----+ … 送信キューに追加し +// +-------------->| pipe |----+ … パイプでホストスレッドに通知 // | | // <-+ : v // --- kevent @@ -43,12 +41,17 @@ // : | // HostCOMDevice::Read() // | -// +---------------| queue |<---+ -// +---------------| event |<---+ +// | queue |<---+ … 受信キューに追加 +// ‖ +// ‖ HostCOMDevice::*(rx_func)() +// | +// +-------------| Message |<---+ … メッセージで VM スレッドに通知 // v -// SerialDevice::Callback() -// | -// 各シリアルデバイス::Rx() +// 各デバイス::RxMessage() ‖ … メッセージコールバック +// | ‖ +// 各デバイス::Rx() ‖ … イベントコールバック +// | ‖ +// HostCOMDevice::Rx() <==++ … ここで queue から読み出す // ログ名 // MPSCC HostDevice COMDriver @@ -63,11 +66,13 @@ #include "hostcom.h" +#include "comdriver_cons.h" #include "comdriver_none.h" #include "comdriver_stdio.h" #include "comdriver_tcp.h" #include "config.h" #include "mainapp.h" +#include "monitor.h" // コンストラクタ // @@ -89,9 +94,9 @@ HostCOMDevice::HostCOMDevice(Device *par // のログレベルは独立。 // モニタは hostcom* のみ必要。 - monitor.func = ToMonitorCallback(&HostCOMDevice::MonitorUpdate); - monitor.SetSize(30, 17); - monitor.Regist(ID_MONITOR_HOSTCOM); + monitor = gMonitorManager->Regist(ID_MONITOR_HOSTCOM, this); + monitor->func = ToMonitorCallback(&HostCOMDevice::MonitorUpdate); + monitor->SetSize(30, 17); } } @@ -111,11 +116,11 @@ HostCOMDevice::SetLogLevel(int loglevel_ } } -// 初期化 +// 動的コンストラクションその2 bool -HostCOMDevice::Init() +HostCOMDevice::Create2() { - if (inherited::Init() == false) { + if (inherited::Create2() == false) { return false; } @@ -167,6 +172,19 @@ HostCOMDevice::SelectDriver() if ((bool)driver && driver->InitDriver() == false) { driver.reset(); } + + } else if (type == "cons") { + // console デバイスのいない機種では指定出来ない。 + if (gMainApp.FindObject(OBJ_CONSOLE) == NULL) { + item.Err("cannot be specified on vmtype=%s", + gMainApp.GetVMTypeStr().c_str()); + return false; + } + + driver.reset(new COMDriverCons(this)); + if ((bool)driver && driver->InitDriver() == false) { + driver.reset(); + } } else { // 知らないドライバ種別