Annotation of nono/vm/mpu.h, revision 1.1.1.17

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
1.1.1.11  root        7: //
1.1.1.15  root        8: // MPU 共通部
1.1.1.11  root        9: //
1.1.1.2   root       10: 
1.1       root       11: #pragma once
                     12: 
                     13: #include "device.h"
1.1.1.11  root       14: #include "message.h"
1.1.1.15  root       15: #include <vector>
1.1       root       16: 
1.1.1.13  root       17: class Debugger;
                     18: class MainbusDevice;
                     19: class Syncer;
                     20: 
1.1.1.15  root       21: // 全 MPU の共通部
1.1       root       22: class MPUDevice : public Device
                     23: {
1.1.1.3   root       24:        using inherited = Device;
1.1       root       25:  public:
1.1.1.15  root       26:        explicit MPUDevice(uint objid_);
1.1.1.14  root       27:        ~MPUDevice() override;
1.1       root       28: 
1.1.1.5   root       29:        bool Init() override;
1.1.1.11  root       30:        void PowerOff() override;
1.1       root       31: 
1.1.1.2   root       32:        // 現在実行中の命令の PC を取得
                     33:        virtual uint32 GetPPC() const = 0;
1.1       root       34: 
1.1.1.15  root       35:  protected:
                     36:        // 1命令実行イベント
1.1.1.17! root       37:        Event *exec_event {};
1.1.1.15  root       38: 
                     39:        Debugger *debugger {};
                     40: };
                     41: 
                     42: // メイン MPU (680x0/88xxx0) 共通部
                     43: class MainMPUDevice : public MPUDevice
                     44: {
                     45:        using inherited = MPUDevice;
1.1.1.16  root       46:  protected:
                     47:        // CPU の実行状態
                     48:        static const uint32 CPU_STATE_NORMAL    = 0;
                     49:        static const uint32 CPU_STATE_STOP              = 1;
                     50:        static const uint32 CPU_STATE_HALT              = 2;
                     51: 
1.1.1.15  root       52:  public:
                     53:        MainMPUDevice();
                     54:        ~MainMPUDevice() override;
                     55: 
                     56:        bool Init() override;
                     57: 
1.1.1.11  root       58:        // 現在の VBR を取得
                     59:        virtual uint32 GetVBR() const = 0;
                     60: 
1.1.1.2   root       61:        // 現在アクセス中の論理アドレス、物理アドレスを取得。
                     62:        // Laddr == Paddr が MMU オフなのか PA=VA で運用中なのかの区別は
                     63:        // ここでは付かない。
                     64:        virtual uint32 GetLaddr() const = 0;
                     65:        virtual uint32 GetPaddr() const = 0;
1.1       root       66: 
1.1.1.16  root       67:        // CPU の実行状態 (uint32) を返す。
                     68:        uint32 GetState() const noexcept { return cpu_state; }
                     69: 
1.1.1.14  root       70:        // MPU 名を取得する。("MC68030" みたいなやつ、ログ名とは別)
                     71:        virtual const char *GetMPUName() const = 0;
                     72: 
1.1.1.5   root       73:        // MPU クロック [kHz] を取得する。
1.1.1.15  root       74:        uint GetClockSpeed() const { return clock_khz; }
1.1.1.5   root       75: 
1.1.1.12  root       76:        // MPU クロック [nsec] を取得する。
                     77:        uint64 GetClock_nsec() const { return clock_nsec; }
                     78: 
1.1.1.5   root       79:        // 割り込み発生を MPU に通知
                     80:        virtual void Interrupt(int level) = 0;
1.1.1.4   root       81: 
1.1.1.14  root       82:        // デバイスが CI (キャッシュ禁止) をセットする。
                     83:        virtual void SetCI() = 0;
1.1.1.9   root       84: 
1.1.1.15  root       85:        // 例外カウンタ
                     86:        std::vector<uint64> excep_counter {};
                     87: 
1.1.1.4   root       88:  protected:
1.1.1.11  root       89:        void TraceMessage(MessageID, uint32);
1.1.1.16  root       90:        virtual void SetTrace(bool enable) = 0;
                     91: 
                     92:        // CPU の状態
                     93:        void ChangeState(uint32 new_state);
                     94: 
                     95:        // CPU の実行状態
                     96:        uint32 cpu_state {};
1.1.1.11  root       97: 
1.1.1.15  root       98:        uint clock_khz {};              // MPU クロック [kHz]
1.1.1.12  root       99:        uint64 clock_nsec {};   // MPU クロック [nsec]
                    100: 
                    101:        bool resetting {};              // リセット処理中フラグ
1.1.1.11  root      102: 
1.1.1.13  root      103:        MainbusDevice *mainbus {};
                    104:        Syncer *syncer {};
                    105: 
1.1.1.10  root      106:        // Round Mode (モニタ表示用)
                    107:        static const char * const rmstr[4];
1.1       root      108: };
                    109: 
1.1.1.15  root      110: static inline MainMPUDevice *GetMPUDevice() {
                    111:        return Object::GetObject<MainMPUDevice>(OBJ_MPU);
1.1.1.13  root      112: }

unix.superglobalmegacorp.com

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