|
|
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"
1.1.1.5 ! root 45: #include "nop.h"
1.1 root 46: #include "subram.h"
47:
48: // コンストラクタ
49: XPbusDevice::XPbusDevice()
50: : inherited(OBJ_XPBUS)
51: {
52: pSubRAM2.reset(new SubRAM2Device(32));
53: pXPRAM.reset(new XPRAMDevice());
54: }
55:
56: // デストラクタ
57: XPbusDevice::~XPbusDevice()
58: {
59: }
60:
61: // 初期化
62: bool
63: XPbusDevice::Init()
64: {
65: nopio = GetNopIODevice();
66: subram = GetSubRAMDevice();
67: return true;
68: }
69:
70: void
71: XPbusDevice::ResetHard(bool poweron)
72: {
73: // RMCR のリセットは XP 側からされるのでここでは何もしない
74: }
75:
76: inline IODevice *
77: XPbusDevice::SearchDevice(uint32 addr) const
78: {
79: // まず内蔵 512 バイトRAM (位置は設定で可変)
80: if (__predict_true((addr & 0xffe00) == ram_addr)) {
81: return pXPRAM.get();
82: }
83:
84: if (__predict_true(addr < 0x20000)) { // 00000H-20000H: 3Port RAM (128KB)
85: return subram;
86: }
87: if (__predict_false(addr < 0x28000)) { // 20000H-28000H: PROM 領域 (32KB)
88: return nopio;
89: }
90: if (__predict_true(addr < 0x30000)) { // 28000H-30000H: 非共有 RAM (32KB)
91: return pSubRAM2.get();
92: }
93: // 30000H 以降は空き。
94: // アクセス特性が NopIO かどうかは未調査。
95: return nopio;
96: }
97:
1.1.1.2 root 98: busdata
1.1.1.3 root 99: XPbusDevice::Read1(uint32 addr)
1.1 root 100: {
101: addr &= 0x000fffff;
102: IODevice *d = SearchDevice(addr);
1.1.1.3 root 103: return d->Read1(addr);
1.1 root 104: }
105:
1.1.1.2 root 106: busdata
1.1.1.3 root 107: XPbusDevice::Write1(uint32 addr, uint32 data)
1.1 root 108: {
109: addr &= 0x000fffff;
110: IODevice *d = SearchDevice(addr);
1.1.1.3 root 111: return d->Write1(addr, data);
1.1 root 112: }
113:
1.1.1.2 root 114: busdata
1.1.1.3 root 115: XPbusDevice::Peek1(uint32 addr)
1.1 root 116: {
117: addr &= 0x000fffff;
118: IODevice *d = SearchDevice(addr);
1.1.1.3 root 119: return d->Peek1(addr);
1.1 root 120: }
121:
1.1.1.2 root 122: bool
1.1.1.3 root 123: XPbusDevice::Poke1(uint32 addr, uint32 data)
1.1 root 124: {
1.1.1.2 root 125: addr &= 0x000fffff;
126: IODevice *d = SearchDevice(addr);
1.1.1.3 root 127: return d->Poke1(addr, data);
1.1 root 128: }
129:
130: // RMCR レジスタを取得する
131: uint32
132: XPbusDevice::GetRMCR() const
133: {
134: return (ram_addr >> 12) & 0xff;
135: }
136:
137: // RMCR レジスタを設定する
138: void
139: XPbusDevice::SetRMCR(uint32 data)
140: {
141: ram_addr = ((data & 0xf0) << 12) | 0xfe00;
142: }
143:
144:
145: //
146: // XP 内蔵 512 バイト RAM
147: //
148: // IODevice にしておかないといけない関係で独立して用意する。
149: // ここは RAM 実体を持っているだけで、配置場所は XPbusDevice が担当している。
150: //
151:
152: // コンストラクタ
153: XPRAMDevice::XPRAMDevice()
154: : inherited(OBJ_XPRAM)
155: {
156: }
157:
158: // デストラクタ
159: XPRAMDevice::~XPRAMDevice()
160: {
161: }
162:
1.1.1.2 root 163: busdata
1.1.1.3 root 164: XPRAMDevice::Read1(uint32 addr)
1.1 root 165: {
1.1.1.3 root 166: uint32 offset = addr & 0x1ff;
167: busdata data = ram[offset];
168: return data;
1.1 root 169: }
170:
1.1.1.2 root 171: busdata
1.1.1.3 root 172: XPRAMDevice::Write1(uint32 addr, uint32 data)
1.1 root 173: {
1.1.1.3 root 174: uint32 offset = addr & 0x1ff;
175: ram[offset] = data;
1.1 root 176: return 0;
177: }
178:
1.1.1.2 root 179: busdata
1.1.1.3 root 180: XPRAMDevice::Peek1(uint32 addr)
1.1 root 181: {
182: addr &= 0x1ff;
183: return ram[addr];
184: }
185:
1.1.1.2 root 186: bool
1.1.1.3 root 187: XPRAMDevice::Poke1(uint32 addr, uint32 data)
1.1 root 188: {
189: if ((int32)data >= 0) {
190: addr &= 0x1ff;
191: ram[addr] = data;
192: }
1.1.1.2 root 193: return true;
1.1 root 194: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.