diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib')
15 files changed, 2638 insertions, 0 deletions
diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.c b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.c new file mode 100644 index 0000000..c062033 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.c @@ -0,0 +1,722 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.c 5 3/14/14 9:56a Joshchou $ +// +// $Revision: 5 $ +// +// $Date: 3/14/14 9:56a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.c $ +// +// 5 3/14/14 9:56a Joshchou +// +// 4 8/05/13 3:02a Joshchou +// [TAG] EIP130093 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] System will hang at CP 0xA2 when plug in special mSATA SSD +// and Intel Rapid Start Technology support +// [RootCause] The buffer size isn't enough. +// [Solution] Modify the size when allocate. +// +// 3 2/20/13 1:47a Bensonlai +// [TAG] EIP115468 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] [SharkBay][Rapid Start] Rapid Start can't work using GPT +// partition when enabled RAID mode +// [RootCause] Rapid Start can't work using GPT partition when enabled +// RAID mode +// [Files] RapidStartDxeLib.c +// +// 2 12/07/12 1:25a Bensonlai +// [TAG] EIP108737 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] When system in the RAID mode without the partition of the +// RapidStart, RapidStart menu still show "No Valid Partition" in the +// setup. +// [RootCause] We didn't check the RAID mode. +// [Solution] Add the RAID mode for checking whether in the RAID mode. +// [Files] RapidStartDxeLib.c +// +// 1 10/15/12 4:41a Bensonlai +// [TAG] None +// [Category] Improvement +// [Description] [Category] Improvement +// [Severity] Important +// [Description] Rename all IFFS sting to Rapid Start. +// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +// +// [Files] RapidStartDxeLib.cif +// RapidStartDxeLib.sdl +// RapidStartDxeLib.mak +// RapidStartDxeLib.c +// RapidStartDxeLib.h +// RapidStartDxeLib.inf +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: RapidStartDxeLib.c +// +// Description: RapidStart Dxe Platform Library. +// +//<AMI_FHDR_END> +//********************************************************************** + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" + +#include EFI_PROTOCOL_CONSUMER (BlockIo) +#include EFI_PROTOCOL_CONSUMER (DiskIo) +#include EFI_PROTOCOL_CONSUMER (RapidStartPlatformPolicy) +#include <SaAccess.h> +#include <PchAccess.h> +#include <UefiGpt.h> +#include <mbr.h> +#include "RapidStartDxeLib.h" +#endif + +//AMIOVERRIDE_BEGIN +#define SIGNATURE_16(A, B) ((A) | (B << 8)) +#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16)) +#define SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32)) +//AMIOVERRIDE_END + +#define RAPID_START_PART_TYPE_MBR 0x84 /* Hibernation partition -- APM 1.1f */ +#define PCH_EFI_RAID_DRIVER_EXECUTION_GUID \ + { 0x99D5757C, 0xD906, 0x11E0, 0x8D, 0x78, 0x8D, 0xE4, 0x48, 0x24, 0x01, 0x9B }; + +EFI_GUID gRapidStartGptGuid = RAPID_START_GPT_GUID; +UINT8 gDriveNum = 0x80; +EFI_GUID gPchEfiRaidDriverExecutionGuid = PCH_EFI_RAID_DRIVER_EXECUTION_GUID; +BOOLEAN gPchEfiRaidDriver = FALSE; + +/** + Search device path by specific Type and SubType + + @param[in,out] DevicePath - A pointer to the device path + @param[in] Type - Device path type + @param[in] SubType - Device path SubType + + @retval EFI_DEVICE_PATH_PROTOCOL - Device path found and the pointer of device path returned + @retval NULL - Specific device path not found +**/ +STATIC +EFI_DEVICE_PATH_PROTOCOL * +SearchDevicePath ( + IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN UINT8 Type, + IN UINT8 SubType + ) +{ + if (DevicePath == NULL) { + return NULL; + } + + while (!IsDevicePathEnd (DevicePath)) { + if ((DevicePathType (DevicePath) == Type) && (DevicePathSubType (DevicePath) == SubType)) { + return DevicePath; + } + + DevicePath = NextDevicePathNode (DevicePath); + } + + return NULL; +} + +STATIC +EFI_STATUS +RetrieveSataPortNumberInt13 ( + IN OUT UINT8 *PortNumber, + IN BOOLEAN GPTDetect + ) +{ + UINTN Index; + BOOLEAN CarryFlag; + EFI_IA32_REGISTER_SET Regs; + EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; + EFI_PHYSICAL_ADDRESS TheRealModeBuffer; + VOID* Int13Buffer = NULL; + EFI_STATUS Status; + UINT8 MaxDriveCount; + + Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, &LegacyBios); + ASSERT_EFI_ERROR(Status); + + // allocate conventional memory for int code + TheRealModeBuffer = 0x00000000000FFFFF; + Status = (gBS->AllocatePages)( + AllocateMaxAddress, + EfiBootServicesData, + 1, + &TheRealModeBuffer); + ASSERT_EFI_ERROR(Status); + + Int13Buffer = (VOID*)TheRealModeBuffer; + // clear 4K page + (gBS->SetMem)(Int13Buffer, 1024 * 4, 0); + + MaxDriveCount = *(UINT8*)0x475; +//#### DEBUG ((EFI_D_ERROR, "MaxDriveCount = %x\n", MaxDriveCount)); + + for (Index = 0; Index < MaxDriveCount; Index++) { + *(UINT16*)Int13Buffer = 0x004A; + // Get physical hard disk information by ATA identify command + Regs.X.DS = EFI_SEGMENT(Int13Buffer); + Regs.X.SI = EFI_OFFSET(Int13Buffer); + Regs.H.AH = 0x48; + + if (GPTDetect) + Regs.H.DL = 0x80 + (UINT8)Index; + else + Regs.H.DL = gDriveNum; + + DEBUG ((EFI_D_ERROR, "Drive Number = %x\n", Regs.H.DL)); + + LegacyBios->Int86 (LegacyBios, 0x13, &Regs); + CarryFlag = (BOOLEAN)Regs.X.Flags.CF; + if ((!CarryFlag) && (Regs.H.AH == 0)) { + + DEBUG ((EFI_D_ERROR, "0x28 = %x\n", *((UINT8*)(Int13Buffer)+0x28))); + DEBUG ((EFI_D_ERROR, "0x29 = %x\n", *((UINT8*)(Int13Buffer)+0x29))); + DEBUG ((EFI_D_ERROR, "0x2A = %x\n", *((UINT8*)(Int13Buffer)+0x2A))); + DEBUG ((EFI_D_ERROR, "0x2B = %x\n", *((UINT8*)(Int13Buffer)+0x2B))); + DEBUG ((EFI_D_ERROR, "0x3C = %x\n", *((UINT8*)(Int13Buffer)+0x3C))); + + if ((*((UINT8*)(Int13Buffer)+0x28) == 'R') && \ + (*((UINT8*)(Int13Buffer)+0x29) == 'A') && \ + (*((UINT8*)(Int13Buffer)+0x2A) == 'I') && \ + (*((UINT8*)(Int13Buffer)+0x2B) == 'D')) { + switch (*((UINT8*)(Int13Buffer)+0x3c)) { + case 0x01: + *PortNumber = 0; + break; + case 0x02: + *PortNumber = 1; + break; + case 0x04: + *PortNumber = 2; + break; + case 0x08: + *PortNumber = 3; + break; + case 0x10: + *PortNumber = 4; + break; + case 0x20: + *PortNumber = 5; + break; + default: + *PortNumber = 0; + break; + } + } + } + if (!GPTDetect) break; + } + if (Int13Buffer) (gBS->FreePages) (TheRealModeBuffer, 1); + + return Status; +} + +/** + Scan and check if GPT type RapidStart Store present. + + @param[in] Device - Device handle + @param[in] DevicePath - A pointer to the device path + @param[out] StoreSectors - Size of RapidStart store partition + @param[out] StoreLbaAddr - Address of RapidStart store partition + + @retval EFI_SUCCESS - GPT type RapidStart Store found. + @retval EFI_NOT_FOUND - GPT type RapidStart Store not found. +**/ +STATIC +EFI_STATUS +ScanForRapidStartGptPartition ( + IN EFI_HANDLE Device, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + OUT UINT32 *StoreSectors, + OUT UINT64 *StoreLbaAddr + ) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_PARTITION_TABLE_HEADER *PrimaryHeader; + EFI_PARTITION_ENTRY *PartitionEntry; + UINT32 Index; + + Status = gBS->HandleProtocol (Device, &gEfiBlockIoProtocolGuid, (VOID*)&BlockIo); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + Status = gBS->HandleProtocol (Device, &gEfiDiskIoProtocolGuid, (VOID*)&DiskIo); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + // + // Read the EFI Partition Table Header + // + PrimaryHeader = (EFI_PARTITION_TABLE_HEADER *) AllocatePool (BlockIo->Media->BlockSize); + if (PrimaryHeader == NULL) { + return EFI_OUT_OF_RESOURCES; + } + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + 1 * BlockIo->Media->BlockSize, + BlockIo->Media->BlockSize, + (UINT8 *)PrimaryHeader + ); + if (EFI_ERROR (Status)) { + FreePool (PrimaryHeader); + return EFI_DEVICE_ERROR; + } +//AMIOVERRIDE_BEGIN + if(PrimaryHeader->Header.Signature != EFI_PTAB_HEADER_ID ){//Check for "EFI PART" signature + FreePool (PrimaryHeader); + return EFI_NOT_FOUND; + } +//AMIOVERRIDE_END + // + // Read the partition entry. + // +//AMIOVERRIDE_BEGIN + // PartitionEntry = AllocatePool (PrimaryHeader->NumberOfPartitionEntries * sizeof (EFI_PARTITION_ENTRY)); + PartitionEntry = AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry); +//AMIOVERRIDE_END + if (PartitionEntry == NULL) { + FreePool (PrimaryHeader); + return EFI_OUT_OF_RESOURCES; + } + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize), + PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry, + PartitionEntry + ); + if (EFI_ERROR (Status)) { + FreePool (PrimaryHeader); + FreePool (PartitionEntry); + return EFI_DEVICE_ERROR; + } + + // + // Count the valid partition + // + for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) { + if (CompareGuid (&PartitionEntry[Index].PartitionTypeGUID, &gRapidStartGptGuid)) { + *StoreLbaAddr = PartitionEntry[Index].StartingLBA; + *StoreSectors = (UINT32) (PartitionEntry[Index].EndingLBA - PartitionEntry[Index].StartingLBA + 1); + DEBUG ( + (EFI_D_INFO, + "Found RapidStart GPT partition: start=%x size=%x\n", + *StoreLbaAddr, + *StoreSectors) + ); + FreePool (PrimaryHeader); + FreePool (PartitionEntry); + return EFI_SUCCESS; + } + } + + FreePool (PrimaryHeader); + FreePool (PartitionEntry); + return EFI_NOT_FOUND; +} + +/** + Scan and check if MBR type RapidStart Store present. + + @param[in] Device - Device handle + @param[out] StoreSectors - Size of RapidStart store partition + @param[out] StoreLbaAddr - Address of RapidStart store partition + + @retval EFI_SUCCESS - MBR type RapidStart Store found. + @retval EFI_NOT_FOUND - MBR type RapidStart Store not found. +**/ +STATIC +EFI_STATUS +ScanForRapidStartMbrPartition ( + IN EFI_HANDLE Device, + OUT UINT32 *StoreSectors, + OUT UINT64 *StoreLbaAddr + ) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + UINTN Idx; + UINT8 OsType; + + MASTER_BOOT_RECORD BootRecord; + MASTER_BOOT_RECORD *Mbr; + MASTER_BOOT_RECORD ExtBootRecord; + MASTER_BOOT_RECORD *ExtPart; + EFI_LBA Lba; + + Mbr = &BootRecord; + + Status = gBS->HandleProtocol (Device, &gEfiBlockIoProtocolGuid, (VOID *) &BlockIo); + ASSERT_EFI_ERROR (Status); + ASSERT (BlockIo != NULL); + + /// + /// read the MBR + /// + Status = BlockIo->ReadBlocks (BlockIo, BlockIo->Media->MediaId, 0, sizeof (*Mbr), Mbr); + if (Status != EFI_SUCCESS) { + DEBUG ((EFI_D_ERROR, "Cannot read MBR\n")); + return Status; + } + + if (Mbr->Sig != MBR_SIGNATURE) { + DEBUG ((EFI_D_ERROR, "Bad MBR\n")); + if (!BlockIo->Media->RemovableMedia) + gDriveNum++; + return EFI_NOT_FOUND; + } + + for (Idx = 0; Idx < NUM_MBR_PARTITIONS; Idx++) { + OsType = Mbr->PartRec[Idx].OSType; + + /// + /// ignore partitions whose OSType or Size is zero + /// + if ((OsType == 0) || (Mbr->PartRec[Idx].SizeInLba == 0)) { + continue; + } + + if (OsType == RAPID_START_PART_TYPE_MBR) { + DEBUG ( + (EFI_D_INFO, + "Found RapidStart MBR partition: start=%x size=%x\n", + Mbr->PartRec[Idx].StartingLba, + Mbr->PartRec[Idx].SizeInLba) + ); + *StoreLbaAddr = Mbr->PartRec[Idx].StartingLba; + *StoreSectors = Mbr->PartRec[Idx].SizeInLba; + return EFI_SUCCESS; + } + + // Now that a valid partition is found process it + if ((Mbr->PartRec[Idx].OSType == EXTENDED_PARTITION) || + (Mbr->PartRec[Idx].OSType == WIN95_EXTENDED_PARTITION)) { + + ExtPart = &ExtBootRecord; + + // defines where to start reading the next MBR/partition + // table from + Lba = Mbr->PartRec[Idx].StartingLba; + + // loop through logical partitions: any number of + // possible partitions + while (TRUE) { + + // if the table points back to itself, exit + if ( Lba == 0) { + break; + } + + // get Partition table from the first block of the device + Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, + Lba, sizeof (*ExtPart), ExtPart); + + if (EFI_ERROR(Status)) { + return Status; + } + + // make sure this is a valid partition + if (ExtPart->PartRec[0].OSType == NO_PARTITION) { + break; + } + + // check for problems that make the partition invalid + if ((Lba + ExtPart->PartRec[0].SizeInLba) > + (Mbr->PartRec[Idx].StartingLba + + Mbr->PartRec[Idx].SizeInLba)) { + + break; + } + + OsType = ExtPart->PartRec[0].OSType; + + if (OsType == RAPID_START_PART_TYPE_MBR) { + DEBUG ( + (EFI_D_INFO, + "Found RapidStart MBR partition: start=%x size=%x\n", + Mbr->PartRec[Idx].StartingLba, + Mbr->PartRec[Idx].SizeInLba) + ); + + *StoreLbaAddr = ExtPart->PartRec[0].StartingLba + Lba; + *StoreSectors = ExtPart->PartRec[0].SizeInLba; + return EFI_SUCCESS; + } + + // check to see if the next partition is an extended partition + if ((ExtPart->PartRec[1].OSType != EXTENDED_PARTITION) && + (ExtPart->PartRec[1].OSType != WIN95_EXTENDED_PARTITION) ) { + break; + } + + // get set up for the next partition. The Starting Lba + // address is a relative address inside the extended + // partition add the starting address of the extended + // partition to get the actual LBA where it starts + Lba = ExtPart->PartRec[1].StartingLba + + Mbr->PartRec[Idx].StartingLba; + } + } + } + + if (!BlockIo->Media->RemovableMedia) + gDriveNum++; + + return EFI_NOT_FOUND; +} + +/** + Verify if this device path was RapidStart store partition. Get SATA port number if it was. + + @param[in] AhciMode - TRUE means current SATA operation mode is AHCI, otherwise it is RAID + @param[in,out] DevicePath - A pointer to the device path + @param[in,out] PortNumber - Port Number connecting to this drive + + @retval EFI_SUCCESS - This is RapidStart Store partition and Port Number retrieved successfully. + @retval EFI_NOT_FOUND - This is not RapidStart Store +**/ +STATIC +EFI_STATUS +VerifyDevicePath ( + IN BOOLEAN AhciMode, + IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN OUT UINT8 *PortNumber + ) +{ + EFI_STATUS Status; + UINT8 Index; + + Status = EFI_NOT_FOUND; + + DevicePath = SearchDevicePath (DevicePath, MESSAGING_DEVICE_PATH, MSG_SATA_DP); + if ((SATA_DEVICE_PATH *) DevicePath != NULL) { +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + * PortNumber = (UINT8) ((SATA_DEVICE_PATH *) DevicePath)->HBAPortNumber; +#else + *PortNumber = (UINT8) ((SATA_DEVICE_PATH *) DevicePath)->HbaPortNumber; +#endif + Status = EFI_SUCCESS; + } + + // Support Intel RST SATA UEFI Driver + if (gPchEfiRaidDriver) { + for (Index = 0; Index < 6; Index++) { + if (*PortNumber & (1 << Index)) { + *PortNumber = Index; + break; + } + } + } + + + if (Status == EFI_SUCCESS) { + DEBUG ((EFI_D_INFO, "Port number=%X\n", *PortNumber)); + } + + return Status; +} + +/** + Look through all device handles to detect if any GPT/MBR type RapidStart Store present + + @param[in] AhciMode - TRUE means current SATA operation mode is AHCI, otherwise it is RAID + @param[in] RapidStartPolicy - RapidStart Platform Policy protocol + @param[out] StoreSectors - Size of RapidStart store partition + @param[out] StoreLbaAddr - Address of RapidStart store partition + @param[out] StoreSataPort - Port number for RapidStart store partition + + @retval EFI_SUCCESS - RapidStart Store found + @retval EFI_NOT_FOUND - RapidStart Store not found +**/ +STATIC +EFI_STATUS +DetectRapidStartPartition ( + IN BOOLEAN AhciMode, + IN RAPID_START_PLATFORM_POLICY_PROTOCOL *RapidStartPolicy, + OUT UINT32 *StoreSectors, + OUT UINT64 *StoreLbaAddr, + OUT UINT8 *StoreSataPort + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINTN Index; + + Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &HandleCount, &HandleBuffer); + if (!EFI_ERROR (Status)) { + // + // Loop through all the device handles that support the BLOCK_IO Protocol + // + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &DevicePath); + if (EFI_ERROR (Status) || DevicePath == NULL) { + continue; + } + + if (VerifyDevicePath (AhciMode, DevicePath, StoreSataPort) == EFI_SUCCESS || (AhciMode == 0)) { //Raid mode + Status = ScanForRapidStartGptPartition (HandleBuffer[Index], DevicePath, StoreSectors, StoreLbaAddr); + if (Status == EFI_SUCCESS) { + if ( (!AhciMode) && (!gPchEfiRaidDriver) ) RetrieveSataPortNumberInt13(StoreSataPort, TRUE); + DEBUG ((EFI_D_INFO, "Found Gpt RapidStart Store on SATA port=%d\n", *StoreSataPort)); + break; + } + Status = ScanForRapidStartMbrPartition (HandleBuffer[Index], StoreSectors, StoreLbaAddr); + if (Status == EFI_SUCCESS) { + + if ( (!AhciMode) && (!gPchEfiRaidDriver) ) RetrieveSataPortNumberInt13(StoreSataPort, FALSE); + + DEBUG ((EFI_D_INFO, "Found Mbr RapidStart Store on SATA port=%d\n", *StoreSataPort)); + break; + } + } + } + + FreePool (HandleBuffer); + } + + return Status; +} + +/** + Search if any type of RapidStart Store partition present + + @param[in] RapidStartPolicy - RapidStart Platform Policy protocol + @param[out] StoreSectors - Size of RapidStart store partition + @param[out] StoreLbaAddr - Address of RapidStart store partition + @param[out] StoreSataPort - Port number for RapidStart store partition + + @retval EFI_SUCCESS - GPT or MBR type RapidStart Store found + @retval EFI_NOT_FOUND - GPT or MBR type RapidStart Store not found +**/ +EFI_STATUS +SearchRapidStartStore ( + IN RAPID_START_PLATFORM_POLICY_PROTOCOL *RapidStartPolicy, + OUT UINT32 *StoreSectors, + OUT UINT64 *StoreLbaAddr, + OUT UINT8 *StoreSataPort + ) +{ + BOOLEAN AhciMode; + EFI_STATUS Status; + VOID *Empty; + + *StoreSectors = 0; + *StoreLbaAddr = 0; + *StoreSataPort = 0; + + // + // Get current SATA operation mode (only AHCI or RAID mode is supported) + // + AhciMode = (MmioRead8 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_SATA, + PCI_FUNCTION_NUMBER_PCH_SATA, + R_PCH_SATA_SUB_CLASS_CODE) + ) == V_PCH_SATA_SUB_CLASS_CODE_AHCI); + + Status = gBS->LocateProtocol(&gPchEfiRaidDriverExecutionGuid, NULL, &Empty); + if (Status == EFI_SUCCESS) gPchEfiRaidDriver = TRUE; + + Status = DetectRapidStartPartition (AhciMode, RapidStartPolicy, StoreSectors, StoreLbaAddr, StoreSataPort); + + return Status; +} + +/** + Generate RapidStart Store UID + + @retval UINT64 as RapidStart Store UID +**/ +UINT64 +GenerateRapidStartStoreUid ( + VOID + ) +{ + UINT64 Uid; + UINT32 HpetBase; + UINT32 HpetSetting; + + Uid = AsmReadTsc (); + + HpetSetting = MmioRead32 (PCH_RCRB_BASE + R_PCH_RCRB_HPTC); + if (HpetSetting & B_PCH_RCRB_HPTC_AE) { + HpetBase = R_PCH_PCH_HPET_CONFIG + (HpetSetting & B_PCH_RCRB_HPTC_AS) * 0x1000; + Uid ^= (LShiftU64 ((*(UINT64 *) (UINTN) (HpetBase + 0xF0)), 32)); + } else { + // + // Use certain random memory content as part of UID. + // + Uid ^= (LShiftU64 ((*(UINT64 *) (UINTN) (0xF5C00)), 32)); + } + + return Uid; +} + +VOID +EnableHibernate ( + VOID + ) +/*++ + +Routine Description: + + Re-enable Hibernation when RapidStart enabled but RapidStart Store not present. + +Arguments: + + None + +Returns: + + None + +--*/ +{ +} +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.cif b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.cif new file mode 100644 index 0000000..88a8a56 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.cif @@ -0,0 +1,12 @@ +<component> + name = "RapidStartDxeLib" + category = ModulePart + LocalRoot = "Board\EM\RapidStartWrapper\Library\RapidStartPlatformLib\Dxe" + RefName = "RapidStartDxeLib" +[files] +"RapidStartDxeLib.sdl" +"RapidStartDxeLib.mak" +"RapidStartDxeLib.c" +"RapidStartDxeLib.h" +"RapidStartDxeLib.inf" +<endComponent> diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.h b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.h new file mode 100644 index 0000000..6685bc4 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.h @@ -0,0 +1,137 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.h 2 3/14/14 9:56a Joshchou $ +// +// $Revision: 2 $ +// +// $Date: 3/14/14 9:56a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.h $ +// +// 2 3/14/14 9:56a Joshchou +// +// 1 10/15/12 4:41a Bensonlai +// [TAG] None +// [Category] Improvement +// [Description] [Category] Improvement +// [Severity] Important +// [Description] Rename all IFFS sting to Rapid Start. +// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +// +// [Files] RapidStartDxeLib.cif +// RapidStartDxeLib.sdl +// RapidStartDxeLib.mak +// RapidStartDxeLib.c +// RapidStartDxeLib.h +// RapidStartDxeLib.inf +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: RapidStartDxeLib.h +// +// Description: RapidStart Dxe Platform Library header file. +// +//<AMI_FHDR_END> +//********************************************************************** + +#ifndef _RAPID_START_DXE_LIB_H_ +#define _RAPID_START_DXE_LIB_H_ +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include EFI_PROTOCOL_CONSUMER (RapidStartPlatformPolicy) +#endif + +#define RAPID_START_PART_TYPE_MBR 0x84 /* Hibernation partition -- APM 1.1f */ +/// +/// Partition Name: Intel RapidStart Reserved +/// GUID: D3BFE2DE-3DAF-11DF-BA40-E3A556D89593 +/// +#define RAPID_START_GPT_GUID \ + { \ + 0xD3BFE2DE, 0x3DAF, 0x11DF, 0xba, 0x40, 0xe3, 0xa5, 0x56, 0xd8, 0x95, 0x93 \ + } + +/** + Search if any type of RapidStart Store partition present + + This function will search all connected/initialized SSD and see if any valid and + supported Rapid Start Store present or not. It will scan both GPT and MBR type + partitions and return the required information for accessing Rapid Start Store. + If no valid/supported Rapid Start Store found the Rapid Start will be disabled. + The method and algorithm for searching Rapid Start Store could be implemented by + platform design. + + @param[in] RapidStartPolicy - RapidStart Platform Policy protocol + @param[out] StoreSectors - Size of RapidStart store partition + @param[out] StoreLbaAddr - Address of RapidStart store partition + @param[out] StoreSataPort - Port number for RapidStart store partition + + @retval EFI_SUCCESS - GPT or MBR type RapidStart Store found + @retval EFI_NOT_FOUND - GPT or MBR type RapidStart Store not found +**/ +EFI_STATUS +SearchRapidStartStore ( + IN RAPID_START_PLATFORM_POLICY_PROTOCOL *RapidStartPolicy, + OUT UINT32 *StoreSectors, + OUT UINT64 *StoreLbaAddr, + OUT UINT8 *StoreSataPort + ); + +/** + Generate RapidStart Store UID + + This function will generate a unique ID which will be stored into Rapid Start + Store for identifying Rapid Start Store changing condition. When Rapid Start + Store changed during Rapid Start Resume, the Rapid Start Resume should be + aborted. By default this ID is combining the CPU TSC and HPET counter. This UID + will only be generated when Rapid Start Persistent Data not present or Rapid + Start Store has changed in previous resume. + + @retval UINT64 as RapidStart Store UID +**/ +UINT64 +GenerateRapidStartStoreUid ( + VOID + ); + +/** + Re-enable Hibernation when RapidStart enabled but RapidStart Store not present. + + It's recommended to disable ACPI Hibernate support when Rapid Start feature + enabled. In this case, if Rapid Start Store not present or invalid (Rapid Start + will not be executed), ACPI Hibernate should be re-enabled. This function + required porting to fit platform implementation. +**/ +VOID +EnableHibernate ( + VOID + ); +#endif +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.inf b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.inf new file mode 100644 index 0000000..f72934d --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.inf @@ -0,0 +1,56 @@ +## @file +# Component description file for the RapidStartDxeLib +# +#@copyright +# Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# This file contains a 'Sample Driver' and is licensed as such +# under the terms of your license agreement with Intel or your +# vendor. This file may be modified by the user, subject to +# the additional terms of the license agreement +# + +[defines] +BASE_NAME = RapidStartDxeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + RapidStartDxeLib.c + RapidStartDxeLib.h + +[includes.common] + . + $(EDK_SOURCE)/Foundation + $(EDK_SOURCE)/Foundation/Include + $(EDK_SOURCE)/Foundation/Efi + $(EDK_SOURCE)/Foundation/Efi/Include + $(EDK_SOURCE)/Foundation/Framework + $(EDK_SOURCE)/Foundation/Framework/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Pcd + $(EDK_SOURCE)/Foundation/Include/IndustryStandard + $(EDK_SOURCE)/Foundation/Library/Dxe/Include + $(EDK_SOURCE)/Foundation/Core/Dxe + $(EDK_SOURCE)/Foundation/Cpu/Pentium/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Protocol + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT) + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT) + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Samplecode + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Samplecode/Include + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Samplecode/Library/RapidStartCommonLib + $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Guid/AcpiVariable + +[nmake.common] +C_FLAGS = $(C_FLAGS) + +C_STD_INCLUDE=
\ No newline at end of file diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.mak b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.mak new file mode 100644 index 0000000..00c4388 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.mak @@ -0,0 +1,78 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.mak 1 10/15/12 4:41a Bensonlai $ +# +# $Revision: 1 $ +# +# $Date: 10/15/12 4:41a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.mak $ +# +# 1 10/15/12 4:41a Bensonlai +# [TAG] None +# [Category] Improvement +# [Description] [Category] Improvement +# [Severity] Important +# [Description] Rename all IFFS sting to Rapid Start. +# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +# +# [Files] RapidStartDxeLib.cif +# RapidStartDxeLib.sdl +# RapidStartDxeLib.mak +# RapidStartDxeLib.c +# RapidStartDxeLib.h +# RapidStartDxeLib.inf +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: RapidStartDxeLib.mak +# +# Description: Component description file for the RapidStartDxeLib. +# +#<AMI_FHDR_END> +#********************************************************************** + +all : RapidStartDxeLib + +$(RapidStartDxeLib_LIB) : RapidStartDxeLib + +RapidStartDxeLib : $(BUILD_DIR)\RapidStartDxeLib.mak RapidStartDxeLibBin + +$(BUILD_DIR)\RapidStartDxeLib.mak : $(RapidStartDxeLib_DIR)\$(@B).cif $(RapidStartDxeLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(RapidStartDxeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +RapidStartDxeLibBin : + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + /f $(BUILD_DIR)\RapidStartDxeLib.mak all\ + "MY_INCLUDES=$(EDK_INCLUDES) $(EdkIIGlueLib_INCLUDES) $(INTEL_MCH_INCLUDES) $(INTEL_PCH_INCLUDES) $(RAPIDSTART_INCLUDES)" \ + TYPE=LIBRARY \ + LIBRARY_NAME=$(RapidStartDxeLib_LIB) +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.sdl b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.sdl new file mode 100644 index 0000000..02fd98b --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.sdl @@ -0,0 +1,98 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.sdl 1 10/15/12 4:41a Bensonlai $ +# +# $Revision: 1 $ +# +# $Date: 10/15/12 4:41a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxeLib/RapidStartDxeLib.sdl $ +# +# 1 10/15/12 4:41a Bensonlai +# [TAG] None +# [Category] Improvement +# [Description] [Category] Improvement +# [Severity] Important +# [Description] Rename all IFFS sting to Rapid Start. +# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +# +# [Files] RapidStartDxeLib.cif +# RapidStartDxeLib.sdl +# RapidStartDxeLib.mak +# RapidStartDxeLib.c +# RapidStartDxeLib.h +# RapidStartDxeLib.inf +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: RapidStartDxeLib.sdl +# +# Description: SDL file for the RapidStartDxeLib. +# +#<AMI_FHDR_END> +#********************************************************************** + +TOKEN + Name = "RapidStartDxeLib_SUPPORT" + Value = "1" + Help = "Main switch to enable RapidStartDxeLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +PATH + Name = "RapidStartDxeLib_DIR" +End + +MODULE + Help = "Includes RapidStartDxeLib.mak to Project" + File = "RapidStartDxeLib.mak" +End + +ELINK + Name = "RapidStartDxeLib_LIB" + InvokeOrder = ReplaceParent +End + +ELINK + Name = "$(BUILD_DIR)\RapidStartDxeLib.lib" + Parent = "RapidStartDxeLib_LIB" + InvokeOrder = AfterParent +End + +ELINK + Name = "/I$(RapidStartDxeLib_DIR)" + Parent = "RAPIDSTART_INCLUDES" + InvokeOrder = AfterParent +End +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/OpensslLib.lib b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/OpensslLib.lib Binary files differnew file mode 100644 index 0000000..290a4fa --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/OpensslLib.lib diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib Binary files differnew file mode 100644 index 0000000..b05426c --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.c b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.c new file mode 100644 index 0000000..61d7f52 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.c @@ -0,0 +1,970 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.c 5 7/15/13 6:32a Joshchou $ +// +// $Revision: 5 $ +// +// $Date: 7/15/13 6:32a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.c $ +// +// 5 7/15/13 6:32a Joshchou +// [TAG] EIP129090 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Platform automatically wakes itself after entering S4 when +// doing Rapid Start flow +// [RootCause] The Update of PCH RC 1.6.0 in PchSmmSx.c will put XHCI +// into incorrect state on ULT platfrom. +// [Solution] Added code in the Rapid Start Entry phase, to put XHCI +// into the correct state i.e. D3 to fix the auto wake-up issue. +// +// 4 6/21/13 6:03a Joshchou +// [TAG] EIP126792 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Can't do AMI capsule when Intel Rapid Start eanble +// [RootCause] CMOS RapidStartFlag does not clear. +// [Solution] Clear RapidStartFlag when cold boot. +// +// 3 3/14/13 11:41p Bensonlai +// [TAG] EIP118122 +// [Category] Spec Update +// [Severity] Normal +// [Description] [SBY] Intel Rapid Start Technology Framework Reference +// Code Production Version 1.3.0 +// [Files] RapidStartPeiLib.c +// +// 2 12/18/12 12:19a Bensonlai +// [TAG] EIP109701 +// [Category] Spec Update +// [Severity] Normal +// [Description] Updated to Shark Bay Rapid Start Reference Code +// Version 0.8.1 +// [Files] RapidStartPeiLib.c, RapidStartPeiLib.h +// +// 1 10/15/12 4:41a Bensonlai +// [TAG] EIPNone +// [Category] Improvement +// [Description] [Category] Improvement +// [Severity] Important +// [Description] Rename all IFFS sting to Rapid Start. +// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +// [Files] RapidStartPeiLib.cif +// RapidStartPeiLib.sdl +// RapidStartPeiLib.mak +// RapidStartPeiLib.c +// RapidStartPeiLib.h +// RapidStartPeiLib.inf +// RapidStartPeiLib.lib +// PeiCryptLib.lib +// OpensslLib.lib +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: RapidStartPeiLib.c +// +// Description: RapidStart Platform PEI library. +// +//<AMI_FHDR_END> +//********************************************************************** + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGluePeim.h" +#include "RapidStartConfig.h" +#include "RapidStartPeiLib.h" +#include "RapidStartCommonLib.h" +#include <SaAccess.h> +#include <PchRegs.h> +#include <PchPlatformLib.h> +#endif +#ifndef SW_SMI_IO_ADDRESS +#define SW_SMI_IO_ADDRESS 0xB2 +#endif + +#ifndef SW_SMI_ACPI_ENABLE +#define SW_SMI_ACPI_ENABLE 0xA0 +#endif + +//AMI_OVERRIDE_FOR_RAPID_START +#ifndef FFS_NV_CONFIG_REG +#define FFS_NV_CONFIG_REG 0x47 +#endif +//AMI_OVERRIDE_FOR_RAPID_START + +#define HDD_PWD_ENCRYPTION_KEY "H?p1mA*k920_84o3d^!z@L.x4$kY64" + +#pragma pack(1) +typedef struct _HDDSECDATA +{ + UINT16 UserMaster; + UINT32 PasswordLength; + UINT8 HddUserPassword[ATA_PASSWORD_LEN]; + UINT8 HddMasterPassword[ATA_PASSWORD_LEN]; +} HDDSECDATA; +#pragma pack() + +#define DEFAULT_PCI_BUS_NUMBER_PCH 0 +#define PCI_DEVICE_NUMBER_PCH_SATA 31 +#define PCI_FUNCTION_NUMBER_PCH_SATA 2 + +#define IDE_SECURITY_PWNV_GUID \ +{ 0x69967a8c, 0x1159, 0x4522, 0xaa, 0x89, 0x74, 0xcd, 0xc6, 0xe5, 0x99, 0xa0} + +/** + Enables ACPI mode after RapidStart resume. + + @param[in] PeiServices - Pointer to PEI Services Table. + + @retval EFI_SUCCESS - enabled ACPI mode +**/ +EFI_STATUS +RapidStartEnableAcpi ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ +#ifdef RAPID_START_WHOLE_MEMORY_CHECK + DEBUG ((EFI_D_INFO, "[RapidStart] SMI port=%X, RapidStart SWSMI cmd=%X\n", SW_SMI_IO_ADDRESS, SW_SMI_WHOLE_MEMORY_CHECK)); + IoWrite8 (SW_SMI_IO_ADDRESS, SW_SMI_WHOLE_MEMORY_CHECK); +#endif + DEBUG ((EFI_D_INFO, "[RapidStart] SMI port=%X, ACPI_ENABLE cmd=%X\n", SW_SMI_IO_ADDRESS, SW_SMI_ACPI_ENABLE)); + IoWrite8 (SW_SMI_IO_ADDRESS, SW_SMI_ACPI_ENABLE); + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// +// Procedure: ConvertHddDataIdToString +// +// Description: Converts Integer HDD Data Id to String. +// +// Input: +// IN UINT32 DataId, +// OUT CHAR16 *String +// Output: +// None +// +// +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID ConvertHddDataIdToString( + IN UINT32 DataId, + OUT CHAR16 *String ) +{ + UINTN Num, i; + Num = EfiValueToString (String, DataId, 0, 0); + + for ( i = 0; i < Num; i++ ) + { + DEBUG((EFI_D_ERROR, "HDD Passowrd: String[%x] = %x. \n", i, String[i])); + } + + return; +} + +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// +// Procedure: EncodeDecodePassword +// +// Description: Encodes/Decodes Password. +// +// Input: +// IN UINT8 *InputString, +// OUT UINT8 *OutputString, +// IN UINT32 StringLen +// Output: +// None +// +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID EncodeDecodePassword( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT8 *InputString, + OUT UINT8 *OutputString, + IN UINT32 StringLength ) +{ + UINT8 *Key; + UINT32 i; + UINT32 KeyIndex; + UINT32 KeyLength; + + if ((InputString == NULL) || (StringLength == 0)) + { + return; + } + + KeyLength = (UINT32)(EfiAsciiStrLen( HDD_PWD_ENCRYPTION_KEY)); + + Key = AllocateZeroPool (KeyLength); + CopyMem ((VOID *) Key, (VOID *) HDD_PWD_ENCRYPTION_KEY, (UINTN) KeyLength); + ASSERT (Key != NULL); + + for ( i = 0, KeyIndex = 0; i < StringLength; i++, KeyIndex++ ) + { + if ( KeyIndex == (KeyLength - 1)) + { + KeyIndex = 0; + } + OutputString[i] = (UINT8) ( InputString[i] ^ Key[KeyIndex] ); + } + + return; +} + +/** + This callback is provided to support drive password locking interoperability with RapidStart. + It is called before RapidStart transition is to occur. If SSD partiotion is located on password + locked drive this function must copy the password to the output buffer. + Size of the buffer equals ATA_PASSWORD_LEN. + + Normally the drive password is kept in SMRAM so it can be used to unlock the drive at S3 resume, + thus during RapidStartEntry the password from SMRAM shall be returned. However at RapidStartExit the content + of SMRAM is not yet available so the password has to be preserved in a non-volatile memory + during RapidStartEntry (in RapidStartAfterTransition callback) and retrieved by this function. + + For security reasons the password must be scrubbed from non-volatile memory on RapidStartExit before + returning from this function. On RapidStartEntry the password must not be stored to non-volatile memory + sooner than RapidStartAfterTransition is called (that is after RapidStart non-volatile flag is set). + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] SataPort - locked SATA port + @param[out] Password - output buffer to place the password in + @param[out] FreezeLock - set to TRUE to freeze drive lock, set to FALSE otherwise + + @retval EFI_SUCCESS - Unlock password copied to the buffer + @retval EFI_NOT_FOUND - No password provided (will break the transition) +**/ +EFI_STATUS +RapidStartGetDriveUnlockPassword ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN UINT8 SataPort, + OUT UINT8 *Password, + OUT BOOLEAN *FreezeLock + ) +{ + EFI_STATUS Status; + EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable; + UINT16 wBDF; + UINT16 wPortPMModeFlag; + UINT8 DeviceorPMPort = 0xff; + BOOLEAN ModeFlag = TRUE; //TRUE is AHCI mode, FALSE is IDE mode. + UINT32 HddDataId; + CHAR16 *HddSecutiyData = NULL; + UINTN HddSecDataSize = sizeof (HDDSECDATA); + HDDSECDATA *HddSecData; + UINT16 Control; + UINTN i; + UINT8 CryptBuffer[ATA_PASSWORD_LEN]; + EFI_GUID gIdeSecurityPwNvguid = IDE_SECURITY_PWNV_GUID; + + Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariablePpiGuid, 0, NULL, &ReadOnlyVariable); + ASSERT_EFI_ERROR (Status); + + wBDF = (UINT16)((DEFAULT_PCI_BUS_NUMBER_PCH << 8) \ + | (PCI_DEVICE_NUMBER_PCH_SATA << 3) \ + | PCI_FUNCTION_NUMBER_PCH_SATA ); + wPortPMModeFlag = (UINT16)((SataPort << 12) \ + | (DeviceorPMPort << 4) \ + | ((UINT8)ModeFlag)); + + HddDataId = (UINT32)(((UINT16)wBDF << 16) + ((UINT16)wPortPMModeFlag)); + DEBUG ((EFI_D_ERROR, "[RapidStart] HddDataId=%X\n", HddDataId)); + + HddSecutiyData = AllocateZeroPool(ATA_PASSWORD_LEN); + + ConvertHddDataIdToString (HddDataId, HddSecutiyData); + + HddSecData = AllocateZeroPool(HddSecDataSize); + + Status = ReadOnlyVariable->PeiGetVariable ( + GetPeiServicesTablePointer (), + HddSecutiyData, + &gIdeSecurityPwNvguid, + NULL, + &HddSecDataSize, + HddSecData + ); + DEBUG ((EFI_D_ERROR, "[RapidStart] PeiGetVariable Status=%r\n", Status)); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + Control = HddSecData->UserMaster; + + DEBUG ((EFI_D_ERROR, "[RapidStart] Control=%x\n", Control)); + + if ( Control & 0x01 ) + { + for ( i = 0; i < sizeof (HddSecData->HddMasterPassword); i++ ) + { + CryptBuffer[i] = HddSecData->HddMasterPassword[i]; + } + + EncodeDecodePassword (PeiServices, CryptBuffer, Password, HddSecData->PasswordLength); + } + else { + for ( i = 0; i < sizeof (HddSecData->HddUserPassword); i++ ) + { + DEBUG ((EFI_D_ERROR, "[RapidStart] HddSecData->HddUserPassword[%x]= %x.\n", i, HddSecData->HddUserPassword[i])); + CryptBuffer[i] = HddSecData->HddUserPassword[i]; + } + + EncodeDecodePassword (PeiServices, CryptBuffer, Password, HddSecData->PasswordLength); + } + + *FreezeLock = TRUE; + + return EFI_SUCCESS; +} + +/** + This callback is executed before RapidStart transition is performed, but after RapidStart transition conditions has been met. + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] SataPort - SATA port of RapidStart storage drive + + @retval EFI_SUCCESS - RapidStart transition will follow + @retval EFI_ABORTED - RapidStart transition will not be performed +**/ +EFI_STATUS +RapidStartBeforeTransition ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN UINT8 SataPort + ) +{ + return EFI_SUCCESS; +} + +/** + This callback is executed at the end of RapidStart transition whether succesfull ot not. + + If RapidStart partition is located on password locked drive the drive password must be + copied to non-volatile memory during RapidStartEntry in this function, so it is available + on RapidStartExit (see RapidStartGetDriveUnlockPassword). + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] TransitionStatus - Status of the RapidStart transition + @param[in] SataPort - SATA port of RapidStart storage drive +**/ +VOID +RapidStartAfterTransition ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN EFI_STATUS TransitionStatus, + IN UINT8 SataPort + ) +{ + //AMI_OVERRIDE_FOR_RAPID_START + //Clear CMOS RapidStartFlag in PEI + RtcWrite (FFS_NV_CONFIG_REG, 0); + //AMI_OVERRIDE_FOR_RAPID_START +} + +#ifndef RAPID_START_NO_SMRAM_INTEGRITY_CHECK +/** + Saves SMRAM Secure Hash to non-volatile secure location. + + @param[in] Hash[] - hash value + + @retval EFI_SUCCESS - Hash value saved successfully + @retval EFI_NOT_FOUND - Hash value not found +**/ +EFI_STATUS +RapidStartSaveSecureHash ( + IN UINT8 Hash[RAPID_START_SECURE_HASH_LENGTH] + ) +{ + UINT8 Index; + + DEBUG ((EFI_D_ERROR, "RapidStartSaveSecureHash()\n")); + + for (Index = 0; Index < RAPID_START_SECURE_HASH_LENGTH; Index++) { + // Save SMRAM hash value + RtcWrite (FFS_SMRAM_HASH_DATA_REG + Index, Hash[Index]); + } + + return EFI_SUCCESS; +} + +/** + Retrieves and removes SMRAM hash from non-volatile memory + + @param[out] Hash[] - hash value + + @retval EFI_SUCCESS - Hash value has been restored and cleared successfully + @retval EFI_NOT_FOUND - Hash value not found +**/ +EFI_STATUS +RapidStartRestoreAndClearSecureHash ( + OUT UINT8 Hash[RAPID_START_SECURE_HASH_LENGTH] + ) +{ + UINT8 Index; + + DEBUG ((EFI_D_ERROR, "RapidStartRestoreAndClearSecureHash()\n")); + + for (Index = 0; Index < RAPID_START_SECURE_HASH_LENGTH; Index++) { + // Retrieve SMRAM hash value + Hash[Index] = RtcRead (FFS_SMRAM_HASH_DATA_REG + Index); + // Remove SMRAM value + RtcWrite (FFS_SMRAM_HASH_DATA_REG + Index, 0); + } + return EFI_SUCCESS; +} + +#endif + +/** + Provide a hook for OEM to cancel RapidStart flow. + This function may impact RapidStart Entry performance since it's polled frequently. + + @retval FALSE - Do not cancel RapidStart flow + @retval TRUE - The RapidStart Entry flow should be canceled and do S3 resume back to OS +**/ +BOOLEAN +RapidStartShouldCancelEntry ( + VOID + ) +{ + return FALSE; +} + +/// +/// Device IDs for WLAN RSR Workaround +/// +UINT16 mWlanSkusDeviceIdsTable[] = { + 0x422B, 0x4238, // 6300 - Puma Peak 3 + 0x0082, 0x0085, // 6205 - Taylor Peak + 0x0890, 0x0891, // 2200 - Marble Peak + 0x0887, 0x0888, // 2230 - Jackson Peak 1 + 0x088F, 0x088E, // 6235 - Jackson Peak 2 + 0x008A, 0x008B, // 1030 - Rainbow Peak 1 + 0x0091, 0x0090, // 6230 - Rainbow Peak 2 + 0x0885, 0x0886, // 6150 - Kelsey Peak + 0x0087, 0x0089, // 6250 - Kilmer Peak +}; + +/// +/// Device IDs for WLAN D3 Workaround +/// +UINT16 mWlanSkusDeviceIdsTable2[] = { + 0x08B3, 0x08B4, // 3160 - Wilkins Peak 1 + 0x08B1, 0x08B2, // 7260 - Wilkins Peak 2 +}; + +/** + This function is work around for NetDetect and WakeOnLan when RapidStart enabled. + + @retval EFI_SUCCESS - Operation successfully performed +**/ +EFI_STATUS +RapidStartWANetDetect ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT32 WlanMmioSpace + ) +{ + UINT8 RpFunction; + UINTN RpBase; + UINT8 SecBusNum; + UINT8 SecSubBusNum; + UINT8 EpBusNum; + UINTN EpBase; + UINTN WlanSkusDeviceIdIndex; + UINT8 CapPtr; + UINT8 NxtPtr; + UINT8 CapID; + UINT8 PMCreg; + UINT8 PMCSR; + UINT32 Timeout; + PEI_STALL_PPI *StallPpi; + EFI_STATUS Status; + + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect Start\n")); + + Status = PeiServicesLocatePpi (&gPeiStallPpiGuid, 0, NULL, (VOID **) &StallPpi); + ASSERT_EFI_ERROR (Status); + + // + // Scan PCH PCI-EX slots (Root Port) : Device 28 Function 0~7 + // + for (RpFunction = 0; RpFunction < GetPchMaxPciePortNum (); RpFunction ++) { + RpBase = MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_PCIE_ROOT_PORTS, RpFunction, 0); + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: PCI-EX slot %x ...\n", RpFunction)); + + if ((MmioRead16 (RpBase + R_PCH_PCIE_SLSTS) & B_PCH_PCIE_SLSTS_PDS) != 0 && MmioRead16 (RpBase + R_PCH_PCIE_VENDOR_ID) == V_PCH_PCIE_VENDOR_ID) { + + /// + /// Set WLAN PortBus = 1 to Read Endpoint. + /// + MmioAndThenOr32(RpBase + R_PCH_PCIE_BNUM, 0xFF0000FF, 0x00010100); + + // + // Get the downstream Bus number + // + SecBusNum = (UINT8) (MmioRead32 (RpBase + R_PCH_PCIE_BNUM) >> 8); + SecSubBusNum = (UINT8) (MmioRead32 (RpBase + R_PCH_PCIE_BNUM) >> 16); + + for (EpBusNum = SecBusNum; EpBusNum <= SecSubBusNum; EpBusNum++) { + EpBase = MmPciAddress (0, EpBusNum, 0, 0, 0); + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: downstream Bus %x\n", EpBusNum)); + + /// + /// A config write is required in order for the device to re-capture the Bus number, + /// according to PCI Express Base Specification, 2.2.6.2 + /// Write to a read-only register VendorID to not cause any side effects. + /// + MmioWrite16 (EpBase + R_PCH_PCIE_VENDOR_ID, 0); + + // + // WLAN RSR Workaround + // + for (WlanSkusDeviceIdIndex = 0; WlanSkusDeviceIdIndex < sizeof (mWlanSkusDeviceIdsTable) / sizeof (mWlanSkusDeviceIdsTable[0]); WlanSkusDeviceIdIndex++) { + if (mWlanSkusDeviceIdsTable[WlanSkusDeviceIdIndex] == MmioRead16 (EpBase + R_PCH_PCIE_DEVICE_ID)) { + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: Found a device to support RSR and device ID is %x\n", MmioRead16 (EpBase + R_PCH_PCIE_DEVICE_ID))); + + // + // Find out PMCSR register + // + CapPtr = MmioRead8 (EpBase + R_PCH_PCIE_CAPP); + CapID = MmioRead8 (EpBase + CapPtr); + NxtPtr = (UINT8) (MmioRead16 (EpBase + CapPtr) >> 8); + PMCreg = CapPtr; + + while (CapID != 0x01) { + CapID = MmioRead8 (EpBase + NxtPtr); + if (CapID == 0x01) { + PMCreg = NxtPtr; + break; + } + NxtPtr = (UINT8) (MmioRead16 (EpBase + NxtPtr) >> 8); + + if (NxtPtr == 0){ + PMCreg = 0; + break; + } + } + + if (PMCreg != 0) { + PMCSR = PMCreg + 0x04; + + // + // Check whether PME enabled + // + if (MmioRead16 (EpBase + PMCSR) & BIT8) { + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: This device PME has been enabled\n")); + + // + // Disabled PME + // + MmioAnd16 ((UINTN) (EpBase + PMCSR), (UINT16) (~BIT8)); + + // + // Set the WLAN device to D0 + // + MmioAnd8 ((UINTN) (EpBase + PMCSR), (UINT8)(~(BIT0 + BIT1))); + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS * 30); + + // + // Disable PCIE memory map access + // + MmioAnd16 ((UINTN) (RpBase + R_PCH_PCIE_PCICMD), (UINT16) (~B_PCH_PCIE_PCICMD_MSE)); + + // + // Define PCIE MMIO BAR contains a valid address value + // + MmioWrite32 (RpBase + R_PCH_PCIE_MBL, (WlanMmioSpace & B_PCH_PCIE_MBL_ML) + ((WlanMmioSpace & B_PCH_PCIE_MBL_ML) >> 16)); + MmioWrite32 (RpBase + R_PCH_PCIE_PMBL, 0x0001FF1); + + // + // Enable PCIE memory map access + // + MmioOr16 ((UINTN) (RpBase + R_PCH_PCIE_PCICMD), (UINT16) B_PCH_PCIE_PCICMD_MSE); + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: Enabled PCIE memory map and MMIO Bar is %x\n", MmioRead32 (RpBase + R_PCH_PCIE_MBL))); + + // + // Disable WLAN memory map access + // + MmioAnd16 ((UINTN) (EpBase + R_PCH_LAN_CMD), (UINT16) (~B_PCH_LAN_CMD_MSE)); + + // + // Define WLAN MMIO BAR contains a valid address value + // + MmioWrite32 (EpBase + R_PCH_LAN_MEM_BASE_A, WlanMmioSpace); + + // + // Enable WLAN memory map access + // + MmioOr16 ((UINTN) (EpBase + R_PCH_LAN_CMD), (UINT16) B_PCH_LAN_CMD_MSE); + + WlanMmioSpace = MmioRead32 (EpBase + R_PCH_LAN_MEM_BASE_A) & B_PCH_LAN_MBARA_BA; + + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: Enabled memory map and MMIO Bar is %x\n", WlanMmioSpace)); + // + // BIOS notify the uCode that RSR flow is needed + // + MmioWrite32 ((WlanMmioSpace + 0x58), 0x40); + // + // BIOS waiting for uCode to do the all necessary preparation and set a timer of 100 ms. + // + Timeout = 0; + while ((MmioRead32 (WlanMmioSpace + 0x54) & BIT7) == 0 && Timeout < MAX_UCODE_TIMEOUT) { + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS); + Timeout++; + } + + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: The Timeout value is %x and Register 0x54 is %x\n", Timeout, MmioRead32 (WlanMmioSpace + 0x54))); + if (Timeout < MAX_UCODE_TIMEOUT) { + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS * 100); + // + // Perform WLAN Shared HW reset + // + MmioWrite32 ((WlanMmioSpace + 0x20), BIT7); + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS * 50); + // + // Re-Enable MAC Clock + // + MmioWrite32 ((WlanMmioSpace + 0x24), BIT2); + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS * 50000); + // + // De-Reset the MAC + // + MmioAnd32 ((UINTN) (WlanMmioSpace + 0x20), (UINT32) (~BIT0)); + StallPpi->Stall (PeiServices, StallPpi, STALL_1_MICROSECONDS * 50); + + // + // Enabled PME again + // + MmioOr16 ((EpBase + PMCSR), BIT8); + // + // Persistence ON + // + MmioOr32 ((WlanMmioSpace + 0x00), BIT30); + + // + // Set the WLAN device to D3 + // + MmioOr8 ((UINTN) (EpBase + PMCSR), BIT0 + BIT1); + + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: RSR is successfully\n")); + } + } + } + } + } + + // + // WLAN D3 Workaround + // + for (WlanSkusDeviceIdIndex = 0; WlanSkusDeviceIdIndex < sizeof (mWlanSkusDeviceIdsTable2) / sizeof (mWlanSkusDeviceIdsTable2[0]); WlanSkusDeviceIdIndex++) { + if (mWlanSkusDeviceIdsTable2[WlanSkusDeviceIdIndex] == MmioRead16 (EpBase + R_PCH_PCIE_DEVICE_ID)) { + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: Found a device to support D3 and device ID is %x\n", MmioRead16 (EpBase + R_PCH_PCIE_DEVICE_ID))); + + // + // Find out PMCSR register + // + CapPtr = MmioRead8 (EpBase + R_PCH_PCIE_CAPP); + CapID = MmioRead8 (EpBase + CapPtr); + NxtPtr = (UINT8) (MmioRead16 (EpBase + CapPtr) >> 8); + PMCreg = CapPtr; + + while (CapID != 0x01) { + CapID = MmioRead8 (EpBase + NxtPtr); + if (CapID == 0x01) { + PMCreg = NxtPtr; + break; + } + NxtPtr = (UINT8) (MmioRead16 (EpBase + NxtPtr) >> 8); + + if (NxtPtr == 0){ + PMCreg = 0; + break; + } + } + + if (PMCreg != 0) { + PMCSR = PMCreg + 0x04; + + // + // Check whether PME enabled + // + if (MmioRead16 (EpBase + PMCSR) & BIT8) { + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: This device PME has been enabled\n")); + + // + // Set the WLAN device to D3 + // + MmioOr8 ((UINTN) (EpBase + PMCSR), BIT0 + BIT1); + + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect: D3 is successfully\n")); + } + } + } + } + + /// + /// Restore bus numbers on the WLAN bridge. + /// + MmioAnd32(RpBase + R_PCH_PCIE_BNUM, 0xFF0000FF); + } + } + } + DEBUG ((EFI_D_INFO, "RapidStartWANetDetect End\n")); + + return EFI_SUCCESS; +} + +/** + This callback is executed to clear all PEM events before Rapid Start enter S4. + + @retval EFI_SUCCESS - Operation successfully performed +**/ +EFI_STATUS +RapidStartClearOemPmeEvent ( + VOID + ) +{ + UINT16 EhciPme, Ehci2Pme, xHciPme; + UINT8 Index; + UINT16 PCIePme[8]; + UINT16 GigaLanPme; + + DEBUG ((EFI_D_INFO, "RapidStartClearOemPmeEvent Start\n")); + + // + // Save Ehci, Ehci2 and xHci Power Control Status register + // + EhciPme = MmioRead16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB, + PCI_FUNCTION_NUMBER_PCH_EHCI, + R_PCH_EHCI_PWR_CNTL_STS) + ); + Ehci2Pme = MmioRead16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB_EXT, + PCI_FUNCTION_NUMBER_PCH_EHCI2, + R_PCH_EHCI_PWR_CNTL_STS) + ); + xHciPme = MmioRead16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_XHCI, + PCI_FUNCTION_NUMBER_PCH_XHCI, + R_PCH_XHCI_PWR_CNTL_STS) + ); + // + // Disabled Ehci, Ehcu2 and xHci PME & Clear PME status + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB, + PCI_FUNCTION_NUMBER_PCH_EHCI, + R_PCH_EHCI_PWR_CNTL_STS), + ((EhciPme & ~B_PCH_EHCI_PWR_CNTL_STS_PME_EN) | B_PCH_EHCI_PWR_CNTL_STS_PME_STS) + ); + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB_EXT, + PCI_FUNCTION_NUMBER_PCH_EHCI2, + R_PCH_EHCI_PWR_CNTL_STS), + ((Ehci2Pme & ~B_PCH_EHCI_PWR_CNTL_STS_PME_EN) | B_PCH_EHCI_PWR_CNTL_STS_PME_STS) + ); + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_XHCI, + PCI_FUNCTION_NUMBER_PCH_XHCI, + R_PCH_XHCI_PWR_CNTL_STS), + ((xHciPme & ~B_PCH_XHCI_PWR_CNTL_STS_PME_EN) | B_PCH_XHCI_PWR_CNTL_STS_PME_STS) + ); + + for (Index = 0; Index <= PCI_FUNCTION_NUMBER_PCH_PCIE_ROOT_PORT_8; Index++) { + // + // Save PCIEs Power Control Status register + // + PCIePme[Index] = MmioRead16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_PCIE_ROOT_PORTS, + (PCI_FUNCTION_NUMBER_PCH_PCIE_ROOT_PORT_1 + Index), + R_PCH_PCIE_PMCS) + ); + // + // Disabled PCIEs PME & Clear PME status + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_PCIE_ROOT_PORTS, + (PCI_FUNCTION_NUMBER_PCH_PCIE_ROOT_PORT_1 + Index), + R_PCH_PCIE_PMCS), + ((PCIePme[Index] & ~B_PCH_PCIE_PMCS_PMEE) | B_PCH_PCIE_PMCS_PMES) + ); + } + + // + // Save Giga Lan Power Control Status register + // + GigaLanPme = MmioRead16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_LAN, + PCI_FUNCTION_NUMBER_PCH_LAN, + R_PCH_LAN_PMCS) + ); + // + // Disabled Giga Lan PME & Clear PME status + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_LAN, + PCI_FUNCTION_NUMBER_PCH_LAN, + R_PCH_LAN_PMCS), + ((GigaLanPme & ~B_PCH_LAN_PMCS_PMEE) | B_PCH_LAN_PMCS_PMES) + ); + + // + // Restore Ehci, Ehci2 and xHci Power Control Status register + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB, + PCI_FUNCTION_NUMBER_PCH_EHCI, + R_PCH_EHCI_PWR_CNTL_STS), + EhciPme + ); + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_USB_EXT, + PCI_FUNCTION_NUMBER_PCH_EHCI2, + R_PCH_EHCI_PWR_CNTL_STS), + Ehci2Pme + ); + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_XHCI, + PCI_FUNCTION_NUMBER_PCH_XHCI, + R_PCH_XHCI_PWR_CNTL_STS), + xHciPme + ); + + // + // XHCI's previous state is D3(this is woken from S3). In the RapidStartEntry, + // when preparing to enter into S4, put XHCI into D3(fix the auto wake-up issue). + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_XHCI, + PCI_FUNCTION_NUMBER_PCH_XHCI, + R_PCH_XHCI_PWR_CNTL_STS), + (xHciPme | V_PCH_XHCI_PWR_CNTL_STS_PWR_STS_D3) + ); + + // + // Restore PCIEs Power Control Status register + // + + for (Index = 0; Index <= PCI_FUNCTION_NUMBER_PCH_PCIE_ROOT_PORT_8; Index++) { + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_PCIE_ROOT_PORTS, + (PCI_FUNCTION_NUMBER_PCH_PCIE_ROOT_PORT_1 + Index), + R_PCH_PCIE_PMCS), + PCIePme[Index] + ); + } + + // + // Restore Giga Lan Power Control Status register + // + MmioWrite16 ( + MmPciAddress ( + 0, + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_LAN, + PCI_FUNCTION_NUMBER_PCH_LAN, + R_PCH_LAN_PMCS), + GigaLanPme + ); + + DEBUG ((EFI_D_INFO, "RapidStartClearOemPmeEvent End\n")); + + return EFI_SUCCESS; +} + +/** + Provide a hook for OEM to cancel RapidStart Instant-On function. + This function may impact RapidStart Resume performance since it's polled frequently. + + @retval FALSE - Do not cancel RapidStart Instant-On + @retval TRUE - The RapidStart Resume will have no Instant-On function +**/ +BOOLEAN +RapidStartUnattendedWake ( + VOID + ) +{ + + return FALSE; +} +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.cif b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.cif new file mode 100644 index 0000000..8469e48 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.cif @@ -0,0 +1,15 @@ +<component> + name = "RapidStartPeiLib" + category = ModulePart + LocalRoot = "Board\EM\RapidStartWrapper\Library\RapidStartPlatformLib\Pei" + RefName = "RapidStartPeiLib" +[files] +"RapidStartPeiLib.sdl" +"RapidStartPeiLib.mak" +"RapidStartPeiLib.c" +"RapidStartPeiLib.h" +"RapidStartPeiLib.inf" +"RapidStartPeiLib.lib" +"PeiCryptLib.lib" +"OpensslLib.lib" +<endComponent> diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.h b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.h new file mode 100644 index 0000000..7eb2422 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.h @@ -0,0 +1,306 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.h 2 12/18/12 12:19a Bensonlai $ +// +// $Revision: 2 $ +// +// $Date: 12/18/12 12:19a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.h $ +// +// 2 12/18/12 12:19a Bensonlai +// [TAG] EIP109701 +// [Category] Spec Update +// [Severity] Normal +// [Description] Updated to Shark Bay Rapid Start Reference Code +// Version 0.8.1 +// [Files] RapidStartPeiLib.c, RapidStartPeiLib.h +// +// 1 10/15/12 4:41a Bensonlai +// [TAG] EIPNone +// [Category] Improvement +// [Description] [Category] Improvement +// [Severity] Important +// [Description] Rename all IFFS sting to Rapid Start. +// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +// [Files] RapidStartPeiLib.cif +// RapidStartPeiLib.sdl +// RapidStartPeiLib.mak +// RapidStartPeiLib.c +// RapidStartPeiLib.h +// RapidStartPeiLib.inf +// RapidStartPeiLib.lib +// PeiCryptLib.lib +// OpensslLib.lib +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: RapidStartPeiLib.h +// +// Description: Defines and prototypes for the library module. +// +//<AMI_FHDR_END> +//********************************************************************** + +#ifndef _RAPID_START_PEI_LIB_H_ +#define _RAPID_START_PEI_LIB_H_ + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "RapidStartConfig.h" +#include EFI_PPI_DEFINITION (RapidStart) +#endif + +#ifndef RAPID_START_NO_SMRAM_INTEGRITY_CHECK +// +// Secure hash definitions for SMRAM integrity check +// +#include "BaseCryptLib.h" +#define RAPID_START_SECURE_HASH_LENGTH SHA256_DIGEST_SIZE +#define IfsSecureHashGetContextSize() (Sha256GetContextSize ()) +#define RapidStartSecureHashInit(state) (Sha256Init (state)) +#define RapidStartSecureHashUpdate(state, data, len) (Sha256Update ((state), (data), (len))) +#define RapidStartSecureHashFinal(state, output) (Sha256Final ((state), (output))) + +/** + Saves SMRAM Secure Hash to non-volatile secure location. + + Only available when "RAPID_START_NO_SMRAM_INTEGRITY_CHECK" not defined. This + function requires porting to support SMRAM Hash algorithm. + + This function will save SMRAM Hash value into non-volatile memory, platform code + has to provide the available non-volatile memory space and modify this function + to save SMRAM Hash value into that space. Reference code by default uses SHA256 + hashing algorithm in UDK2010 "Crypto library". See section "Porting + Recommendation" for more information. The hash needs to be as strong as the + one used to produce security measurements stored in the TPM, so as to not weaken + the overall security level provided by the platform. + "RAPID_START_SECURE_HASH_LENGTH" is defined as "SHA256_DIGEST_SIZE", + which is defined as 32 in BaseCryptLib.h See "Porting Recommendation" + section in this document for SMRAM Hashing implementation. + + @param[in] Hash[] - hash value + + @retval EFI_SUCCESS - Hash value has been saved successfully + @retval EFI_NOT_FOUND - Hash value not found +**/ +EFI_STATUS +RapidStartSaveSecureHash ( + IN UINT8 Hash[RAPID_START_SECURE_HASH_LENGTH] + ); + +/** + Retrieves and removes SMRAM hash from non-volatile memory + + Only available when "RAPID_START_NO_SMRAM_INTEGRITY_CHECK" not defined. This + function requires porting to support SMRAM Hash algorithm. + + This function will retrieve SMRAM Hash value from non-volatile memory and then + remove it from non-volatile memory. Platform code has to provide the available + non-volatile memory space and modify this function to retrieve SMRAM Hash value + from that space. After hash value retrieved, the hash value has to be scrubbed + from non-volatile memory immediately. Reference code by default uses SHA256 + hashing algorithm in UDK2010 "Crypto library". See section "Porting + Recommendation" for more information. The hash needs to be as strong as the + one used to produce security measurements stored in the TPM, so as to not weaken + the overall security level provided by the platform. + "RAPID_START_SECURE_HASH_LENGTH" is defined as "SHA256_DIGEST_SIZE", + which is defined as 32 in BaseCryptLib.h + + @param[out] Hash[] - hash value + + @retval EFI_SUCCESS - Hash value has been restored and cleared successfully + @retval EFI_NOT_FOUND - Hash value not found +**/ +EFI_STATUS +RapidStartRestoreAndClearSecureHash ( + OUT UINT8 Hash[RAPID_START_SECURE_HASH_LENGTH] + ); + +#endif /* RAPID_START_NO_SMRAM_INTEGRITY_CHECK */ + +/** + Enables ACPI mode after RapidStart resume. + + This function will do the platform specific initialization for switching to ACPI + mode by issuing ACPI_ENABLE SWSMI in the end of Rapid Start Exit transition. OS + will treat Rapid Start Exit as same as regular S3 resume so it will not + re-initialize certain tasks, like ACPI_ENABLE SMI will be skipped by OS, but + those tasks still required for Rapid Start Exit because it could be resume from + S4 or G3 state. This function may need some porting to fit platform design. + + @param[in] PeiServices - Pointer to PEI Services Table. + + @retval EFI_SUCCESS - enabled ACPI mode +**/ +EFI_STATUS +RapidStartEnableAcpi ( + IN EFI_PEI_SERVICES **PeiServices + ); + +/** + This callback is provided to support drive password locking interoperability with RapidStart. + It is called before RapidStart transition is to occur. If SSD partiotion is located on password + locked drive this function must copy the password to the output buffer. + Size of the buffer equals ATA_PASSWORD_LEN. + + Normally the drive password is kept in SMRAM so it can be used to unlock the drive at S3 resume, + thus during RapidStartEntry the password from SMRAM shall be returned. However at RapidStartExit the content + of SMRAM is not yet available so the password has to be preserved in a non-volatile memory + during RapidStartEntry (in RapidStartAfterTransition callback) and retrieved by this function. + + For security reasons the password must be scrubbed from non-volatile memory on RapidStartExit before + returning from this function. On RapidStartEntry the password must not be stored to non-volatile memory + sooner than RapidStartAfterTransition is called (that is after RapidStart non-volatile flag is set). + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] SataPort - locked SATA port + @param[out] Password - output buffer to place the password in + @param[out] FreezeLock - set to TRUE to freeze drive lock, set to FALSE otherwise + + @retval EFI_SUCCESS - Unlock password copied to the buffer + @retval EFI_NOT_FOUND - No password provided (will break the transition) +**/ +EFI_STATUS +RapidStartGetDriveUnlockPassword ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN UINT8 SataPort, + OUT UINT8 *Password, + OUT BOOLEAN *FreezeLock + ); + +/** + This callback is executed before RapidStart transition is performed, but after RapidStart transition conditions has been met. + + This callback is executed before Rapid Start transition is performed, but after + Rapid Start transition conditions have been met. This callback provides + capability to cancel Rapid Start transition if required by platform specific + condition. + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] SataPort - SATA port of RapidStart storage drive + + @retval EFI_SUCCESS - RapidStart transition will follow + @retval EFI_ABORTED - RapidStart transition will not be performed +**/ +EFI_STATUS +RapidStartBeforeTransition ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN UINT8 SataPort + ); + +/** + This callback is executed at the end of RapidStart transition whether succesfull ot not. + + If RapidStart partition is located on password locked drive the drive password must be + copied to non-volatile memory during RapidStartEntry in this function, so it is available + on RapidStartExit (see RapidStartGetDriveUnlockPassword). + + @param[in] PeiServices - Pointer to PEI Services Table + @param[in] Transition - RapidStart transition being performed + @param[in] TransitionStatus - Status of the RapidStart transition + @param[in] SataPort - SATA port of RapidStart storage drive +**/ +VOID +RapidStartAfterTransition ( + IN EFI_PEI_SERVICES **PeiServices, + IN RAPID_START_TRANSITION Transition, + IN EFI_STATUS TransitionStatus, + IN UINT8 SataPort + ); + +/** + Provide a hook for OEM to cancel RapidStart flow. + This function may impact RapidStart Entry performance since it's polled frequently. + + This routine is a callback for platform designer to cancel the Rapid Start Entry + process and do S3 resume back to OS immediately (e.g. Lid opening). Since the + time for Rapid Start Entry might be long and user might want to cancel it for + any urgent scenario. This required condition check for when the Rapid Start + Entry should be canceled. Note: This callback will be polled frequently during + Rapid Start Entry process, so the implementation may impact Rapid Start Entry + performance. + + A callback for platform designer to cancel Rapid Start Entry process when + specific condition happened (e.g. Lid opening). This is optional, required + porting and might impact Rapid Start Entry performance. + + @retval FALSE - Do not cancel RapidStart flow + @retval TRUE - The RapidStart Entry flow should be canceled and do S3 resume back to OS +**/ +BOOLEAN +RapidStartShouldCancelEntry ( + VOID + ); + +/** + This callback is executed to clear all PEM events before Rapid Start enter S4. + + @retval EFI_SUCCESS - Operation successfully performed +**/ +EFI_STATUS +RapidStartClearOemPmeEvent ( + VOID + ); + +// +// Max uCode time out is 100 Milli second +// +#define MAX_UCODE_TIMEOUT 100000 +#define STALL_1_MICROSECONDS 1 + +/** + This function is work around for NetDetect and WakeOnLan when RapidStart enabled. + + @param EFI_SUCCESS - Operation successfully performed +**/ +EFI_STATUS +RapidStartWANetDetect ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT32 WlanMmioSpace + ); + +/** + Provide a hook for OEM to cancel RapidStart Instant-On function. + This function may impact RapidStart Resume performance since it's polled frequently. + + @retval FALSE - Do not cancel RapidStart Instant-On + @retval TRUE - The RapidStart Resume will have no Instant-On function +**/ +BOOLEAN +RapidStartUnattendedWake ( + VOID + ); +#endif +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.inf b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.inf new file mode 100644 index 0000000..1737737 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.inf @@ -0,0 +1,63 @@ +## @file +# Component description file for the RapidStart Peim library +# +#@copyright +# Copyright (c) 2004 - 2012 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# This file contains a 'Sample Driver' and is licensed as such +# under the terms of your license agreement with Intel or your +# vendor. This file may be modified by the user, subject to +# the additional terms of the license agreement +# + +[defines] +BASE_NAME = RapidStartPeiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + RapidStartPeiLib.h + RapidStartPeiLib.c + +[includes.common] + . + $(EDK_SOURCE)/Foundation/Library/Pei/Include + $(EDK_SOURCE)/Foundation/Efi + $(EDK_SOURCE)/Foundation/Include + $(EDK_SOURCE)/Foundation/Efi/Include + $(EDK_SOURCE)/Foundation/Framework/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include/Library + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT) + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Samplecode/Library/RapidStartCommonLib + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT) + $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_ME_ROOT) + $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Include + $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include + +# +# EDK II Glue Library utilizes some standard headers from EDK +# + $(EFI_SOURCE) + $(EDK_SOURCE)/Foundation + $(EDK_SOURCE)/Foundation/Framework + $(EDK_SOURCE)/Foundation/Include/IndustryStandard + $(EDK_SOURCE)/Foundation/Core/Dxe + $(EDK_SOURCE)/Foundation/Include/Pei + $(EDK_SOURCE)/Foundation/Library/Dxe/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include + $(EFI_SOURCE)/Include + +[libraries.common] + PchPlatformLib + +[nmake.common] +C_STD_INCLUDE= + diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.lib b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.lib Binary files differnew file mode 100644 index 0000000..e308456 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.lib diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.mak b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.mak new file mode 100644 index 0000000..ef8eef4 --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.mak 1 10/15/12 4:41a Bensonlai $ +# +# $Revision: 1 $ +# +# $Date: 10/15/12 4:41a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.mak $ +# +# 1 10/15/12 4:41a Bensonlai +# [TAG] EIPNone +# [Category] Improvement +# [Description] [Category] Improvement +# [Severity] Important +# [Description] Rename all IFFS sting to Rapid Start. +# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +# [Files] RapidStartPeiLib.cif +# RapidStartPeiLib.sdl +# RapidStartPeiLib.mak +# RapidStartPeiLib.c +# RapidStartPeiLib.h +# RapidStartPeiLib.inf +# RapidStartPeiLib.lib +# PeiCryptLib.lib +# OpensslLib.lib +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: RapidStartPeiLib.mak +# +# Description: Component description file for the RapidStart Peim library +# +#<AMI_FHDR_END> +#********************************************************************** + +all : RapidStartPeiLib + +$(RapidStartPeiLib_LIB) : RapidStartPeiLib + +RapidStartPeiLib : $(BUILD_DIR)\RapidStartPeiLib.mak RapidStartPeiLibBin + +$(BUILD_DIR)\RapidStartPeiLib.mak : $(RapidStartPeiLib_DIR)\$(@B).cif $(RapidStartPeiLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(RapidStartPeiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +RapidStartPeiLibBin : + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + /f $(BUILD_DIR)\RapidStartPeiLib.mak all\ + "MY_INCLUDES=$(EDK_INCLUDES) $(EdkIIGlueLib_INCLUDES) $(NB_INCLUDES) $(INTEL_MCH_INCLUDES) $(INTEL_PCH_INCLUDES) $(RAPIDSTART_INCLUDES)" \ + TYPE=PEI_LIBRARY \ + LIBRARY_NAME=$(RapidStartPeiLib_LIB) +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.sdl b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.sdl new file mode 100644 index 0000000..7ea853b --- /dev/null +++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.sdl @@ -0,0 +1,101 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.sdl 1 10/15/12 4:41a Bensonlai $ +# +# $Revision: 1 $ +# +# $Date: 10/15/12 4:41a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartPeiLib/RapidStartPeiLib.sdl $ +# +# 1 10/15/12 4:41a Bensonlai +# [TAG] EIPNone +# [Category] Improvement +# [Description] [Category] Improvement +# [Severity] Important +# [Description] Rename all IFFS sting to Rapid Start. +# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.* +# [Files] RapidStartPeiLib.cif +# RapidStartPeiLib.sdl +# RapidStartPeiLib.mak +# RapidStartPeiLib.c +# RapidStartPeiLib.h +# RapidStartPeiLib.inf +# RapidStartPeiLib.lib +# PeiCryptLib.lib +# OpensslLib.lib +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: RapidStartPeiLib.sdl +# +# Description: SDL file for the RapidStart Peim library +# +#<AMI_FHDR_END> +#********************************************************************** + +TOKEN + Name = "RapidStartPeiLib_SUPPORT" + Value = "1" + Help = "Main switch to enable RapidStartPeiLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +PATH + Name = "RapidStartPeiLib_DIR" +End + +MODULE + Help = "Includes RapidStartPeiLib.mak to Project" + File = "RapidStartPeiLib.mak" +End + +ELINK + Name = "RapidStartPeiLib_LIB" + InvokeOrder = ReplaceParent +End + +ELINK + Name = "$(BUILD_DIR)\RapidStartPeiLib.lib" + Parent = "RapidStartPeiLib_LIB" + InvokeOrder = AfterParent +End + +ELINK + Name = "/I$(RapidStartPeiLib_DIR)" + Parent = "RAPIDSTART_INCLUDES" + InvokeOrder = AfterParent +End + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* |