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
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
[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
#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
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
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
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
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