Annotation of nono/vm/mpu88xx0.cpp, revision 1.1.1.5

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: 
                      7: // MPU (m88xx0)
                      8: 
                      9: #include "mpu88xx0.h"
                     10: #include "config.h"
1.1.1.2   root       11: #include "sysctlr.h"
                     12: 
                     13: std::unique_ptr<MPU88200ATC> gMPU88200ATC[2];
1.1       root       14: 
                     15: // コンストラクタ
1.1.1.5 ! root       16: MPU88xx0Device::MPU88xx0Device(uint32 reset_vector)
1.1       root       17: {
1.1.1.3   root       18:        monitor_size = nnSize(79, 18);
1.1       root       19: 
1.1.1.5 ! root       20:        cpu.reset(new m88kcpu(reset_vector));
1.1.1.2   root       21: 
1.1.1.4   root       22:        // リセット例外イベントコールバック設定
1.1.1.5 ! root       23:        event.func = (DeviceCallback_t)&MPU88xx0Device::Callback;
1.1.1.4   root       24: 
1.1.1.2   root       25:        // LUNA88K では CMMU の ID は次のように割り振ってあるようだ。
                     26:        // OpenBSD の sys/arch/luna68k/include/board.h より。
                     27:        //
                     28:        //       Inst Data
                     29:        // CPU#0 ID=7 ID=6
                     30:        // CPU#1 ID=5 ID=4
                     31:        // CPU#2 ID=3 ID=2
                     32:        // CPU#3 ID=1 ID=0
                     33:        //
                     34:        // 厳密にはこれは LUNA88K のハードウェアがどういうコンフィグレーションで
                     35:        // m88200 を使うかなので、ここではなくて vm_luna あたりのほうがいいかも
                     36:        // しれんけど、あまり遠いのも面倒なので、とりあえずこの辺に。
                     37:        // あとマルチプロセッサになったらまたその時考える。
                     38:        cpu->cmmu[0].SetID(7);
                     39:        cpu->cmmu[1].SetID(6);
                     40: 
                     41:        // モニタ用の別オブジェクト
                     42:        gMPU88200ATC[0].reset(new MPU88200ATC(&cpu->cmmu[0]));
                     43:        gMPU88200ATC[1].reset(new MPU88200ATC(&cpu->cmmu[1]));
1.1       root       44: }
                     45: 
                     46: // デストラクタ
                     47: MPU88xx0Device::~MPU88xx0Device()
                     48: {
                     49: }
                     50: 
1.1.1.5 ! root       51: bool
        !            52: MPU88xx0Device::Init()
        !            53: {
        !            54:        // 親クラス
        !            55:        if (inherited::Init() == false) {
        !            56:                return false;
        !            57:        }
        !            58:        // MPU クロックは親 Init() で読み込んで、ここで cpu にセットする
        !            59:        cpu->SetClockSpeed(clock_khz);
        !            60: 
        !            61:        return true;
        !            62: }
        !            63: 
1.1.1.4   root       64: // リセット例外イベントコールバック
1.1       root       65: void
1.1.1.5 ! root       66: MPU88xx0Device::Callback(Event& ev)
1.1       root       67: {
1.1.1.5 ! root       68:        cpu->RequestReset();
1.1       root       69: }
                     70: 
1.1.1.4   root       71: // アクセスウェイトを加算
                     72: void
1.1.1.5 ! root       73: MPU88xx0Device::AddCycle(int32 cycle)
1.1.1.4   root       74: {
                     75:        // 今アクセスしてきている(= バスマスターの) CMMU に対して加算する
                     76:        m88200 *cmmu = m88200::GetBusMaster();
                     77:        assert(cmmu);
                     78:        cmmu->AddCycle(cycle);
                     79: }
                     80: 
1.1.1.2   root       81: // Interrupt
                     82: void
1.1.1.5 ! root       83: MPU88xx0Device::Interrupt(int level)
1.1.1.2   root       84: {
1.1.1.5 ! root       85:        cpu->Interrupt(level);
1.1.1.2   root       86: }
                     87: 
1.1       root       88: // モニター更新
1.1.1.3   root       89: void
                     90: MPU88xx0Device::MonitorUpdate(TextScreen& monitor)
