|
|
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.18! root 15: #include "event.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.18! root 31: void ResetHard(bool poweron) override;
1.1.1.11 root 32: void PowerOff() override;
1.1 root 33:
1.1.1.2 root 34: // 現在実行中の命令の PC を取得
35: virtual uint32 GetPPC() const = 0;
1.1 root 36:
1.1.1.18! root 37: // 最後に発生した例外ベクタを取得し、同時にクリアする
! 38: int32 GetAndResetLastVector();
! 39:
! 40: // exec イベントの回数
! 41: uint64 GetExecCount() const { return exec_event->count; }
! 42:
1.1.1.15 root 43: protected:
44: // 1命令実行イベント
1.1.1.17 root 45: Event *exec_event {};
1.1.1.15 root 46:
47: Debugger *debugger {};
1.1.1.18! root 48:
! 49: // 最後に発生した例外ベクタ。起きてなければ -1。
! 50: int32 last_vector {};
1.1.1.15 root 51: };
52:
53: // メイン MPU (680x0/88xxx0) 共通部
54: class MainMPUDevice : public MPUDevice
55: {
56: using inherited = MPUDevice;
1.1.1.16 root 57: protected:
58: // CPU の実行状態
59: static const uint32 CPU_STATE_NORMAL = 0;
60: static const uint32 CPU_STATE_STOP = 1;
61: static const uint32 CPU_STATE_HALT = 2;
62:
1.1.1.15 root 63: public:
64: MainMPUDevice();
65: ~MainMPUDevice() override;
66:
67: bool Init() override;
68:
1.1.1.11 root 69: // 現在の VBR を取得
70: virtual uint32 GetVBR() const = 0;
71:
1.1.1.16 root 72: // CPU の実行状態 (uint32) を返す。
73: uint32 GetState() const noexcept { return cpu_state; }
74:
1.1.1.14 root 75: // MPU 名を取得する。("MC68030" みたいなやつ、ログ名とは別)
76: virtual const char *GetMPUName() const = 0;
77:
1.1.1.5 root 78: // MPU クロック [kHz] を取得する。
1.1.1.15 root 79: uint GetClockSpeed() const { return clock_khz; }
1.1.1.5 root 80:
1.1.1.18! root 81: // MPU クロック [tsec] を取得する。
! 82: uint64 GetClock_tsec() const { return clock_tsec; }
1.1.1.12 root 83:
1.1.1.5 root 84: // 割り込み発生を MPU に通知
85: virtual void Interrupt(int level) = 0;
1.1.1.4 root 86:
1.1.1.14 root 87: // デバイスが CI (キャッシュ禁止) をセットする。
88: virtual void SetCI() = 0;
1.1.1.9 root 89:
1.1.1.15 root 90: // 例外カウンタ
91: std::vector<uint64> excep_counter {};
92:
1.1.1.4 root 93: protected:
1.1.1.11 root 94: void TraceMessage(MessageID, uint32);
1.1.1.16 root 95: virtual void SetTrace(bool enable) = 0;
96:
97: // CPU の状態
98: void ChangeState(uint32 new_state);
99:
100: // CPU の実行状態
101: uint32 cpu_state {};
1.1.1.11 root 102:
1.1.1.15 root 103: uint clock_khz {}; // MPU クロック [kHz]
1.1.1.18! root 104: uint64 clock_tsec {}; // MPU クロック [tsec]
1.1.1.12 root 105:
106: bool resetting {}; // リセット処理中フラグ
1.1.1.11 root 107:
1.1.1.18! root 108: // キャッシュを強制的に無効にする。テスト用。
! 109: bool force_disable_dcache {};
! 110: bool force_disable_icache {};
! 111:
1.1.1.13 root 112: MainbusDevice *mainbus {};
113: Syncer *syncer {};
114:
1.1.1.10 root 115: // Round Mode (モニタ表示用)
116: static const char * const rmstr[4];
1.1 root 117: };
118:
1.1.1.18! root 119: inline MainMPUDevice *GetMPUDevice() {
1.1.1.15 root 120: return Object::GetObject<MainMPUDevice>(OBJ_MPU);
1.1.1.13 root 121: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.