--- nono/vm/pio.h 2026/04/29 17:04:59 1.1.1.8 +++ nono/vm/pio.h 2026/04/29 17:05:10 1.1.1.9 @@ -4,10 +4,14 @@ // Licensed under nono-license.txt // +// +// PIO/PPI (i8255) +// + #pragma once -#include "device.h" -#include "scheduler.h" +#include "event.h" +#include "monitor.h" // Intel 82C55 の仕様書にはコントロールポートからの読み出しは明記してある。 // NEC uPD8255 の仕様書にはコントロールポートからの読み出しについての記載が @@ -20,7 +24,7 @@ class i8255Device : public IODevice i8255Device(const std::string& objname_); virtual ~i8255Device() override; - void ResetHard() override; + void ResetHard(bool poweron) override; protected: // コントロールポートの読み出し @@ -28,7 +32,7 @@ class i8255Device : public IODevice // コントロールポートへの書き込み void WriteCtrl(uint32); // PortC への個別書き込み - virtual void SetPC(int, int); + virtual void SetPC(int, int) = 0; // 7 6 5 4 3 2 1 0 // 1 AM AM AD CHD BM BD CLD @@ -56,7 +60,7 @@ class i8255Device : public IODevice class PPIDevice : public i8255Device { using inherited = i8255Device; - private: + static const int baseaddr = 0xe9a000; public: @@ -69,6 +73,9 @@ class PPIDevice : public i8255Device uint64 Read(uint32 offset); uint64 Write(uint32 offset, uint32 data); uint64 Peek(uint32 offset); + + private: + void SetPC(int, int) override; }; class PIO0Device : public i8255Device @@ -80,14 +87,8 @@ class PIO0Device : public i8255Device bool Init() override; - // DIP-SW1 の状態を取得 (ROM エミュレーション用) - // - // b7 b6 b5 b4 b3 b2 b1 b0 - // +------+------+------+------+------+------+------+------+ - // | #1-8 | #1-7 | #1-6 | #1-5 | #1-4 | #1-3 | #1-2 | #1-1 | - // +------+------+------+------+------+------+------+------+ - // %1 が UP、%0 が DOWN - uint32 GetDIPSW1() const { return GetPA(); } + // DIPSW #1-1 が Up なら true を返す (ROM エミュレーション用) + bool IsDIPSW11Up() const { return dipsw1[0]; } protected: // BusIO インタフェース @@ -124,7 +125,7 @@ class PIO1Device : public i8255Device PIO1Device(); virtual ~PIO1Device() override; - void ResetHard() override; + void ResetHard(bool poweron) override; protected: // BusIO インタフェース @@ -144,6 +145,6 @@ class PIO1Device : public i8255Device Event poffevent { this }; }; -extern std::unique_ptr gPPI; -extern std::unique_ptr gPIO0; -extern std::unique_ptr gPIO1; +extern PPIDevice *gPPI; +extern PIO0Device *gPIO0; +extern PIO1Device *gPIO1;