1.1       root       91: {
                     92:        m88100reg reg;
                     93:        int x;
                     94:        int y;
                     95: 
                     96:        monitor.Clear();
                     97: 
                     98:        // ローカルにコピー
                     99:        reg = *cpu;
                    100: 
                    101:        //
                    102:        for (int i = 0; i < countof(reg.r); i++) {
                    103:                monitor.Print((i / 8) * 14, i % 8, "r%-2d:%08x", i, reg.r[i]);
                    104:        }
                    105: 
                    106:        // 制御レジスタ
                    107:        x = 0;
                    108:        y = 9;
1.1.1.2   root      109:        monitor.Print(x, y++,  "pid (cr0):%08x(Arch=$%02x Ver=$%02x MC=%s)",
1.1       root      110:                reg.pid,
                    111:                (reg.pid >> 8) & 0xff,
1.1.1.2   root      112:                (reg.pid >> 1) & 0x7f,
                    113:                (reg.pid & 1) ? "Master" : "Checker");
                    114:        monitor.Print(x, y, "psr (cr1):%08x(", reg.psr);
                    115:        monitor.Puts(x + 19, y, TA::OnOff(reg.psr  & m88100reg::PSR_SUPER), "S");
                    116:        monitor.Puts(x + 21, y,
                    117:                ((reg.psr & m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
                    118:        monitor.Puts(x + 27, y, TA::OnOff(reg.psr  & m88100reg::PSR_SER),  "SER");
                    119:        monitor.Puts(x + 31, y, TA::OnOff(reg.psr  & m88100reg::PSR_C),    "Cy");
                    120:        monitor.Puts(x + 34, y, TA::OnOff(reg.psr  & m88100reg::PSR_SFD1), "SFD1");
                    121:        monitor.Puts(x + 39, y, TA::OnOff(reg.psr  & m88100reg::PSR_MXM),  "MXM");
                    122:        monitor.Puts(x + 43, y, TA::OnOff(reg.psr  & m88100reg::PSR_IND),  "IND");
                    123:        monitor.Puts(x + 47, y, TA::OnOff(reg.psr  & m88100reg::PSR_SFRZ), "SFRZ");
                    124:        monitor.Puts(x + 51, y, ")");
                    125:        y++;
                    126:        monitor.Print(x, y, "epsr(cr2):%08x(", reg.epsr);
                    127:        monitor.Puts(x + 19, y, TA::OnOff(reg.epsr & m88100reg::PSR_SUPER), "S");
                    128:        monitor.Puts(x + 21, y,
                    129:                ((reg.epsr& m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
                    130:        monitor.Puts(x + 27, y, TA::OnOff(reg.epsr & m88100reg::PSR_SER),  "SER");
                    131:        monitor.Puts(x + 31, y, TA::OnOff(reg.epsr & m88100reg::PSR_C),    "Cy");
                    132:        monitor.Puts(x + 34, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFD1), "SFD1");
                    133:        monitor.Puts(x + 39, y, TA::OnOff(reg.epsr & m88100reg::PSR_MXM),  "MXM");
                    134:        monitor.Puts(x + 43, y, TA::OnOff(reg.epsr & m88100reg::PSR_IND),  "IND");
                    135:        monitor.Puts(x + 47, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFRZ), "SFRZ");
                    136:        monitor.Puts(x + 51, y, ")");
1.1       root      137: 
1.1.1.2   root      138:        // 制御レジスタ(左中; *IP)
1.1       root      139:        x = 0;
                    140:        y = 12;
                    141:        monitor.Print(x, y + 0, "xip:%08x  opX:%08x(%c%c)",
                    142:                reg.xip, (uint32)reg.opX,
                    143:                cpu->OpIsBusErr(reg.opX) ? 'B' : '-',
                    144:                cpu->OpIsDelay(reg.opX)  ? 'D' : '-');
                    145:        monitor.Print(x, y + 1, "nip:%08x  opF:%08x(%c%c)",
                    146:                reg.nip, (uint32)reg.opF,
                    147:                cpu->OpIsBusErr(reg.opF) ? 'B' : '-',
                    148:                cpu->OpIsDelay(reg.opF)  ? 'D' : '-');
                    149:        monitor.Print(x, y + 2, "fip:%08x", reg.fip);
                    150: 
                    151:        // 制御レジスタ (S*IP)
                    152:        x = 32;
                    153:        for (int i = 0; i < 3; i++) {
                    154:                monitor.Print(x, y + i, "%s(cr%d):%08x:%c%c",
                    155:                        m88100reg::sipname[i], 4 + i,
                    156:                        (reg.cr[4 + i] & m88100reg::SIP_MASK),
                    157:                        (reg.cr[4 + i] & m88100reg::SIP_V) ? 'V' : '-',
                    158:                        (reg.cr[4 + i] & m88100reg::SIP_E) ? 'E' : '-');
                    159:        }
                    160: 
1.1.1.2   root      161:        // 制御レジスタ(右中)
1.1       root      162:        x = 55;
                    163:        y = 9;
                    164:        for (int i = 0; i < 4; i++) {
                    165:                int rn = 17 + i;
1.1.1.4   root      166:                monitor.Print(x, y++, "sr%d(cr%d):%08x", i, rn, reg.cr[rn]);
1.1       root      167:        }
1.1.1.4   root      168:        monitor.Print(x, y++, "ssbr(cr3):%08x", reg.ssbr);
                    169:        monitor.Print(x, y++, "vbr (cr7):%08x", reg.vbr);
1.1       root      170: 
1.1.1.2   root      171:        // MMU レジスタ(下段)
                    172:        y = 15;
                    173:        for (int i = 0; i <= 2; i++) {
                    174:                int dt =  8 + i * 3;
                    175:                int dd =  9 + i * 3;
                    176:                int da = 10 + i * 3;
                    177: 
                    178:                monitor.Print(0, y, "dmt%d(cr%-2d):%04x",
                    179:                        i, dt, (reg.cr[dt] & 0xffff));
                    180:                monitor.Puts(15, y, "(b,s,d,l,rx, s,en  ,w,v)");
                    181:                monitor.Puts(16, y, (reg.cr[dt] & m88100reg::DM_BO)     ? "B" : "-");
                    182:                monitor.Puts(18, y, (reg.cr[dt] & m88100reg::DM_DAS)    ? "S" : "U");
                    183:                monitor.Puts(20, y, (reg.cr[dt] & m88100reg::DM_DOUB1)  ? "D" : "-");
                    184:                monitor.Puts(22, y, (reg.cr[dt] & m88100reg::DM_LOCK)   ? "L" : "-");
                    185:                // カンマが自然に見えるようにここだけカンマも含めて前詰めで出力
                    186:                monitor.Print(25, y, "%d,",
                    187:                        (reg.cr[dt] & m88100reg::DM_DREG_MASK) >> 7);
                    188:                monitor.Puts(28, y, (reg.cr[dt] & m88100reg::DM_SIGNED) ? "S" : "-");
                    189:                uint32 en = (reg.cr[dt] & m88100reg::DM_EN_MASK) >> 2;
                    190:                monitor.Puts(30, y, m88100reg::dmt_en_str[en]);
                    191:                monitor.Puts(35, y, (reg.cr[dt] & m88100reg::DM_WRITE)  ? "W" : "-");
                    192:                monitor.Puts(37, y, (reg.cr[dt] & m88100reg::DM_VALID)  ? "V" : "-");
                    193: 
                    194:                monitor.Print(40, y, "dmd%d(cr%-2d):%08x", i, dd, reg.cr[dd]);
                    195:                monitor.Print(60, y, "dma%d(cr%2d):%08x",  i, da, reg.cr[da]);
                    196:                y++;
                    197:        }
                    198: }
                    199: 
                    200: //
                    201: // {B,P}ATC モニタ
                    202: //
                    203: 
                    204: // コンストラクタ
                    205: MPU88200ATC::MPU88200ATC(m88200 *cmmu_)
                    206: {
                    207:        cmmu = cmmu_;
                    208: 
1.1.1.3   root      209:        monitor_size = nnSize(65, 38);
1.1.1.2   root      210: }
                    211: 
1.1.1.3   root      212: void
                    213: MPU88200ATC::MonitorUpdate(TextScreen& monitor)
1.1.1.2   root      214: {
                    215:        int x;
                    216:        int y;
                    217: 
                    218:        monitor.Clear();
                    219: 
                    220:        monitor.Print(0, 0,  "SAPR  %05x'000 TE=%d      %c%c%c",
                    221:                (cmmu->sapr.addr >> 12) & 0xfffff,
                    222:                 cmmu->sapr.enable ? 1 : 0,
                    223:                (cmmu->sapr.stat & m88200::APR_WT) ? 'T' : '-',
                    224:                (cmmu->sapr.stat & m88200::APR_G)  ? 'G' : '-',
                    225:                (cmmu->sapr.stat & m88200::APR_CI) ? 'C' : '-');
                    226: 
                    227:        monitor.Print(34, 0, "UAPR  %05x'000 TE=%d      %c%c%c",
                    228:                (cmmu->uapr.addr >> 12) & 0xfffff,
                    229:                 cmmu->uapr.enable ? 1 : 0,
                    230:                (cmmu->uapr.stat & m88200::APR_WT) ? 'T' : '-',
                    231:                (cmmu->uapr.stat & m88200::APR_G)  ? 'G' : '-',
                    232:                (cmmu->uapr.stat & m88200::APR_CI) ? 'C' : '-');
                    233: 
                    234:        monitor.Puts(0,  1, "<BATC>");
                    235:        monitor.Puts(0,  2, "No. LBA         PBA       Stat");
                    236:        monitor.Puts(34, 2, "No. LBA         PBA       Stat");
                    237:        x = 0;
                    238:        y = 3;
                    239:        for (int i = 0; i < 10; i++) {
                    240:                m88200BATC& b = cmmu->batc[i];
                    241: 
                    242:                if (i == cmmu->batc.size() / 2) {
                    243:                        x = 34;
                    244:                        y = 3;
                    245:                }
                    246:                if (i < 8) {
                    247:                        monitor.Print(x, y, " %d:", i);
                    248:                } else {
                    249:                        monitor.Print(x, y, "(%d)", i);
                    250:                }
                    251:                if ((b.lba & 1) == 0) {
                    252:                        monitor.Print(x + 4, y, "%c:%04x'0000 %04x'0000 %c%c%c%c",
                    253:                                (b.lba & m88200::BATC_S) ? 'S' : 'U',
                    254:                                b.lba >> 16, b.pba >> 16,
                    255:                                (b.stat & m88200::DESC_WT) ? 'T' : '-',
                    256:                                (b.stat & m88200::DESC_G)  ? 'G' : '-',
                    257:                                (b.stat & m88200::DESC_CI) ? 'C' : '-',
                    258:                                (b.stat & m88200::DESC_WP) ? 'P' : '-');
                    259:                }
                    260:                y++;
                    261:        }
                    262: 
                    263:        monitor.Puts(0,  8, "<PATC>");
                    264:        monitor.Puts(0,  9, "No. LPA         PFA       Stat");
                    265:        monitor.Puts(34, 9, "No. LPA         PFA       Stat");
                    266: 
                    267:        x = 0;
                    268:        y = 10;
                    269:        for (int i = 0; i < cmmu->patc.size(); i++) {
                    270:                m88200PATC& p = cmmu->patc[i];
                    271: 
                    272:                if (i == cmmu->patc.size() / 2) {
                    273:                        x = 34;
                    274:                        y = 10;
                    275:                }
                    276: 
                    277:                monitor.Print(x, y, "%2d:", i);
                    278:                if ((p.lpa & 1) == 0) {
                    279:                        monitor.Print(x + 4,  y, "%c:%05x'000 %05x'000 %c%c%c%c%c",
                    280:                                (p.lpa & m88200::PATC_S) ? 'S' : 'U',
                    281:                                p.lpa >> 12, p.pfa >> 12,
                    282:                                (p.stat & m88200::DESC_WT) ? 'T' : '-',
                    283:                                (p.stat & m88200::DESC_G)  ? 'G' : '-',
                    284:                                (p.stat & m88200::DESC_CI) ? 'C' : '-',
                    285:                                (p.stat & m88200::DESC_WP) ? 'P' : '-',
                    286:                                p.m                        ? 'M' : '-');
                    287:                }
                    288: 
                    289:                y++;
                    290:        }
1.1       root      291: }

unix.superglobalmegacorp.com

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