summaryrefslogtreecommitdiff
path: root/Board/EM/RapidStartWrapper
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/RapidStartWrapper
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Board/EM/RapidStartWrapper')
-rw-r--r--Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.cif9
-rw-r--r--Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.sdl102
-rw-r--r--Board/EM/RapidStartWrapper/AcpiTables/Ssdt/RapidStartWrapper.asl131
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c626
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.cif13
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs76
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h187
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.inf74
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak165
-rw-r--r--Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl94
-rw-r--r--Board/EM/RapidStartWrapper/Include/Mbr.h72
-rw-r--r--Board/EM/RapidStartWrapper/Include/UefiGpt.h145
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.c916
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.cif12
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.h374
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.inf54
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.mak103
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.sdl121
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.c722
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.cif12
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.h137
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.inf56
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.mak78
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Dxe/RapidStartDxeLib.sdl98
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/OpensslLib.libbin0 -> 132502 bytes
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.libbin0 -> 115966 bytes
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.c970
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.cif15
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.h306
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.inf63
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.libbin0 -> 105606 bytes
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.mak80
-rw-r--r--Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.sdl101
-rw-r--r--Board/EM/RapidStartWrapper/RapidStart.ssp246
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.c248
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.cif13
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.h76
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.mak97
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sd367
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sdl161
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.unibin0 -> 12256 bytes
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartWrapper.cif19
-rw-r--r--Board/EM/RapidStartWrapper/RapidStartWrapper.sdl219
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.c238
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.cif12
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.dxs92
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.h135
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.mak126
-rw-r--r--Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.sdl120
49 files changed, 8081 insertions, 0 deletions
diff --git a/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.cif b/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.cif
new file mode 100644
index 0000000..4a82a51
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "RapidStartWrapperAcpiTables"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper\AcpiTables"
+ RefName = "RapidStartWrapperAcpiTables"
+[files]
+"RapidStartWrapperAcpiTables.sdl"
+"Ssdt\RapidStartWrapper.asl"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.sdl b/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.sdl
new file mode 100644
index 0000000..e181424
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/AcpiTables/RapidStartWrapperAcpiTables.sdl
@@ -0,0 +1,102 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartWrapperAcpiTables.sdl 2 4/15/13 2:38a Bensonlai $
+#
+# $Revision: 2 $
+#
+# $Date: 4/15/13 2:38a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperAcpiTables.sdl $
+#
+# 2 4/15/13 2:38a Bensonlai
+# [TAG] None
+# [Category] Bug Fix
+# [Severity] Important
+# [Symptom] If users change any item from driver then restore to boot
+# setting, our SMI can't distinguish between user's and driver's event.
+# [RootCause] It's an Intel driver issue.
+# [Solution] 1. Removing the sync up with Rapid Start driver and BIOS
+# variable as default.
+# 2. Remove our BIOS workaround.
+# [Files] RapidStartWrapperSmm.sdl, RapidStartWrapperSmm.h,
+# RapidStartWrapperSmm.sdl, RapidStartWrapperAcpiTables.sdl,
+# RapidStartWrapper.sdl
+#
+# 1 12/27/12 2:25a Bensonlai
+# [TAG] EIP110680
+# [Category] New Feature
+# [Description] When iRST application is run under OS, and change
+# timer.
+# BIOS should update the changed to Setup option as well.
+# [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+# Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+# Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartWrapperAcpiTables.sdl
+#
+# Description: SDL file for RapidStartWrapperAcpiTables
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "RapidStartWrapperAcpiTables_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStartWrapper ACPI tables in Project"
+ Token = "SYNC_UP_DRIVER_AND_BIOS_VARIABLE" "=" "1"
+End
+
+PATH
+ Name = "RapidStartWrapperAcpiTables_DIR"
+End
+
+TOKEN
+ Name = "INTEL_RAPIDSTART_ASL_FILE"
+ Value = "$(RapidStartWrapperAcpiTables_DIR)\Ssdt\RapidStartWrapper.asl"
+ TokenType = Expression
+ TargetMAK = Yes
+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/AcpiTables/Ssdt/RapidStartWrapper.asl b/Board/EM/RapidStartWrapper/AcpiTables/Ssdt/RapidStartWrapper.asl
new file mode 100644
index 0000000..ad41ac1
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/AcpiTables/Ssdt/RapidStartWrapper.asl
@@ -0,0 +1,131 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Ssdt/RapidStartWrapper.asl 1 12/27/12 2:25a Bensonlai $
+//
+// $Revision: 1 $
+//
+// $Date: 12/27/12 2:25a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/Ssdt/RapidStartWrapper.asl $
+//
+// 1 12/27/12 2:25a Bensonlai
+// [TAG] EIP110680
+// [Category] New Feature
+// [Description] When iRST application is run under OS, and change
+// timer.
+// BIOS should update the changed to Setup option as well.
+// [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+// Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+// Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartWrapper.asl
+//
+// Description: RapidStart ACPI ASL code to support OS control
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+DefinitionBlock (
+ "RapidStart.aml",
+ "SSDT",
+ 0x01,
+ "Iffs",
+ "IffsAsl",
+ 0x3000
+ )
+{
+
+ Scope (\_SB) {
+ Device(IFFS) {
+ OperationRegion(FFSN,SystemMemory,0xFFFF0000,0xAA55)
+ Field(FFSN,AnyAcc,Lock,Preserve)
+ {
+ FFSA, 8, // (0) iFFS available events
+ FFSS, 8, // (1) iFFS enabled events
+ FFST, 16, // (2) iFFS wake timer in minutes
+ FFSP, 32 // (4) iFFS performance monitoring data
+ }
+
+//AMIOVERRIDE_BEGIN
+ OperationRegion (RSMI, SystemIO, 0xB2, 0x02)
+ Field (RSMI, ByteAcc, NoLock, Preserve) {
+ SMIC, 8,
+ SMID, 8
+ }
+//AMIOVERRIDE_END
+
+ Name(_HID,EISAID("INT3392"))
+ Name(_CID,EISAID("PNP0C02"))
+
+ Method(GFFS,0,Serialized) {
+ Return(FFSS)
+ }
+ Method(SFFS,1,Serialized) {
+ And(Arg0, FFSA, FFSS)
+//AMIOVERRIDE_BEGIN
+ Store(0x01, SMID)
+ Store(0xB4, SMIC)
+//AMIOVERRIDE_END
+ Return(FFSS)
+ }
+ Method(GFTV,0,Serialized) {
+ Return(FFST)
+ }
+ Method(SFTV,1,Serialized) {
+ //
+ // 24*60=1440 minutes (24 Hours)
+ //
+ If (LLessEqual(Arg0,1440)) {
+ Store(Arg0,FFST)
+ } Else {
+ And(FFSS,0xFFFE,FFSS)
+ Store(10,FFST)
+ }
+//AMIOVERRIDE_BEGIN
+ Store(0x01, SMID)
+ Store(0xB4, SMIC)
+//AMIOVERRIDE_END
+ Return(FFST)
+ }
+ }
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c
new file mode 100644
index 0000000..87b9146
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c
@@ -0,0 +1,626 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c 9 5/13/14 4:55a Joshchou $
+//
+// $Revision: 9 $
+//
+// $Date: 5/13/14 4:55a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxePolicyInit/RapidStartDxePolicyInit.c $
+//
+// 9 5/13/14 4:55a Joshchou
+// [TAG] EIP167032
+// [Category] Improvement
+// [Description] Review the variable's attribute, we shouldn't use
+// runtime attribute with setup variable.
+// [Files] RapidStartDxePolicyInit.h
+// RapidStartDxePolicyInit.c
+// RapidStartDxePolicyInit.cif
+//
+// 8 6/21/13 5:59a 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.
+//
+// 7 1/15/13 4:44a Bensonlai
+// [TAG] EIP112263
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] [RapidStart] Instant-on can't work
+// [RootCause] Intel reference code can't work on AMI base.
+// [Solution] Modified the PeiGfxDriver.dxs and RapidStartDxe.dxs for
+// AMI code
+// [Files] RapidStartDxePolicyInit.c, RapidStartSetup.uni,
+// RapidStartSetup.sdl, RapidStartSetup.sd, PeiGfxDriver.dxs,
+// RapidStartDxe.dxs
+//
+// 6 1/13/13 7:46a Bensonlai
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Disabling the RapidStart while STAT mode in the IDE
+// mode
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+// RapidStartSetup.sd, RapidStartSetup.sdl
+//
+// 5 12/11/12 10:59p Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] Removed unused code
+// [Files] RapidStartDxePolicyInit.c
+//
+// 4 12/07/12 1:15a Bensonlai
+// [TAG] None
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When installed memory size less than HDD partition size of
+// teh RapidStart, it still can work.
+// [RootCause] The RAPID_START_PERSISTENT_DATA wasn't updated in the
+// BdsAllDriversConnectedCallback().
+// [Solution] Get the real total size of memory directly.
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak
+//
+// 3 12/03/12 2:12a Bensonlai
+// [TAG] EIP107865
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] While system has no disk drives, we still free the null
+// pointer IdentifyDriveInfo/HandleBuffer and that will cause an assert
+// error with DEBUG_MODE=1.
+// [Solution] Improved the function of SsdDetection.
+//
+// 2 11/15/12 12:24a Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] Move the RAPID_START_PARTITION_DETECT_BEFORE_SETUP to
+// RapidStartDxePolicyInit.c
+//
+// 1 10/15/12 4:40a Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] [Category] Improvement
+// [Severity] Important
+// [Description] Rename all IFFS sting to Rapid Start.
+// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+//
+// [Category] Improvement
+// [Severity] Important
+// [Description] Implementation of the LOCK_DISABLE_RAPID_START_IF_NO_SSD
+// using EDKII.
+// [Files] Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit\*.*
+// [Files] RapidStartDxePolicyInit.cif
+// RapidStartDxePolicyInit.sdl
+// RapidStartDxePolicyInit.mak
+// RapidStartDxePolicyInit.h
+// RapidStartDxePolicyInit.c
+// RapidStartDxePolicyInit.dxs
+// RapidStartDxePolicyInit.inf
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartDxePolicyInit.c
+//
+// Description: This file is a wrapper for Intel RapidStart Platform Policy driver.
+// Get Setup Value to initilize Intel DXE Platform Policy.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "RapidStartDxePolicyInit.h"
+
+RAPID_START_PLATFORM_POLICY_PROTOCOL mDxePlatformRapidStartPolicy;
+EFI_GUID gRapidStartPlatformPolicyProtocolGuid = RAPID_START_PLATFORM_POLICY_PROTOCOL_GUID;
+
+//
+// Function implementations
+//
+#if LOCK_DISABLE_RAPID_START_IF_NO_SSD
+BOOLEAN SsdDetection (
+ VOID
+)
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINT8 Index;
+ PCI_DEVICE_PATH *PciDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ EFI_DISK_INFO_PROTOCOL *DiskInfo;
+ EFI_IDENTIFY_DATA *IdentifyDriveInfo;
+ UINT32 BufferSize = 0;
+
+ Status = gBS->LocateHandleBuffer ( ByProtocol, \
+ &gEfiDiskInfoProtocolGuid, \
+ NULL, \
+ &HandleCount, \
+ &HandleBuffer \
+ );
+
+ if ( EFI_ERROR(Status) ) return FALSE;
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol ( HandleBuffer[Index], \
+ &gEfiDevicePathProtocolGuid, \
+ (VOID *) &DevicePath \
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ continue;
+ }
+
+ DevicePathNode = DevicePath;
+ while (!IsDevicePathEnd (DevicePathNode)) {
+ if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (DevicePathNode) == HW_PCI_DP)
+ ) {
+ PciDevicePath = (PCI_DEVICE_PATH *) DevicePathNode;
+ break;
+ }
+
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+
+
+ if (PciDevicePath == NULL) continue;
+
+ if ( ((PciDevicePath->Device == PCI_DEVICE_NUMBER_PCH_SATA) && (PciDevicePath->Function == PCI_FUNCTION_NUMBER_PCH_SATA)) ||
+ ((PciDevicePath->Device == PCI_DEVICE_NUMBER_PCH_SATA) && (PciDevicePath->Function == PCI_FUNCTION_NUMBER_PCH_SATA2)) ) {
+
+ Status = gBS->HandleProtocol ( HandleBuffer[Index], \
+ &gEfiDiskInfoProtocolGuid, \
+ &DiskInfo \
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ continue;
+ }
+
+ BufferSize = sizeof (EFI_IDENTIFY_DATA);
+ IdentifyDriveInfo = AllocatePool (BufferSize);
+ if (IdentifyDriveInfo == NULL) {
+ FreePool (HandleBuffer);
+ return FALSE;
+ }
+
+ Status = DiskInfo->Identify (
+ DiskInfo,
+ IdentifyDriveInfo,
+ &BufferSize
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ FreePool (IdentifyDriveInfo);
+ continue;
+ }
+
+ if (IdentifyDriveInfo->AtaData.reserved_160_255[57] == 0x0001) {
+ FreePool (IdentifyDriveInfo);
+ FreePool (HandleBuffer);
+ return TRUE;
+ }
+
+ FreePool (IdentifyDriveInfo);
+ }
+ }
+
+ if (HandleCount > 0) {
+ FreePool (HandleBuffer);
+ }
+ return FALSE;
+}
+
+VOID
+SsdDetectionCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+
+ EFI_STATUS Status;
+ UINTN VariableSize;
+ SETUP_DATA SetupData;
+ UINT32 Attributes = 0;
+
+ VariableSize = sizeof( SETUP_DATA );
+ Status = gRT->GetVariable( L"Setup", \
+ &SetupGuid, \
+ &Attributes, \
+ &VariableSize, \
+ &SetupData );
+
+ if ( EFI_ERROR(Status) ) {
+ gBS->CloseEvent (Event);
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ if (!SsdDetection()) {
+ SetupData.RapidStartLock = 1;
+ SetupData.RapidStartEnabled = 0;
+ } else {
+ SetupData.RapidStartLock = 0;
+ }
+
+ Status = gRT->SetVariable( L"Setup", \
+ &SetupGuid, \
+ Attributes, \
+ sizeof (SETUP_DATA), \
+ &SetupData
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ gBS->CloseEvent (Event);
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ gBS->CloseEvent (Event);
+}
+
+VOID
+SsdDetectionRegisterCallBack (
+ VOID
+)
+{
+ EFI_EVENT Event;
+ VOID *NotifyReg;
+ EFI_STATUS Status;
+
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ SsdDetectionCallback,
+ NULL,
+ &Event
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gNotifyProtocolGuid ,
+ Event,
+ &NotifyReg
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ return;
+}
+#endif
+
+#ifdef RAPID_START_PARTITION_DETECT_BEFORE_SETUP
+VOID
+BdsAllDriversConnectedCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ EFI_STATUS Status;
+ EFI_GUID RapidStartPartitionProtocolGuid = RAPID_START_PARTITION_STATUS_PROTOCOL_GUID;
+ RAPID_START_PERSISTENT_DATA *mRapidStartData;
+ UINTN MchBase;
+
+ mRapidStartData = AllocateZeroPool (sizeof(RAPID_START_PERSISTENT_DATA));
+ if (mRapidStartData == NULL) {
+ return;
+ }
+
+ MchBase = MmPciAddress (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, 0);
+ mRapidStartData->Tolm = MmioRead32 (MchBase + R_SA_BDSM) & B_SA_BDSM_BDSM_MASK;
+ mRapidStartData->Tohm = MmioRead64 (MchBase + R_SA_TOUUD) & B_SA_TOUUD_TOUUD_MASK;
+ ///
+ /// Calculate total size of memory to be stored
+ ///
+ mRapidStartData->TotalMem = mRapidStartData->Tolm;
+ if (mRapidStartData->Tohm > MEM_EQU_4GB) {
+ mRapidStartData->TotalMem += mRapidStartData->Tohm - MEM_EQU_4GB;
+ }
+
+ //
+ // Rapid Start has been enabled, check if Rapid Start store valid.
+ //
+ Status = SearchRapidStartStore (
+ &mDxePlatformRapidStartPolicy,
+ &(mRapidStartData->StoreSectors),
+ &(mRapidStartData->StoreLbaAddr),
+ &(mRapidStartData->StoreSataPort)
+ );
+ if ( (EFI_ERROR (Status)) ||
+ (MEM_TO_SECT (mRapidStartData->TotalMem) > mRapidStartData->StoreSectors) &&
+ (mDxePlatformRapidStartPolicy.ActivePageThresholdSupport == 0) ) {
+ //
+ } else {
+ Status = gBS->InstallProtocolInterface (
+ &gImageHandle,
+ &RapidStartPartitionProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ gBS->CloseEvent (Event);
+}
+
+VOID
+RegisterForBdsAllDriversConnected (
+ IN EFI_HANDLE ImageHandle
+)
+{
+ EFI_EVENT Event;
+ VOID *NotifyReg;
+ EFI_STATUS Status;
+
+ gImageHandle = ImageHandle;
+
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ BdsAllDriversConnectedCallback,
+ NULL,
+ &Event
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gBdsAllDriversConnectedProtocolGuid,
+ Event,
+ &NotifyReg
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ ASSERT_EFI_ERROR (Status);
+ return;
+ }
+
+ return;
+}
+#endif
+
+#if SYNC_UP_DRIVER_AND_BIOS_VARIABLE
+VOID
+SyncUpDriverAndBiosVariable (
+ VOID
+)
+{
+ EFI_STATUS Status;
+ UINTN VariableSize;
+ RAPID_START_WRAPPER_SMM_DATA RapidStartWrapperSmmData;
+ UINT32 Attributes = 0;
+ SETUP_DATA SetupData;
+
+ VariableSize = sizeof( RAPID_START_WRAPPER_SMM_DATA );
+ Status = gRT->GetVariable( L"RstWrapVar",
+ &RapidStartWrapperSmmDataGuid,
+ &Attributes,
+ &VariableSize,
+ &RapidStartWrapperSmmData );
+
+ //TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE Get Setup Variable RstWrapVar Attributes = %x.\n",Attributes));
+
+ if ( EFI_ERROR (Status) ) {
+ //TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE Get Variable Failed!\n"));
+ return;
+ }
+ else{
+// TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE S3WakeTimerMin = %d\n",RapidStartWrapperSmmData.S3WakeTimerMin));
+// TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE EntryOnS3RtcWake = %x\n",RapidStartWrapperSmmData.EntryOnS3RtcWake));
+// TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE EntryOnS3CritBattWake = %x\n",RapidStartWrapperSmmData.EntryOnS3CritBattWake));
+
+ VariableSize = sizeof( SETUP_DATA );
+ Status = gRT->GetVariable( L"Setup",
+ &SetupGuid,
+ &Attributes,
+ &VariableSize,
+ &SetupData );
+
+// TRACE((-1,"SYNC_UP_DRIVER_AND_BIOS_VARIABLE Get Setup Variable Attributes = %x.\n",Attributes));
+ SetupData.S3WakeTimerMin = RapidStartWrapperSmmData.S3WakeTimerMin;
+ SetupData.EntryOnS3RtcWake = RapidStartWrapperSmmData.EntryOnS3RtcWake;
+ SetupData.EntryOnS3CritBattWake = RapidStartWrapperSmmData.EntryOnS3CritBattWake;
+
+ Status = gRT->SetVariable( L"Setup", \
+ &SetupGuid, \
+ Attributes, \
+ sizeof (SETUP_DATA), \
+ &SetupData );
+
+ return;
+ }
+
+
+}
+#endif
+
+VOID
+SetCriticalBatteryThreshole (
+ IN UINT8 Value
+)
+{
+ UINT8 RtcIndexPort;
+ UINT8 RtcDataPort;
+
+ //
+ // CMOS access registers (using alternative access not to handle NMI bit)
+ //
+ if (FFS_CBTH_DATA_REG < 0x80) {
+ //
+ // First bank
+ //
+ RtcIndexPort = 0x74;
+ RtcDataPort = 0x75;
+ } else {
+ //
+ // Second bank
+ //
+ RtcIndexPort = 0x76;
+ RtcDataPort = 0x77;
+ }
+
+ IoWrite8 (RtcIndexPort, FFS_CBTH_DATA_REG & 0x7F);
+ IoWrite8 (RtcDataPort, Value);
+}
+
+/**
+ Initilize Intel RapidStart DXE Platform Policy
+
+ @param[in] ImageHandle Image handle of this driver.
+ @param[in] SystemTable Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+EFIAPI
+RapidStartDxePolicyInitEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+{
+ EFI_STATUS Status;
+ UINTN VariableSize;
+ SETUP_DATA SetupData;
+ PCH_SERIES PchSeries = GetPchSeries();
+ ///
+ /// Initialize the EFI Driver Library
+ ///
+ ZeroMem (&mDxePlatformRapidStartPolicy, sizeof (RAPID_START_PLATFORM_POLICY_PROTOCOL));
+
+ VariableSize = sizeof( SETUP_DATA );
+ Status = gRT->GetVariable( L"Setup",
+ &SetupGuid,
+ NULL,
+ &VariableSize,
+ &SetupData );
+
+ if ( EFI_ERROR(Status) ) {
+ mDxePlatformRapidStartPolicy.EnableRapidStart = 0;
+ mDxePlatformRapidStartPolicy.EntryOnS3RtcWake = 0;
+ mDxePlatformRapidStartPolicy.S3WakeTimerMin = 0;
+ mDxePlatformRapidStartPolicy.EntryOnS3CritBattWake = 0;
+ mDxePlatformRapidStartPolicy.ActivePageThresholdSupport = 0;
+ mDxePlatformRapidStartPolicy.ActivePageThresholdSize = 0;
+ mDxePlatformRapidStartPolicy.HybridHardDisk = 0;
+ mDxePlatformRapidStartPolicy.DisplaySaveRestore = 0;
+ mDxePlatformRapidStartPolicy.DisplayType = 0;
+ mDxePlatformRapidStartPolicy.RaidModeSataPortNumber = 255;
+ } else {
+ if (PchSeries == PchLp) {
+ if ( SetupData.ULTSataInterfaceMode == 0 ) { //IDE mode
+ mDxePlatformRapidStartPolicy.EnableRapidStart = 0;
+ } else {
+ mDxePlatformRapidStartPolicy.EnableRapidStart = SetupData.RapidStartEnabled;
+ }
+ } else {
+ if ( SetupData.SataInterfaceMode == 0 ) { //IDE mode
+ mDxePlatformRapidStartPolicy.EnableRapidStart = 0;
+ } else {
+ mDxePlatformRapidStartPolicy.EnableRapidStart = SetupData.RapidStartEnabled;
+ }
+ }
+ mDxePlatformRapidStartPolicy.EntryOnS3RtcWake = SetupData.EntryOnS3RtcWake;
+ mDxePlatformRapidStartPolicy.S3WakeTimerMin = SetupData.S3WakeTimerMin;
+ mDxePlatformRapidStartPolicy.EntryOnS3CritBattWake = SetupData.EntryOnS3CritBattWake;
+ mDxePlatformRapidStartPolicy.ActivePageThresholdSupport = SetupData.ActivePageThresholdSupport;
+ mDxePlatformRapidStartPolicy.ActivePageThresholdSize = SetupData.ActivePageThresholdSize;
+ mDxePlatformRapidStartPolicy.HybridHardDisk = SetupData.RapidStartHybridHardDisk;
+ mDxePlatformRapidStartPolicy.DisplaySaveRestore = SetupData.RapidStartDisplaySaveRestore;
+ mDxePlatformRapidStartPolicy.DisplayType = SetupData.RapidStartDisplayType;
+ SetCriticalBatteryThreshole(SetupData.CritBattWakeThreshold);
+
+ ///
+ /// By default set to 255 as not used
+ ///
+ mDxePlatformRapidStartPolicy.RaidModeSataPortNumber = 255;
+ }
+ //AMI_OVERRIDE_FOR_RAPID_START
+ //Clear CMOS RapidStartFlag in DXE
+ RapidStartSetConfig(0);
+ //AMI_OVERRIDE_FOR_RAPID_START
+#if LOCK_DISABLE_RAPID_START_IF_NO_SSD
+ SsdDetectionRegisterCallBack();
+#endif
+
+#ifdef RAPID_START_PARTITION_DETECT_BEFORE_SETUP
+ RegisterForBdsAllDriversConnected(ImageHandle);
+#endif
+
+#if SYNC_UP_DRIVER_AND_BIOS_VARIABLE
+ SyncUpDriverAndBiosVariable();
+#endif
+
+ ///
+ /// Protocol revision number
+ ///
+ mDxePlatformRapidStartPolicy.Revision = DXE_RAPID_START_PLATFORM_POLICY_PROTOCOL_REVISION;
+
+ ///
+ /// FviSmbiosType is the SMBIOS OEM type (0x80 to 0xFF) defined in SMBIOS Type 14 - Group
+ /// Associations structure - item type. FVI structure uses it as SMBIOS OEM type to provide
+ /// version information. The default value is type 221.
+ ///
+ mDxePlatformRapidStartPolicy.FviSmbiosType = 0xDD;
+
+
+ ///
+ /// Install protocol to to allow access to this Policy.
+ ///
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gRapidStartPlatformPolicyProtocolGuid,
+ &mDxePlatformRapidStartPolicy,
+ NULL
+ );
+ if ( EFI_ERROR(Status) ) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.cif b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.cif
new file mode 100644
index 0000000..2edcee5
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "RapidStartDxePolicyInit"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit"
+ RefName = "RapidStartDxePolicyInit"
+[files]
+"RapidStartDxePolicyInit.sdl"
+"RapidStartDxePolicyInit.mak"
+"RapidStartDxePolicyInit.h"
+"RapidStartDxePolicyInit.c"
+"RapidStartDxePolicyInit.dxs"
+"RapidStartDxePolicyInit.inf"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs
new file mode 100644
index 0000000..a785e6d
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs
@@ -0,0 +1,76 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs 1 10/15/12 4:40a Bensonlai $
+//
+// $Revision: 1 $
+//
+// $Date: 10/15/12 4:40a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxePolicyInit/RapidStartDxePolicyInit.dxs $
+//
+// 1 10/15/12 4:40a Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] [Category] Improvement
+// [Severity] Important
+// [Description] Rename all IFFS sting to Rapid Start.
+// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+//
+// [Category] Improvement
+// [Severity] Important
+// [Description] Implementation of the LOCK_DISABLE_RAPID_START_IF_NO_SSD
+// using EDKII.
+// [Files] Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit\*.*
+// [Files] RapidStartDxePolicyInit.cif
+// RapidStartDxePolicyInit.sdl
+// RapidStartDxePolicyInit.mak
+// RapidStartDxePolicyInit.h
+// RapidStartDxePolicyInit.c
+// RapidStartDxePolicyInit.dxs
+// RapidStartDxePolicyInit.inf
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartDxePolicyInit.dxs
+//
+// Description: Dependency expression source file.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "EfiDepex.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+
+DEPENDENCY_START
+ EFI_VARIABLE_ARCH_PROTOCOL_GUID
+DEPENDENCY_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/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h
new file mode 100644
index 0000000..13a5bd0
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h
@@ -0,0 +1,187 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h 6 5/13/14 4:55a Joshchou $
+//
+// $Revision: 6 $
+//
+// $Date: 5/13/14 4:55a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxePolicyInit/RapidStartDxePolicyInit.h $
+//
+// 6 5/13/14 4:55a Joshchou
+// [TAG] EIP167032
+// [Category] Improvement
+// [Description] Review the variable's attribute, we shouldn't use
+// runtime attribute with setup variable.
+// [Files] RapidStartDxePolicyInit.h
+// RapidStartDxePolicyInit.c
+// RapidStartDxePolicyInit.cif
+//
+// 5 6/21/13 6:00a 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.
+//
+// 4 1/13/13 7:47a Bensonlai
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Disabling the RapidStart while STAT mode in the IDE
+// mode
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+// RapidStartSetup.sd, RapidStartSetup.sdl
+//
+// 3 12/07/12 1:16a Bensonlai
+// [TAG] None
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When installed memory size less than HDD partition size of
+// teh RapidStart, it still can work.
+// [RootCause] The RAPID_START_PERSISTENT_DATA wasn't updated in the
+// BdsAllDriversConnectedCallback().
+// [Solution] Get the real total size of memory directly.
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak
+//
+// 2 11/15/12 1:03a Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] Move the RAPID_START_PARTITION_DETECT_BEFORE_SETUP to
+// RapidStartDxePolicyInit.c.
+//
+// 1 10/15/12 4:40a Bensonlai
+// [TAG] None
+// [Category] Improvement
+// [Description] [Category] Improvement
+// [Severity] Important
+// [Description] Rename all IFFS sting to Rapid Start.
+// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+//
+// [Category] Improvement
+// [Severity] Important
+// [Description] Implementation of the LOCK_DISABLE_RAPID_START_IF_NO_SSD
+// using EDKII.
+// [Files] Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit\*.*
+// [Files] RapidStartDxePolicyInit.cif
+// RapidStartDxePolicyInit.sdl
+// RapidStartDxePolicyInit.mak
+// RapidStartDxePolicyInit.h
+// RapidStartDxePolicyInit.c
+// RapidStartDxePolicyInit.dxs
+// RapidStartDxePolicyInit.inf
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartDxePolicyInit.h
+//
+// Description: Header file for the RapidStartDxePolicyInit Driver.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _RAPID_START_DXE_PLATFORM_POLICY_H_
+#define _RAPID_START_DXE_PLATFORM_POLICY_H_
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include EFI_PROTOCOL_PRODUCER (RapidStartPlatformPolicy)
+#include EFI_PROTOCOL_CONSUMER (DiskInfo)
+#include <token.h>
+#include "PchRegs.h"
+#include "SaAccess.h"
+#include "PchPlatformLib.h"
+#include <SetupDataDefinition.h>
+#define SYSTEM_CONFIGURATION_GUID { 0xEC87D643, 0xEBA4, 0x4BB5, 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 }
+EFI_GUID SetupGuid = SYSTEM_CONFIGURATION_GUID;
+
+#if LOCK_DISABLE_RAPID_START_IF_NO_SSD
+#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \
+ { 0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93 }
+
+EFI_GUID gNotifyProtocolGuid = BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID;
+#endif
+
+#ifdef RAPID_START_PARTITION_DETECT_BEFORE_SETUP
+#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \
+ { 0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93 }
+
+#define RAPID_START_PARTITION_STATUS_PROTOCOL_GUID \
+ { 0x65639144, 0xd492, 0x4328, 0xa4, 0x98, 0xf4, 0xb5, 0x54, 0x5e, 0x4a, 0x30 }
+
+EFI_GUID gBdsAllDriversConnectedProtocolGuid = \
+ BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID;
+EFI_HANDLE gImageHandle;
+#if SYNC_UP_DRIVER_AND_BIOS_VARIABLE
+#define RAPID_START_WRAPPER_SMM_DATA_GUID { 0xc840359f, 0x1c11, 0x4d41, 0x92, 0x4c, 0x89, 0x70, 0x52, 0x22, 0x6a, 0xd4 }
+EFI_GUID RapidStartWrapperSmmDataGuid = RAPID_START_WRAPPER_SMM_DATA_GUID;
+
+typedef struct _RAPID_START_WRAPPER_SMM_DATA {
+ UINT16 S3WakeTimerMin;
+ UINT8 EntryOnS3RtcWake;
+ UINT8 EntryOnS3CritBattWake;
+} RAPID_START_WRAPPER_SMM_DATA;
+#endif
+#include <RapidStartData.h>
+#include <RapidStartDxeLib.h>
+#include <RapidStartAhciReg.h>
+//AMI_OVERRIDE_FOR_RAPID_START
+#include <RapidStartCommonLib.h>
+//AMI_OVERRIDE_FOR_RAPID_START
+#endif
+//#include "RapidStartPlatformPolicyUpdateDxeLib.h"
+#endif
+
+/**
+ Initilize Intel RapidStart DXE Platform Policy
+
+ @param[in] ImageHandle - Image handle of this driver.
+ @param[in] SystemTable - Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+RapidStartDxePolicyInitEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN OUT EFI_SYSTEM_TABLE *SystemTable
+ );
+
+#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/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.inf b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.inf
new file mode 100644
index 0000000..97d8602
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.inf
@@ -0,0 +1,74 @@
+## @file
+# Component description file for the RapidStartDxePolicyInit DXE driver.
+#
+#@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 = RapidStartDxePolicyInit
+FILE_GUID = DDB412A6-E3F3-4e9e-90A3-2A991270219C
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ RapidStartDxePolicyInit.c
+ RapidStartDxePolicyInit.h
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGlueDxeDriverEntryPoint.c
+
+[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_RAPID_START_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Include
+ $(EFI_SOURCE)
+ $(PLATFORM_ECP_PACKAGE)/Include
+
+[libraries.common]
+ EdkIIGlueDxeReportStatusCodeLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkFrameworkProtocolLib
+ EdkProtocolLib
+ RapidStartProtocolLib
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiRuntimeServicesTableLib
+ PlatformPolicyUpdateDxeLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+ DPX_SOURCE = RapidStartDxePolicyInit.dxs
+
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartDxePolicyInitEntryPoint
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ -D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+
diff --git a/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak
new file mode 100644
index 0000000..484a1eb
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak
@@ -0,0 +1,165 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak 5 6/21/13 6:01a Joshchou $
+#
+# $Revision: 5 $
+#
+# $Date: 6/21/13 6:01a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxePolicyInit/RapidStartDxePolicyInit.mak $
+#
+# 5 6/21/13 6:01a 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.
+#
+# 4 1/13/13 7:47a Bensonlai
+# [TAG] EIPNone
+# [Category] Improvement
+# [Description] Disabling the RapidStart while STAT mode in the IDE
+# mode
+# [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+# RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+# RapidStartSetup.sd, RapidStartSetup.sdl
+#
+# 3 12/07/12 1:17a Bensonlai
+# [TAG] None
+# [Category] Bug Fix
+# [Severity] Normal
+# [Symptom] When installed memory size less than HDD partition size of
+# teh RapidStart, it still can work.
+# [RootCause] The RAPID_START_PERSISTENT_DATA wasn't updated in the
+# BdsAllDriversConnectedCallback().
+# [Solution] Get the real total size of memory directly.
+# [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+# RapidStartDxePolicyInit.mak
+#
+# 2 11/15/12 12:38a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] Move the RAPID_START_PARTITION_DETECT_BEFORE_SETUP to
+# RapidStartDxePolicyInit.c.
+#
+# 1 10/15/12 4:40a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# [Category] Improvement
+# [Severity] Important
+# [Description] Implementation of the LOCK_DISABLE_RAPID_START_IF_NO_SSD
+# using EDKII.
+# [Files] Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit\*.*
+# [Files] RapidStartDxePolicyInit.cif
+# RapidStartDxePolicyInit.sdl
+# RapidStartDxePolicyInit.mak
+# RapidStartDxePolicyInit.h
+# RapidStartDxePolicyInit.c
+# RapidStartDxePolicyInit.dxs
+# RapidStartDxePolicyInit.inf
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartDxePolicyInit.mak
+#
+# Description: Component description file for the RapidStartDxePolicyInit DXE driver.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+All : RapidStartDxePolicyInit
+
+RapidStartDxePolicyInit : $(BUILD_DIR)\RapidStartDxePolicyInit.mak RapidStartDxePolicyInitBin
+
+$(BUILD_DIR)\RapidStartDxePolicyInit.mak : $(RapidStartDxePolicyInit_DIR)\$(@B).cif $(RapidStartDxePolicyInit_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartDxePolicyInit_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartDxePolicyInit_INCLUDES=\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(EDK_INCLUDES)\
+ $(RAPIDSTART_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)\
+ $(INTEL_MCH_INCLUDES)\
+
+RapidStartDxePolicyInit_LIBS=\
+ $(EDKPROTOCOLLIB)\
+ $(EFIGUIDLIB)\
+ $(EdkIIGlueBaseLib_LIB)\
+!IF "$(x64_BUILD)"=="1"
+ $(EdkIIGlueBaseLibX64_LIB)\
+!ELSE
+ $(EdkIIGlueBaseLibIA32_LIB)\
+!ENDIF
+ $(EDKFRAMEWORKGUIDLIB)\
+ $(EDKFRAMEWORKPROTOCOLLIB)\
+ $(EdkIIGlueBaseIoLibIntrinsic_LIB)\
+ $(EdkIIGlueBaseMemoryLib_LIB)\
+ $(EdkIIGlueDxeReportStatusCodeLib_LIB)\
+ $(EdkIIGlueDxeServicesTableLib_LIB)\
+ $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\
+ $(EdkIIGlueUefiBootServicesTableLib_LIB)\
+ $(EdkIIGlueBasePciLibPciExpress_LIB)\
+ $(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)\
+ $(RapidStartProtocolLib_LIB)\
+ $(RapidStartDxeLib_LIB)\
+ $(PchPlatformDxeLib_LIB)\
+ $(RapidStartCommonDxeLib_LIB)\
+
+RapidStartDxePolicyInit_DEFINES=\
+ $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartDxePolicyInitEntryPoint"\
+ /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\
+ /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ /D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \
+
+RapidStartDxePolicyInitBin : $(RapidStartDxePolicyInit_LIBS)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartDxePolicyInit.mak all\
+ "MY_INCLUDES=$(RapidStartDxePolicyInit_INCLUDES)"\
+ "MY_DEFINES=$(RapidStartDxePolicyInit_DEFINES)"\
+ GUID=DDB412A6-E3F3-4e9e-90A3-2A991270219C\
+ ENTRY_POINT=_ModuleEntryPoint \
+ EDKIIModule=DXEDRIVER\
+ TYPE=BS_DRIVER \
+ DEPEX1=$(RapidStartDxePolicyInit_DIR)\RapidStartDxePolicyInit.dxs \
+ DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \
+ COMPRESS=1\
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl
new file mode 100644
index 0000000..c895fdc
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Dxe/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl
@@ -0,0 +1,94 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl 1 10/15/12 4:40a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 4:40a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartDxePolicyInit/RapidStartDxePolicyInit.sdl $
+#
+# 1 10/15/12 4:40a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# [Category] Improvement
+# [Severity] Important
+# [Description] Implementation of the LOCK_DISABLE_RAPID_START_IF_NO_SSD
+# using EDKII.
+# [Files] Board\EM\RapidStartWrapper\Dxe\RapidStartDxePolicyInit\*.*
+# [Files] RapidStartDxePolicyInit.cif
+# RapidStartDxePolicyInit.sdl
+# RapidStartDxePolicyInit.mak
+# RapidStartDxePolicyInit.h
+# RapidStartDxePolicyInit.c
+# RapidStartDxePolicyInit.dxs
+# RapidStartDxePolicyInit.inf
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartDxePolicyInit.sdl
+#
+# Description: SDL file for the RapidStartDxePolicyInit.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "RapidStartDxePolicyInit_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable RapidStartDxePolicyInit support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "RapidStartDxePolicyInit_DIR"
+End
+
+MODULE
+ File = "RapidStartDxePolicyInit.mak"
+ Help = "Includes RapidStartDxePolicyInit.mak to Project"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartDxePolicyInit.ffs"
+ Parent = "FV_MAIN"
+ 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/Include/Mbr.h b/Board/EM/RapidStartWrapper/Include/Mbr.h
new file mode 100644
index 0000000..5a04738
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Include/Mbr.h
@@ -0,0 +1,72 @@
+/** @file
+ EFI Mbr Partition Generic Driver Header. This header contains Data structures and Definitions
+ needed to recognize partitions in a MBR
+
+@copyright
+ Copyright (c) 2006 - 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
+**/
+#ifndef _MBR_H
+#define _MBR_H
+
+#define MBR_SIGNATURE 0xAA55
+#define NUM_MBR_PARTITIONS 4
+
+///
+/// Type definitions for the Hard drive device path
+///
+#define MBR_TYPE_MASTER_BOOT_RECORD 0x01
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
+
+///
+/// Needed Partition Type definitions for MBR
+///
+#define NO_PARTITION 0x0
+#define EXTENDED_PARTITION 0x05
+#define WIN95_EXTENDED_PARTITION 0x0F
+
+//
+// Data Structures needed for MBR
+//
+#pragma pack(1)
+
+///
+/// Data Structure definition for each partition in the MBR
+///
+typedef struct _MBR_PARTITION {
+ UINT8 BootIndicator;
+ UINT8 StartHead;
+ UINT8 StartSector;
+ UINT8 StartTrack;
+ UINT8 OSType;
+ UINT8 EndHead;
+ UINT8 EndSector;
+ UINT8 EndTrack;
+ UINT32 StartingLba;
+ UINT32 SizeInLba;
+} MBR_PARTITION;
+
+///
+/// Data Structure definition of the MBR located in the first block on an MBR drive
+///
+typedef struct _MASTER_BOOT_RECORD {
+ UINT8 BootCode[440];
+ UINT32 UniqueMbrSig;
+ UINT16 Unknown;
+ MBR_PARTITION PartRec[4];
+ UINT16 Sig;
+} MASTER_BOOT_RECORD;
+
+#pragma pack()
+#endif
diff --git a/Board/EM/RapidStartWrapper/Include/UefiGpt.h b/Board/EM/RapidStartWrapper/Include/UefiGpt.h
new file mode 100644
index 0000000..1ba0cf0
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Include/UefiGpt.h
@@ -0,0 +1,145 @@
+/** @file
+ EFI Guid Partition Table Format Definition.
+
+@copyright
+ Copyright (c) 2006 - 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
+**/
+
+#ifndef __UEFI_GPT_H__
+#define __UEFI_GPT_H__
+
+///
+/// The primary GUID Partition Table Header must be
+/// located in LBA 1 (i.e., the second logical block).
+///
+#define PRIMARY_PART_HEADER_LBA 1
+///
+/// EFI Partition Table Signature: "EFI PART".
+///
+#define EFI_PTAB_HEADER_ID SIGNATURE_64 ('E','F','I',' ','P','A','R','T')
+
+#pragma pack(1)
+
+///
+/// GPT Partition Table Header.
+///
+typedef struct {
+ ///
+ /// The table header for the GPT partition Table.
+ /// This header contains EFI_PTAB_HEADER_ID.
+ ///
+ EFI_TABLE_HEADER Header;
+ ///
+ /// The LBA that contains this data structure.
+ ///
+ EFI_LBA MyLBA;
+ ///
+ /// LBA address of the alternate GUID Partition Table Header.
+ ///
+ EFI_LBA AlternateLBA;
+ ///
+ /// The first usable logical block that may be used
+ /// by a partition described by a GUID Partition Entry.
+ ///
+ EFI_LBA FirstUsableLBA;
+ ///
+ /// The last usable logical block that may be used
+ /// by a partition described by a GUID Partition Entry.
+ ///
+ EFI_LBA LastUsableLBA;
+ ///
+ /// GUID that can be used to uniquely identify the disk.
+ ///
+ EFI_GUID DiskGUID;
+ ///
+ /// The starting LBA of the GUID Partition Entry array.
+ ///
+ EFI_LBA PartitionEntryLBA;
+ ///
+ /// The number of Partition Entries in the GUID Partition Entry array.
+ ///
+ UINT32 NumberOfPartitionEntries;
+ ///
+ /// The size, in bytes, of each the GUID Partition
+ /// Entry structures in the GUID Partition Entry
+ /// array. This field shall be set to a value of 128 x 2^n where n is
+ /// an integer greater than or equal to zero (e.g., 128, 256, 512, etc.).
+ ///
+ UINT32 SizeOfPartitionEntry;
+ ///
+ /// The CRC32 of the GUID Partition Entry array.
+ /// Starts at PartitionEntryLBA and is
+ /// computed over a byte length of
+ /// NumberOfPartitionEntries * SizeOfPartitionEntry.
+ ///
+ UINT32 PartitionEntryArrayCRC32;
+} EFI_PARTITION_TABLE_HEADER;
+
+///
+/// GPT Partition Entry.
+///
+typedef struct {
+ ///
+ /// Unique ID that defines the purpose and type of this Partition. A value of
+ /// zero defines that this partition entry is not being used.
+ ///
+ EFI_GUID PartitionTypeGUID;
+ ///
+ /// GUID that is unique for every partition entry. Every partition ever
+ /// created will have a unique GUID.
+ /// This GUID must be assigned when the GUID Partition Entry is created.
+ ///
+ EFI_GUID UniquePartitionGUID;
+ ///
+ /// Starting LBA of the partition defined by this entry
+ ///
+ EFI_LBA StartingLBA;
+ ///
+ /// Ending LBA of the partition defined by this entry.
+ ///
+ EFI_LBA EndingLBA;
+ ///
+ /// Attribute bits, all bits reserved by UEFI
+ /// Bit 0: If this bit is set, the partition is required for the platform to function. The owner/creator of the
+ /// partition indicates that deletion or modification of the contents can result in loss of platform
+ /// features or failure for the platform to boot or operate. The system cannot function normally if
+ /// this partition is removed, and it should be considered part of the hardware of the system.
+ /// Actions such as running diagnostics, system recovery, or even OS install or boot, could
+ /// potentially stop working if this partition is removed. Unless OS software or firmware
+ /// recognizes this partition, it should never be removed or modified as the UEFI firmware or
+ /// platform hardware may become non-functional.
+ /// Bit 1: If this bit is set, then firmware must not produce an EFI_BLOCK_IO_PROTOCOL device for
+ /// this partition. By not producing an EFI_BLOCK_IO_PROTOCOL partition, file system
+ /// mappings will not be created for this partition in UEFI.
+ /// Bit 2: This bit is set aside to let systems with traditional PC-AT BIOS firmware implementations
+ /// inform certain limited, special-purpose software running on these systems that a GPT
+ /// partition may be bootable. The UEFI boot manager must ignore this bit when selecting
+ /// a UEFI-compliant application, e.g., an OS loader.
+ /// Bits 3-47: Undefined and must be zero. Reserved for expansion by future versions of the UEFI
+ /// specification.
+ /// Bits 48-63: Reserved for GUID specific use. The use of these bits will vary depending on the
+ /// PartitionTypeGUID. Only the owner of the PartitionTypeGUID is allowed
+ /// to modify these bits. They must be preserved if Bits 0-47 are modified..
+ ///
+ UINT64 Attributes;
+ ///
+ /// Null-terminated name of the partition.
+ ///
+ CHAR16 PartitionName[36];
+} EFI_PARTITION_ENTRY;
+
+#pragma pack()
+#endif
+
diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.c b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.c
new file mode 100644
index 0000000..666f3a7
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.c
@@ -0,0 +1,916 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartCommonLib/RapidStartCommonLib.c 2 11/20/12 2:46a Bensonlai $
+//
+// $Revision: 2 $
+//
+// $Date: 11/20/12 2:46a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.c $
+//
+// 2 11/20/12 2:46a Bensonlai
+// [TAG] EIP107013
+// [Category] Improvement
+// [Description] Update Shark Bay Rapid Start Reference Code Version
+// 0.8.0.0
+// [Files] RapidStartCommonLib.sdl
+// RapidStartCommonLib.mak
+// RapidStartCommonLib.c
+// RapidStartCommonLib.h
+// RapidStartCommonLib.inf
+// RapidStartCommonLib.cif
+//
+// 1 10/15/12 4:40a 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] RapidStartCommonLib.cif
+// RapidStartCommonLib.sdl
+// RapidStartCommonLib.mak
+// RapidStartCommonLib.c
+// RapidStartCommonLib.h
+// RapidStartCommonLib.inf
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartCommonLib.c
+//
+// Description: RapidStart Common code library.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueBase.h"
+#include "EfiCommon.h"
+#include <PchRegs.h>
+#include "RapidStartCommonLib.h"
+#include "PchPlatformLib.h"
+#endif
+#define R_PCH_RTC_INDEX_ALT 0x74
+#define R_PCH_RTC_TARGET_ALT 0x75
+#define R_PCH_RTC_EXT_INDEX_ALT 0x76
+#define R_PCH_RTC_EXT_TARGET_ALT 0x77
+
+#define R_PCH_RTC_REGC 0x0C
+#define B_PCH_RTC_REGC_AF 0x20
+
+#define RTC_INDEX_MASK 0x7F
+#define RTC_BANK_SIZE 0x80
+
+#define R_PCH_RTC_SECOND 0x00
+#define R_PCH_RTC_ALARM_SECOND 0x01
+#define R_PCH_RTC_MINUTE 0x02
+#define R_PCH_RTC_ALARM_MINUTE 0x03
+#define R_PCH_RTC_HOUR 0x04
+#define R_PCH_RTC_ALARM_HOUR 0x05
+#define R_PCH_RTC_DAY_OF_WEEK 0x06
+#define R_PCH_RTC_DAY_OF_MONTH 0x07
+#define R_PCH_RTC_MONTH 0x08
+#define R_PCH_RTC_YEAR 0x09
+
+///
+/// Non-volatile RapidStart flag must be kept within locked CMOS range
+/// to prevent triggering RapidStart resume by manipulating CMOS in OS runtime,
+/// and mitigate attacks on SMRAM image content.
+///
+#ifndef FFS_NV_FLAG_REG
+#define FFS_NV_FLAG_REG 0x88
+#endif
+///
+/// Some runtime configuration settings (e.g. enabled wake events must be
+/// available to determine RapidStart transition before memory is initialized.
+/// This CMOS register is used to store these settings, thus must be
+/// within unlocked range.
+///
+#ifndef FFS_NV_CONFIG_REG
+#define FFS_NV_CONFIG_REG 0x47
+#endif
+///
+/// Defines for KSC common code
+/// Timeout if KSC command/data fails
+///
+#define KSC_TIME_OUT 0x20000
+#define KSC_WAIT_PERIOD 15
+///
+/// The Keyboard and System management Controller (KSC) implements a standard 8042 keyboard
+/// controller interface at ports 0x60/0x64 and a ACPI compliant system management controller
+/// at ports 0x62/0x66. Port 0x66 is the command and status port, port 0x62 is the data port.
+///
+#define KSC_D_PORT 0x62
+#define KSC_C_PORT 0x66
+
+//
+// Status Port 0x62
+//
+#define KSC_S_OVR_TMP 0x80 ///< Current CPU temperature exceeds the threshold
+#define KSC_S_SMI_EVT 0x40 ///< SMI event is pending
+#define KSC_S_SCI_EVT 0x20 ///< SCI event is pending
+#define KSC_S_BURST 0x10 ///< KSC is in burst mode or normal mode
+#define KSC_S_CMD 0x08 ///< Byte in data register is command/data
+#define KSC_S_IGN 0x04 ///< Ignored
+#define KSC_S_IBF 0x02 ///< Input buffer is full/empty
+#define KSC_S_OBF 0x01 ///< Output buffer is full/empty
+#define KSC_CMD_SET_CRITICAL_BATTERY_WAKE_THRESHOLD 0x34
+#define DISABLE_CRITICAL_BATTERY_WAKE 0
+#define MINIMAL_CRITICAL_BATTERY_WAKE_THRESHOLD 15
+#define KSC_CMD_GET_WAKE_STATUS 0x35
+#define KSC_WAKE_STATUS_CRITICAL_BATTERY 1
+#define KSC_CMD_CLEAR_WAKE_STATUS 0x36
+
+/**
+ Read specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for read
+
+ @retval The data of specific location in RTC/CMOS RAM.
+**/
+UINT8
+RtcRead (
+ IN UINT8 Location
+ )
+{
+ UINT8 RtcIndexPort;
+ UINT8 RtcDataPort;
+
+ ///
+ /// CMOS access registers (using alternative access not to handle NMI bit)
+ ///
+ if (Location < RTC_BANK_SIZE) {
+ ///
+ /// First bank
+ ///
+ RtcIndexPort = R_PCH_RTC_INDEX_ALT;
+ RtcDataPort = R_PCH_RTC_TARGET_ALT;
+ } else {
+ ///
+ /// Second bank
+ ///
+ RtcIndexPort = R_PCH_RTC_EXT_INDEX_ALT;
+ RtcDataPort = R_PCH_RTC_EXT_TARGET_ALT;
+ }
+
+ IoWrite8 (RtcIndexPort, Location & RTC_INDEX_MASK);
+ return IoRead8 (RtcDataPort);
+}
+
+/**
+ Write specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for write
+ @param[in] Value The data that will be written to RTC/CMOS RAM
+**/
+VOID
+RtcWrite (
+ IN UINT8 Location,
+ IN UINT8 Value
+ )
+{
+ UINT8 RtcIndexPort;
+ UINT8 RtcDataPort;
+
+ ///
+ /// CMOS access registers (using alternative access not to handle NMI bit)
+ ///
+ if (Location < RTC_BANK_SIZE) {
+ ///
+ /// First bank
+ ///
+ RtcIndexPort = R_PCH_RTC_INDEX_ALT;
+ RtcDataPort = R_PCH_RTC_TARGET_ALT;
+ } else {
+ ///
+ /// Second bank
+ ///
+ RtcIndexPort = R_PCH_RTC_EXT_INDEX_ALT;
+ RtcDataPort = R_PCH_RTC_EXT_TARGET_ALT;
+ }
+
+ IoWrite8 (RtcIndexPort, Location & RTC_INDEX_MASK);
+ IoWrite8 (RtcDataPort, Value);
+}
+
+/**
+ Read word from specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for read
+
+ @retval The data of specific location in RTC/CMOS RAM.
+**/
+UINT16
+RtcRead16 (
+ IN UINT8 Location
+ )
+{
+ return RtcRead (Location) | (RtcRead (Location + 1) << 8);
+}
+
+/**
+ Write word to specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for write
+ @param[in] Value The data that will be written to RTC/CMOS RAM
+**/
+VOID
+RtcWrite16 (
+ IN UINT8 Location,
+ IN UINT16 Value
+ )
+{
+ RtcWrite (Location, (UINT8) Value);
+ RtcWrite (Location + 1, (UINT8) (Value >> 8));
+}
+
+/**
+ Initialize RTC Timer
+**/
+VOID
+RtcInit (
+ VOID
+ )
+{
+ UINT8 RegB;
+ RegB = RtcRead (R_PCH_RTC_REGB);
+ RegB |= B_PCH_RTC_REGB_HOURFORM;
+ RegB &= ~B_PCH_RTC_REGB_DM;
+ RtcWrite (R_PCH_RTC_REGB, RegB);
+}
+
+/**
+ Wait for updating RTC process finished.
+**/
+STATIC
+VOID
+RtcWaitEndOfUpdate (
+ VOID
+ )
+{
+ while (RtcRead (R_PCH_RTC_REGA) & B_PCH_RTC_REGA_UIP) {
+ }
+}
+
+/**
+ Get current RTC time
+
+ @param[out] tm RTC time structure including Second, Minute and Hour.
+
+ @retval EFI_SUCCESS Operation successfully and RTC_TIME structure contained current time.
+**/
+EFI_STATUS
+RtcGetTime (
+ OUT RTC_TIME *tm
+ )
+{
+ ASSERT (tm != NULL);
+ RtcWaitEndOfUpdate ();
+ tm->Second = BcdToDecimal8 (RtcRead (R_PCH_RTC_SECOND));
+ tm->Minute = BcdToDecimal8 (RtcRead (R_PCH_RTC_MINUTE));
+ tm->Hour = BcdToDecimal8 (RtcRead (R_PCH_RTC_HOUR));
+ tm->Date = BcdToDecimal8 (RtcRead (R_PCH_RTC_DAY_OF_MONTH));
+ tm->Month = BcdToDecimal8 (RtcRead (R_PCH_RTC_MONTH));
+ tm->Year = (UINT16) BcdToDecimal8 (RtcRead (R_PCH_RTC_YEAR)) + 2000;
+ return EFI_SUCCESS;
+}
+
+/**
+ Check if RTC Alarm has been enabled.
+
+ @retval TRUE RTC Alarm is enabled
+ @retval FALSE RTC Alarm is not enabled
+**/
+BOOLEAN
+RtcIsAlarmEnabled (
+ VOID
+ )
+{
+ return (RtcRead (R_PCH_RTC_REGB) & B_PCH_RTC_REGB_AIE) != 0;
+}
+
+/**
+ Get current RTC Alarm time.
+
+ @param[out] tm A structure which will be updated with current RTC Alarm time
+
+ @retval EFI_NOT_STARTED RTC Alarm has not been enabled yet.
+ @retval EFI_SUCCESS RTC Alarm enabled and RTC_TIME structure contain current Alarm time setting.
+**/
+EFI_STATUS
+RtcGetAlarm (
+ OUT RTC_TIME *tm
+ )
+{
+ ASSERT (tm != NULL);
+ if (!RtcIsAlarmEnabled ()) {
+ return EFI_NOT_STARTED;
+ }
+
+ RtcWaitEndOfUpdate ();
+ tm->Second = BcdToDecimal8 (RtcRead (R_PCH_RTC_ALARM_SECOND));
+ tm->Minute = BcdToDecimal8 (RtcRead (R_PCH_RTC_ALARM_MINUTE));
+ tm->Hour = BcdToDecimal8 (RtcRead (R_PCH_RTC_ALARM_HOUR));
+ tm->Date = BcdToDecimal8 (RtcRead (R_PCH_RTC_REGD) & 0x3F);
+ tm->Month = 0;
+ tm->Year = 0;
+ return EFI_SUCCESS;
+}
+
+/**
+ Set RTC Alarm with specific time
+
+ @param[in] tm A time interval structure which will be used to setup an RTC Alarm
+
+ @retval EFI_SUCCESS RTC Alarm has been enabled with specific time interval
+**/
+EFI_STATUS
+RtcSetAlarm (
+ IN RTC_TIME *tm
+ )
+{
+ UINT8 RegB;
+
+ ASSERT (tm != NULL);
+
+ RegB = RtcRead (R_PCH_RTC_REGB);
+
+ RtcWaitEndOfUpdate ();
+
+ ///
+ /// Inhibit update cycle
+ ///
+ RtcWrite (R_PCH_RTC_REGB, RegB | B_PCH_RTC_REGB_SET);
+
+ RtcWrite (R_PCH_RTC_ALARM_SECOND, DecimalToBcd8 (tm->Second));
+ RtcWrite (R_PCH_RTC_ALARM_MINUTE, DecimalToBcd8 (tm->Minute));
+ RtcWrite (R_PCH_RTC_ALARM_HOUR, DecimalToBcd8 (tm->Hour));
+ RtcWrite (R_PCH_RTC_REGD, DecimalToBcd8 (tm->Date));
+
+ ///
+ /// Allow update cycle and enable wake alarm
+ ///
+ RegB &= ~B_PCH_RTC_REGB_SET;
+ RtcWrite (R_PCH_RTC_REGB, RegB | B_PCH_RTC_REGB_AIE);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Check if CRB KSC controller present or not.
+
+ @retval EFI_SUCCESS - CRB KSC present.
+ @retval EFI_DEVICE_ERROR - CRB KSC not present.
+**/
+STATIC
+EFI_STATUS
+CheckKscPresence (
+ VOID
+ )
+{
+ if (IoRead8 (KSC_C_PORT) == 0xff) {
+ return EFI_DEVICE_ERROR;
+ } else {
+ return EFI_SUCCESS;
+ }
+}
+
+/**
+ Receives status from Keyboard System Controller.
+
+ @param[in] KscStatus - Status byte to receive
+
+ @retval EFI_SUCCESS - Always success
+ @retval EFI_DEVICE_ERROR - KSC not present
+**/
+STATIC
+EFI_STATUS
+ReceiveKscStatus (
+ UINT8 *KscStatus
+ )
+{
+ ///
+ /// Verify if KscLib has been initialized, NOT if EC dose not exist.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return EFI_DEVICE_ERROR;
+ }
+ ///
+ /// Read and return the status
+ ///
+ *KscStatus = IoRead8 (KSC_C_PORT);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends command to Keyboard System Controller.
+
+ @param[in] Command - Command byte to send
+
+ @retval EFI_SUCCESS - Command success
+ @retval EFI_DEVICE_ERROR - Command error
+**/
+STATIC
+EFI_STATUS
+SendKscCommand (
+ UINT8 Command
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ KscStatus = 0;
+ ///
+ /// Verify if KscLib has been initialized, NOT if EC dose not exist.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ ///
+ /// Wait for KSC to be ready (with a timeout)
+ ///
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ PchPmTimerStall (KSC_WAIT_PERIOD);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+ ///
+ /// Send the KSC command
+ ///
+ IoWrite8 (KSC_C_PORT, Command);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends data to Keyboard System Controller.
+
+ @param[in] Data - Data byte to send
+
+ @retval EFI_SUCCESS - Success
+ @retval EFI_DEVICE_ERROR - Error
+**/
+STATIC
+EFI_STATUS
+SendKscData (
+ UINT8 Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ ///
+ /// Verify if KscLib has been initialized, NOT if EC dose not exist.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ ///
+ /// Wait for KSC to be ready (with a timeout)
+ ///
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ PchPmTimerStall (KSC_WAIT_PERIOD);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+ ///
+ /// Send the data and return
+ ///
+ IoWrite8 (KSC_D_PORT, Data);
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives data from Keyboard System Controller.
+
+ @param[in] Data - Data byte received
+
+ @retval EFI_SUCCESS - Read success
+ @retval EFI_DEVICE_ERROR - Read error
+**/
+STATIC
+EFI_STATUS
+ReceiveKscData (
+ UINT8 *Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ ///
+ /// Verify if KscLib has been initialized, NOT if EC dose not exist.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ ///
+ /// Wait for KSC to be ready (with a timeout)
+ ///
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_OBF) == 0) && (Index < KSC_TIME_OUT)) {
+ PchPmTimerStall (KSC_WAIT_PERIOD);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+ ///
+ /// Read KSC data and return
+ ///
+ *Data = IoRead8 (KSC_D_PORT);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Enable or disable critical battery wakeup event.
+
+ @param[in] Enabled - Enable or disable Critical Battery wakeup event.
+**/
+VOID
+RapidStartInitializeCriticalBatteryWakeupEvent (
+ IN BOOLEAN Enabled
+ )
+{
+ UINT8 Threshold;
+ ///
+ /// If platform doesn't have KSC controller, skip all KSC commands.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return ;
+ }
+ ///
+ /// This function can be modified to always enable critical battery event if platform design required.
+ /// If platform code already handled critical battery wakeup event, refer to spec and ensure required
+ /// Minimal battery capacity threshold implemented for RapidStart Entry transition.
+ ///
+ if (Enabled == FALSE) {
+ ///
+ /// Disable critical battery wake event.
+ ///
+ Threshold = DISABLE_CRITICAL_BATTERY_WAKE;
+ } else {
+ //
+ // Enable critical battery wake event.
+ //
+ Threshold = RtcRead (FFS_CBTH_DATA_REG);
+ }
+
+ SendKscCommand (KSC_CMD_SET_CRITICAL_BATTERY_WAKE_THRESHOLD);
+ SendKscData (Threshold);
+}
+
+/**
+ Check if current wakeup is because of critical low battery.
+
+ @retval TRUE - Current wakeup source is critical low battery event.
+ @retval FALSE - The wakeup source is not critical low battery event.
+**/
+BOOLEAN
+RapidStartCheckCriticalBatteryWakeupEvent (
+ VOID
+ )
+{
+ UINT8 WakeStatus;
+
+ ///
+ /// If platform doesn't have KSC controller, return FALSE
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return FALSE;
+ }
+
+ SendKscCommand (KSC_CMD_GET_WAKE_STATUS);
+ ///
+ /// if get wake status failed, return false
+ ///
+ if (ReceiveKscData (&WakeStatus) != EFI_SUCCESS) {
+ return FALSE;
+ }
+
+ if (WakeStatus & KSC_WAKE_STATUS_CRITICAL_BATTERY) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Clear all wakeup status.
+**/
+VOID
+RapidStartClearAllKscWakeStatus (
+ VOID
+ )
+{
+ ///
+ /// If platform doesn't have KSC controller, skip all KSC commands.
+ ///
+ if (CheckKscPresence () != EFI_SUCCESS) {
+ return ;
+ }
+
+ SendKscCommand (KSC_CMD_CLEAR_WAKE_STATUS);
+}
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+/**
+ Calculate CRC32 value for inputed data
+
+ @param[in] Data - data to calc on CRC
+ @param[in] DataSize - data size
+ @param[in] Crc32 - crc value.
+ @param[in] RapidStartData - A data buffer stored RapidStart internal non-volatile information.
+ @param[in] CrcTable - The base CRC table
+
+ @retval EFI_INVALID_PARAMETER inputed parameters are invalid
+ @retval EFI_SUCCESS Process successfully and CRC value has been passed by Crc32 parameter.
+**/
+EFI_STATUS
+RapidStartCalculateCrc32 (
+ IN UINT8 *Data,
+ IN UINT32 DataSize,
+ IN UINT32 *Crc32,
+ IN RAPID_START_PERSISTENT_DATA *RapidStartData,
+ IN UINT32 *CrcTable
+ )
+{
+ UINT32 i;
+ UINT32 crc;
+
+ crc = (UINT32) -1;
+
+ if (!DataSize || !Crc32) {
+ return EFI_INVALID_PARAMETER;
+ }
+ ///
+ /// Calculate the CRC
+ ///
+ for (i = 0; i < DataSize; i++) {
+ if (((Data + i) >= (UINT8 *) (UINTN) RapidStartData->AcpiReservedMemoryBase) &&
+ ((Data + i) < (UINT8 *) (UINTN) (RapidStartData->AcpiReservedMemoryBase + RapidStartData->AcpiReservedMemorySize))
+ ) {
+ continue;
+ }
+
+ if (((Data + i) < (UINT8 *) (UINTN) RapidStartData->RapidStartMem) ||
+ ((Data + i) >= (UINT8 *) (UINTN) (RapidStartData->RapidStartMem + RapidStartData->RapidStartMemSize))
+ ) {
+ crc = (crc >> 8) ^ CrcTable[(UINT8) crc ^ ((UINT8 *) Data)[i]];
+ }
+ }
+
+ *Crc32 = ~crc;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Log CRC32 mismatched address and length
+
+ @param[in] MismatchedBaseAddress - Memory address caused mismatched CRC32
+ @param[in] MismatchedDataSize - memory length for calculating CRC32
+
+ @retval EFI_SUCCESS Process successfully
+**/
+EFI_STATUS
+LogCrc32MismatchedAddress (
+ UINTN MismatchedBaseAddress,
+ UINT32 MismatchedDataSize
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ Log or compare CRC32 value for specific memory range.
+
+ @param[in] IsComparingCrc32 - FALSE to save CRC32 value into buffer. TRUE to compare CRC32 value with pre-saved value in buffer.
+ @param[in] BaseAddress - Base memory address for logging or checking CRC32
+ @param[in] EndAddress - End memory address for logging or checking CRC32
+ @param[in] RapidStartData - A data buffer stored RapidStart internal non-volatile information.
+**/
+VOID
+SaveOrCompareCrc32 (
+ IN BOOLEAN IsComparingCrc32,
+ IN UINTN BaseAddress,
+ IN UINTN EndAddress,
+ IN RAPID_START_PERSISTENT_DATA *RapidStartData
+ )
+{
+ UINT32 *Crc32Record;
+ UINT32 *Crc32RecordPointer;
+ UINT32 Crc32;
+ UINT32 DataSize;
+ volatile UINTN Crc32MismatchedAddress;
+ volatile UINT32 Crc32MismatchedSize;
+ UINT32 Crc32RecordSizeInDword;
+ UINT32 CrcTable[256];
+ UINT32 i;
+ UINT32 j;
+
+ ///
+ /// init the CRC base table
+ ///
+ for (i = 0; i < 256; i++) {
+ CrcTable[i] = i;
+ for (j = 8; j > 0; j--) {
+ CrcTable[i] = (CrcTable[i] & 1) ? (CrcTable[i] >> 1) ^ 0xedb88320 : CrcTable[i] >> 1;
+ }
+ }
+
+ Crc32Record = RAPID_START_CRC32_RECORD_PTR (RapidStartData);
+ Crc32RecordPointer = Crc32Record + (UINT32) DivU64x32 (BaseAddress, MEMORY_CRC32_GRANULARITY);
+ Crc32RecordSizeInDword = (UINT32) RShiftU64 (RapidStartData->Crc32RecordSize, 2);
+ while (BaseAddress < EndAddress) {
+ ASSERT (Crc32RecordPointer < (Crc32Record + Crc32RecordSizeInDword));
+ if ((EndAddress - BaseAddress) >= MEMORY_CRC32_GRANULARITY) {
+ DataSize = MEMORY_CRC32_GRANULARITY;
+ } else {
+ DataSize = (UINT32) (EndAddress - BaseAddress);
+ }
+ ///
+ /// indicate which address is handling
+ ///
+ IoWrite16 (0x80, (UINT16) DivU64x32 (BaseAddress, MEMORY_CRC32_GRANULARITY));
+ RapidStartCalculateCrc32 ((UINT8 *) BaseAddress, DataSize, &Crc32, RapidStartData, CrcTable);
+ if (IsComparingCrc32) {
+ ///
+ /// Send debug message and log error when mismatch data is found
+ ///
+ if (Crc32 != *(Crc32RecordPointer)) {
+ if (sizeof (BaseAddress) == 4) {
+ DEBUG ((EFI_D_ERROR, "CRC_CHECK: Address=%08X, ", BaseAddress));
+ } else {
+ DEBUG ((EFI_D_ERROR, "CRC_CHECK: Address=%010lX, ", BaseAddress));
+ }
+
+ DEBUG ((EFI_D_ERROR, "Size=%08X, ", DataSize));
+ DEBUG ((EFI_D_ERROR, "current CRC32=%08X, Expected CRC32=%08X, ", Crc32, *(Crc32RecordPointer)));
+ DEBUG ((EFI_D_ERROR, "Crc32Pointer=%08X\n", Crc32RecordPointer));
+ DEBUG ((EFI_D_ERROR, "\nFound mismatched CRC32!!\n\n"));
+ Crc32MismatchedAddress = BaseAddress;
+ Crc32MismatchedSize = DataSize;
+ LogCrc32MismatchedAddress (Crc32MismatchedAddress, Crc32MismatchedSize);
+ }
+ } else {
+ ///
+ /// Save CRC result for comparison during RapidStart exit
+ ///
+ *(Crc32RecordPointer) = Crc32;
+ }
+
+ BaseAddress += MEMORY_CRC32_GRANULARITY;
+ Crc32RecordPointer++;
+ }
+}
+
+#endif
+
+/**
+ Gets RapidStart non-volatile flag.
+
+ @param[out] Value - RapidStart non-volatile flag
+
+ @retval EFI_SUCCESS - Return the RapidStart flag in Value argument.
+**/
+EFI_STATUS
+RapidStartGetFlag (
+ OUT UINT8 *Value
+ )
+{
+ *Value = RtcRead (FFS_NV_FLAG_REG);
+ return EFI_SUCCESS;
+}
+
+/**
+ Sets RapidStart non-volatile flag.
+
+ @param[in] Value - RapidStart flag state
+
+ @retval EFI_SUCCESS - Flag is set.
+**/
+EFI_STATUS
+RapidStartSetFlag (
+ IN UINT8 Value
+ )
+{
+ RtcWrite (FFS_NV_FLAG_REG, Value);
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieves non-volatile RapidStart settings.
+
+ @param[out] Value - RapidStart non-volatile settings
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+RapidStartGetConfig (
+ OUT UINT8 *Value
+ )
+{
+ *Value = RtcRead (FFS_NV_CONFIG_REG);
+ return EFI_SUCCESS;
+}
+
+/**
+ Sets non-volatile RapidStart settings.
+
+ @param[in] Value - RapidStart non-volatile settings
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+RapidStartSetConfig (
+ IN UINT8 Value
+ )
+{
+ RtcWrite (FFS_NV_CONFIG_REG, Value);
+ return EFI_SUCCESS;
+}
+
+/**
+ This callback is executed at the end of RapidStart Entry events initialization. (Inside sleep SMI handler)
+
+ @param[in] TransitionStatus - Status of initialization for RapidStart Entry events.
+**/
+VOID
+AfterInitializingEntryEvent (
+ IN EFI_STATUS TransitionStatus
+ )
+{
+}
+
+/**
+ Check whether RapidStart Resume.
+
+ @retval TRUE - Rapid Start Entry flow has completed successfully
+**/
+BOOLEAN
+RapidStartResumeCheck (
+ VOID
+)
+{
+ EFI_STATUS Status;
+ BOOLEAN RapidStartFlag;
+
+ Status = RapidStartGetFlag (&RapidStartFlag);
+ if ( !EFI_ERROR (Status) && ((RapidStartFlag & RAPID_START_FLAG_ENTRY_DONE) != 0)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/RapidStartCommonLib/RapidStartCommonLib.cif b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.cif
new file mode 100644
index 0000000..0294a74
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "RapidStartCommonLib"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper\Library\RapidStartCommonLib"
+ RefName = "RapidStartCommonLib"
+[files]
+"RapidStartCommonLib.sdl"
+"RapidStartCommonLib.mak"
+"RapidStartCommonLib.c"
+"RapidStartCommonLib.h"
+"RapidStartCommonLib.inf"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.h b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.h
new file mode 100644
index 0000000..2788e2f
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.h
@@ -0,0 +1,374 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartCommonLib/RapidStartCommonLib.h 2 11/20/12 2:46a Bensonlai $
+//
+// $Revision: 2 $
+//
+// $Date: 11/20/12 2:46a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.h $
+//
+// 2 11/20/12 2:46a Bensonlai
+// [TAG] EIP107013
+// [Category] Improvement
+// [Description] Update Shark Bay Rapid Start Reference Code Version
+// 0.8.0.0
+// [Files] RapidStartCommonLib.sdl
+// RapidStartCommonLib.mak
+// RapidStartCommonLib.c
+// RapidStartCommonLib.h
+// RapidStartCommonLib.inf
+// RapidStartCommonLib.cif
+//
+// 1 10/15/12 4:40a 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] RapidStartCommonLib.cif
+// RapidStartCommonLib.sdl
+// RapidStartCommonLib.mak
+// RapidStartCommonLib.c
+// RapidStartCommonLib.h
+// RapidStartCommonLib.inf
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartCommonLib.h
+//
+// Description: Defines and prototypes for the library module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _RAPID_START_LIB_H_
+#define _RAPID_START_LIB_H_
+#include <RapidStartConfig.h>
+#include <RapidStartData.h>
+
+/**
+ Read specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for read
+
+ @retval The data of specific location in RTC/CMOS RAM.
+**/
+UINT8
+RtcRead (
+ IN UINT8 Location
+ );
+
+/**
+ Write specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for write
+ @param[in] Value The data that will be written to RTC/CMOS RAM
+**/
+VOID
+RtcWrite (
+ IN UINT8 Location,
+ IN UINT8 Value
+ );
+
+/**
+ Read word from specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for read
+
+ @retval The data of specific location in RTC/CMOS RAM.
+**/
+UINT16
+RtcRead16 (
+ IN UINT8 Location
+ );
+
+/**
+ Write word to specific RTC/CMOS RAM
+
+ @param[in] Location Point to RTC/CMOS RAM offset for write
+ @param[in] Value The data that will be written to RTC/CMOS RAM
+**/
+VOID
+RtcWrite16 (
+ IN UINT8 Location,
+ IN UINT16 Value
+ );
+
+/**
+ Initialize RTC Timer
+**/
+VOID
+RtcInit (
+ VOID
+ );
+
+/**
+ Get current RTC time
+
+ @param[out] tm RTC time structure including Second, Minute and Hour.
+
+ @retval EFI_SUCCESS Operation successfully and RTC_TIME structure contained current time.
+**/
+EFI_STATUS
+RtcGetTime (
+ OUT RTC_TIME *tm
+ );
+
+/**
+ Check if RTC Alarm has been enabled.
+
+ @retval TRUE RTC Alarm is enabled
+ @retval FALSE RTC Alarm is not enabled
+**/
+BOOLEAN
+RtcIsAlarmEnabled (
+ VOID
+ );
+
+/**
+ Get current RTC Alarm time.
+
+ @param[out] tm A structure which will be updated with current RTC Alarm time
+
+ @retval EFI_NOT_STARTED RTC Alarm has not been enabled yet.
+ @retval EFI_SUCCESS RTC Alarm enabled and RTC_TIME structure contain current Alarm time setting.
+**/
+EFI_STATUS
+RtcGetAlarm (
+ OUT RTC_TIME *tm
+ );
+
+/**
+ Set RTC Alarm with specific time
+
+ @param[in] tm A time interval structure which will be used to setup an RTC Alarm
+
+ @retval EFI_SUCCESS RTC Alarm has been enabled with specific time interval
+**/
+EFI_STATUS
+RtcSetAlarm (
+ IN RTC_TIME *tm
+ );
+
+/**
+ Enable or disable critical battery wakeup event.
+
+ This function enables/disables critical battery wakeup event on KSC controller.
+ This KSC specific command will not be sent if KSC not present. Porting is
+ required to match platform design.
+
+ @param[in] Enabled - Enable or disable Critical Battery wakeup event.
+**/
+VOID
+RapidStartInitializeCriticalBatteryWakeupEvent (
+ IN BOOLEAN Enabled
+ );
+
+/**
+ Check if current wakeup is because of critical low battery.
+
+ This function checks if current S3 resume caused by critical battery wakeup
+ event. This KSC specific command will not be sent if KSC not present. Porting is
+ required to match platform design.
+
+ @retval TRUE - Current wakeup source is critical low battery event.
+ @retval FALSE - The wakeup source is not critical low battery event.
+**/
+BOOLEAN
+RapidStartCheckCriticalBatteryWakeupEvent (
+ VOID
+ );
+
+/**
+ Clear all wakeup status.
+
+ This function clears all wakeup status bits on KSC controller. This KSC specific
+ command will not be sent if KSC not present. Porting is required to match
+ platform design.
+**/
+VOID
+RapidStartClearAllKscWakeStatus (
+ VOID
+ );
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+/**
+ Log CRC32 mismatched address and length
+
+ This is optional OEM hook function. It can be used to log any CRC32 mismatched memory chunk if needed.
+
+ @param[in] MismatchedBaseAddress - Memory address caused mismatched CRC32
+ @param[in] MismatchedDataSize - memory length for calculating CRC32
+
+ @retval EFI_SUCCESS Process successfully
+**/
+EFI_STATUS
+LogCrc32MismatchedAddress (
+ UINTN MismatchedBaseAddress,
+ UINT32 MismatchedDataSize
+ );
+
+/**
+ Log or compare CRC32 value for specific memory range. Each 16MB block will have one CRC32 value.
+
+ This function checks the memory integrity between Rapid Start Entry and Resume.
+ It calculates CRC32 for each memory chunk during Rapid Start Entry, and when
+ Rapid Start Resume it compares each memory chunk CRC32 value with previously
+ saved value to see if any mismatch found. Basically the debug mode BIOS can
+ display all information regarding mismatched memory address. In non-debug mode
+ BIOS, the mismatched memory address and size can be logged if needed. Refer to
+ section "Porting recommendation" for more information.
+
+ @param[in] IsComparingCrc32 - FALSE to save CRC32 value into buffer. TRUE to compare CRC32 value with pre-saved value in buffer.
+ @param[in] BaseAddress - Base memory address for logging or checking CRC32
+ @param[in] EndAddress - End memory address for logging or checking CRC32
+ @param[in] RapidStartData - A data buffer stored RapidStart internal non-volatile information.
+**/
+VOID
+SaveOrCompareCrc32 (
+ IN BOOLEAN IsComparingCrc32,
+ IN UINTN BaseAddress,
+ IN UINTN EndAddress,
+ IN RAPID_START_PERSISTENT_DATA *RapidStartData
+ );
+#endif
+/**
+ Gets RapidStart non-volatile flag.
+
+ Bit0 (RAPID_START_FLAG_ENTRY_DONE):
+ - Rapid Start Entry flow has completed successfully.
+ - Next boot will perform Rapid Start Resume.
+ Bit1 (RAPID_START_FLAG_STORE_CHANGE):
+ - Rapid Start Store change detected in Rapid Start Resume flow.
+ - Rapid Start Resume should be aborted.
+
+ This function will get Rapid Start non-volatile flag which controls overall
+ Rapid Start transition behavior. If Rapid Start Entry already performed in last
+ boot (Rapid Start Flag bit1 was set) the Rapid Start Exit transition can be
+ executed in current boot. After got the Rapid Start Entry state it is
+ recommended to clear this flag (Rapid Start Flag bit1) after drive lock password
+ has been retrieved and scrubbed from non-volatile memory (if drive-lock feature
+ enabled). There are several ways to store Rapid Start Flag and it is platform
+ specific. It must be stored in non-volatile memory and one of the methods is to
+ use CMOS RAM.
+
+ @param[out] Value - RapidStart non-volatile flag
+
+ @retval EFI_SUCCESS - Return the RapidStart flag in Value argument.
+**/
+EFI_STATUS
+RapidStartGetFlag (
+ OUT UINT8 *Value
+ );
+
+/**
+ Sets RapidStart non-volatile flag.
+
+ Bit0 (RAPID_START_FLAG_ENTRY_DONE):
+ - Rapid Start Entry flow has completed successfully.
+ - Next boot will perform Rapid Start Resume.
+ Bit1 (RAPID_START_FLAG_STORE_CHANGE):
+ - Rapid Start Store change detected in Rapid Start Resume flow.
+ - Rapid Start Resume should be aborted.
+
+ This function will set Rapid Start non-volatile flag which controls overall
+ Rapid Start transition behavior. In end of Rapid Start Entry it will set bit0 to
+ indicate next boot may perform Rapid Start Resume. It will also be used to clear
+ Rapid Start Flag when required information has been retrieved.
+
+ @param[in] Value - RapidStart flag state
+
+ @retval EFI_SUCCESS - Flag is set.
+**/
+EFI_STATUS
+RapidStartSetFlag (
+ IN UINT8 Value
+ );
+
+/**
+ Retrieves non-volatile RapidStart settings.
+
+ @param[out] Value - RapidStart non-volatile settings
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+RapidStartGetConfig (
+ OUT UINT8 *Value
+ );
+
+/**
+ Sets non-volatile RapidStart settings.
+
+ @param[in] Value - RapidStart non-volatile settings
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+RapidStartSetConfig (
+ IN UINT8 Value
+ );
+
+/**
+ This callback is executed at the end of RapidStart Entry events initialization. (Inside sleep SMI handler)
+
+ This function will be called in the end of sleep SMI handler which initializes
+ Rapid Start Entry trigger events (RTC alarm timer or critical battery wakeup
+ threshold). It can be used to log the status of initialization like Entry
+ cancellation or Entry aborted due to a sooner wakeup timer has be initialized by
+ OS/application. In these cases Rapid Start trigger events will not be
+ initialized and system will directly enter standard S3 state.
+
+ This function can be used to log any error status of initializing Rapid Start
+ Entry trigger events in sleep SMI handler and then inform users for why Rapid
+ Start Entry not happened.
+
+ @param[in] TransitionStatus - Status of initialization for RapidStart Entry events.
+**/
+VOID
+AfterInitializingEntryEvent (
+ IN EFI_STATUS TransitionStatus
+ );
+
+/**
+ Check whether RapidStart Resume.
+
+ @retval TRUE - Rapid Start Entry flow has completed successfully
+**/
+BOOLEAN
+RapidStartResumeCheck (
+ 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/RapidStartCommonLib/RapidStartCommonLib.inf b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.inf
new file mode 100644
index 0000000..adebfa2
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.inf
@@ -0,0 +1,54 @@
+## @file
+# Component description file for the RapidStart Common code PEIM/SMM/DXE 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 = RapidStartCommonLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ RapidStartCommonLib.h
+ RapidStartCommonLib.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
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include/Library
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_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
+
+[nmake.common]
+C_STD_INCLUDE=
+
diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.mak b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.mak
new file mode 100644
index 0000000..7b2d2df
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.mak
@@ -0,0 +1,103 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartCommonLib/RapidStartCommonLib.mak 1 10/15/12 4:40a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 4:40a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.mak $
+#
+# 1 10/15/12 4:40a 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] RapidStartCommonLib.cif
+# RapidStartCommonLib.sdl
+# RapidStartCommonLib.mak
+# RapidStartCommonLib.c
+# RapidStartCommonLib.h
+# RapidStartCommonLib.inf
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartCommonLib.mak
+#
+# Description: Component description file for the RapidStart Common code PEIM/SMM/DXE library.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+all : RapidStartCommonSmmLib RapidStartCommonDxeLib RapidStartCommonPeiLib
+
+$(RapidStartCommonSmmLib_LIB) : RapidStartCommonSmmLib
+$(RapidStartCommonDxeLib_LIB) : RapidStartCommonDxeLib
+$(RapidStartCommonPeiLib_LIB) : RapidStartCommonPeiLib
+
+RapidStartCommonSmmLib : $(BUILD_DIR)\RapidStartCommonLib.mak RapidStartCommonSmmLibBin
+RapidStartCommonDxeLib : $(BUILD_DIR)\RapidStartCommonLib.mak RapidStartCommonDxeLibBin
+RapidStartCommonPeiLib : $(BUILD_DIR)\RapidStartCommonLib.mak RapidStartCommonPeiLibBin
+
+$(BUILD_DIR)\RapidStartCommonLib.mak : $(RapidStartCommonLib_DIR)\$(@B).cif $(RapidStartCommonLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartCommonLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartCommonSmmLibBin : $(PchPlatformLib)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartCommonLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES) $(EdkIIGlueLib_INCLUDES) $(NB_INCLUDES) $(INTEL_PCH_INCLUDES) $(RAPIDSTART_INCLUDES)" \
+ TYPE=LIBRARY \
+ LIBRARIES=\
+ LIBRARY_NAME=$(RapidStartCommonSmmLib_LIB)
+
+RapidStartCommonDxeLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartCommonLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES) $(EdkIIGlueLib_INCLUDES) $(NB_INCLUDES) $(INTEL_PCH_INCLUDES) $(RAPIDSTART_INCLUDES)" \
+ TYPE=LIBRARY \
+ LIBRARIES=\
+ LIBRARY_NAME=$(RapidStartCommonDxeLib_LIB)
+
+RapidStartCommonPeiLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+!ENDIF
+ /f $(BUILD_DIR)\RapidStartCommonLib.mak all\
+ "MY_INCLUDES=/I$(BUILD_DIR) $(EDK_INCLUDES) $(EdkIIGlueLib_INCLUDES) $(NB_INCLUDES) $(INTEL_PCH_INCLUDES) $(RAPIDSTART_INCLUDES)" \
+ TYPE=PEI_LIBRARY \
+ LIBRARIES=\
+ LIBRARY_NAME=$(RapidStartCommonPeiLib_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/RapidStartCommonLib/RapidStartCommonLib.sdl b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.sdl
new file mode 100644
index 0000000..947adba
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartCommonLib/RapidStartCommonLib.sdl
@@ -0,0 +1,121 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartCommonLib/RapidStartCommonLib.sdl 1 10/15/12 4:40a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 4:40a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.sdl $
+#
+# 1 10/15/12 4:40a 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] RapidStartCommonLib.cif
+# RapidStartCommonLib.sdl
+# RapidStartCommonLib.mak
+# RapidStartCommonLib.c
+# RapidStartCommonLib.h
+# RapidStartCommonLib.inf
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartCommonLib.sdl
+#
+# Description: SDL file for the RapidStart library.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "INTEL_MPG_RapidStartCommonLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable INTEL_MPG_RapidStartCommonLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "RapidStartCommonLib_DIR"
+End
+
+MODULE
+ Help = "Includes RapidStartCommonLib.mak to Project"
+ File = "RapidStartCommonLib.mak"
+End
+
+
+ELINK
+ Name = "RapidStartCommonSmmLib_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartCommonSmmLib.lib"
+ Parent = "RapidStartCommonSmmLib_LIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "RapidStartCommonDxeLib_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartCommonDxeLib.lib"
+ Parent = "RapidStartCommonDxeLib_LIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "RapidStartCommonPeiLib_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartCommonPeiLib.lib"
+ Parent = "RapidStartCommonPeiLib_LIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/I$(RapidStartCommonLib_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/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
new file mode 100644
index 0000000..290a4fa
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/OpensslLib.lib
Binary files differ
diff --git a/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib
new file mode 100644
index 0000000..b05426c
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/PeiCryptLib.lib
Binary files differ
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
new file mode 100644
index 0000000..e308456
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Library/RapidStartPlatformLib/Pei/RapidStartPeiLib.lib
Binary files differ
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 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/Board/EM/RapidStartWrapper/RapidStart.ssp b/Board/EM/RapidStartWrapper/RapidStart.ssp
new file mode 100644
index 0000000..908cabf
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStart.ssp
@@ -0,0 +1,246 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStart.ssp 2 3/21/13 5:49a Bensonlai $
+//
+// $Revision: 2 $
+//
+// $Date: 3/21/13 5:49a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStart.ssp $
+//
+// 2 3/21/13 5:49a Bensonlai
+// [TAG] EIP118812
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] Intel Rapid Start Technology issue on Sharkbay platform
+// [RootCause] FFS_NV_CONFIG_REG(0x47) didn't define to CMOS Manager.
+// [Solution] FFS_NV_CONFIG_REG(0x47) define to CMOS Manager.
+// [Files] RapidStart.ssp, RapidStartWrapper.sdl
+//
+// 1 10/15/12 4:39a 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] RapidStartWrapper.cif
+// RapidStartWrapper.sdl
+// RapidStart.ssp
+// Include\Mbr.h
+// Include\UefiGpt.h
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStart.ssp
+//
+// Description: This AMI Setup Script Processor (SSP) file contains setup items that
+// are related to the CMOS Manager.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+//---------------------------------------------------------------------------
+// CMOS manager starts auto-assigning at 0x40
+//
+// This is a typical CMOS usage arrangement.
+// (Note: these locations are not currently reserverd by default.)
+//---------------------------------------------------------------------------
+//
+// 0x00..0x3F Legacy CMOS area, used by CSM
+// 0x40..0x7F OEM/ODM
+// 0x80..0xBF Chipset
+// 0xC0..0xFF Core+Technologies
+//
+// This is the format of a CMOS token defintion:
+//---------------------------------------------------------------------------
+// NvramField (TOKEN_NAME)
+// OptionBits = integer // how many bits to use
+// [Default = integer] // assembler format "xxxh"
+// [CheckSum = YES | NO] // include=YES | exclude=NO
+// [Location = cmos address, clobber mask] // CMOS register, size/offset
+// EndNvramField
+
+
+//-----------------------------------------------------------------
+// TODO: Check if all 8 bits are needed for each of these locations
+//-----------------------------------------------------------------
+NvramField (CMOS_FFS_NV_CONFIG_REG)
+ OptionBits = 8
+ Default = 00h
+ CheckSum = NO
+ Location = MKF_FFS_NV_CONFIG_REG, 0FFh
+EndNvramField
+
+NvramField (CMOS_FFS_NV_FLAG_REG)
+ OptionBits = 8
+ Default = 00h
+ CheckSum = NO
+ Location = MKF_FFS_NV_FLAG_REG, 0FFh
+EndNvramField
+
+NvramField (CMOS_iFFS_CBTH_DATA_REG)
+ OptionBits = 8
+ Default = 0Ah
+ CheckSum = NO
+ Location = MKF_iFFS_CBTH_DATA_REG, 0FFh
+EndNvramField
+
+// 00 - 01
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD0)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0, 0FFFFh
+EndNvramField
+
+// 02 - 03
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD1)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+2, 0FFFFh
+EndNvramField
+
+// 04 - 05
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD2)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+4, 0FFFFh
+EndNvramField
+
+// 06 - 07
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD3)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+6, 0FFFFh
+EndNvramField
+
+// 08 - 09
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD4)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+8, 0FFFFh
+EndNvramField
+
+// 10 - 11
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD5)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+10, 0FFFFh
+EndNvramField
+
+// 12 - 13
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD6)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+12, 0FFFFh
+EndNvramField
+
+// 14 - 15
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD7)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+14, 0FFFFh
+EndNvramField
+
+// 16 - 17
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD8)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+16, 0FFFFh
+EndNvramField
+
+// 18 - 19
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD9)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+18, 0FFFFh
+EndNvramField
+
+// 20 - 21
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD10)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+20, 0FFFFh
+EndNvramField
+
+// 22 - 23
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD11)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+22, 0FFFFh
+EndNvramField
+
+// 24 - 25
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD12)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+24, 0FFFFh
+EndNvramField
+
+// 26 - 27
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD13)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+26, 0FFFFh
+EndNvramField
+
+// 28 - 29
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD14)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+28, 0FFFFh
+EndNvramField
+
+// 30 - 31
+NvramField (CMOS_iFFS_SMRAM_HASH_WORD15)
+ OptionBits = 16
+ Default = 0000h
+ CheckSum = NO
+ Location = MKF_iFFS_SMRAM_HASH_WORD0+30, 0FFFFh
+EndNvramField
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.c b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.c
new file mode 100644
index 0000000..f8c8172
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.c
@@ -0,0 +1,248 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.c 4 7/16/14 5:14a Joshchou $
+//
+// $Revision: 4 $
+//
+// $Date: 7/16/14 5:14a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartSetup/RapidStartSetup.c $
+//
+// 4 7/16/14 5:14a Joshchou
+// [TAG] EIP177828
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Restore Defaults on setup cannot set the SATA mode to
+// default.
+// [RootCause] When action == EFI_BROWSER_ACTION_DEFAULT_STANDARD.
+// Need to return unsupported.
+// [Solution] Add the judgement when action ==
+// EFI_BROWSER_ACTION_DEFAULT_STANDARD.
+//
+// 3 7/11/14 4:08a Joshchou
+// [TAG] EIP176979
+// [Category] Improvement
+// [Description] Change "#else if" to "#elif".
+//
+// 2 1/13/13 7:48a Bensonlai
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Disabling the RapidStart while STAT mode in the IDE
+// mode
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+// RapidStartSetup.sd, RapidStartSetup.sdl
+//
+// 1 10/15/12 4:42a 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] RapidStartSetup.cif
+// RapidStartSetup.sdl
+// RapidStartSetup.mak
+// RapidStartSetup.sd
+// RapidStartSetup.uni
+// RapidStartSetup.c
+// RapidStartSetup.h
+// RapidStartSetupReset.c
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartSetup.c
+//
+// Description: Create the setup item for RapidStart.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include <token.h>
+#include <Setup.h>
+#include <SetupStrTokens.h>
+#include "RapidStartSetup.h"
+#include <AmiCspLib.h>
+#include <AmiDxeLib.h>
+#if EFI_SPECIFICATION_VERSION>0x20000
+#include <Protocol\HiiDatabase.h>
+#include <Protocol\HiiString.h>
+#else
+#include <Protocol/Hii.h>
+#endif
+
+#if defined RAPID_START_PARTITION_DETECT_MODE && RAPID_START_PARTITION_DETECT_MODE == 1
+
+#define RAPID_START_PARTITION_STATUS_PROTOCOL_GUID \
+ { \
+ 0x65639144, 0xd492, 0x4328, 0xa4, 0x98, 0xf4, 0xb5, 0x54, 0x5e, 0x4a, 0x30 \
+ }
+
+#else
+
+#define RAPID_START_PERSISTENT_DATA_GUID \
+ { \
+ 0xf9f0b131, 0xf346, 0x4f16, 0x80, 0xdd, 0xf9, 0x41, 0x07, 0x2b, 0x3a, 0x7d \
+ }
+
+EFI_GUID gRapidStartPersistentDataGuid = RAPID_START_PERSISTENT_DATA_GUID;
+
+typedef struct {
+ UINT32 RapidStartMem;
+ UINT32 MmioSpace;
+ UINT32 RapidStartGlobalNvsPtr;
+ UINT32 StoreSectors;
+ UINT64 StoreLbaAddr;
+ UINT8 StoreSataPort;
+ UINT8 SataPortConfiguration;
+ UINT32 Tolm;
+ UINT64 Tohm;
+ UINT64 TotalMem;
+ UINT32 RapidStartMemSize;
+ UINT32 ZeroBitmapSize;
+ UINT32 WlanMmioSpace;
+ UINT64 SystemMemoryLengthBelow4GB;
+ UINT64 SystemMemoryLengthAbove4GB;
+ UINT64 AcpiReservedMemoryBase;
+ UINT32 AcpiReservedMemorySize;
+ UINT32 Crc32RecordSize;
+ UINT64 RapidStartStoreUid;
+ UINT32 ActivePageThresholdSizeInSector;
+} RAPID_START_PERSISTENT_DATA;
+
+#endif
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: InitRapidStartInfo
+//
+// Description: Initializes Intel Rapid Start Technology (RapidStart) Setup String
+//
+// Input: HiiHandle - Handle to HII database
+// Class - Indicates the setup class
+//
+// Output: None
+//
+// Notes: PORTING REQUIRED
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID
+InitRapidStartInfo(
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 Class
+)
+{
+ return;
+}
+
+EFI_STATUS
+EFIAPI
+RapidStartMenuEntry (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 Class,
+ IN UINT16 SubClass,
+ IN UINT16 Key
+)
+{
+ EFI_STATUS Status;
+ CALLBACK_PARAMETERS *pCallbackData = NULL;
+ SETUP_DATA *SetupData = NULL;
+ UINTN BufferSize = sizeof(SETUP_DATA);
+ EFI_GUID SetupGuid = SETUP_GUID;
+#if defined RAPID_START_PARTITION_DETECT_MODE && RAPID_START_PARTITION_DETECT_MODE == 1
+ VOID *Empty;
+ EFI_GUID RapidStartPartitionProtocolGuid = RAPID_START_PARTITION_STATUS_PROTOCOL_GUID;
+#else
+ UINTN VariableSize = sizeof(RAPID_START_PERSISTENT_DATA);
+ RAPID_START_PERSISTENT_DATA RapidStartData;
+#endif
+ PCH_SERIES PchSeries = GetPchSeries();;
+
+ pCallbackData = GetCallbackParameters();
+ if (pCallbackData == NULL) return EFI_SUCCESS;
+
+ if(pCallbackData->Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD) return EFI_UNSUPPORTED;
+
+ if (pCallbackData->Action == EFI_BROWSER_ACTION_FORM_OPEN) {
+#if defined RAPID_START_PARTITION_DETECT_MODE && RAPID_START_PARTITION_DETECT_MODE == 1
+ Status = pBS->LocateProtocol ( &RapidStartPartitionProtocolGuid,
+ NULL,
+ &Empty );
+#else
+ Status = pRS->GetVariable ( L"RapidStartData",
+ &gRapidStartPersistentDataGuid,
+ NULL,
+ &VariableSize,
+ &RapidStartData );
+#endif
+ if (!EFI_ERROR(Status)) {
+ // If RapidStart Persistent Data or RAPID_START_PARTITION_STATUS_PROTOCOL_GUID is exist,
+ // hidng the warning message.
+ InitString( HiiHandle, \
+ STRING_TOKEN(STR_RAPIDSTART_PAR_STATUS_PROMPT), \
+ L"");
+ }
+ }
+
+ // Check callback action
+#if ((TSE_BUILD >= 0x1224) && (EFI_SPECIFICATION_VERSION >= 0x2000A))
+ if (pCallbackData->Action != EFI_BROWSER_ACTION_CHANGED)
+ return EFI_SUCCESS;
+#elif ((TSE_BUILD > 0x1208) && (EFI_SPECIFICATION_VERSION >= 0x2000A))
+ if (pCallbackData->Action != EFI_BROWSER_ACTION_CHANGING)
+ return EFI_SUCCESS;
+#endif
+
+ Status = pBS->AllocatePool(EfiBootServicesData, BufferSize, &SetupData);
+
+ Status = HiiLibGetBrowserData( &BufferSize, SetupData, &SetupGuid, L"Setup" );
+
+ if (PchSeries == PchLp) {
+ if (SetupData->ULTSataInterfaceMode == 0) {
+ SetupData->RapidStartEnabled = 0;
+ }
+ } else {
+ if (SetupData->SataInterfaceMode == 0) {
+ SetupData->RapidStartEnabled = 0;
+ }
+ }
+
+ Status = HiiLibSetBrowserData( BufferSize, SetupData, &SetupGuid, L"Setup" );
+
+ pBS->FreePool(SetupData);
+
+
+ return EFI_SUCCESS;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.cif b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.cif
new file mode 100644
index 0000000..38f3760
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "RapidStartSetup"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper\RapidStartSetup"
+ RefName = "RapidStartSetup"
+[files]
+"RapidStartSetup.sdl"
+"RapidStartSetup.mak"
+"RapidStartSetup.sd"
+"RapidStartSetup.uni"
+"RapidStartSetup.c"
+"RapidStartSetup.h"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.h b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.h
new file mode 100644
index 0000000..bc9b688
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.h
@@ -0,0 +1,76 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.h 1 10/15/12 4:42a Bensonlai $
+//
+// $Revision: 1 $
+//
+// $Date: 10/15/12 4:42a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartSetup/RapidStartSetup.h $
+//
+// 1 10/15/12 4:42a 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] RapidStartSetup.cif
+// RapidStartSetup.sdl
+// RapidStartSetup.mak
+// RapidStartSetup.sd
+// RapidStartSetup.uni
+// RapidStartSetup.c
+// RapidStartSetup.h
+// RapidStartSetupReset.c
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartSetup.h
+//
+// Description: Header file for RapidStart.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef __RapidStart_SETUP_H__
+#define __RapidStart_SETUP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#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/RapidStartSetup/RapidStartSetup.mak b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.mak
new file mode 100644
index 0000000..2e563d7
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.mak
@@ -0,0 +1,97 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartSetup/RapidStartSetup.mak 3 5/03/13 2:53a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 5/03/13 2:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartSetup/RapidStartSetup.mak $
+#
+# 3 5/03/13 2:53a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] After changed the iRST status, we don't have to do a
+# cold reset.
+#
+# 2 1/13/13 7:49a Bensonlai
+# [TAG] EIPNone
+# [Category] Improvement
+# [Description] Disabling the RapidStart while STAT mode in the IDE
+# mode
+# [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+# RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+# RapidStartSetup.sd, RapidStartSetup.sdl
+#
+# 1 10/15/12 4:42a 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] RapidStartSetup.cif
+# RapidStartSetup.sdl
+# RapidStartSetup.mak
+# RapidStartSetup.sd
+# RapidStartSetup.uni
+# RapidStartSetup.c
+# RapidStartSetup.h
+# RapidStartSetupReset.c
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartSetup.mak
+#
+# Description: Component description file for the RapidStart
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+All : RapidStartSetup
+
+RapidStartSetup : $(BUILD_DIR)\RapidStartSetup.mak
+
+SetupSdbs : $(BUILD_DIR)\RapidStartSetup.sdb
+
+$(BUILD_DIR)\RapidStartSetup.sdb : $(RapidStartSetup_DIR)\$(@B).sd $(RapidStartSetup_DIR)\$(@B).uni
+ $(STRGATHER) -i INCLUDE -parse -newdb -db $(BUILD_DIR)\$(@B).sdb $(RapidStartSetup_DIR)\$(@B).uni
+ $(STRGATHER) -scan -db $(BUILD_DIR)\$(@B).sdb -od $(BUILD_DIR)\$(@B).sdb $(RapidStartSetup_DIR)\$(@B).sd
+
+$(BUILD_DIR)\RapidStartSetup.mak : $(RapidStartSetup_DIR)\$(@B).cif $(RapidStartSetup_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartSetup_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+SetupBin : $(BUILD_DIR)\RapidStartSetup.obj
+
+$(BUILD_DIR)\RapidStartSetup.obj : $(PROJECT_DIR)\$(RapidStartSetup_DIR)\RapidStartSetup.c $(BUILD_DIR)\SetupStrTokens.h $(AMICSPLib)
+ $(CC) $(CFLAGS) $(INTEL_PCH_INCLUDES) /I$(RapidStartInclude_DIR) /Fo$(BUILD_DIR)\ $(RapidStartSetup_DIR)\RapidStartSetup.c
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartSetup/RapidStartSetup.sd b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sd
new file mode 100644
index 0000000..751d63f
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sd
@@ -0,0 +1,367 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.sd 4 1/15/13 4:46a Bensonlai $
+//
+// $Revision: 4 $
+//
+// $Date: 1/15/13 4:46a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sd $
+//
+// 4 1/15/13 4:46a Bensonlai
+// [TAG] EIP112263
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] [RapidStart] Instant-on can't work
+// [RootCause] Intel reference code can't work on AMI base.
+// [Solution] Modified the PeiGfxDriver.dxs and RapidStartDxe.dxs for
+// AMI code
+// [Files] RapidStartDxePolicyInit.c, RapidStartSetup.uni,
+// RapidStartSetup.sdl, RapidStartSetup.sd, PeiGfxDriver.dxs,
+// RapidStartDxe.dxs
+//
+// 3 1/13/13 7:49a Bensonlai
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Disabling the RapidStart while STAT mode in the IDE
+// mode
+// [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+// RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+// RapidStartSetup.sd, RapidStartSetup.sdl
+//
+// 2 12/27/12 1:17a Bensonlai
+// [TAG] EIP110680
+// [Category] New Feature
+// [Description] When iRST application is run under OS, and change
+// timer.
+// BIOS should update the changed to Setup option as well.
+// [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+// Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+// Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+//
+// 1 10/15/12 4:42a 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] RapidStartSetup.cif
+// RapidStartSetup.sdl
+// RapidStartSetup.mak
+// RapidStartSetup.sd
+// RapidStartSetup.uni
+// RapidStartSetup.c
+// RapidStartSetup.h
+// RapidStartSetupReset.c
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartSetup.sd
+//
+// Description: Create the setup item for RapidStart.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef SATA_MODE_IDE
+#define SATA_MODE_IDE 0
+#endif
+
+#ifndef SATA_MODE_AHCI
+#define SATA_MODE_AHCI 1
+#endif
+
+#ifndef SATA_MODE_RAID
+#define SATA_MODE_RAID 2
+#endif
+
+#ifdef SETUP_DATA_DEFINITION
+/***********************************************************/
+/* Put NVRAM data definitions here.
+/* For example: UINT8 Data1;
+/* These definitions will be converted by the build process
+/* to a definitions of SETUP_DATA fields.
+/***********************************************************/
+
+ UINT8 RapidStartEnabled;
+ UINT8 EntryOnS3RtcWake;
+ UINT16 S3WakeTimerMin;
+ UINT8 EntryOnS3CritBattWake;
+ UINT8 CritBattWakeThreshold;
+ UINT8 ActivePageThresholdSupport;
+ UINT32 ActivePageThresholdSize;
+ UINT8 RapidStartLock;
+ UINT8 RapidStartHybridHardDisk;
+ UINT8 RapidStartDisplaySaveRestore;
+ UINT8 RapidStartDisplayType;
+#endif
+
+#if defined(VFRCOMPILE) && !defined(CONTROLS_ARE_DEFINED)
+#define CONTROL_DEFINITION
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef CONTROL_DEFINITION
+
+#define RAPIDSTART_ONEOF_RAPIDSTARTENABLED\
+ oneof varid = SETUP_DATA.RapidStartEnabled,\
+ prompt = STRING_TOKEN(STR_RAPIDSTART_SUPPORT_PROMPT),\
+ help = STRING_TOKEN(STR_RAPIDSTART_SUPPORT_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_ENTRYONS3RTCWAKE\
+ oneof varid = SETUP_DATA.EntryOnS3RtcWake,\
+ prompt = STRING_TOKEN(STR_S3_RTC_WAKE_PROMPT),\
+ help = STRING_TOKEN(STR_S3_RTC_WAKE_SUPPORT_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_S3WAKETIMERMIN\
+ numeric varid = SETUP_DATA.S3WakeTimerMin,\
+ prompt = STRING_TOKEN(STR_S3_WAKE_TIMER_MIN_PROMPT),\
+ help = STRING_TOKEN(STR_S3_WAKE_TIMER_MIN_SUPPORT_HELP),\
+ flags = RESET_REQUIRED,\
+ minimum = 0,\
+ maximum = 120,\
+ step = 1,\
+ default = 10,\
+ endnumeric;
+
+#define RAPIDSTART_ONEOF_ENTRYONS3CRITBATTWAKE\
+ oneof varid = SETUP_DATA.EntryOnS3CritBattWake,\
+ prompt = STRING_TOKEN(STR_CRIT_BATT_WAKE_PROMPT),\
+ help = STRING_TOKEN(STR_CRIT_BATT_WAKE_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSUPPORT\
+ oneof varid = SETUP_DATA.ActivePageThresholdSupport,\
+ prompt = STRING_TOKEN(STR_ACT_PAGE_SUPPORT_PROMPT),\
+ help = STRING_TOKEN(STR_ACT_PAGE_SUPPORT_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSIZE\
+ numeric varid = SETUP_DATA.ActivePageThresholdSize,\
+ prompt = STRING_TOKEN(STR_ACT_PAGE_SIZE_PROMPT),\
+ help = STRING_TOKEN(STR_ACT_PAGE_SIZE_HELP),\
+ flags = RESET_REQUIRED,\
+ minimum = 0,\
+ maximum = 65535,\
+ step = 1,\
+ default = 0,\
+ endnumeric;
+
+#define RAPIDSTART_ONEOF_CRITBATTWAKETHRESHOLD\
+ numeric varid = SETUP_DATA.CritBattWakeThreshold,\
+ prompt = STRING_TOKEN (STR_CRIT_BAT_WAK_THRHLD),\
+ help = STRING_TOKEN (STR_CRIT_BAT_WAK_THRHLD_HELP),\
+ flags = RESET_REQUIRED,\
+ minimum = 0,\
+ maximum = 100,\
+ step = 1,\
+ default = 10,\
+ endnumeric;
+
+#define RAPIDSTART_ONEOF_RAPIDSTARTPARSTATUSSTRING\
+ text\
+ help = STRING_TOKEN(STR_EMPTY_STRING),\
+ text = STRING_TOKEN(STR_RAPIDSTART_PAR_STATUS_PROMPT),\
+ text = STRING_TOKEN(STR_EMPTY_STRING),\
+ flags = 0,\
+ key = 0;\
+
+#define RAPIDSTART_ONEOF_RAPIDSTARTHYBRIDHARDDISK\
+ oneof varid = SETUP_DATA.RapidStartHybridHardDisk,\
+ prompt = STRING_TOKEN(STR_HYBRID_HARD_DISK_SUPPORT_PROMPT),\
+ help = STRING_TOKEN(STR_HYBRID_HARD_DISK_SUPPORT_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYSAVERESTORE\
+ oneof varid = SETUP_DATA.RapidStartDisplaySaveRestore,\
+ prompt = STRING_TOKEN(STR_DISPLAY_SAVE_RESTORE_PROMPT),\
+ help = STRING_TOKEN(STR_DISPLAY_SAVE_RESTORE_HELP),\
+ option text = STRING_TOKEN(STR_DISABLED), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#define RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYTYPE\
+ oneof varid = SETUP_DATA.RapidStartDisplayType,\
+ prompt = STRING_TOKEN(STR_DISPLAY_TYPE_PROMPT),\
+ help = STRING_TOKEN(STR_DISPLAY_TYPE_HELP),\
+ option text = STRING_TOKEN(STR_BIOS_SAVE_RESTORE_HELP), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = 0;\
+ option text = STRING_TOKEN(STR_DESKTOP_SAVE_RESTORE_TYPE_HELP), value = 1, flags = RESET_REQUIRED, key = 0;\
+ endoneof;
+
+#ifdef SB_ONEOF_SATAINTERFACEMODE
+#undef SB_ONEOF_SATAINTERFACEMODE
+#define SB_ONEOF_SATAINTERFACEMODE\
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;\
+ suppressif ideqval SETUP_DATA.PchSata == 0;\
+ oneof varid = SETUP_DATA.SataInterfaceMode,\
+ prompt = STRING_TOKEN (STR_SATA_MODE_SELECTION_PROMPT),\
+ help = STRING_TOKEN (STR_SATA_MODE_SELECTION_HELP),\
+ option text = STRING_TOKEN (STR_SATA_IDE), value = SATA_MODE_IDE, flags = RESET_REQUIRED | INTERACTIVE, key = AUTO_ID(KEY_IDE);\
+ option text = STRING_TOKEN (STR_SATA_AHCI), value = SATA_MODE_AHCI, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED, key = AUTO_ID(KEY_AHCI);\
+ option text = STRING_TOKEN (STR_SATA_RAID), value = SATA_MODE_RAID, flags = RESET_REQUIRED, key = AUTO_ID(KEY_RAID);\
+ endoneof;\
+ SUPPRESS_GRAYOUT_ENDIF
+#endif
+
+#endif // CONTROL_DEFINITION
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef CONTROLS_WITH_DEFAULTS
+ RAPIDSTART_ONEOF_RAPIDSTARTENABLED
+ RAPIDSTART_ONEOF_ENTRYONS3RTCWAKE
+ RAPIDSTART_ONEOF_S3WAKETIMERMIN
+ RAPIDSTART_ONEOF_ENTRYONS3CRITBATTWAKE
+ RAPIDSTART_ONEOF_CRITBATTWAKETHRESHOLD
+ RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSUPPORT
+ RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSIZE
+ RAPIDSTART_ONEOF_RAPIDSTARTPARSTATUSSTRING
+ RAPIDSTART_ONEOF_RAPIDSTARTHYBRIDHARDDISK
+ RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYSAVERESTORE
+ RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYTYPE
+#endif // CONTROLS_WITH_DEFAULTS
+//---------------------------------------------------------------------------
+
+
+//**********************************************************************
+// Advanced - RAPIDSTART Configuration Form
+//**********************************************************************
+
+#ifdef ADVANCED_FORM_SET
+
+#ifdef FORM_SET_TYPEDEF
+ #include <RapidStartSetup.h>
+#endif
+
+ #ifndef SUPPRESS_GRAYOUT_ENDIF //old Core
+ #define SUPPRESS_GRAYOUT_ENDIF endif;
+ #endif
+
+ #ifdef FORM_SET_GOTO
+ // Define goto commands for the forms defined in this file
+ goto RAPIDSTART_FORM_ID,
+ prompt = STRING_TOKEN(STR_RAPIDSTART_FORM),
+ help = STRING_TOKEN(STR_RAPIDSTART_FORM_HELP);
+ #endif
+
+ #ifdef FORM_SET_FORM
+ // Define forms
+ #ifndef RAPIDSTART_FORM_SETUP
+ #define RAPIDSTART_FORM_SETUP
+ form formid = AUTO_ID(RAPIDSTART_FORM_ID),
+ title = STRING_TOKEN(STR_RAPIDSTART_FORM);
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER OR
+ ideqval SETUP_DATA.RapidStartLock == 1;
+ RAPIDSTART_ONEOF_RAPIDSTARTENABLED
+ endif;
+
+ SEPARATOR
+
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_RAPIDSTARTPARSTATUSSTRING
+ endif;
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_ENTRYONS3RTCWAKE
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0 OR ideqval SETUP_DATA.EntryOnS3RtcWake == 0;
+ RAPIDSTART_ONEOF_S3WAKETIMERMIN
+ SUPPRESS_GRAYOUT_ENDIF
+
+#if defined CRB_EC_SUPPORT && CRB_EC_SUPPORT == 1
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_ENTRYONS3CRITBATTWAKE
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0 OR ideqval SETUP_DATA.EntryOnS3CritBattWake == 0;
+ RAPIDSTART_ONEOF_CRITBATTWAKETHRESHOLD
+ SUPPRESS_GRAYOUT_ENDIF
+#endif
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSUPPORT
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0 OR ideqval SETUP_DATA.ActivePageThresholdSupport == 0;
+ RAPIDSTART_ONEOF_ACTIVEPAGETHRESHOLDSIZE
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_RAPIDSTARTHYBRIDHARDDISK
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0;
+ RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYSAVERESTORE
+ SUPPRESS_GRAYOUT_ENDIF
+
+ grayoutif ideqval SYSTEM_ACCESS.Access == SYSTEM_PASSWORD_USER;
+ suppressif ideqval SETUP_DATA.RapidStartEnabled == 0 OR ideqval SETUP_DATA.RapidStartDisplaySaveRestore == 0;
+ RAPIDSTART_ONEOF_RAPIDSTARTDISPLAYTYPE
+ SUPPRESS_GRAYOUT_ENDIF
+
+ endform;
+ #endif // RAPIDSTART_FORM_SETUP
+ #endif // FORM_SET_FORM
+
+#endif // ADVANCED_FORM_SET
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/RapidStartSetup/RapidStartSetup.sdl b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sdl
new file mode 100644
index 0000000..31e34cc
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sdl
@@ -0,0 +1,161 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartSetup/RapidStartSetup.sdl 4 5/03/13 2:54a Bensonlai $
+#
+# $Revision: 4 $
+#
+# $Date: 5/03/13 2:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartSetup/RapidStartSetup.sdl $
+#
+# 4 5/03/13 2:54a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] After changed the iRST status, we don't have to do a
+# cold reset.
+#
+# 3 1/15/13 4:46a Bensonlai
+# [TAG] EIP112263
+# [Category] Bug Fix
+# [Severity] Normal
+# [Symptom] [RapidStart] Instant-on can't work
+# [RootCause] Intel reference code can't work on AMI base.
+# [Solution] Modified the PeiGfxDriver.dxs and RapidStartDxe.dxs for
+# AMI code
+# [Files] RapidStartDxePolicyInit.c, RapidStartSetup.uni,
+# RapidStartSetup.sdl, RapidStartSetup.sd, PeiGfxDriver.dxs,
+# RapidStartDxe.dxs
+#
+# 2 1/13/13 7:49a Bensonlai
+# [TAG] EIPNone
+# [Category] Improvement
+# [Description] Disabling the RapidStart while STAT mode in the IDE
+# mode
+# [Files] RapidStartDxePolicyInit.c, RapidStartDxePolicyInit.h,
+# RapidStartDxePolicyInit.mak, RapidStartSetup.c, RapidStartSetup.mak,
+# RapidStartSetup.sd, RapidStartSetup.sdl
+#
+# 1 10/15/12 4:42a 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] RapidStartSetup.cif
+# RapidStartSetup.sdl
+# RapidStartSetup.mak
+# RapidStartSetup.sd
+# RapidStartSetup.uni
+# RapidStartSetup.c
+# RapidStartSetup.h
+# RapidStartSetupReset.c
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartSetup.sdl
+#
+# Description: SDL file for the RapidStart
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "RapidStart_Setup"
+ Value = "1"
+ Help = "Main switch to enable RapidStart Setup support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "RapidStartSetup_DIR"
+End
+
+MODULE
+ Help = "Includes RapidStartSetup.mak to Project"
+ File = "RapidStartSetup.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartSetup.sdb"
+ Parent = "SETUP_SDBS"
+ Priority = 30
+ Help = "Includes generic FFS setup screens to the project"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(RapidStartSetup_DIR)\RapidStartSetup.sd"
+ Parent = "SETUP_DEFINITIONS"
+ Priority = 30
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/I$(RapidStartSetup_DIR)"
+ Parent = "RAPIDSTART_INCLUDES"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "-i $(RapidStartSetup_DIR)"
+ Parent = "SETUP_VFR_INCLUDES"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "InitRapidStartInfo,"
+ Parent = "SetupStringInit"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ITEM_CALLBACK(ADVANCED_FORM_SET_CLASS, 0, KEY_IDE, RapidStartMenuEntry),"
+ Parent = "SetupItemCallbacks"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ITEM_CALLBACK(ADVANCED_FORM_SET_CLASS, 0, KEY_AHCI, RapidStartMenuEntry),"
+ Parent = "SetupItemCallbacks"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ITEM_CALLBACK(ADVANCED_FORM_SET_CLASS, 0, KEY_RAID, RapidStartMenuEntry),"
+ Parent = "SetupItemCallbacks"
+ 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/RapidStartSetup/RapidStartSetup.uni b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.uni
new file mode 100644
index 0000000..4f4e34b
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartSetup/RapidStartSetup.uni
Binary files differ
diff --git a/Board/EM/RapidStartWrapper/RapidStartWrapper.cif b/Board/EM/RapidStartWrapper/RapidStartWrapper.cif
new file mode 100644
index 0000000..d784cff
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartWrapper.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "RapidStartWrapper"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper"
+ RefName = "RapidStartWrapper"
+[files]
+"RapidStartWrapper.sdl"
+"RapidStart.ssp"
+"Include\Mbr.h"
+"Include\UefiGpt.h"
+[parts]
+"RapidStartDxePolicyInit"
+"RapidStartCommonLib"
+"RapidStartDxeLib"
+"RapidStartPeiLib"
+"RapidStartSetup"
+"RapidStartWrapperSmm"
+"RapidStartWrapperAcpiTables"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/RapidStartWrapper.sdl b/Board/EM/RapidStartWrapper/RapidStartWrapper.sdl
new file mode 100644
index 0000000..dad40ea
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/RapidStartWrapper.sdl
@@ -0,0 +1,219 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartWrapper.sdl 3 4/15/13 2:33a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 4/15/13 2:33a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapper.sdl $
+#
+# 3 4/15/13 2:33a Bensonlai
+# [TAG] None
+# [Category] Bug Fix
+# [Severity] Important
+# [Symptom] If users change any item from driver then restore to boot
+# setting, our SMI can't distinguish between user's and driver's event.
+# [RootCause] It's an Intel driver issue.
+# [Solution] 1. Removing the sync up with Rapid Start driver and BIOS
+# variable as default.
+# 2. Remove our BIOS workaround.
+# [Files] RapidStartWrapperSmm.sdl, RapidStartWrapperSmm.h,
+# RapidStartWrapperSmm.sdl, RapidStartWrapperAcpiTables.sdl,
+# RapidStartWrapper.sdl
+#
+# 2 3/21/13 5:49a Bensonlai
+# [TAG] EIP118812
+# [Category] Bug Fix
+# [Severity] Critical
+# [Symptom] Intel Rapid Start Technology issue on Sharkbay platform
+# [RootCause] FFS_NV_CONFIG_REG(0x47) didn't define to CMOS Manager.
+# [Solution] FFS_NV_CONFIG_REG(0x47) define to CMOS Manager.
+# [Files] RapidStart.ssp, RapidStartWrapper.sdl
+#
+# 1 10/15/12 4:39a 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] RapidStartWrapper.cif
+# RapidStartWrapper.sdl
+# RapidStart.ssp
+# Include\Mbr.h
+# Include\UefiGpt.h
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartWrapper.sdl
+#
+# Description: SDL file for the RapidStartWrapper.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "RapidStartWrapper_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable RapidStartWrapper support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "FFS_NV_CONFIG_REG"
+ Value = "0x47"
+ Help = "Save CMOS RapidStartFlag REG"
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "FFS_NV_FLAG_REG"
+ Value = "0x88"
+ Help = "Save CMOS RapidStartFlag REG"
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "iFFS_CBTH_DATA_REG"
+ Value = "0x89"
+ Help = "Save critical battery threshole value"
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "iFFS_SMRAM_HASH_WORD0"
+ Value = "0xA0"
+ Help = "Save SMRAM hash value."
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "LOCK_DISABLE_RAPID_START_IF_NO_SSD"
+ Value = "0"
+ Help = "Lock and disable Rapid Start if no SSD found."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SYNC_UP_DRIVER_AND_BIOS_VARIABLE"
+ Value = "0"
+ Help = "If you set the token to 1, please modify the register key(SkipRestoreSettingOnExit) to 1 for Rapid Start driver in Setup.if2"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "RAPID_START_PARTITION_DETECT_MODE"
+ Value = "1"
+ Help = "0: Detect Rapid Start Partition in ReadyToBoot phase(Intel RC original).\1: Detect Rapid Start partition after BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID to be installed."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+PATH
+ Name = "RapidStartWrapper_DIR"
+End
+
+ELINK
+ Name = "$(RapidStartWrapper_DIR)\RapidStart.ssp"
+ Parent = "ADDON_SSP_FILES"
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D FFS_NV_CONFIG_REG=$(FFS_NV_CONFIG_REG)"
+ Parent = "CFLAGS"
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D FFS_NV_FLAG_REG=$(FFS_NV_FLAG_REG)"
+ Parent = "CFLAGS"
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D FFS_CBTH_DATA_REG=$(iFFS_CBTH_DATA_REG)"
+ Parent = "CFLAGS"
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D FFS_SMRAM_HASH_DATA_REG=$(iFFS_SMRAM_HASH_WORD0)"
+ Parent = "CFLAGS"
+ Token = "CMOS_MANAGER_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/I$(RapidStartWrapper_DIR)\Include"
+ Parent = "RAPIDSTART_INCLUDES"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D RAPID_START_PARTITION_DETECT_BEFORE_SETUP"
+ Parent = "GLOBAL_DEFINES"
+ InvokeOrder = AfterParent
+ Token = "RAPID_START_PARTITION_DETECT_MODE" "=" "1"
+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/Smm/RapidStartWrapperSmm.c b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.c
new file mode 100644
index 0000000..2d21006
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.c
@@ -0,0 +1,238 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartWrapperSmm.c 3 5/13/14 4:56a Joshchou $
+//
+// $Revision: 3 $
+//
+// $Date: 5/13/14 4:56a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperSmm.c $
+//
+// 3 5/13/14 4:56a Joshchou
+// [TAG] EIP167032
+// [Category] Improvement
+// [Description] Review the variable's attribute, we shouldn't use
+// runtime attribute with setup variable.
+// [Files] RapidStartWrapperSmm.c
+// RapidStartWrapperSmm.h
+// RapidStartWrapperSmm.cif
+//
+// 2 4/15/13 2:36a Bensonlai
+// [TAG] None
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If users change any item from driver then restore to boot
+// setting, our SMI can't distinguish between user's and driver's event.
+// [RootCause] It's an Intel driver issue.
+// [Solution] 1. Removing the sync up with Rapid Start driver and BIOS
+// variable as default.
+// 2. Remove our BIOS workaround.
+// [Files] RapidStartWrapperSmm.sdl, RapidStartWrapperSmm.h,
+// RapidStartWrapperSmm.sdl, RapidStartWrapperAcpiTables.sdl,
+// RapidStartWrapper.sdl
+//
+// 1 12/27/12 2:23a Bensonlai
+// [TAG] EIP110680
+// [Category] New Feature
+// [Description] When iRST application is run under OS, and change
+// timer.
+// BIOS should update the changed to Setup option as well.
+// [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+// Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+// Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartWrapperSmm.c
+//
+// Description: Sw SMI for RapidStart Wrapper
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "RapidStartWrapperSmm.h"
+
+VOID* InternalGetSmstConfigurationTable(IN EFI_GUID *TableGuid) {
+ EFI_CONFIGURATION_TABLE *Table;
+ UINTN i;
+ EFI_STATUS Status;
+
+ if (mSmmBase == NULL) {
+ Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, &mSmmBase);
+ if (EFI_ERROR(Status) || mSmmBase == NULL)return NULL;
+ }
+
+ if (mSmst == NULL ) {
+ if (mSmmBase!=NULL) {
+ Status = mSmmBase->GetSmstLocation (mSmmBase, &mSmst);
+ if (EFI_ERROR(Status) || mSmst == NULL)return NULL;
+ }
+ }
+
+ if (mSmst != NULL) {
+ Table = mSmst->SmmConfigurationTable;
+ i = mSmst->NumberOfTableEntries;
+
+ for (; i; --i,++Table)
+ {
+ if (CompareGuid(&Table->VendorGuid,TableGuid))
+ return Table->VendorTable;
+ }
+ }
+ return NULL;
+}
+
+VOID
+RapidStartSyncVariable (
+ VOID
+)
+{
+ EFI_STATUS Status;
+ RAPID_START_WRAPPER_SMM_DATA RapidStartWrapperSmmData;
+ RapidStartWrapperSmmData.S3WakeTimerMin = mRapidStartGlobalNvs->WakeTimerMin;
+
+ if ( (mRapidStartGlobalNvs->EventsEnabled & RAPID_START_ACPI_RTC_WAKE) != 0) {
+ RapidStartWrapperSmmData.EntryOnS3RtcWake = 1;
+ } else {
+ RapidStartWrapperSmmData.EntryOnS3RtcWake = 0;
+ }
+
+ if ( (mRapidStartGlobalNvs->EventsEnabled & RAPID_START_ACPI_BATT_WAKE) != 0) {
+ RapidStartWrapperSmmData.EntryOnS3CritBattWake = 1;
+ } else {
+ RapidStartWrapperSmmData.EntryOnS3CritBattWake = 0;
+ }
+
+ Status = mySMMgRT->SetVariable( L"RstWrapVar", \
+ &RapidStartWrapperSmmDataGuid, \
+ EFI_VARIABLE_NON_VOLATILE | \
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | \
+ EFI_VARIABLE_RUNTIME_ACCESS, \
+ sizeof (RAPID_START_WRAPPER_SMM_DATA), \
+ &RapidStartWrapperSmmData
+ );
+
+ if ( EFI_ERROR(Status) ) {
+ return;
+ }
+
+ return;
+}
+
+VOID
+RapidStartWrapperSwSmiCallback (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
+)
+{
+ UINT8 WrapperFunctionIndex;
+
+ WrapperFunctionIndex = IoRead8(SW_SMI_IO_DATA_ADDRESS); // Get Wrapper Function Index
+ IoWrite8(SW_SMI_IO_DATA_ADDRESS, 0x00); // Clear data
+
+ switch ( WrapperFunctionIndex ) {
+ case AMI_RAPID_START_SYNC_VARIABLE_FUNCTION:
+ RapidStartSyncVariable();
+ break;
+
+ default :
+ break;
+ }
+
+ return;
+}
+
+EFI_STATUS
+RapidStartWrapperSmmEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+{
+ RAPID_START_GLOBAL_NVS_AREA_PROTOCOL *RapidStartGlobalNvsAreaProtocol;
+ EFI_SMM_SW_DISPATCH_PROTOCOL *SwDispatch;
+ EFI_SMM_SW_DISPATCH_CONTEXT SwContext;
+ EFI_HANDLE DispatchHandle;
+ EFI_STATUS Status;
+ VOID *ptrRs;
+
+ ptrRs = InternalGetSmstConfigurationTable(&SmmRtServTableGuid);
+ if (ptrRs!=NULL) mySMMgRT = ptrRs;
+
+ DEBUG ((EFI_D_INFO, "RapidStartWrapperSmmEntryPoint()\n"));
+
+ Status = gBS->LocateProtocol (
+ &gRapidStartGlobalNvsAreaProtocolGuid,
+ NULL,
+ (VOID **) &RapidStartGlobalNvsAreaProtocol
+ );
+
+ if ( EFI_ERROR (Status) ) {
+ DEBUG ((EFI_D_INFO, "No RapidStart info protocol available\n"));
+ return Status;
+ }
+
+ mRapidStartGlobalNvs = RapidStartGlobalNvsAreaProtocol->Area;
+ DEBUG ((EFI_D_INFO, "RapidStartGlobalNvs: %x\n", mRapidStartGlobalNvs));
+
+ ///
+ /// Locate the SMM SW dispatch protocol
+ ///
+ Status = gBS->LocateProtocol (&gEfiSmmSwDispatchProtocolGuid, NULL, &SwDispatch);
+ if ( EFI_ERROR (Status) ) {
+ return Status;
+ }
+
+ ///
+ /// Register SWSMI handler
+ ///
+ DEBUG ((EFI_D_INFO, "Register SW_SMI_RAPID_START_WRAPPER: %x\n", SW_SMI_RAPID_START_WRAPPER));
+ SwContext.SwSmiInputValue = SW_SMI_RAPID_START_WRAPPER;
+ Status = SwDispatch->Register (
+ SwDispatch,
+ RapidStartWrapperSwSmiCallback,
+ &SwContext,
+ &DispatchHandle
+ );
+ if ( EFI_ERROR (Status) ) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Smm/RapidStartWrapperSmm.cif b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.cif
new file mode 100644
index 0000000..6ddc4e2
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "RapidStartWrapperSmm"
+ category = ModulePart
+ LocalRoot = "Board\EM\RapidStartWrapper\Smm"
+ RefName = "RapidStartWrapperSmm"
+[files]
+"RapidStartWrapperSmm.c"
+"RapidStartWrapperSmm.h"
+"RapidStartWrapperSmm.mak"
+"RapidStartWrapperSmm.dxs"
+"RapidStartWrapperSmm.sdl"
+<endComponent>
diff --git a/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.dxs b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.dxs
new file mode 100644
index 0000000..247058d
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.dxs
@@ -0,0 +1,92 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartWrapperSmm.dxs 1 12/27/12 2:23a Bensonlai $
+//
+// $Revision: 1 $
+//
+// $Date: 12/27/12 2:23a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperSmm.dxs $
+//
+// 1 12/27/12 2:23a Bensonlai
+// [TAG] EIP110680
+// [Category] New Feature
+// [Description] When iRST application is run under OS, and change
+// timer.
+// BIOS should update the changed to Setup option as well.
+// [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+// Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+// Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartWrapperSmm.dxs
+//
+// Description: Dependency expression file for RapidStartWrapperSmm Driver
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+//
+// Common for R8 and R9 codebase
+//
+#include "AutoGen.h"
+#include "DxeDepex.h"
+
+//
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are both "defined" in R8 codebase;
+// BUILD_WITH_EDKII_GLUE_LIB is defined in Edk-Dev-Snapshot-20070228 and later version
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are "not defined" in R9 codebase.
+//
+#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB)
+#include "EfiDepex.h"
+
+#include EFI_PROTOCOL_DEPENDENCY (SmmBase)
+#include EFI_PROTOCOL_DEPENDENCY (SmmSwDispatch)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartGlobalNvsArea)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+#endif
+
+DEPENDENCY_START
+ EFI_SMM_BASE_PROTOCOL_GUID AND
+ EFI_SMM_SW_DISPATCH_PROTOCOL_GUID AND
+ RAPID_START_GLOBAL_NVS_AREA_PROTOCOL_GUID AND
+ EFI_VARIABLE_ARCH_PROTOCOL_GUID
+DEPENDENCY_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/Smm/RapidStartWrapperSmm.h b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.h
new file mode 100644
index 0000000..c4ba9a2
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.h
@@ -0,0 +1,135 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/RapidStartWrapperSmm.h 3 5/13/14 4:56a Joshchou $
+//
+// $Revision: 3 $
+//
+// $Date: 5/13/14 4:56a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperSmm.h $
+//
+// 3 5/13/14 4:56a Joshchou
+// [TAG] EIP167032
+// [Category] Improvement
+// [Description] Review the variable's attribute, we shouldn't use
+// runtime attribute with setup variable.
+// [Files] RapidStartWrapperSmm.c
+// RapidStartWrapperSmm.h
+// RapidStartWrapperSmm.cif
+//
+// 2 4/15/13 2:37a Bensonlai
+// [TAG] None
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If users change any item from driver then restore to boot
+// setting, our SMI can't distinguish between user's and driver's event.
+// [RootCause] It's an Intel driver issue.
+// [Solution] 1. Removing the sync up with Rapid Start driver and BIOS
+// variable as default.
+// 2. Remove our BIOS workaround.
+// [Files] RapidStartWrapperSmm.sdl, RapidStartWrapperSmm.h,
+// RapidStartWrapperSmm.sdl, RapidStartWrapperAcpiTables.sdl,
+// RapidStartWrapper.sdl
+//
+// 1 12/27/12 2:23a Bensonlai
+// [TAG] EIP110680
+// [Category] New Feature
+// [Description] When iRST application is run under OS, and change
+// timer.
+// BIOS should update the changed to Setup option as well.
+// [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+// Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+// Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+// Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+// Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: RapidStartWrapperSmm.h
+//
+// Description: Sw SMI for RapidStart Wrapper
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _RAPID_START_WRAPPER_SMM_H_
+#define _RAPID_START_WRAPPER_SMM_H_
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include "RapidStartData.h"
+#include <token.h>
+//
+// Driver Consumed Protocol Prototypes
+//
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)
+#include EFI_PROTOCOL_DEPENDENCY (SmmBase)
+#include EFI_PROTOCOL_DEPENDENCY (SmmSwDispatch)
+#include EFI_PROTOCOL_DEPENDENCY (DevicePath)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartGlobalNvsArea)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+#endif
+
+#include <SetupDataDefinition.h>
+#define RAPID_START_WRAPPER_SMM_DATA_GUID { 0xc840359f, 0x1c11, 0x4d41, 0x92, 0x4c, 0x89, 0x70, 0x52, 0x22, 0x6a, 0xd4 }
+EFI_GUID RapidStartWrapperSmmDataGuid = RAPID_START_WRAPPER_SMM_DATA_GUID;
+
+#define EFI_SMM_RUNTIME_SERVICES_TABLE_GUID \
+ { 0x395c33fe, 0x287f, 0x413e, { 0xa0, 0x55, 0x80, 0x88, 0xc0, 0xe1, 0xd4, 0x3e } }
+
+EFI_GUID SmmRtServTableGuid = EFI_SMM_RUNTIME_SERVICES_TABLE_GUID;
+EFI_SMM_BASE_PROTOCOL *mSmmBase;
+EFI_SMM_SYSTEM_TABLE *mSmst = NULL;
+EFI_RUNTIME_SERVICES *mySMMgRT = NULL;
+RAPID_START_GLOBAL_NVS_AREA *mRapidStartGlobalNvs;
+
+//
+// Define SMI number of AMI Wrapper
+//
+#define AMI_RAPID_START_SYNC_VARIABLE_FUNCTION 0x01
+
+typedef struct _RAPID_START_WRAPPER_SMM_DATA {
+ UINT16 S3WakeTimerMin;
+ UINT8 EntryOnS3RtcWake;
+ UINT8 EntryOnS3CritBattWake;
+} RAPID_START_WRAPPER_SMM_DATA;
+#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/Smm/RapidStartWrapperSmm.mak b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.mak
new file mode 100644
index 0000000..85fa7fe
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.mak
@@ -0,0 +1,126 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartWrapperSmm.mak 1 12/27/12 2:23a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 12/27/12 2:23a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperSmm.mak $
+#
+# 1 12/27/12 2:23a Bensonlai
+# [TAG] EIP110680
+# [Category] New Feature
+# [Description] When iRST application is run under OS, and change
+# timer.
+# BIOS should update the changed to Setup option as well.
+# [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+# Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+# Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartWrapperSmm.mak
+#
+# Description: Make file to build RapidStartWrapperSmm components
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+EDK : RapidStartWrapperSmm
+
+RapidStartWrapperSmm : $(BUILD_DIR)\RapidStartWrapperSmm.mak RapidStartWrapperSmmBin
+
+$(BUILD_DIR)\RapidStartWrapperSmm.mak : $(RapidStartWrapperSmm_DIR)\$(@B).cif $(RapidStartWrapperSmm_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartWrapperSmm_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartWrapperSmm_INCLUDES=\
+ $(RAPIDSTART_INCLUDES)\
+ $(EdkIIGlueLib_INCLUDES)\
+
+RapidStartWrapperSmm_DEFINES = $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartWrapperSmmEntryPoint"\
+ /D __EDKII_GLUE_BASE_LIB__ \
+ /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ /D __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ \
+ /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ /D __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ \
+ /D __EDKII_GLUE_UEFI_LIB__ \
+ /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
+ /D __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__ \
+ /D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \
+
+RapidStartWrapperSmm_LIB =\
+ $(EFIPROTOCOLLIB)\
+ $(EDKPROTOCOLLIB)\
+ $(EDKFRAMEWORKPROTOCOLLIB)\
+ $(EdkIIGlueBaseLib_LIB)\
+!IF "$(x64_BUILD)"=="1"
+ $(EdkIIGlueBaseLibX64_LIB)\
+!ELSE
+ $(EdkIIGlueBaseLibIA32_LIB)\
+!ENDIF
+ $(ArchProtocolLib)\
+ $(EdkIIGlueBaseIoLibIntrinsic_LIB)\
+ $(EdkIIGlueBaseMemoryLib_LIB)\
+ $(EdkIIGlueDxeMemoryAllocationLib_LIB)\
+ $(EdkIIGlueDxeServicesTableLib_LIB)\
+ $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\
+ $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)\
+ $(EdkIIGlueBasePciLibPciExpress_LIB)\
+ $(EdkIIGlueUefiLib_LIB)\
+ $(EdkIIGlueUefiBootServicesTableLib_LIB)\
+ $(EdkIIGlueUefiDevicePathLib_LIB)\
+ $(RapidStartProtocolLib_LIB)\
+ $(RapidStartGuidLib_LIB)\
+
+RapidStartWrapperSmmBin: $(RapidStartWrapperSmm_LIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartWrapperSmm.mak all \
+ "MY_INCLUDES=$(RapidStartWrapperSmm_INCLUDES)" \
+ "MY_DEFINES=$(RapidStartWrapperSmm_DEFINES)" \
+ GUID=760DCD41-FF47-41d8-91B2-BC527D6C5823\
+ ENTRY_POINT=_ModuleEntryPoint \
+ TYPE=BS_DRIVER\
+ EDKIIModule=SMMDRIVER\
+ DEPEX1=$(RapidStartWrapperSmm_DIR)\RapidStartWrapperSmm.dxs\
+ DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \
+ COMPRESS=1
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Smm/RapidStartWrapperSmm.sdl b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.sdl
new file mode 100644
index 0000000..a99eb23
--- /dev/null
+++ b/Board/EM/RapidStartWrapper/Smm/RapidStartWrapperSmm.sdl
@@ -0,0 +1,120 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/RapidStartWrapperSmm.sdl 2 4/15/13 2:36a Bensonlai $
+#
+# $Revision: 2 $
+#
+# $Date: 4/15/13 2:36a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartWrapperSmm.sdl $
+#
+# 2 4/15/13 2:36a Bensonlai
+# [TAG] None
+# [Category] Bug Fix
+# [Severity] Important
+# [Symptom] If users change any item from driver then restore to boot
+# setting, our SMI can't distinguish between user's and driver's event.
+# [RootCause] It's an Intel driver issue.
+# [Solution] 1. Removing the sync up with Rapid Start driver and BIOS
+# variable as default.
+# 2. Remove our BIOS workaround.
+# [Files] RapidStartWrapperSmm.sdl, RapidStartWrapperSmm.h,
+# RapidStartWrapperSmm.sdl, RapidStartWrapperAcpiTables.sdl,
+# RapidStartWrapper.sdl
+#
+# 1 12/27/12 2:23a Bensonlai
+# [TAG] EIP110680
+# [Category] New Feature
+# [Description] When iRST application is run under OS, and change
+# timer.
+# BIOS should update the changed to Setup option as well.
+# [Files] Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.c
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.h
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.mak
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.dxs
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.sdl
+# Board\EM\RapidStartWrapper\Smm\RapidStartWrapperSmm.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.cif
+# Board\EM\RapidStartWrapper\AcpiTables\RapidStartWrapperAcpiTables.sdl
+# Board\EM\RapidStartWrapper\AcpiTables\Ssdt\RapidStartWrapper.asl
+# Board\EM\RapidStartWrapper\RapidStartSetup\RapidStartSetup.sd
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: RapidStartWrapperSmm.sdl
+#
+# Description: SDL file for RapidStartWrapperSmm
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "RAPID_START_WRAPPER_SMM_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable RapidStartWrapperSmm support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Token = "SYNC_UP_DRIVER_AND_BIOS_VARIABLE" "=" "1"
+End
+
+TOKEN
+ Name = "AMI_SW_SMI_RAPID_START_WRAPPER"
+ Value = "0xB4"
+ Help = "SWSMI# for AMI_SW_SMI_RAPID_START_WRAPPER"
+ TokenType = Integer
+ TargetH = Yes
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "RapidStartWrapperSmm_DIR"
+End
+
+MODULE
+ Help = "Includes RapidStartWrapperSmm.mak to Project"
+ File = "RapidStartWrapperSmm.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartWrapperSmm.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D SW_SMI_RAPID_START_WRAPPER=$(AMI_SW_SMI_RAPID_START_WRAPPER)"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ 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 **
+#** **
+#*************************************************************************
+#*************************************************************************