--- nono/vm/pedec.cpp 2026/04/29 17:05:06 1.1.1.4 +++ nono/vm/pedec.cpp 2026/04/29 17:05:14 1.1.1.6 @@ -4,12 +4,34 @@ // Licensed under nono-license.txt // +// +// PEDEC +// + +// IODevice +// | +// +-- InterruptDevice (割り込みコントローラの共通部) +// | +// +-- M680x0Interrupt (m68k 割り込みコントローラの共通部) +// | | +// | +-- X68030Interrupt (X68030 の割り込みコントローラ) +// | +-- LunaInterrupt (LUNA-I の割り込みコントローラ) +// | +// | +-------------+ +// +--| PEDECDevice | (X68030 の Lv1 担当コントローラ) +// | +-------------+ +// | +// +-- SysCtlrDevice (LUNA88K の割り込みコントローラ) + #include "pedec.h" #include "fdc.h" +#include "fdd.h" #include "spc.h" -std::unique_ptr gPEDEC; +// グローバル参照用 +PEDECDevice *gPEDEC; +// コンストラクタ PEDECDevice::PEDECDevice() : inherited("PEDEC") { @@ -17,14 +39,17 @@ PEDECDevice::PEDECDevice() devlen = 0x2000; } +// デストラクタ PEDECDevice::~PEDECDevice() { + gPEDEC = NULL; } +// リセット void -PEDECDevice::ResetHard() +PEDECDevice::ResetHard(bool poweron) { - inherited::ResetHard(); + inherited::ResetHard(poweron); intmap_enabled = IntmapSPC; // XXX vector @@ -57,7 +82,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 +91,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: @@ -166,8 +191,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 +202,14 @@ PEDECDevice::InterruptAcknowledge(int lv uint32 PEDECDevice::GetIntmap(Device *source) const { - if (__predict_true(source == gSPC.get())) { + if (__predict_true(source == gSPC)) { return IntmapSPC; } - if (__predict_true(source == gFDC.get())) { + if (__predict_true(source == gFDC)) { return IntmapFDC; } - PANIC("Unsupported interrupt device"); + if (dynamic_cast(source)) { + return IntmapFDD; + } + VMPANIC("Unsupported interrupt device"); }