|
|
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:
1.1 root 13: // コンストラクタ
1.1.1.7 root 14: MPU88xx0Device::MPU88xx0Device()
1.1.1.8 ! root 15: : inherited("MPU(88xx0)")
1.1 root 16: {
1.1.1.7 root 17: cpu.reset(new m88kcpu());
1.1.1.4 root 18:
1.1.1.2 root 19: // LUNA88K では CMMU の ID は次のように割り振ってあるようだ。
20: // OpenBSD の sys/arch/luna68k/include/board.h より。
21: //
22: // Inst Data
23: // CPU#0 ID=7 ID=6
24: // CPU#1 ID=5 ID=4
25: // CPU#2 ID=3 ID=2
26: // CPU#3 ID=1 ID=0
27: //
28: // 厳密にはこれは LUNA88K のハードウェアがどういうコンフィグレーションで
29: // m88200 を使うかなので、ここではなくて vm_luna あたりのほうがいいかも
30: // しれんけど、あまり遠いのも面倒なので、とりあえずこの辺に。
31: // あとマルチプロセッサになったらまたその時考える。
32: cpu->cmmu[0].SetID(7);
33: cpu->cmmu[1].SetID(6);
34:
1.1.1.8 ! root 35: // レジスタモニター
! 36: monitor.func = (MonitorCallback_t)&MPU88xx0Device::MonitorUpdate;
! 37: monitor.SetSize(79, 18);
! 38: monitor.Regist(ID_MONITOR_MPUREG);
1.1 root 39: }
40:
41: // デストラクタ
42: MPU88xx0Device::~MPU88xx0Device()
43: {
44: }
45:
1.1.1.5 root 46: bool
47: MPU88xx0Device::Init()
48: {
49: // 親クラス
50: if (inherited::Init() == false) {
51: return false;
52: }
53: // MPU クロックは親 Init() で読み込んで、ここで cpu にセットする
54: cpu->SetClockSpeed(clock_khz);
55:
1.1.1.8 ! root 56: const ConfigItem& item = gConfig->Find("mpu-pseudo-stop");
! 57: cpu->pseudo_stop_enable = (bool)item.AsInt();
! 58:
1.1.1.5 root 59: return true;
60: }
61:
1.1.1.7 root 62: bool
63: MPU88xx0Device::PowerOn()
64: {
65: cpu->PowerOn();
66: return true;
67: }
68:
1.1 root 69: void
1.1.1.7 root 70: MPU88xx0Device::ResetHard()
1.1 root 71: {
1.1.1.5 root 72: cpu->RequestReset();
1.1 root 73: }
74:
1.1.1.6 root 75: // アクセス中の論理アドレスを取得
76: uint32
77: MPU88xx0Device::GetLaddr() const
78: {
79: m88200 *cmmu = m88200::GetBusMaster();
80: assert(cmmu);
81: return cmmu->GetLaddr();
82: }
83:
84: // アクセス中の物理アドレスを取得
85: uint32
86: MPU88xx0Device::GetPaddr() const
87: {
88: m88200 *cmmu = m88200::GetBusMaster();
89: assert(cmmu);
90: return cmmu->GetPaddr();
91: }
92:
1.1.1.4 root 93: // アクセスウェイトを加算
94: void
1.1.1.5 root 95: MPU88xx0Device::AddCycle(int32 cycle)
1.1.1.4 root 96: {
97: // 今アクセスしてきている(= バスマスターの) CMMU に対して加算する
98: m88200 *cmmu = m88200::GetBusMaster();
99: assert(cmmu);
100: cmmu->AddCycle(cycle);
101: }
102:
1.1.1.2 root 103: // Interrupt
104: void
1.1.1.5 root 105: MPU88xx0Device::Interrupt(int level)
1.1.1.2 root 106: {
1.1.1.5 root 107: cpu->Interrupt(level);
1.1.1.2 root 108: }
109:
1.1 root 110: // モニター更新
1.1.1.3 root 111: void
1.1.1.8 ! root 112: MPU88xx0Device::MonitorUpdate(Monitor *, TextScreen& screen)
1.1 root 113: {
114: m88100reg reg;
115: int x;
116: int y;
117:
1.1.1.8 ! root 118: screen.Clear();
1.1 root 119:
120: // ローカルにコピー
121: reg = *cpu;
122:
123: //
124: for (int i = 0; i < countof(reg.r); i++) {
1.1.1.8 ! root 125: screen.Print((i / 8) * 14, i % 8, "r%-2d:%08x", i, reg.r[i]);
1.1 root 126: }
127:
128: // 制御レジスタ
129: x = 0;
130: y = 9;
1.1.1.8 ! root 131: screen.Print(x, y++, "pid (cr0):%08x(Arch=$%02x Ver=$%02x MC=%s)",
1.1 root 132: reg.pid,
133: (reg.pid >> 8) & 0xff,
1.1.1.2 root 134: (reg.pid >> 1) & 0x7f,
135: (reg.pid & 1) ? "Master" : "Checker");
1.1.1.8 ! root 136: screen.Print(x, y, "psr (cr1):%08x(", reg.psr);
! 137: screen.Puts(x + 19, y, TA::OnOff(reg.psr & m88100reg::PSR_SUPER), "S");
! 138: screen.Puts(x + 21, y,
1.1.1.2 root 139: ((reg.psr & m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
1.1.1.8 ! root 140: screen.Puts(x + 27, y, TA::OnOff(reg.psr & m88100reg::PSR_SER), "SER");
! 141: screen.Puts(x + 31, y, TA::OnOff(reg.psr & m88100reg::PSR_C), "Cy");
! 142: screen.Puts(x + 34, y, TA::OnOff(reg.psr & m88100reg::PSR_SFD1), "SFD1");
! 143: screen.Puts(x + 39, y, TA::OnOff(reg.psr & m88100reg::PSR_MXM), "MXM");
! 144: screen.Puts(x + 43, y, TA::OnOff(reg.psr & m88100reg::PSR_IND), "IND");
! 145: screen.Puts(x + 47, y, TA::OnOff(reg.psr & m88100reg::PSR_SFRZ), "SFRZ");
! 146: screen.Puts(x + 51, y, ")");
1.1.1.2 root 147: y++;
1.1.1.8 ! root 148: screen.Print(x, y, "epsr(cr2):%08x(", reg.epsr);
! 149: screen.Puts(x + 19, y, TA::OnOff(reg.epsr & m88100reg::PSR_SUPER), "S");
! 150: screen.Puts(x + 21, y,
1.1.1.2 root 151: ((reg.epsr& m88100reg::PSR_BO_LE) ? "BO=LE" : "BO=BE"));
1.1.1.8 ! root 152: screen.Puts(x + 27, y, TA::OnOff(reg.epsr & m88100reg::PSR_SER), "SER");
! 153: screen.Puts(x + 31, y, TA::OnOff(reg.epsr & m88100reg::PSR_C), "Cy");
! 154: screen.Puts(x + 34, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFD1), "SFD1");
! 155: screen.Puts(x + 39, y, TA::OnOff(reg.epsr & m88100reg::PSR_MXM), "MXM");
! 156: screen.Puts(x + 43, y, TA::OnOff(reg.epsr & m88100reg::PSR_IND), "IND");
! 157: screen.Puts(x + 47, y, TA::OnOff(reg.epsr & m88100reg::PSR_SFRZ), "SFRZ");
! 158: screen.Puts(x + 51, y, ")");
1.1 root 159:
1.1.1.2 root 160: // 制御レジスタ(左中; *IP)
1.1 root 161: x = 0;
162: y = 12;
1.1.1.8 ! root 163: screen.Print(x, y + 0, "xip:%08x opX:%08x(%c%c)",
1.1 root 164: reg.xip, (uint32)reg.opX,
165: cpu->OpIsBusErr(reg.opX) ? 'B' : '-',
166: cpu->OpIsDelay(reg.opX) ? 'D' : '-');
1.1.1.8 ! root 167: screen.Print(x, y + 1, "nip:%08x opF:%08x(%c%c)",
1.1 root 168: reg.nip, (uint32)reg.opF,
169: cpu->OpIsBusErr(reg.opF) ? 'B' : '-',
170: cpu->OpIsDelay(reg.opF) ? 'D' : '-');
1.1.1.8 ! root 171: screen.Print(x, y + 2, "fip:%08x", reg.fip);
1.1 root 172:
173: // 制御レジスタ (S*IP)
174: x = 32;
175: for (int i = 0; i < 3; i++) {
1.1.1.8 ! root 176: screen.Print(x, y + i, "%s(cr%d):%08x:%c%c",
1.1 root 177: m88100reg::sipname[i], 4 + i,
178: (reg.cr[4 + i] & m88100reg::SIP_MASK),
179: (reg.cr[4 + i] & m88100reg::SIP_V) ? 'V' : '-',
180: (reg.cr[4 + i] & m88100reg::SIP_E) ? 'E' : '-');
181: }
182:
1.1.1.2 root 183: // 制御レジスタ(右中)
1.1 root 184: x = 55;
185: y = 9;
186: for (int i = 0; i < 4; i++) {
187: int rn = 17 + i;
1.1.1.8 ! root 188: screen.Print(x, y++, "sr%d(cr%d):%08x", i, rn, reg.cr[rn]);
1.1 root 189: }
1.1.1.8 ! root 190: screen.Print(x, y++, "ssbr(cr3):%08x", reg.ssbr);
! 191: screen.Print(x, y++, "vbr (cr7):%08x", reg.vbr);
1.1 root 192:
1.1.1.2 root 193: // MMU レジスタ(下段)
194: y = 15;
195: for (int i = 0; i <= 2; i++) {
196: int dt = 8 + i * 3;
197: int dd = 9 + i * 3;
198: int da = 10 + i * 3;
199:
1.1.1.8 ! root 200: screen.Print(0, y, "dmt%d(cr%-2d):%04x",
1.1.1.2 root 201: i, dt, (reg.cr[dt] & 0xffff));
1.1.1.8 ! root 202: screen.Puts(15, y, "(b,s,d,l,rx, s,en ,w,v)");
! 203: screen.Puts(16, y, (reg.cr[dt] & m88100reg::DM_BO) ? "B" : "-");
! 204: screen.Puts(18, y, (reg.cr[dt] & m88100reg::DM_DAS) ? "S" : "U");
! 205: screen.Puts(20, y, (reg.cr[dt] & m88100reg::DM_DOUB1) ? "D" : "-");
! 206: screen.Puts(22, y, (reg.cr[dt] & m88100reg::DM_LOCK) ? "L" : "-");
1.1.1.2 root 207: // カンマが自然に見えるようにここだけカンマも含めて前詰めで出力
1.1.1.8 ! root 208: screen.Print(25, y, "%d,",
1.1.1.2 root 209: (reg.cr[dt] & m88100reg::DM_DREG_MASK) >> 7);
1.1.1.8 ! root 210: screen.Puts(28, y, (reg.cr[dt] & m88100reg::DM_SIGNED) ? "S" : "-");
1.1.1.2 root 211: uint32 en = (reg.cr[dt] & m88100reg::DM_EN_MASK) >> 2;
1.1.1.8 ! root 212: screen.Puts(30, y, m88100reg::dmt_en_str[en]);
! 213: screen.Puts(35, y, (reg.cr[dt] & m88100reg::DM_WRITE) ? "W" : "-");
! 214: screen.Puts(37, y, (reg.cr[dt] & m88100reg::DM_VALID) ? "V" : "-");
1.1.1.2 root 215:
1.1.1.8 ! root 216: screen.Print(40, y, "dmd%d(cr%-2d):%08x", i, dd, reg.cr[dd]);
! 217: screen.Print(60, y, "dma%d(cr%2d):%08x", i, da, reg.cr[da]);
1.1.1.2 root 218: y++;
219: }
1.1 root 220: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.