+++ /dev/null
-/*++\r
-\r
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
-\r
-Module Name:\r
-\r
- SmmIo.c\r
-\r
-Abstract:\r
-\r
- SMM I/O access utility implementation file, for Ia32\r
-\r
---*/\r
-\r
-//\r
-// Include files\r
-//\r
-#include "Library/StallSmmLib.h"\r
-#include "Pi/PiSmmCis.h"\r
-#include "PiDxe.h"\r
-#include <Library/IoLib.h>\r
-#include <Library/PcdLib.h>\r
-#include "PchAccess.h"\r
-\r
-/**\r
- Delay for at least the request number of microseconds.\r
- Timer used is ACPI time counter, which has 1us granularity.\r
-\r
- @param Microseconds Number of microseconds to delay.\r
-\r
- @retval None\r
-\r
-**/\r
-VOID\r
-SmmStall (\r
- IN UINTN Microseconds\r
- )\r
-{\r
- UINTN Ticks;\r
- UINTN Counts;\r
- UINTN CurrentTick;\r
- UINTN OriginalTick;\r
- UINTN RemainingTick;\r
- UINT16 AcpiBaseAddr;\r
-\r
- if (Microseconds == 0) {\r
- return;\r
- }\r
-\r
- AcpiBaseAddr = PchLpcPciCfg16 (R_PCH_LPC_ACPI_BASE) & B_PCH_LPC_ACPI_BASE_BAR;\r
-\r
- OriginalTick = IoRead32 (AcpiBaseAddr + R_PCH_ACPI_PM1_TMR);\r
- CurrentTick = OriginalTick;\r
-\r
- //\r
- // The timer frequency is 3.579545 MHz, so 1 ms corresponds 3.58 clocks\r
- //\r
- Ticks = Microseconds * 358 / 100 + OriginalTick + 1;\r
-\r
- //\r
- // The loops needed by timer overflow\r
- //\r
- Counts = Ticks / V_PCH_ACPI_PM1_TMR_MAX_VAL;\r
-\r
- //\r
- // Remaining clocks within one loop\r
- //\r
- RemainingTick = Ticks % V_PCH_ACPI_PM1_TMR_MAX_VAL;\r
-\r
- //\r
- // not intend to use TMROF_STS bit of register PM1_STS, because this adds extra\r
- // one I/O operation, and maybe generate SMI\r
- //\r
- while ((Counts != 0) || (RemainingTick > CurrentTick)) {\r
- CurrentTick = IoRead32 (AcpiBaseAddr + R_PCH_ACPI_PM1_TMR);\r
- //\r
- // Check if timer overflow\r
- //\r
- if (CurrentTick < OriginalTick) {\r
- Counts--;\r
- }\r
- OriginalTick = CurrentTick;\r
- }\r
-}\r