|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // ABORT/INTERRUPT スイッチによる NMI 機構デバイス
9: //
10:
11: #include "nmi.h"
12: #include "interrupt.h"
13: #include "mainapp.h"
14: #include "scheduler.h"
15:
16: // コンストラクタ
17: NMIDevice::NMIDevice()
1.1.1.3 root 18: : inherited(OBJ_NMI)
1.1 root 19: {
20: }
21:
22: // デストラクタ
23: NMIDevice::~NMIDevice()
24: {
25: }
26:
27: // 初期化
28: bool
29: NMIDevice::Init()
30: {
1.1.1.3 root 31: interrupt = GetInterruptDevice();
32:
33: scheduler->ConnectMessage(MessageID::NMI, this,
1.1.1.4 root 34: ToMessageCallback(&NMIDevice::AssertMessage));
1.1.1.3 root 35:
1.1.1.5 root 36: event.func = ToEventCallback(&NMIDevice::NegateCallback);
37: event.time = 100_msec;
38: event.SetName("NMI");
39: scheduler->RegistEvent(event);
40:
1.1 root 41: return true;
42: }
43:
44: // NMI ボタンを押す (GUI から呼ばれる)
45: void
46: NMIDevice::PressNMI()
47: {
1.1.1.3 root 48: scheduler->SendMessage(MessageID::NMI);
1.1 root 49: }
50:
51: // NMI 信号線をアサートする
52: void
53: NMIDevice::AssertNMI()
54: {
1.1.1.3 root 55: interrupt->AssertINT(this);
1.1 root 56: }
57:
58: // NMI 信号線をネゲートする
59: void
60: NMIDevice::NegateNMI()
61: {
1.1.1.3 root 62: interrupt->NegateINT(this);
1.1 root 63: }
64:
65: // NMI アサートのメッセージコールバック
66: void
1.1.1.4 root 67: NMIDevice::AssertMessage(MessageID msgid, uint32 arg)
1.1 root 68: {
69: AssertNMI();
70:
1.1.1.2 root 71: if (gMainApp.Has(VMCap::LUNA)) {
1.1 root 72: // LUNA(-I) は誰がいつどうネゲートしているのか分からないが
73: // コードが能動的にネゲートしているようには見えないので、
74: // とりあえず適当な時間経過後に自動的にネゲートしておいてみる。
1.1.1.3 root 75: scheduler->RestartEvent(event);
1.1 root 76: }
77: }
78:
79: // NMI ネゲートのイベントコールバック
80: void
81: NMIDevice::NegateCallback(Event& ev)
82: {
83: NegateNMI();
84: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.