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

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"
1.1.1.7 ! root       12: #include "event.h"
1.1       root       13: #include "interrupt.h"
                     14: #include "mainapp.h"
                     15: #include "scheduler.h"
                     16: 
                     17: // コンストラクタ
                     18: NMIDevice::NMIDevice()
1.1.1.3   root       19:        : inherited(OBJ_NMI)
1.1       root       20: {
                     21: }
                     22: 
                     23: // デストラクタ
                     24: NMIDevice::~NMIDevice()
                     25: {
                     26: }
                     27: 
                     28: // 初期化
                     29: bool
                     30: NMIDevice::Init()
                     31: {
1.1.1.3   root       32:        interrupt = GetInterruptDevice();
                     33: 
                     34:        scheduler->ConnectMessage(MessageID::NMI, this,
1.1.1.4   root       35:                ToMessageCallback(&NMIDevice::AssertMessage));
1.1.1.3   root       36: 
1.1.1.7 ! root       37:        auto evman = GetEventManager();
        !            38:        event = evman->Regist(this,
        !            39:                ToEventCallback(&NMIDevice::NegateCallback),
        !            40:                "NMI");
        !            41:        event->time = 100_msec;
1.1.1.5   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
1.1.1.7 ! root       83: NMIDevice::NegateCallback(Event *ev)
1.1       root       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.