--- nono/vm/pio.cpp 2026/04/29 17:04:36 1.1.1.2 +++ nono/vm/pio.cpp 2026/04/29 17:04:42 1.1.1.4 @@ -7,6 +7,7 @@ #include "pio.h" #include "config.h" #include "lcd.h" +#include "mainapp.h" #include "mystring.h" #include "scheduler.h" @@ -37,6 +38,17 @@ i8255Device::~i8255Device() { } +// リセット +void +i8255Device::ResetHard() +{ + // clears the control register + // and place ports A, B, and C in input mode. + // The input latches in ports A, B, and C are not cleared. + + ctrl = 0b10011011; +} + // コントロールポートへの書き込み。 void i8255Device::WriteCtrl(uint32 data) @@ -98,6 +110,8 @@ PPIDevice::~PPIDevice() uint64 PPIDevice::Read(uint32 addr) { + gMPU->AddCycle(19); // InsideOut p.135 + switch (addr) { case 0: case 1: @@ -117,6 +131,8 @@ PPIDevice::Read(uint32 addr) uint64 PPIDevice::Write(uint32 addr, uint32 data) { + gMPU->AddCycle(19); // InsideOut p.135 + switch (addr) { case 0: case 1: @@ -157,6 +173,7 @@ PPIDevice::Peek(uint32 addr) // 変数は dipsw{1,2}[0..7] に対応。 // 設定ファイルと変数の値は %0 が down を表し、%1 が up を表す。 // +// LUNA-1: // #1-1 up なら UNIX をロードして移行。down なら ROM モニタで起動。 // #1-2 up ならディスプレイコンソール。down ならシリアルコンソール。 // #1-3 up - color display, down - force to have monochrome display @@ -173,6 +190,13 @@ PPIDevice::Peek(uint32 addr) // あれば /boot がプロンプトで停止。これは ROM ではなく NetBSD のブート // ローダの話。 // どこか由来のソースコードらしいがたぶんビット演算を間違えている。 +// +// LUNA88K: +// #1-1 up なら ROM モニタで停止、down ならマルチユーザブート。 +// OpenBSD カーネルも up なら UserKernelConfig で止まる模様?。 +// #1-2 up なら外付けシリアルコンソール、down なら内蔵ビットマップ。 +// #1-3..#1-8 は予約。 +// #2-x はユーザ(?) // コンストラクタ PIO0Device::PIO0Device() @@ -183,7 +207,23 @@ PIO0Device::PIO0Device() devaddr = 0x49000000; devlen = 4; - monitor.Init(22, 11); + // 機種固有パラメータ + + // LUNA-1 と LUNA88K で使いやすいように初期値を変えておく。 + switch (gMainApp.GetVMType()) { + case VMTYPE_LUNA1: + gConfig->SetDefault("luna-dipsw1", "11110111"); + break; + case VMTYPE_LUNA88K: + gConfig->SetDefault("luna-dipsw1", "11111111"); + break; + default: + __unreachable(); + } + // DIP-SW#2 はユーザ定義(?)なので(今の所?)どちらも共通。 + gConfig->SetDefault("luna-dipsw2", "11111111"); + + monitor_size = nnSize(22, 11); } // デストラクタ @@ -293,8 +333,8 @@ PIO0Device::Peek(uint32 addr) } } -bool -PIO0Device::MonitorUpdate() +void +PIO0Device::MonitorUpdate(TextScreen& monitor) { int y; @@ -328,8 +368,6 @@ PIO0Device::MonitorUpdate() monitor.Puts(1, y++, TA::OnOff(int1en), "b2: Int1 Enable"); monitor.Puts(1, y++, "b1: ---"); monitor.Puts(1, y++, TA::OnOff(int1rq), "b0: Intq Request"); - - return true; } // PortA (DIP-SW 1) 読み込み @@ -447,6 +485,15 @@ PIO1Device::~PIO1Device() { } +// リセット +void +PIO1Device::ResetHard() +{ + inherited::ResetHard(); + + poffevent.Stop(); +} + uint64 PIO1Device::Read(uint32 addr) { @@ -579,7 +626,7 @@ PIO1Device::SetPC(int pc, int val) // 電源 OFF イベントのコールバック void -PIO1Device::PowerOffCallback(int arg) +PIO1Device::PowerOffCallback(Event& ev) { putlog(0, "電源 OFF"); gScheduler->RequestPowerOff();