Annotation of nono/vm/vm_x68k.cpp, revision 1.1.1.11

1.1       root        1: //
                      2: // nono
1.1.1.2   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
1.1.1.8   root        7: //
                      8: // VM (X68030)
                      9: //
                     10: 
1.1       root       11: #include "vm_x68k.h"
1.1.1.2   root       12: #include "config.h"
1.1.1.5   root       13: #include "dmac.h"
1.1.1.10  root       14: #include "extram.h"
1.1.1.5   root       15: #include "fdc.h"
1.1       root       16: #include "human68k.h"
1.1.1.4   root       17: #include "interrupt.h"
1.1.1.7   root       18: #include "mainapp.h"
1.1.1.10  root       19: #include "mainbus.h"
1.1.1.5   root       20: #include "mfp.h"
1.1.1.2   root       21: #include "mpu680x0.h"
1.1.1.8   root       22: #include "nmi.h"
1.1.1.5   root       23: #include "pedec.h"
                     24: #include "pluto.h"
                     25: #include "pio.h"
1.1.1.8   root       26: #include "power.h"
1.1       root       27: #include "renderer.h"
                     28: #include "rp5c15.h"
1.1.1.6   root       29: #include "romimg_x68k.h"
1.1       root       30: #include "scheduler.h"
1.1.1.5   root       31: #include "spc.h"
1.1.1.10  root       32: #include "x68kio.h"
1.1       root       33: #include "x68kkbd.h"
                     34: 
                     35: // コンストラクタ
                     36: VM_X68030::VM_X68030()
                     37: {
1.1.1.2   root       38:        // 機種固有パラメータ
                     39:        // MPU クロックの初期値は機種ごとに異なる。単位は MHz
                     40:        gConfig->SetDefault("mpu-clock", 25);
                     41:        // RAM 初期値は MAX にしておく
                     42:        gConfig->SetDefault("ram-size", 12);
                     43:        // SPC の入力クロック (5MHz = 200ns)
                     44:        gConfig->Add("!spc-tCLF", 200);
                     45: 
1.1       root       46:        // デバイス (順序に注意)
1.1.1.2   root       47:        // BusErrDevice は親コンストラクタで作成済み。
1.1.1.8   root       48:        NEWDV(MPU, new MPU680x0Device());
                     49:        NEWDV(Interrupt, new X68030Interrupt());
1.1.1.10  root       50:        NEWDV(MainRAM, new MainRAMDevice());                    // req. by X68kIO,Human68k
                     51:        NEWDV(X68kIO, new X68kIODevice());
1.1.1.8   root       52:        NEWDV(IPLROM0, new IPLROM0Device());
1.1.1.10  root       53:        NEWDV(ExtRAM, new ExtRAMDevice());
1.1.1.8   root       54: 
                     55:        NEWDV(NMI, new NMIDevice());
                     56:        NEWDV(Keyboard, new X68030Keyboard());
                     57:        NEWDV(Renderer, new X68030Renderer());
1.1       root       58: 
1.1.1.7   root       59:        if (gMainApp.human_mode) {
1.1.1.8   root       60:                NEWDV(Human68k, new Human68k());
1.1.1.7   root       61:        }
                     62: 
1.1.1.10  root       63:        // デバイスの割り当ては Init() で行っている。
1.1       root       64: }
                     65: 
                     66: // デストラクタ
                     67: VM_X68030::~VM_X68030()
                     68: {
                     69: }
                     70: 
