Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to

https://svn.code.sf.net/p/edk2/code/trunk/edk2/, 

which are for MinnowBoard MAX open source project.


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Wei <david.wei@intel.com>
Reviewed-by: Mike Wu <mike.wu@intel.com>
Reviewed-by: Hot Tian <hot.tian@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16599 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
David Wei
2015-01-12 09:37:20 +00:00
committed by zwei4
parent 6f785cfcc3
commit 3cbfba02fe
518 changed files with 118538 additions and 0 deletions

View File

@@ -0,0 +1,403 @@
/** @file
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
BootMode.c
Abstract:
EFI PEIM to provide the platform support functionality on the Thurley.
--*/
#include "CommonHeader.h"
#include "Platform.h"
#include "PlatformBaseAddresses.h"
#include "PchAccess.h"
#include "PlatformBootMode.h"
#include <Guid/SetupVariable.h>
#include <Guid/BootState.h>
//
// Priority of our boot modes, highest priority first
//
EFI_BOOT_MODE mBootModePriority[] = {
BOOT_IN_RECOVERY_MODE,
BOOT_WITH_DEFAULT_SETTINGS,
BOOT_ON_FLASH_UPDATE,
BOOT_ON_S2_RESUME,
BOOT_ON_S3_RESUME,
BOOT_ON_S4_RESUME,
BOOT_WITH_MINIMAL_CONFIGURATION,
BOOT_ASSUMING_NO_CONFIGURATION_CHANGES,
BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS,
BOOT_WITH_FULL_CONFIGURATION,
BOOT_ON_S5_RESUME
};
EFI_PEI_NOTIFY_DESCRIPTOR mCapsuleNotifyList[1] = {
{
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gPeiCapsulePpiGuid,
CapsulePpiNotifyCallback
}
};
BOOLEAN
GetSleepTypeAfterWakeup (
IN CONST EFI_PEI_SERVICES **PeiServices,
OUT UINT16 *SleepType
);
EFI_STATUS
EFIAPI
CapsulePpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
PEI_CAPSULE_PPI *Capsule;
Status = (*PeiServices)->GetBootMode((const EFI_PEI_SERVICES **)PeiServices, &BootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_ON_S3_RESUME) {
//
// Determine if we're in capsule update mode
//
Status = (*PeiServices)->LocatePpi ((const EFI_PEI_SERVICES **)PeiServices,
&gPeiCapsulePpiGuid,
0,
NULL,
(VOID **)&Capsule
);
if (Status == EFI_SUCCESS) {
if (Capsule->CheckCapsuleUpdate ((EFI_PEI_SERVICES**)PeiServices) == EFI_SUCCESS) {
BootMode = BOOT_ON_FLASH_UPDATE;
Status = (*PeiServices)->SetBootMode((const EFI_PEI_SERVICES **)PeiServices, BootMode);
ASSERT_EFI_ERROR (Status);
}
}
}
return Status;
}
/**
Check CMOS register bit to determine if previous boot was successful
@param PeiServices pointer to the PEI Service Table
@retval TRUE - Previous Boot was success
@retval FALSE - Previous Boot wasn't success
**/
BOOLEAN
IsPreviousBootSuccessful(
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
BOOLEAN BootState;
UINTN DataSize;
CHAR16 VarName[] = BOOT_STATE_VARIABLE_NAME;
EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiVar;
Status = (**PeiServices).LocatePpi (
PeiServices,
&gEfiPeiReadOnlyVariable2PpiGuid,
0,
NULL,
(void **)&PeiVar
);
ASSERT_EFI_ERROR (Status);
//
// Get last Boot State Variable to confirm that it is not a first boot .
//
DataSize = sizeof (BOOLEAN);
Status = PeiVar->GetVariable (
PeiVar,
VarName,
&gEfiBootStateGuid,
NULL,
&DataSize,
&BootState
);
if (EFI_ERROR (Status) || (BootState == TRUE)) {
return FALSE;
}
DEBUG ((EFI_D_INFO, "Previous boot cycle successfully completed handover to OS\n"));
return TRUE;
}
#ifdef NOCS_S3_SUPPORT
EFI_STATUS
UpdateBootMode (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
UINT16 SleepType;
CHAR16 *strBootMode;
Status = (*PeiServices)->GetBootMode(PeiServices, &BootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_IN_RECOVERY_MODE){
return Status;
}
//
// Let's assume things are OK if not told otherwise
//
BootMode = BOOT_WITH_FULL_CONFIGURATION;
if (GetSleepTypeAfterWakeup (PeiServices, &SleepType)) {
switch (SleepType) {
case V_PCH_ACPI_PM1_CNT_S3:
BootMode = BOOT_ON_S3_RESUME;
Status = (*PeiServices)->NotifyPpi (PeiServices, &mCapsuleNotifyList[0]);
ASSERT_EFI_ERROR (Status);
break;
case V_PCH_ACPI_PM1_CNT_S4:
BootMode = BOOT_ON_S4_RESUME;
break;
case V_PCH_ACPI_PM1_CNT_S5:
BootMode = BOOT_ON_S5_RESUME;
break;
} // switch (SleepType)
}
if (IsFastBootEnabled (PeiServices) && IsPreviousBootSuccessful (PeiServices)) {
DEBUG ((EFI_D_INFO, "Prioritizing Boot mode to BOOT_WITH_MINIMAL_CONFIGURATION\n"));
PrioritizeBootMode (&BootMode, BOOT_WITH_MINIMAL_CONFIGURATION);
}
switch (BootMode) {
case BOOT_WITH_FULL_CONFIGURATION:
strBootMode = L"BOOT_WITH_FULL_CONFIGURATION";
break;
case BOOT_WITH_MINIMAL_CONFIGURATION:
strBootMode = L"BOOT_WITH_MINIMAL_CONFIGURATION";
break;
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
strBootMode = L"BOOT_ASSUMING_NO_CONFIGURATION_CHANGES";
break;
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
strBootMode = L"BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS";
break;
case BOOT_WITH_DEFAULT_SETTINGS:
strBootMode = L"BOOT_WITH_DEFAULT_SETTINGS";
break;
case BOOT_ON_S4_RESUME:
strBootMode = L"BOOT_ON_S4_RESUME";
break;
case BOOT_ON_S5_RESUME:
strBootMode = L"BOOT_ON_S5_RESUME";
break;
case BOOT_ON_S2_RESUME:
strBootMode = L"BOOT_ON_S2_RESUME";
break;
case BOOT_ON_S3_RESUME:
strBootMode = L"BOOT_ON_S3_RESUME";
break;
case BOOT_ON_FLASH_UPDATE:
strBootMode = L"BOOT_ON_FLASH_UPDATE";
break;
case BOOT_IN_RECOVERY_MODE:
strBootMode = L"BOOT_IN_RECOVERY_MODE";
break;
default:
strBootMode = L"Unknown boot mode";
} // switch (BootMode)
DEBUG ((EFI_D_ERROR, "Setting BootMode to %s\n", strBootMode));
Status = (*PeiServices)->SetBootMode(PeiServices, BootMode);
ASSERT_EFI_ERROR (Status);
return Status;
}
#endif
/**
Get sleep type after wakeup
@param PeiServices Pointer to the PEI Service Table.
@param SleepType Sleep type to be returned.
@retval TRUE A wake event occured without power failure.
@retval FALSE Power failure occured or not a wakeup.
**/
BOOLEAN
GetSleepTypeAfterWakeup (
IN CONST EFI_PEI_SERVICES **PeiServices,
OUT UINT16 *SleepType
)
{
UINT16 Pm1Sts;
UINT16 Pm1Cnt;
UINT16 GenPmCon1;
//
// VLV BIOS Specification 0.6.2 - Section 18.4, "Power Failure Consideration"
//
// When the SUS_PWR_FLR bit is set, it indicates the SUS well power is lost.
// This bit is in the SUS Well and defaults to 1<>b1 based on RSMRST# assertion (not cleared by any type of reset).
// System BIOS should follow cold boot path if SUS_PWR_FLR (PBASE + 0x20[14]),
// GEN_RST_STS (PBASE + 0x20[9]) or PWRBTNOR_STS (ABASE + 0x00[11]) is set to 1<>b1
// regardless of the value in the SLP_TYP (ABASE + 0x04[12:10]) field.
//
GenPmCon1 = MmioRead16 (PMC_BASE_ADDRESS + R_PCH_PMC_GEN_PMCON_1);
//
// Read the ACPI registers
//
Pm1Sts = IoRead16 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_STS);
Pm1Cnt = IoRead16 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_CNT);
if ((GenPmCon1 & (B_PCH_PMC_GEN_PMCON_SUS_PWR_FLR | B_PCH_PMC_GEN_PMCON_GEN_RST_STS)) ||
(Pm1Sts & B_PCH_ACPI_PM1_STS_PRBTNOR)) {
//
// If power failure indicator, then don't attempt s3 resume.
// Clear PM1_CNT of S3 and set it to S5 as we just had a power failure, and memory has
// lost already. This is to make sure no one will use PM1_CNT to check for S3 after
// power failure.
//
if ((Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP) == V_PCH_ACPI_PM1_CNT_S3) {
Pm1Cnt = ((Pm1Cnt & ~B_PCH_ACPI_PM1_CNT_SLP_TYP) | V_PCH_ACPI_PM1_CNT_S5);
IoWrite16 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_CNT, Pm1Cnt);
}
//
// Clear Wake Status (WAK_STS)
//
}
//
// Get sleep type if a wake event occurred and there is no power failure
//
if ((Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP) == V_PCH_ACPI_PM1_CNT_S3) {
*SleepType = Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP;
return TRUE;
} else if ((Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP) == V_PCH_ACPI_PM1_CNT_S4) {
*SleepType = Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP;
return TRUE;
}
return FALSE;
}
BOOLEAN
EFIAPI
IsFastBootEnabled (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiReadOnlyVarPpi;
UINTN VarSize;
SYSTEM_CONFIGURATION SystemConfiguration;
BOOLEAN FastBootEnabledStatus;
FastBootEnabledStatus = FALSE;
Status = (**PeiServices).LocatePpi (
PeiServices,
&gEfiPeiReadOnlyVariable2PpiGuid,
0,
NULL,
(void **)&PeiReadOnlyVarPpi
);
if (Status == EFI_SUCCESS) {
VarSize = sizeof (SYSTEM_CONFIGURATION);
Status = PeiReadOnlyVarPpi->GetVariable (
PeiReadOnlyVarPpi,
PLATFORM_SETUP_VARIABLE_NAME,
&gEfiSetupVariableGuid,
NULL,
&VarSize,
&SystemConfiguration
);
if (Status == EFI_SUCCESS) {
if (SystemConfiguration.FastBoot != 0) {
FastBootEnabledStatus = TRUE;
}
}
}
return FastBootEnabledStatus;
}
/**
Given the current boot mode, and a proposed new boot mode, determine
which has priority. If the new boot mode has higher priority, then
make it the current boot mode.
@param CurrentBootMode pointer to current planned boot mode
@param NewBootMode proposed boot mode
@retval EFI_NOT_FOUND if either boot mode is not recognized
@retval EFI_SUCCESS if both boot mode values were recognized and
were processed.
**/
EFI_STATUS
PrioritizeBootMode (
IN OUT EFI_BOOT_MODE *CurrentBootMode,
IN EFI_BOOT_MODE NewBootMode
)
{
UINT32 CurrentIndex;
UINT32 NewIndex;
//
// Find the position of the current boot mode in our priority array
//
for ( CurrentIndex = 0;
CurrentIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
CurrentIndex++) {
if (mBootModePriority[CurrentIndex] == *CurrentBootMode) {
break;
}
}
if (CurrentIndex >= sizeof (mBootModePriority) / sizeof (mBootModePriority[0])) {
return EFI_NOT_FOUND;
}
//
// Find the position of the new boot mode in our priority array
//
for ( NewIndex = 0;
NewIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
NewIndex++) {
if (mBootModePriority[NewIndex] == NewBootMode) {
//
// If this new boot mode occurs before the current boot mode in the
// priority array, then take it.

View File

@@ -0,0 +1,65 @@
/*++
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __COMMON_HEADER_H_
#define __COMMON_HEADER_H_
#include <FrameworkPei.h>
#include <IndustryStandard/SmBus.h>
#include <IndustryStandard/Pci22.h>
#include <Ppi/AtaController.h>
#include <Guid/Capsule.h>
#include <Ppi/Cache.h>
#include <Ppi/MasterBootMode.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/RecoveryDevice.h>
#include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/FvLoadFile.h>
#include <Ppi/DeviceRecoveryModule.h>
#include <Ppi/Capsule.h>
#include <Ppi/Reset.h>
#include <Ppi/Stall.h>
#include <Ppi/BootInRecoveryMode.h>
#include <Guid/FirmwareFileSystem2.h>
#include <Ppi/MemoryDiscovered.h>
#include <Ppi/RecoveryModule.h>
#include <Ppi/Smbus2.h>
#include <Ppi/FirmwareVolumeInfo.h>
#include <Ppi/EndOfPeiPhase.h>
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/BaseLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HobLib.h>
#include <Library/PciCf8Lib.h>
#include <Library/IoLib.h>
#include <Library/PciLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/PcdLib.h>
#include <Library/SmbusLib.h>
#include <Library/TimerLib.h>

View File

@@ -0,0 +1,160 @@
/** @file
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
This file includes a memory call back function notified when MRC is done,
following action is performed in this file,
1. ICH initialization after MRC.
2. SIO initialization.
3. Install ResetSystem and FinvFv PPI.
4. Set MTRR for PEI
5. Create FV HOB and Flash HOB
**/
#include "CommonHeader.h"
#include "Platform.h"
#include <Ppi/Cache.h>
#include <Library/BaseCryptLib.h>
#include <Library/PciLib.h>
#include "VlvAccess.h"
EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode[] = {
{ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiBootInRecoveryModePpiGuid,
NULL
}
};
#if 0
STATIC
EFI_STATUS
GetMemorySize (
IN CONST EFI_PEI_SERVICES **PeiServices,
OUT UINT64 *LowMemoryLength,
OUT UINT64 *HighMemoryLength
)
{
EFI_STATUS Status;
EFI_PEI_HOB_POINTERS Hob;
*HighMemoryLength = 0;
*LowMemoryLength = 0x100000;
//
// Get the HOB list for processing
//
Status = (*PeiServices)->GetHobList (PeiServices, (void **)&Hob.Raw);
if (EFI_ERROR(Status)) {
return Status;
}
//
// Collect memory ranges
//
while (!END_OF_HOB_LIST (Hob)) {
if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
//
// Need memory above 1MB to be collected here
//
if (Hob.ResourceDescriptor->PhysicalStart >= 0x100000 &&
Hob.ResourceDescriptor->PhysicalStart < (EFI_PHYSICAL_ADDRESS) 0x100000000) {
*LowMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength);
} else if (Hob.ResourceDescriptor->PhysicalStart >= (EFI_PHYSICAL_ADDRESS) 0x100000000) {
*HighMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength);
}
}
}
Hob.Raw = GET_NEXT_HOB (Hob);
}
return EFI_SUCCESS;
}
#endif
/**
This function will be called when MRC is done.
@param PeiServices General purpose services available to every PEIM.
@param NotifyDescriptor Information about the notify event..
@param Ppi The notify context.
@retval EFI_SUCCESS If the function completed successfully.
**/
EFI_STATUS
EFIAPI
MemoryDiscoveredPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
UINT32 Pages;
VOID* Memory;
UINTN Size;
//
// Allocate LM memory and configure PDM if enabled by user.
// ConfigureLM(PeiServices);
//
Status = (*PeiServices)->GetBootMode (
(const EFI_PEI_SERVICES **)PeiServices,
&BootMode
);
if (BootMode != BOOT_ON_S3_RESUME) {
Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size);
Pages= Size/0x1000;
Memory = AllocatePages ( Pages );
CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size);
//
// We don't verify just load
//
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))),
PcdGet32 (PcdFlashFvRecovery2Size),
NULL,
NULL
);
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *) Memory,
PcdGet32 (PcdFlashFvMainSize),
NULL,
NULL
);
}
if (BootMode == BOOT_ON_S3_RESUME) {
PeiServicesInstallFvInfoPpi (
NULL,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,216 @@
/*++
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __PEI_PLATFORM_H__
#define __PEI_PLATFORM_H__
#define PEI_STALL_RESOLUTION 1
#define STALL_PEIM_SIGNATURE SIGNATURE_32('p','p','u','s')
typedef struct {
UINT32 Signature;
EFI_FFS_FILE_HEADER *FfsHeader;
EFI_PEI_NOTIFY_DESCRIPTOR StallNotify;
} STALL_CALLBACK_STATE_INFORMATION;
#define STALL_PEIM_FROM_THIS(a) CR (a, STALL_CALLBACK_STATE_INFORMATION, StallNotify, STALL_PEIM_SIGNATURE)
#ifdef NOCS_S3_SUPPORT
/**
Peform the boot mode determination logic
If the box is closed, then
1. If it's first time to boot, it's boot with full config .
2. If the ChassisIntrution is selected, force to be a boot with full config
3. Otherwise it's boot with no change.
@param PeiServices General purpose services available to every PEIM.
@param BootMode The detected boot mode.
@retval EFI_SUCCESS if the boot mode could be set
**/
EFI_STATUS
UpdateBootMode (
IN CONST EFI_PEI_SERVICES **PeiServices
);
#endif
/**
This function reset the entire platform, including all processor and devices, and
reboots the system.
@param PeiServices General purpose services available to every PEIM.
@retval EFI_SUCCESS if it completed successfully.
**/
EFI_STATUS
EFIAPI
ResetSystem (
IN CONST EFI_PEI_SERVICES **PeiServices
);
/**
This function will be called when MRC is done.
@param PeiServices General purpose services available to every PEIM.
@param NotifyDescriptor Information about the notify event..
@param Ppi The notify context.
@retval EFI_SUCCESS If the function completed successfully.
**/
EFI_STATUS
EFIAPI
MemoryDiscoveredPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
);
/**
This is the callback function notified by FvFileLoader PPI, it depends on FvFileLoader PPI to load
the PEIM into memory.
@param PeiServices General purpose services available to every PEIM.
@param NotifyDescriptor The context of notification.
@param Ppi The notify PPI.
@retval EFI_SUCCESS if it completed successfully.
**/
EFI_STATUS
EFIAPI
FvFileLoaderPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
);
/**
This function provides a blocking stall for reset at least the given number of microseconds
stipulated in the final argument.
@param PeiServices General purpose services available to every PEIM.
@param this Pointer to the local data for the interface.
@param Microseconds number of microseconds for which to stall.
@retval EFI_SUCCESS the function provided at least the required stall.
**/
EFI_STATUS
EFIAPI
Stall (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_STALL_PPI *This,
IN UINTN Microseconds
);
/**
This function initialize recovery functionality by installing the recovery PPI.
@param PeiServices General purpose services available to every PEIM.
@retval EFI_SUCCESS If the interface could be successfully installed.
**/
EFI_STATUS
EFIAPI
InitializeRecovery (
IN EFI_PEI_SERVICES **PeiServices
);
/**
This function
1. Calling MRC to initialize memory.
2. Install EFI Memory.
3. Capsule coalesce if capsule boot mode.
4. Create HOB of system memory.
@param PeiServices Pointer to the PEI Service Table
@retval EFI_SUCCESS If it completes successfully.
**/
EFI_STATUS
MemoryInit (
IN EFI_PEI_SERVICES **PeiServices
);
/**
This function provides the implementation of AtaController PPI Enable Channel function.
@param PeiServices General purpose services available to every PEIM.
@param this Pointer to the local data for the interface.
@param ChannelMask This parameter is used to specify primary or slavery IDE channel.
@retval EFI_SUCCESS Procedure returned successfully.
**/
EFI_STATUS
EnableAtaChannel (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_ATA_CONTROLLER_PPI *This,
IN UINT8 ChannelMask
);
/**
This function provides the implementation of AtaController PPI Get IDE channel Register Base Address
@param PeiServices General purpose services available to every PEIM.
@param this Pointer to the local data for the interface.
@param IdeRegsBaseAddr Pointer to IDE_REGS_BASE_ADDR struct, which is used to record
IDE Command and Control regeisters Base Address.
@retval EFI_SUCCESS Procedure returned successfully.
**/
EFI_STATUS
GetIdeRegsBaseAddr (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_ATA_CONTROLLER_PPI *This,
IN IDE_REGS_BASE_ADDR *IdeRegsBaseAddr
);
/**
This function provides the implementation to properly setup both LM & PDM functionality.
@param PeiServices General purpose services available to every PEIM.
@retval EFI_SUCCESS Procedure returned successfully.
**/
EFI_STATUS
ConfigureLM(
IN EFI_PEI_SERVICES **PeiServices
);
#include <Ppi/VlvMmioPolicy.h>
BOOLEAN
EFIAPI
IsFastBootEnabled (
IN CONST EFI_PEI_SERVICES **PeiServices
);
EFI_STATUS
PrioritizeBootMode (
IN OUT EFI_BOOT_MODE *CurrentBootMode,
IN EFI_BOOT_MODE NewBootMode
);

