|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2017 [email protected]
4: //
5:
6: #include "iocon.h"
7: #include "mpu.h"
8:
1.1.1.2 ! root 9: std::unique_ptr<IOConDevice> gIOCon;
1.1 root 10:
11: IOConDevice::IOConDevice()
12: {
13: logname = "iocon";
14: devname = "IOCtrler";
15: devaddr = baseaddr;
16: devlen = 0x2000;
17: }
18:
19: IOConDevice::~IOConDevice()
20: {
21: }
22:
1.1.1.2 ! root 23: inline uint64
! 24: IOConDevice::Decoder(uint32 addr) const
! 25: {
! 26: // 折り返しは?
! 27: addr -= baseaddr;
! 28:
! 29: // 偶数アドレスはバスエラー
! 30: if ((addr & 1) == 0)
! 31: return (uint64)-1;
! 32:
! 33: return addr >> 1;
! 34: }
! 35:
1.1 root 36: uint64
37: IOConDevice::Read8(uint32 addr)
38: {
1.1.1.2 ! root 39: switch (Decoder(addr)) {
! 40: case 0: // $E9C001 割り込みステータス
1.1 root 41: return (fdc_int ? 0x80 : 0)
42: | (fdd_int ? 0x40 : 0)
43: | (prt_int ? 0x20 : 0)
44: | (hdd_int ? 0x10 : 0)
45: | (hdd_en ? 0x08 : 0)
46: | (fdc_en ? 0x04 : 0)
47: | (fdd_en ? 0x02 : 0)
48: | (prt_en ? 0x01 : 0);
1.1.1.2 ! root 49: case 1: // $E9C003 割り込みベクタ
1.1 root 50: return vector;
51: break;
52: }
53: return (uint64)-1;
54: }
55:
56: uint64
57: IOConDevice::Read16(uint32 addr)
58: {
59: return 0xff00 | Read8(addr + 1);
60: }
61:
62: uint64
63: IOConDevice::Write8(uint32 addr, uint32 data)
64: {
1.1.1.2 ! root 65: switch (Decoder(addr)) {
! 66: case 0: // $E9C001 割り込みマスク
1.1 root 67: hdd_en = (data & 0x08);
68: fdc_en = (data & 0x04);
69: fdd_en = (data & 0x02);
70: prt_en = (data & 0x01);
71: putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d",
72: hdd_en, fdc_en, fdd_en, prt_en);
73: return 0;
1.1.1.2 ! root 74: case 1: // $E9C003 割り込みベクタ
1.1 root 75: vector = data & 0xfc;
76: putlog(1, "割り込みベクタ設定 $%02x", vector);
77: return 0;
78: default:
79: break;
80: }
81: return (uint64)-1;
82: }
83:
84: uint64
85: IOConDevice::Write16(uint32 addr, uint32 data)
86: {
87: return Write8(addr + 1, data);
88: }
89:
90: uint64
91: IOConDevice::Peek8(uint32 addr)
92: {
1.1.1.2 ! root 93: switch (Decoder(addr)) {
! 94: case 0:
1.1 root 95: return (fdc_int ? 0x80 : 0)
96: | (fdd_int ? 0x40 : 0)
97: | (prt_int ? 0x20 : 0)
98: | (hdd_int ? 0x10 : 0)
99: | (hdd_en ? 0x08 : 0)
100: | (fdc_en ? 0x04 : 0)
101: | (fdd_en ? 0x02 : 0)
102: | (prt_en ? 0x01 : 0);
103:
1.1.1.2 ! root 104: case 1:
1.1 root 105: return vector;
106:
107: default:
108: return 0xff;
109: }
110: }
111:
112: // FDC からの割り込み要求
113: void
114: IOConDevice::IntFDC()
115: {
116: fdc_int = true;
117: if (fdc_en) {
118: putlog(1, "FDC からの割り込み要求");
1.1.1.2 ! root 119: gMPU680x0->Interrupt(1, vector + 0);
1.1 root 120: } else {
121: putlog(2, "FDC からの割り込み要求(マスク)");
122: }
123: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.