|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2024 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: #pragma once ! 8: ! 9: struct m68040MMU ! 10: { ! 11: // 3 2 1 0 ! 12: // 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 ! 13: // +-------------------------------------+-+-+-+---+-+---+-+-+-+---+ ! 14: // | Physical Address (4K/8K) : | |G|U10|S|CM |M|U|W|PDT| ! 15: // +-------------------------------------+-+-+-+---+-+---+-+-+-+---+ ! 16: // ^ ^ ! 17: // | | ! 18: // +-+-- UR (ユーザ用予約) ! 19: static const uint32 DESC_G = 0x00000400; ! 20: static const uint32 DESC_S = 0x00000080; ! 21: static const uint32 DESC_CM = 0x00000060; ! 22: static const uint32 DESC_M = 0x00000010; ! 23: static const uint32 DESC_U = 0x00000008; ! 24: static const uint32 DESC_W = 0x00000004; ! 25: static const uint32 DESC_DT = 0x00000003; ! 26: ! 27: // PDT は ! 28: // %00 無効 ! 29: // %01 常駐 ! 30: // %10 間接 ! 31: // %11 常駐 ! 32: static const uint32 PDT_INVALID = 0; ! 33: static const uint32 PDT_INDIRECT = 2; ! 34: ! 35: // UDT は ! 36: // %00 無効 ! 37: // %01 無効 ! 38: // %10 常駐 ! 39: // %11 常駐 ! 40: }; ! 41: ! 42: class m68040RP ! 43: { ! 44: // SRP, URP ! 45: // ! 46: // 3 2 1 0 ! 47: // 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 ! 48: // +-------------------------------------------+-------------------+ ! 49: // | Root Pointer | 0 | ! 50: // +-------------------------------------------+-------------------+ ! 51: ! 52: public: ! 53: static const uint32 ADDR_MASK = 0xfffffc00; ! 54: }; ! 55: ! 56: class m68040TT ! 57: { ! 58: // 3 2 1 0 ! 59: // 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 ! 60: // +---------------+---------------+-+-+-+-+-+-+---+-+-+-+-+-+-+-+-+ ! 61: // |LogicalAddrBase|LogicalAddrMask|E| S | | U | |CM | |W| | ! 62: // +---------------+---------------+-+-+-+-+-+-+---+-+-+-+-+-+-+-+-+ ! 63: ! 64: public: ! 65: static const uint32 MASK = 0xffffe364; ! 66: static const uint32 LBASE_MASK = 0xff000000; ! 67: static const uint32 LMASK_MASK = 0x00ff0000; ! 68: static const uint32 E = 0x00008000; ! 69: static const uint32 S_IGN = 0x00004000; ! 70: static const uint32 S_FC2 = 0x00002000; ! 71: static const uint32 U_MASK = 0x00000300; ! 72: static const uint32 U1 = 0x00000200; ! 73: static const uint32 U0 = 0x00000100; ! 74: static const uint32 CM = 0x00000060; ! 75: static const uint32 W = 0x00000004; ! 76: ! 77: m68040TT(const char *, uint32 *); ! 78: ~m68040TT(); ! 79: ! 80: bool Match(busaddr addr) const; ! 81: const char *GetName() const { return name; } ! 82: ! 83: uint32 base {}; ! 84: uint32 mask {}; ! 85: bool e {}; ! 86: bool s_ign {}; ! 87: bool s_fc2 {}; ! 88: uint32 u {}; ! 89: uint8 cm {}; ! 90: bool w {}; ! 91: ! 92: uint32 *reg {}; // レジスタイメージ置き場 (®.*tt) ! 93: private: ! 94: const char *name {}; // 表示用のレジスタ名 ! 95: }; ! 96: ! 97: class m68040TC ! 98: { ! 99: // 1 0 ! 100: // 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ! 101: // +-+-+---------------------------+ ! 102: // |E|P| reserved | ! 103: // +-+-+---------------------------+ ! 104: ! 105: public: ! 106: static const uint16 MASK = 0xc000; ! 107: static const uint16 E = 0x8000; // 有効 ! 108: static const uint16 P = 0x4000; // ページサイズ(%1=8K) ! 109: ! 110: bool e {}; ! 111: bool ps4k {}; // ページサイズが 4K なら true (ビット定義と逆) ! 112: uint32 table_mask {}; // ページテーブルアドレスのマスク ! 113: uint32 tic_shift {}; // 論理アドレス TIC 部の右シフト量 ! 114: uint32 tic_mask {}; // 論理アドレス TIC 部のマスク ! 115: uint32 page_mask {}; // ページディスクリプタの物理アドレスマスク ! 116: }; ! 117: ! 118: class m68040MMUSR ! 119: { ! 120: // 3 2 1 0 ! 121: // 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 ! 122: // +---------------------------------------+-+-+---+-+-+-+-+-+-+-+-+ ! 123: // | Physical Address |B|G| U |S|CM |M| |W|T|R| ! 124: // +---------------------------------------+-+-+---+-+-+-+-+-+-+-+-+ ! 125: ! 126: public: ! 127: static const uint32 ADDR_MASK = 0xfffff000; // 物理アドレス ! 128: static const uint32 B = 0x00000800; // バスエラー ! 129: static const uint32 G = 0x00000400; // グローバル ! 130: static const uint32 U_MASK = 0x00000300; // ユーザ領域 ! 131: static const uint32 U1 = 0x00000200; ! 132: static const uint32 U0 = 0x00000100; ! 133: static const uint32 S = 0x00000080; // スーパーバイザ保護 ! 134: static const uint32 CM = 0x00000060; // キャッシュモード ! 135: static const uint32 M = 0x00000010; // 修正済み ! 136: static const uint32 W = 0x00000004; // 書き込み保護 ! 137: static const uint32 T = 0x00000002; // 透過変換がヒット ! 138: static const uint32 R = 0x00000001; // 常駐 ! 139: }; ! 140: ! 141: // ATC エントリ ! 142: class m68040ATCEntry ! 143: { ! 144: public: ! 145: // タグは無効なら最下位ビットを立てる。これでマッチしなくなる。 ! 146: // ! 147: // 3 2 1 0 ! 148: // 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 ! 149: // +-----+-+---------------------------------------+-------------+--+ ! 150: // | 0 |S| Logical Address (4K/8K) : | 0 |~V| ! 151: // +-----+-+---------------------------------------+-------------+--+ ! 152: static const uint32 SUPER = 0x10000000; ! 153: static const uint32 INVALID = 0x00000001; ! 154: uint32 tag {}; ! 155: ! 156: bool IsValid() const { return (tag & INVALID) == 0; } ! 157: bool IsSuper() const { return (tag & SUPER) != 0; } ! 158: void Invalidate() { tag |= INVALID; } ! 159: ! 160: // desc はページディスクリプタをそのまま持っておく。 ! 161: // ページディスクリプタなので PDT(下位2bit) は %01 か %11 なら Resident。 ! 162: // ! 163: // 3 2 1 0 ! 164: // 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 ! 165: // +-----------------------------------------+-+---+-+---+-+-+-+-+-+ ! 166: // | (not used) |G|U10|S|CM |M|U|W|-|R| ! 167: // +-----------------------------------------+-+---+-+---+-+-+-+-+-+ ! 168: uint32 paddr {}; ! 169: uint32 desc {}; ! 170: ! 171: bool IsGlobal() const { return (desc & m68040MMU::DESC_G); } ! 172: bool IsSuperProtected() const { return (desc & m68040MMU::DESC_S); } ! 173: bool IsWriteProtected() const { return (desc & m68040MMU::DESC_W); } ! 174: bool IsResident() const { return (desc & 0x0001); } ! 175: ! 176: bool MatchStatus(busaddr laddr) const; ! 177: }; ! 178: ! 179: // ATC セット ! 180: class m68040ATCSet ! 181: { ! 182: public: ! 183: std::array<m68040ATCEntry, 4> entry {}; ! 184: uint LRU {}; ! 185: ! 186: int GetEntry() const; ! 187: }; ! 188: ! 189: // ATC ! 190: class m68040ATC ! 191: { ! 192: public: ! 193: std::array<m68040ATCSet, 16> sets {}; ! 194: ! 195: // アドレス (busaddr >> 4) からタグを作る際のマスク。 ! 196: // PS が 4K か 8K かで長さが違うため。 ! 197: uint32 tag_mask {}; ! 198: ! 199: void Flush(bool s, bool global); ! 200: void Flush(busaddr addr, bool global); ! 201: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.