mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-30 12:03:54 +02:00
43 lines
1.7 KiB
Lua
43 lines
1.7 KiB
Lua
-- CALIBRATION: settle the address-unit conventions once and for all.
|
|
--
|
|
-- Four different conventions have been in play and I keep tripping on them:
|
|
-- 1. the firmware's own operands (bit addresses, e.g. @0x64000D0)
|
|
-- 2. the driver's address-map units (BOARD_BASE 0x06400000 + offset)
|
|
-- 3. the catch-all log's addresses (it printed 0x400000..0x40D7FF)
|
|
-- 4. the debugger's wpset/bpset units
|
|
--
|
|
-- The access log PROVES the firmware hits the window at driver address
|
|
-- 0x0620000D. So: watch that, and also the firmware's operand for it, and see
|
|
-- which one fires and what wpaddr reports. Whatever fires calibrates the rest.
|
|
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
|
|
if not dbg then
|
|
print("ERROR: debugger not enabled; pass -debug")
|
|
machine:exit()
|
|
return
|
|
end
|
|
|
|
-- A: the driver-map address (proven hit by VT1200_BOARD_LOG)
|
|
dbg:command('wpset 0620000d,10,rw,{ printf "CAL-A wpaddr=%08X data=%04X acc=%02X pc=%08X\\n", wpaddr, wpdata, wpaccess, pc ; g }')
|
|
-- B: the firmware operand (bit address as printed in disassembly)
|
|
dbg:command('wpset 6200010,10,rw,{ printf "CAL-B wpaddr=%08X data=%04X acc=%02X pc=%08X\\n", wpaddr, wpdata, wpaccess, pc ; g }')
|
|
-- C: the same value shifted the other way
|
|
dbg:command('wpset 00620000,10,rw,{ printf "CAL-C wpaddr=%08X data=%04X acc=%02X pc=%08X\\n", wpaddr, wpdata, wpaccess, pc ; g }')
|
|
print("calibration watchpoints armed: A=0x0620000d B=0x6200010 C=0x00620000")
|
|
|
|
local maxframes = tonumber(os.getenv("CAL_FRAMES") or "200")
|
|
local n = 0
|
|
emu.register_frame_done(function()
|
|
n = n + 1
|
|
if n >= maxframes then
|
|
print("done (" .. n .. " frames)")
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-cal")
|
|
|
|
dbg.visible_cpu = cpu
|
|
dbg.execution_state = 'run'
|