debug(timer): timer_handler 每 250 拍打印 [T],验证定时器中断触发

sti 后卡死在 timer_msleep,静态分析 PIT/PIC/IDT/ISR/timer_handler/
msleep/sched_tick 的 IR 全部正确。加串口诊断确认 ISR 是否触发:
若串口无 [T] → 中断未触发(PIC/PIT/IDT 运行期问题);有 [T] 仍挂 →
ticks 未推进/ISR 未返回。用后移除。
This commit is contained in:
TermiNexus committed 2026-08-26 18:07:47 +08:00
1 parent 8b40203b63
commit 7336ddff48
1 file changed
+7 -1
+7 -1
View File
@@ -1,6 +1,7 @@
import platform.pch.pic as pic
import platform.pch.pit as pit
import sched.sched as sched
import drivers.serial.uart.serial as serial
import asm
import t, c
@@ -12,6 +13,7 @@ ticks: t.CStatic | t.CVolatile | t.CUInt64T = 0
seconds: t.CStatic | t.CVolatile | t.CUInt32T = 0
milliseconds: t.CStatic | t.CVolatile | t.CUInt32T = 0
timer_running: t.CStatic | t.CVolatile | bool = False
_dbg_last: t.CUInt64T = 0
def timer_init():
global ticks, seconds, milliseconds, timer_running
@@ -24,7 +26,7 @@ def timer_init():
pit.pit_init(TIMER_FREQUENCY)
def timer_handler():
global ticks, seconds, milliseconds, timer_running
global ticks, seconds, milliseconds, timer_running, _dbg_last
if not timer_running:
pic.eoi(0)
return
@@ -35,6 +37,10 @@ def timer_handler():
seconds = seconds + 1
milliseconds = milliseconds - 1000
c.Asm("mfence", op=[t.ASM_DESCR.CLOBBER_MEMORY])
# [DBG] 每 250 拍打印一次,验证定时器中断是否触发(排查 sti 后挂起,用后移除)
if ticks - _dbg_last >= 250:
_dbg_last = ticks
serial.puts("[T]")
sched.Scheduler.sched_tick()
pic.eoi(0)