Home | History | Annotate | Download | only in FspNotifyPhase
      1 /** @file
      2   Source file for FSP notify phase PEI module
      3 
      4   Copyright (c) 2016, Intel Corporation. All rights reserved.
      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 #include "FspNotifyPhasePeim.h"
     15 
     16 /**
     17 
     18    This function waits for FSP notify.
     19 
     20    @param This          Entry point for DXE IPL PPI.
     21    @param PeiServices   General purpose services available to every PEIM.
     22    @param HobList       Address to the Pei HOB list.
     23 
     24    @return EFI_SUCCESS              This function never returns.
     25 
     26 **/
     27 EFI_STATUS
     28 EFIAPI
     29 WaitForNotify (
     30   IN CONST EFI_DXE_IPL_PPI *This,
     31   IN EFI_PEI_SERVICES      **PeiServices,
     32   IN EFI_PEI_HOB_POINTERS  HobList
     33   );
     34 
     35 CONST EFI_DXE_IPL_PPI mDxeIplPpi = {
     36   WaitForNotify
     37 };
     38 
     39 CONST EFI_PEI_PPI_DESCRIPTOR mInstallDxeIplPpi = {
     40   EFI_PEI_PPI_DESCRIPTOR_PPI,
     41   &gEfiDxeIplPpiGuid,
     42   (VOID *) &mDxeIplPpi
     43 };
     44 
     45 CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {
     46   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
     47   &gEfiEndOfPeiSignalPpiGuid,
     48   NULL
     49 };
     50 
     51 /**
     52 
     53    This function waits for FSP notify.
     54 
     55    @param This          Entry point for DXE IPL PPI.
     56    @param PeiServices   General purpose services available to every PEIM.
     57    @param HobList       Address to the Pei HOB list.
     58 
     59    @return EFI_SUCCESS              This function never returns.
     60 
     61 **/
     62 EFI_STATUS
     63 EFIAPI
     64 WaitForNotify (
     65   IN CONST EFI_DXE_IPL_PPI *This,
     66   IN EFI_PEI_SERVICES      **PeiServices,
     67   IN EFI_PEI_HOB_POINTERS  HobList
     68   )
     69 {
     70   EFI_STATUS   Status;
     71 
     72   DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP HOB is located at 0x%08X\n", HobList));
     73 
     74   //
     75   // End of PEI phase signal
     76   //
     77   Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
     78   ASSERT_EFI_ERROR (Status);
     79 
     80   //
     81   // Give control back to BootLoader after FspSiliconInit
     82   //
     83   DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));
     84   FspSiliconInitDone2 (EFI_SUCCESS);
     85 
     86   //
     87   // BootLoader called FSP again through NotifyPhase
     88   //
     89   FspWaitForNotify ();
     90 
     91   //
     92   // Should not come here
     93   //
     94   while (TRUE) {
     95     DEBUG ((DEBUG_ERROR, "No FSP API should be called after FSP is DONE!\n"));
     96     SetFspApiReturnStatus (EFI_UNSUPPORTED);
     97     Pei2LoaderSwitchStack ();
     98   }
     99 
    100   return EFI_SUCCESS;
    101 }
    102 
    103 /**
    104   FSP notify phase PEI module entry point
    105 
    106   @param[in]  FileHandle           Not used.
    107   @param[in]  PeiServices          General purpose services available to every PEIM.
    108 
    109   @retval     EFI_SUCCESS          The function completes successfully
    110   @retval     EFI_OUT_OF_RESOURCES Insufficient resources to create database
    111 **/
    112 EFI_STATUS
    113 FspNotifyPhasePeimEntryPoint (
    114   IN       EFI_PEI_FILE_HANDLE    FileHandle,
    115   IN CONST EFI_PEI_SERVICES       **PeiServices
    116   )
    117 {
    118   EFI_STATUS                      Status;
    119   VOID                            *OldDxeIplPpi;
    120   EFI_PEI_PPI_DESCRIPTOR          *OldDescriptor;
    121 
    122   DEBUG ((DEBUG_INFO | DEBUG_INIT, "The entry of FspNotificationPeim\n"));
    123 
    124   //
    125   // Locate old DXE IPL PPI
    126   //
    127   Status = PeiServicesLocatePpi (
    128             &gEfiDxeIplPpiGuid,
    129             0,
    130             &OldDescriptor,
    131             &OldDxeIplPpi
    132             );
    133   ASSERT_EFI_ERROR (Status);
    134 
    135   //
    136   // Re-install the DXE IPL PPI to wait for notify
    137   //
    138   Status = PeiServicesReInstallPpi (OldDescriptor, &mInstallDxeIplPpi);
    139   ASSERT_EFI_ERROR (Status);
    140 
    141   return EFI_SUCCESS;
    142 }
    143