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

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.13! root        8: // メイン MPU (680x0/88xx0) 共通部
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       root       16: 
1.1.1.13! root       17: class Debugger;
        !            18: class MainbusDevice;
        !            19: class Syncer;
        !            20: 
1.1       root       21: class MPUDevice : public Device
                     22: {
1.1.1.3   root       23:        using inherited = Device;
1.1       root       24:  public:
1.1.1.13! root       25:        MPUDevice();
1.1.1.5   root       26:        virtual ~MPUDevice() override;
1.1       root       27: 
1.1.1.5   root       28:        bool Init() override;
1.1.1.11  root       29:        void PowerOff() override;
1.1       root       30: 
1.1.1.2   root       31:        // 現在実行中の命令の PC を取得
                     32:        virtual uint32 GetPPC() const = 0;
1.1       root       33: 
1.1.1.11  root       34:        // 現在の VBR を取得
                     35:        virtual uint32 GetVBR() const = 0;
                     36: 
1.1.1.2   root       37:        // 現在アクセス中の論理アドレス、物理アドレスを取得。
                     38:        // Laddr == Paddr が MMU オフなのか PA=VA で運用中なのかの区別は
                     39:        // ここでは付かない。
                     40:        virtual uint32 GetLaddr() const = 0;
                     41:        virtual uint32 GetPaddr() const = 0;
1.1       root       42: 
1.1.1.5   root       43:        // MPU クロック [kHz] を取得する。
                     44:        int GetClockSpeed() const { return clock_khz; }
                     45: 
1.1.1.12  root       46:        // MPU クロック [nsec] を取得する。
                     47:        uint64 GetClock_nsec() const { return clock_nsec; }
                     48: 
1.1.1.4   root       49:        // アクセスウェイトを加算
1.1.1.5   root       50:        virtual void AddCycle(int32 cycle) = 0;
1.1.1.4   root       51: 
1.1.1.5   root       52:        // 割り込み発生を MPU に通知
                     53:        virtual void Interrupt(int level) = 0;
1.1.1.4   root       54: 
1.1.1.9   root       55:        // MPU からのアクセスをエミュレートする。
                     56:        // アドレスは論理アドレス。
                     57:        // 空間は現在のデータ空間。
                     58:        // アクセスエラーは (int64)-1 を返す。
                     59:        virtual uint64 Read8(uint32 addr) = 0;
                     60:        virtual uint64 Read16(uint32 addr) = 0;
                     61:        virtual uint64 Read32(uint32 addr) = 0;
                     62:        virtual uint64 Write8(uint32 addr, uint32 data) = 0;
                     63:        virtual uint64 Write16(uint32 addr, uint32 data) = 0;
                     64:        virtual uint64 Write32(uint32 addr, uint32 data) = 0;
                     65: 
1.1.1.4   root       66:  protected:
1.1.1.11  root       67:        void TraceMessage(MessageID, uint32);
                     68:        virtual void SetTrace(bool trace_on) = 0;
                     69: 
1.1.1.5   root       70:        int clock_khz {};               // MPU クロック [kHz]
1.1.1.12  root       71:        uint64 clock_nsec {};   // MPU クロック [nsec]
                     72: 
                     73:        bool resetting {};              // リセット処理中フラグ
1.1.1.11  root       74: 
1.1.1.13! root       75:        Debugger *debugger {};
        !            76:        MainbusDevice *mainbus {};
        !            77:        Syncer *syncer {};
        !            78: 
1.1.1.11  root       79:        // 1命令実行イベント
                     80:        Event exec_event { this };
1.1.1.10  root       81: 
                     82:        // Round Mode (モニタ表示用)
                     83:        static const char * const rmstr[4];
1.1       root       84: };
                     85: 
1.1.1.13! root       86: // XXX 互換性のためまだしばらく必要
1.1.1.11  root       87: extern MPUDevice *gMPU;
1.1.1.13! root       88: 
        !            89: static inline MPUDevice *GetMPUDevice() {
        !            90:        return Object::GetObject<MPUDevice>(OBJ_MPU);
        !            91: }

unix.superglobalmegacorp.com

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