Home | History | Annotate | Download | only in PlatformPei
      1 /** @file
      2   Build FV related hobs for platform.
      3 
      4   Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
      5   This program and the accompanying materials
      6   are licensed and made available under the terms and conditions of the BSD License
      7   which accompanies this distribution.  The full text of the license may be found at
      8   http://opensource.org/licenses/bsd-license.php
      9 
     10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 #include "PiPei.h"
     16 #include "Platform.h"
     17 #include <Library/DebugLib.h>
     18 #include <Library/HobLib.h>
     19 #include <Library/PeiServicesLib.h>
     20 #include <Library/PcdLib.h>
     21 
     22 
     23 /**
     24   Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
     25   and DXE know about them.
     26 
     27   @retval EFI_SUCCESS   Platform PEI FVs were initialized successfully.
     28 
     29 **/
     30 EFI_STATUS
     31 PeiFvInitialization (
     32   VOID
     33   )
     34 {
     35   BOOLEAN SecureS3Needed;
     36 
     37   DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
     38 
     39   //
     40   // Create a memory allocation HOB for the PEI FV.
     41   //
     42   // Allocate as ACPI NVS is S3 is supported
     43   //
     44   BuildMemoryAllocationHob (
     45     PcdGet32 (PcdOvmfPeiMemFvBase),
     46     PcdGet32 (PcdOvmfPeiMemFvSize),
     47     mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
     48     );
     49 
     50   //
     51   // Let DXE know about the DXE FV
     52   //
     53   BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
     54 
     55   SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
     56 
     57   //
     58   // Create a memory allocation HOB for the DXE FV.
     59   //
     60   // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
     61   // firmware volumes at S3 resume too, hence we need to keep away the OS from
     62   // DXEFV as well. Otherwise we only need to keep away DXE itself from the
     63   // DXEFV area.
     64   //
     65   BuildMemoryAllocationHob (
     66     PcdGet32 (PcdOvmfDxeMemFvBase),
     67     PcdGet32 (PcdOvmfDxeMemFvSize),
     68     SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
     69     );
     70 
     71   //
     72   // Additionally, said decompression will use temporary memory above the end
     73   // of DXEFV, so let's keep away the OS from there too.
     74   //
     75   if (SecureS3Needed) {
     76     UINT32 DxeMemFvEnd;
     77 
     78     DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
     79                   PcdGet32 (PcdOvmfDxeMemFvSize);
     80     BuildMemoryAllocationHob (
     81       DxeMemFvEnd,
     82       PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
     83       EfiACPIMemoryNVS
     84       );
     85   }
     86 
     87   //
     88   // Let PEI know about the DXE FV so it can find the DXE Core
     89   //
     90   PeiServicesInstallFvInfoPpi (
     91     NULL,
     92     (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),
     93     PcdGet32 (PcdOvmfDxeMemFvSize),
     94     NULL,
     95     NULL
     96     );
     97 
     98   return EFI_SUCCESS;
     99 }
    100 
    101