--- nono/m680x0/m68030mmu.cpp 2026/04/29 17:05:26 1.1.1.10 +++ nono/m680x0/m68030mmu.cpp 2026/04/29 17:05:31 1.1.1.11 @@ -78,7 +78,7 @@ indent_format(int indent, const char *fm class m68030MMU final { public: - m68030MMU(MPU680x0Device *, int loglevel_); + m68030MMU(MPU68030Device *, int loglevel_); ~m68030MMU(); // サーチを実行 @@ -97,12 +97,6 @@ class m68030MMU final // ディスクリプタを取得 bool fetch_desc(uint32, int); - // MMU による物理メモリ読み込み - busdata phys_read_4(uint32 addr); - - // MMU による物理メモリ書き込み - busdata phys_write_4(uint32 addr, uint32 data); - // ディスクリプタを表示用に (デバッグ用) std::string sprintf_desc(); @@ -133,13 +127,13 @@ class m68030MMU final int loglevel {}; - MPU680x0Device *cpu; + MPU68030Device *cpu; }; // 現在の TC:E、TT:E の状態に応じてアドレス変換の有無を切り替える。 // mmu_enable ならアドレス変換ありのバスアクセスを使う。see m68030bus.cpp void -MPU680x0Device::mmu_enable_changed() +MPU68030Device::mmu_enable_changed() { bool enable; @@ -164,7 +158,7 @@ MPU680x0Device::mmu_enable_changed() // bool -MPU680x0Device::SetSRP(uint32 h, uint32 l) +MPU68030Device::SetSRP(uint32 h, uint32 l) { if ((h & m68030RP::DT_MASK) == 0) { return false; @@ -175,7 +169,7 @@ MPU680x0Device::SetSRP(uint32 h, uint32 } bool -MPU680x0Device::SetCRP(uint32 h, uint32 l) +MPU68030Device::SetCRP(uint32 h, uint32 l) { if ((h & m68030RP::DT_MASK) == 0) { return false; @@ -186,7 +180,7 @@ MPU680x0Device::SetCRP(uint32 h, uint32 } void -MPU680x0Device::SetTT(int n, uint32 data) +MPU68030Device::SetTT(int n, uint32 data) { uint32 lbase; uint32 lmask; @@ -268,7 +262,7 @@ MPU680x0Device::SetTT(int n, uint32 data sbase |= (data & m68030TT::FCBASE_MASK) >> 3; smask = m68030TT::E; if ((data & m68030TT::RWM) == 0) { - smask |= M68K::SSW_RW; + smask |= M68030::SSW_RW; } smask |= (~data & m68030TT::FCMASK_MASK) << 1; @@ -314,7 +308,7 @@ m68030TT::Match(busaddr laddr) const // 成功すれば true、MMU 構成例外が起きる場合は false を返す。 // 呼び出し側で例外を起こすこと。 bool -MPU680x0Device::SetTC(uint32 data) +MPU68030Device::SetTC(uint32 data) { // マスクしてレジスタイメージにセット reg.tc = data & m68030TC::MASK; @@ -424,21 +418,30 @@ m68030TC::MakeMask() } void -MPU680x0Device::SetMMUSR(uint16 data) +MPU68030Device::SetMMUSR(uint16 data) { reg.mmusr = data & m68030MMUSR::MASK; } +// リセット例外の CPU 固有部分。 +void +MPU68030Device::ResetMMU() +{ + SetTC(GetTC() & ~m68030TC::TC_E); + SetTT(0, GetTT(0) & ~m68030TT::E); + SetTT(1, GetTT(1) & ~m68030TT::E); +} + // // ATC // // 今となっては独立したクラスである必要はなくなっているが、これを -// MPU680x0Device にマージするとパフォーマンスが下がるので維持してある。 +// MPU68030Device にマージするとパフォーマンスが下がるので維持してある。 // // コンストラクタ -m68030ATC::m68030ATC(MPU680x0Device *cpu_) +m68030ATC::m68030ATC(MPU68030Device *cpu_) { cpu = cpu_; @@ -559,7 +562,7 @@ m68030ATC::flush(uint32 fc, uint32 mask, // フラッシュが起きるんじゃないかな… // コンストラクタ -m68030ATCTable::m68030ATCTable(MPU680x0Device *cpu_, uint fc_) +m68030ATCTable::m68030ATCTable(MPU68030Device *cpu_, uint fc_) { cpu = cpu_; fc = fc_; @@ -760,7 +763,7 @@ m68030ATCTable::LineToStr(const m68030AT // // コンストラクタ -m68030MMU::m68030MMU(MPU680x0Device *cpu_, int loglevel_) +m68030MMU::m68030MMU(MPU68030Device *cpu_, int loglevel_) { cpu = cpu_; loglevel = loglevel_; @@ -1039,14 +1042,14 @@ m68030MMU::fetch_desc(uint32 tableaddr, } else { busdata bd; - bd = phys_read_4(descaddr); + bd = cpu->read_phys_4(descaddr); if (bd.IsBusErr()) { goto buserr; } m_desc1 = bd.Data(); if (m_descsize == 8) { - bd = phys_read_4(descaddr + 4); + bd = cpu->read_phys_4(descaddr + 4); if (bd.IsBusErr()) { goto buserr; } @@ -1094,7 +1097,7 @@ m68030MMU::fetch_desc(uint32 tableaddr, // ライトライクルの実行 if (do_write) { - busdata bd = phys_write_4(descaddr, m_desc1); + busdata bd = cpu->write_phys_4(descaddr, m_desc1); if (bd.IsBusErr()) { goto buserr; } @@ -1215,54 +1218,6 @@ m68030MMU::make_atc_debugger() const return paddr; } -// 物理メモリからの読み込み。 -busdata -m68030MMU::phys_read_4(uint32 addr) -{ - m68kbus backup; - busdata bd; - - // バス情報を一旦退避 - backup = cpu->bus; - - // 物理バスアクセス - cpu->bus.laddr = busaddr(addr) | BusAddr::SRead | BusAddr::Size4; - cpu->bus.paddr = cpu->bus.laddr; - bd = cpu->read_phys(); - if (__predict_false(bd.IsBusErr())) { - cpu->bus.size = M68K::SSW_SIZE_LONG; - return bd; - } - - // バス情報を復元 - cpu->bus = backup; - return bd; -} - -// 物理メモリへの書き込み。 -busdata -m68030MMU::phys_write_4(uint32 addr, uint32 data) -{ - m68kbus backup; - busdata bd; - - // バス情報を一旦退避 - backup = cpu->bus; - - // 物理バスアクセス - cpu->bus.laddr = busaddr(addr) | BusAddr::SWrite | BusAddr::Size4; - cpu->bus.paddr = cpu->bus.laddr; - bd = cpu->write_phys(data); - if (__predict_false(bd.IsBusErr())) { - cpu->bus.size = M68K::SSW_SIZE_LONG; - return bd; - } - - // バス情報を復元 - cpu->bus = backup; - return bd; -} - // ディスクリプタ表示用の文字列を返す。 // m_descsize によって m_desc1, m_desc2 を適切に文字列にする。 std::string @@ -1320,7 +1275,7 @@ const char * const m68030MMU::m_lvname[M // 論理アドレスが TT0/TT1 どちらかと一致すれば (bus.ci を更新して) true を返す。 // 一致しなければ false を返す。 bool -MPU680x0Device::CheckTT() +MPU68030Device::CheckTT() { bool ci; int match; @@ -1351,7 +1306,7 @@ MPU680x0Device::CheckTT() // リード/フェッチ用のアドレス変換を行う。 // 変換できれば true、バスエラーなら false を返す。 bool -MPU680x0Device::TranslateRead() +MPU68030Device::TranslateRead() { m68030ATCLine *a; busaddr& laddr = bus.laddr; @@ -1417,7 +1372,7 @@ MPU680x0Device::TranslateRead() // ライト用のアドレス変換を行う。 // 変換できれば true、バスエラーなら false を返す。 bool -MPU680x0Device::TranslateWrite() +MPU68030Device::TranslateWrite() { m68030ATCLine *a; busaddr& laddr = bus.laddr; @@ -1490,7 +1445,7 @@ MPU680x0Device::TranslateWrite() // 変換できれば対応する物理アドレスを、バスエラーなら BusErr を返す。 // テーブルサーチを行ったら TableSearched ビットを立てる。 busaddr -MPU680x0Device::TranslatePeek(busaddr laddr) +MPU68030Device::TranslatePeek(busaddr laddr) { const m68030ATCLine *a; busaddr paddr; @@ -1576,7 +1531,7 @@ MPU680x0Device::TranslatePeek(busaddr la // ir2 の下位5ビットから FC を返す。 // 不当パターンなら C++ の例外をスローする。 uint32 -MPU680x0Device::get_fc() +MPU68030Device::get_fc() { uint fcfield = ir2 & 0x1f; @@ -1597,7 +1552,7 @@ MPU680x0Device::get_fc() // MMU 不当命令 (2ワード目で確定) void -MPU680x0Device::mmu_op_illg2() +MPU68030Device::mmu_op_illg2() { putlog(1, "MMU illegal instruction %04x %04x", ir, ir2); Exception(M68K::EXCEP_FLINE); @@ -1605,7 +1560,7 @@ MPU680x0Device::mmu_op_illg2() // PFLUSH fc,#mask 命令 (EA を持たない方) void -MPU680x0Device::mmu_op_pflush() +MPU68030Device::mmu_op_pflush() { uint32 mask; uint32 fc; @@ -1617,7 +1572,7 @@ MPU680x0Device::mmu_op_pflush() // PFLUSH fc,#mask,ea 命令 void -MPU680x0Device::mmu_op_pflush_ea() +MPU68030Device::mmu_op_pflush_ea() { uint32 ea; uint32 mask; @@ -1631,7 +1586,7 @@ MPU680x0Device::mmu_op_pflush_ea() // PLOADR/PLOADW 命令 void -MPU680x0Device::mmu_op_pload() +MPU68030Device::mmu_op_pload() { uint32 ea; uint32 fc; @@ -1688,7 +1643,7 @@ MPU680x0Device::mmu_op_pload() // PTESTR/PTESTW 命令 void -MPU680x0Device::mmu_op_ptest() +MPU68030Device::mmu_op_ptest() { uint level = (ir2 >> 10) & 7; busaddr rw = (ir2 & 0x0200) ? BusAddr::R : BusAddr::W;