debug(timer): 门32读回+软int0x20+PIC ISR,一次性区分中断分发路径

LAPIC 配置已确认正常(base/ver/svr/lint0 全部读回正确)但硬件中断仍不达。
新增三段诊断:1) 读回 IDT 门 32 的 base/sel/type;2) 软件 int 0x20 验证
分发路径(门有效→H+返回,门无效→[GP] err=0x20);3) 读 PIC1 ISR 确认
PIT IRQ0 是否真正到达 PIC 并被响应。
This commit is contained in:
TermiNexus committed 2026-08-26 18:42:58 +08:00
1 parent ee329c313f
commit 3995cb9545
1 file changed
+23
+23
View File
@@ -92,9 +92,32 @@ class ViperKernel:
1 if (_dbg_feat & cpu.CPU_FEATURE_APIC) else 0)
serial.puts(c.Addr(_dbg_buf))
# [DBG] 读回 IDT 门 32,验证 isr32 分发地址是否正确安装(用后移除)
_g32: t.CUInt64T = (t.CUInt64T(intr.idt.idt[32].base_low) |
(t.CUInt64T(intr.idt.idt[32].base_middle) << 16) |
(t.CUInt64T(intr.idt.idt[32].base_high) << 32))
_g32buf: t.CArray[t.CChar, 96]
viperlib.snprintf(c.Addr(_g32buf), 96, "[DBG] idt32 base=0x%lx sel=0x%x type=0x%x\n",
_g32, intr.idt.idt[32].selector, intr.idt.idt[32].type_attr)
serial.puts(c.Addr(_g32buf))
asm.sti()
serial.puts("[main] sti done\n")
# [DBG] 软件触发 int 0x20:门 32 有效则分发到 isr32→timer_handler 打印 H 并返回;
# 门无效则 #GP(isrCommonhandler 打印 [GP] err=0x20),一次性区分分发路径(用后移除)
serial.puts("[DBG] before swint\n")
c.Asm("int 0x20", op=[t.ASM_DESCR.CLOBBER_MEMORY])
serial.puts("[DBG] after swint\n")
# [DBG] 读 PIC1 ISR:bit0 置位说明 PIT IRQ0 已到达 PIC 并被响应(用后移除)
asm.outb(0x20, 0x0B) # OCW3 读 ISR
asm.io_wait()
_pic_isr: t.CUInt8T = asm.inb(0x20)
_isrbuf: t.CArray[t.CChar, 48]
viperlib.snprintf(c.Addr(_isrbuf), 48, "[DBG] pic_isr=0x%x\n", _pic_isr)
serial.puts(c.Addr(_isrbuf))
timer.timer_msleep(100)
serial.puts("[main] msleep done\n")
rtc.rtc_init()