From 366d27796ca1d09d6b6a6ad69a89cb7644d92930 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 Oct 2023 09:38:00 +0100 Subject: mac_via: work around underflow in TimeDBRA timing loop in SETUPTIMEK The MacOS toolbox ROM calculates the number of branches that can be executed per millisecond as part of its timer calibration. Since modern hosts are considerably quicker than original hardware, the negative counter reaches zero before the calibration completes leading to division by zero later in CALCULATESLOD. Instead of trying to fudge the timing loop (which won't work for TimeDBRA/TimeSCCDB anyhow), use the pattern of access to the VIA1 registers to detect when SETUPTIMEK has finished executing and write some well-known good timer values to TimeDBRA and TimeSCCDB taken from real hardware with a suitable scaling factor. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-ID: <20231004083806.757242-15-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index 422da43..63cdcf7 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -74,6 +74,9 @@ struct MOS6522Q800VIA1State { int64_t next_second; QEMUTimer *sixty_hz_timer; int64_t next_sixty_hz; + + /* SETUPTIMEK hack */ + int timer_hack_state; }; -- cgit v1.1