]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1, Remove DxeReportStatus driver, because DxeIpl has published a instance from hob...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 7 Jan 2009 09:36:44 +0000 (09:36 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 7 Jan 2009 09:36:44 +0000 (09:36 +0000)
2, Use gBS->Stall() for MicroSecondDelay() implementation in DuetTimerLib.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7202 6f19259b-4bc3-4df7-8a09-765794883524

DuetPkg/DuetPkg.dsc
DuetPkg/LegacyMetronome/Metronome.inf
DuetPkg/Library/DuetDxeReportStatusCodeLib/DuetDxeReportStatusCodeLib.inf
DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf
DuetPkg/Library/DuetTimerLib/X86TimerLib.c

index bfcc6649f6540815d62beac46b03a6b81e3da89e..a276746f4c5b5eb6180399a502b24ce7ae29ffea 100644 (file)
@@ -17,7 +17,7 @@
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
+  ReportStatusCodeLib|DuetPkg/Library/DuetDxeReportStatusCodeLib/DuetDxeReportStatusCodeLib.inf\r
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
   UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
   UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
@@ -29,7 +29,6 @@
   UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
   UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
   UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
-  BaseUefiTianoDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
   ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
   PlatformBdsLib|DuetPkg/Library/DuetBdsLib/PlatformBds.inf\r
   IfrSupportLib|MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
   TimerLib|DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf\r
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   \r
 [LibraryClasses.common.DXE_DRIVER]\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
   SerialPortLib|DuetPkg/Library/DuetSerialIoLib/DuetSerialIoLib.inf\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
   DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
 \r
 [LibraryClasses.common.DXE_CORE]\r
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
@@ -76,7 +74,6 @@
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
   SerialPortLib|DuetPkg/Library/DuetSerialIoLib/DuetSerialIoLib.inf\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
   DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   SerialPortLib|DuetPkg/Library/DuetSerialIoLib/DuetSerialIoLib.inf\r
   DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
 \r
 [LibraryClasses.common.UEFI_APPLICATION]\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   SerialPortLib|DuetPkg/Library/DuetSerialIoLib/DuetSerialIoLib.inf\r
   DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-  ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
 \r
 [PcdsFixedAtBuild]\r
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07\r
index d97b67f334069defc208d91f2d71575b0722c699..9f061d27b9cc4ae8105b9dc70caa54108df07a25 100644 (file)
@@ -35,7 +35,8 @@
   UefiDriverEntryPoint\r
   DebugLib\r
   UefiBootServicesTableLib\r
-\r
+  IoLib\r
+  \r
 [Sources.common]\r
   Metronome.c\r
   Metronome.h\r
index ed432ea67ff569883480870deaf816a56cb9c52e..11dcbcb69feea6a378bc90d58da2294092a78d19 100644 (file)
@@ -36,7 +36,6 @@
   DxeSupport.c\r
   ReportStatusCodeLibInternal.h\r
 \r
-\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
index 9a3af0afb6088861dd2471946f83bd9b12e92301..6d841645b0a8c24908cf969ba10eb6b81c71a268 100644 (file)
@@ -22,7 +22,7 @@
   INF_VERSION                    = 0x00010005\r
   BASE_NAME                      = DuetTimerLib\r
   FILE_GUID                      = 5F9A01F5-726E-4f59-809D-887F4766734E\r
-  MODULE_TYPE                    = BASE\r
+  MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = TimerLib\r
   EDK_RELEASE_VERSION            = 0x00020000\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
-\r
 [LibraryClasses]\r
   BaseLib\r
-\r
-[LibraryClasses.IA32]\r
-  PcdLib\r
-  IoLib\r
-\r
-[LibraryClasses.X64]\r
-  PcdLib\r
-  IoLib\r
-\r
-[LibraryClasses.IPF]\r
   DebugLib\r
-  PalLib\r
-\r
-\r
-[Pcd.IA32]\r
-  gEfiMdePkgTokenSpaceGuid.PcdFSBClock\r
-\r
-[Pcd.X64]\r
-  gEfiMdePkgTokenSpaceGuid.PcdFSBClock\r
+  UefiBootServicesTableLib\r
 \r
+[Protocols]\r
+  gEfiMetronomeArchProtocolGuid         # ALWAYS_CONSUMED\r
index 9c8d46fe7005002faf7d689068c4c55e1624ad66..13df34fc34d4afa29eb1fd317f62f3857fca6fa8 100644 (file)
 #include <Base.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/IoLib.h>\r
 #include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
-\r
-//\r
-// The following array is used in calculating the frequency of local APIC\r
-// timer. Refer to IA-32 developers' manual for more details.\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED\r
-CONST UINT8                           mTimerLibLocalApicDivisor[] = {\r
-  0x02, 0x04, 0x08, 0x10,\r
-  0x02, 0x04, 0x08, 0x10,\r
-  0x20, 0x40, 0x80, 0x01,\r
-  0x20, 0x40, 0x80, 0x01\r
-};\r
-\r
-/**\r
-  Internal function to retrieve the base address of local APIC.\r
-\r
-  Internal function to retrieve the base address of local APIC.\r
-\r
-  @return The base address of local APIC\r
-\r
-**/\r
-UINTN\r
-InternalX86GetApicBase (\r
-  VOID\r
-  )\r
-{\r
-  return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12;\r
-}\r
-\r
-/**\r
-  Internal function to return the frequency of the local APIC timer.\r
-\r
-  Internal function to return the frequency of the local APIC timer.\r
-\r
-  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
-\r
-  @return The frequency of the timer in Hz.\r
-\r
-**/\r
-UINT32\r
-InternalX86GetTimerFrequency (\r
-  IN      UINTN                     ApicBase\r
-  )\r
-{\r
-  return\r
-    PcdGet32(PcdFSBClock) /\r
-    mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)];\r
-}\r
+#include <Protocol/Metronome.h>\r
 \r
 /**\r
-  Internal function to read the current tick counter of local APIC.\r
-\r
-  Internal function to read the current tick counter of local APIC.\r
-\r
-  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
+EFI_METRONOME_ARCH_PROTOCOL *gDuetMetronome = NULL;\r
 \r
-  @return The tick counter read.\r
-\r
-**/\r
-INT32\r
-InternalX86GetTimerTick (\r
-  IN      UINTN                     ApicBase\r
-  )\r
+EFI_METRONOME_ARCH_PROTOCOL*\r
+GetMetronomeArchProtocol (\r
+    VOID\r
+    )\r
 {\r
-  return MmioRead32 (ApicBase + 0x390);\r
-}\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of ticks.\r
-\r
-  Stalls the CPU for at least the given number of ticks. It's invoked by\r
-  MicroSecondDelay() and NanoSecondDelay().\r
-\r
-  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
-  @param  Delay     A period of time to delay in ticks.\r
-\r
+  if (gDuetMetronome == NULL) {\r
+     gBS->LocateProtocol (&gEfiMetronomeArchProtocolGuid, NULL, (VOID**) &gDuetMetronome);\r
+  }\r
+  \r
+  return gDuetMetronome;\r
+}    \r
 **/\r
