Annotation of nono/vm/pio.h, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2017 [email protected]
        !             4: //
        !             5: 
        !             6: #pragma once
        !             7: 
        !             8: #include "device.h"
        !             9: #include "scheduler.h"
        !            10: 
        !            11: // Intel 82C55 の仕様書にはコントロールポートからの読み出しは明記してある。
        !            12: // NEC uPD8255 の仕様書にはコントロールポートからの読み出しについての記載が
        !            13: // ない (禁止とも書いてない)。
        !            14: class i8255Device
        !            15:        : public IODevice
        !            16: {
        !            17:        typedef IODevice inherited;
        !            18: 
        !            19:  public:
        !            20:        i8255Device();
        !            21:        virtual ~i8255Device();
        !            22: 
        !            23:  protected:
        !            24:        // コントロールポートの読み出し
        !            25:        uint32 ReadCtrl() const { return ctrl; }
        !            26:        // コントロールポートへの書き込み
        !            27:        void WriteCtrl(uint32);
        !            28:        // PortC への個別書き込み
        !            29:        virtual void SetPC(int, int);
        !            30: 
        !            31:        // 7  6  5  4  3   2  1  0
        !            32:        // 1  AM AM AD CHD BM BD CLD
        !            33:        //    |  |  |  |   |  |  +--- ポートC下位グループの方向。入力なら1
        !            34:        //    |  |  |  |   |  +------ ポートB の方向。入力なら1
        !            35:        //    |  |  |  |   +--------- ポートB のモード。
        !            36:        //    |  |  |  +------------- ポートC上位グループの方向。入力なら1
        !            37:        //    |  |  +---------------- ポートA の方向。入力なら1
        !            38:        //    +--+------------------- ポートA のモード。
        !            39:        uint8 ctrl = 0;                 // コントロールポートの値
        !            40: 
        !            41:        static const uint DIR_IN  = 1;
        !            42:        static const uint DIR_OUT = 0;
        !            43:        // グループA/B (ポートA/B) のモード
        !            44:        uint GetGroupAMode() const      { return (ctrl >> 5) & 3; }
        !            45:        uint GetGroupBMode() const      { return (ctrl >> 2) & 1; }
        !            46:        // ポート A/B/C上位/C下位 の入出力方向
        !            47:        uint PortADir() const   { return (ctrl & 0x10) ? DIR_IN : DIR_OUT; }
        !            48:        uint PortBDir() const   { return (ctrl & 0x02) ? DIR_IN : DIR_OUT; }
        !            49:        uint PortCHDir() const  { return (ctrl & 0x08) ? DIR_IN : DIR_OUT; }
        !            50:        uint PortCLDir() const  { return (ctrl & 0x01) ? DIR_IN : DIR_OUT; }
        !            51: };
        !            52: 
        !            53: 
        !            54: class PPIDevice
        !            55:        : public i8255Device
        !            56: {
        !            57:        typedef i8255Device inherited;
        !            58:  private:
        !            59:        static const int baseaddr = 0xe9a000;
        !            60: 
        !            61:  public:
        !            62:        PPIDevice();
        !            63:        virtual ~PPIDevice();
        !            64: 
        !            65:  protected:
        !            66:        // BusIO インタフェース
        !            67:        static const uint32 NPORT = 4;
        !            68:        uint64 Read(uint32 addr);
        !            69:        uint64 Write(uint32 addr, uint32 data);
        !            70:        uint64 Peek(uint32 addr);
        !            71: };
        !            72: 
        !            73: class PIO0Device
        !            74:        : public i8255Device
        !            75: {
        !            76:        typedef i8255Device inherited;
        !            77:  public:
        !            78:        PIO0Device();
        !            79:        virtual ~PIO0Device();
        !            80: 
        !            81:        virtual bool Init();
        !            82: 
        !            83:        // DIP-SW1 の状態を取得 (ROM エミュレーション用)
        !            84:        //
        !            85:        //    b7     b6     b5     b4     b3     b2     b1     b0
        !            86:        // +------+------+------+------+------+------+------+------+
        !            87:        // | #1-8 | #1-7 | #1-6 | #1-5 | #1-4 | #1-3 | #1-2 | #1-1 |
        !            88:        // +------+------+------+------+------+------+------+------+
        !            89:        // %1 が UP、%0 が DOWN
        !            90:        uint32 GetDIPSW1() const { return GetPA(); }
        !            91: 
        !            92:  protected:
        !            93:        // BusIO インタフェース
        !            94:        static const uint32 NPORT = 4;
        !            95:        uint64 Read(uint32 addr);
        !            96:        uint64 Write(uint32 addr, uint32 data);
        !            97:        uint64 Peek(uint32 addr);
        !            98: 
        !            99:  private:
        !           100:        uint32 GetPA() const;
        !           101:        uint32 GetPB() const;
        !           102:        uint32 GetPC() const;
        !           103:        virtual void SetPC(int, int);
        !           104: 
        !           105:        bool dipsw1[8] {};
        !           106:        bool dipsw2[8] {};
        !           107:        bool int1rq = false;    // $01 INT1 割り込み要求
        !           108:        bool int1en = false;    // $04 INT1 割り込み許可
        !           109:        bool int5rq = false;    // $08 INT5 割り込み要求
        !           110:        bool int5en = false;    // $10 INT5 割り込み許可
        !           111:        bool parity = false;    // $40 パリティ有効/無効
        !           112:        bool xp_reset = false;  // $80 XP リセット
        !           113: };
        !           114: 
        !           115: class PIO1Device
        !           116:        : public i8255Device
        !           117: {
        !           118:        typedef i8255Device inherited;
        !           119:  public:
        !           120:        PIO1Device();
        !           121:        virtual ~PIO1Device();
        !           122: 
        !           123:  protected:
        !           124:        // BusIO インタフェース
        !           125:        static const uint32 NPORT = 4;
        !           126:        uint64 Read(uint32 addr);
        !           127:        uint64 Write(uint32 addr, uint32 data);
        !           128:        uint64 Peek(uint32 addr);
        !           129: 
        !           130:  private:
        !           131:        virtual void SetPC(int, int);
        !           132:        void PowerOffCallback(int);
        !           133: 
        !           134:        bool power = false;             // パワーダウン (false で電源オフ指示)
        !           135:        bool xp_intreq = false; // XP 割り込み要求。あり(true)なら %0
        !           136:        Event poffevent {};             // 電源オフイベント
        !           137: };
        !           138: 
        !           139: extern std::unique_ptr<PIO0Device> gPIO0;
        !           140: extern std::unique_ptr<PIO1Device> gPIO1;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.