mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-31 12:05:05 +02:00
59 lines
2.1 KiB
Lua
59 lines
2.1 KiB
Lua
-- probe_irq.lua -- which periodic interrupt can a payload hook?
|
|
--
|
|
-- Boot the OS (VT1200_SKIP_LEVEL1=1), then count entries to the handlers that
|
|
-- the firmware's RAM trampolines point at. The trampolines are the 6-byte
|
|
-- `JA target` stubs at the low-RAM vector page (see dwt/notes/VISUAL_INJECTION.md).
|
|
--
|
|
-- Investigation only: this script uses breakpoints to count. The resident-hook
|
|
-- acceptance run does not.
|
|
--
|
|
-- VT1200_SKIP_LEVEL1=1 <mame> vt1200 ... -autoboot_script dwt/visual/probe_irq.lua
|
|
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
local prog = cpu.spaces['program']
|
|
if not dbg then print("ERROR: no debugger"); machine:exit(); return end
|
|
|
|
local START = tonumber(os.getenv("IRQ_START") or "3200")
|
|
local STOP = tonumber(os.getenv("IRQ_STOP") or "3500")
|
|
local EVERY = tonumber(os.getenv("IRQ_EVERY") or "50")
|
|
|
|
local hits = { di = 0, int1 = 0, int2 = 0 }
|
|
local function bp(addr, key)
|
|
dbg:command(string.format(
|
|
'bpset %s,,{ %s = %s + 1 ; g }', addr, key, key))
|
|
end
|
|
bp("3f7146d0", "hits.di")
|
|
bp("3f7144c0", "hits.int1")
|
|
bp("3f714530", "hits.int2")
|
|
|
|
local rd = function(a) return prog:read_u16(a) end
|
|
local f = 0
|
|
local armed = false
|
|
local last = { di = 0, int1 = 0, int2 = 0 }
|
|
|
|
emu.register_frame_done(function()
|
|
f = f + 1
|
|
if f == START then
|
|
armed = true
|
|
print(string.format("probe_irq: armed at frame %d (DI handler 3F7146D0, INT1 3F7144C0, INT2 3F714530)", f))
|
|
end
|
|
if armed and (f % EVERY == 0) then
|
|
print(string.format(
|
|
"f%4d DI=%d(+%d) INT1=%d(+%d) INT2=%d(+%d) DPYCTL=%04X DPYINT=%04X INTENB=%04X INTPEND=%04X VCOUNT=%04X",
|
|
f, hits.di, hits.di - last.di, hits.int1, hits.int1 - last.int1,
|
|
hits.int2, hits.int2 - last.int2,
|
|
rd(0xc0000080), rd(0xc00000a0), rd(0xc0000110), rd(0xc0000120), rd(0xc00001d0)))
|
|
last.di, last.int1, last.int2 = hits.di, hits.int1, hits.int2
|
|
end
|
|
if f >= STOP then
|
|
print(string.format("probe_irq: totals DI=%d INT1=%d INT2=%d over %d frames",
|
|
hits.di, hits.int1, hits.int2, STOP - START))
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-probe-irq")
|
|
|
|
dbg.visible_cpu = cpu
|
|
dbg.execution_state = 'run'
|