示例#1
0
/**
  The entry point for TrEE configuration driver.

  @param  FileHandle  Handle of the file being invoked.
  @param  PeiServices Describes the list of possible PEI Services.

  @retval EFI_SUCCES             Convert variable to PCD successfully.
  @retval Others                 Fail to convert variable to PCD.
**/
EFI_STATUS
EFIAPI
TrEEConfigPeimEntryPoint (
  IN       EFI_PEI_FILE_HANDLE  FileHandle,
  IN CONST EFI_PEI_SERVICES     **PeiServices
  )
{
  UINTN                           Size;
  EFI_STATUS                      Status;
  EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi;
  TREE_CONFIGURATION              TrEEConfiguration;
  UINTN                           Index;
  UINT8                           TpmDevice;

  Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi);
  ASSERT_EFI_ERROR (Status);

  Size = sizeof(TrEEConfiguration);
  Status = VariablePpi->GetVariable (
                          VariablePpi,
                          TREE_STORAGE_NAME,
                          &gTrEEConfigFormSetGuid,
                          NULL,
                          &Size,
                          &TrEEConfiguration
                          );
  if (EFI_ERROR (Status)) {
    //
    // Variable not ready, set default value
    //
    TrEEConfiguration.TpmDevice           = TPM_DEVICE_DEFAULT;
  }

  //
  // Validation
  //
  if (TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) {
    TrEEConfiguration.TpmDevice   = TPM_DEVICE_DEFAULT;
  }

  //
  // Although we have SetupVariable info, we still need detect TPM device manually.
  //
  DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice));

  if (PcdGetBool (PcdTpmAutoDetection)) {
    TpmDevice = DetectTpmDevice (TrEEConfiguration.TpmDevice);
    DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice final: %x\n", TpmDevice));
    TrEEConfiguration.TpmDevice = TpmDevice;
  }

  //
  // Convert variable to PCD.
  // This is work-around because there is no gurantee DynamicHiiPcd can return correct value in DXE phase.
  // Using DynamicPcd instead.
  //
  for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
    if (TrEEConfiguration.TpmDevice == mTpmInstanceId[Index].TpmDevice) {
      Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid);
      PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
      DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));
      break;
    }
  }

  //
  // Selection done
  //
  Status = PeiServicesInstallPpi (&gTpmSelectedPpi);
  ASSERT_EFI_ERROR (Status);

  return Status;
}
示例#2
0
/**
  This is the entry point of PEIM

  @param[in]   FileHandle     Handle of the file being invoked.
  @param[in]   PeiServices    Describes the list of possible PEI Services.

  @retval   EFI_SUCCESS       If it is completed successfully.

**/
EFI_STATUS
EFIAPI
PeiInitPlatform (
  IN       EFI_PEI_FILE_HANDLE  FileHandle,
  IN CONST EFI_PEI_SERVICES     **PeiServices
  )
{
  EFI_STATUS                       Status = EFI_SUCCESS;
  UINTN                            Size;
  SYSTEM_CONFIGURATION             SystemConfiguration;
  
  //
  // Get setup variable. This can only be done after BootMode is updated
  //
  Status = GetSetupVariable (PeiServices, &SystemConfiguration);
  Size = sizeof(SYSTEM_CONFIGURATION);

  if(EFI_ERROR(Status)){
    //
    // For OC solution, there is no setup variable, so set the SystemConfiguration with default value.
    //
    CopyMem(&SystemConfiguration, &gDefaultSystemConfiguration,Size);
    //
    // Update the values according to PCD settings
    //
	
    //
    // Platform
    //
    SystemConfiguration.TurboModeEnable = PcdGet8(PcdTurboMode);
	
    //
    // South Complex
    //
    SystemConfiguration.SccSdcardEnabled = PcdGet8(PcdSdcardMode);
    SystemConfiguration.LpssHsuart0Enabled = PcdGet8(PcdEnableHsuart0);
    SystemConfiguration.LpssHsuart1Enabled = PcdGet8(PcdEnableHsuart1);
    SystemConfiguration.PchAzalia = PcdGet8(PcdEnableAzalia);
    SystemConfiguration.PchSata = PcdGet8(PcdEnableSata);
    SystemConfiguration.PchUsb30Mode = PcdGet8(PcdEnableXhci);
    SystemConfiguration.PchLpeEnabled = PcdGet8(PcdEnableLpe);
    SystemConfiguration.LpssDma0Enabled = PcdGet8(PcdEnableDma0);
    SystemConfiguration.LpssDma1Enabled = PcdGet8(PcdEnableDma1);
    SystemConfiguration.LpssI2C0Enabled = PcdGet8(PcdEnableI2C0);
    SystemConfiguration.LpssI2C1Enabled = PcdGet8(PcdEnableI2C1);
    SystemConfiguration.LpssI2C2Enabled = PcdGet8(PcdEnableI2C2);
    SystemConfiguration.LpssI2C3Enabled = PcdGet8(PcdEnableI2C3);
    SystemConfiguration.LpssI2C4Enabled = PcdGet8(PcdEnableI2C4);
    SystemConfiguration.LpssI2C5Enabled = PcdGet8(PcdEnableI2C5);
    SystemConfiguration.LpssI2C6Enabled = PcdGet8(PcdEnableI2C6);
    SystemConfiguration.ScceMMCEnabled = PcdGet8(PcdEmmcMode);
    SystemConfiguration.SataInterfaceSpeed = PcdGet8(PcdSataInterfaceSpeed);
    SystemConfiguration.ISPEn = PcdGet8(ISPEnable);
    SystemConfiguration.ISPDevSel = PcdGet8(ISPPciDevConfig);
    SystemConfiguration.PchSata = PcdGet8(PcdEnableSata);	
    SystemConfiguration.MrcDvfsEnable = PcdGet8(PcdDvfsEnable);
    SystemConfiguration.PnpSettings = PcdGet8(PcdPnpSettings);
	
    //
    // North Complex
    //
    SystemConfiguration.GTTSize = PcdGet8(PcdGttSize);
    SystemConfiguration.IgdApertureSize = PcdGet8(PcdApertureSize);
    SystemConfiguration.IgdDvmt50PreAlloc = PcdGet8(PcdIgdDvmt50PreAlloc);
    SystemConfiguration.TSEGSizeSel = (UINT8)PcdGet16(PcdMrcInitTsegSize);
    DEBUG ((EFI_D_INFO, "PeiInitPlatform(): GetSetupVariable returns EFI_NOT_FOUND!! \n"));
  }else {
    // Chipsec: Go thrugh all setup items is corrupted one by one
    CheckSetupVarItem(&SystemConfiguration);

  }
  PcdSetPtr (PcdSystemConfiguration, &Size, &SystemConfiguration);
  DEBUG ((EFI_D_INFO, "PcdSystemConfiguration size - 0x%x\n", LibPcdGetExSize(&gEfiEdkIIPlatformTokenSpaceGuid, PcdTokenEx(&gEfiEdkIIPlatformTokenSpaceGuid, PcdSystemConfiguration)) ));

  //
  // Initialize Stall PPIs
  //
  Status = (*PeiServices)->InstallPpi (PeiServices, &mInstallStallPpi[0]);
  ASSERT_EFI_ERROR (Status);

  Status = (*PeiServices)->NotifyPpi (PeiServices, &mMemoryDiscoveredNotifyList[0]);
  ASSERT_EFI_ERROR (Status);

  Status = (*PeiServices)->NotifyPpi (PeiServices, &mEndOfPeiNotifyList[0]);
  ASSERT_EFI_ERROR (Status);

  //
  // Start board detection
  //
  Status = PeiServicesInstallPpi (mBoardDetectionStartPpi);
  ASSERT_EFI_ERROR (Status);
  
  //
  // Set the new boot mode for MRC
  //
  Status = UpdateBootMode (PeiServices);
  ASSERT_EFI_ERROR (Status);

  return Status;
}