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