From c37cbc030d96631b3c795a1b4fdae7daece2499c Mon Sep 17 00:00:00 2001 From: Min Xu Date: Tue, 26 Oct 2021 13:37:11 +0800 Subject: OvmfPkg: Switch timer in build time for OvmfPkg BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3711 Discussion in https://bugzilla.tianocore.org/show_bug.cgi?id=1496 shows that 8254TimerDxe was not written for OVMF. It was moved over from PcAtChipsetPkg to OvmfPkg in 2019. Probably because OVMF was the only user left. Most likely the reason OVMF used 8254TimerDxe initially was that it could just use the existing driver in PcAtChipsetPkg. And it simply hasn't been changed ever. CSM support was moved in 2019 too. (CSM support depends on 8254/8259 drivers). So 8254TimerDxe will be used when CSM_ENABLE=TRUE. There are 4 .dsc which include the 8254Timer. - OvmfPkg/AmdSev/AmdSevX64.dsc - OvmfPkg/OvmfPkgIa32.dsc - OvmfPkg/OvmfPkgIa32X64.dsc - OvmfPkg/OvmfPkgX64.dsc For the three OvmfPkg* configs using 8254TimerDxe with CSM_ENABLE=TRUE and LapicTimerDxe otherwise. For the AmdSev config it doesn't make sense to support a CSM. So use the lapic timer unconditionally. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Suggested-by: Gerd Hoffmann Acked-by: Gerd Hoffmann Reviewed-by: Jiewen Yao Signed-off-by: Min Xu --- OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c | 2 +- OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'OvmfPkg/LocalApicTimerDxe') diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c index dd9352b..cbc17c9 100644 --- a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c +++ b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c @@ -174,7 +174,7 @@ TimerDriverSetTimerPeriod ( // DisableApicTimerInterrupt (); } else { - TimerFrequency = PcdGet32 (PcdFSBClock) / DivideValue; + TimerFrequency = PcdGet32 (PcdFSBClock) / (UINT32)DivideValue; // // Convert TimerPeriod into local APIC counts diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf index 63b75b7..3ad28a1 100644 --- a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +++ b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf @@ -1,5 +1,6 @@ ## @file # Local APIC timer driver that provides Timer Arch protocol. +# PcdFSBClock is defined in MdePkg and it should be set by the consumer. # # Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.
# Copyright (c) 2019, Citrix Systems, Inc. -- cgit v1.1