|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // XP プロセッサの物理バス
9: //
10:
1.1.1.2 root 11: // IODevice
12: // +-- MainbusDevice (InitMainbus() と Read/Write に FC 版がある)
13: // | +-- Mainbus24Device
14: // | | +-- LunaMainbus
15: // | | | +-- Luna1Mainbus
16: // | | | +-- Luna88kMainbus
17: // | | +-- NewsMainbus
18: // | | +-- Virt68kMainbus
19: // | +-- X68kMainbus
20: // | +-- X68kIODevice
21: // |
22: // | +-------------+
23: // +-------| XPbusDevice | (これはただの IODevice)
24: // +-------------+
25:
1.1 root 26: // 00000H +-------------------+
27: // | 3Port RAM (128KB) |
28: // 20000H +-------------------+
29: // | PROM (32KB) | ソケットが空のようだ
30: // 28000H +-------------------+
31: // | 3Port RAM (32KB) |
32: // 30000H +-------------------+
33: // | |
34: // : 無効
35: // | |
36: // FFE00H +-------------------+
37: // | 内蔵 RAM (512B) | (実際の位置は I/O で決まる)
38: // FFFFFH +-------------------+
39: //
40: // 3Port RAM (128KB) のほうは vm_luna で確保されている subram、
41: // 3Port RAM (32KB) のほうはこちらで確保する subram2。
42: // 内蔵 RAM は XPBusDevice の internal_ram[]。
43:
44: #include "xpbus.h"
45: #include "subram.h"
46:
47: // コンストラクタ
48: XPbusDevice::XPbusDevice()
49: : inherited(OBJ_XPBUS)
50: {
51: pSubRAM2.reset(new SubRAM2Device(32));
52: pXPRAM.reset(new XPRAMDevice());
53: }
54:
55: // デストラクタ
56: XPbusDevice::~XPbusDevice()
57: {
58: }
59:
60: // 初期化
61: bool
62: XPbusDevice::Init()
63: {
64: if (inherited::Init() == false) {
65: return false;
66: }
67:
68: nopio = GetNopIODevice();
69: subram = GetSubRAMDevice();
70: return true;
71: }
72:
73: void
74: XPbusDevice::ResetHard(bool poweron)
75: {
76: // RMCR のリセットは XP 側からされるのでここでは何もしない
77: }
78:
79: inline IODevice *
80: XPbusDevice::SearchDevice(uint32 addr) const
81: {
82: // まず内蔵 512 バイトRAM (位置は設定で可変)
83: if (__predict_true((addr & 0xffe00) == ram_addr)) {
84: return pXPRAM.get();
85: }
86:
87: if (__predict_true(addr < 0x20000)) { // 00000H-20000H: 3Port RAM (128KB)
88: return subram;
89: }
90: if (__predict_false(addr < 0x28000)) { // 20000H-28000H: PROM 領域 (32KB)
91: return nopio;
92: }
93: if (__predict_true(addr < 0x30000)) { // 28000H-30000H: 非共有 RAM (32KB)
94: return pSubRAM2.get();
95: }
96: // 30000H 以降は空き。
97: // アクセス特性が NopIO かどうかは未調査。
98: return nopio;
99: }
100:
1.1.1.2 root 101: busdata
1.1.1.3 ! root 102: XPbusDevice::Read1(uint32 addr)
1.1 root 103: {
104: addr &= 0x000fffff;
105: IODevice *d = SearchDevice(addr);
1.1.1.3 ! root 106: return d->Read1(addr);
1.1 root 107: }
108:
1.1.1.2 root 109: busdata
1.1.1.3 ! root 110: XPbusDevice::Write1(uint32 addr, uint32 data)
1.1 root 111: {
112: addr &= 0x000fffff;
113: IODevice *d = SearchDevice(addr);
1.1.1.3 ! root 114: return d->Write1(addr, data);
1.1 root 115: }
116:
1.1.1.2 root 117: busdata
1.1.1.3 ! root 118: XPbusDevice::Peek1(uint32 addr)
1.1 root 119: {
120: addr &= 0x000fffff;
121: IODevice *d = SearchDevice(addr);
1.1.1.3 ! root 122: return d->Peek1(addr);
1.1 root 123: }
124:
1.1.1.2 root 125: bool
1.1.1.3 ! root 126: XPbusDevice::Poke1(uint32 addr, uint32 data)
1.1 root 127: {
1.1.1.2 root 128: addr &= 0x000fffff;
129: IODevice *d = SearchDevice(addr);
1.1.1.3 ! root 130: return d->Poke1(addr, data);
1.1 root 131: }
132:
133: // RMCR レジスタを取得する
134: uint32
135: XPbusDevice::GetRMCR() const
136: {
137: return (ram_addr >> 12) & 0xff;
138: }
139:
140: // RMCR レジスタを設定する
141: void
142: XPbusDevice::SetRMCR(uint32 data)
143: {
144: ram_addr = ((data & 0xf0) << 12) | 0xfe00;
145: }
146:
147:
148: //
149: // XP 内蔵 512 バイト RAM
150: //
151: // IODevice にしておかないといけない関係で独立して用意する。
152: // ここは RAM 実体を持っているだけで、配置場所は XPbusDevice が担当している。
153: //
154:
155: // コンストラクタ
156: XPRAMDevice::XPRAMDevice()
157: : inherited(OBJ_XPRAM)
158: {
159: }
160:
161: // デストラクタ
162: XPRAMDevice::~XPRAMDevice()
163: {
164: }
165:
1.1.1.2 root 166: busdata
1.1.1.3 ! root 167: XPRAMDevice::Read1(uint32 addr)
1.1 root 168: {
1.1.1.3 ! root 169: uint32 offset = addr & 0x1ff;
! 170: busdata data = ram[offset];
! 171: return data;
1.1 root 172: }
173:
1.1.1.2 root 174: busdata
1.1.1.3 ! root 175: XPRAMDevice::Write1(uint32 addr, uint32 data)
1.1 root 176: {
1.1.1.3 ! root 177: uint32 offset = addr & 0x1ff;
! 178: ram[offset] = data;
1.1 root 179: return 0;
180: }
181:
1.1.1.2 root 182: busdata
1.1.1.3 ! root 183: XPRAMDevice::Peek1(uint32 addr)
1.1 root 184: {
185: addr &= 0x1ff;
186: return ram[addr];
187: }
188:
1.1.1.2 root 189: bool
1.1.1.3 ! root 190: XPRAMDevice::Poke1(uint32 addr, uint32 data)
1.1 root 191: {
192: if ((int32)data >= 0) {
193: addr &= 0x1ff;
194: ram[addr] = data;
195: }
1.1.1.2 root 196: return true;
1.1 root 197: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.