]> git.proxmox.com Git - mirror_edk2.git/blobdiff - QuarkPlatformPkg/Library/PlatformHelperLib/PlatformHelperDxe.c
edk2: Remove packages moved to edk2-platforms
[mirror_edk2.git] / QuarkPlatformPkg / Library / PlatformHelperLib / PlatformHelperDxe.c
diff --git a/QuarkPlatformPkg/Library/PlatformHelperLib/PlatformHelperDxe.c b/QuarkPlatformPkg/Library/PlatformHelperLib/PlatformHelperDxe.c
deleted file mode 100644 (file)
index a0acf88..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/** @file\r
-Implementation of helper routines for DXE environment.\r
-\r
-Copyright (c) 2013 - 2016 Intel Corporation.\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/S3BootScriptLib.h>\r
-#include <Library/DxeServicesLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Protocol/SmmBase2.h>\r
-#include <Protocol/Spi.h>\r
-#include <Protocol/VariableLock.h>\r
-\r
-#include <Guid/MemoryConfigData.h>\r
-#include <Guid/QuarkVariableLock.h>\r
-\r
-#include "CommonHeader.h"\r
-\r
-#define FLASH_BLOCK_SIZE            SIZE_4KB\r
-\r
-//\r
-// Global variables.\r
-//\r
-EFI_SPI_PROTOCOL                    *mPlatHelpSpiProtocolRef = NULL;\r
-\r
-//\r
-// Routines defined in other source modules of this component.\r
-//\r
-\r
-//\r
-// Routines local to this component.\r
-//\r
-\r
-//\r
-// Routines shared with other souce modules in this component.\r
-//\r
-\r
-EFI_SPI_PROTOCOL *\r
-LocateSpiProtocol (\r
-  IN  EFI_SMM_SYSTEM_TABLE2             *Smst\r
-  )\r
-{\r
-  if (mPlatHelpSpiProtocolRef == NULL) {\r
-    if (Smst != NULL) {\r
-      Smst->SmmLocateProtocol (\r
-              &gEfiSmmSpiProtocolGuid,\r
-              NULL,\r
-              (VOID **) &mPlatHelpSpiProtocolRef\r
-              );\r
-    } else {\r
-      gBS->LocateProtocol (\r
-             &gEfiSpiProtocolGuid,\r
-             NULL,\r
-             (VOID **) &mPlatHelpSpiProtocolRef\r
-             );\r
-    }\r
-    ASSERT (mPlatHelpSpiProtocolRef != NULL);\r
-  }\r
-  return mPlatHelpSpiProtocolRef;\r
-}\r
-\r
-//\r
-// Routines exported by this source module.\r
-//\r
-\r
-/**\r
-  Find pointer to RAW data in Firmware volume file.\r
-\r
-  @param   FvNameGuid       Firmware volume to search. If == NULL search all.\r
-  @param   FileNameGuid     Firmware volume file to search for.\r
-  @param   SectionData      Pointer to RAW data section of found file.\r
-  @param   SectionDataSize  Pointer to UNITN to get size of RAW data.\r
-\r
-  @retval  EFI_SUCCESS            Raw Data found.\r
-  @retval  EFI_INVALID_PARAMETER  FileNameGuid == NULL.\r
-  @retval  EFI_NOT_FOUND          Firmware volume file not found.\r
-  @retval  EFI_UNSUPPORTED        Unsupported in current enviroment (PEI or DXE).\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PlatformFindFvFileRawDataSection (\r
-  IN CONST EFI_GUID                 *FvNameGuid OPTIONAL,\r
-  IN CONST EFI_GUID                 *FileNameGuid,\r
-  OUT VOID                          **SectionData,\r
-  OUT UINTN                         *SectionDataSize\r
-  )\r
-{\r
-  if (FileNameGuid == NULL || SectionData == NULL || SectionDataSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  if (FvNameGuid != NULL) {\r
-    return EFI_UNSUPPORTED;  // Searching in specific FV unsupported in DXE.\r
-  }\r
-\r
-  return GetSectionFromAnyFv (FileNameGuid, EFI_SECTION_RAW, 0, SectionData, SectionDataSize);\r
-}\r
-\r
-/**\r
-  Find free spi protect register and write to it to protect a flash region.\r
-\r
-  @param   DirectValue      Value to directly write to register.\r
-                            if DirectValue == 0 the use Base & Length below.\r
-  @param   BaseAddress      Base address of region in Flash Memory Map.\r
-  @param   Length           Length of region to protect.\r
-\r
-  @retval  EFI_SUCCESS      Free spi protect register found & written.\r
-  @retval  EFI_NOT_FOUND    Free Spi protect register not found.\r
-  @retval  EFI_DEVICE_ERROR Unable to write to spi protect register.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PlatformWriteFirstFreeSpiProtect (\r
-  IN CONST UINT32                         DirectValue,\r
-  IN CONST UINT32                         BaseAddress,\r
-  IN CONST UINT32                         Length\r
-  )\r
-{\r
-  UINT32                            FreeOffset;\r
-  UINT32                            PchRootComplexBar;\r
-  EFI_STATUS                        Status;\r
-\r
-  PchRootComplexBar = QNC_RCRB_BASE;\r
-\r
-  Status = WriteFirstFreeSpiProtect (\r
-             PchRootComplexBar,\r
-             DirectValue,\r
-             BaseAddress,\r
-             Length,\r
-             &FreeOffset\r
-             );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    S3BootScriptSaveMemWrite (\r
-      S3BootScriptWidthUint32,\r
-        (UINTN) (PchRootComplexBar + FreeOffset),\r
-        1,\r
-        (VOID *) (UINTN) (PchRootComplexBar + FreeOffset)\r
-        );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Lock legacy SPI static configuration information.\r
-\r
-  Function will assert if unable to lock config.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformFlashLockConfig (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  EFI_SPI_PROTOCOL  *SpiProtocol;\r
-\r
-  //\r
-  // Enable lock of legacy SPI static configuration information.\r
-  //\r
-\r
-  SpiProtocol = LocateSpiProtocol (NULL);  // This routine will not be called in SMM.\r
-  ASSERT (SpiProtocol != NULL);\r
-  if (SpiProtocol != NULL) {\r
-    Status = SpiProtocol->Lock (SpiProtocol);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_INFO, "Platform: Spi Config Locked Down\n"));\r
-    } else if (Status == EFI_ACCESS_DENIED) {\r
-      DEBUG ((EFI_D_INFO, "Platform: Spi Config already locked down\n"));\r
-    } else {\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Platform Variable Lock.\r
-\r
-  @retval EFI_SUCCESS           Platform Variable Lock successful.\r
-  @retval EFI_NOT_FOUND         No protocol instances were found that match Protocol and\r
-                                Registration.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformVariableLock (\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EDKII_VARIABLE_LOCK_PROTOCOL      *VariableLockProtocol;\r
-\r
-  Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = VariableLockProtocol->RequestToLock (\r
-                                   VariableLockProtocol,\r
-                                   QUARK_VARIABLE_LOCK_NAME,\r
-                                   &gQuarkVariableLockGuid\r
-                                   );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  // Memory Config Data shouldn't be writable when Quark Variable Lock is enabled.\r
-  Status = VariableLockProtocol->RequestToLock (\r
-                                   VariableLockProtocol,\r
-                                   EFI_MEMORY_CONFIG_DATA_NAME,\r
-                                   &gEfiMemoryConfigDataGuid\r
-                                   );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-/**\r
-  Lock regions and config of SPI flash given the policy for this platform.\r
-\r
-  Function will assert if unable to lock regions or config.\r
-\r
-  @param   PreBootPolicy    If TRUE do Pre Boot Flash Lock Policy.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformFlashLockPolicy (\r
-  IN CONST BOOLEAN                        PreBootPolicy\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT64                            CpuAddressNvStorage;\r
-  UINT64                            CpuAddressFlashDevice;\r
-  UINT64                            SpiAddress;\r
-  EFI_BOOT_MODE                     BootMode;\r
-  UINTN                             SpiFlashDeviceSize;\r
-\r
-  BootMode = GetBootModeHob ();\r
-\r
-  SpiFlashDeviceSize = (UINTN) PcdGet32 (PcdSpiFlashDeviceSize);\r
-  CpuAddressFlashDevice = SIZE_4GB - SpiFlashDeviceSize;\r
-  DEBUG (\r
-      (EFI_D_INFO,\r
-      "Platform:FlashDeviceSize = 0x%08x Bytes\n",\r
-      SpiFlashDeviceSize)\r
-      );\r
-\r
-  //\r
-  // If not in update or recovery mode, lock stuff down\r
-  //\r
-  if ((BootMode != BOOT_IN_RECOVERY_MODE) && (BootMode != BOOT_ON_FLASH_UPDATE)) {\r
-\r
-    //\r
-    // Lock regions\r
-    //\r
-    CpuAddressNvStorage = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);\r
-\r
-    //\r
-    // Lock from start of flash device up to Smi writable flash storage areas.\r
-    //\r
-    SpiAddress = 0;\r
-    if (!PlatformIsSpiRangeProtected ((UINT32) SpiAddress, (UINT32) (CpuAddressNvStorage - CpuAddressFlashDevice))) {\r
-      DEBUG (\r
-        (EFI_D_INFO,\r
-        "Platform: Protect Region Base:Len 0x%08x:0x%08x\n",\r
-        (UINTN) SpiAddress, (UINTN)(CpuAddressNvStorage - CpuAddressFlashDevice))\r
-        );\r
-      Status = PlatformWriteFirstFreeSpiProtect (\r
-                  0,\r
-                  (UINT32) SpiAddress,\r
-                  (UINT32) (CpuAddressNvStorage - CpuAddressFlashDevice)\r
-                  );\r
-\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-    //\r
-    // Move Spi Address to after Smi writable flash storage areas.\r
-    //\r
-    SpiAddress = CpuAddressNvStorage - CpuAddressFlashDevice;\r
-    SpiAddress += ((UINT64) PcdGet32 (PcdFlashNvStorageVariableSize));\r
-\r
-    //\r
-    // Lock from end of OEM area to end of flash part.\r
-    //\r
-    if (!PlatformIsSpiRangeProtected ((UINT32) SpiAddress, SpiFlashDeviceSize - ((UINT32) SpiAddress))) {\r
-      DEBUG (\r
-        (EFI_D_INFO,\r
-        "Platform: Protect Region Base:Len 0x%08x:0x%08x\n",\r
-        (UINTN) SpiAddress,\r
-        (UINTN) (SpiFlashDeviceSize - ((UINT32) SpiAddress)))\r
-        );\r
-      ASSERT (SpiAddress < ((UINT64) SpiFlashDeviceSize));\r
-      Status = PlatformWriteFirstFreeSpiProtect (\r
-                  0,\r
-                  (UINT32) SpiAddress,\r
-                  SpiFlashDeviceSize - ((UINT32) SpiAddress)\r
-                  );\r
-\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Always Lock flash config registers if about to boot a boot option\r
-  // else lock depending on boot mode.\r
-  //\r
-  if (PreBootPolicy || (BootMode != BOOT_ON_FLASH_UPDATE)) {\r
-    PlatformFlashLockConfig ();\r
-  }\r
-\r
-  //\r
-  // Enable Quark Variable lock if PreBootPolicy.\r
-  //\r
-  if (PreBootPolicy) {\r
-    PlatformVariableLock ();\r
-  }\r
-}\r
-\r
-/** Check if System booted with recovery Boot Stage1 image.\r
-\r
-  @retval  TRUE    If system booted with recovery Boot Stage1 image.\r
-  @retval  FALSE   If system booted with normal stage1 image.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-PlatformIsBootWithRecoveryStage1 (\r
-  VOID\r
-  )\r
-{\r
-  ASSERT_EFI_ERROR (EFI_UNSUPPORTED);\r
-  return FALSE;\r
-}\r
-\r