Annotation of nono/vm/nmi.cpp, revision 1.1.1.4

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.