Annotation of nono/vm/xpbus.cpp, revision 1.1.1.4

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.