1.1.1.10  root       71: bool
                     72: VM_X68030::Init()
                     73: {
                     74:        if (inherited::Init() == false) {
                     75:                return false;
                     76:        }
                     77: 
                     78:        // 拡張メモリのサイズが確定したので、ここで配置。
                     79:        auto mainbus = dynamic_cast<MainbusDevice *>(pMainbus.get());
                     80:        auto xiospace = dynamic_cast<X68kIODevice *>(pX68kIO.get());
                     81:        auto extram = dynamic_cast<ExtRAMDevice *>(pExtRAM.get());
                     82:        int extsize = extram->GetSizeMB();
                     83: 
1.1.1.11! root       84:        // 上位8ビット全域を一旦全部ミラーで埋めてから
        !            85:        for (int i = 0; i < mainbus->devtable.size(); i++) {
        !            86:                mainbus->SetDevice(i, xiospace);
        !            87:        }
        !            88:        if (extsize == 16) {
1.1.1.10  root       89:                // TS-6BE16 互換 (16MB) なら、
                     90:                // $01: ExtRAM
                     91:                mainbus->SetDevice(1, extram);
                     92:        } else {
                     93:                // 060turbo 互換。とりあえず 128MB/256MB のみ。この場合は
                     94:                // $10..$17: ExtRAM (128MB)
                     95:                // $18..$1f: ExtRAM (256MB)
                     96:                for (int i = 0x10, end = i + (extsize / 16); i < end; i++) {
                     97:                        mainbus->SetDevice(i, extram);
                     98:                }
                     99:        }
                    100: 
                    101:        return true;
                    102: }
                    103: 
1.1.1.6   root      104: // ブートページを切り替える。
                    105: void
                    106: VM_X68030::SwitchBootPage(Device *parent, bool isrom)
                    107: {
1.1.1.7   root      108:        if (gMainApp.human_mode) {
                    109:                // Human モードではブートページを RAM に見せる。
                    110:                // 今のところ。
                    111:                return;
                    112:        }
                    113: 
1.1.1.6   root      114:        // 共通処理
                    115:        inherited::SwitchBootPage(parent, isrom);
                    116: 
1.1.1.10  root      117:        // X68030 では X68kIO が担当している
                    118:        auto xiospace = dynamic_cast<X68kIODevice *>(pX68kIO.get());
                    119:        xiospace->SwitchBootPage(isrom);
1.1       root      120: }
                    121: 
1.1.1.5   root      122: // リセットについて
                    123: //
                    124: //           PWRRESET
                    125: // 電源オン ----------+--> VIPS
                    126: // (7505)             +--> VideoCtlr
                    127: //                    +--> OSCIAN2
                    128: //                    |
                    129: //                    |   +------+
                    130: //                    +-->|      |
1.1.1.9   root      131: // 本体      SWRESET      | YUKI |
                    132: // リセット ------------->|      |
1.1.1.5   root      133: // スイッチ               +------+
1.1.1.9   root      134: //                         | IPLRESET
                    135: //                         |
                    136: //                         +--> FPU
1.1.1.5   root      137: //                         |
                    138: //                         ▽
                    139: //                   RESET |
                    140: //                         |<-> MPU (68030)
1.1.1.9   root      141: //                         +--> PPI (8255)
                    142: //                         +--> SPC (MB89352)
                    143: //                         +--> ADPCM (MSM6258)
                    144: //                         +--> FDC (uPD72065B)
                    145: //                         +--> MFP (MC68901)
                    146: //                         |
                    147: //                         |   +-------+
                    148: //                         +-->| PEDEC |
                    149: //                         |   +-------+
                    150: //                         |     |
                    151: //                         |     +-- OPMIC -----> OPM(YM2151)
                    152: //                         |     +-- SCCRD/WR --> SCC(Z8530)
1.1.1.5   root      153: //                         |
                    154: //                         |      EXRESET
                    155: //                         +---|>-----------> 外部バス
                    156: //                         ▽
                    157: //                SYSRESET |
                    158: //                         |<-> SAKI  ---+
                    159: //                         |             | BEC0,BEC1
                    160: //                         +--> DMAC  <--+
                    161: //                         +--> CYNTHIA
                    162: // リセットされない?
                    163: // o CACHY
                    164: 
                    165: // MPU の RESET 命令によるリセット
                    166: void
                    167: VM_X68030::ResetByMPU()
                    168: {
1.1.1.10  root      169:        std::vector<int> ids {
                    170:                OBJ_DMAC,
                    171:                OBJ_FDC,
                    172:                OBJ_MFP,
                    173:                OBJ_PEDEC,
                    174:                OBJ_PLUTO,
                    175:                OBJ_PPI,
                    176:                OBJ_SPC,
                    177:        };
                    178:        for (auto id : ids) {
                    179:                auto dev = gMainApp.GetObject<IODevice>(id);
                    180:                dev->ResetHard(false);
                    181:        }
1.1.1.5   root      182: }

unix.superglobalmegacorp.com

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