--- nono/vm/pedec.cpp 2026/04/29 17:05:06 1.1.1.4 +++ nono/vm/pedec.cpp 2026/04/29 17:05:17 1.1.1.7 @@ -4,27 +4,61 @@ // Licensed under nono-license.txt // +// +// PEDEC +// + +// IODevice +// | +// +-- InterruptDevice (割り込みコントローラの共通部) +// | +// +-- M680x0Interrupt (m68k 割り込みコントローラの共通部) +// | | +// | +-- X68030Interrupt (X68030 の割り込みコントローラ) +// | +-- LunaInterrupt (LUNA-I の割り込みコントローラ) +// | +// | +-------------+ +// +--| PEDECDevice | (X68030 の Lv1 担当コントローラ) +// | +-------------+ +// | +// +-- SysCtlrDevice (LUNA-88K の割り込みコントローラ) + #include "pedec.h" #include "fdc.h" +#include "fdd.h" #include "spc.h" -std::unique_ptr gPEDEC; - +// コンストラクタ PEDECDevice::PEDECDevice() - : inherited("PEDEC") + : inherited(OBJ_PEDEC) { - devaddr = baseaddr; - devlen = 0x2000; } +// デストラクタ PEDECDevice::~PEDECDevice() { } +// 初期化 +bool +PEDECDevice::Init() +{ + if (inherited::Init() == false) { + return false; + } + + fdc = GetFDCDevice(); + interrupt = GetInterruptDevice(); + spc = GetSPCDevice(); + + return true; +} + +// リセット void -PEDECDevice::ResetHard() +PEDECDevice::ResetHard(bool poweron) { - inherited::ResetHard(); + inherited::ResetHard(poweron); intmap_enabled = IntmapSPC; // XXX vector @@ -57,7 +91,7 @@ PEDECDevice::Write(uint32 offset, uint32 intmap_enabled |= (data & 0x02) ? IntmapFDD : 0; intmap_enabled |= (data & 0x01) ? IntmapPRT : 0; - putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d", + putlog(1, "Set Interrupt Mask HDD=%d FDC=%d FDD=%d PRT=%d", ((intmap_enabled & IntmapHDD) ? 1 : 0), ((intmap_enabled & IntmapFDC) ? 1 : 0), ((intmap_enabled & IntmapFDD) ? 1 : 0), @@ -66,7 +100,7 @@ PEDECDevice::Write(uint32 offset, uint32 case 1: // $E9C003 割り込みベクタ vector = data & 0xfc; - putlog(1, "割り込みベクタ設定 $%02x", vector); + putlog(1, "Set Interrupt Vector $%02x", vector); return 0; default: @@ -107,12 +141,11 @@ PEDECDevice::MonitorUpdate(TextScreen& s for (int i = 0; i < countof(table); i++) { uint32 map = table[i].map; int clz = __builtin_clz(map); - screen.Puts(3, y, TA::OnOff(intmap & map), table[i].name); - screen.Print(8, y, "%11" PRIu64, counter[clz]); - + screen.Puts(4, y, TA::OnOff(intmap & map), table[i].name); if (intr_level >= 1 || (intmap_enabled & map) == 0) { - screen.Puts(21, y, "Mask"); + screen.Puts(10, y, "Mask"); } + screen.Print(14, y, "%26s", format_number(counter[clz]).c_str()); y++; } } @@ -148,7 +181,7 @@ PEDECDevice::ChangeInterrupt() #endif uint32 stat = (intmap & intmap_enabled); - gInterrupt->ChangeINT(this, stat); + interrupt->ChangeINT(this, stat); } // 割り込みアクノリッジ @@ -166,8 +199,10 @@ PEDECDevice::InterruptAcknowledge(int lv if ((stat & IntmapFDC)) { return vector + 0; + } else if ((stat & IntmapFDD)) { + return vector + 1; } else { - PANIC("Unknown interrupt acknowledge"); + VMPANIC("Unknown interrupt acknowledge"); } } @@ -175,11 +210,14 @@ PEDECDevice::InterruptAcknowledge(int lv uint32 PEDECDevice::GetIntmap(Device *source) const { - if (__predict_true(source == gSPC.get())) { + if (__predict_true(source == spc)) { return IntmapSPC; } - if (__predict_true(source == gFDC.get())) { + if (__predict_true(source == fdc)) { return IntmapFDC; } - PANIC("Unsupported interrupt device"); + if (dynamic_cast(source)) { + return IntmapFDD; + } + VMPANIC("Unsupported interrupt device"); }