|
|
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:
1.1.1.10! root 7: //
! 8: // MPU (MC68030)
! 9: //
1.1 root 10:
11: #pragma once
12:
1.1.1.7 root 13: #include "event.h"
1.1 root 14: #include "mpu.h"
15: #include "m68030.h"
16:
17: class MPU680x0Device : public MPUDevice
18: {
1.1.1.2 root 19: using inherited = MPUDevice;
1.1 root 20: public:
1.1.1.7 root 21: MPU680x0Device();
1.1.1.5 root 22: virtual ~MPU680x0Device() override;
1.1 root 23:
1.1.1.2 root 24: bool Init() override;
1.1.1.10! root 25: void ResetHard(bool poweron) override;
1.1 root 26:
27: // 現在の PPC を取得
1.1.1.2 root 28: uint32 GetPPC() const override { return RegPPC; }
1.1 root 29:
1.1.1.10! root 30: // 現在の VBR を取得
! 31: uint32 GetVBR() const override { return RegVBR; }
! 32:
1.1 root 33: // 現在アクセス中の論理アドレス、物理アドレスを取得。
1.1.1.2 root 34: uint32 GetLaddr() const override { return cpu->bus.laddr; }
35: uint32 GetPaddr() const override { return cpu->bus.paddr; }
1.1 root 36:
1.1.1.4 root 37: // アクセスウェイトを加算
1.1.1.5 root 38: void AddCycle(int32 cycle) override { cpu->used_cycle += cycle; }
1.1 root 39:
1.1.1.5 root 40: // 割り込みレベルが変わったことを MPU に通知
41: void Interrupt(int level) override;
1.1 root 42:
43: // A-Line, F-Line 命令エミュレーションのコールバックを指定する。
44: // (Human68k エミュレーションで使用)
45: void SetALineCallback(bool (*callback)(m68kcpu*, void*), void *arg);
46: void SetFLineCallback(bool (*callback)(m68kcpu*, void*), void *arg);
47:
48: // FPU を持っているか
49: bool HaveFPU() const {
50: return cpu->has_fpu;
51: }
52:
53: // CPU コアを取得 (主にデバッグ用途)
54: m68kcpu *GetCPU() const {
55: return cpu;
56: }
57:
1.1.1.9 root 58: // MPU からのアクセスをエミュレートする。
59: // アドレスは論理アドレス。
60: // 空間は現在のデータ空間。
61: uint64 Read8(uint32 addr) override;
62: uint64 Read16(uint32 addr) override;
63: uint64 Read32(uint32 addr) override;
64: uint64 Write8(uint32 addr, uint32 data) override;
65: uint64 Write16(uint32 addr, uint32 data) override;
66: uint64 Write32(uint32 addr, uint32 data) override;
67:
1.1.1.10! root 68: // コアからスケジューラへの動作モード変更通知
! 69: static void NotifyCPUMode(uint32 new_mode);
! 70:
! 71: // コアからの次命令境界での割り込みチェック指示
! 72: void CheckIntr();
! 73:
! 74: // 次の実行サイクルを Full にする。
! 75: void MakeNextFull();
! 76:
! 77: // ホールト時のコアからのコールバック関数
! 78: void Halt();
! 79:
1.1 root 80: private:
1.1.1.10! root 81: // リセット例外コールバック
! 82: void ResetCallback(Event& ev);
! 83:
! 84: // 命令実行系コールバック
! 85: void ExecShort(Event& ev);
! 86: void ExecFull(Event& ev);
! 87: void ExecTrace(Event& ev);
1.1.1.5 root 88:
1.1.1.10! root 89: // トレース設定。デバッガから呼び出される。
! 90: void SetTrace(bool trace_on) override;
1.1.1.9 root 91:
1.1.1.10! root 92: // 割り込みイベントコールバック
! 93: void InterruptCallback(Event& ev);
! 94:
! 95: // 割り込みイベント
! 96: Event intr_event { this };
1.1.1.8 root 97:
98: // レジスタモニター
99: DECLARE_MONITOR_CALLBACK(MonitorUpdateReg);
100: Monitor reg_monitor { this };
101:
102: // ATC モニター
103: DECLARE_MONITOR_CALLBACK(MonitorUpdateATC);
104: Monitor atc_monitor { this };
1.1.1.7 root 105:
1.1.1.10! root 106: // 割り込みペンディング
! 107: bool intr_pending {};
! 108:
! 109: // トレースでコールバックを差し替えることができるように
! 110: // イベントコールバックを変数に入れてある
! 111: EventCallback_t exec_short {};
! 112: EventCallback_t exec_full {};
1.1.1.4 root 113:
114: m68kcpu *cpu {};
1.1 root 115: };
116:
1.1.1.10! root 117: #define gMPU680x0 (dynamic_cast<MPU680x0Device *>(gMPU))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.