]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Add ASSERT to handle local APIC not config properly
authorHao Wu <hao.a.wu@intel.com>
Fri, 9 Oct 2015 07:04:00 +0000 (07:04 +0000)
committerhwu1225 <hwu1225@Edk2>
Fri, 9 Oct 2015 07:04:00 +0000 (07:04 +0000)
When the local APIC is not configurated properly, function
GetApicTimerInitCount() in LocalApicLib may return zero, which will lead
to a divide by zero exception in SecPeiDxeTimerLibUefiCpu.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18594 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c

index 52ae7717ddf5aff8b98a2b3011137a2a3937320e..f703d7e4776838a3cacc1e5e149c65f44dd47249 100644 (file)
@@ -3,7 +3,7 @@
 \r
   This library uses the local APIC library so that it supports x2APIC mode.\r
   \r
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -45,6 +45,9 @@ InternalX86GetTimerFrequency (
   Stalls the CPU for at least the given number of ticks. It's invoked by\r
   MicroSecondDelay() and NanoSecondDelay().\r
 \r
+  This function will ASSERT if the APIC timer intial count returned from\r
+  GetApicTimerInitCount() is zero.\r
+\r
   @param  Delay     A period of time to delay in ticks.\r
 \r
 **/\r
@@ -67,6 +70,7 @@ InternalX86Delay (
   // Delay and the Init Count.\r
   //\r
   InitCount = GetApicTimerInitCount ();\r
+  ASSERT (InitCount != 0);\r
   Times     = Delay / (InitCount / 2);\r
   Delay     = Delay % (InitCount / 2);\r
 \r