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