]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c
CorebootModulePkg: Remove PciSioSerialDxe and SerialDxe driver
[mirror_edk2.git] / PcAtChipsetPkg / HpetTimerDxe / HpetTimer.c
index 4f165bdc521dd8f52b0e1068a2a675b9e3f419e5..e23a2c83e4f6e4ab7f70434130e50eb7e3b4126b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Timer Architectural Protocol module using High Precesion Event Timer (HPET)\r
 \r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2014, 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
@@ -492,9 +492,10 @@ TimerDriverSetTimerPeriod (
   IN UINT64                   TimerPeriod\r
   )\r
 {\r
-  UINT64  MainCounter;\r
-  UINT64  Delta;\r
-  UINT64  CurrentComparator;\r
+  UINT64                         MainCounter;\r
+  UINT64                         Delta;\r
+  UINT64                         CurrentComparator;\r
+  HPET_TIMER_MSI_ROUTE_REGISTER  HpetTimerMsiRoute;\r
   \r
   //\r
   // Disable HPET timer when adjusting the timer period\r
@@ -576,6 +577,13 @@ TimerDriverSetTimerPeriod (
     // Enable HPET Timer interrupt generation\r
     //\r
     if (mTimerConfiguration.Bits.MsiInterruptCapablity != 0 && FeaturePcdGet (PcdHpetMsiEnable)) {\r
+      //\r
+      // Program MSI Address and MSI Data values in the selected HPET Timer\r
+      // Program HPET register with APIC ID of current BSP in case BSP has been switched\r
+      //\r
+      HpetTimerMsiRoute.Bits.Address = GetApicMsiAddress ();\r
+      HpetTimerMsiRoute.Bits.Value   = (UINT32)GetApicMsiValue (PcdGet8 (PcdHpetLocalApicVector), LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY, FALSE, FALSE);\r
+      HpetWrite (HPET_TIMER_MSI_ROUTE_OFFSET + mTimerIndex * HPET_TIMER_STRIDE, HpetTimerMsiRoute.Uint64);\r
       //\r
       // Enable HPET MSI Interrupt\r
       //\r
@@ -583,7 +591,9 @@ TimerDriverSetTimerPeriod (
     } else {\r
       //\r
       // Enable timer interrupt through I/O APIC\r
+      // Program IOAPIC register with APIC ID of current BSP in case BSP has been switched\r
       //\r
+      IoApicConfigureInterrupt (mTimerIrq, PcdGet8 (PcdHpetLocalApicVector), IO_APIC_DELIVERY_MODE_LOWEST_PRIORITY, TRUE, FALSE);\r
       IoApicEnableInterrupt (mTimerIrq, TRUE);\r
     }\r
 \r