|
|
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 *gNMI;
18:
19: // コンストラクタ
20: NMIDevice::NMIDevice()
21: : inherited("NMI")
22: {
23: event.func = ToEventCallback(&NMIDevice::NegateCallback);
24: event.time = 100_msec;
25: event.Regist("NMI");
26: }
27:
28: // デストラクタ
29: NMIDevice::~NMIDevice()
30: {
31: gNMI = NULL;
32: }
33:
34: // 初期化
35: bool
36: NMIDevice::Init()
37: {
38: gScheduler->ConnectMessage(MessageID::NMI, this,
39: ToMessageCallback(&NMIDevice::AssertCallback));
40: return true;
41: }
42:
43: // NMI ボタンを押す (GUI から呼ばれる)
44: void
45: NMIDevice::PressNMI()
46: {
47: gScheduler->SendMessage(MessageID::NMI);
48: }
49:
50: // NMI 信号線をアサートする
51: void
52: NMIDevice::AssertNMI()
53: {
54: gInterrupt->AssertINT(this);
55: }
56:
57: // NMI 信号線をネゲートする
58: void
59: NMIDevice::NegateNMI()
60: {
61: gInterrupt->NegateINT(this);
62: }
63:
64: // NMI アサートのメッセージコールバック
65: void
66: NMIDevice::AssertCallback(MessageID msgid, uint32 arg)
67: {
68: AssertNMI();
69:
1.1.1.2 ! root 70: if (gMainApp.Has(VMCap::LUNA)) {
1.1 root 71: // LUNA(-I) は誰がいつどうネゲートしているのか分からないが
72: // コードが能動的にネゲートしているようには見えないので、
73: // とりあえず適当な時間経過後に自動的にネゲートしておいてみる。
74: gScheduler->RestartEvent(event);
75: }
76: }
77:
78: // NMI ネゲートのイベントコールバック
79: void
80: NMIDevice::NegateCallback(Event& ev)
81: {
82: NegateNMI();
83: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.