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

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: // コンストラクタ
                     16: MPU88xx0Device::MPU88xx0Device(uint32 addr)
                     17: {
1.1.1.3 ! root       18:        monitor_size = nnSize(79, 18);
1.1       root       19: 
                     20:        // リセットベクタアドレスは Reset() で指定するので保持しておく
                     21:        reset_vector = addr;
                     22: 
                     23:        cpu.reset(new m88kcpu());
1.1.1.2   root       24: 
                     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: 
                     51: // リセット
                     52: // (MPU が動くのはこの後 Scheduler::Run() を発行した後)
                     53: void
                     54: MPU88xx0Device::ResetHard()
                     55: {
                     56:        cpu->Reset(reset_vector);
                     57: }
                     58: 
1.1.1.2   root       59: // Interrupt
                     60: void
                     61: MPU88xx0Device::Interrupt(Object *src, int level)
                     62: {
                     63:        // XXX: なぜか 1 レベルずれている?
                     64:        level++;
                     65:        if (gSysCtlr->GetIntMask(0) & (1 << level)) {
                     66:                putlog(1, "Interrupt from %s", src->devname.c_str());
                     67:                gSysCtlr->TellIntLevel(0, 1 << level);
                     68:                cpu->Interrupt();
                     69:        }
                     70: }
                     71: 
1.1       root       72: // モニター更新
1.1.1.3 ! root       73: void
        !            74: MPU88xx0Device::MonitorUpdate(TextScreen& monitor)
1.1       root       75: {
                     76:        m88100reg reg;
                     77:        int x;
                     78:        int y;
                     79: 
                     80:        monitor.Clear();
                     81: 
                     82:        // ローカルにコピー
                     83:        reg = *cpu;
                     84: 
                     85:        //
                     86:        for (int i = 0; i < countof(reg.r); i++) {
                     87:                monitor.Print((i / 8) * 14, i % 8, "r%-2d:%08x", i, reg.r[i]);
                     88:        }
                     89: 
                     90:        // 制御レジスタ
                     91:        x = 0;
                     92:        y = 9;
1.1.1.2   root       93:        monitor.Print(x, y++,  "pid (cr0):%08x(Arch=$%02x Ver=$%02x MC=%s)",
1.1       root       94:                reg.pid,
                     95:                (reg.pid >> 8) & 0xff,
1.1.1.2   root       96:                (reg.pid >> 1) & 0x7f,
                     97:                (reg.pid & 1) ? "Master" : "Checker");
                     98:        monitor.Print(x, y, "psr (cr1):%08x(", reg.psr);
                     99:        monitor.Puts(x + 19, y, TA::OnOff(reg.psr  & m88100reg::PSR_SUPER), "S");
                    100:        monitor.Puts(x + 21, y,
                    101:                ((reg.psr & m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
                    102:        monitor.Puts(x + 27, y, TA::OnOff(reg.psr  & m88100reg::PSR_SER),  "SER");
                    103:        monitor.Puts(x + 31, y, TA::OnOff(reg.psr  & m88100reg::PSR_C),    "Cy");
                    104:        monitor.Puts(x + 34, y, TA::OnOff(reg.psr  & m88100reg::PSR_SFD1), "SFD1");
                    105:        monitor.Puts(x + 39, y, TA::OnOff(reg.psr  & m88100reg::PSR_MXM),  "MXM");
                    106:        monitor.Puts(x + 43, y, TA::OnOff(reg.psr  & m88100reg::PSR_IND),  "IND");
                    107:        monitor.Puts(x + 47, y, TA::OnOff(reg.psr  & m88100reg::PSR_SFRZ), "SFRZ");
                    108:        monitor.Puts(x + 51, y, ")");
                    109:        y++;
                    110:        monitor.Print(x, y, "epsr(cr2):%08x(", reg.epsr);
                    111:        monitor.Puts(x + 19, y, TA::OnOff(reg.epsr & m88100reg::PSR_SUPER), "S");
                    112:        monitor.Puts(x + 21, y,
                    113:                ((reg.epsr& m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
                    114:        monitor.Puts(x + 27, y, TA::OnOff(reg.epsr & m88100reg::PSR_SER),  "SER");
                    115:        monitor.Puts(x + 31, y, TA::OnOff(reg.epsr & m88100reg::PSR_C),    "Cy");
                    116:        monitor.Puts(x + 34, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFD1), "SFD1");
                    117:        monitor.Puts(x + 39, y, TA::OnOff(reg.epsr & m88100reg::PSR_MXM),  "MXM");
                    118:        monitor.Puts(x + 43, y, TA::OnOff(reg.epsr & m88100reg::PSR_IND),  "IND");
                    119:        monitor.Puts(x + 47, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFRZ), "SFRZ");
                    120:        monitor.Puts(x + 51, y, ")");
1.1       root      121: 
1.1.1.2   root      122:        // 制御レジスタ(左中; *IP)
1.1       root      123:        x = 0;
                    124:        y = 12;
                    125:        monitor.Print(x, y + 0, "xip:%08x  opX:%08x(%c%c)",
                    126:                reg.xip, (uint32)reg.opX,
                    127:                cpu->OpIsBusErr(reg.opX) ? 'B' : '-',
                    128:                cpu->OpIsDelay(reg.opX)  ? 'D' : '-');
                    129:        monitor.Print(x, y + 1, "nip:%08x  opF:%08x(%c%c)",
                    130:                reg.nip, (uint32)reg.opF,
                    131:                cpu->OpIsBusErr(reg.opF) ? 'B' : '-',
                    132:                cpu->OpIsDelay(reg.opF)  ? 'D' : '-');
                    133:        monitor.Print(x, y + 2, "fip:%08x", reg.fip);
                    134: 
                    135:        // 制御レジスタ (S*IP)
                    136:        x = 32;
                    137:        for (int i = 0; i < 3; i++) {
                    138:                monitor.Print(x, y + i, "%s(cr%d):%08x:%c%c",
                    139:                        m88100reg::sipname[i], 4 + i,
                    140:                        (reg.cr[4 + i] & m88100reg::SIP_MASK),
                    141:                        (reg.cr[4 + i] & m88100reg::SIP_V) ? 'V' : '-',
                    142:                        (reg.cr[4 + i] & m88100reg::SIP_E) ? 'E' : '-');
                    143:        }
                    144: 
1.1.1.2   root      145:        // 制御レジスタ(右中)
1.1       root      146:        x = 55;
                    147:        y = 9;
                    148:        monitor.Print(x, y++, "ssbr(cr3):%08x", reg.ssbr);
                    149:        monitor.Print(x, y++, "vbr (cr7):%08x", reg.vbr);
                    150:        for (int i = 0; i < 4; i++) {
                    151:                int rn = 17 + i;
                    152:                monitor.Print(x, y + i, "sr%d(cr%d):%08x", i, rn, reg.cr[rn]);
                    153:        }
                    154: 
1.1.1.2   root      155:        // MMU レジスタ(下段)
                    156:        x = 0;
                    157:        y = 15;
                    158:        for (int i = 0; i <= 2; i++) {
                    159:                int dt =  8 + i * 3;
                    160:                int dd =  9 + i * 3;
                    161:                int da = 10 + i * 3;
                    162: 
                    163:                monitor.Print(0, y, "dmt%d(cr%-2d):%04x",
                    164:                        i, dt, (reg.cr[dt] & 0xffff));
                    165:                monitor.Puts(15, y, "(b,s,d,l,rx, s,en  ,w,v)");
                    166:                monitor.Puts(16, y, (reg.cr[dt] & m88100reg::DM_BO)     ? "B" : "-");
                    167:                monitor.Puts(18, y, (reg.cr[dt] & m88100reg::DM_DAS)    ? "S" : "U");
                    168:                monitor.Puts(20, y, (reg.cr[dt] & m88100reg::DM_DOUB1)  ? "D" : "-");
                    169:                monitor.Puts(22, y, (reg.cr[dt] & m88100reg::DM_LOCK)   ? "L" : "-");
                    170:                // カンマが自然に見えるようにここだけカンマも含めて前詰めで出力
                    171:                monitor.Print(25, y, "%d,",
                    172:                        (reg.cr[dt] & m88100reg::DM_DREG_MASK) >> 7);
                    173:                monitor.Puts(28, y, (reg.cr[dt] & m88100reg::DM_SIGNED) ? "S" : "-");
                    174:                uint32 en = (reg.cr[dt] & m88100reg::DM_EN_MASK) >> 2;
                    175:                monitor.Puts(30, y, m88100reg::dmt_en_str[en]);
                    176:                monitor.Puts(35, y, (reg.cr[dt] & m88100reg::DM_WRITE)  ? "W" : "-");
                    177:                monitor.Puts(37, y, (reg.cr[dt] & m88100reg::DM_VALID)  ? "V" : "-");
                    178: 
                    179:                monitor.Print(40, y, "dmd%d(cr%-2d):%08x", i, dd, reg.cr[dd]);
                    180:                monitor.Print(60, y, "dma%d(cr%2d):%08x",  i, da, reg.cr[da]);
                    181:                y++;
                    182:        }
                    183: }
                    184: 
                    185: //
                    186: // {B,P}ATC モニタ
                    187: //
                    188: 
                    189: // コンストラクタ
                    190: MPU88200ATC::MPU88200ATC(m88200 *cmmu_)
                    191: {
                    192:        cmmu = cmmu_;
                    193: 
1.1.1.3 ! root      194:        monitor_size = nnSize(65, 38);
1.1.1.2   root      195: }
                    196: 
1.1.1.3 ! root      197: void
        !           198: MPU88200ATC::MonitorUpdate(TextScreen& monitor)
1.1.1.2   root      199: {
                    200:        int x;
                    201:        int y;
                    202: 
                    203:        monitor.Clear();
                    204: 
                    205:        monitor.Print(0, 0,  "SAPR  %05x'000 TE=%d      %c%c%c",
                    206:                (cmmu->sapr.addr >> 12) & 0xfffff,
                    207:                 cmmu->sapr.enable ? 1 : 0,
                    208:                (cmmu->sapr.stat & m88200::APR_WT) ? 'T' : '-',
                    209:                (cmmu->sapr.stat & m88200::APR_G)  ? 'G' : '-',
                    210:                (cmmu->sapr.stat & m88200::APR_CI) ? 'C' : '-');
                    211: 
                    212:        monitor.Print(34, 0, "UAPR  %05x'000 TE=%d      %c%c%c",
                    213:                (cmmu->uapr.addr >> 12) & 0xfffff,
                    214:                 cmmu->uapr.enable ? 1 : 0,
                    215:                (cmmu->uapr.stat & m88200::APR_WT) ? 'T' : '-',
                    216:                (cmmu->uapr.stat & m88200::APR_G)  ? 'G' : '-',
                    217:                (cmmu->uapr.stat & m88200::APR_CI) ? 'C' : '-');
                    218: 
                    219:        monitor.Puts(0,  1, "<BATC>");
                    220:        monitor.Puts(0,  2, "No. LBA         PBA       Stat");
                    221:        monitor.Puts(34, 2, "No. LBA         PBA       Stat");
                    222:        x = 0;
                    223:        y = 3;
                    224:        for (int i = 0; i < 10; i++) {
                    225:                m88200BATC& b = cmmu->batc[i];
                    226: 
                    227:                if (i == cmmu->batc.size() / 2) {
                    228:                        x = 34;
                    229:                        y = 3;
                    230:                }
                    231:                if (i < 8) {
                    232:                        monitor.Print(x, y, " %d:", i);
                    233:                } else {
                    234:                        monitor.Print(x, y, "(%d)", i);
                    235:                }
                    236:                if ((b.lba & 1) == 0) {
                    237:                        monitor.Print(x + 4, y, "%c:%04x'0000 %04x'0000 %c%c%c%c",
                    238:                                (b.lba & m88200::BATC_S) ? 'S' : 'U',
                    239:                                b.lba >> 16, b.pba >> 16,
                    240:                                (b.stat & m88200::DESC_WT) ? 'T' : '-',
                    241:                                (b.stat & m88200::DESC_G)  ? 'G' : '-',
                    242:                                (b.stat & m88200::DESC_CI) ? 'C' : '-',
                    243:                                (b.stat & m88200::DESC_WP) ? 'P' : '-');
                    244:                }
                    245:                y++;
                    246:        }
                    247: 
                    248:        monitor.Puts(0,  8, "<PATC>");
                    249:        monitor.Puts(0,  9, "No. LPA         PFA       Stat");
                    250:        monitor.Puts(34, 9, "No. LPA         PFA       Stat");
                    251: 
                    252:        x = 0;
                    253:        y = 10;
                    254:        for (int i = 0; i < cmmu->patc.size(); i++) {
                    255:                m88200PATC& p = cmmu->patc[i];
                    256: 
                    257:                if (i == cmmu->patc.size() / 2) {
                    258:                        x = 34;
                    259:                        y = 10;
                    260:                }
                    261: 
                    262:                monitor.Print(x, y, "%2d:", i);
                    263:                if ((p.lpa & 1) == 0) {
                    264:                        monitor.Print(x + 4,  y, "%c:%05x'000 %05x'000 %c%c%c%c%c",
                    265:                                (p.lpa & m88200::PATC_S) ? 'S' : 'U',
                    266:                                p.lpa >> 12, p.pfa >> 12,
                    267:                                (p.stat & m88200::DESC_WT) ? 'T' : '-',
                    268:                                (p.stat & m88200::DESC_G)  ? 'G' : '-',
                    269:                                (p.stat & m88200::DESC_CI) ? 'C' : '-',
                    270:                                (p.stat & m88200::DESC_WP) ? 'P' : '-',
                    271:                                p.m                        ? 'M' : '-');
                    272:                }
                    273: 
                    274:                y++;
                    275:        }
1.1       root      276: }

unix.superglobalmegacorp.com

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