--- nono/m680x0/m68030mmu.h 2026/04/29 17:04:54 1.1.1.4 +++ nono/m680x0/m68030mmu.h 2026/04/29 17:05:22 1.1.1.7 @@ -6,6 +6,8 @@ #pragma once +class MPU680x0Device; + // ATC_SINGLE は過去との比較のために残してある、双方向リストによる // FC 混合 22 エントリ実装。 // 定義しない場合(デフォルト)は、FC 別の世代付き配列みたいなもの。 @@ -26,12 +28,13 @@ class m68030RP // | TABLE ADDRESS (PA31-PA4) |unused | // +-------------------------------------------------------+-------+ public: + static const uint32 DT_MASK = 0x00000003; static const uint32 H_MASK = 0xffff0003; static const uint32 L_MASK = 0xfffffff0; }; // TT レジスタの各フィールドを束ねた構造体のようなもの。 -// m68kcpu::SetTT(), GetTT() で読み書きする。 +// MPU680x0Device::SetTT(), GetTT() で読み書きする。 class m68030TT { // 3 2 1 0 @@ -52,19 +55,27 @@ class m68030TT static const uint32 FCBASE_MASK = 0x00000070; static const uint32 FCMASK_MASK = 0x00000007; - uint32 e {}; // 00008000 イネーブル - uint32 ci {}; // 00000400 キャッシュ禁止 + bool e {}; // イネーブル + bool ci {}; // キャッシュ禁止 uint64 base {}; // ベース uint64 mask {}; // マスク // アクセスがこの TT と一致するか調べる。 - bool Match(uint64 ssw_laddr); + bool Match(busaddr addr) const; }; // TC レジスタの各フィールドを束ねた構造体のようなもの。 // m68kcpu::SetTC(), GetTC() で読み書きする。 class m68030TC { + // 3 2 1 0 + // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + // +-+---------+-+-+-------+-------+-------+-------+-------+-------+ + // |E| 0 |S|F| PS | IS | TIA | TIB | TIC | TID | + // +-+---------+-+-+-------+-------+-------+-------+-------+-------+ + // | | +-- FCL (Function Code Lookup Enable) + // | +---- SRE (Supervisor Root Pointer Enable) + // +-- Enable public: static const uint32 MASK = 0x83ffffff; static const uint32 TC_E = 0x80000000; @@ -115,16 +126,17 @@ class m68030MMUSR // ATC の1エントリ struct m68030ATCLine { - // 1エントリはタグとデータの計64ビット。 - // - // タグ + // tag // LLLLLLLL_LLLLLLLL_LLLLLLLL_0000000I : L は論理アドレス // +-- invalid (%1で無効) // // FC はテーブル選択の時点で確定しているのでタグには不要。 // - // データ - // PPPPPPPP_PPPPPPPP_PPPPPPPP_0000BCPM : P は物理アドレス + // paddr + // PPPPPPPP_PPPPPPPP_PPPPPPPP_00000000 : P は物理アドレス + // + // data + // 00000000_00000000_00000000_0000BCPM // |||+-- Modified // ||+--- Write Protect // |+---- Cache Inhibit @@ -167,7 +179,7 @@ struct m68030ATCLine #endif // デバッグ表示 - void fill_print(uint fc); + std::string fill_print(uint fc); }; // ATC のテーブル @@ -177,7 +189,7 @@ class m68030ATCTable final static const int LINES = 22; m68030ATCTable(); - ~m68030ATCTable() { } + ~m68030ATCTable(); #if !defined(ATC_SINGLE) // 空きエントリを取得。 @@ -226,10 +238,14 @@ class m68030ATCTable final #if !defined(ATC_SINGLE) // LRU 用の更新カウンタ - uint32 counter = 0; + uint32 counter {}; // head のヒット回数。 - uint64 hit_head = 0; + uint64 hit_head {}; #endif + + int loglevel {}; + + MPU680x0Device *cpu {}; }; // ATC (Address Translation Cache) @@ -237,15 +253,18 @@ class m68030ATC final { friend class MPU680x0Device; public: - m68030ATC(m68kcpu *); - ~m68030ATC() { } + m68030ATC(MPU680x0Device *); + ~m68030ATC(); + + // ログレベルを設定する。Object のとは同じ使い方だけど別物。 + void SetLogLevel(int loglevel_); // エントリをサーチ&更新 - const m68030ATCLine& fill_fetch(); - const m68030ATCLine& fill_read(); - const m68030ATCLine& fill_write(); + const m68030ATCLine& fill_fetch(busaddr addr); + const m68030ATCLine& fill_read(busaddr addr); + const m68030ATCLine& fill_write(busaddr addr); // デバッグ用にエントリを検索 - uint64 fill_peek(uint32 laddr, uint fc); + const m68030ATCLine *fill_peek(uint32 laddr, uint fc); // フラッシュ (pflush* 命令から呼ばれる) void flush(); @@ -262,15 +281,7 @@ class m68030ATC final m68030ATCTable tables[1] {}; #endif - m68kcpu *cpu {}; -}; + int loglevel {}; -extern bool m68030_mmu_translate_fetch(m68kcpu *cpu); -extern bool m68030_mmu_translate_read(m68kcpu *cpu); -extern bool m68030_mmu_translate_write(m68kcpu *cpu); -extern uint64 m68030_mmu_translate_peek(m68kcpu *cpu, uint32 laddr, uint fc, - bool do_search); -extern void mmu_op_pflush(m68kcpu *cpu); -extern void mmu_op_pflush_ea(m68kcpu *cpu); -extern void mmu_op_pload(m68kcpu *cpu); -extern void mmu_op_ptest(m68kcpu *cpu); + MPU680x0Device *cpu {}; +};