|
|
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.9 root 7: //
1.1.1.11! root 8: // メイン MPU (680x0/88xx0) 共通部
1.1.1.9 root 9: //
1.1.1.2 root 10:
1.1.1.11! root 11: // Device
! 12: // | +-----------+
! 13: // +--| MPUDevice | (680x0/88xx0 の共通部)
! 14: // | +-----------+
! 15: // | |
! 16: // | +-- MPU680x0Device
! 17: // | +-- MPU88xx0Device
! 18: // |
! 19: // +-------- MPU64180Device
! 20:
1.1 root 21: #include "mpu.h"
1.1.1.5 root 22: #include "config.h"
1.1.1.11! root 23: #include "debugger.h"
! 24: #include "mainbus.h"
1.1.1.9 root 25: #include "scheduler.h"
1.1.1.11! root 26: #include "syncer.h"
1.1 root 27:
1.1.1.9 root 28: // グローバル参照用
29: MPUDevice *gMPU;
1.1 root 30:
31: // コンストラクタ
1.1.1.11! root 32: MPUDevice::MPUDevice()
! 33: : inherited(OBJ_MPU)
1.1 root 34: {
1.1.1.9 root 35: exec_event.Regist("MPU Execute");
1.1 root 36: }
37:
38: // デストラクタ
39: MPUDevice::~MPUDevice()
40: {
1.1.1.9 root 41: gMPU = NULL;
1.1 root 42: }
1.1.1.4 root 43:
1.1.1.11! root 44: // 初期化
1.1.1.5 root 45: bool
46: MPUDevice::Init()
47: {
1.1.1.11! root 48: if (inherited::Init() == false) {
! 49: return false;
! 50: }
! 51:
! 52: // XXX 主に m680x0 配下がグローバル変数じゃないと色々解決できない。
! 53: // そのうちなんとかする。
! 54: gMPU = this;
! 55:
! 56: debugger = GetDebugger();
! 57: mainbus = GetMainbusDevice();
! 58: syncer = GetSyncer();
! 59:
! 60: scheduler->ConnectMessage(MessageID::MPU_TRACE_MAIN, this,
1.1.1.9 root 61: ToMessageCallback(&MPUDevice::TraceMessage));
62:
1.1.1.5 root 63: // MPU クロック
64: const ConfigItem& item = gConfig->Find("mpu-clock");
65: const std::string& val = item.AsString();
66: if (val.empty()) {
67: item.Err();
68: return false;
69: }
70: // 文字列を double に変換
71: char *end;
72: errno = 0;
73: double f = strtod(val.c_str(), &end);
74: if (end == val.c_str() || end[0] != '\0' || errno == ERANGE) {
75: item.Err();
76: return false;
77: }
78: // 設定の "mpu-clock" は MHz 単位だが、変数 clock_khz は kHz 単位。
79: clock_khz = (int)(f * 1000);
1.1.1.7 root 80: // 1MHz 未満はエラー。実際 10MHz 未満でもいい気がするけど
1.1.1.5 root 81: if (clock_khz < 1000) {
82: item.Err();
83: return false;
84: }
1.1.1.9 root 85: clock_nsec = 1000 * 1000 / clock_khz;
1.1.1.5 root 86:
87: return true;
88: }
1.1.1.8 root 89:
1.1.1.9 root 90: void
91: MPUDevice::PowerOff()
92: {
1.1.1.11! root 93: scheduler->StopEvent(exec_event);
1.1.1.9 root 94: }
95:
96: // MPU トレース状態設定要求メッセージ
97: void
98: MPUDevice::TraceMessage(MessageID msgid, uint32 arg)
99: {
1.1.1.10 root 100: // リセット中は SetTrace しない
101: if (resetting) {
102: return;
103: }
104:
1.1.1.9 root 105: // デバッガから MPU のトレース状態を設定してくれと言われた
106: SetTrace((bool)arg);
107: }
108:
1.1.1.8 root 109: // Round Mode (モニタ表示用)
110: /*static*/ const char * const
111: MPUDevice::rmstr[4] = {
112: "Near",
113: "Zero",
114: "Minus",
115: "Plus",
116: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.