--- nono/vm/interrupt.cpp 2026/04/29 17:04:55 1.1.1.4 +++ nono/vm/interrupt.cpp 2026/04/29 17:05:06 1.1.1.5 @@ -55,6 +55,47 @@ InterruptDevice::~InterruptDevice() { } +// リセット +void +InterruptDevice::ResetHard() +{ + intmap = IntmapSentinel; + memset(&counter, 0, sizeof(counter)); +} + +// 子デバイスが割り込み信号線をアサートした +void +InterruptDevice::AssertINT(Device *source) +{ + uint32 oldmap; + uint32 srcmap; + + oldmap = intmap; + srcmap = GetIntmap(source); + intmap |= srcmap; + + if ((oldmap ^ intmap) != 0) { + // 立ち上がりエッジでカウント + counter[__builtin_clz(srcmap)]++; + ChangeInterrupt(); + } +} + +// 子デバイスが割り込み信号線をネゲートした +void +InterruptDevice::NegateINT(Device *source) +{ + uint32 oldmap; + uint32 srcmap; + + oldmap = intmap; + srcmap = GetIntmap(source); + intmap &= ~srcmap; + + if ((oldmap ^ intmap) != 0) { + ChangeInterrupt(); + } +} // // 仮想割り込みコントローラ (m680x0 共通部) @@ -81,51 +122,20 @@ M680x0Interrupt::~M680x0Interrupt() void M680x0Interrupt::ResetHard() { + inherited::ResetHard(); ipl = 0; - intmap = 0x00000001; - memset(&counter, 0, sizeof(counter)); -} - -// 子デバイスが割り込み信号線をアサートした (m680x0 共通) -void -M680x0Interrupt::AssertINT(Device *source) -{ - uint32 oldmap; - uint32 srcmap; - int newipl; - - oldmap = intmap; - srcmap = GetIntmap(source); - intmap |= srcmap; - - if ((oldmap ^ intmap) != 0) { - // 立ち上がりエッジでカウント - counter[__builtin_clz(srcmap)]++; - } - - newipl = (uint)(31 - __builtin_clz(intmap)) / 4; - - // アサートによって割り込みレベルが上がったら、新しいレベルを通知 - // (現在通知中より低い割り込みは受け付けただけでここで保留) - if (newipl > ipl) { - ipl = newipl; - gMPU->Interrupt(ipl); - } } -// 子デバイスが割り込み信号線をネゲートした (m680x0 共通) void -M680x0Interrupt::NegateINT(Device *source) +M680x0Interrupt::ChangeInterrupt() { int newipl; - intmap &= ~GetIntmap(source); - // intmap の最下位ビットは常に立ててあり intmap は 0 にならない + // intmap の最下位ビットは常に立ててあるので 0 にならない newipl = (uint)(31 - __builtin_clz(intmap)) / 4; - // ネゲートによって割り込みレベルが下がったら、新しいレベルを通知 - // (以前に保留されていた低いレベルがあればここで見えるようになる) - if (newipl < ipl) { + // 割り込みレベルが変わったら、新しいレベルを通知 + if (newipl != ipl) { ipl = newipl; gMPU->Interrupt(ipl); } @@ -140,7 +150,7 @@ M680x0Interrupt::NegateINT(Device *sourc X68030Interrupt::X68030Interrupt() { monitor.func = (MonitorCallback_t)&X68030Interrupt::MonitorUpdate; - monitor.SetSize(24, 11); + monitor.SetSize(25, 11); monitor.Regist(ID_MONITOR_INTERRUPT); } @@ -208,47 +218,30 @@ X68030Interrupt::MonitorUpdate(Monitor * { "SCC", IntmapSCC }, { "DMAC", IntmapDMAC }, { "PEDEC", IntmapPEDEC }, - }, tablePEDEC[] = { - { "SPC", PEDECDevice::IntmapSPC }, - { "FDC", PEDECDevice::IntmapFDC }, - { "FDD", PEDECDevice::IntmapFDD }, - { "HDD", PEDECDevice::IntmapHDD }, - { "PRT", PEDECDevice::IntmapPRT }, }; // CPU の割り込み可否は本当は関係ないけど、便宜的に一緒に表示したい uint intr_level = gMPU680x0->GetCPU()->reg.intr_level; - // PEDEC 分も一緒に表示したい - uint32 pintr = gPEDEC->GetInt(); screen.Clear(); y = 0; - screen.Print(0, y++, "Lv Device Count IM=%d", intr_level); + screen.Print(0, y++, "Lv Device Count IM=%d", intr_level); for (int i = 0; i < countof(table); i++) { uint32 map = table[i].map; int clz = __builtin_clz(map); int lv = (31 - clz) / 4; screen.Print(0, y, "%d", lv); screen.Print(2, y, TA::OnOff(intmap & map), "%s", table[i].name); - screen.Print(8, y, "%10u", counter[clz]); + screen.Print(8, y, "%11" PRIu64, counter[clz]); if (lv <= intr_level) { - screen.Puts(20, y, "Mask"); + screen.Puts(21, y, "Mask"); } y++; } - // pintr は下位ワードが割り込み状態、上位ワードが許可状態。 - uint32 pmask = pintr >> 16; - for (int i = 0; i < countof(tablePEDEC); i++) { - uint32 map = tablePEDEC[i].map; - screen.Puts(3, y, TA::OnOff(pintr & map), tablePEDEC[i].name); - // XXX カウンタはまだない - if (intr_level >= 1 || (pmask & map) == 0) { - screen.Puts(20, y, "Mask"); - } - y++; - } + // PEDEC 分も一緒に表示したい + gPEDEC->MonitorUpdate(screen, intr_level, y); } // @@ -259,7 +252,7 @@ X68030Interrupt::MonitorUpdate(Monitor * LunaInterrupt::LunaInterrupt() { monitor.func = (MonitorCallback_t)&LunaInterrupt::MonitorUpdate; - monitor.SetSize(24, 5); + monitor.SetSize(25, 5); monitor.Regist(ID_MONITOR_INTERRUPT); } @@ -316,16 +309,16 @@ LunaInterrupt::MonitorUpdate(Monitor *, screen.Clear(); y = 0; - screen.Print(0, y++, "Lv Device Count IM=%d", intr_level); + screen.Print(0, y++, "Lv Device Count IM=%d", intr_level); for (int i = 0; i < countof(table); i++) { uint32 map = table[i].map; int clz = __builtin_clz(map); int lv = (31 - clz) / 4; screen.Print(0, y, "%d", lv); screen.Print(2, y, TA::OnOff(intmap & map), "%s", table[i].name); - screen.Print(8, y, "%10u", counter[clz]); + screen.Print(8, y, "%11" PRIu64, counter[clz]); if (lv <= intr_level) { - screen.Puts(20, y, "Mask"); + screen.Puts(21, y, "Mask"); } y++; }