EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

ArmPlatformPkg/PlatformPei/PlatformPeim.c

Go to the documentation of this file.
00001 
00015 #include <PiPei.h>
00016 
00017 //
00018 // The protocols, PPI and GUID defintions for this module
00019 //
00020 #include <Ppi/ArmGlobalVariable.h>
00021 #include <Ppi/MasterBootMode.h>
00022 #include <Ppi/BootInRecoveryMode.h>
00023 #include <Ppi/GuidedSectionExtraction.h>
00024 //
00025 // The Library classes this module consumes
00026 //
00027 #include <Library/ArmPlatformLib.h>
00028 #include <Library/BaseMemoryLib.h>
00029 #include <Library/DebugLib.h>
00030 #include <Library/HobLib.h>
00031 #include <Library/PeimEntryPoint.h>
00032 #include <Library/PeiServicesLib.h>
00033 #include <Library/PcdLib.h>
00034 
00035 #include <Guid/ArmGlobalVariableHob.h>
00036 
00037 EFI_STATUS
00038 EFIAPI
00039 InitializePlatformPeim (
00040   IN       EFI_PEI_FILE_HANDLE  FileHandle,
00041   IN CONST EFI_PEI_SERVICES     **PeiServices
00042   );
00043   
00044 EFI_STATUS
00045 EFIAPI
00046 PlatformPeim (
00047   VOID
00048   );
00049 
00050 //
00051 // Module globals
00052 //
00053 EFI_PEI_PPI_DESCRIPTOR  mPpiListBootMode = {
00054   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
00055   &gEfiPeiMasterBootModePpiGuid,
00056   NULL
00057 };
00058 
00059 EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {
00060   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
00061   &gEfiPeiBootInRecoveryModePpiGuid,
00062   NULL
00063 };
00064 
00065 VOID
00066 EFIAPI
00067 BuildGlobalVariableHob (
00068   IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,
00069   IN UINT32                       GlobalVariableSize
00070   )
00071 {
00072   EFI_STATUS                Status;
00073   ARM_HOB_GLOBAL_VARIABLE   *Hob;
00074 
00075   Status = PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE), (VOID**)&Hob);
00076   if (!EFI_ERROR(Status)) {
00077     CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
00078     Hob->GlobalVariableBase = GlobalVariableBase;
00079     Hob->GlobalVariableSize = GlobalVariableSize;
00080   }
00081 }
00082 
00083 /*++
00084 
00085 Routine Description:
00086 
00087   
00088 
00089 Arguments:
00090 
00091   FileHandle  - Handle of the file being invoked.
00092   PeiServices - Describes the list of possible PEI Services.
00093     
00094 Returns:
00095 
00096   Status -  EFI_SUCCESS if the boot mode could be set
00097 
00098 --*/
00099 EFI_STATUS
00100 EFIAPI
00101 InitializePlatformPeim (
00102   IN       EFI_PEI_FILE_HANDLE  FileHandle,
00103   IN CONST EFI_PEI_SERVICES     **PeiServices
00104   )
00105 {
00106   EFI_STATUS                    Status;
00107   UINTN                         BootMode;
00108   ARM_GLOBAL_VARIABLE_PPI       *ArmGlobalVariablePpi;
00109   EFI_PHYSICAL_ADDRESS          GlobalVariableBase;
00110 
00111   DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
00112 
00113   PlatformPeim ();
00114   
00115   Status = PeiServicesLocatePpi (&gArmGlobalVariablePpiGuid, 0, NULL, (VOID**)&ArmGlobalVariablePpi);
00116   if (!EFI_ERROR(Status)) {
00117     Status = ArmGlobalVariablePpi->GetGlobalVariableMemory (&GlobalVariableBase);
00118 
00119     if (!EFI_ERROR(Status)) {
00120       // Declare the Global Variable HOB
00121       BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));
00122     }
00123   }
00124 
00125   BootMode  = ArmPlatformGetBootMode ();
00126   Status    = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
00127   ASSERT_EFI_ERROR (Status);
00128 
00129   Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
00130   ASSERT_EFI_ERROR (Status);
00131 
00132   if (BootMode == BOOT_IN_RECOVERY_MODE) {
00133     Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
00134     ASSERT_EFI_ERROR (Status);
00135   }
00136 
00137   return Status;
00138 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines