Generated mechanically with:
find OvmfPkg -type f -exec sed -i -e 's/EFI_D_/DEBUG_/g' {} \;
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Cc: Philippe Mathieu-Daude <philmd@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200429215327.606467-1-rebecca@bsdio.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
		
	
		
			
				
	
	
		
			84 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/** @file
 | 
						|
  Provide constructor and GetTick for Dxe instance of ACPI Timer Library
 | 
						|
 | 
						|
  Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
 | 
						|
 | 
						|
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
						|
**/
 | 
						|
 | 
						|
#include <Library/DebugLib.h>
 | 
						|
#include <Library/IoLib.h>
 | 
						|
#include <Library/PcdLib.h>
 | 
						|
#include <Library/PciLib.h>
 | 
						|
#include <OvmfPlatforms.h>
 | 
						|
 | 
						|
//
 | 
						|
// Cached ACPI Timer IO Address
 | 
						|
//
 | 
						|
STATIC UINT32 mAcpiTimerIoAddr;
 | 
						|
 | 
						|
/**
 | 
						|
  The constructor function caches the ACPI tick counter address
 | 
						|
 | 
						|
  At the time this constructor runs (DXE_CORE or later), ACPI IO space
 | 
						|
  has already been enabled by either PlatformPei or by the "Base"
 | 
						|
  instance of this library.
 | 
						|
  In order to avoid querying the underlying platform type during each
 | 
						|
  tick counter read operation, we cache the counter address during
 | 
						|
  initialization of this instance of the Timer Library.
 | 
						|
 | 
						|
  @retval EFI_SUCCESS   The constructor always returns RETURN_SUCCESS.
 | 
						|
 | 
						|
**/
 | 
						|
RETURN_STATUS
 | 
						|
EFIAPI
 | 
						|
AcpiTimerLibConstructor (
 | 
						|
  VOID
 | 
						|
  )
 | 
						|
{
 | 
						|
  UINT16 HostBridgeDevId;
 | 
						|
  UINTN Pmba;
 | 
						|
 | 
						|
  //
 | 
						|
  // Query Host Bridge DID to determine platform type
 | 
						|
  //
 | 
						|
  HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
 | 
						|
  switch (HostBridgeDevId) {
 | 
						|
    case INTEL_82441_DEVICE_ID:
 | 
						|
      Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
 | 
						|
      break;
 | 
						|
    case INTEL_Q35_MCH_DEVICE_ID:
 | 
						|
      Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE);
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
 | 
						|
        __FUNCTION__, HostBridgeDevId));
 | 
						|
      ASSERT (FALSE);
 | 
						|
      return RETURN_UNSUPPORTED;
 | 
						|
  }
 | 
						|
 | 
						|
  mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET;
 | 
						|
 | 
						|
  return RETURN_SUCCESS;
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
  Internal function to read the current tick counter of ACPI.
 | 
						|
 | 
						|
  Read the current ACPI tick counter using the counter address cached
 | 
						|
  by this instance's constructor.
 | 
						|
 | 
						|
  @return The tick counter read.
 | 
						|
 | 
						|
**/
 | 
						|
UINT32
 | 
						|
InternalAcpiGetTimerTick (
 | 
						|
  VOID
 | 
						|
  )
 | 
						|
{
 | 
						|
  //
 | 
						|
  //   Return the current ACPI timer value.
 | 
						|
  //
 | 
						|
  return IoRead32 (mAcpiTimerIoAddr);
 | 
						|
}
 |