|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: #include "ioctlr.h"
8: #include "mpu680x0.h"
9:
10: std::unique_ptr<IOCtlrDevice> gIOCtlr;
11:
12: IOCtlrDevice::IOCtlrDevice()
13: {
14: logname = "ioctlr";
15: devname = "IOCtlr";
16: devaddr = baseaddr;
17: devlen = 0x2000;
18: }
19:
20: IOCtlrDevice::~IOCtlrDevice()
21: {
22: }
23:
1.1.1.2 ! root 24: void
! 25: IOCtlrDevice::ResetHard()
! 26: {
! 27: // XXX not yet
! 28: }
! 29:
1.1 root 30: uint64
31: IOCtlrDevice::Read(uint32 addr)
32: {
33: switch (addr) {
34: case 0: // $E9C001 割り込みステータス
35: return (fdc_int ? 0x80 : 0)
36: | (fdd_int ? 0x40 : 0)
37: | (prt_int ? 0x20 : 0)
38: | (hdd_int ? 0x10 : 0)
39: | (hdd_en ? 0x08 : 0)
40: | (fdc_en ? 0x04 : 0)
41: | (fdd_en ? 0x02 : 0)
42: | (prt_en ? 0x01 : 0);
43:
44: case 1: // $E9C003 割り込みベクタ
45: // 書き込み専用
46: return 0xff;
47:
48: default:
49: return 0xff;
50: }
51: }
52:
53: uint64
54: IOCtlrDevice::Write(uint32 addr, uint32 data)
55: {
56: switch (addr) {
57: case 0: // $E9C001 割り込みマスク
58: hdd_en = (data & 0x08);
59: fdc_en = (data & 0x04);
60: fdd_en = (data & 0x02);
61: prt_en = (data & 0x01);
62: putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d",
63: hdd_en, fdc_en, fdd_en, prt_en);
64: return 0;
65:
66: case 1: // $E9C003 割り込みベクタ
67: vector = data & 0xfc;
68: putlog(1, "割り込みベクタ設定 $%02x", vector);
69: return 0;
70:
71: default:
72: return 0;
73: }
74: }
75:
76: uint64
77: IOCtlrDevice::Peek(uint32 addr)
78: {
79: switch (addr) {
80: case 0:
81: return (fdc_int ? 0x80 : 0)
82: | (fdd_int ? 0x40 : 0)
83: | (prt_int ? 0x20 : 0)
84: | (hdd_int ? 0x10 : 0)
85: | (hdd_en ? 0x08 : 0)
86: | (fdc_en ? 0x04 : 0)
87: | (fdd_en ? 0x02 : 0)
88: | (prt_en ? 0x01 : 0);
89:
90: case 1:
91: // 書き込み専用
92: return 0xff;
93:
94: default:
95: return 0xff;
96: }
97: }
98:
99: // FDC からの割り込み要求
100: void
101: IOCtlrDevice::IntFDC()
102: {
103: fdc_int = true;
104: if (fdc_en) {
105: putlog(1, "FDC からの割り込み要求");
106: gMPU680x0->Interrupt(this, 1, vector + 0);
107: } else {
108: putlog(2, "FDC からの割り込み要求(マスク)");
109: }
110: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.