--- nono/lib/config.cpp 2026/04/29 17:05:39 1.1.1.18 +++ nono/lib/config.cpp 2026/04/29 17:05:57 1.1.1.21 @@ -37,8 +37,6 @@ Config::Config() // デバッガコンソール Add("debugger-driver", "none"); Add("debugger-tcp-port", 0); - // デバッガコンソールの fallback は常に不可とする。hostcom.cpp 参照。 - // "debugger-fallback" // DIPSW エイリアス Add("dipsw-autoboot", "", VMCap::LUNA | VMCap::NEWS); @@ -78,22 +76,30 @@ Config::Config() Add("fast-mode", "0"); // ホスト CPU アクセラレーション。 - Add("host-avx2", "auto"); - Add("host-neon", "auto"); + // host-* の方は少しの間残しておくがそのうち消す。 + Add("hostcpu-avx2", "auto"); + Add("hostcpu-neon", "auto"); + AddObsolete("host-avx2", "hostcpu-avx2"); + AddObsolete("host-neon", "hostcpu-neon"); + + // ホスト CPU の高性能コア指定。 + Add("hostcpu-fastcore", "auto"); + // 古い隠しオプションのほうは使われたらエラーを出す。 + // こっちは単なる読み替えではないため AddObsolete() ではない。 + Add(".host-cpu-affinity", "obsolete"); + + // シリアルポートのホスト側設定。 + Add("hostcom0-driver", "none"); + Add("hostcom0-tcp-port", 9998); - // CPU アフィニティ (解釈が複雑すぎるので隠しオプション)。 - // "" … 指定しない - // auto … 予約。現状は "" と同じ。 - // low: … Light スレッドを の CPU に割り付ける。 - // high: … Heavy スレッドを の CPU に割り付ける。 - // perf: … Heavy スレッドを の CPU に、 - // Light スレッドをその反集合の CPU に割り付ける。 - Add(".host-cpu-affinity", "auto"); - - // シリアルポートのホスト側設定 - Add("hostcom-driver", "none"); - Add("hostcom-fallback", 0); - Add("hostcom-tcp-port", 9998); + Add("hostcom1-driver", "none", VMCap::LUNA); + Add("hostcom1-tcp-port", 9997, VMCap::LUNA); + + Add("hostcom2-driver", "none", VMCap::LUNA); + Add("hostcom2-tcp-port", 9996, VMCap::LUNA); + + AddAlias("hostcom-driver", "hostcom0-driver"); + AddAlias("hostcom-tcp-port", "hostcom0-tcp-port"); // キーボードの入力モード Add("hostkbd-input", "char", VMCap::LUNA | VMCap::X68030); @@ -101,7 +107,6 @@ Config::Config() // ネットワークのホスト側設定。 // (0 と 1 で -driver の初期値が違う) Add("hostnet0-driver", "auto"); - Add("hostnet0-fallback", 0); Add("hostnet0-afpacket-ifname", "auto"); Add("hostnet0-bpf-ifname", "auto"); Add("hostnet0-tap-devpath", "auto"); @@ -110,7 +115,6 @@ Config::Config() Add("hostnet0-usermode-net6", "fd08::/64"); Add("hostnet1-driver", "none", VMCap::X68030); - Add("hostnet1-fallback", 0, VMCap::X68030); Add("hostnet1-afpacket-ifname", "auto", VMCap::X68030); Add("hostnet1-bpf-ifname", "auto", VMCap::X68030); Add("hostnet1-tap-devpath", "auto", VMCap::X68030); @@ -119,7 +123,6 @@ Config::Config() Add("hostnet1-usermode-net6", "fd08::/64", VMCap::X68030); AddAlias("hostnet-driver", "hostnet0-driver"); - AddAlias("hostnet-fallback", "hostnet0-fallback"); AddAlias("hostnet-afpacket-ifname", "hostnet0-afpacket-ifname"); AddAlias("hostnet-bpf-ifname", "hostnet0-bpf-ifname"); AddAlias("hostnet-tap-devpath", "hostnet0-tap-devpath"); @@ -127,6 +130,10 @@ Config::Config() AddAlias("hostnet-usermode-net", "hostnet0-usermode-net"); AddAlias("hostnet-usermode-net6", "hostnet0-usermode-net6"); + Add("hostsound-driver", "auto"); + Add("hostsound-alsa-device", "default"); + Add("hostsound-netbsd-device", "/dev/sound"); + // IPLROM1/2 ファイルパス。なければ内蔵 ROM。 Add("iplrom1-image", "", VMCap::X68030); Add("iplrom2-image", "", VMCap::X68030); @@ -167,6 +174,10 @@ Config::Config() // 初期値は各 VM クラスで設定している。 Add("mpu-clock"); + // MPU のキャッシュをオンに出来なくする。テスト用。 + Add("mpu-force-disable-dcache", 0); + Add("mpu-force-disable-icache", 0); + // M88100 で疑似 STOP 状態をサポートする Add("mpu-pseudo-stop", 1, VMCap::M88K); @@ -231,12 +242,18 @@ Config::Config() // virtio 設定。 auto viocap = VMCap::VIRT68K; + // デバイス。 + Add("virtio-net", 1, viocap); + Add("virtio-entropy", 1, viocap); + Add("virtio-scsi", 1, viocap); + // virtio-block for (int id = 0; id < 8; id++) { // イメージパス Add(string_format("virtio-block%u-image", id), viocap); // エミュレータ的に書き込みを禁止するか Add(string_format("virtio-block%u-writeignore", id), 0, viocap); } + // virtio-scsi for (int id = 0; id < 8; id++) { // 種別とイメージパス Add(string_format("virtio-scsi-id%u-image", id), viocap); @@ -300,6 +317,17 @@ Config::AddAlias(const std::string& alia return true; } +// 廃止項目を追加 +void +Config::AddObsolete(const std::string& old, const std::string& alter) +{ + // すでに追加済みなら、プログラムミス。 + if (IsObsolete(old)) { + PANIC("obsolete already has %s !", old.c_str()); + } + obsolete[old] = alter; +} + // 項目を削除 // key が見付からなくても何もしない。key は複数登録されていることはないはず。 void @@ -359,7 +387,7 @@ Config::Update(const std::string& line, UpdateLinePerf("fd2-writeignore=1"); UpdateLinePerf("fd3-writeignore=1"); UpdateLinePerf("ethernet-macaddr=02:00:00:00:00:01"); - UpdateLinePerf("hostcom-driver=none"); + // hostcom0-driver は機種依存があるので後で mainapp.cpp で変更する。 UpdateLinePerf("hostnet-driver=none"); UpdateLinePerf("luna-dipsw1=11110111"); UpdateLinePerf("luna-video-plane=4"); @@ -377,34 +405,65 @@ Config::Update(const std::string& line, UpdateLinePerf("virtio-block4-writeignore=1"); UpdateLinePerf("virtio-block5-writeignore=1"); UpdateLinePerf("virtio-block6-writeignore=1"); + UpdateLinePerf("virtio-block7-writeignore=1"); + UpdateLinePerf("virtio-scsi-id0-writeignore=1"); + UpdateLinePerf("virtio-scsi-id1-writeignore=1"); + UpdateLinePerf("virtio-scsi-id2-writeignore=1"); + UpdateLinePerf("virtio-scsi-id3-writeignore=1"); + UpdateLinePerf("virtio-scsi-id4-writeignore=1"); + UpdateLinePerf("virtio-scsi-id5-writeignore=1"); + UpdateLinePerf("virtio-scsi-id6-writeignore=1"); + UpdateLinePerf("virtio-scsi-id7-writeignore=1"); return true; } else { return UpdateLine(line, ConfigItem::FromOption, optname); } } +// 実行中に動的に変更する。 +bool +Config::UpdateRunning(const std::string& line) +{ + return UpdateLine(line, ConfigItem::FromRunning, ""); +} + // 更新1行分の共通処理。 // キーが見付からない場合は from によって動作が異なる。 // o 共通設定ファイルでなら、何もせず true を返す。 // o VM 設定ファイルでなら、エラーメッセージを表示するが true を返す。 // o コマンドラインでなら、エラーメッセージを表示して false を返す。 -// 戻り値 false は実行中止を示す。 +// 起動前のこれらでは、false は実行中止を示す。 +// また +// o 実行中の変更なら、何もせず false を返す。 +// この場合の false はキーが見付からなかったことを意味する。 +// (文法エラーの場合にも false が返るが、それはプログラムエラー) bool Config::UpdateLine(const std::string& line, ConfigItem::from_t from, const std::string& where) { std::string key; std::string val; + std::string head; // キーと値に分解 if (SplitKeyVal(&key, &val, line) == false) { - ConfigItem::PrintErr(from, where, "", line, "Syntax error"); + head = ConfigItem::ErrFrom(from, where, "", line); + warnx("%s: Syntax error", head.c_str()); return false; } + head = ConfigItem::ErrFrom(from, where, key, val); + // キーが別名なら正規名に置換 key = GetCanonKey(key); + // このキーが廃止予定なら警告は出すがそのまま使う。 + if (IsObsolete(key)) { + warnx("Warning: %s: '%s' is obsolete. Please use '%s' instead.", + head.c_str(), key.c_str(), obsolete[key].c_str()); + key = obsolete[key]; + } + // キーで検索 ConfigItem *itemptr = FindItem(key); if (itemptr == NULL) { @@ -421,13 +480,17 @@ Config::UpdateLine(const std::string& li // VM 設定ファイルなら警告のみで無視する。 // このファイルに他機種向けの設定があるのはおかしいが // 止めるほどではない。 - ConfigItem::PrintErr(from, where, key, val, "Unknown key, ignored"); + warnx("%s: Unknown key, ignored", head.c_str()); return true; case ConfigItem::FromOption: // コマンドラインからの場合はエラーにする。 - ConfigItem::PrintErr(from, where, key, val, "Unknown key"); + warnx("%s: Unknown key", head.c_str()); return false; + + case ConfigItem::FromRunning: + // 実行中なら、黙って無視する。 + return true; } } @@ -719,6 +782,33 @@ ConfigItem::SetDefault(const std::string } } +std::string +ConfigItem::ErrMsg() const +{ + // 定型文 + return ErrMsg("Invalid argument"); +} + +std::string +ConfigItem::ErrMsg(const char *fmt, ...) const +{ + char buf[1024]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + std::string msg(buf); + return ErrMsg(msg); +} + +std::string +ConfigItem::ErrMsg(const std::string& msg) const +{ + return ErrFrom(from, where, key, value) + ": " + msg; +} + void ConfigItem::Err() const { @@ -743,14 +833,14 @@ ConfigItem::Err(const char *fmt, ...) co void ConfigItem::Err(const std::string& msg) const { - PrintErr(from, where, key, value, msg); + warnx("%s", ErrMsg(msg).c_str()); } -// この item についてエラーを表示する。 +// この item のエラーメッセージのヘッダ部分を返す。 // key=val の '=' がない場合のみ key を空、value を行全体として呼ぶ。 -/*static*/ void -ConfigItem::PrintErr(ConfigItem::from_t from, const std::string& where, - const std::string& key, const std::string& value, const std::string& msg) +/*static*/ std::string +ConfigItem::ErrFrom(ConfigItem::from_t from, const std::string& where, + const std::string& key, const std::string& value) { std::string fromstr; @@ -794,7 +884,7 @@ ConfigItem::PrintErr(ConfigItem::from_t break; } - warnx("%s: %s", fromstr.c_str(), msg.c_str()); + return fromstr; }