View File

@@ -0,0 +1,136 @@
#
#
# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
#
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that accompanies this distribution.
# The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
# This PEIM includes 3 parts, pre memory initialization, MRC
# wrapper and post memory initialization.
# On pre memory, following action is performed,
# 1. Initizluize GMCH.
# 2. Detect boot mode.
# 3. Detect video adapter to determine whether we need pre allocated
# memory.
#
# After that MRC wrapper calls MRC to initialize memory and install a PPI
# notify to do post memory
# initialization. MRC wrapper performance following actions,
# 1. Install EFI Memory.
# 2. Capsule coalesce if capsule boot mode.
# 3. Create HOB of system memory.
# Note: MRC supports 3 kinds of chipsets including Lakeport, Glenwood and Mukilteo,
# so please don't define MACRO MUKILTEO_SUPPORT on Lakeport here.
#
# On post memory, following action is performed,
# 1. TC initialization after MRC.
# 2. SIO initialization.
# 3. Install ResetSystem and FinvFv PPI, relocate Stall to memory on
# recovery boot mode.
# 4. Set MTRR for PEI
# 5. Create FV HOB and Flash HOB
# 6. Install RecoveryModule and AtaController PPI if on recovery boot mode.
#
# This PEIM does not have any register access directly, it depends on
# IntelTCLib, TCAccess libraries to access Chipset
# registers.
#
# Platform.c - Provide main flow and entrypoint of PEIM.
# MemoryCallback.c - Includes a memory call back function notified when
# MRC is done.
#
#
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatformPeim
FILE_GUID = 9618C0DC-50A4-496c-994F-7241F282ED01
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
ENTRY_POINT = PeiInitPlatform
PI_SPECIFICATION_VERSION = 0x0001000A
[sources.common]
Platform.c
Platform.h
MemoryCallback.c
CommonHeader.h
Stall.c
BootMode.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Vlv2TbltDevicePkg/PlatformPkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
IA32FamilyCpuPkg/IA32FamilyCpuPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
CryptoPkg/CryptoPkg.dec
EdkCompatibilityPkg/EdkCompatibilityPkg.dec
[LibraryClasses]
PeimEntryPoint
DebugLib
HobLib
IoLib
MultiPlatformLib
MtrrLib
PerformanceLib
MonoStatusCodeLib
BaseCryptLib
PciLib
[Ppis]
gEfiPeiStallPpiGuid
gPeiSpeakerInterfacePpiGuid
gEfiPeiMemoryDiscoveredPpiGuid
gVlvPolicyPpiGuid
gEfiPeiReadOnlyVariable2PpiGuid
gEfiPeiResetPpiGuid
gEfiEndOfPeiSignalPpiGuid
gEfiFindFvPpiGuid
gPeiCapsulePpiGuid
gEfiPeiBootInRecoveryModePpiGuid
gEfiPeiRecoveryModulePpiGuid
gEfiPeiDeviceRecoveryModulePpiGuid
gPeiCachePpiGuid
gEfiPeiMasterBootModePpiGuid
gEfiPeiSmbusPpiGuid
gPeiMfgMemoryTestPpiGuid
gPeiSha256HashPpiGuid
gVlvMmioPolicyPpiGuid
[Guids]
gEfiSetupVariableGuid
gEfiPlatformInfoGuid
gEfiPlatformBootModeGuid
gEfiPlatformCpuInfoGuid
gEfiGlobalVariableGuid
gRecoveryOnFatFloppyDiskGuid
gRecoveryOnFatUsbDiskGuid
gRecoveryOnFatIdeDiskGuid
gRecoveryOnDataCdGuid
gMfgModeVariableGuid
gEfiNormalSetupGuid
gEfiBootStateGuid
gEfiVlv2VariableGuid
[Pcd.common]
gPlatformModuleTokenSpaceGuid.PcdFlashFvMainBase

