Annotation of nono/vm/mainbus_virt68k.cpp, revision 1.1.1.3

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2024 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
1.1.1.2   root        8: // メインバス (virt-m68k)
1.1       root        9: //
                     10: 
                     11: // IODevice
                     12: //   +-- MainbusBaseDevice (InitMainbus() と FC アクセスを持つ)
                     13: //   |    +-- MainbusDevice (これがメインバス、システムに1つ)
                     14: //   |    |    +-- Mainbus24Device (上位8ビットがテーブルで表せるメインバス)
                     15: //   |    |    |    +-- LunaMainbus
                     16: //   |    |    |    |    +-- Luna1Mainbus
                     17: //   |    |    |    |    +-- Luna88kMainbus
                     18: //   |    |    |    +-- NewsMainbus
1.1.1.2   root       19: //   |    |    |
                     20: //   |    |    |  +----------------+
                     21: //   |    |    +--| Virt68kMainbus |
                     22: //   |    |    |  +----------------+
1.1       root       23: //   |    |    |
                     24: //   |    |    +-- X68kMainbus
                     25: //   |    +-- X68kIODevice
                     26: //   +-- XPbusDevice
                     27: 
                     28: #include "mainbus_virt68k.h"
                     29: #include "interrupt.h"
                     30: #include "mainapp.h"
                     31: #include "mainram.h"
1.1.1.3 ! root       32: #include "monitor.h"
1.1       root       33: #include "v68kio.h"
                     34: 
                     35: // コンストラクタ
                     36: Virt68kMainbus::Virt68kMainbus()
1.1.1.2   root       37:        : inherited(OBJ_MAINBUS)
1.1       root       38: {
                     39:        NEWDV(BusErr, new BusErrDevice());
                     40:        NEWDV(Interrupt, new Virt68kInterrupt());
                     41:        NEWDV(MainRAM, new MainRAMDevice());
                     42:        NEWDV(V68kIO, new V68kIODevice());
                     43: 
                     44:        // メインメモリは Init() で設定する。
                     45: 
1.1.1.3 ! root       46:        accstat_monitor->SetSize(80, 2 + 32);
1.1       root       47: }
                     48: 
                     49: // デストラクタ
                     50: Virt68kMainbus::~Virt68kMainbus()
                     51: {
                     52: }
                     53: 
                     54: // メインバスの初期化
                     55: bool
                     56: Virt68kMainbus::InitMainbus()
                     57: {
                     58:        // RAM は容量が確定した後のここで配置。
                     59:        // 16MB 単位になっている。
                     60:        auto mainram = dynamic_cast<MainRAMDevice *>(pMainRAM.get());
1.1.1.2   root       61:        ramsize = mainram->GetSize();
1.1       root       62: 
                     63:        // アクセス状況用のマップを作成。
1.1.1.2   root       64:        for (uint32 i = 0; i < 4096 / 16; i++) {
                     65:                if (Decoder(i * 0x0100'0000) != pBusErr.get()) {
                     66:                        accstat_avail[i / 8] |= 0x80U >> (i % 8);
                     67:                }
                     68:        }
1.1       root       69: 
                     70:        return true;
                     71: }
                     72: 
1.1.1.2   root       73: inline IODevice *
                     74: Virt68kMainbus::Decoder(uint32 addr) const
                     75: {
                     76:        if (__predict_true(addr < ramsize)) {
                     77:                return pMainRAM.get();
                     78:        } else if (__predict_true(addr >= 0xff000000)) {
                     79:                return pV68kIO.get();
                     80:        } else {
                     81:                return pBusErr.get();
                     82:        }
                     83: }
                     84: 
                     85: busdata
                     86: Virt68kMainbus::Read(busaddr addr)
                     87: {
                     88:        uint32 pa = addr.Addr();
                     89:        accstat_read[pa >> AccStat::SHIFT] = AccStat::READ;
                     90:        IODevice *dev = Decoder(pa);
                     91:        return dev->Read(addr);
                     92: }
                     93: 
                     94: busdata
                     95: Virt68kMainbus::Write(busaddr addr, uint32 data)
                     96: {
                     97:        uint32 pa = addr.Addr();
                     98:        accstat_read[pa >> AccStat::SHIFT] = AccStat::WRITE;
                     99:        IODevice *dev = Decoder(pa);
                    100:        return dev->Write(addr, data);
                    101: }
                    102: 
                    103: busdata
                    104: Virt68kMainbus::ReadBurst16(busaddr addr, uint32 *dst)
                    105: {
                    106:        uint32 pa = addr.Addr();
                    107:        IODevice *dev = Decoder(pa);
                    108:        busdata r = dev->ReadBurst16(addr, dst);
                    109:        if (__predict_true(r.IsBusErr() == false)) {
                    110:                accstat_read[pa >> AccStat::SHIFT] = AccStat::READ;
                    111:        }
                    112:        return r;
                    113: }
                    114: 
                    115: busdata
                    116: Virt68kMainbus::WriteBurst16(busaddr addr, const uint32 *src)
                    117: {
                    118:        uint32 pa = addr.Addr();
                    119:        IODevice *dev = Decoder(pa);
                    120:        busdata r = dev->WriteBurst16(addr, src);
                    121:        if (__predict_true(r.IsBusErr() == false)) {
                    122:                accstat_read[pa >> AccStat::SHIFT] = AccStat::WRITE;
                    123:        }
                    124:        return r;
                    125: }
                    126: 
                    127: busdata
                    128: Virt68kMainbus::Peek1(uint32 addr)
                    129: {
                    130:        IODevice *dev = Decoder(addr);
                    131:        return dev->Peek1(addr);
                    132: }
                    133: 
                    134: bool
                    135: Virt68kMainbus::Poke1(uint32 addr, uint32 data)
                    136: {
                    137:        IODevice *dev = Decoder(addr);
                    138:        return dev->Poke1(addr, data);
                    139: }
                    140: 
1.1       root      141: // ブートページを切り替える。
                    142: void
                    143: Virt68kMainbus::SwitchBootPage(bool isram)
                    144: {
                    145:        // まだサポートしていない。
                    146: }

unix.superglobalmegacorp.com

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