System Monitors / Freezer
There are a lot of pure software freezers out there. The usage of such tools
may be of great help during the development and debugging of Slaves and the
installed programs. WHDLoad directly supports HRTmon and ThrillKill.
Additionally there is a generic interface which every
freezer may implement to get supported by WHDLoad automatically.
During startup WHDLoad checks if one of the supported
monitors are active. If one is found WHDLoad will do some special stuff. If the
MMU is used by WHDLoad it will declare the memory used by the monitor as valid
and cacheable using the appropriate cache mode. While the game/demo runs it
will forward all NMI
exceptions to the NMI vector saved from the monitors vector table. Additional,
if the VBR is moved by WHDLoad (NoVBRMove/S is
not set and the cpu is at least a 68010) it will compare the FreezeKey with the actual keyboard value at each
interrupt. If the keys match WHDLoad will acknowledge the keyboard, transform
the stackframe to a NMI stackframe and enter the monitor via his NMI handler.
The monitor must return to the interrupted program using a RTE
instruction.
Some further notes which are valid for all freezers:
- Only one freezer is supported at a time. The detection stops at the first
match, the generic interface is checked as last one.
- The freezer must be installed, that means his NMI vector must be set, before
WHDLoad is started, because WHDLoad reads the vector only once on startup.
- The freezer must reside outside the BaseMem area (the memory required by the
Slave), otherwise WHDLoad will refuse to start.
- The memory of the freezer is included in a core dump
and may be used as argument for resload functions
and as stack.
- WHDLoadCD32 has no freezer support built in.
Supported Freezers
| Type | Freezer | Detection |
| 1 | ThrillKill 1.04d ... 1.05d |
code compare before the NMI vector |
| 2 | ThrillKill 1.05d patched by stembbe@ala.net |
code compare before the NMI vector |
| 3 | ThrillKill 17 patched by stembbe@ala.net |
signature "TKTK" before the NMI vector |
| 4 | HRTmon 2.1d ... 2.19 |
signature "HRT!" relative to the VBR |
| 5 | HRTmon 2.20 ... 2.24 |
signature "HRT!" before the NMI vector |
| 6 | HRTmon 2.25 and newer |
signature "HRT!" and "NEWHRT" |
| 7 | HRTmon 2.32 built into WinUAE |
signature "HRT!" at the fixed address $a10000 |
| 8 | ACA500plus and any other freezer implementing
the generic interface |
signature "ACAF" before the NMI vector |
The type is shown in the log file if the option Trace/S is used.
HRTmon
The detection in memory should be safe especially with newer versions of the
monitor cause a new signature was added to the monitor. Be careful if the MMU
is used by WHDLoad: don't access memory outside BaseMem/ExpMem from HRTmon. It
will crash because HRTmon cannot handle the resulting Access Fault Exception.
In the HRTmonPrefs you must check the 'No VBR move' box, otherwise you will
not be able to enter the monitor while WHDLoad is running.
After returning from an activated HRTmon to the program running under WHDLoad
you may note a incorrect graphic display. This is because HRTmon overwrites some
Custom register. You can work around this by telling HRTmon the correct value,
e.g. use 'e $100 $5200' for a 32 color screen before return.
The HRTmon built into WinUAE can only be detected if HRTmon has been
previousy activated at least one time (press key PgUp). This is the case
because not until the first activation the NMI vector will be set which is
required by WHDLoad to locate the monitor.
There are newer releases of HRTmon which add special commands when running
under WHDLoad. So you can load/save files and use the resload_Protect#? functions from within HRTmon. These
releases are downloadable from the WHDLoad page.
ThrillKill
There is no useable signature in the freezer, so some code compares are used.
Therefore the detection only works with known releases.
This interface was introduced with WHDLoad 18.6 for the freezer of the
ACA500plus (which may contain ActionReplay or HRTmon code), but it is not
limited to this hardware. Every freezer, software or hardware based, which
implements this interface will be detected and supported by WHDLoad
automatically, no changes in WHDLoad are required for it.
The interface consists of a signature and a list of the memory areas used by
the freezer, both located immediately before the entry of the NMI handler. On
startup WHDLoad reads the NMI vector (offset $7c) from the exception vector
table (located at the VBR on a 68010 or better, otherwise at address 0) and
checks for the signature.
dc.l memlist ;NMI-8 pointer to the memory list
dc.l "ACAF" ;NMI-4 signature
nmi ... ;NMI entry of the NMI handler
...
rte
memlist dc.l $aa0000,$be0000,3 ;freezer code and data, write through
dc.l $400000,$480000,3 ;freezer buffer, write through
dc.l $bff000,$c00000,1 ;hardware registers, non cachable
dc.l $d8c000,$d90000,1 ;hardware registers, non cachable
dc.l 0 ;end of list
The memory list consists of entries of three long words each, terminated by a
long word of zero. Each entry describes one memory area:
| Offset | Contents |
| 0 | start address of the area |
| 4 | end address of the area (exclusive) |
| 8 | MMU page flags for the area, see below |
The following values are supported as MMU page flags:
| Value | Meaning |
| 0 | invalid (any access creates an access fault) |
| 1 | non cachable |
| 2 | non cachable, serialized |
| 3 | cachable, write through |
| 4 | cachable, copy back |
| +8 | additionally write protected |
Things to consider when implementing the interface:
- The first entry of the memory list must describe the main area of the
freezer, i.e. his code and data. WHDLoad uses this area to check the freezer
against the BaseMem area, to include it in a core dump
and to allow this memory as argument for resload
functions and as stack while the freezer is running.
- The memory list must contain all memory and hardware registers which are
accessed by the freezer, otherwise WHDLoad will create an access fault on such
an access as soon as the MMU is used. The areas which are
setup by WHDLoad anyway ($0...BaseMem, Custom registers $dff000...$dff200, CIA
registers $bfd000...$bff000, Slave, WHDLoad and Resload) need not to be listed.
- The MMU handles memory in pages of 4096 bytes, therefore the start and end
addresses should be aligned to this size. Non aligned addresses are rounded to
cover the given area completely.
- The memory list is only evaluated if WHDLoad uses the MMU, but it should be
provided always because the user may enable the MMU at any time.
- The freezer must be able to handle the environment created by WHDLoad, that
means especially it must not access memory which is not declared in the memory
list and which is not part of BaseMem/ExpMem, because the resulting Access
Fault Exception cannot be handled by the freezer.
- The freezer is entered by WHDLoad with a NMI (vector $7c) stackframe on the
supervisor stack and must return with a RTE instruction.
- The signature is checked as last one, after all other supported freezers.
So if the freezer contains a HRTmon or ThrillKill which is detected by his own
signature, this detection wins and the generic interface is not used.
- To verify the implementation start WHDLoad with the option Trace/S and check the created log file .whdl_trace.
It contains a line "freezer found type=8 start=... end=... nmi=... mem=..."
followed by one line for each entry of the memory list.