-VOID\r
-InternalX86Delay (\r
-  IN      UINTN                     ApicBase,\r
-  IN      UINT32                    Delay\r
-  )\r
-{\r
-  INT32                             Ticks;\r
-\r
-  //\r
-  // The target timer count is calculated here\r
-  //\r
-  Ticks = InternalX86GetTimerTick (ApicBase) - Delay;\r
-\r
-  //\r
-  // Wait until time out\r
-  // Delay > 2^31 could not be handled by this function\r
-  // Timer wrap-arounds are handled correctly by this function\r
-  //\r
-  while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);\r
-}\r
 \r
 /**\r
   Stalls the CPU for at least the given number of microseconds.\r
@@ -133,19 +52,36 @@ MicroSecondDelay (
   IN      UINTN                     MicroSeconds\r
   )\r
 {\r
-  UINTN                             ApicBase;\r
-\r
-  ApicBase = InternalX86GetApicBase ();\r
-  InternalX86Delay (\r
-    ApicBase,\r
-    (UINT32)DivU64x32 (\r
-              MultU64x64 (\r
-                InternalX86GetTimerFrequency (ApicBase),\r
-                MicroSeconds\r
-                ),\r
-              1000000u\r
-              )\r
-    );\r
+  gBS->Stall (MicroSeconds);\r
+/**\r
+  EFI_METRONOME_ARCH_PROTOCOL       *mMetronome;\r
+  UINT32                            Counter;\r
+  UINTN                             Remainder;  \r
+  \r
+  if ((mMetronome = GetMetronomeArchProtocol()) == NULL) {\r
+    return MicroSeconds;\r
+  }\r
+  \r
+  //\r
+  // Calculate the number of ticks by dividing the number of microseconds by\r
+  // the TickPeriod.\r
+  // Calculation is based on 100ns unit.\r
+  //\r
+  Counter = (UINT32) DivU64x32Remainder (\r
+                       MicroSeconds * 10,\r
+                       mMetronome->TickPeriod,\r
+                       &Remainder\r
+                       );\r
+  //\r
+  // Call WaitForTick for Counter + 1 ticks to try to guarantee Counter tick\r
+  // periods, thus attempting to ensure Microseconds of stall time.\r
+  //\r
+  if (Remainder != 0) {\r
+    Counter++;\r
+  }\r
+\r
+  mMetronome->WaitForTick (mMetronome, Counter);\r
+**/\r
   return MicroSeconds;\r
 }\r
 \r
@@ -165,20 +101,11 @@ NanoSecondDelay (
   IN      UINTN                     NanoSeconds\r
   )\r
 {\r
-  UINTN                             ApicBase;\r
-\r
-  ApicBase = InternalX86GetApicBase ();\r
-  InternalX86Delay (\r
-    ApicBase,\r
-    (UINT32)DivU64x32 (\r
-              MultU64x64 (\r
-                InternalX86GetTimerFrequency (ApicBase),\r
-                NanoSeconds\r
-                ),\r
-              1000000000u\r
-              )\r
-    );\r
-  return NanoSeconds;\r
+  //\r
+  // Duet platform need *not* this interface.\r
+  //\r
+  //ASSERT (FALSE);\r
+  return 0;\r
 }\r
 \r
 /**\r
@@ -199,7 +126,11 @@ GetPerformanceCounter (
   VOID\r
   )\r
 {\r
-  return (UINT64)(UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ());\r
+  //\r
+  // Duet platform need *not* this interface.\r
+  //\r
+  //ASSERT (FALSE);\r
+  return 0;\r
 }\r
 \r
 /**\r
@@ -232,17 +163,9 @@ GetPerformanceCounterProperties (
   OUT      UINT64                    *EndValue     OPTIONAL\r
   )\r
 {\r
-  UINTN                             ApicBase;\r
-\r
-  ApicBase = InternalX86GetApicBase ();\r
-\r
-  if (StartValue != NULL) {\r
-    *StartValue = MmioRead32 (ApicBase + 0x380);\r
-  }\r
-\r
-  if (EndValue != NULL) {\r
-    *EndValue = 0;\r
-  }\r
-\r
-  return (UINT64) InternalX86GetTimerFrequency (ApicBase);;\r
+  //\r
+  // Duet platform need *not* this interface.\r
+  //\r
+  //ASSERT (FALSE);\r
+  return 0;\r
 }\r