View File

@@ -0,0 +1,95 @@
/** @file
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Stall.c
Abstract:
Produce Stall Ppi.
--*/
#include "CommonHeader.h"
#include "PlatformBaseAddresses.h"
#include "PchRegs.h"
/**
Waits for at least the given number of microseconds.
@param PeiServices General purpose services available to every PEIM.
@param This PPI instance structure.
@param Microseconds Desired length of time to wait.
@retval EFI_SUCCESS If the desired amount of time was passed.
**/
EFI_STATUS
EFIAPI
Stall (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_STALL_PPI *This,
IN UINTN Microseconds
)
{
UINTN Ticks;
UINTN Counts;
UINT32 CurrentTick;
UINT32 OriginalTick;
UINT32 RemainingTick;
if (Microseconds == 0) {
return EFI_SUCCESS;
}
OriginalTick = IoRead32 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_TMR);
OriginalTick &= (V_PCH_ACPI_PM1_TMR_MAX_VAL - 1);
CurrentTick = OriginalTick;
//
// The timer frequency is 3.579545MHz, so 1 ms corresponds to 3.58 clocks
//
Ticks = Microseconds * 358 / 100 + OriginalTick + 1;
//
// The loops needed for timer overflow
//
Counts = (UINTN)RShiftU64((UINT64)Ticks, 24);
//
// Remaining clocks within one loop
//
RemainingTick = Ticks & 0xFFFFFF;
//
// Do not intend to use TMROF_STS bit of register PM1_STS, because this add extra
// one I/O operation, and may generate SMI
//
while (Counts != 0) {
CurrentTick = IoRead32 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_TMR) & B_PCH_ACPI_PM1_TMR_VAL;
if (CurrentTick <= OriginalTick) {
Counts--;
}
OriginalTick = CurrentTick;