Annotation of nono/m88xx0/m88200.h, revision 1.1.1.3

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: // MC88200(CMMU)
                      8: 
                      9: #pragma once
                     10: 
                     11: #include "bus.h"
                     12: #include <array>
                     13: 
                     14: class m88kcpu;
                     15: 
                     16: // SAPR, UAPR レジスタ
                     17: struct m88200APR
                     18: {
                     19:        bool enable;
                     20:        uint32 addr;
                     21:        uint32 stat;
                     22:        const char *name;       // 自分の名前(ログ表示用)
                     23: };
                     24: 
                     25: // BATC
                     26: struct m88200BATC
                     27: {
                     28:        // LBA には S, V ビットを混ぜておく。比較を1回で済ませるため。
                     29:        // V ビットは invalid なら %1 にして一致しなくしておく。
                     30:        //  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
                     31:        // +-------------------------+-------------------------+-+-------+--+
                     32:        // |           LBA           |           0             |S|   0   |~V|
                     33:        // +-------------------------+-------------------------+-+-------+--+
                     34:        uint32 lba;             // LBA,S,V
                     35:        uint32 pba;             // PBA
                     36:        // stat は ACC_STAT_MASK と同じ WT,G,CI,WP のみ使用。
                     37:        // BATC (BWP レジスタ) のビット位置とは違うので注意。
                     38:        uint32 stat;
                     39:        bool wp;                // WP (比較で使うのでこれだけ抜き出しておく)
                     40: };
                     41: 
                     42: // PATC
                     43: struct m88200PATC
                     44: {
                     45:        // LPA には S ビットと有効/無効情報を混ぜておく。比較を1回で済ませるため。
                     46:        // V ビットは invalid なら %1 にして一致しなくしておく。実際の
                     47:        // PATC エントリの有効/無効は 46ビットの PATC 構造の外で管理されている?
                     48:        //  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
                     49:        // +---------------------------------------+-----------+-+-------+--+
                     50:        // |                 LPA                   |           |S|    0  |~V|
                     51:        // +---------------------------------------+-----------+-+-------+--+
                     52:        uint32 lpa;             // LPA,S,(V)
                     53:        uint32 pfa;             // PFA
                     54:        uint32 stat;    // ACC_STAT_MASK と同じ WT,G,CI,WP のみ使用。
                     55:        bool m;                 // Modified
                     56:        bool wp;                // Write Protect (比較で使うのでこれだけ抜き出しておく)
                     57: };
                     58: 
                     59: // キャッシュの1セット
                     60: class m88200CacheSet
                     61: {
                     62:  public:
                     63:        enum Status {
                     64:                EU = 0,         // Exclusive Unmodified
                     65:                EM = 1,         // Exclusive Modified
                     66:                SU = 2,         // Shared Unmodified
                     67:                IV = 3,         // Invalid
                     68:        };
                     69: 
                     70:        //
                     71:        //    3                   2                   1
                     72:        //  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
                     73:        // +---------------------------------------+---------------+----+---+
                     74:        // |                tag                    |      set      |Word|   |
                     75:        // +---------------------------------------+---------------+----+---+
                     76: 
                     77:        // タグはアドレスの上位 20ビット。
                     78:        // ただし無効なラインかどうかのチェックも一度で済ませるために
                     79:        // 無効(vv[]==IV)ならビット 0 を 1 にしておく。比較対象の paddr は
                     80:        // 下位12ビットを落としているため、これで絶対に一致しなくなる。
                     81:        static const uint32 TAG_INVALID = 0x00000001;
1.1.1.3 ! root       82:        uint32 tag[4] {};
1.1       root       83: 
                     84:        // LRU
                     85:        // CSSP の L ビットのロジックに従う。
                     86:        int L {};
                     87: 
                     88:        // ステータス
1.1.1.3 ! root       89:        Status vv[4] {};
1.1       root       90: 
                     91:        // データ。word[] は以下の順
                     92:        //       Word
                     93:        //        +0   +1   +2   +3
                     94:        // line0 [ 0] [ 1] [ 2] [ 3]
                     95:        // line1 [ 4] [ 5] [ 6] [ 7]
                     96:        // :
1.1.1.3 ! root       97:        uint32 word[16] {};
1.1       root       98: 
                     99:        // 自身のセットインデックス
1.1.1.3 ! root      100:        uint32 setidx {};
1.1       root      101: 
                    102:        // 引数 L の状態から line を最新にしたらどうなるか、を返す。
                    103:        // 表示処理で一時変数に対して処理が必要なため static 分離してある。
                    104:        static int TryUseLine(int L, int line);
                    105: 
                    106:        // 引数 L の状態から line を最古にしたらどうなるか、を返す。
                    107:        // 対称性のため static 分離してある。
                    108:        static int TryUnuseLine(int L, int line);
                    109: 
                    110:        // 引数 L の状態で、最新の line を返す。
                    111:        // 表示処理で一時変数に対して処理が必要なため static 分離してある。
                    112:        static int TryGetOldestLine(int L);
                    113: 
                    114:        void Use(int line) {
                    115:                L = TryUseLine(L, line);
                    116:        }
                    117: 
                    118:        // 更新用に最も古いラインを選んで差し出す
                    119:        int SelectOldestLine() const;
                    120: 
                    121:        void Update(int line, Status status);
                    122: 
                    123:        void Write(int line, uint32 paddr, uint32 data, int size);
                    124: 
                    125:        // キャッシュを検索して、ヒットした line を返す。
                    126:        int Lookup(uint32 tagaddr) const;
                    127: };
                    128: 
                    129: class m88200 : public Object
                    130: {
                    131:  public:
                    132:        m88200();
                    133:        ~m88200() override;
                    134: 
                    135:        // 本当はコンストラクタ渡ししたかったもの
                    136:        void Ctor(m88kcpu *parent_);
                    137: 
                    138:        // リセット
                    139:        void Reset();
                    140: 
1.1.1.2   root      141:        void MonitorUpdate(TextScreen&) override;
1.1       root      142: 
                    143:  private:
1.1.1.3 ! root      144:        m88kcpu *parent {};
1.1       root      145: 
                    146:  public:
                    147:        //
                    148:        // レジスタ
                    149:        //
                    150: 
                    151:        // IDR (ID Register) +$000
                    152:        //    3                   2                   1
                    153:        //  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
                    154:        // +---------------+-----+---------+-------------------------------+
                    155:        // |      ID       | Type| Version |           reserved            |
                    156:        // +---------------+-----+---------+-------------------------------+
                    157:        //
                    158:        // ID はリセット時、下位7ビットはハードウェアで初期化、最上位ビットは
                    159:        // 0 で初期化。その後は全ビット変更可能。
                    160:        // Type は $5 = 88200、$6 = 88204。ここでは 88200 固定。
                    161:        // Version は不明。
1.1.1.3 ! root      162:        uint32 id {};
        !           163:        uint32 version {};
1.1       root      164: 
                    165:        // IDR レジスタの内容を返す
                    166:        uint32 GetIDR() const {
                    167:                return (id << 24) | (0x5 << 21);
                    168:        }
                    169:        // ID を設定する (IDR ではない)
                    170:        void SetID(uint id_);
                    171:        // Version フィールドを設定する
                    172:        void SetVersion(uint version_);
                    173: 
                    174:        // SCR (System Command Register) +$004
                    175:        //    3                   2                   1
                    176:        //  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
                    177:        // +---------------------------------------------------+-----------+
                    178:        // |                     reserved                      |CommandCode|
                    179:        // +---------------------------------------------------+-----------+
1.1.1.3 ! root      180:        uint32 command {};
1.1       root      181:        uint32 GetSCR() const;
                    182:        void SetSCR(uint32 val);
                    183:  private:
                    184:        static const char * const commandname[];
                    185:        static const uint32 GG_LINE     = 0;
                    186:        static const uint32 GG_PAGE     = 1;
                    187:        static const uint32 GG_SEG      = 2;
                    188:        static const uint32 GG_ALL      = 3;
                    189:        void FlushCache();
                    190:        void InvalidatePATC();
                    191: 
                    192:  public:
                    193:        // SSR (System Status Register) +$008
                    194:        //    3                   2                   1
                    195:        //  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
                    196:        // +---------------------------------------------------------------+
                    197:        // |                               |C|B|       |W|S|G|C| |M|U|W|B|V|
                    198:        // |            reserved           |E|E|  res  |T|P| |I|r| | |P|H| |
                    199:        // +---------------------------------------------------------------+
                    200:        static const uint32 SSR_CE      = 0x00008000;   // Copyback Error
                    201:        static const uint32 SSR_BE      = 0x00004000;   // Bus Error
                    202:        static const uint32 SSR_WT      = 0x00000200;   // WriteThrough
                    203:        static const uint32 SSR_SP      = 0x00000100;   // Supervisor Privilege
                    204:        static const uint32 SSR_G       = 0x00000080;   // Global
                    205:        static const uint32 SSR_CI      = 0x00000040;   // Cache Inhibit
                    206:        static const uint32 SSR_M       = 0x00000010;   // Modified
                    207:        static const uint32 SSR_U       = 0x00000008;   // Used
                    208:        static const uint32 SSR_WP      = 0x00000004;   // Write Protection
                    209:        static const uint32 SSR_BH      = 0x00000002;   // BATC Hit
                    210:        static const uint32 SSR_V       = 0x00000001;   // Valid
1.1.1.3 ! root      211:        uint32 ssr {};
1.1       root      212:        uint32 GetSSR() const { return ssr; }
                    213:        void SetSSR(uint32 val) { ssr = val; }
                    214: 
                    215:        // SAR (System Address Register) +$00c
                    216:        //    3                   2                   1
                    217:        //  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
                    218:        // +---------------------------------------------------------------+
                    219:        // |                          Address                              |
                    220:        // +---------------------------------------------------------------+
1.1.1.3 ! root      221:        uint32 sar {};
1.1       root      222:        uint32 GetSAR() const { return sar; }
                    223:        void SetSAR(uint32 val) { sar = val; }
                    224: 
                    225:        // SCTR (System Control Register) +$104
                    226:        //    3                   2                   1
                    227:        //  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
                    228:        // +-------------------------------+-+-+-+-------------------------+
                    229:        // |                               |P|S|P|                         |
                    230:        // |           reserved            |E|E|R|         reserved        |
                    231:        // +-------------------------------+-+-+-+-------------------------+
                    232:        static const uint32 SCTR_PE     = 0x00008000;   // Parity Enable
                    233:        static const uint32 SCTR_SE     = 0x00004000;   // Snoop Enable
                    234:        static const uint32 SCTR_PR     = 0x00002000;   // Priority Arbitration
1.1.1.3 ! root      235:        uint32 sctr {};
1.1       root      236:        uint32 GetSCTR() const { return sctr; }
                    237:        void SetSCTR(uint32 val);
                    238: 
                    239:        // SAPR (Supervisor Area Pointer Register) +$200
                    240:        // UAPR (User       Area Pointer Register) +$204
                    241:        //    3                   2                   1
                    242:        //  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
                    243:        // +---------------------------------------+---+-+-+-+-+---------+-+
                    244:        // | Supervisor Segment Table Base Address |   |W| |G|C|         |T|
                    245:        // | or    User Segment Table Base Address |0 0|T|0| |I|0 0 0 0 0|E|
                    246:        // +---------------------------------------+---+-+-+-+-+---------+-+
                    247:        static const uint32 APR_ADDR_MASK       = 0xfffff000;   // Base Address
                    248:        static const uint32 APR_WT                      = 0x00000200;   // WriteThrough
                    249:        static const uint32 APR_G                       = 0x00000080;   // Global
                    250:        static const uint32 APR_CI                      = 0x00000040;   // Cache Inhibit
                    251:        static const uint32 APR_TE                      = 0x00000001;   // Translation Enable
                    252:        m88200APR uapr {};
                    253:        m88200APR sapr {};
                    254:  private:
                    255:        uint32 GetAPR(const m88200APR&) const;
                    256:        void SetAPR(m88200APR&, uint32 data);
                    257:  public:
                    258:        uint32 GetAPR(uint issuper) const;
                    259:        uint32 GetUAPR() const { return GetAPR(uapr); }
                    260:        uint32 GetSAPR() const { return GetAPR(sapr); }
                    261:        void SetAPR(uint issuper, uint32 data);
                    262:        void SetUAPR(uint32 data) { SetAPR(uapr, data); }
                    263:        void SetSAPR(uint32 data) { SetAPR(sapr, data); }
                    264: 
                    265:        // PFSR (P Bus Fault Status Register) +$108
                    266:        //    3                   2                   1
                    267:        //  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
                    268:        // +-------------------------+-----+-------------------------------+
                    269:        // |                         |Fault|                               |
                    270:        // |        reserved         | Code|            reserved           |
                    271:        // +-------------------------+-----+-------------------------------+
                    272:        static const uint32 FAULT_CODE_SUCCESS          = 0;    // Success (No fault)
                    273:        static const uint32 FAULT_CODE_BUSERR           = 3;    // Bus Error
                    274:        static const uint32 FAULT_CODE_SEGMENT          = 4;    // Segment Fault
                    275:        static const uint32 FAULT_CODE_PAGE                     = 5;    // Page Fault
                    276:        static const uint32 FAULT_CODE_SUPERVISOR       = 6;    // Supervisor Violation
                    277:        static const uint32 FAULT_CODE_WRITE            = 7;    // Write Violation
1.1.1.3 ! root      278:        uint32 fault_code {};
1.1       root      279:        uint32 GetPFSR() const {
                    280:                return fault_code << 16;
                    281:        }
                    282:        void SetPFSR(uint32 data) {
                    283:                fault_code = (data >> 16) & 7;
                    284:        }
                    285: 
                    286:        // PFAR (P Bus Fault Address Register) +$10c
                    287:        //    3                   2                   1
                    288:        //  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
                    289:        // +---------------------------------------------------------------+
                    290:        // |                          Address                              |
                    291:        // +---------------------------------------------------------------+
1.1.1.3 ! root      292:        uint32 fault_addr {};
1.1       root      293:        uint32 GetPFAR() const { return fault_addr; }
                    294:        void SetPFAR(uint32 val) { fault_addr = val; }
                    295: 
                    296:        // BWP0-7 (BATC Write Ports 0..7) +$400..+$41c
                    297:        //    3                   2                   1
                    298:        //  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
                    299:        // +---------------------------------------------------------------+
                    300:        // |                         |                         |S|W|G|C|W|V|
                    301:        // |  Logical Block Address  | Physical Block Address  | |T| |I|P| |
                    302:        // +---------------------------------------------------------------+
                    303:        static const uint32 BATC_LBA_MASK       = 0xfff80000;
                    304:        static const uint32 BATC_PBA_MASK       = 0x0007ffc0;
                    305:        static const uint32 BATC_S                      = 0x00000020;   // Address Space
                    306:        static const uint32 BATC_WT                     = 0x00000010;   // WriteThrough
                    307:        static const uint32 BATC_G                      = 0x00000008;   // Global
                    308:        static const uint32 BATC_CI                     = 0x00000004;   // Cache Inhibit
                    309:        static const uint32 BATC_WP                     = 0x00000002;   // Write Protect
                    310:        static const uint32 BATC_V                      = 0x00000001;   // Valid
                    311:        std::array<m88200BATC, 10> batc {};
                    312:        uint32 GetBATC(uint n) const;
                    313:        void SetBATC(uint n, uint32 val);
                    314: 
                    315:        // CDP0-3 (Cache Data Ports 0..3) +$800..+$80c
                    316:        //    3                   2                   1
                    317:        //  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
                    318:        // +---------------------------------------------------------------+
                    319:        // |                          Data Word                            |
                    320:        // +---------------------------------------------------------------+
                    321: 
                    322:        // CTP0-3 (Cache Tag Ports 0..3) +$840..+$84c
                    323:        //    3                   2                   1
                    324:        //  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
                    325:        // +---------------------------------------+-----------------------+
                    326:        // |            Physical Address           |       reserved        |
                    327:        // +---------------------------------------+-----------------------+
                    328: 
                    329:        // CSSP (Cache Set Status Port) +$880
                    330:        //    3                   2                   1
                    331:        //  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
                    332:        // +---------------------------------------------------------------+
                    333:        // |   |L|L|L|L|L|L|D|D|D|D|VV3|VV2|VV1|VV0|                       |
                    334:        // |res|5|4|3|2|1|0|3|2|1|0|   |   |   |   |       reserved        |
                    335:        // +---------------------------------------------------------------+
                    336:        static const uint32 CSSP_L5             = 0x20000000;   // Line5
                    337:        static const uint32 CSSP_L4             = 0x10000000;   // Line4
                    338:        static const uint32 CSSP_L3             = 0x08000000;   // Line3
                    339:        static const uint32 CSSP_L2             = 0x04000000;   // Line2
                    340:        static const uint32 CSSP_L1             = 0x02000000;   // Line1
                    341:        static const uint32 CSSP_L0             = 0x01000000;   // Line0
                    342:        static const uint32 CSSP_D3             = 0x00800000;   // Line Disable
                    343:        static const uint32 CSSP_D2             = 0x00400000;   // Line Disable
                    344:        static const uint32 CSSP_D1             = 0x00200000;   // Line Disable
                    345:        static const uint32 CSSP_D0             = 0x00100000;   // Line Disable
                    346:        static const uint32 CSSP_VV3    = 0x000c0000;   // Line Valid
                    347:        static const uint32 CSSP_VV2    = 0x00030000;   // Line Valid
                    348:        static const uint32 CSSP_VV1    = 0x0000c000;   // Line Valid
                    349:        static const uint32 CSSP_VV0    = 0x00003000;   // Line Valid
                    350:        static const uint32 CSSP_VV3_OFFSET     = 18;
                    351:        static const uint32 CSSP_VV2_OFFSET     = 16;
                    352:        static const uint32 CSSP_VV1_OFFSET     = 14;
                    353:        static const uint32 CSSP_VV0_OFFSET     = 12;
                    354:        uint32 GetCSSP() const;
                    355:        void SetCSSP(uint32 val);
                    356: 
                    357:        //
                    358:        // 物理バスアクセス
                    359:        //
                    360:        // XXX size をどうするか
                    361:        uint64 MBusRead(uint32 paddr, int size);
                    362:        uint64 MBusWrite(uint32 paddr, uint32 data, int size);
                    363:        uint64 MBusXmem(uint32 paddr, uint32 data, int size);
                    364: 
                    365:        //
                    366:        // アクセス関数
                    367:        //
                    368:  private:
                    369:        template <int bits> uint64 load(uint32 addr);
                    370:        template <int bits> uint64 store(uint32 addr, uint32 data);
                    371:        template <int bits> uint64 xmem(uint32 addr, uint32 data);
                    372:  public:
                    373:        uint64 load_8(uint32 addr);
                    374:        uint64 load_16(uint32 addr);
                    375:        uint64 load_32(uint32 addr);
                    376:        uint64 store_8(uint32 addr, uint32 data);
                    377:        uint64 store_16(uint32 addr, uint32 data);
                    378:        uint64 store_32(uint32 addr, uint32 data);
                    379:        uint64 xmem_8(uint32 addr, uint32 data);
                    380:        uint64 xmem_16(uint32 addr, uint32 data);
                    381:        uint64 xmem_32(uint32 addr, uint32 data);
                    382: 
                    383:        //
                    384:        // 現在のアクセス中の状態。
                    385:        //
                    386:        // アドレス変換およびデータキャッシュルーチンではこれらの値を
                    387:        // グローバルに状態変数として使う。
                    388: 
                    389:        // ディスクリプタの下位にあるフラグは全部ビット位置が同じ。
                    390:        // Area descriptor (SAPR or UAPR)
                    391:        //  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
                    392:        // +---------------------------------------+---+-+-+-+-+---------+-+
                    393:        // | Supervisor Segment Table Base Address |   |W| |G|C|         |T|
                    394:        // | or    User Segment Table Base Address |0 0|T|0| |I|0 0 0 0 0|E|
                    395:        // +---------------------------------------+---+-+-+-+-+---------+-+
                    396:        //
                    397:        // Segment Descriptor
                    398:        //  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
                    399:        // +---------------------------------------+---+-+-+-+-+-----+-+-+-+
                    400:        // |    Page Table Base Address (PTBA)     |   |W|S|G|C|     |W| |V|
                    401:        // |                                       |0 0|T|P| |I|0 0 0|P|0| |
                    402:        // +---------------------------------------+---+-+-+-+-+-----+-+-+-+
                    403:        //
                    404:        // Page Descriptor
                    405:        //  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
                    406:        // +---------------------------------------+---+-+-+-+-+-+-+-+-+-+-+
                    407:        // |       Page Frame Address (PFA)        |   |W|S|G|C| |M|U|W| |V|
                    408:        // |                                       |0 0|T|P| |I|0| | |P|0| |
                    409:        // +---------------------------------------+---+-+-+-+-+-+-+-+-+-+-+
                    410:        //
                    411:        // acc_stat も同じビット位置を使う。
                    412:        //  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
                    413:        // +---------------------------------------+---+-+-+-+-+-----+-+---+
                    414:        // |                                       |   |W| |G|C|     |W|   |
                    415:        // |                                       |0 0|T|0| |I|  0  |P| 0 |
                    416:        // +---------------------------------------+---+-+-+-+-+-----+-+---+
                    417:        //
                    418:        static const uint32 DESC_WT             = 0x00000200;   // Write Through
                    419:        static const uint32 DESC_SP             = 0x00000100;   // Supervisor Protect
                    420:        static const uint32 DESC_G              = 0x00000080;   // Global
                    421:        static const uint32 DESC_CI             = 0x00000040;   // Cache Inhibit
                    422:        static const uint32 DESC_M              = 0x00000010;   // Modified
                    423:        static const uint32 DESC_U              = 0x00000008;   // Used
                    424:        static const uint32 DESC_WP             = 0x00000004;   // Write Protect
                    425:        static const uint32 DESC_V              = 0x00000001;   // Valid
                    426: 
                    427:        uint32 acc_laddr {};            // Logical Address
                    428:        uint32 acc_paddrH {};           // Physical Address 上位30ビット。
                    429:                                                                //  下位2ビットは 0 固定。
                    430:        uint32 acc_paddrL {};           // paddr の下位2ビット
                    431:                                                                //  上位30ビットは 0 固定。
                    432: 
                    433:        // acc_stat は 4 ビットのみ使用。
                    434:        // それ以外のビットは代入時にマスクすること。
                    435:        static const uint32 ACC_STAT_MASK = DESC_WT | DESC_G | DESC_CI | DESC_WP;
                    436:        uint32 acc_stat {};
                    437:        // Table Address.  とマニュアルには書いてあるけど、テーブル先頭と
                    438:        // 紛らわしいし 88200 のアドレス変換ツリーは2段固定で、今何段目か
                    439:        // しらんけど現在のテーブルアドレス…みたいなのを持つ必要はないので、
                    440:        // ここでは
                    441:        // sdaddr ... Segment Descriptor Address
                    442:        // pdaddr ... Page    Descriptor Address
                    443:        // の2つに明確に分けて管理することにする。
                    444:        uint32 acc_sdaddr {};
                    445:        uint32 acc_pdaddr {};
1.1.1.3 ! root      446:        bool acc_read {};                       // True if read access
1.1       root      447:        bool acc_IsWrite() const { return !acc_read; }  // True if write access
                    448: 
                    449:        // S/U 信号線
                    450:        // 実際には P Bus の Address フェーズで毎回送られてくるが
                    451:        // そうそう変わらないので状態変化を通知してもらう方式。
                    452:        // true なら super, false なら user。
1.1.1.3 ! root      453:        bool acc_super {};
1.1       root      454:        void SetSuper(bool super) {
                    455:                acc_super = super;
                    456:        }
                    457: 
                    458:        m88200PATC *acc_patc {};        // ヒットした PATC エントリ
1.1.1.3 ! root      459:        uint32 tmp_desc {};                     // TEMP_DESCR
1.1       root      460: 
                    461:        //
                    462:        // アドレス変換
                    463:        //
                    464:        bool Translate();
                    465:        uint64 TranslatePeek(uint32 laddr, bool issuper, bool do_search) const;
                    466:  private:
                    467:        static std::string stat2str(uint32 stat);
                    468:        bool SelectAreaDesc();
                    469:        bool TableSearch();
                    470:        bool FetchSegmentDesc();
                    471:        bool FetchPageDesc();
                    472:        bool UpdatePageDesc();
                    473:        void CreatePATCEntry();
                    474: 
                    475:  public:
                    476:        // PATC
                    477:        static const uint32 PATC_S                      = 0x00000020;   // Supervisor
                    478:        std::array<m88200PATC, 56> patc {};
                    479: 
                    480: 
                    481:        //
                    482:        // キャッシュ
                    483:        //
1.1.1.3 ! root      484:  private:
1.1       root      485:        std::array<m88200CacheSet,256> setarray {};
1.1.1.3 ! root      486:        // キャッシュラインにメモリから読み込む
        !           487:        uint64 ReadLine(m88200CacheSet& set, int line, uint32 tagaddr);
        !           488:        // キャッシュラインをメモリに書き出す
        !           489:        uint64 CopyBackLine(m88200CacheSet& set, int line);
1.1       root      490: 
1.1.1.3 ! root      491:  public:
1.1       root      492:        // キャッシュに対して paddr の読み込みを行う
                    493:        uint64 CacheRead(uint32 paddr);
                    494:        // キャッシュに対して paddr への書き込みを行う
                    495:        uint64 CacheWrite(uint32 paddr, uint32 data, int size);
                    496:        uint64 CacheWriteHit(m88200CacheSet& set, int line,
                    497:                uint32 paddr, uint32 data, int size);
                    498:        uint64 CacheXmem(uint32 paddr, uint32 data, int size);
                    499: 
                    500:        // モニタスクリーン作成用
                    501:        void MonitorCacheSet(TextScreen&, int y, int setidx);
                    502:        void MonitorCacheOverview(TextScreen&, int y, int cursor, bool is_gui);
                    503:        void MonitorCacheOverview(TextScreen& s, int y, bool is_gui) {
                    504:                MonitorCacheOverview(s, y, -1, is_gui);
                    505:        }
                    506: 
1.1.1.3 ! root      507:        //
        !           508:        // MBus
        !           509:        //
        !           510:  public:
        !           511:        // MBus を所有している CMMU ID を返す。誰も持っていなければ -1。
        !           512:        // これは static 関数
        !           513:        static m88200 *GetBusMaster() { return mbus_master; }
        !           514: 
        !           515:        // この CMMU からのアクセスにウェイトを加算する (VM から使う)
        !           516:        void AddCycle(uint64 cycle);
        !           517: 
1.1       root      518:  private:
1.1.1.3 ! root      519:        void MBusAcquire();
1.1       root      520:        void MBusRelease() { }
1.1.1.3 ! root      521: 
        !           522:        // MBus を所有してる CMMU を指す。NULL なら解放。
        !           523:        // これは static 変数で全 m88200 で共有している
        !           524:        static m88200 *mbus_master;
1.1       root      525: };

unix.superglobalmegacorp.com

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