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

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2022 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // メインバス (NEWS)
                      9: //
                     10: 
                     11: // IODevice
                     12: //   +-- MainbusBaseDevice (InitMainbus() と FC アクセスを持つ)
                     13: //   |    +-- MainbusDevice (これがメインバス、システムに1つ)
                     14: //   |    |    +-- Mainbus24Device (上位8ビットがテーブルで表せるメインバス)
                     15: //   |    |    |    +-- LunaMainbus
                     16: //   |    |    |    |    +-- Luna1Mainbus
                     17: //   |    |    |    |    +-- Luna88kMainbus
                     18: //   |    |    |    |
                     19: //   |    |    |    |  +-------------+
                     20: //   |    |    |    +--| NewsMainbus |
                     21: //   |    |    |    |  +-------------+
                     22: //   |    |    |    |
                     23: //   |    |    |    +-- Virt68kMainbus
                     24: //   |    |    +-- X68kMainbus
                     25: //   |    +-- X68kIODevice
                     26: //   +-- XPbusDevice
                     27: 
                     28: #include "mainbus_news.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 "newsctlr.h"
                     34: #include "newsio.h"
                     35: #include "prom.h"
                     36: #include "romemu_news.h"
                     37: 
                     38: // コンストラクタ
                     39: NewsMainbus::NewsMainbus()
                     40: {
                     41:        NEWDV(BusErr, new BusErrDevice());
                     42:        NEWDV(Interrupt, new NewsInterrupt());
                     43:        NEWDV(PROM, new NewsROMEmuDevice());
                     44:        NEWDV(MainRAM, new MainRAMDevice());
                     45:        NEWDV(NopIO, new NopIODevice());                                // required by NewsIO
                     46:        NEWDV(NewsCtlr, new NewsCtlrDevice());
                     47:        NEWDV(NewsIO, new NewsIODevice());
                     48: 
                     49:        // 公式には $c0'000000〜$ff'ffffff となっているが、
                     50:        // たぶん上位2ビットがデコードされてないように見えるので、
                     51:        // ここでは $00'000000〜$3f'ffffff ×4 として扱う。
                     52: 
                     53:        // $eX'XXXXXX はバスエラーが起きないらしい。
                     54:        // $fX'XXXXXX はバスエラーが起きるらしい。
                     55:        // それ以上は詳細不明。
                     56:        // とりあえず $eX'XXXXXX だけ NopIO、他はバスエラーにしておく。
                     57:        for (int i = 0; i < 0x40; i++) {
                     58:                devtable[i] = pBusErr.get();
                     59:        }
                     60:        for (int i = 0x20; i < 0x30; i++) {
                     61:                devtable[i] = pNopIO.get();
                     62:        }
                     63: 
                     64:        // 少ないので手動で置いていく。
                     65:        auto newsio = pNewsIO.get();
                     66:        auto newsctlr = pNewsCtlr.get();
                     67:        auto prom = pPROM.get();
                     68: #define A(addr)        (((addr) >> 24) & 0x3f)
                     69:        devtable[A(0xe0'000000)] = newsio;
                     70:        devtable[A(0xe1'000000)] = newsctlr;
                     71:        devtable[A(0xf8'000000)] = prom;
                     72: 
1.1.1.2   root       73:        // アドレス空間は 0xc000'0000 からの 30bit。
                     74:        accstat_baseaddr = 0xc0;
                     75:        accstat_bitlen = 30;
1.1.1.3 ! root       76:        accstat_monitor->SetSize(80, 2 + 32 / 4);
1.1       root       77: }
                     78: 
                     79: // デストラクタ
                     80: NewsMainbus::~NewsMainbus()
                     81: {
                     82: }
                     83: 
                     84: // メインバスの初期化
                     85: bool
                     86: NewsMainbus::InitMainbus()
                     87: {
                     88:        // RAM は容量が確定した後のここで配置。
                     89:        auto mainram = dynamic_cast<MainRAMDevice *>(pMainRAM.get());
                     90:        int ram_size_MB = mainram->GetSizeMB();
                     91:        int i = 0;
                     92:        while (ram_size_MB >= 16) {
                     93:                // 16MB 単位にとりあえずしとく
                     94:                devtable[i++] = mainram;
                     95:                ram_size_MB -= 16;
                     96:        }
                     97: 
                     98:        // $40'000000〜、$80'000000〜、$c0'000000〜はミラーっぽい。
                     99:        memcpy(&devtable[0x40], &devtable[0], 0x40 * sizeof(devtable[0]));
                    100:        memcpy(&devtable[0x80], &devtable[0], 0x40 * sizeof(devtable[0]));
                    101:        memcpy(&devtable[0xc0], &devtable[0], 0x40 * sizeof(devtable[0]));
                    102: 
                    103:        // アクセス状況用のマップを作成。
                    104:        InitAccStat();
                    105: 
                    106:        return true;
                    107: }
                    108: 
                    109: // ブートページを切り替える。
                    110: void
                    111: NewsMainbus::SwitchBootPage(bool isram)
                    112: {
                    113:        // まだサポートしていない。
                    114: }

unix.superglobalmegacorp.com

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