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

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

unix.superglobalmegacorp.com

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