|
|
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.13 root 8: // MPU (共通部分)
1.1.1.9 root 9: //
1.1.1.2 root 10:
1.1.1.11 root 11: // Device
12: // | +-----------+
1.1.1.13 root 13: // +--| MPUDevice | (全 MPU の共通部)
14: // +-----------+
15: // |
16: // | +---------------+
17: // +--| MainMPUDevice | (680x0/88xx0 の共通部)
18: // | +---------------+
19: // | |
20: // | +-- MPU680x0Device
21: // | +-- MPU88xx0Device
22: // |
23: // +-- MPU64180Device
1.1.1.11 root 24:
1.1 root 25: #include "mpu.h"
1.1.1.5 root 26: #include "config.h"
1.1.1.11 root 27: #include "debugger.h"
28: #include "mainbus.h"
1.1.1.9 root 29: #include "scheduler.h"
1.1.1.11 root 30: #include "syncer.h"
1.1 root 31:
1.1.1.13 root 32: //
33: // 全 MPU 共通
34: //
35:
1.1 root 36: // コンストラクタ
1.1.1.13 root 37: MPUDevice::MPUDevice(uint objid_)
38: : inherited(objid_)
1.1 root 39: {
40: }
41:
42: // デストラクタ
43: MPUDevice::~MPUDevice()
44: {
45: }
1.1.1.4 root 46:
1.1.1.11 root 47: // 初期化
1.1.1.5 root 48: bool
49: MPUDevice::Init()
50: {
1.1.1.11 root 51: debugger = GetDebugger();
1.1.1.13 root 52:
53: // パラメータは継承側でセットしている。
54: scheduler->RegistEvent(exec_event);
55:
56: return true;
57: }
58:
59: void
60: MPUDevice::PowerOff()
61: {
62: scheduler->StopEvent(exec_event);
63: }
64:
65:
66: //
67: // メイン MPU (680x0/88xx0) 共通部
68: //
69:
70: // コンストラクタ
71: MainMPUDevice::MainMPUDevice()
72: : inherited(OBJ_MPU)
73: {
74: }
75:
76: // デストラクタ
77: MainMPUDevice::~MainMPUDevice()
78: {
79: }
80:
81: // 初期化
82: bool
83: MainMPUDevice::Init()
84: {
85: if (inherited::Init() == false) {
86: return false;
87: }
88:
1.1.1.11 root 89: mainbus = GetMainbusDevice();
90: syncer = GetSyncer();
91:
1.1.1.14 root 92: // MPU クロック。
93: // 設定の "mpu-clock" は MHz 単位だが、変数 clock_khz は kHz 単位。
1.1.1.13 root 94: int val;
1.1.1.14 root 95: const ConfigItem& item = gConfig->Find("mpu-clock");
1.1.1.13 root 96: if (item.TryFixedDecimal(&val, 3) == false) {
97: item.Err();
98: return false;
99: }
100: clock_khz = (uint)val;
1.1.1.7 root 101: // 1MHz 未満はエラー。実際 10MHz 未満でもいい気がするけど
1.1.1.5 root 102: if (clock_khz < 1000) {
103: item.Err();
104: return false;
105: }
1.1.1.9 root 106: clock_nsec = 1000 * 1000 / clock_khz;
1.1.1.14 root 107: if (clock_nsec < 1) {
108: item.Err("Clock speed too high");
109: return false;
110: }
1.1.1.5 root 111:
1.1.1.13 root 112: scheduler->ConnectMessage(MessageID::MPU_TRACE_MAIN, this,
113: ToMessageCallback(&MainMPUDevice::TraceMessage));
1.1.1.8 root 114:
1.1.1.13 root 115: exec_event.SetName("MPU Execute");
116:
117: return true;
1.1.1.9 root 118: }
119:
120: // MPU トレース状態設定要求メッセージ
121: void
1.1.1.13 root 122: MainMPUDevice::TraceMessage(MessageID msgid, uint32 arg)
1.1.1.9 root 123: {
1.1.1.10 root 124: // リセット中は SetTrace しない
125: if (resetting) {
126: return;
127: }
128:
1.1.1.9 root 129: // デバッガから MPU のトレース状態を設定してくれと言われた
130: SetTrace((bool)arg);
131: }
132:
1.1.1.8 root 133: // Round Mode (モニタ表示用)
134: /*static*/ const char * const
1.1.1.13 root 135: MainMPUDevice::rmstr[4] = {
1.1.1.8 root 136: "Near",
137: "Zero",
138: "Minus",
139: "Plus",
140: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.