|
|
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: virtual uint64 Read8(uint32 addr);
66: virtual uint64 Read16(uint32 addr);
67: virtual uint64 Write8(uint32 addr, uint32 data);
68: virtual uint64 Write16(uint32 addr, uint32 data);
69: virtual uint64 Peek8(uint32 addr);
70: };
71:
72: class PIO0Device
73: : public i8255Device
74: {
75: typedef i8255Device inherited;
76: public:
77: PIO0Device();
78: virtual ~PIO0Device();
79:
80: virtual bool Init();
81: virtual uint64 Read8(uint32 addr);
82: virtual uint64 Write8(uint32 addr, uint32 data);
83:
84: private:
85: virtual void SetPC(int, int);
86:
87: bool dipsw1[8] {};
88: bool dipsw2[8] {};
89: bool int1rq = false; // $01 INT1 割り込み要求
90: bool int1en = false; // $04 INT1 割り込み許可
91: bool int5rq = false; // $08 INT5 割り込み要求
92: bool int5en = false; // $10 INT5 割り込み許可
93: bool parity = false; // $40 パリティ有効/無効
94: bool xp_reset = false; // $80 XP リセット
95: };
96:
97: class PIO1Device
98: : public i8255Device
99: {
100: typedef i8255Device inherited;
101: public:
102: PIO1Device();
103: virtual ~PIO1Device();
104:
105: virtual uint64 Read8(uint32 addr);
106: virtual uint64 Write8(uint32 addr, uint32 data);
107:
108: private:
109: virtual void SetPC(int, int);
110: void PowerOffCallback(int);
111:
112: bool power = false; // パワーダウン (false で電源オフ指示)
113: bool xp_intreq = false; // XP 割り込み要求。あり(true)なら %0
114: Event poffevent {}; // 電源オフイベント
115: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.