]> git.proxmox.com Git - mirror_qemu.git/commit
mac_via: work around underflow in TimeDBRA timing loop in SETUPTIMEK
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Wed, 4 Oct 2023 08:38:00 +0000 (09:38 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 6 Oct 2023 08:33:43 +0000 (10:33 +0200)
commit366d27796ca1d09d6b6a6ad69a89cb7644d92930
tree46ea26b3950d1e1cd407e889a247f4cc63a71111
parent994af0b2e020a91729a39f8c4af4a522ccd3a556
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 <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20231004083806.757242-15-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
hw/misc/mac_via.c
hw/misc/trace-events
include/hw/misc/mac_via.h