Annotation of nono/vm/mpu680x0.h, revision 1.1.1.9

1.1       root        1: //
                      2: // nono
1.1.1.2   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
                      7: // MPU (m680x0)
                      8: 
                      9: #pragma once
                     10: 
1.1.1.7   root       11: #include "event.h"
1.1       root       12: #include "mpu.h"
                     13: #include "m68030.h"
                     14: 
                     15: class MPU680x0Device : public MPUDevice
                     16: {
1.1.1.2   root       17:        using inherited = MPUDevice;
1.1       root       18:  public:
1.1.1.7   root       19:        MPU680x0Device();
1.1.1.5   root       20:        virtual ~MPU680x0Device() override;
1.1       root       21: 
1.1.1.2   root       22:        bool Init() override;
1.1.1.7   root       23:        bool PowerOn() override;
                     24:        void ResetHard() override;
1.1       root       25: 
1.1.1.5   root       26:        // MPU を vtime [nsec] 分実行する
                     27:        uint32 Run(uint32 vtime) override;
                     28: 
                     29:        // 現在の仮想時刻 [nsec] を取得する
1.1.1.6   root       30:        uint64 GetVirtTime() const override;
1.1       root       31: 
                     32:        // 現在の PPC を取得
1.1.1.2   root       33:        uint32 GetPPC() const override { return RegPPC; }
1.1       root       34: 
                     35:        // 現在アクセス中の論理アドレス、物理アドレスを取得。
1.1.1.2   root       36:        uint32 GetLaddr() const override { return cpu->bus.laddr; }
                     37:        uint32 GetPaddr() const override { return cpu->bus.paddr; }
1.1       root       38: 
1.1.1.4   root       39:        // アクセスウェイトを加算
1.1.1.5   root       40:        void AddCycle(int32 cycle) override { cpu->used_cycle += cycle; }
1.1       root       41: 
1.1.1.5   root       42:        // 割り込みレベルが変わったことを MPU に通知
                     43:        void Interrupt(int level) override;
1.1       root       44: 
                     45:        // MPU の処理をこの命令で中断させる。
                     46:        // スケジューラのイベントリストに追加が発生した時に VM 側から
                     47:        // MPU へ処理の中断を指示する。
1.1.1.2   root       48:        void Release() override { cpu->atomic_reqflag |= CPU_REQ_RELEASE; }
1.1       root       49: 
                     50:        // A-Line, F-Line 命令エミュレーションのコールバックを指定する。
                     51:        // (Human68k エミュレーションで使用)
                     52:        void SetALineCallback(bool (*callback)(m68kcpu*, void*), void *arg);
                     53:        void SetFLineCallback(bool (*callback)(m68kcpu*, void*), void *arg);
                     54: 
                     55:        // FPU を持っているか
                     56:        bool HaveFPU() const {
                     57:                return cpu->has_fpu;
                     58:        }
                     59: 
                     60:        // CPU コアを取得 (主にデバッグ用途)
                     61:        m68kcpu *GetCPU() const {
                     62:                return cpu;
                     63:        }
                     64: 
1.1.1.9 ! root       65:        // MPU からのアクセスをエミュレートする。
        !            66:        // アドレスは論理アドレス。
        !            67:        // 空間は現在のデータ空間。
        !            68:        uint64 Read8(uint32 addr) override;
        !            69:        uint64 Read16(uint32 addr) override;
        !            70:        uint64 Read32(uint32 addr) override;
        !            71:        uint64 Write8(uint32 addr, uint32 data) override;
        !            72:        uint64 Write16(uint32 addr, uint32 data) override;
        !            73:        uint64 Write32(uint32 addr, uint32 data) override;
        !            74: 
1.1       root       75:  private:
1.1.1.5   root       76:        // イベントコールバック
                     77:        void Callback(Event& ev);
                     78: 
1.1.1.9 ! root       79:        // MPU ホールト時のコールバック関数
        !            80:        static void HaltCallback(void *arg);
        !            81: 
1.1.1.7   root       82:        // 割り込み用イベント
1.1.1.8   root       83:        Event event { this };
                     84: 
                     85:        // レジスタモニター
                     86:        DECLARE_MONITOR_CALLBACK(MonitorUpdateReg);
                     87:        Monitor reg_monitor { this };
                     88: 
                     89:        // ATC モニター
                     90:        DECLARE_MONITOR_CALLBACK(MonitorUpdateATC);
                     91:        Monitor atc_monitor { this };
1.1.1.7   root       92: 
1.1.1.5   root       93:        // 割り込み確定のためのディレイ [nsec]
                     94:        uint64 intdelay {};
1.1.1.4   root       95: 
                     96:        m68kcpu *cpu {};
1.1       root       97: };
                     98: 
                     99: #define gMPU680x0      (dynamic_cast<MPU680x0Device *>(gMPU.get()))

unix.superglobalmegacorp.com

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