Snooping
What it is
Snooping is a feature of WHDLoad which performs validating and logging of CPU
accesses to the Custom registers. If Snoop is
activated all invalid accesses to the Custom registers will create a Access
Fault and the installed program will be terminated. Invalid accesses are:
- accesses to nonexistent registers
- read accesses to Write Only registers
- write accesses to Read Only registers
- accesses to Early Read registers
- byte write accesses (except bltcon0l)
Strobe registers can be read or written. The set of valid Custom registers can
vary between OCS (Old ChipSet - A500, A1000, old A2000), ECS (Enhanced ChipSet -
A600, new A2000, A3000) and AGA (Advanced Graphics - A1200, A4000). This is
useful especially to locate bugs in old programs caused by undefined accesses to
new AGA registers.
How it works
If Snoop is enabled WHDLoad does mark the addresses of the Custom registers as
invalid in the MMU translation tree. Because this each access to a Custom
register will result in a Access Fault exception. The exception handler in
WHDLoad does handle this exception. First it checks if the access is valid. If
the access is invalid the program will be terminated. If the access is valid and
it is a read operation the access will be emulated and program execution
continues. If it is a write operation WHDload saves the value which should be
written before emulation.
Because the overhead of the exception and the emulation sequence the program
execution will slow down. How much it slows down depends on the CPU type, Chip
Memory type (16/32 Bit) and Stackpointer alignment if Chip Memory is 32 Bit
(LongWord aligned or not). It also differs for the access type
(Byte/Word/LongWord, Read/Write). On the 68030 Writes are faster than Reads
(because on Reads the Stackframe is 92 Bytes on Writes 32 Byte), on the 68060
Reads are faster because the emulation for Writes is more complex.
Blitter check
On the 68030 there are special checks concerning the blitter implemented. On
each access to a blitter register WHDLoad checks the Blitter Busy Flag in the
dmacon register. If the blitter is busy WHDLoad will terminate the
program and show an appropriate requester. This has been implemented to detect
bad code which does not correctly wait that the blitter job has finished. But
practically due the large delay caused by the exception processing this check
will detect missing waits only in conjunction with very big blitter operations.
If the accessed custom register is bltsize or bltsizh and the
line mode is not enabled in the saved bltcon1 WHDLoad will check if the
activated blitter operation will access any memory outside BaseMem. WHDLoad will
calculate the first and the last word access for each activated dma channel. If
one address is outside the BaseMem area the program will be terminated with an
requester. The calculation is designed to work with all modes
(ascending/descending, positive/negativ modulos).
Remember that the line drawing mode will not verified and that all blitter
registers can also be written by the copper if copcon is 1.
Future
It is planned to implement features like Freezing, Iconifing and a Picture
Ripper. For these Snoop is a essential assumption. Therefore it is recommend for
install authors to check her installs with Snoop to secure future compatibility.
Requirements
A MMU is required for the Snoop feature. Also WHDLoad must use the MMU, therefore MMU/S must be enabled on 68030 machines.
Limitations
- 68020 + 68851
- this hardware is currently not supported
- 68030
- 68040
- this hardware is currently not supported
- 68060
- movem instruction may access a invalid registers without creating a Access
Fault exception, this is possible because only the first access will be verified
for matching a valid register
- "move <Custom register>,sr" will be executed wrong if it likes to
change the supervisor portion of the status register, wrong in the way that the
supervisor portion will remain unchanged
- any "(a7)+" and "-(a7)" when it
accesses the Custom registers and is a write operation will be executed wrong,
wrong because a7 will be incremented/decremented two times instead one time, if
this occurs very probably the whole program will crash, for this problem
is no simple fix possible
Bugs
- read accesses to the color registers will always cause a Access Fault, write
accesses never (on AGA machines the color registers can be read if RDRAM is set
in custom.bplcon2)