summaryrefslogtreecommitdiff
path: root/ReferenceCode/RapidStart
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 /ReferenceCode/RapidStart
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'ReferenceCode/RapidStart')
-rw-r--r--ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.cif11
-rw-r--r--ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.inf66
-rw-r--r--ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.mak105
-rw-r--r--ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.sdl91
-rw-r--r--ReferenceCode/RapidStart/AcpiTables/Ssdt/RapidStart.asl80
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.c935
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.cif12
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.dxs56
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.inf102
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.mak130
-rw-r--r--ReferenceCode/RapidStart/Dxe/RapidStartDxe.sdl68
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.cif11
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.efibin0 -> 2880 bytes
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.inf36
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.mak72
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.sdl85
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.cif12
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.dxs32
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.efibin0 -> 32256 bytes
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.inf40
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.mak79
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.sdl84
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.c141
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.cif12
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.h29
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.inf58
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.mak76
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.sdl77
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.c55
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.cif12
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.h35
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.inf51
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.mak75
-rw-r--r--ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.sdl77
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.c40
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.h31
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartGuidLib.cif16
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartGuidLib.inf60
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartGuidLib.mak82
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartGuidLib.sdl68
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.c27
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.h41
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.c40
-rw-r--r--ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.h31
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartAcpi.dsc69
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartAhciReg.h163
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartConfig.h70
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartData.h144
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartDxe.dsc26
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartDxeLib.dsc24
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartInclude.cif16
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartInclude.sdl68
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartPei.dsc25
-rw-r--r--ReferenceCode/RapidStart/Include/RapidStartPeiLib.dsc24
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartAhci.c1211
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartAhci.h344
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.c2379
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.cif14
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.dxs41
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.inf119
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.mak151
-rw-r--r--ReferenceCode/RapidStart/Pei/RapidStartPei.sdl68
-rw-r--r--ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.c33
-rw-r--r--ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.h89
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.c35
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.h190
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.cif14
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.inf51
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.mak60
-rw-r--r--ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.sdl72
-rw-r--r--ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.c30
-rw-r--r--ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.h63
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.c31
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.h100
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.c40
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.h93
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.c46
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.h162
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.cif18
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.inf61
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.mak58
-rw-r--r--ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.sdl71
-rw-r--r--ReferenceCode/RapidStart/RapidStart.cif23
-rw-r--r--ReferenceCode/RapidStart/RapidStart.sdl237
-rw-r--r--ReferenceCode/RapidStart/ReleaseNotes.chmbin0 -> 87046 bytes
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.c836
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.cif14
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.dxs47
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.h47
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.inf104
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.mak130
-rw-r--r--ReferenceCode/RapidStart/Smm/RapidStartSmm.sdl97
-rw-r--r--ReferenceCode/RapidStart/Smm/x64/RapidStartAsm.asm56
93 files changed, 11105 insertions, 0 deletions
diff --git a/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.cif b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.cif
new file mode 100644
index 0000000..9e95414
--- /dev/null
+++ b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "RapidStartAcpiTables"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\AcpiTables"
+ RefName = "RapidStartAcpiTables"
+[files]
+"RapidStartAcpiTables.sdl"
+"RapidStartAcpiTables.mak"
+"RapidStartAcpiTables.inf"
+"Ssdt\RapidStart.asl"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.inf b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.inf
new file mode 100644
index 0000000..6b98d1f
--- /dev/null
+++ b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.inf
@@ -0,0 +1,66 @@
+## @file
+# Component description file for the ACPI tables
+#
+#@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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[defines]
+BASE_NAME = RapidStartAcpiTables
+FILE_GUID = 60AC3A8F-4D66-4CD4-895A-C3F06E6665EE
+COMPONENT_TYPE = ACPITABLE #ECP Override RAPID_START_ACPI_TABLES
+FFS_EXT = .ffs
+
+[sources.common]
+ Ssdt/RapidStart.asl
+
+[libraries.common]
+
+[includes.common]
+ .
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/Include
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EFI_SOURCE)/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Framework
+#
+# Typically the sample code referenced will be available in the code base already
+# So keep this include at the end to defer to the source base definition
+# and only use the sample code definition if source base does not include these files.
+#
+
+#
+# Edk II Glue Library, some hearder are included by R9 header so have to include
+#
+
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/Framework
+ $(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]
diff --git a/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.mak b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.mak
new file mode 100644
index 0000000..998ef06
--- /dev/null
+++ b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.mak
@@ -0,0 +1,105 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartAcpiTables/RapidStartAcpiTables.mak 3 6/02/13 8:23a Joshchou $
+#
+# $Revision: 3 $
+#
+# $Date: 6/02/13 8:23a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartAcpiTables/RapidStartAcpiTables.mak $
+#
+# 3 6/02/13 8:23a Joshchou
+# [TAG] None
+# [Category] Improvement
+# [Description] Change IASL compiler path to
+# $(ACPIPLATFORM_ASL_COMPILER) in SharkBay project.
+#
+# 2 11/20/12 2:22a Bensonlai
+# [TAG] EIP107013
+# [Category] Improvement
+# [Description] Update Shark Bay Rapid Start Reference Code Version
+# 0.8.0.0
+# [Files] RapidStartAcpiTables.sdl
+# RapidStartAcpiTables.mak
+# RapidStartAcpiTables.inf
+# Ssdt\RapidStart.asl
+# RapidStartAcpiTables.cif
+#
+# 1 4/19/12 7:50a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+#-----------------------------------------------------------------------
+# ASL compiler definition
+#-----------------------------------------------------------------------
+MASL = $(SILENT)asl.exe # Microsoft ASL compiler
+!IF "$(ACPIPLATFORM_ASL_COMPILER)"==""
+!ERROR It is an invalid path, please check your ASL compiler path.
+!ENDIF
+
+IASL = $(ACPIPLATFORM_ASL_COMPILER)
+#-----------------------------------------------------------------------
+ASL_COMPILER = IASL # Default ASL compiler. Can be 'IASL' for Intel ASL and 'MASL' for Microsoft ASL compiler.
+# Note. Msft. ASL compiler of version 1.0.14NT correctly process ACPI 2.0 extended ASL objects.
+#-----------------------------------------------------------------------
+EDK : RapidStartASL
+
+ALLRapidStartSEC = $(BUILD_DIR)\RapidStart.sec\
+
+RapidStartASL: $(BUILD_DIR)\RapidStartAcpiTables.ffs
+
+$(BUILD_DIR)\RapidStart.aml: $(INTEL_RAPIDSTART_ASL_FILE)
+!if "$(ASL_COMPILER)" == "MASL"
+ @$(MASL) /Fo=$@ $**
+!elseif "$(ASL_COMPILER)" == "IASL"
+ @cl /C /EP $(INTEL_RAPIDSTART_ASL_FILE) > $(BUILD_DIR)\RapidStart.asl
+ $(IASL) -p $(BUILD_DIR)\RapidStart.aml $(BUILD_DIR)\RapidStart.asl
+!endif
+
+$(BUILD_DIR)\RapidStart.sec: $(BUILD_DIR)\RapidStart.aml
+ $(GENSECTION) -I $** -O $@ -S EFI_SECTION_RAW
+
+$(BUILD_DIR)\RapidStartAcpiTables.ffs: $(ALLRapidStartSEC) $(RapidStartAcpiTables_DIR)\RapidStartAcpiTables.mak
+ $(GENFFSFILE) -B $(BUILD_DIR) -V -o $@ -P1 <<$(BUILD_DIR)\RapidStartAcpiTables.pkg
+PACKAGE.INF
+[.]
+BASE_NAME = RapidStartAcpiTables
+FFS_FILEGUID = 60AC3A8F-4D66-4CD4-895A-C3F06E6665EE
+FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM
+FFS_ATTRIB_CHECKSUM = TRUE
+
+IMAGE_SCRIPT =
+{
+ Compress (dummy) {
+ $(PROJECT_DIR)\$(BUILD_DIR)\RapidStart.sec
+ }
+}
+<<KEEP
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.sdl b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.sdl
new file mode 100644
index 0000000..be7a5f2
--- /dev/null
+++ b/ReferenceCode/RapidStart/AcpiTables/RapidStartAcpiTables.sdl
@@ -0,0 +1,91 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartAcpiTables/RapidStartAcpiTables.sdl 3 11/20/12 2:22a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 11/20/12 2:22a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartAcpiTables/RapidStartAcpiTables.sdl $
+#
+# 3 11/20/12 2:22a Bensonlai
+# [TAG] EIP107013
+# [Category] Improvement
+# [Description] Update Shark Bay Rapid Start Reference Code Version
+# 0.8.0.0
+# [Files] RapidStartAcpiTables.sdl
+# RapidStartAcpiTables.mak
+# RapidStartAcpiTables.inf
+# Ssdt\RapidStart.asl
+# RapidStartAcpiTables.cif
+#
+# 2 10/15/12 5:46a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 1 4/19/12 7:50a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartAcpiTables_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStart ACPI tables in Project"
+End
+
+MODULE
+ Help = "Includes RapidStartAcpiTables.mak to Project"
+ File = "RapidStartAcpiTables.mak"
+End
+
+PATH
+ Name = "RapidStartAcpiTables_DIR"
+End
+
+TOKEN
+ Name = "INTEL_RAPIDSTART_ASL_FILE"
+ Value = "$(RapidStartAcpiTables_DIR)\Ssdt\RapidStart.asl"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartAcpiTables.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/ReferenceCode/RapidStart/AcpiTables/Ssdt/RapidStart.asl b/ReferenceCode/RapidStart/AcpiTables/Ssdt/RapidStart.asl
new file mode 100644
index 0000000..0004f89
--- /dev/null
+++ b/ReferenceCode/RapidStart/AcpiTables/Ssdt/RapidStart.asl
@@ -0,0 +1,80 @@
+/*++
+ This file contains an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+--*/
+
+/*++
+
+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.
+
+Module Name:
+
+ RapidStart.asl
+
+Abstract:
+
+ RapidStart ACPI ASL code to support OS control
+
+--*/
+
+
+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
+ }
+
+ Name(_HID,EISAID("INT3392"))
+ Name(_CID,EISAID("PNP0C02"))
+
+ Method(GFFS,0,Serialized) {
+ Return(FFSS)
+ }
+ Method(SFFS,1,Serialized) {
+ And(Arg0, FFSA, FFSS)
+ 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)
+ }
+ Return(FFST)
+ }
+ }
+ }
+}
diff --git a/ReferenceCode/RapidStart/Dxe/RapidStartDxe.c b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.c
new file mode 100644
index 0000000..8e7cf92
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.c
@@ -0,0 +1,935 @@
+/** @file
+ This Dxe driver will initialize RapidStart Persistent Data Variable and also verify RapidStart Store valid or not
+
+@copyright
+ Copyright (c) 1999 - 2013 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include "RapidStartConfig.h"
+#include EFI_PROTOCOL_PRODUCER (RapidStartInfo)
+#include EFI_PROTOCOL_CONSUMER (RapidStartPlatformPolicy)
+#include EFI_GUID_DEFINITION (RapidStartAcpiTableStorage)
+#include EFI_PROTOCOL_PRODUCER (RapidStartGlobalNvsArea)
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEPENDENCY (AcpiTable)
+#else
+#include EFI_PROTOCOL_DEPENDENCY (AcpiSupport)
+#endif
+#include EFI_PROTOCOL_CONSUMER (FirmwareVolume)
+
+#include <PchAccess.h>
+#include <SaAccess.h>
+#include EFI_GUID_DEFINITION (AcpiVariable)
+#include <RapidStartData.h>
+#include <RapidStartCommonLib.h>
+#include <RapidStartAhciReg.h>
+#include "Acpi3_0.h"
+#include <RapidStartDxeLib.h>
+#include <RcFviDxeLib.h>
+#endif
+
+#include "GfxDisplayLibDxe.h"
+#include EFI_PROTOCOL_PRODUCER (DxeGfxProtocol)
+
+EFI_GUID gEfiAcpiVariableGuid = EFI_ACPI_VARIABLE_GUID;
+
+RAPID_START_GLOBAL_NVS_AREA_PROTOCOL mRapidStartGlobalNvsAreaProtocol;
+RAPID_START_PERSISTENT_DATA *mRapidStartData;
+RAPID_START_PLATFORM_POLICY_PROTOCOL *mRapidStartPolicy;
+BOOLEAN mForceNewStoreUid = FALSE;
+BOOLEAN SecondTimeSearchRSTPartition;
+
+/**
+ Search for RapidStart Store and verify if valid. Install ACPI table only when RapidStart can be performed.
+
+ @param[in] Event - The event that triggered this notification function
+ @param[in] Context - Pointer to the notification functions context
+**/
+
+VOID
+EFIAPI
+SearchRapidStartPartition (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+;
+
+FVI_ELEMENT_AND_FUNCTION mRapidStartFviElementsData[] = {
+ {
+ DEFAULT_FVI_ELEMENT_DATA(RAPID_START),
+ NULL
+ }
+};
+
+FVI_DATA_HUB_CALLBACK_CONTEXT mRapidStartFviVersionData = {
+ MISC_SUBCLASS_FVI_HEADER_ENTRY(RAPID_START),
+ mRapidStartFviElementsData,
+};
+
+UINTN mRapidStartFviElements = sizeof (mRapidStartFviElementsData) / sizeof (FVI_ELEMENT_AND_FUNCTION);
+
+/**
+ Installs RapidStart info protocols.
+
+ @param[in] ImageHandle - Image handle for this driver image
+
+ @retval EFI_OUT_OF_RESOURCES - Not enough resource to install RapidStart Info Protocol
+ @retval EFI_SUCCESS - RapidStart Info Protocol installed successfully
+**/
+STATIC
+EFI_STATUS
+RapidStartInstallInfoProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ RAPID_START_INFO_PROTOCOL *pRapidStartInfoProtocol;
+ EFI_STATUS Status;
+
+ ///
+ /// Install RAPID_START_INFO_PROTOCOL
+ ///
+ pRapidStartInfoProtocol = AllocateZeroPool (sizeof (RAPID_START_INFO_PROTOCOL));
+ if (pRapidStartInfoProtocol == NULL) {
+ ASSERT (FALSE);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ pRapidStartInfoProtocol->Revision = RAPID_START_INFO_PROTOCOL_REVISION_1;
+ ///
+ /// RCVersion[32:0] is the release number.
+ /// For example:
+ /// RapidStart Framework 0.5.0 should be 00 05 00 00 (0x00050000)
+ ///
+ pRapidStartInfoProtocol->RCVersion = RAPID_START_RC_VERSION;
+ DEBUG ((EFI_D_INFO, "RapidStart Reference Code Revision = %X\n", pRapidStartInfoProtocol->RCVersion));
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gRapidStartInfoProtocolGuid,
+ pRapidStartInfoProtocol,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ Allocates RapidStart memory ranges.
+
+ @param[in] ImageHandle - Image handle for this driver image
+ @param[in,out] RapidStartData - Pointer to RapidStart persistent data
+**/
+STATIC
+VOID
+RapidStartAllocateMemory (
+ IN EFI_HANDLE ImageHandle,
+ IN OUT RAPID_START_PERSISTENT_DATA *RapidStartData
+ )
+{
+ EFI_PHYSICAL_ADDRESS Addr;
+ EFI_STATUS Status;
+ UINT64 MemMax;
+ RAPID_START_MEM_DATA *RapidStartMemData;
+ EFI_STATUS GfxStatus;
+ DXE_GFX_PROTOCOL *DxeGfxProtocol;
+ UINT64 *DssAddress;
+ UINT64 DssSize;
+
+ DssAddress = NULL;
+ DssSize = 0;
+
+ if (RapidStartData->Tohm > MEM_EQU_4GB) {
+ MemMax = RapidStartData->Tohm;
+ } else {
+ MemMax = RapidStartData->Tolm;
+ }
+
+ RapidStartData->ZeroBitmapSize = ALIGN ((UINT32) (RShiftU64 (NUMBER_OF_PAGES (MemMax), 3) + 8), EFI_PAGE_SIZE);
+ RapidStartData->RapidStartMemSize = ALIGN (
+ sizeof (RAPID_START_MEM_DATA) + AHCI_MEM_MAX_SIZE + RapidStartData->ZeroBitmapSize,
+ EFI_PAGE_SIZE
+ );
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ RapidStartData->Crc32RecordSize = ALIGN ((UINT32) DivU64x32 (MemMax, (MEMORY_CRC32_GRANULARITY / 4)), EFI_PAGE_SIZE);
+ RapidStartData->RapidStartMemSize += RapidStartData->Crc32RecordSize;
+#else
+ RapidStartData->Crc32RecordSize = 0;
+#endif
+
+ if (mRapidStartPolicy->DisplaySaveRestore == 1) {
+ GfxStatus = gBS->LocateProtocol (&gDxeGfxProtocolGuid, NULL, &DxeGfxProtocol);
+ if (!EFI_ERROR (GfxStatus)) {
+ Status = DxeGfxProtocol->AllocateDssBuffer ((UINT8)mRapidStartPolicy->DisplayType + 1);
+ Status = DxeGfxProtocol->GetDssAddress (&DssAddress, &DssSize);
+ }
+ }
+
+ RapidStartData->DssAddress = (UINT64)(DssAddress);
+ RapidStartData->DssSize = DssSize;
+ RapidStartData->DisplayType = (UINT8)(mRapidStartPolicy->DisplayType);
+ DEBUG ((EFI_D_INFO, "RapidStart Display DssAddress = %x, DssSize = %x\n", DssAddress, DssSize));
+
+ RapidStartData->HybridHardDisk = (UINT8)(mRapidStartPolicy->HybridHardDisk);
+ ///
+ /// Allocate RapidStart reserved memory
+ ///
+ Addr = (UINT64) AllocateReservedPages (EFI_SIZE_TO_PAGES (RapidStartData->RapidStartMemSize));
+ ASSERT (Addr != 0);
+ ASSERT (RShiftU64 (Addr, 32) == 0);
+
+ RapidStartData->RapidStartMem = (UINT32) Addr;
+ DEBUG ((EFI_D_ERROR, "RapidStartMem = %X\n", RapidStartData->RapidStartMem));
+ DEBUG ((EFI_D_ERROR, "RapidStartMemSize = %X\n", RapidStartData->RapidStartMemSize));
+ DEBUG ((EFI_D_ERROR, "ZeroBitmapSize = %X\n", RapidStartData->ZeroBitmapSize));
+ DEBUG ((EFI_D_ERROR, "Crc32RecordSize = %X\n", RapidStartData->Crc32RecordSize));
+ ///
+ /// Initialize private memory data
+ ///
+ RapidStartMemData = RAPID_START_MEM_DATA_PTR (RapidStartData);
+ RapidStartMemData->EntryCanceled = 0;
+ ///
+ /// Allocate RapidStart AHCI MMIO
+ ///
+ Addr = 0xFFFFFFFF;
+ Status = gDS->AllocateMemorySpace (
+//AMI_OVERRIDE_FOR_RAPID_START
+// EfiGcdAllocateMaxAddressSearchBottomUp,
+ EfiGcdAllocateMaxAddressSearchTopDown,
+//AMI_OVERRIDE_FOR_RAPID_START
+ EfiGcdMemoryTypeMemoryMappedIo,
+ N_PCH_SATA_AHCI_BAR_ALIGNMENT, // 2^11: 2K Alignment
+ V_PCH_SATA_AHCI_BAR_LENGTH, // 2K Length
+ &Addr,
+ ImageHandle,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ RapidStartData->MmioSpace = (UINT32) Addr;
+ ///
+ /// Allocate Wlan MMIO
+ ///
+ Addr = 0xFFFFFFFF;
+ Status = gDS->AllocateMemorySpace (
+//AMI_OVERRIDE_FOR_RAPID_START
+// EfiGcdAllocateMaxAddressSearchBottomUp,
+ EfiGcdAllocateMaxAddressSearchTopDown,
+//AMI_OVERRIDE_FOR_RAPID_START
+ EfiGcdMemoryTypeMemoryMappedIo,
+ 15, // 2^15: 32K Alignment
+ 0x8000, // 32K Length
+ &Addr,
+ ImageHandle,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ RapidStartData->WlanMmioSpace = (UINT32) Addr;
+
+}
+
+/**
+ Initialize RapidStart ACPI tables
+
+ @retval EFI_SUCCESS RapidStart ACPI tables are initialized successfully
+ @retval EFI_NOT_FOUND RapidStart ACPI tables not found
+**/
+STATIC
+EFI_STATUS
+InitializeRapidStartAcpiTables (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ EFI_FV_FILETYPE FileType;
+ UINT32 FvStatus;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINTN Size;
+ UINTN i;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *FwVol;
+ INTN Instance;
+ EFI_ACPI_COMMON_HEADER *CurrentTable;
+ UINTN AcpiTableKey;
+ UINT8 *CurrPtr;
+ UINT8 *EndPtr;
+ UINT32 *Signature;
+ EFI_ACPI_DESCRIPTION_HEADER *RapidStartAcpiTable;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+#else
+ EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport;
+#endif
+
+ FwVol = NULL;
+ RapidStartAcpiTable = NULL;
+
+ ///
+ /// Locate ACPI support protocol
+ ///
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, &AcpiTable);
+#else
+ Status = gBS->LocateProtocol (&gEfiAcpiSupportProtocolGuid, NULL, (VOID **) &AcpiSupport);
+#endif
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Locate protocol.
+ /// There is little chance we can't find an FV protocol
+ ///
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolumeProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ ASSERT_EFI_ERROR (Status);
+ ///
+ /// Looking for FV with ACPI storage file
+ ///
+ for (i = 0; i < NumberOfHandles; i++) {
+ ///
+ /// Get the protocol on this handle
+ /// This should not fail because of LocateHandleBuffer
+ ///
+ Status = gBS->HandleProtocol (
+ HandleBuffer[i],
+ &gEfiFirmwareVolumeProtocolGuid,
+ (VOID **) &FwVol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// See if it has the ACPI storage file
+ ///
+ Size = 0;
+ FvStatus = 0;
+ Status = FwVol->ReadFile (
+ FwVol,
+ &gRapidStartAcpiTableStorageGuid,
+ NULL,
+ &Size,
+ &FileType,
+ &Attributes,
+ &FvStatus
+ );
+
+ ///
+ /// If we found it, then we are done
+ ///
+ if (Status == EFI_SUCCESS) {
+ break;
+ }
+ }
+ ///
+ /// Free any allocated buffers
+ ///
+ FreePool (HandleBuffer);
+
+ ///
+ /// Sanity check that we found our data file
+ ///
+ ASSERT (FwVol != NULL);
+ if (FwVol == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ ///
+ /// Our exit status is determined by the success of the previous operations
+ /// If the protocol was found, Instance already points to it.
+ /// Read tables from the storage file.
+ ///
+ Instance = 0;
+ CurrentTable = NULL;
+ while (Status == EFI_SUCCESS) {
+ Status = FwVol->ReadSection (
+ FwVol,
+ &gRapidStartAcpiTableStorageGuid,
+ EFI_SECTION_RAW,
+ Instance,
+ (VOID **) &CurrentTable,
+ &Size,
+ &FvStatus
+ );
+
+ if (!EFI_ERROR (Status)) {
+ ///
+ /// Check the table ID to modify the table
+ ///
+ if (((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->OemTableId == EFI_SIGNATURE_64 ('I', 'f', 'f', 's', 'A', 's', 'l', 0)) {
+ RapidStartAcpiTable = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable;
+ ///
+ /// Locate the SSDT package
+ ///
+ CurrPtr = (UINT8 *) RapidStartAcpiTable;
+ EndPtr = CurrPtr + RapidStartAcpiTable->Length;
+
+ for (; CurrPtr <= EndPtr; CurrPtr++) {
+ Signature = (UINT32 *) (CurrPtr + 3);
+ if (*Signature == EFI_SIGNATURE_32 ('F', 'F', 'S', 'N')) {
+ ASSERT_EFI_ERROR (*(UINT32 *) (CurrPtr + 3 + sizeof (*Signature) + 2) == 0xFFFF0000);
+ ASSERT_EFI_ERROR (*(UINT16 *) (CurrPtr + 3 + sizeof (*Signature) + 2 + sizeof (UINT32) + 1) == 0xAA55);
+ ///
+ /// RapidStart Global NVS Area address
+ ///
+ *(UINT32 *) (CurrPtr + 3 + sizeof (*Signature) + 2) = (UINT32) (UINTN) mRapidStartGlobalNvsAreaProtocol.Area;
+ ///
+ /// RapidStart Global NVS Area size
+ ///
+ *(UINT16 *) (CurrPtr + 3 + sizeof (*Signature) + 2 + sizeof (UINT32) + 1) =
+ sizeof (RAPID_START_GLOBAL_NVS_AREA);
+
+ AcpiTableKey = 0;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ RapidStartAcpiTable,
+ RapidStartAcpiTable->Length,
+ &AcpiTableKey
+ );
+#else
+ Status = AcpiSupport->SetAcpiTable (
+ AcpiSupport,
+ RapidStartAcpiTable,
+ TRUE,
+ EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0,
+ &AcpiTableKey
+ );
+ Status = AcpiSupport->PublishTables (
+ AcpiSupport,
+ EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0
+ );
+#endif
+ ASSERT_EFI_ERROR (Status);
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ ///
+ /// Increment the instance
+ ///
+ Instance++;
+ CurrentTable = NULL;
+ }
+ }
+
+ return Status;
+
+}
+
+/**
+ Update RapidStart Persistent Data if necessary.
+
+ @param[in] RapidStartData - Pointer to RapidStart persistent data
+
+ @retval EFI_SUCCESS - RapidStart Persistent Data updated successfully
+**/
+STATIC
+EFI_STATUS
+RapidStartUpdatePersistentData (
+ IN RAPID_START_PERSISTENT_DATA *RapidStartData
+ )
+{
+ RAPID_START_PERSISTENT_DATA RapidStartDataOrg;
+ UINTN RapidStartDataSize;
+ EFI_STATUS Status;
+
+ RapidStartDataSize = sizeof (RAPID_START_PERSISTENT_DATA);
+ Status = gRT->GetVariable (
+ gRapidStartPersistentDataName,
+ &gRapidStartPersistentDataGuid,
+ NULL,
+ &RapidStartDataSize,
+ &RapidStartDataOrg
+ );
+ ///
+ /// RapidStartData variable not present or RapidStart Store change detected in previous RapidStart Resume.
+ /// Generate new RapidStart Store UID
+ ///
+ if (EFI_ERROR (Status) ||
+ mForceNewStoreUid ||
+ (RapidStartData->StoreSectors != RapidStartDataOrg.StoreSectors) ||
+ (RapidStartData->StoreLbaAddr != RapidStartDataOrg.StoreLbaAddr) ||
+ (RapidStartData->StoreSataPort != RapidStartDataOrg.StoreSataPort)
+ ) {
+ DEBUG ((EFI_D_ERROR, "Generate RapidStart Store UID.\n"));
+ RapidStartData->RapidStartStoreUid = GenerateRapidStartStoreUid ();
+ } else {
+ RapidStartData->RapidStartStoreUid = RapidStartDataOrg.RapidStartStoreUid;
+ }
+ ///
+ /// Check for changes in RapidStartData
+ ///
+ if ((Status == EFI_SUCCESS) &&
+ (CompareMem (&RapidStartDataOrg, RapidStartData, sizeof (RAPID_START_PERSISTENT_DATA)) == 0)
+ ) {
+ return EFI_SUCCESS;
+ }
+
+ Status = gRT->SetVariable (
+ gRapidStartPersistentDataName,
+ &gRapidStartPersistentDataGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof (RAPID_START_PERSISTENT_DATA),
+ RapidStartData
+ );
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
+
+/**
+ Installs Search RapidStart Partition handler by DiskIoProtocol.
+**/
+VOID
+RegisterForSearchRapidStartPartitionAgain (
+ VOID
+ )
+{
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+ VOID *Registration;
+
+ //
+ // Set this flag to TRUE and we will not search RapidStart partition again.
+ //
+ SecondTimeSearchRSTPartition = TRUE;
+ //
+ // Create a callback event to detect RapidStart Partition
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ SearchRapidStartPartition,
+ NULL,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Register DISK_IO_PROTOCOL notify function
+ //
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiDiskIoProtocolGuid,
+ Event,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+//AMI_OVERRIDE_FOR_RAPID_START
+//EIP123061
+ gBS->SignalEvent(Event);
+//AMI_OVERRIDE_FOR_RAPID_END
+}
+
+/**
+ Search for RapidStart Store and verify if valid. Install ACPI table only when RapidStart can be performed.
+
+ @param[in] Event - The event that triggered this notification function
+ @param[in] Context - Pointer to the notification functions context
+**/
+
+VOID
+EFIAPI
+SearchRapidStartPartition (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN DisableRapidStart;
+ BOOLEAN CheckSize;
+ UINT32 ThresholdSize;
+
+ DEBUG ((EFI_D_INFO, "SearchRapidStartPartition Start()\n"));
+
+ DisableRapidStart = FALSE;
+ CheckSize = FALSE;
+ ThresholdSize = MEM_TO_SECT (mRapidStartData->TotalMem);
+
+ ///
+ /// RapidStart has been enabled, check if RapidStart store valid.
+ ///
+ Status = SearchRapidStartStore (
+ mRapidStartPolicy,
+ &(mRapidStartData->StoreSectors),
+ &(mRapidStartData->StoreLbaAddr),
+ &(mRapidStartData->StoreSataPort)
+ );
+ mRapidStartData->ActivePageThresholdSizeInSector = 0;
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "RapidStart parition not found\n"));
+
+ if (SecondTimeSearchRSTPartition == FALSE) {
+ RegisterForSearchRapidStartPartitionAgain ();
+ DEBUG ((EFI_D_ERROR, " - Will search RapidStart parition again\n"));
+ gBS->CloseEvent (Event);
+ return;
+ }
+
+ DisableRapidStart = TRUE;
+ } else if (mRapidStartPolicy->ActivePageThresholdSupport == 0) {
+ CheckSize = TRUE;
+ } else {
+ DEBUG ((EFI_D_ERROR, "RapidStart Partition size less than memory size is supported\n"));
+ if (mRapidStartPolicy->ActivePageThresholdSize == 0) {
+ DEBUG ((EFI_D_ERROR, "RapidStart Partition size check in Auto Mode\n"));
+ } else {
+ ///
+ /// ActivePageThreshold size in MB
+ ///
+ ThresholdSize = (UINT32)MultU64x32 (mRapidStartPolicy->ActivePageThresholdSize, MEM_TO_SECT (MEM_EQU_1MB));
+ mRapidStartData->ActivePageThresholdSizeInSector = ThresholdSize;
+ CheckSize = TRUE;
+ }
+ }
+
+ if (CheckSize) {
+ if (ThresholdSize > mRapidStartData->StoreSectors) {
+ DEBUG ((EFI_D_ERROR, "RapidStart partition too small\n"));
+ DisableRapidStart = TRUE;
+ }
+ }
+
+ if (DisableRapidStart) {
+ DEBUG ((EFI_D_ERROR, "Disabling RapidStart!\n"));
+ ///
+ /// Disable RapidStart
+ ///
+ mRapidStartPolicy->EnableRapidStart = 0;
+ ///
+ /// Delete RapidStart variable
+ ///
+ Status = gRT->SetVariable (
+ gRapidStartPersistentDataName,
+ &gRapidStartPersistentDataGuid,
+ 0,
+ 0,
+ NULL
+ );
+ ///
+ /// Disable FFS relevant SMI handlers.
+ ///
+ mRapidStartGlobalNvsAreaProtocol.Area->EventsAvailable = 0;
+ mRapidStartGlobalNvsAreaProtocol.Area->EventsEnabled = 0;
+ } else {
+ ///
+ /// Enabling RapidStart
+ /// install RapidStart ACPI Table.
+ ///
+ DEBUG ((EFI_D_INFO, "Enabling RapidStart\n"));
+ DEBUG ((EFI_D_ERROR, "RapidStart Store:\n"));
+ DEBUG ((EFI_D_ERROR, " Port : %X\n", mRapidStartData->StoreSataPort));
+ DEBUG ((EFI_D_ERROR, " LbaAddr : %X\n", mRapidStartData->StoreLbaAddr));
+ DEBUG ((EFI_D_ERROR, " Size : %X Sectors\n", mRapidStartData->StoreSectors));
+ DEBUG ((EFI_D_ERROR, "Threshold Size : %X Sectors\n", mRapidStartData->ActivePageThresholdSizeInSector));
+
+ Status = InitializeRapidStartAcpiTables ();
+ ASSERT_EFI_ERROR (Status);
+#ifndef RAPID_START_ON_MEMORY_INSTALLED
+ RapidStartUpdatePersistentData (mRapidStartData);
+#endif
+ }
+
+ gBS->CloseEvent (Event);
+}
+
+/**
+ Installs Search RapidStart Partition handler.
+**/
+VOID
+RegisterForSearchRapidStartPartition (
+ VOID
+ )
+{
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+
+ SecondTimeSearchRSTPartition = FALSE;
+
+ Status = EfiCreateEventReadyToBootEx (
+ EFI_TPL_CALLBACK,
+ SearchRapidStartPartition,
+ NULL,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+#ifdef RAPID_START_ON_MEMORY_INSTALLED
+/**
+ Updates pointers necessary for S3 resume to RapidStart Flash variable.
+ This has to be postponed till ReadyToBoot as framework may update
+ this pointers late in a boot flow.
+
+ @param[in] Event - The event that triggered this notification function
+ @param[in] Context - Pointer to the notification functions context
+**/
+
+VOID
+EFIAPI
+RapidStartOnExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ UINT64 AcpiVariableSet64;
+ ACPI_VARIABLE_SET *AcpiVariableSet;
+ UINTN VarSize;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "RapidStartOnExitBootServices()\n"));
+
+ if (mRapidStartPolicy->EnableRapidStart) {
+ VarSize = sizeof (AcpiVariableSet64);
+ Status = gRT->GetVariable (
+ ACPI_GLOBAL_VARIABLE,
+ &gEfiAcpiVariableGuid,
+ NULL,
+ &VarSize,
+ &AcpiVariableSet64
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ AcpiVariableSet = (ACPI_VARIABLE_SET *) (UINTN) AcpiVariableSet64;
+
+ mRapidStartData->AcpiReservedMemoryBase = AcpiVariableSet->AcpiReservedMemoryBase;
+ mRapidStartData->AcpiReservedMemorySize = AcpiVariableSet->AcpiReservedMemorySize;
+#ifdef RAPID_START_USE_OLD_ACPI_VARIABLE_SET
+ mRapidStartData->SystemMemoryLengthBelow4GB = AcpiVariableSet->SystemMemoryLength;
+ mRapidStartData->SystemMemoryLengthAbove4GB = 0;
+#else
+ mRapidStartData->SystemMemoryLengthBelow4GB = AcpiVariableSet->SystemMemoryLengthBelow4GB;
+ mRapidStartData->SystemMemoryLengthAbove4GB = AcpiVariableSet->SystemMemoryLengthAbove4GB;
+#endif
+ DEBUG ((EFI_D_INFO, "AcpiReservedMemoryBase = %0lx\n", mRapidStartData->AcpiReservedMemoryBase));
+ DEBUG ((EFI_D_INFO, "AcpiReservedMemorySize = %0x\n", mRapidStartData->AcpiReservedMemorySize));
+ DEBUG ((EFI_D_INFO, "SystemMemoryLengthBelow4GB = %0lx\n", mRapidStartData->SystemMemoryLengthBelow4GB));
+ DEBUG ((EFI_D_INFO, "SystemMemoryLengthAbove4GB = %0lx\n", mRapidStartData->SystemMemoryLengthAbove4GB));
+ RapidStartUpdatePersistentData (mRapidStartData);
+ }
+
+ gBS->CloseEvent (Event);
+}
+
+/**
+ Installs ExitBootService handler.
+**/
+VOID
+RegisterForExitBootService (
+ VOID
+ )
+{
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+
+ Status = gBS->CreateEvent (
+ EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ EFI_TPL_CALLBACK,
+ RapidStartOnExitBootServices,
+ NULL,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = EfiCreateEventLegacyBootEx (
+ EFI_TPL_CALLBACK,
+ RapidStartOnExitBootServices,
+ NULL,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+#endif /* RAPID_START_ON_MEMORY_INSTALLED */
+
+/**
+ Initial RC Firmware Version Info
+**/
+VOID
+InitRcFvi (
+ VOID
+ )
+{
+ InitFviDataHubCbContext (
+ mRapidStartPolicy->FviSmbiosType,
+ (UINT8) mRapidStartFviElements,
+ &mRapidStartFviVersionData
+ );
+
+ CreateRcFviDatahub (&mRapidStartFviVersionData);
+}
+
+/**
+ RapidStart DXE driver entry point function
+
+ @param[in] ImageHandle - Image handle for this driver image
+ @param[in] SystemTable - Pointer to the EFI System Table
+
+ @retval EFI_OUT_OF_RESOURCES - no enough memory resource when installing reference code information protocol
+ @retval EFI_SUCCESS - function completed successfully
+**/
+EFI_STATUS
+RapidStartDxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ RAPID_START_GLOBAL_NVS_AREA *RapidStartGlobalNvs;
+ UINT16 SaDeviceId;
+ EFI_STATUS Status;
+ UINTN MchBase;
+ UINT8 RapidStartFlag;
+
+ DEBUG ((EFI_D_INFO, "RapidStartDxeEntryPoint()\n"));
+
+ Status = RapidStartInstallInfoProtocol (ImageHandle);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ ///
+ /// Locate RapidStart platform policy.
+ ///
+ Status = gBS->LocateProtocol (
+ &gRapidStartPlatformPolicyProtocolGuid,
+ NULL,
+ (VOID **) &mRapidStartPolicy
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "No RapidStart Platform Policy Protocol available"));
+ ASSERT_EFI_ERROR (Status);
+ }
+ ///
+ /// Initial RC Firmware Version Info
+ ///
+ InitRcFvi ();
+
+ if ((!EFI_ERROR (Status)) && (mRapidStartPolicy->EnableRapidStart)) {
+
+ Status = RapidStartGetFlag (&RapidStartFlag);
+ if (!EFI_ERROR (Status) && (RapidStartFlag & RAPID_START_FLAG_STORE_CHANGE)) {
+ mForceNewStoreUid = TRUE;
+ }
+
+ RapidStartSetFlag (0);
+
+ Status = (gBS->AllocatePool) (EfiACPIMemoryNVS, sizeof (RAPID_START_GLOBAL_NVS_AREA), (VOID **) &mRapidStartGlobalNvsAreaProtocol.Area);
+ ASSERT_EFI_ERROR (Status);
+ ZeroMem ((VOID *) mRapidStartGlobalNvsAreaProtocol.Area, sizeof (RAPID_START_GLOBAL_NVS_AREA));
+
+ Status = (gBS->AllocatePool) (EfiACPIMemoryNVS, sizeof (RAPID_START_PERSISTENT_DATA), &mRapidStartGlobalNvsAreaProtocol.RapidStartData);
+ ASSERT_EFI_ERROR (Status);
+ ZeroMem ((VOID *) mRapidStartGlobalNvsAreaProtocol.RapidStartData, sizeof (RAPID_START_PERSISTENT_DATA));
+
+ mRapidStartData = mRapidStartGlobalNvsAreaProtocol.RapidStartData;
+
+ ///
+ /// Get Tolm and Tohm
+ ///
+ 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;
+ }
+
+ if (mRapidStartPolicy->EntryOnS3RtcWake == 0 && mRapidStartPolicy->EntryOnS3CritBattWake == 0) {
+ DEBUG ((EFI_D_WARN, "RapidStart both S3 wakeup timer and critical battery wake event are disabled\n"));
+ }
+
+ RapidStartGlobalNvs = mRapidStartGlobalNvsAreaProtocol.Area;
+ RapidStartGlobalNvs->EventsAvailable = RAPID_START_ACPI_RTC_WAKE;
+
+ if (mRapidStartPolicy->S3WakeTimerMin <= RAPID_START_WAKE_TIMER_MAX) {
+ RapidStartGlobalNvs->WakeTimerMin = mRapidStartPolicy->S3WakeTimerMin;
+ } else {
+ DEBUG ((EFI_D_WARN, "RapidStart S3 wakeup timer out of range - resetting to default\n"));
+ RapidStartGlobalNvs->WakeTimerMin = RAPID_START_WAKE_TIMER_DEFAULT;
+ }
+
+ if (mRapidStartPolicy->EntryOnS3RtcWake) {
+ RapidStartGlobalNvs->EventsEnabled |= RAPID_START_ACPI_RTC_WAKE;
+ }
+
+ SaDeviceId = MmioRead16 (
+ MmPciAddress (
+ 0,
+ SA_MC_BUS,
+ SA_MC_DEV,
+ SA_MC_FUN,
+ R_SA_MC_DEVICE_ID)
+ );
+
+ if (IS_SA_DEVICE_ID_MOBILE (SaDeviceId)) {
+ RapidStartGlobalNvs->EventsAvailable |= RAPID_START_ACPI_BATT_WAKE;
+ if ((mRapidStartPolicy->EntryOnS3CritBattWake)) {
+ RapidStartGlobalNvs->EventsEnabled |= RAPID_START_ACPI_BATT_WAKE;
+ }
+ }
+
+ mRapidStartData->RapidStartGlobalNvsPtr = (UINT32) (UINTN) RapidStartGlobalNvs;
+
+ mRapidStartData->SataPortConfiguration = MmioRead8 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_SATA,
+ PCI_FUNCTION_NUMBER_PCH_SATA,
+ R_PCH_SATA_PCS)
+ );
+
+ RapidStartAllocateMemory (ImageHandle, mRapidStartData);
+
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gRapidStartGlobalNvsAreaProtocolGuid,
+ &mRapidStartGlobalNvsAreaProtocol,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ RegisterForSearchRapidStartPartition ();
+#ifdef RAPID_START_ON_MEMORY_INSTALLED
+ RegisterForExitBootService ();
+#endif
+ RegisterForRapidStartDisplayScreenCallback();
+ return EFI_SUCCESS;
+ }
+ ///
+ /// Delete RapidStart variable
+ ///
+ Status = gRT->SetVariable (
+ gRapidStartPersistentDataName,
+ &gRapidStartPersistentDataGuid,
+ 0,
+ 0,
+ NULL
+ );
+ if (Status == EFI_NOT_FOUND) {
+ return EFI_SUCCESS;
+ }
+
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
diff --git a/ReferenceCode/RapidStart/Dxe/RapidStartDxe.cif b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.cif
new file mode 100644
index 0000000..c313b10
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "RapidStartDxe"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Dxe"
+ RefName = "RapidStartDxe"
+[files]
+"RapidStartDxe.sdl"
+"RapidStartDxe.dxs"
+"RapidStartDxe.mak"
+"RapidStartDxe.inf"
+"RapidStartDxe.c"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Dxe/RapidStartDxe.dxs b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.dxs
new file mode 100644
index 0000000..76d7ccf
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.dxs
@@ -0,0 +1,56 @@
+/** @file
+ Dependency expression source file.
+
+@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
+
+**/
+
+
+#include "AutoGen.h"
+#include "DxeDepex.h"
+#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB)
+#include "EfiDepex.h"
+
+#include EFI_PROTOCOL_DEFINITION (PchPlatformPolicy)
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEPENDENCY (AcpiTable)
+#else
+#include EFI_PROTOCOL_DEPENDENCY (AcpiSupport)
+#endif
+#include EFI_PROTOCOL_DEFINITION (PchS3Support)
+#include EFI_PROTOCOL_DEFINITION (SmmControl)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartPlatformPolicy)
+#include EFI_PROTOCOL_DEPENDENCY (FirmwareVolume)
+//AMI_OVERRIDE_FOR_RAPID_START
+#include EFI_PROTOCOL_DEPENDENCY (DxeGfxProtocol)
+//AMI_OVERRIDE_FOR_RAPID_START
+#endif
+
+DEPENDENCY_START
+ DXE_PCH_PLATFORM_POLICY_PROTOCOL_GUID AND
+ EFI_PCH_S3_SUPPORT_PROTOCOL_GUID AND
+ EFI_SMM_CONTROL_PROTOCOL_GUID AND
+ RAPID_START_PLATFORM_POLICY_PROTOCOL_GUID AND
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_ACPI_TABLE_PROTOCOL_GUID AND
+#else
+ EFI_ACPI_SUPPORT_GUID AND
+#endif
+//AMI_OVERRIDE_FOR_RAPID_START
+ DXE_GFX_PROTOCOL_GUID AND
+//AMI_OVERRIDE_FOR_RAPID_START
+ EFI_FIRMWARE_VOLUME_PROTOCOL_GUID
+DEPENDENCY_END
diff --git a/ReferenceCode/RapidStart/Dxe/RapidStartDxe.inf b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.inf
new file mode 100644
index 0000000..756b8f6
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.inf
@@ -0,0 +1,102 @@
+## @file
+# Component description file for the RapidStartDxe 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 = RapidStartDxe
+FILE_GUID = B6B9295F-CABF-4CEC-BB14-FE4246F2173A
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ RapidStartDxe.c
+#
+# 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_PCH_ROOT)/Protocol
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include/Library
+ $(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_RAPID_START_ROOT)/Samplecode/Library/RapidStartPlatformLib/Dxe
+ $(EFI_SOURCE)\$(PROJECT_RAPID_START_ROOT)\GfxDisplay
+ $(EFI_SOURCE)\$(PROJECT_RAPID_START_ROOT)\GfxDisplay\Library\Dxe
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)
+
+[libraries.common]
+ EdkGuidLib
+ EdkFrameworkGuidLib
+ EdkFrameworkProtocolLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueDxeReportStatusCodeLib
+ EdkIIGlueDxeServicesTableLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiDevicePathLib
+ EdkIIGlueBasePciLibPciExpress
+ EdkProtocolLib
+ RapidStartProtocolLib
+ RapidStartGuidLib
+ RapidStartDxeLib
+ PchPlatformLib
+ RapidStartCommonLib
+ RapidStartGuidLib
+ RcFviDxeLib
+ GfxDisplayLibDxe
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+ DPX_SOURCE = RapidStartDxe.dxs
+
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartDxeEntryPoint
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ -D __EDKII_GLUE_BASE_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_UEFI_RUNTIME_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ \
+ -D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \
+ -DRAPID_START_USE_OLD_ACPI_VARIABLE_SET
+
diff --git a/ReferenceCode/RapidStart/Dxe/RapidStartDxe.mak b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.mak
new file mode 100644
index 0000000..f35b941
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.mak
@@ -0,0 +1,130 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartDxe/RapidStartDxe.mak 3 10/15/12 5:41a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 10/15/12 5:41a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartDxe/RapidStartDxe.mak $
+#
+# 3 10/15/12 5:41a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 2 9/26/12 3:28a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+# 1 4/19/12 8:03a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+
+all : RapidStartDxe
+
+RapidStartDxe : $(BUILD_DIR)\RapidStartDxe.mak RapidStartDxe_Bin
+
+$(BUILD_DIR)\RapidStartDxe.mak : $(RapidStartDxe_DIR)\$(@B).cif $(RapidStartDxe_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartDxe_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartDxe_INCLUDES=\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(EDK_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)\
+ $(PROJECT_INCLUDES)\
+ $(MISCFRAMEWORK_INCLUDES)\
+ $(PLATFORM_INFO_PROTOCOL_INCLUDES)\
+ $(INTEL_MCH_INCLUDES)\
+ $(NB_INCLUDES)\
+ $(ME_INCLUDES)\
+ /I$(GfxDisplayLibDxe_DIR)\
+ $(RAPIDSTART_INCLUDES)\
+ /I$(IntelPlatformProtocolLib_DIR)\
+
+RapidStartDxe_LIBS=\
+ $(EDKPROTOCOLLIB)\
+ $(INTEL_PCH_PROTOCOL_LIB)\
+ $(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)\
+ $(EdkIIGlueUefiDevicePathLib_LIB)\
+ $(EdkIIGlueBasePciLibPciExpress_LIB)\
+ $(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)\
+ $(RapidStartProtocolLib_LIB)\
+ $(RapidStartGuidLib_LIB)\
+ $(RapidStartDxeLib_LIB)\
+ $(PchPlatformDxeLib_LIB)\
+ $(RapidStartCommonSmmLib_LIB)\
+ $(RcFviDxeLib_LIB)\
+ $(GfxDisplayLibDxe_LIB)\
+
+RapidStartDxe_DEFINES=\
+ $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartDxeEntryPoint"\
+ /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__ \
+
+RapidStartDxe_Bin : $(RapidStartDxe_LIBS)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartDxe.mak all\
+ "MY_INCLUDES=$(RapidStartDxe_INCLUDES)"\
+ "MY_DEFINES=$(RapidStartDxe_DEFINES)"\
+ GUID=b6b9295f-cabf-4cec-bb14-fe4246f2173a\
+ ENTRY_POINT=_ModuleEntryPoint \
+ EDKIIModule=DXEDRIVER\
+ TYPE=BS_DRIVER \
+ DEPEX1=$(RapidStartDxe_DIR)\RapidStartDxe.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/ReferenceCode/RapidStart/Dxe/RapidStartDxe.sdl b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.sdl
new file mode 100644
index 0000000..e3c4657
--- /dev/null
+++ b/ReferenceCode/RapidStart/Dxe/RapidStartDxe.sdl
@@ -0,0 +1,68 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartDxe/RapidStartDxe.sdl 1 4/19/12 8:03a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:03a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartDxe/RapidStartDxe.sdl $
+#
+# 1 4/19/12 8:03a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartDxe_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable FFS support in Project in DXE Phase"
+End
+
+MODULE
+ File = "RapidStartDxe.mak"
+ Help = "Includes RapidStartDxe.mak to Project"
+End
+
+PATH
+ Name = "RapidStartDxe_DIR"
+ Help = "RapidStartDxe Dir"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartDxe.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.cif b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.cif
new file mode 100644
index 0000000..5659101
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "DxeFfsGfxDriver"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\"
+ RefName = "DxeFfsGfxDriver"
+[files]
+"DxeFfsGfxDriver.efi"
+"DxeFfsGfxDriver.inf"
+"DxeFfsGfxDriver.mak"
+"DxeFfsGfxDriver.sdl"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.efi b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.efi
new file mode 100644
index 0000000..85a94b1
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.efi
Binary files differ
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.inf b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.inf
new file mode 100644
index 0000000..3e7d772
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.inf
@@ -0,0 +1,36 @@
+## @file
+# Component description file for DxeFfsGfxDriver.
+#
+#@copyright
+# Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[defines]
+BASE_NAME = DxeFfsGfxDriver
+FILE_GUID = 6FD1DCC5-B5B9-4a82-8728-8D854428A4A3
+COMPONENT_TYPE = BS_DRIVER
+BUILD_TYPE = BS_DRIVER_EFI
+
+[sources.common]
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+
+[nmake.common]
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.mak b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.mak
new file mode 100644
index 0000000..96ec790
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.mak
@@ -0,0 +1,72 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/DxeFfsGfxDriver/DxeFfsGfxDriver.mak 1 10/15/12 5:02a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 5:02a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/DxeFfsGfxDriver/DxeFfsGfxDriver.mak $
+#
+# 1 10/15/12 5:02a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: DxeFfsGfxDriver.mak
+#
+# Description: Component description file for DxeFfsGfxDriver.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+all : DxeFfsGfxDriver
+
+DxeFfsGfxDriver : $(BUILD_DIR)\DxeFfsGfxDriver.ffs
+
+$(BUILD_DIR)\DxeFfsGfxDriver.ffs : $(DxeFfsGfxDriver_PATH)\DxeFfsGfxDriver.efi
+ $(MAKE) /f Core\FFS.mak \
+ NAME=DxeFfsGfxDriver \
+ BUILD_DIR=$(BUILD_DIR) \
+ SOURCE_DIR=$(DxeFfsGfxDriver_PATH) \
+ GUID=6FD1DCC5-B5B9-4a82-8728-8D854428A4A3 \
+ TYPE=EFI_FV_FILETYPE_DRIVER \
+ PEFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B)
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.sdl b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.sdl
new file mode 100644
index 0000000..21295e4
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Dxe/DxeFfsGfxDriver.sdl
@@ -0,0 +1,85 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/DxeFfsGfxDriver/DxeFfsGfxDriver.sdl 1 10/15/12 5:02a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 5:02a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/DxeFfsGfxDriver/DxeFfsGfxDriver.sdl $
+#
+# 1 10/15/12 5:02a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: DxeFfsGfxDriver.sdl
+#
+# Description: SDL file for DxeFfsGfxDriver.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "DxeFfsGfxDriver_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable FFS support in Project in DXE Phase"
+End
+
+MODULE
+ Help = "Includes DxeFfsGfxDriver.mak to Project"
+ File = "DxeFfsGfxDriver.mak"
+End
+
+PATH
+ Name = "DxeFfsGfxDriver_PATH"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\DxeFfsGfxDriver.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/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.cif b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.cif
new file mode 100644
index 0000000..5237f31
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "PeiGfxDriver"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\"
+ RefName = "PeiGfxDriver"
+[files]
+"PeiGfxDriver.efi"
+"PeiGfxDriver.dxs"
+"PeiGfxDriver.mak"
+"PeiGfxDriver.sdl"
+"PeiGfxDriver.inf"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.dxs b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.dxs
new file mode 100644
index 0000000..ec5b4d5
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.dxs
@@ -0,0 +1,32 @@
+/** @file
+ Dependency expression source file.
+
+@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
+
+**/
+
+
+#include "EfiDepex.h"
+//AMI_OVERRIDE_FOR_RAPID_START
+//#include EFI_PPI_CONSUMER (MemoryDiscovered)
+//AMI_OVERRIDE_FOR_RAPID_START
+
+DEPENDENCY_START
+//AMI_OVERRIDE_FOR_RAPID_START
+// PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+//AMI_OVERRIDE_FOR_RAPID_START
+ TRUE
+DEPENDENCY_END
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.efi b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.efi
new file mode 100644
index 0000000..e7f6ff1
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.efi
Binary files differ
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.inf b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.inf
new file mode 100644
index 0000000..5ba2eba
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.inf
@@ -0,0 +1,40 @@
+## @file
+# Component description file for PeiGfxDriver.
+#
+#@copyright
+# Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[defines]
+BASE_NAME = PeiGfxDriver
+FILE_GUID = B9846521-FF99-4953-8FA2-85C9ADCCE5AF
+COMPONENT_TYPE = PE32_PEIM
+BUILD_TYPE = BS_DRIVER_EFI
+
+[sources.common]
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Include
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = PeiGfxDriverEntry
+ DPX_SOURCE=PeiGfxDriver.dxs
+
diff --git a/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.mak b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.mak
new file mode 100644
index 0000000..d811ffc
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.mak
@@ -0,0 +1,79 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/PeiGfxDriver/PeiGfxDriver.mak 1 10/15/12 4:46a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 4:46a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/PeiGfxDriver/PeiGfxDriver.mak $
+#
+# 1 10/15/12 4:46a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PeiGfxDriver.mak
+#
+# Description: Component description file for PeiGfxDriver.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+all : PeiGfxDriver
+
+PeiGfxDriver : $(BUILD_DIR)\PeiGfxDriver.ffs
+
+PeiGfxDriver_INCLUDES=\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(EDK_INCLUDES)
+
+$(BUILD_DIR)\PeiGfxDriver.ffs : $(PeiGfxDriver_PATH)\PeiGfxDriver.efi
+ $(MAKE) $(EDKIIGLUE_DEFAULTS) /f Core\FFS.mak \
+ CPFLAGS="$(GLOBAL_DEFINES) /D TIANO_RELEASE_VERSION=0x00080006 $(EXTRA_DEFINES) $(PeiGfxDriver_INCLUDES)" \
+ NAME=PeiGfxDriver \
+ BUILD_DIR=$(BUILD_DIR) \
+ SOURCE_DIR=$(PeiGfxDriver_PATH) \
+ GUID=B9846521-FF99-4953-8FA2-85C9ADCCE5AF \
+ TYPE=EFI_FV_FILETYPE_PEIM \
+ EDKIIModule=EFI_FV_FILETYPE_PEIM\
+ DEPEX1=$(PeiGfxDriver_PATH)\PeiGfxDriver.dxs DEPEX1_TYPE=EFI_SECTION_PEI_DEPEX \
+ PEFILE=$** FFSFILE=$@ COMPRESS=0 NAME=$(**B)
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.sdl b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.sdl
new file mode 100644
index 0000000..a40e3d2
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/FfsGfxDriver/Pei/PeiGfxDriver.sdl
@@ -0,0 +1,84 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/PeiGfxDriver/PeiGfxDriver.sdl 1 10/15/12 4:56a Bensonlai $
+#
+# $Revision: 1 $
+#
+# $Date: 10/15/12 4:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/PeiGfxDriver/PeiGfxDriver.sdl $
+#
+# 1 10/15/12 4:56a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PeiGfxDriver.sdl
+#
+# Description: SDL file for PeiGfxDriver.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+TOKEN
+ Name = "PeiGfxDriver_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PeiGfxDriver support in Project"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+End
+
+MODULE
+ Help = "Includes PeiGfxDriver.mak to Project"
+ File = "PeiGfxDriver.mak"
+End
+
+PATH
+ Name = "PeiGfxDriver_PATH"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\PeiGfxDriver.ffs"
+ Parent = "FV_BB"
+ 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/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.c b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.c
new file mode 100644
index 0000000..8a1c156
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.c
@@ -0,0 +1,141 @@
+/** @file
+ Implementation file for GfxDisplay Dxe functionality
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+//
+// 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 EFI_PROTOCOL_PRODUCER (DxeGfxProtocol)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartGlobalNvsArea)
+#include EFI_PROTOCOL_CONSUMER (RapidStartPlatformPolicy)
+#include EFI_PROTOCOL_DEPENDENCY (IgdOpRegion)
+
+#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \
+ {0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93}
+
+#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
+ {0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21}
+
+EFI_GUID gEfiConsoleControlProtocolGuid = BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID;
+
+#endif
+
+//
+// Internal function for GfxDisplayLib used only
+//
+/**
+ Event callback to get screen shot for RapidStart exit
+
+ @param[in] Event - The event that triggered this notification function
+ @param[in] Context - Pointer to the notification functions context
+**/
+STATIC
+VOID
+RapidStartDisplayScreenCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status, IgdOpRegionStatus;
+ VOID *ProtocolPointer;
+ DXE_GFX_PROTOCOL *DxeGfxProtocol;
+ RAPID_START_PLATFORM_POLICY_PROTOCOL *RapidStartPolicy;
+ RAPID_START_GLOBAL_NVS_AREA_PROTOCOL *RapidStartGlobalNvsAreaProtocol;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ IGD_OPREGION_PROTOCOL *IgdOpRegion;
+
+ //
+ // Check whether this is real protocal callback notification, or just a SignalEvent
+ //
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ProtocolPointer);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ //
+ // Locate RapidStart platform policy.
+ //
+ Status = gBS->LocateProtocol (&gRapidStartPlatformPolicyProtocolGuid, NULL, &RapidStartPolicy);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "No RapidStart Platform Policy Protocol available\n"));
+ return;
+ }
+
+ Status = gBS->LocateProtocol (&gRapidStartGlobalNvsAreaProtocolGuid, NULL, &RapidStartGlobalNvsAreaProtocol);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_INFO, "No RapidStart info protocol available\n"));
+ return;
+ }
+
+ RapidStartData = RapidStartGlobalNvsAreaProtocol->RapidStartData;
+
+ IgdOpRegionStatus = gBS->LocateProtocol (&gIgdOpRegionProtocolGuid, NULL, &IgdOpRegion);
+ if (!EFI_ERROR (IgdOpRegionStatus)) {
+ IgdOpRegion->OpRegion->MBox3.FDSP = RapidStartData->DssAddress;
+ IgdOpRegion->OpRegion->MBox3.FDSS = (UINT32)(RapidStartData->DssSize);
+ }
+
+ if (RapidStartPolicy->DisplaySaveRestore == 1) {
+ Status = gBS->LocateProtocol (&gDxeGfxProtocolGuid, NULL, &DxeGfxProtocol);
+ DEBUG ((EFI_D_INFO, "RapidStartDisplayScreenCallback():Locating DxeGfxProtocol - Status = %r\n", Status));
+ if (!EFI_ERROR(Status)) {
+ if (RapidStartPolicy->DisplayType == BIOS_RESTORE) {
+ Status = DxeGfxProtocol->SaveDisplay(NULL);
+ } else {
+ Status = DxeGfxProtocol->SaveDisplay((UINT8*)(UINTN)((RapidStartData)->DssAddress));
+ }
+ }
+ }
+
+ gBS->CloseEvent (Event);
+}
+
+//
+// Interface functions of GfxDisplayLib
+//
+/**
+ Install EFI_CONSOLE_CONTROL_PROTOCOL_GUID callback handler.
+**/
+VOID
+RegisterForRapidStartDisplayScreenCallback (
+ VOID
+ )
+{
+ EFI_EVENT Event;
+
+ //
+ // Create an EFI_CONSOLE_CONTROL_PROTOCOL_GUID protocol call back event, to capture splash screen.
+ //
+ EfiCreateProtocolNotifyEvent (
+ &gEfiConsoleControlProtocolGuid,
+ EFI_TPL_CALLBACK,
+ RapidStartDisplayScreenCallback,
+ NULL,
+ &Event
+ );
+}
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.cif b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.cif
new file mode 100644
index 0000000..f97cd70
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "GfxDisplayLibDxe"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\GfxDisplay\Library\Dxe\"
+ RefName = "GfxDisplayLibDxe"
+[files]
+"GfxDisplayLibDxe.sdl"
+"GfxDisplayLibDxe.mak"
+"GfxDisplayLibDxe.c"
+"GfxDisplayLibDxe.h"
+"GfxDisplayLibDxe.inf"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.h b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.h
new file mode 100644
index 0000000..59fd7a5
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.h
@@ -0,0 +1,29 @@
+/** @file
+ Header file for GfxDisplay functionality
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _DXE_GFX_DISPLAY_LIB_H_
+#define _DXE_GFX_DISPLAY_LIB_H_
+
+VOID
+RegisterForRapidStartDisplayScreenCallback (
+ VOID
+ );
+
+#endif
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.inf b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.inf
new file mode 100644
index 0000000..c9cc81b
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.inf
@@ -0,0 +1,58 @@
+## @file
+# Component description file for GfxDisplay Library functions for Dxe
+#
+#@copyright
+# Copyright (c) 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 = GfxDisplayLibDxe
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ GfxDisplayLibDxe.c
+ GfxDisplayLibDxe.h
+
+[includes.common]
+ $(EFI_SOURCE)\$(PROJECT_RAPID_START_ROOT)
+ $(EFI_SOURCE)\$(PROJECT_RAPID_START_ROOT)\Include
+ $(EFI_SOURCE)\$(PROJECT_SA_ROOT)
+
+#
+# EDK II Glue Library utilizes some standard headers from EDK
+#
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include
+
+[libraries.common]
+ EdkFrameworkProtocolLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueDxeFirmwarePerformanceLib
+ RapidStartProtocolLib
+ IntelSaProtocolLib
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ /D __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ \
+ /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.mak b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.mak
new file mode 100644
index 0000000..02f32f7
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.mak
@@ -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/GfxDisplayLibDxe/GfxDisplayLibDxe.mak 2 10/15/12 5:11a Bensonlai $
+#
+# $Revision: 2 $
+#
+# $Date: 10/15/12 5:11a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/GfxDisplayLibDxe/GfxDisplayLibDxe.mak $
+#
+# 2 10/15/12 5:11a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+# 1 9/26/12 3:51a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+#*************************************************************************
+
+all : GfxDisplayLibDxe
+
+$(GfxDisplayLibDxe_LIB) : GfxDisplayLibDxe
+
+GfxDisplayLibDxe : $(BUILD_DIR)\GfxDisplayLibDxe.mak GfxDisplayLibDxeBin
+
+$(BUILD_DIR)\GfxDisplayLibDxe.mak : $(GfxDisplayLibDxe_DIR)\$(@B).cif $(GfxDisplayLibDxe_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(GfxDisplayLibDxe_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+GfxDisplayLibDxe_INCLUDES =\
+ $(EDK_INCLUDES)\
+ $(RAPIDSTART_INCLUDES)\
+ $(INTEL_MCH_INCLUDES)\
+
+GfxDisplayLibDxeBin : $(INTEL_SA_PROTOCOL_LIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\GfxDisplayLibDxe.mak all\
+ "MY_INCLUDES=$(GfxDisplayLibDxe_INCLUDES)" \
+ TYPE=LIBRARY
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.sdl b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.sdl
new file mode 100644
index 0000000..7c590da
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Dxe/GfxDisplayLibDxe.sdl
@@ -0,0 +1,77 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/GfxDisplayLibDxe/GfxDisplayLibDxe.sdl 1 9/26/12 3:51a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 9/26/12 3:51a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/GfxDisplayLibDxe/GfxDisplayLibDxe.sdl $
+#
+# 1 9/26/12 3:51a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+#*************************************************************************
+TOKEN
+ Name = "GfxDisplayLibDxe_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable GfxDisplayLibDxe support in Project"
+End
+
+PATH
+ Name = "GfxDisplayLibDxe_DIR"
+ Help = "GfxDisplayLibDxe file source directory"
+End
+
+MODULE
+ File = "GfxDisplayLibDxe.mak"
+ Help = "Includes GfxDisplayLibDxe.mak to Project"
+End
+
+ELINK
+ Name = "GfxDisplayLibDxe_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\GfxDisplayLibDxe.lib"
+ Parent = "GfxDisplayLibDxe_LIB"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.c b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.c
new file mode 100644
index 0000000..a7c05b2
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.c
@@ -0,0 +1,55 @@
+/** @file
+ Implementation file for GfxDisplay Pei functionality
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "GfxDisplayLibPei.h"
+#include EFI_PPI_DEFINITION (PeiGfxPpi)
+#endif
+
+/**
+ This function allows the platform to restore the display to the Display Save State.
+
+ @retval EFI_SUCCESS - RapidStartGfxDisplayScreen succeeded
+ @retval EFI_INVALID_PARAMETER - Invalid Parameter
+ @retval EFI_NOT_FOUND - Display Save State Header Signature failed
+**/
+EFI_STATUS
+RapidStartGfxDisplayScreen (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ PEI_GFX_PPI *PeiGfxPpi;
+
+ DEBUG ((EFI_D_INFO, "RapidStartGfxDisplayScreen Start\n"));
+ Status = PeiServicesLocatePpi (&gPeiGfxPpiGuid, 0, NULL, &PeiGfxPpi);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PeiGfxPpi->RestoreDisplay (GetPeiServicesTablePointer ());
+ DEBUG ((EFI_D_INFO, "Call PeiGfxPpi->RestoreDisplay, Status = %r\n", Status));
+
+ return Status;
+}
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.cif b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.cif
new file mode 100644
index 0000000..3e8c5f3
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "GfxDisplayLibPei"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\GfxDisplay\Library\Pei\"
+ RefName = "GfxDisplayLibPei"
+[files]
+"GfxDisplayLibPei.sdl"
+"GfxDisplayLibPei.mak"
+"GfxDisplayLibPei.c"
+"GfxDisplayLibPei.h"
+"GfxDisplayLibPei.inf"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.h b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.h
new file mode 100644
index 0000000..198bfb3
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.h
@@ -0,0 +1,35 @@
+/** @file
+ Header file for GfxDisplay functionality
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _PEI_GFX_DISPLAY_LIB_H_
+#define _PEI_GFX_DISPLAY_LIB_H_
+
+/**
+ This function allows the platform to restore the display to the Display Save State.
+
+ @retval EFI_SUCCESS - RapidStartGfxDisplayScreen succeeded
+ @retval EFI_INVALID_PARAMETER - Invalid Parameter
+ @retval EFI_NOT_FOUND - Display Save State Header Signature failed
+**/
+EFI_STATUS
+RapidStartGfxDisplayScreen (
+ VOID
+ );
+#endif
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.inf b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.inf
new file mode 100644
index 0000000..44ca9fd
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.inf
@@ -0,0 +1,51 @@
+## @file
+# Component description file for GfxDisplay Library functions for PEIMs
+#
+#@copyright
+# Copyright (c) 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 = GfxDisplayLibPei
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ GfxDisplayLibPei.c
+ GfxDisplayLibPei.h
+
+[includes.common]
+ $(EFI_SOURCE)\$(PROJECT_RAPID_START_ROOT)
+
+#
+# EDK II Glue Library utilizes some standard headers from EDK
+#
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include
+
+[libraries.common]
+ EdkIIGluePeiServicesLib
+ RapidStartPpiLib
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D __EDKII_GLUE_PEI_SERVICES_LIB__
diff --git a/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.mak b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.mak
new file mode 100644
index 0000000..48f1893
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.mak
@@ -0,0 +1,75 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/GfxDisplayLibPei/GfxDisplayLibPei.mak 2 10/15/12 5:07a Bensonlai $
+#
+# $Revision: 2 $
+#
+# $Date: 10/15/12 5:07a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/GfxDisplayLibPei/GfxDisplayLibPei.mak $
+#
+# 2 10/15/12 5:07a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Graphics Driver for Shark Bay
+# Platform 5.0.1.1001, please increase your FV_BB_BLOCKS size if you
+# compile fail that caused by FV_BB size too small.
+# [Files] ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Pei\*.*,
+# ReferenceCode\RapidStart\GfxDisplay\FfsGfxDriver\Dxe\*.*
+#
+# 1 9/26/12 3:53a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+#*************************************************************************
+
+all : GfxDisplayLibPei
+
+$(GfxDisplayLibPei_LIB) : GfxDisplayLibPei
+
+GfxDisplayLibPei : $(BUILD_DIR)\GfxDisplayLibPei.mak GfxDisplayLibPeiBin
+
+$(BUILD_DIR)\GfxDisplayLibPei.mak : $(GfxDisplayLibPei_DIR)\$(@B).cif $(GfxDisplayLibPei_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(GfxDisplayLibPei_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+GfxDisplayLibPei_INCLUDES =\
+ $(EDK_INCLUDES)\
+ $(RAPIDSTART_INCLUDES)\
+
+GfxDisplayLibPeiBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\GfxDisplayLibPei.mak all\
+ "MY_INCLUDES=$(GfxDisplayLibPei_INCLUDES)" \
+ TYPE=PEI_LIBRARY
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.sdl b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.sdl
new file mode 100644
index 0000000..8b78b83
--- /dev/null
+++ b/ReferenceCode/RapidStart/GfxDisplay/Library/Pei/GfxDisplayLibPei.sdl
@@ -0,0 +1,77 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/GfxDisplayLibPei/GfxDisplayLibPei.sdl 1 9/26/12 3:53a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 9/26/12 3:53a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/GfxDisplayLibPei/GfxDisplayLibPei.sdl $
+#
+# 1 9/26/12 3:53a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+#*************************************************************************
+TOKEN
+ Name = "GfxDisplayLibPei_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable GfxDisplayLibPei support in Project"
+End
+
+PATH
+ Name = "GfxDisplayLibPei_DIR"
+ Help = "GfxDisplayLibPei file source directory"
+End
+
+MODULE
+ File = "GfxDisplayLibPei.mak"
+ Help = "Includes GfxDisplayLibPei.mak to Project"
+End
+
+ELINK
+ Name = "GfxDisplayLibPei_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\GfxDisplayLibPei.lib"
+ Parent = "GfxDisplayLibPei_LIB"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.c b/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.c
new file mode 100644
index 0000000..bd875b5
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.c
@@ -0,0 +1,40 @@
+/** @file
+ The GUID definition for RapidStart ACPI table storage file name
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+//
+// Statements that include other files
+//
+#include "EdkIIGlueDxe.h"
+#include "RapidStartAcpiTableStorage.h"
+
+///
+/// Protocol GUID definition
+///
+EFI_GUID gRapidStartAcpiTableStorageGuid = RAPID_START_ACPI_TABLE_STORAGE_GUID;
+
+///
+/// Protocol description
+///
+EFI_GUID_STRING
+ (
+ &gRapidStartAcpiTableStorageGuid, "RapidStart ACPI Table Storage File Name",
+ "RapidStart ACPI Table Storage file name GUID"
+ );
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.h b/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.h
new file mode 100644
index 0000000..fe590e4
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.h
@@ -0,0 +1,31 @@
+/** @file
+ GUID definition for the RapidStart ACPI table storage file name
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _RAPID_START_ACPI_TABLE_STORAGE_H_
+#define _RAPID_START_ACPI_TABLE_STORAGE_H_
+
+#define RAPID_START_ACPI_TABLE_STORAGE_GUID \
+ { \
+ 0x60ac3a8f, 0x4d66, 0x4cd4, 0x89, 0x5a, 0xc3, 0xf0, 0x6e, 0x66, 0x65, 0xee \
+ }
+
+extern EFI_GUID gRapidStartAcpiTableStorageGuid;
+
+#endif
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.cif b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.cif
new file mode 100644
index 0000000..66d2889
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.cif
@@ -0,0 +1,16 @@
+<component>
+ name = "RapidStartGuidLib"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Guid"
+ RefName = "RapidStartGuidLib"
+[files]
+"RapidStartGuidLib.sdl"
+"RapidStartGuidLib.mak"
+"RapidStartGuidLib.inf"
+"RapidStartAcpiTableStorage\RapidStartAcpiTableStorage.c"
+"RapidStartAcpiTableStorage\RapidStartAcpiTableStorage.h"
+"RapidStartPersistentData\RapidStartPersistentData.c"
+"RapidStartPersistentData\RapidStartPersistentData.h"
+"RapidStartTransition\RapidStartTransition.c"
+"RapidStartTransition\RapidStartTransition.h"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.inf b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.inf
new file mode 100644
index 0000000..d38d2ba
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.inf
@@ -0,0 +1,60 @@
+## @file
+# Component description file for the GUID library
+#
+#@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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[defines]
+BASE_NAME = RapidStartGuidLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.h
+ RapidStartAcpiTableStorage/RapidStartAcpiTableStorage.c
+ RapidStartPersistentData/RapidStartPersistentData.c
+ RapidStartPersistentData/RapidStartPersistentData.h
+ RapidStartTransition/RapidStartTransition.c
+ RapidStartTransition/RapidStartTransition.h
+
+[includes.common]
+ $(EFI_SOURCE)
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EFI_SOURCE)/Include
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/Include
+
+#
+# Edk II Glue Library, some hearder are included by R9 header so have to include
+#
+
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/Framework
+ $(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/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.mak b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.mak
new file mode 100644
index 0000000..398a29a
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.mak
@@ -0,0 +1,82 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartGuidLib/RapidStartGuidLib.mak 3 10/15/12 5:40a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 10/15/12 5:40a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartGuidLib/RapidStartGuidLib.mak $
+#
+# 3 10/15/12 5:40a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 2 9/26/12 3:31a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+# 1 4/19/12 8:04a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+all : RapidStartGuidLib
+
+$(RapidStartGuidLib_LIB) : RapidStartGuidLib
+
+RapidStartGuidLib : $(BUILD_DIR)\RapidStartGuidLib.mak RapidStartGuidLibBin
+
+$(BUILD_DIR)\RapidStartGuidLib.mak : $(RapidStartGuidLib_DIR)\$(@B).cif $(RapidStartGuidLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartGuidLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartGuidLib_INCLUDES =\
+ $(EDK_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(RAPIDSTART_INCLUDES)\
+
+RapidStartGuidLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartGuidLib.mak all\
+ "MY_INCLUDES=$(RapidStartGuidLib_INCLUDES)" \
+ TYPE=LIBRARY
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\RapidStartGuidLib.mak all\
+ "MY_INCLUDES=$(RapidStartGuidLib_INCLUDES)" \
+ TYPE=PEI_LIBRARY
+!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/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.sdl b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.sdl
new file mode 100644
index 0000000..8e60134
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartGuidLib.sdl
@@ -0,0 +1,68 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartGuidLib/RapidStartGuidLib.sdl 1 4/19/12 8:04a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:04a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartGuidLib/RapidStartGuidLib.sdl $
+#
+# 1 4/19/12 8:04a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartGuidLib_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable iFFS GUID LIB support in Project"
+End
+
+MODULE
+ File = "RapidStartGuidLib.mak"
+ Help = "Includes RapidStartGuidLib.mak to Project"
+End
+
+PATH
+ Name = "RapidStartGuidLib_DIR"
+End
+
+TOKEN
+ Name = "RapidStartGuidLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\RapidStartGuidLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.c b/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.c
new file mode 100644
index 0000000..ff51884
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.c
@@ -0,0 +1,27 @@
+/** @file
+ The GUID definition for RapidStart Persistent Data
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#include "EdkIIGlueDxe.h"
+#include "RapidStartPersistentData.h"
+
+EFI_GUID gRapidStartPersistentDataGuid = RAPID_START_PERSISTENT_DATA_GUID;
+CHAR16 gRapidStartPersistentDataName[] = RAPID_START_PERSISTENT_DATA_NAME;
+
+EFI_GUID_STRING(&gRapidStartPersistentDataGuid, "RapidStart Persistent Data", "RapidStart Persistent Data GUID");
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.h b/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.h
new file mode 100644
index 0000000..0436e98
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartPersistentData/RapidStartPersistentData.h
@@ -0,0 +1,41 @@
+/** @file
+ GUID definition for the RapidStart Persistent Data
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _RAPID_START_PERSISTENT_DATA_H_
+#define _RAPID_START_PERSISTENT_DATA_H_
+
+///
+/// Publish GUID/Name definition for platform code to identify if Rapid Start
+/// function is enabled or not. Platform code is able to provide related setup
+/// options for further control and configuration by detecting
+/// RAPID_START_PERSISTENT_DATA_GUID/ RAPID_START_PERSISTENT_DATA_NAME exists or not
+/// in BIOS setup.
+///
+#define RAPID_START_PERSISTENT_DATA_GUID \
+ { \
+ 0xf9f0b131, 0xf346, 0x4f16, 0x80, 0xdd, 0xf9, 0x41, 0x07, 0x2b, 0x3a, 0x7d \
+ }
+
+#define RAPID_START_PERSISTENT_DATA_NAME L"RapidStartData"
+
+extern EFI_GUID gRapidStartPersistentDataGuid;
+extern CHAR16 gRapidStartPersistentDataName[];
+
+#endif
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.c b/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.c
new file mode 100644
index 0000000..63ac569
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.c
@@ -0,0 +1,40 @@
+/** @file
+ GUIDs used for RapidStart Transition.
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+//
+// Statements that include other files
+//
+#include "EdkIIGluePeim.h"
+#include "RapidStartConfig.h"
+#include "RapidStartTransition.h"
+#include EFI_PPI_DEFINITION (PeiGfxPpi)
+
+///
+/// The purpose of this PPI GUID is to trigger the RapidStartTransition
+/// for IBVs can decide the best point to trigger our Rapid Start module.
+///
+#ifdef RAPID_START_ON_START_PPI_INSTALLED
+EFI_GUID gRapidStartTransitionPpiGuid = PEI_RAPID_START_TRANSITION_PPI_GUID;
+#else
+EFI_GUID gRapidStartTransitionPpiGuid = PEI_GFX_PPI_GUID;
+#endif
+
+EFI_GUID_STRING(&gRapidStartTransitionPpiGuid, "RapidStart Transition", "RapidStart Transition GUID");
diff --git a/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.h b/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.h
new file mode 100644
index 0000000..ce13472
--- /dev/null
+++ b/ReferenceCode/RapidStart/Guid/RapidStartTransition/RapidStartTransition.h
@@ -0,0 +1,31 @@
+/** @file
+ GUID definition for the RapidStart Transition
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _RAPID_START_TRANSITION_H_
+#define _RAPID_START_TRANSITION_H_
+
+#define PEI_RAPID_START_TRANSITION_PPI_GUID \
+ { \
+ 0xde8f2878, 0x36d5, 0x498e, 0xba, 0x59, 0x16, 0x8c, 0x26, 0x47, 0xb3, 0x35 \
+ }
+
+extern EFI_GUID gRapidStartTransitionPpiGuid;
+
+#endif
diff --git a/ReferenceCode/RapidStart/Include/RapidStartAcpi.dsc b/ReferenceCode/RapidStart/Include/RapidStartAcpi.dsc
new file mode 100644
index 0000000..d4376fa
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartAcpi.dsc
@@ -0,0 +1,69 @@
+## @file
+# Build description file for building the RapidStart ACPI tables
+#
+#@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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[=============================================================================]
+#
+# Instructions for building the RapidStart ACPI table storage file
+#
+[=============================================================================]
+[Build.Ia32.RAPID_START_ACPI_TABLES,Build.x64.RAPID_START_ACPI_TABLES]
+#
+# Check if we have any source to work with.
+#
+!IFNDEF SECTIONS
+!IFNDEF ASL_FILES
+!ERROR No ASL source files to build were defined in the INF file
+!ENDIF
+!ENDIF
+
+#
+# Define some macros to simplify changes
+#
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs
+
+$(DEST_DIR)\RapidStart.sec : $(ASL_SOURCE_FILES) $(ASL_FILES)
+ $(ASL) $(ASL_FLAGS) $(DEST_DIR)\Ssdt\RapidStart.asl
+ -copy $(DEST_DIR)\Ssdt\RapidStart.aml $(DEST_DIR)\RapidStart.acpi
+ $(GENSECTION) -I $(DEST_DIR)\RapidStart.acpi -O $(DEST_DIR)\RapidStart.sec -S EFI_SECTION_RAW
+
+#
+# Build FFS file
+#
+$(TARGET_FFS_FILE) : $(SECTIONS) $(DEST_DIR)\RapidStart.sec
+ $(GENFFSFILE) -B $(DEST_DIR) -P1 $(DEST_DIR)\$(BASE_NAME).pkg -V
+
+all : $(TARGET_FFS_FILE)
+
+[=============================================================================]
+[Package.RAPID_START_ACPI_TABLES.Default]
+PACKAGE.INF
+\[.]
+BASE_NAME = $(BASE_NAME)
+FFS_FILEGUID = $(FILE_GUID)
+FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM
+FFS_ATTRIB_CHECKSUM = TRUE
+
+IMAGE_SCRIPT =
+{
+ Compress (Dummy) {
+ $(DEST_DIR)\RapidStart.sec
+ }
+}
diff --git a/ReferenceCode/RapidStart/Include/RapidStartAhciReg.h b/ReferenceCode/RapidStart/Include/RapidStartAhciReg.h
new file mode 100644
index 0000000..8e85370
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartAhciReg.h
@@ -0,0 +1,163 @@
+/** @file
+ Header file for Registers and Structure definitions
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef RAPID_START_AHCIREG_H_
+#define RAPID_START_AHCIREG_H_
+
+#define SECTOR_SIZE 0x200
+#define SECTOR_SHIFT 9
+
+#define MEM_TO_SECT(mem) ((UINT32) RShiftU64 ((mem), SECTOR_SHIFT))
+
+//
+// Known issues with 3rd party SSDs : some 3rd party SSD was not compliant with the ATA spec (transfer size of 0 sector issue)
+// We have seen it on more than one vendor's drive so far,
+// The w/a does not cause performance issue to our code or any special checks
+// #define AHCI_MAX_SECTORS 0x10000
+//
+#define AHCI_MAX_SECTORS 0xFF80
+#define AHCI_MAX_TRANSFER (SECTOR_SIZE * AHCI_MAX_SECTORS)
+
+#define AHCI_NO_DATA 0
+#define AHCI_DIR_HOST2DEV 1
+#define AHCI_DIR_DEV2HOST 0
+
+#define ATA_CMD_IDENTIFY_DEVICE 0xEC
+#define ATA_CMD_READ_DMA_EXT 0x25
+#define ATA_CMD_WRITE_DMA_EXT 0x35
+#define ATA_CMD_WRITE_DMA_FUA_EXT 0x3D
+#define ATA_CMD_STANDBY_IMMEDIATE 0xE0
+#define ATA_CMD_DATA_SET_MANAGEMENT 0x06
+#define V_ATA_TRIM_FEATURE 0x01
+
+#define ATA_CMD_SECURITY_UNLOCK 0xF2
+#define ATA_CMD_SECURITY_FREEZE_LOCK 0xF5
+#define ATA_CMD_SECURITY_SET_PASSWORD 0xF1
+#define ATA_CMD_FLUSH_CACHE 0xE7
+
+#define ATA_CMD_SET_FEATURES 0xEF
+#define V_ATA_FEATURE_ENABLE 0x10
+#define V_ATA_FEATURE_DISABLE 0x90
+#define ATA_CMD_READ_LOG_EXT 0x2F
+
+#define ATA_ID_DEV_HYBRID_FEATURE_SUPPORT 78
+#define B_ATA_ID_DEV_HYBRID_FEATURE_SUPPORT BIT9
+#define ATA_ID_DEV_HYBRID_FEATURE_ENABLE 79
+#define B_ATA_ID_DEV_HYBRID_FEATURE_ENABLE BIT9
+
+#define ATA_ID_DEV_DATA_SET_MGMNT_BLOCKS 105
+#define ATA_ID_DEV_DATA_SET_MGMNT_SUPPORT 169
+#define B_ATA_ID_DEV_DATA_SET_TRIM 0x01
+
+#define ATA_ID_DEV_SECURITY_STATUS 128
+#define B_ATA_ID_DEV_SEC_SUPPORTED 0x01
+#define B_ATA_ID_DEV_SEC_ENABLED 0x02
+#define B_ATA_ID_DEV_SEC_LOCKED 0x04
+#define B_ATA_ID_DEV_SEC_FROZEN 0x08
+#define B_ATA_ID_DEV_SEC_COUNT_EXP 0x10
+
+#define ALIGN(v, a) ((((v) - 1) | ((a) - 1)) + 1)
+
+#define AHCI_HBA_SIZE 0x100
+#define AHCI_PORT_SIZE 0x80
+#define AHCI_PORT_BASE_X(Ahci, port) (Ahci->Abar + AHCI_HBA_SIZE + AHCI_PORT_SIZE * port)
+#define AHCI_PORT_BASE(Ahci) AHCI_PORT_BASE_X (Ahci, Ahci->Port)
+#define AHCI_MAX_CMD 16
+#define AHCI_CMD_HEADER_SIZE 0x20
+#define AHCI_CMD_LIST_BASE(Ahci) (Ahci->PortBase)
+#define AHCI_CMD_LIST_SIZE (AHCI_MAX_CMD * AHCI_CMD_HEADER_SIZE)
+
+#define AHCI_RXFIS_BASE(Ahci) ALIGN ((AHCI_CMD_LIST_BASE (Ahci) + AHCI_CMD_LIST_SIZE), 0x100) ///< align 256
+#define AHCI_RXFIS_SIZE 0x100
+#define AHCI_CMD_TABLE_BASE(Ahci) ALIGN ((AHCI_RXFIS_BASE (Ahci) + AHCI_RXFIS_SIZE), 0x80) ///< align 128
+#define AHCI_CMD_TABLE_HEADER_SIZE 0x80
+#define AHCI_MAX_PRDT 8192 ///< We need 8192 PRT entries of 4KB transfer size for single 32MB command
+#define AHCI_PRD_SIZE 0x10
+#define AHCI_CMD_TABLE_SIZE (AHCI_CMD_TABLE_HEADER_SIZE + AHCI_PRD_SIZE * AHCI_MAX_PRDT)
+
+#define AHCI_CMD_HEADER(Ahci, cmd) (AHCI_CMD_LIST_BASE (Ahci) + (cmd) * AHCI_CMD_HEADER_SIZE)
+#define AHCI_CMD_TABLE(Ahci, cmd) (AHCI_CMD_TABLE_BASE (Ahci) + (cmd) * AHCI_CMD_TABLE_SIZE) ///< align 128
+
+#define AHCI_ID_BLOCK_SIZE SECTOR_SIZE
+#define AHCI_ID_BLOCK(Ahci) (AHCI_CMD_TABLE (Ahci, AHCI_MAX_CMD))
+
+#define AHCI_TMP_BLOCK_SIZE SECTOR_SIZE
+#define AHCI_TMP_BLOCK(Ahci) (AHCI_ID_BLOCK (Ahci) + AHCI_ID_BLOCK_SIZE)
+
+#define AHCI_MEM_MAX(Ahci) (AHCI_TMP_BLOCK (Ahci) + AHCI_TMP_BLOCK_SIZE)
+#define AHCI_MEM_MAX_SIZE (AHCI_TMP_BLOCK_SIZE + \
+ AHCI_ID_BLOCK_SIZE + \
+ AHCI_MAX_CMD * \
+ AHCI_CMD_TABLE_SIZE + \
+ AHCI_RXFIS_SIZE + \
+ AHCI_CMD_LIST_SIZE \
+ )
+
+#define AHCI_INIT_WAIT 10000 ///< us
+#define AHCI_INIT_TIMEOUT 10000000 ///< us
+#define AHCI_INIT_RETRY_COUNT 3
+#define AHCI_CMD_WAIT 100 ///< us
+#define AHCI_CMD_TIMEOUT 20000000 ///< us
+
+#define AHCI_CMD_PRDTL(prdtl) ((prdtl) << 16)
+#define AHCI_CMD_CFL(cfl) ((cfl) & 0x0F)
+#define AHCI_CMD_WRITE BIT6
+#define AHCI_CMD_PREFETCHABLE BIT7
+
+#define AHCI_REGION_MAX 0x400000 ///< 4MB
+#define R_PCH_SATA_AHCI_PXCLB 0x000
+#define R_PCH_SATA_AHCI_PXCLBU 0x004
+#define R_PCH_SATA_AHCI_PXFB 0x008
+#define R_PCH_SATA_AHCI_PXFBU 0x00C
+#define R_PCH_SATA_AHCI_PXIS 0x010
+#define R_PCH_SATA_AHCI_PXIE 0x014
+#define R_PCH_SATA_AHCI_PXCMD 0x018
+#define R_PCH_SATA_AHCI_PXTFD 0x020
+#define B_PCH_SATA_AHCI_PXTFD_STS_ERR BIT0
+#define B_PCH_SATA_AHCI_PXTFD_STS_DRQ BIT3
+#define B_PCH_SATA_AHCI_PXTFD_STS_BSY BIT7
+#define R_PCH_SATA_AHCI_PXSIG 0x024
+#define R_PCH_SATA_AHCI_PXSSTS 0x028
+#define B_PCH_SATA_AHCI_PXSSTS_DET 0x0000000F
+#define R_PCH_SATA_AHCI_PXSCTL 0x02C
+#define R_PCH_SATA_AHCI_PXSERR 0x030
+#define R_PCH_SATA_AHCI_PXSACT 0x034
+#define R_PCH_SATA_AHCI_PXCI 0x038
+
+#define B_PCH_SATA_AHCI_PXIS_FATAL (B_PCH_SATA_AHCI_PXIS_HBFS | \
+ B_PCH_SATA_AHCI_PXIS_HBDS | \
+ B_PCH_SATA_AHCI_PXIS_IFS | \
+ B_PCH_SATA_AHCI_PXIS_TFES | \
+ B_PCH_SATA_AHCI_PXIS_PCS \
+ )
+
+#define AHCI_ERROR(PxBase) ((MmioRead32 ((PxBase) + R_PCH_SATA_AHCI_PXIS) & B_PCH_SATA_AHCI_PXIS_FATAL) != 0)
+
+#define SATA_FIS_HOST2DEVICE 0x27
+#define SATA_FIS_C 0x8000
+#define SATA_FIS_CMD(cmd) (((cmd) & 0xFF) << 16)
+#define SATA_FIS_DEV_LBA 0x40000000
+#define SATA_FIS_LBA(lba) ((UINT32) ((lba) & 0x00FFFFFF))
+#define SATA_FIS_LBA_EXP(lba) ((UINT32) RShiftU64 ((lba), 24) & 0x00FFFFFF)
+#define SATA_FIS_SECT_COUNT(count) ((UINT16) (count))
+#define SATA_FIS_FEAT(feat) ((((UINT16) (feat)) & 0xFF) << 24)
+#define SATA_FIS_FEAT_EXP(feat) ((((UINT16) (feat)) & 0xFF00) << 16)
+
+#endif
diff --git a/ReferenceCode/RapidStart/Include/RapidStartConfig.h b/ReferenceCode/RapidStart/Include/RapidStartConfig.h
new file mode 100644
index 0000000..a290606
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartConfig.h
@@ -0,0 +1,70 @@
+/** @file
+ Header file to define the default build options
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef RAPID_START_CONFIG_H_
+#define RAPID_START_CONFIG_H_
+
+///
+/// uncomment #define to enable the setting.
+/// Don't just change the value to 0 to disable setting.
+///
+#ifndef RAPID_START_TRIM_ON_RESUME
+#define RAPID_START_TRIM_ON_RESUME 1
+#endif
+
+#ifndef RAPID_START_NO_SMRAM_INTEGRITY_CHECK
+#define RAPID_START_NO_SMRAM_INTEGRITY_CHECK
+#endif
+
+#ifndef RAPID_START_USE_OLD_ACPI_VARIABLE_SET
+#define RAPID_START_USE_OLD_ACPI_VARIABLE_SET
+#endif
+
+#ifndef RAPID_START_WHOLE_MEMORY_CHECK
+// #define RAPID_START_WHOLE_MEMORY_CHECK
+#endif
+
+#ifndef RAPID_START_ON_MEMORY_INSTALLED
+#define RAPID_START_ON_MEMORY_INSTALLED
+#endif
+
+#ifndef RAPID_START_ON_START_PPI_INSTALLED
+// #define RAPID_START_ON_START_PPI_INSTALLED
+#endif
+
+#ifndef RAPID_START_SCAN_ZERO_PAGE
+#define RAPID_START_SCAN_ZERO_PAGE
+#endif
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+///
+/// SW SMI callback function to check memory
+///
+#ifndef SW_SMI_WHOLE_MEMORY_CHECK
+#define SW_SMI_WHOLE_MEMORY_CHECK 0x51
+#endif
+///
+/// Default granularity 1MB
+///
+#ifndef MEMORY_CRC32_GRANULARITY
+#define MEMORY_CRC32_GRANULARITY 0x100000
+#endif
+#endif // RAPID_START_WHOLE_MEMORY_CHECK
+#endif
diff --git a/ReferenceCode/RapidStart/Include/RapidStartData.h b/ReferenceCode/RapidStart/Include/RapidStartData.h
new file mode 100644
index 0000000..132d6c6
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartData.h
@@ -0,0 +1,144 @@
+/** @file
+ Header file to define structure and GUID of RapidStart Persistent Data
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef RAPID_START_DATA_H_
+#define RAPID_START_DATA_H_
+
+#include EFI_GUID_DEFINITION (RapidStartPersistentData)
+
+#define MEM_EQU_4GB 0x100000000ULL
+#define MEM_EQU_1MB 0x100000
+#define LEGACY_SMRAM_BASE 0xA0000
+#define LEGACY_SMRAM_SIZE 0x20000
+#define LEGACY_SMRAM_BUFFER MEM_EQU_1MB
+
+//
+// RapidStart Flag definitions
+//
+#define RAPID_START_FLAG_ENTRY_DONE BIT0
+#define RAPID_START_FLAG_STORE_CHANGE BIT1
+
+#define V_PCH_LAN_IO_LEN 32
+#define R_PCH_LAN_IOADDR 0
+#define R_PCH_LAN_IODATA 4
+#define R_PCH_LAN_MDIC 0x20
+#define B_PCH_LAN_MDIC_READY BIT28
+#define B_PCH_LAN_MDIC_ERROR BIT30
+#define V_PCH_LAN_MDIC_SET_PAGE 0x043F0000
+#define V_PCH_LAN_MDIC_SET_ADDR 0x04310000
+#define V_PCH_LAN_MDIC_WRITE 0x04320000
+#define V_PCH_LAN_MDIC_READ 0x08320000
+#define R_PCH_LAN_EXTCNF_CTRL 0x0F00
+#define B_PCH_LAN_EXTCNF_CTRL_SWFLAG BIT5
+#define R_PCH_LAN_FWSM_S 0x5B54
+#define B_PCH_LAN_FWSM_S_FW_VAL BIT15
+#define R_PCH_LAN_FFVT 0x9800
+
+#define V_PHY_VALID_SIG 0x8086
+#define V_PHY_PAGE_WAKEUP 800
+#define R_LAN_PHY_RCTL 0x00
+#define R_LAN_PHY_IPAV 0x40
+#define R_LAN_PHY_PRXC 0x46
+
+#pragma pack(1)
+typedef struct {
+ UINT16 Year;
+ UINT8 Month;
+ UINT8 Date;
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+} RTC_TIME;
+
+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;
+ UINT8 HybridHardDisk;
+ UINT8 DisplayType;
+ UINT64 DssAddress;
+ UINT64 DssSize;
+} RAPID_START_PERSISTENT_DATA;
+
+#define FFVT_SIZE 5
+
+typedef struct {
+ UINT32 GPE0;
+ UINT32 GPE0a;
+ UINT32 GPE0b;
+ UINT32 Ffvt[FFVT_SIZE];
+ RTC_TIME OsWakeTime;
+ UINT8 OsWakeTimeEnabled;
+ UINT8 EntryCanceled;
+} RAPID_START_MEM_DATA;
+
+#pragma pack()
+
+#define RAPID_START_ACPI_RTC_WAKE 0x01
+#define RAPID_START_ACPI_BATT_WAKE 0x02
+
+#define RAPID_START_MEM_DATA_PTR(RapidStartData) \
+ ( \
+ (RAPID_START_MEM_DATA *) (VOID *) \
+ ( \
+ ((RapidStartData)->RapidStartMem) + ((RapidStartData)->RapidStartMemSize) - sizeof (RAPID_START_MEM_DATA) - \
+ ((RapidStartData)->ZeroBitmapSize) - ((RapidStartData)->Crc32RecordSize) \
+ ) \
+ )
+
+#define RAPID_START_ZERO_PAGE_BITMAP_PTR(RapidStartData) \
+ ( \
+ (UINT32 *) (UINTN) \
+ ( \
+ ((RapidStartData)->RapidStartMem) + \
+ ((RapidStartData)->RapidStartMemSize) - \
+ ((RapidStartData)->ZeroBitmapSize) - \
+ ((RapidStartData)->Crc32RecordSize) \
+ ) \
+ )
+
+#define RAPID_START_CRC32_RECORD_PTR(RapidStartData) \
+ ( \
+ (UINT32 *) (UINTN) ( \
+ ((RapidStartData)->RapidStartMem) + ((RapidStartData)->RapidStartMemSize) - ((RapidStartData)->Crc32RecordSize) \
+ ) \
+ )
+
+#define NUMBER_OF_PAGES(MemAddr) RShiftU64 (MemAddr, 12)
+#define NUMBER_OF_PAGES_IN_DWORD(MemAddr) RShiftU64 (MemAddr, 17)
+#define ZERO_BITMAP_UNIT 32 /* (sizeof (UINT32) * 8bits) */
+#endif
diff --git a/ReferenceCode/RapidStart/Include/RapidStartDxe.dsc b/ReferenceCode/RapidStart/Include/RapidStartDxe.dsc
new file mode 100644
index 0000000..36b1d76
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartDxe.dsc
@@ -0,0 +1,26 @@
+## @file
+# Build description file for building the RapidStart DXE drivers
+#
+#@copyright
+# Copyright (c) 2008 - 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
+#
+
+$(PROJECT_RAPID_START_ROOT)\Dxe\RapidStartDxe.inf SOURCE_OVERRIDE_PATH = $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\EntryPoints
+$(PROJECT_RAPID_START_ROOT)\Smm\RapidStartSmm.inf SOURCE_OVERRIDE_PATH = $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\EntryPoints
+$(PROJECT_RAPID_START_ROOT)\AcpiTables\RapidStartAcpiTables.inf
+#
+# Please uncomment following line after download binary modules PeiGfxDriver.efi and DxeGfxDriver.efi from IRS UEFI Graphics Drivers Release 5.0.1.1001 and later.
+#
+# $(PROJECT_RAPID_START_ROOT)\GfxDisplay\FfsGfxDriver\Dxe\DxeFfsGfxDriver.inf SOURCE_OVERRIDE_PATH = $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\EntryPoints
diff --git a/ReferenceCode/RapidStart/Include/RapidStartDxeLib.dsc b/ReferenceCode/RapidStart/Include/RapidStartDxeLib.dsc
new file mode 100644
index 0000000..15d15b9
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartDxeLib.dsc
@@ -0,0 +1,24 @@
+## @file
+# Build description file for building the RapidStart DXE Library
+#
+#@copyright
+# Copyright (c) 2008 - 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
+#
+
+$(PROJECT_RAPID_START_ROOT)\Protocol\RapidStartProtocolLib.inf
+$(PROJECT_RAPID_START_ROOT)\SampleCode\Library\RapidStartCommonLib\RapidStartCommonLib.inf
+$(PROJECT_RAPID_START_ROOT)\Guid\RapidStartGuidLib.inf
+$(PROJECT_RAPID_START_ROOT)\SampleCode\Library\RapidStartPlatformLib\Dxe\RapidStartDxeLib.inf
+$(PROJECT_RAPID_START_ROOT)\GfxDisplay\Library\Dxe\GfxDisplayLibDxe.inf
diff --git a/ReferenceCode/RapidStart/Include/RapidStartInclude.cif b/ReferenceCode/RapidStart/Include/RapidStartInclude.cif
new file mode 100644
index 0000000..8ea12e1
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartInclude.cif
@@ -0,0 +1,16 @@
+<component>
+ name = "RapidStartInclude"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Include"
+ RefName = "RapidStartInclude"
+[files]
+"RapidStartInclude.sdl"
+"RapidStartAhciReg.h"
+"RapidStartConfig.h"
+"RapidStartData.h"
+"RapidStartAcpi.dsc"
+"RapidStartDxe.dsc"
+"RapidStartDxeLib.dsc"
+"RapidStartPei.dsc"
+"RapidStartPeiLib.dsc"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Include/RapidStartInclude.sdl b/ReferenceCode/RapidStart/Include/RapidStartInclude.sdl
new file mode 100644
index 0000000..97b32fc
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartInclude.sdl
@@ -0,0 +1,68 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartInclude/RapidStartInclude.sdl 2 10/15/12 5:35a Bensonlai $
+#
+# $Revision: 2 $
+#
+# $Date: 10/15/12 5:35a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartInclude/RapidStartInclude.sdl $
+#
+# 2 10/15/12 5:35a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Shark Bay Rapid Start Reference Code Version
+# 0.7.1.0.
+# [Files] ReferenceCode\RapidStart\*.*
+#
+# 1 4/19/12 8:09a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartInclude_SUPPORT"
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStartInclude support in Project"
+End
+
+PATH
+ Name = "RapidStartInclude_DIR"
+End
+
+ELINK
+ Name = "/I$(RapidStartInclude_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/ReferenceCode/RapidStart/Include/RapidStartPei.dsc b/ReferenceCode/RapidStart/Include/RapidStartPei.dsc
new file mode 100644
index 0000000..15f7dfd
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartPei.dsc
@@ -0,0 +1,25 @@
+## @file
+# Build description file for building the RapidStart PEI modules
+#
+#@copyright
+# Copyright (c) 2008 - 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
+#
+
+$(PROJECT_RAPID_START_ROOT)\Pei\RapidStartPei.inf SOURCE_OVERRIDE_PATH = $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\EntryPoints
+
+#
+# Please uncomment following line after download binary modules PeiGfxDriver.efi and DxeGfxDriver.efi from IRS UEFI Graphics Drivers Release 5.0.1.1001 and later.
+#
+# $(PROJECT_RAPID_START_ROOT)\GfxDisplay\FfsGfxDriver\Pei\PeiGfxDriver.inf SOURCE_OVERRIDE_PATH = $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\EntryPoints
diff --git a/ReferenceCode/RapidStart/Include/RapidStartPeiLib.dsc b/ReferenceCode/RapidStart/Include/RapidStartPeiLib.dsc
new file mode 100644
index 0000000..d84bcb2
--- /dev/null
+++ b/ReferenceCode/RapidStart/Include/RapidStartPeiLib.dsc
@@ -0,0 +1,24 @@
+## @file
+# Build description file for building the RapidStart PEI library
+#
+#@copyright
+# Copyright (c) 2008 - 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
+#
+
+$(PROJECT_RAPID_START_ROOT)\Ppi\RapidStartPpiLib.inf
+$(PROJECT_RAPID_START_ROOT)\Guid\RapidStartGuidLib.inf
+$(PROJECT_RAPID_START_ROOT)\SampleCode\Library\RapidStartCommonLib\RapidStartCommonLib.inf
+$(PROJECT_RAPID_START_ROOT)\SampleCode\Library\RapidStartPlatformLib\Pei\RapidStartPeiLib.inf
+$(PROJECT_RAPID_START_ROOT)\GfxDisplay\Library\Pei\GfxDisplayLibPei.inf
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartAhci.c b/ReferenceCode/RapidStart/Pei/RapidStartAhci.c
new file mode 100644
index 0000000..7a37eb6
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartAhci.c
@@ -0,0 +1,1211 @@
+/** @file
+ Provide functions to initialize SATA controller and perform ACHI commands
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "RapidStartConfig.h"
+#include <SaAccess.h>
+#include <PchAccess.h>
+#include <PchPlatformLib.h>
+#include "RapidStartPeiLib.h"
+#include "RapidStartData.h"
+#include "RapidStartAhci.h"
+#endif
+
+typedef struct {
+ UINT64 DataByteAddr;
+ UINT32 Reserved;
+ UINT32 ByteCountI;
+} AHCI_PRDT;
+
+#ifndef EFI_DEBUG
+#define DumpPortStatus(a)
+#else
+/**
+ Send serial out debug message for AHCI port status
+
+ @param[in] Ahci - AHCI controller information structure
+**/
+STATIC
+VOID
+DumpPortStatus (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PxBase;
+ ASSERT (Ahci->Port <= 31);
+ PxBase = AHCI_PORT_BASE (Ahci);
+
+ DEBUG (
+ (EFI_D_ERROR,
+ " CLB:%08x FB:%08x\n CMD:%08x TFD:%08x IS:%08x\nSSTS:%08x SERR:%08x\n CI:%08x SACT:%08x SIG:%08x\n",
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCLB),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXFB),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXTFD),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXIS),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSSTS),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSERR),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSACT),
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSIG))
+ );
+}
+#endif
+
+/**
+ Returns SATA Port Control and Status register value.
+
+ @retval PCS value
+**/
+STATIC
+UINT16
+AhciGetPortControlStatus (
+ VOID
+ )
+{
+ UINTN PciD31F2RegBase;
+ PciD31F2RegBase = MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_SATA,
+ PCI_FUNCTION_NUMBER_PCH_SATA,
+ 0
+ );
+ return MmioRead16 (PciD31F2RegBase + R_PCH_SATA_PCS);
+}
+
+/**
+ Returns SATA enabled port bitmap basing on PCS value.
+
+ @retval Enabled ports map.
+**/
+UINT32
+AhciGetEnabledPorts (
+ VOID
+ )
+{
+ return AhciGetPortControlStatus () & 0x7F;
+}
+
+/**
+ Returns SATA present port bitmap basing on PCS value.
+
+ @retval Present ports map.
+**/
+UINT32
+AhciGetPresentPorts (
+ VOID
+ )
+{
+ return (AhciGetPortControlStatus () >> 8) & 0x7F;
+}
+
+/**
+ This is a work-around to make sure Port Implemented bits (RWO) are set.
+ PI is set according to PCS value restored from previous boot
+
+ @param[in] Ahci - SATA controller information structure
+**/
+STATIC
+VOID
+AhciConfigurePortsImplemented (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ ASSERT (Ahci->Port <= 31);
+ if ((MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_PI) & (1 << Ahci->Port)) == 0) {
+ MmioWrite32 (Ahci->Abar + R_PCH_SATA_AHCI_PI, AhciGetEnabledPorts ());
+ //
+ // Two reads required (C-spec ch. 25 - 1.9.14.1)
+ //
+ MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_PI);
+ MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_PI);
+ ASSERT (MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_PI) & (1 << Ahci->Port));
+ }
+}
+
+/**
+ Initialize SATA controller and enable decode
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - SATA controller has been initialized successfully
+**/
+EFI_STATUS
+AhciInit (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PciD31F2RegBase;
+
+ DEBUG ((EFI_D_INFO, "AhciInit()\n"));
+
+ Ahci->State = AHCI_STATE_INIT;
+ Ahci->Identify = NULL;
+
+ ASSERT ((Ahci->Abar &~(~0 << N_PCH_SATA_AHCI_BAR_ALIGNMENT)) == 0);
+
+ PciD31F2RegBase = MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_SATA,
+ PCI_FUNCTION_NUMBER_PCH_SATA,
+ 0
+ );
+
+ MmioWrite32 (PciD31F2RegBase + R_PCH_SATA_AHCI_BAR, Ahci->Abar);
+ ///
+ /// Enable decode
+ ///
+ MmioWrite8 (PciD31F2RegBase + R_PCH_SATA_COMMAND, 0x6);
+
+ DEBUG ((EFI_D_INFO, "FFS SATA BAR: %x\n", MmioRead32 (PciD31F2RegBase + R_PCH_SATA_AHCI_BAR)));
+ DEBUG ((EFI_D_INFO, "FFS SATA ID: %x\n", MmioRead32 (PciD31F2RegBase + 0)));
+ DEBUG ((EFI_D_INFO, "FFS SATA CMD: %x\n", MmioRead16 (PciD31F2RegBase + R_PCH_SATA_COMMAND)));
+ DEBUG ((EFI_D_INFO, "FFS SATA STS: %x\n", MmioRead16 (PciD31F2RegBase + R_PCH_SATA_PCISTS)));
+ DEBUG ((EFI_D_INFO, "FFS SATA PI: %x\n", MmioRead8 (PciD31F2RegBase + R_PCH_SATA_PI_REGISTER)));
+ DEBUG ((EFI_D_INFO, "FFS SATA CC: %x\n", MmioRead8 (PciD31F2RegBase + R_PCH_SATA_SUB_CLASS_CODE)));
+
+ ///
+ /// Enable SATA ports if not enabled already.
+ ///
+ AhciConfigurePortsImplemented (Ahci);
+
+ ///
+ /// Enable AHCI by setting AE bit
+ ///
+ MmioWrite32 (Ahci->Abar + R_PCH_SATA_AHCI_GHC, B_PCH_SATA_AHCI_GHC_AE);
+
+ DEBUG ((EFI_D_INFO, "FFS AHCI VS: %x\n", MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_VS)));
+ DEBUG ((EFI_D_INFO, "FFS AHCI GHC: %x\n", MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_GHC)));
+ DEBUG ((EFI_D_INFO, "FFS AHCI CAP: %x\n", MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_CAP)));
+ DEBUG ((EFI_D_INFO, "FFS AHCI PI: %x\n", MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_PI)));
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Disable SATA controller after all AHCI commands have completed
+
+ @param[in] Ahci - SATA controller information structure
+**/
+VOID
+AhciDone (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PciD31F2RegBase;
+
+ DEBUG ((EFI_D_INFO, "AhciDone()\n"));
+ ASSERT (Ahci->State == AHCI_STATE_INIT);
+ Ahci->State = AHCI_STATE_UNKNOWN;
+
+ PciD31F2RegBase = MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_SATA,
+ PCI_FUNCTION_NUMBER_PCH_SATA,
+ 0
+ );
+
+ ///
+ /// Disable AHCI
+ ///
+ MmioWrite32 (Ahci->Abar + R_PCH_SATA_AHCI_GHC, 0);
+
+ ///
+ /// Unconfigure SATA
+ ///
+ MmioWrite32 (PciD31F2RegBase + R_PCH_SATA_AHCI_BAR, 0);
+ MmioWrite8 (PciD31F2RegBase + R_PCH_SATA_COMMAND, 0);
+}
+
+/**
+ Spin up Ahci port
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Port - SATA port number
+
+ @retval EFI_SUCCESS - AHCI Port has been spun up successfully
+**/
+EFI_STATUS
+AhciSpinUpPort (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINTN Port
+ )
+{
+ UINTN PxBase;
+
+ DEBUG ((EFI_D_INFO, "AhciPortSpinUpPort(%d)\n", Port));
+ ASSERT (Ahci->State == AHCI_STATE_INIT);
+ ASSERT (Port <= 31);
+ ASSERT (MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_GHC) & B_PCH_SATA_AHCI_GHC_AE);
+
+ PxBase = AHCI_PORT_BASE_X (Ahci, Port);
+
+ ASSERT ((MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_ST) == 0);
+
+ ///
+ /// Clear errors
+ ///
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXSERR, (UINT32)~0u);
+
+ ///
+ /// Spin Up
+ ///
+ MmioOr32 (PxBase + R_PCH_SATA_AHCI_PXCMD, B_PCH_SATA_AHCI_PxCMD_SUD);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Initialize AHCI port for reading/writing RapidStart Store
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_DEVICE_ERROR - AHCI port initialization failed
+ @retval EFI_SUCCESS - AHCI port initialized successfully and RapidStart Store is ready for reading/writing
+ @retval EFI_SECURITY_VIOLATION - Drive is already in SECURITY FREEZE state and will not accept UNLOCK command
+ @retval EFI_ACCESS_DENIED - Drive is in LOCKED state and need to execute UNLOCK command before accessing
+**/
+EFI_STATUS
+AhciPortInit (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PxBase;
+ UINT32 Timer;
+ UINT32 Count;
+
+ DEBUG ((EFI_D_INFO, "AhciPortInit()\n"));
+ ASSERT (Ahci->State == AHCI_STATE_INIT);
+ ASSERT (Ahci->Port <= 31);
+ ASSERT (MmioRead32 (Ahci->Abar + R_PCH_SATA_AHCI_GHC) & B_PCH_SATA_AHCI_GHC_AE);
+ DEBUG ((EFI_D_INFO, "Mem used: %d\n", AHCI_MEM_MAX (Ahci) - Ahci->PortBase));
+ DEBUG ((EFI_D_INFO, "AHCI_MEM_MAX_SIZE: %d\n", AHCI_MEM_MAX_SIZE));
+
+ ASSERT (AHCI_MEM_MAX (Ahci) <= (Ahci->PortBase + Ahci->PortSize));
+ ASSERT ((AHCI_MEM_MAX (Ahci) - Ahci->PortBase) == AHCI_MEM_MAX_SIZE);
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+
+ ASSERT ((MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_ST) == 0);
+
+ ZeroMem ((VOID *) Ahci->PortBase, Ahci->PortSize);
+
+ DEBUG ((EFI_D_INFO, "AHCI_CMD_LIST_BASE: %08lx\n", (UINT64) AHCI_CMD_LIST_BASE (Ahci)));
+ DEBUG ((EFI_D_INFO, "AHCI_RXFIS_BASE: %08lx\n", (UINT64) AHCI_RXFIS_BASE (Ahci)));
+ DEBUG ((EFI_D_INFO, "AHCI_CMD_TABLE_BASE: %08lx\n", (UINT64) AHCI_CMD_TABLE_BASE (Ahci)));
+ DEBUG ((EFI_D_INFO, "AHCI_MEM_MAX: %08lx\n", (UINT64) AHCI_MEM_MAX (Ahci)));
+
+ ASSERT ((AHCI_CMD_LIST_BASE (Ahci) & 0x3FF) == 0);
+ ASSERT ((AHCI_RXFIS_BASE (Ahci) & 0xFF) == 0);
+
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXCLB, (UINT32) AHCI_CMD_LIST_BASE (Ahci));
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXCLBU, (UINT32) RShiftU64 (AHCI_CMD_LIST_BASE (Ahci), 32));
+
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXFB, (UINT32) AHCI_RXFIS_BASE (Ahci));
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXFBU, (UINT32) RShiftU64 (AHCI_RXFIS_BASE (Ahci), 32));
+
+ MmioOr32 (PxBase + R_PCH_SATA_AHCI_PXCMD, B_PCH_SATA_AHCI_PxCMD_FRE);
+
+ ASSERT (MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_SUD);
+
+ ///
+ /// Clear errors
+ ///
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXSERR, (UINT32)~0u);
+
+ for (Count = 0; Count < AHCI_INIT_RETRY_COUNT; ++Count) {
+ ///
+ /// Reset port if in error state
+ ///
+ if (Count > 0 || MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSERR) != 0) {
+ DEBUG ((EFI_D_INFO, "Resetting AHCI port.\n"));
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXSCTL, V_PCH_SATA_AHCI_PXSCTL_DET_1);
+ PchPmTimerStall (1000);
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXSCTL, 0);
+ }
+
+ Timer = 0;
+
+ ///
+ /// Wait till device detected
+ ///
+ while
+ (
+ Timer < AHCI_INIT_TIMEOUT &&
+ ((MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXSSTS) & B_PCH_SATA_AHCI_PXSSTS_DET) != B_PCH_SATA_AHCI_PXSSTS_DET_3)
+ ) {
+ PchPmTimerStall (AHCI_INIT_WAIT);
+ Timer += AHCI_INIT_WAIT;
+ }
+ ///
+ /// Clear errors
+ ///
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXSERR, (UINT32)~0u);
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXIS, (UINT32)~0u);
+
+ ///
+ /// Wait for device ready
+ ///
+ while (Timer < AHCI_INIT_TIMEOUT) {
+ if ((
+ MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXTFD) & (B_PCH_SATA_AHCI_PXTFD_STS_DRQ | B_PCH_SATA_AHCI_PXTFD_STS_BSY)
+ ) == 0
+ ) {
+ goto complete;
+ }
+
+ PchPmTimerStall (AHCI_INIT_WAIT);
+ Timer += AHCI_INIT_WAIT;
+ }
+ }
+
+complete:
+
+ if (Count == AHCI_INIT_RETRY_COUNT) {
+
+ DEBUG ((EFI_D_ERROR, "AHCI port initialization timeout.\n"));
+ DumpPortStatus (Ahci);
+
+ ///
+ /// Clear FRE
+ ///
+ MmioAnd32 (PxBase + R_PCH_SATA_AHCI_PXCMD, (UINT32)~B_PCH_SATA_AHCI_PxCMD_FRE);
+
+ ///
+ /// Wait for FR to be cleared
+ ///
+ while (MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_FR) {
+ }
+
+ return EFI_DEVICE_ERROR;
+ }
+
+ ASSERT ((MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & (B_PCH_SATA_AHCI_PxCMD_CLO | B_PCH_SATA_AHCI_PxCMD_CR)) == 0);
+
+ ///
+ /// Set Start bit
+ ///
+ MmioOr32 (PxBase + R_PCH_SATA_AHCI_PXCMD, B_PCH_SATA_AHCI_PxCMD_ST);
+
+ Ahci->State = AHCI_STATE_INUSE;
+ return EFI_SUCCESS;
+}
+
+/**
+ Check whether device is password locked.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - Device not locked
+ @retval EFI_ACCESS_DENIED - Drive is in LOCKED state and need to execute UNLOCK command before accessing
+ @retval EFI_SECURITY_VIOLATION - Drive is already in SECURITY FREEZE state and will not accept UNLOCK command
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+**/
+EFI_STATUS
+AhciGetLockStatus (
+ IN AHCI_CONTEXT *Ahci
+)
+{
+ UINT16 SecurityStatus;
+ EFI_STATUS Status;
+ VOID *Buffer;
+
+ DEBUG ((EFI_D_INFO, "AhciGetLockStatus()\n"));
+ ASSERT (Ahci->State == AHCI_STATE_INUSE);
+
+ if (Ahci->Identify == 0) {
+ Buffer = (VOID*) AHCI_ID_BLOCK (Ahci);
+ Status = AhciIdentifyDevice (Ahci, Buffer);
+ if (Status == EFI_SUCCESS) {
+ Ahci->Identify = (UINT16 *) Buffer;
+ } else {
+ DEBUG ((EFI_D_ERROR, "Error: Identifying device failed!\n"));
+ return Status;
+ }
+ }
+ SecurityStatus = Ahci->Identify[ATA_ID_DEV_SECURITY_STATUS];
+ if ((SecurityStatus & (B_ATA_ID_DEV_SEC_SUPPORTED | B_ATA_ID_DEV_SEC_ENABLED | B_ATA_ID_DEV_SEC_LOCKED)
+ ) == (B_ATA_ID_DEV_SEC_SUPPORTED | B_ATA_ID_DEV_SEC_ENABLED | B_ATA_ID_DEV_SEC_LOCKED)
+ ) {
+ if (SecurityStatus & (B_ATA_ID_DEV_SEC_FROZEN | B_ATA_ID_DEV_SEC_COUNT_EXP)) {
+ DEBUG ((EFI_D_ERROR, "AHCI device lock freeze!\n"));
+ return EFI_SECURITY_VIOLATION;
+ }
+ DEBUG ((EFI_D_WARN, "AHCI device locked!\n"));
+ return EFI_ACCESS_DENIED;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Stops AHCI port.
+
+ @param[in] Ahci - SATA controller information structure
+**/
+VOID
+AhciPortDone (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PxBase;
+
+ DEBUG ((EFI_D_INFO, "AhciPortDone()\n"));
+ Ahci->State = AHCI_STATE_INIT;
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+ ASSERT (MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI) == 0);
+
+ MmioAnd32 (PxBase + R_PCH_SATA_AHCI_PXCMD, (UINT32)~B_PCH_SATA_AHCI_PxCMD_ST);
+
+ ///
+ /// Wait for CR to be cleared
+ ///
+ while (MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_CR) {
+ }
+
+ MmioAnd32 (PxBase + R_PCH_SATA_AHCI_PXCMD, (UINT32)~B_PCH_SATA_AHCI_PxCMD_FRE);
+
+ ///
+ /// Wait for FR to be cleared
+ ///
+ while (MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCMD) & B_PCH_SATA_AHCI_PxCMD_FR) {
+ }
+}
+
+/**
+ Check whether there are available command slots.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval TRUE if there is an available slot, FALSE otherwise.
+**/
+BOOLEAN
+AhciHasFreeCmdSlot (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PxBase;
+ UINT32 ci;
+
+ ASSERT (AHCI_MAX_CMD <= 32);
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+ ci = MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI);
+
+ return ci != ((UINT32)~0u >> (32 - AHCI_MAX_CMD));
+}
+
+/**
+ Finds or waits for available command slot
+
+ @param[in] Ahci - SATA controller information structure
+ @param[out] CmdIndex - Available command slot index
+
+ @retval EFI_SUCCESS - Available command slot index found
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+ @retval EFI_NOT_STARTED - The RapidStart Entry flow should be canceled and do S3 resume back to OS
+**/
+STATIC
+EFI_STATUS
+AhciFindCmdSlot (
+ IN AHCI_CONTEXT *Ahci,
+ OUT UINTN *CmdIndex
+ )
+{
+ UINTN PxBase;
+ UINT32 ci;
+ UINT32 Timer;
+ UINT32 Index;
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+
+ Timer = 0;
+ while (Timer < AHCI_CMD_TIMEOUT) {
+ ci = MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI);
+
+ for (Index = 0; Index < AHCI_MAX_CMD; ++Index) {
+ if ((ci & (1u << Index)) == 0) {
+ *CmdIndex = Index;
+ return EFI_SUCCESS;
+ }
+ }
+
+ if (Ahci->PollCancellation && RapidStartShouldCancelEntry ()) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (AHCI_ERROR (PxBase)) {
+ DEBUG ((EFI_D_ERROR, "AHCI error!\n"));
+ DumpPortStatus (Ahci);
+ return EFI_DEVICE_ERROR;
+ }
+
+ PchPmTimerStall (AHCI_CMD_WAIT);
+ Timer += AHCI_CMD_WAIT;
+ }
+
+ DEBUG ((EFI_D_ERROR, "AHCI command timeout!\n"));
+ DumpPortStatus (Ahci);
+ return EFI_TIMEOUT;
+}
+
+/**
+ Waits until given command(s) complete.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] CmdMask - Command(s) mask
+
+ @retval EFI_SUCCESS - Command complete
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+ @retval EFI_NOT_STARTED - The RapidStart Entry flow should be canceled and do S3 resume back to OS
+**/
+EFI_STATUS
+AhciWaitComplete (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT32 CmdMask
+ )
+{
+ UINTN PxBase;
+ UINT32 ci;
+ UINT32 Timer;
+
+ DEBUG ((EFI_D_INFO, "AhciWaitComplete(%d)\n", CmdMask));
+ ASSERT (Ahci->State == AHCI_STATE_INUSE);
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+
+ Timer = 0;
+ while (Timer < AHCI_CMD_TIMEOUT) {
+ ci = MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI);
+
+ if ((ci & CmdMask) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ if (Ahci->PollCancellation && RapidStartShouldCancelEntry ()) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (AHCI_ERROR (PxBase)) {
+ DEBUG ((EFI_D_ERROR, "AHCI error!\n"));
+ DumpPortStatus (Ahci);
+ return EFI_DEVICE_ERROR;
+ }
+
+ PchPmTimerStall (AHCI_CMD_WAIT);
+ Timer += AHCI_CMD_WAIT;
+ }
+
+ DEBUG ((EFI_D_ERROR, "AHCI command timeout!\n"));
+ DumpPortStatus (Ahci);
+ return EFI_TIMEOUT;
+}
+
+/**
+ Waits until all AHCI commands completed.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - All AHCI commands have completed
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+ @retval EFI_NOT_STARTED - The RapidStart Entry flow should be canceled and do S3 resume back to OS
+**/
+EFI_STATUS
+AhciWaitAllComplete (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ UINTN PxBase;
+ UINT32 Ci;
+ UINT32 PrevCi;
+ EFI_STATUS Status;
+ UINT32 Timer;
+
+ DEBUG ((EFI_D_INFO, "AhciWaitAllComplete() "));
+ ASSERT (Ahci->State == AHCI_STATE_INUSE);
+
+ PxBase = AHCI_PORT_BASE (Ahci);
+ Timer = 0;
+ Status = EFI_TIMEOUT;
+
+ Ci = MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI);
+ PrevCi = Ci;
+
+ while (Timer < AHCI_CMD_TIMEOUT) {
+ if (Ci == 0) {
+ Status = EFI_SUCCESS;
+ break;
+ }
+
+ if (Ahci->PollCancellation && RapidStartShouldCancelEntry ()) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (AHCI_ERROR (PxBase)) {
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+ if (Ci != PrevCi) {
+ DEBUG ((EFI_D_INFO, "."));
+ Timer = 0;
+ }
+
+ PchPmTimerStall (AHCI_CMD_WAIT);
+ Timer += AHCI_CMD_WAIT;
+ PrevCi = Ci;
+ Ci = MmioRead32 (PxBase + R_PCH_SATA_AHCI_PXCI);
+ }
+
+ DEBUG ((EFI_D_INFO, "\n"));
+ if (Status == EFI_TIMEOUT) {
+ DEBUG ((EFI_D_ERROR, "AHCI command timeout!\n"));
+ } else if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "AHCI error!\n"));
+ DumpPortStatus (Ahci);
+ }
+
+ return Status;
+}
+
+/**
+ Enqueues ahci command for read/write and optionally with Zero filter
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in,out] AtaCmd - ATA command structure
+ @param[out] CmdMask - If given a bit corresponding to allocated command slot is set
+ @param[in] ZeroPageBitMap - A pointer for ZeroPageTable
+ @param[out] SmRamBufferLba - If given the drive LBA storing original SMRAM buffer content will be passed by it.
+
+ @retval EFI_SUCCESS - AHCI command successfully posted
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciPostCommandWithZeroFilter (
+ IN AHCI_CONTEXT *Ahci,
+ IN OUT ATA_COMMAND *AtaCmd,
+ OUT OPTIONAL UINT32 *CmdMask,
+ IN OPTIONAL UINT32 *ZeroPageBitMap,
+ OUT OPTIONAL UINT64 *SmRamBufferLba
+ )
+{
+ UINTN PxBase;
+ UINTN CmdIndex;
+ UINTN CmdTableAddr;
+ UINT32 *CmdHeader;
+ UINT32 *CmdFis;
+ AHCI_PRDT *Prdt;
+ UINT16 PrdCount;
+ UINT16 Index;
+ UINT32 MemLeft;
+ UINT32 MemChunk;
+ UINT64 MemAddr;
+ EFI_STATUS Status;
+ UINT32 TempBitMap;
+ UINT32 *ZeroPagePointer;
+ UINT8 count;
+ UINT32 AhciMaxRegion;
+ UINT32 NumberOfPages;
+ UINT32 SectorCount;
+
+ count = 0;
+ ZeroPagePointer = 0;
+ TempBitMap = 0;
+ CmdIndex = 0;
+
+ DEBUG (
+ (EFI_D_INFO,
+ "AhciPostCommand port=%d cmd=%02x lba=%08x mem=%08lx ",
+ Ahci->Port,
+ AtaCmd->Command,
+ (UINT32) AtaCmd->Lba,
+ (UINT64) AtaCmd->MemAddr)
+ );
+ ASSERT (Ahci->State == AHCI_STATE_INUSE);
+
+ MemAddr = AtaCmd->MemAddr;
+ MemLeft = AtaCmd->SectorCount << SECTOR_SHIFT;
+ PxBase = AHCI_PORT_BASE (Ahci);
+
+ ASSERT ((MemAddr & (ZeroPageBitMap ? 0xFFF : 1)) == 0);
+ ASSERT (AtaCmd->SectorCount <= AHCI_MAX_SECTORS);
+
+ Status = AhciFindCmdSlot (Ahci, &CmdIndex);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ASSERT (CmdIndex < AHCI_MAX_CMD);
+
+ CmdHeader = (UINT32 *) AHCI_CMD_HEADER (Ahci, CmdIndex);
+ CmdTableAddr = AHCI_CMD_TABLE (Ahci, CmdIndex);
+ CmdFis = (UINT32 *) (UINTN) CmdTableAddr;
+ Prdt = (AHCI_PRDT *) (UINTN) (CmdTableAddr + AHCI_CMD_TABLE_HEADER_SIZE);
+
+ ASSERT ((UINT32) CmdHeader >= AHCI_CMD_LIST_BASE (Ahci));
+ ASSERT ((UINT32) CmdHeader + AHCI_CMD_HEADER_SIZE <= AHCI_CMD_LIST_BASE (Ahci) + AHCI_CMD_LIST_SIZE);
+ ASSERT (CmdTableAddr >= Ahci->PortBase);
+ ASSERT (CmdTableAddr + AHCI_CMD_TABLE_SIZE <= Ahci->PortBase + Ahci->PortSize);
+ ASSERT (RShiftU64 (AtaCmd->Lba, 48) == 0);
+
+ ///
+ /// Create PRD table
+ ///
+ PrdCount = 0;
+ AhciMaxRegion = AHCI_REGION_MAX;
+ SectorCount = 0;
+ ///
+ /// Initialize ZeroPage Filter Parameters
+ ///
+ if (ZeroPageBitMap != NULL) {
+ NumberOfPages = (UINT32) NUMBER_OF_PAGES_IN_DWORD (MemAddr);
+ ZeroPagePointer = ZeroPageBitMap + NumberOfPages;
+ count = (UINT8) (NUMBER_OF_PAGES (MemAddr) - (NumberOfPages * ZERO_BITMAP_UNIT));
+ TempBitMap = (UINT32) *ZeroPagePointer;
+ AhciMaxRegion = EFI_PAGE_SIZE;
+ }
+
+ while (MemLeft > 0) {
+ ASSERT (PrdCount < AHCI_MAX_PRDT);
+ ASSERT ((MemAddr & 1) == 0);
+
+ if (MemLeft >= AhciMaxRegion) {
+ MemChunk = AhciMaxRegion;
+ } else {
+ MemChunk = MemLeft;
+ }
+
+ ASSERT (((MemChunk - 1) &~(AhciMaxRegion - 1)) == 0);
+ ASSERT ((MemChunk & 0x1FF) == 0);
+
+ if (ZeroPageBitMap != NULL) {
+ ///
+ /// Get LBA which storing SMRAM buffer and later restore this buffer after SMRAM handled.
+ ///
+ if (SmRamBufferLba != NULL) {
+ if (MemAddr == LEGACY_SMRAM_BUFFER) {
+ *SmRamBufferLba = AtaCmd->Lba + SectorCount;
+ }
+ }
+
+ if (((UINT32) (TempBitMap >> count) & 1) == 0) {
+ Prdt[PrdCount].DataByteAddr = MemAddr;
+ Prdt[PrdCount].Reserved = 0;
+ Prdt[PrdCount].ByteCountI = MemChunk - 1;
+ PrdCount++;
+ SectorCount += 8;
+ }
+ ///
+ /// Shift ZeroPage filter bitmap to next bit, if it is end of current DWORD, will shift to next DWORD
+ ///
+ if (count < (ZERO_BITMAP_UNIT - 1)) {
+ count++;
+ } else {
+ count = 0;
+ ZeroPagePointer++;
+ TempBitMap = (UINT32) *ZeroPagePointer;
+ }
+ } else {
+ Prdt[PrdCount].DataByteAddr = MemAddr;
+ Prdt[PrdCount].Reserved = 0;
+ Prdt[PrdCount].ByteCountI = MemChunk - 1;
+ PrdCount++;
+ SectorCount += MemChunk >> SECTOR_SHIFT;
+ }
+
+ MemAddr += MemChunk;
+ MemLeft -= MemChunk;
+ }
+
+ AtaCmd->MemAddr += AtaCmd->SectorCount << SECTOR_SHIFT;
+ AtaCmd->SectorCount = SectorCount;
+
+ if (ZeroPageBitMap != NULL && PrdCount == 0) {
+ DEBUG ((EFI_D_INFO, "skipped\n"));
+ return EFI_SUCCESS;
+ }
+ ///
+ /// Fill command header
+ ///
+ ASSERT ((CmdTableAddr & 0x7F) == 0);
+ CmdHeader[0] = AHCI_CMD_PRDTL (PrdCount) | AHCI_CMD_CFL (5);
+ if (AtaCmd->Direction == AHCI_DIR_HOST2DEV) {
+ CmdHeader[0] |= AHCI_CMD_WRITE | AHCI_CMD_PREFETCHABLE;
+ }
+
+ CmdHeader[1] = 0;
+ CmdHeader[2] = (UINT32) CmdTableAddr;
+ CmdHeader[3] = (UINT32) RShiftU64 (CmdTableAddr, 32);
+ for (Index = 4; Index < 8; ++Index) {
+ CmdHeader[Index] = 0;
+ }
+ ///
+ /// Create FIS
+ ///
+ CmdFis[0] = SATA_FIS_FEAT (AtaCmd->Feature) | SATA_FIS_CMD (AtaCmd->Command) | SATA_FIS_C | SATA_FIS_HOST2DEVICE;
+ CmdFis[1] = SATA_FIS_DEV_LBA | SATA_FIS_LBA (AtaCmd->Lba);
+ CmdFis[2] = SATA_FIS_FEAT_EXP (AtaCmd->Feature) | SATA_FIS_LBA_EXP (AtaCmd->Lba);
+ CmdFis[3] = SATA_FIS_SECT_COUNT (SectorCount);
+ CmdFis[4] = AtaCmd->Auxiliary.Data;
+ DEBUG ((EFI_D_INFO, "FIS[4] = %x\n", AtaCmd->Auxiliary.Data));
+
+ DEBUG ((EFI_D_INFO, "actualcount=%d ", SectorCount));
+
+ ///
+ /// Issue the command to the controller
+ ///
+ MmioWrite32 (PxBase + R_PCH_SATA_AHCI_PXCI, (1u << CmdIndex));
+
+ if (CmdMask != NULL) {
+ *CmdMask |= (1u << CmdIndex);
+ }
+
+ AtaCmd->Lba += SectorCount;
+ DEBUG ((EFI_D_INFO, "idx=%d\n", CmdIndex));
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Executes AHCI command and waits until command completes.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in,out] AtaCmd - ATA command structure
+
+ @retval EFI_SUCCESS - AHCI command successfully posted
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciExecCommand (
+ IN AHCI_CONTEXT *Ahci,
+ IN OUT ATA_COMMAND *AtaCmd
+ )
+{
+ EFI_STATUS Status;
+ UINTN CmdMask;
+
+ CmdMask = 0;
+ Status = AhciPostCommand (Ahci, AtaCmd, &CmdMask);
+ if (Status == EFI_SUCCESS) {
+ Status = AhciWaitComplete (Ahci, CmdMask);
+ }
+
+ return Status;
+}
+
+/**
+ Issues ATA command with no data transfer.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Command - Command to be issued
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciSimpleCommand (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT8 Command
+ )
+{
+ ATA_COMMAND AtaCmd;
+
+ ZeroMem (&AtaCmd, sizeof (AtaCmd));
+ AtaCmd.Command = Command;
+
+ return AhciExecCommand (Ahci, &AtaCmd);
+}
+
+/**
+ Sends Identify Device ATA command to port
+
+ @param[in] Ahci - SATA controller information structure
+ @param[out] Buffer - Buffer to store device information
+
+ @retval EFI_SUCCESS - function executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciIdentifyDevice (
+ IN AHCI_CONTEXT *Ahci,
+ OUT VOID *Buffer
+ )
+{
+ ATA_COMMAND AtaCmd;
+
+ DEBUG ((EFI_D_INFO, "AhciIdentifyDevice()\n"));
+ ASSERT (Buffer != NULL);
+
+ AtaCmd.Command = ATA_CMD_IDENTIFY_DEVICE;
+ AtaCmd.Direction = AHCI_DIR_DEV2HOST;
+ AtaCmd.Lba = 0;
+ AtaCmd.SectorCount = 1;
+ AtaCmd.MemAddr = (UINTN) Buffer;
+ AtaCmd.Feature = 0;
+
+ return AhciExecCommand (Ahci, &AtaCmd);
+}
+
+/**
+ Performs TRIM command on given LBA range.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Lba - First block to be trimmed
+ @param[in] Count - Number of blocks to trim
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @exception EFI_UNSUPPORTED - TRIM is not supported by the device
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciTrimRange (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT64 Lba,
+ IN UINT32 Count
+ )
+{
+ UINT64 *RangeEntries;
+ UINTN Index;
+ UINT16 Blocks;
+ ATA_COMMAND AtaCmd;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "AhciTrimRange(lba=%lx count=%x)\n", Lba, Count));
+ ASSERT (Ahci->Identify != NULL);
+
+ if (!((Ahci->Identify[ATA_ID_DEV_DATA_SET_MGMNT_SUPPORT] & B_ATA_ID_DEV_DATA_SET_TRIM) &&
+ (Ahci->Identify[ATA_ID_DEV_DATA_SET_MGMNT_BLOCKS] > 0))
+ ) {
+ DEBUG ((EFI_D_WARN, "TRIM is not supported!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
+ RangeEntries = (UINT64 *) AHCI_TMP_BLOCK (Ahci);
+
+ AtaCmd.Command = ATA_CMD_DATA_SET_MANAGEMENT;
+ AtaCmd.Direction = AHCI_DIR_HOST2DEV;
+ AtaCmd.Feature = V_ATA_TRIM_FEATURE;
+ AtaCmd.SectorCount = 1;
+
+ while (Count > 0) {
+ for (Index = 0; Index < (AHCI_TMP_BLOCK_SIZE / sizeof (UINT64)); ++Index) {
+ if (Count <= 0xFFFF) {
+ Blocks = (UINT16) Count;
+ } else {
+ Blocks = 0xFFFF;
+ }
+
+ if (Blocks != 0) {
+ RangeEntries[Index] = LShiftU64 (Blocks, 48) | Lba;
+ } else {
+ RangeEntries[Index] = 0;
+ }
+
+ Count -= Blocks;
+ Lba += Blocks;
+ }
+
+ AtaCmd.Lba = 0;
+ AtaCmd.MemAddr = (UINTN) RangeEntries;
+
+ Status = AhciExecCommand (Ahci, &AtaCmd);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Unlocks ATA device.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Password - security credential
+
+ @retval EFI_SUCCESS - Command executed successfully
+ @retval EFI_SECURITY_VIOLATION - Device security lock freeze
+ @exception EFI_UNSUPPORTED - Security is not supported by the device
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciSecurityUnlock (
+ IN AHCI_CONTEXT *Ahci,
+ IN CHAR8 *Password
+ )
+{
+ UINT16 *Block;
+ ATA_COMMAND AtaCmd;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "AhciSecurityUnlock()\n"));
+ ASSERT (Ahci->Identify != NULL);
+
+ if ((Ahci->Identify[ATA_ID_DEV_SECURITY_STATUS] & B_ATA_ID_DEV_SEC_SUPPORTED) == 0) {
+ DEBUG ((EFI_D_ERROR, "AHCI security not supported!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
+ if ((Ahci->Identify[ATA_ID_DEV_SECURITY_STATUS] & (B_ATA_ID_DEV_SEC_ENABLED | B_ATA_ID_DEV_SEC_LOCKED)) !=
+ (B_ATA_ID_DEV_SEC_ENABLED | B_ATA_ID_DEV_SEC_LOCKED)
+ ) {
+ DEBUG ((EFI_D_WARN, "AHCI device already unlocked!\n"));
+ return EFI_SUCCESS;
+ }
+
+ if (Ahci->Identify[ATA_ID_DEV_SECURITY_STATUS] & (B_ATA_ID_DEV_SEC_FROZEN | B_ATA_ID_DEV_SEC_COUNT_EXP)) {
+ DEBUG ((EFI_D_ERROR, "AHCI device lock freeze!\n"));
+ return EFI_SECURITY_VIOLATION;
+ }
+
+ Block = (UINT16 *) AHCI_TMP_BLOCK (Ahci);
+ Block[0] = 0;
+ CopyMem (&Block[1], Password, ATA_PASSWORD_LEN);
+
+ AtaCmd.Command = ATA_CMD_SECURITY_UNLOCK;
+ AtaCmd.Direction = AHCI_DIR_HOST2DEV;
+ AtaCmd.Feature = 0;
+ AtaCmd.Lba = 0;
+ AtaCmd.MemAddr = (UINTN) Block;
+ AtaCmd.SectorCount = 1;
+
+ Status = AhciExecCommand (Ahci, &AtaCmd);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "AHCI unlock failed!\n"));
+ }
+
+ return Status;
+}
+
+/**
+ Hybrid Hard Disk Support.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @exception EFI_UNSUPPORTED - HHD is not supported by the device
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciHybridHardDiskSupport (
+ IN AHCI_CONTEXT *Ahci
+ )
+{
+ EFI_STATUS Status;
+ ATA_COMMAND AtaCmd;
+ UINT8 *HybridLogRangeEntries;
+ UINT8 *HybridInfoHeader;
+ UINT8 *HybridInfoDescriptor;
+ UINT16 Index, HybridInfoDescriptorNumber;
+ UINT64 X, Y;
+ UINT64 NvmSize;
+
+ DEBUG ((EFI_D_INFO, "Ahci Hybrid Hard Device Support Start\n"));
+ ASSERT (Ahci->Identify != NULL);
+
+ if (!((Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_SUPPORT] & B_ATA_ID_DEV_HYBRID_FEATURE_SUPPORT) &
+ (Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_ENABLE] & B_ATA_ID_DEV_HYBRID_FEATURE_ENABLE))
+ ) {
+ DEBUG ((EFI_D_ERROR, "Hybrid is not supported!\n"));
+ DEBUG ((EFI_D_ERROR, "Hybrid Feature support = %x\n", Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_SUPPORT]));
+ DEBUG ((EFI_D_ERROR, "Hybrid Feature Enable = %x\n", Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_ENABLE]));
+
+ return EFI_UNSUPPORTED;
+ }
+
+ HybridLogRangeEntries = (UINT8 *) AHCI_TMP_BLOCK (Ahci);
+
+ AtaCmd.Command = ATA_CMD_READ_LOG_EXT;
+ AtaCmd.Direction = AHCI_DIR_DEV2HOST;
+ AtaCmd.Lba = 0x14;
+ AtaCmd.SectorCount = 1;
+ AtaCmd.MemAddr = (UINTN) HybridLogRangeEntries;
+ AtaCmd.Feature = 0;
+
+ Status = AhciExecCommand (Ahci, &AtaCmd);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Hybrid can't be supported, READ_LOG_EXT fail and Status is %r\n", Status));
+ return Status;
+ }
+
+ HybridInfoHeader = HybridLogRangeEntries;
+
+ if (HybridInfoHeader[2] != 0xFF) {
+ DEBUG ((EFI_D_ERROR, "Hybrid Information is Disabled\n"));
+ return EFI_DEVICE_ERROR;
+ }
+
+ DEBUG ((EFI_D_INFO, "Maximum Hybrid Priority is %x\n", HybridInfoHeader[7]));
+ if (HybridInfoHeader[7] == 0 || HybridInfoHeader[7] > 16) {
+ DEBUG ((EFI_D_ERROR, "Maximum Hybrid Priority Level is invalid !!\n"));
+ return EFI_DEVICE_ERROR;
+ }
+
+ Ahci->HybridInfo.HybridInfoValid = HybridInfoHeader[2];
+ Ahci->HybridInfo.HybridPriority = HybridInfoHeader[7] - 1;
+ DEBUG ((EFI_D_INFO, "RapidStart Hybrid Priority is %x\n", Ahci->HybridInfo.HybridPriority));
+
+ X = 0;
+ Y = 0;
+ HybridInfoDescriptorNumber = *(UINT16 *)HybridInfoHeader;
+ DEBUG ((EFI_D_INFO, "HybridInfoDescriptorNumber is %x\n", HybridInfoDescriptorNumber));
+ for (Index = 0; Index < HybridInfoDescriptorNumber; Index++) {
+ HybridInfoDescriptor = HybridLogRangeEntries + 64;
+ HybridInfoDescriptor += (16 * Index);
+ DEBUG ((EFI_D_INFO, "%x - Hybrid Priority is %x\n", Index, HybridInfoDescriptor[0]));
+ DEBUG ((EFI_D_INFO, " - Consumed NVM Size Fraction is %x\n", HybridInfoDescriptor[1]));
+ DEBUG ((EFI_D_INFO, " - Consumed Mapping Resources Fraction is %x\n", HybridInfoDescriptor[2]));
+ DEBUG ((EFI_D_INFO, " - Consumed NVM Size for Dirty Data Fraction is %x\n", HybridInfoDescriptor[3]));
+ DEBUG ((EFI_D_INFO, " - Consumed Mapping Resources for Dirty Data Fraction is %x\n", HybridInfoDescriptor[4]));
+
+ X+= HybridInfoDescriptor[3];
+ Y+= HybridInfoDescriptor[4];
+ }
+
+ DEBUG ((EFI_D_INFO, "Total Consumed Capacity For Dirty Data Fraction is %x\n", X));
+
+ NvmSize = *(UINT64 *)(HybridInfoHeader + 16);
+ DEBUG ((EFI_D_INFO, "NVM Size is %lx\n", NvmSize));
+ X = MultU64x64 (X, NvmSize);
+ X = DivU64x32 (X, 0xFF);
+
+ Ahci->TotalRemainingCacheCapacityInSector = (UINT32)(NvmSize - X);
+ DEBUG ((EFI_D_INFO, "TotalRemainingCacheCapacityInSector = %x\n", Ahci->TotalRemainingCacheCapacityInSector));
+
+ DEBUG ((EFI_D_INFO, "Ahci Hybrid Hard Device Support Successfully\n"));
+
+ return EFI_SUCCESS;
+}
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartAhci.h b/ReferenceCode/RapidStart/Pei/RapidStartAhci.h
new file mode 100644
index 0000000..652cf96
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartAhci.h
@@ -0,0 +1,344 @@
+/** @file
+ Header file for function definitions
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+#ifndef RAPID_START_AHCI_H_
+#define RAPID_START_AHCI_H_
+
+#include <RapidStartAhciReg.h>
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Abar;
+ UINT32 PortBase;
+ UINT32 PortSize;
+ UINTN Port;
+ BOOLEAN PollCancellation;
+
+ // Internal fields
+ UINT16 *Identify;
+ enum {
+ AHCI_STATE_UNKNOWN,
+ AHCI_STATE_INIT,
+ AHCI_STATE_INUSE,
+ AHCI_STATE_MAX,
+ } State;
+ struct {
+ UINT8 HybridPriority : 4;
+ UINT8 Reserved : 3;
+ UINT8 HybridInfoValid : 1;
+ } HybridInfo;
+ UINT32 TotalRemainingCacheCapacityInSector;
+} AHCI_CONTEXT;
+
+typedef union {
+ UINT32 Data;
+ struct {
+ UINT32 ByteReserved1 : 8;
+ UINT32 ByteReserved2 : 8;
+ UINT32 HybridPriority : 4;
+ UINT32 Reserved : 1;
+ UINT32 HybridInfoValid : 1;
+ UINT32 Reserved1 : 2;
+ UINT32 ByteReserved4 : 8;
+ } r;
+} ATA_AUX;
+
+typedef struct {
+ UINT64 MemAddr;
+ UINT64 Lba;
+ UINT32 SectorCount;
+ UINT16 Feature;
+ UINT8 Command;
+ UINT8 Direction;
+ ATA_AUX Auxiliary;
+} ATA_COMMAND;
+
+#pragma pack()
+
+#define AhciSpinUp(Ahci) \
+ AhciSpinUpPort (Ahci, Ahci->Port)
+
+#define AhciPostCommand(Ahci, AtaCmd, CmdIdx) \
+ AhciPostCommandWithZeroFilter (Ahci, AtaCmd, CmdIdx, NULL, NULL)
+
+/**
+ Initialize SATA controller and enable decode
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - SATA controller has been initialized successfully
+**/
+EFI_STATUS
+AhciInit (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Returns SATA enabled port bitmap basing on PCS value.
+
+ @retval Enabled ports map.
+**/
+UINT32
+AhciGetEnabledPorts (
+ VOID
+ );
+
+/**
+ Returns SATA present port bitmap basing on PCS value.
+
+ @retval Present ports map.
+**/
+UINT32
+AhciGetPresentPorts (
+ VOID
+ );
+
+/**
+ Check whether device is password locked.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - Device not locked
+ @retval EFI_ACCESS_DENIED - Drive is in LOCKED state and need to execute UNLOCK command before accessing
+ @retval EFI_SECURITY_VIOLATION - Drive is already in SECURITY FREEZE state and will not accept UNLOCK command
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+**/
+EFI_STATUS
+AhciGetLockStatus (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Disable SATA controller after all AHCI commands have completed
+
+ @param[in] Ahci - SATA controller information structure
+**/
+VOID
+AhciDone (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Spin up Ahci port
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Port - SATA port number
+
+ @retval EFI_SUCCESS - AHCI Port has been spun up successfully
+**/
+EFI_STATUS
+AhciSpinUpPort (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINTN Port
+ );
+
+/**
+ Initialize AHCI port for reading/writing RapidStart Store
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_DEVICE_ERROR - AHCI port initialization failed
+ @retval EFI_SUCCESS - AHCI port initialized successfully and RapidStart Store is ready for reading/writing
+**/
+EFI_STATUS
+AhciPortInit (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Stops AHCI port.
+
+ @param[in] Ahci - SATA controller information structure
+**/
+VOID
+AhciPortDone (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Executes AHCI command.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in,out] AtaCmd - ATA command structure
+
+ @retval EFI_SUCCESS - Command successfull
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciExecCommand (
+ IN AHCI_CONTEXT *Ahci,
+ IN OUT ATA_COMMAND *AtaCmd
+ );
+
+/**
+ Enqueues ahci command and for read/write it is optionally with Zero filter.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in,out] AtaCmd - ATA command structure
+ @param[out] CmdMask - If given a bit corresponding to allocated command slot is set
+ @param[in] ZeroPageBitMap - A pointer for ZeroPageTable
+ @param[out] SmRamBufferLba - If given the drive LBA storing original SMRAM buffer content will be passed by it.
+
+ @retval EFI_SUCCESS - AHCI command successfully posted
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciPostCommandWithZeroFilter (
+ IN AHCI_CONTEXT *Ahci,
+ IN OUT ATA_COMMAND *AtaCmd,
+ OUT OPTIONAL UINT32 *CmdMask,
+ IN OPTIONAL UINT32 *ZeroPageBitMap,
+ OUT OPTIONAL UINT64 *SmRamBufferLba
+ );
+
+/**
+ Issues ATA command with no data transfer.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Command - Command to be issued
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciSimpleCommand (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT8 Command
+ );
+
+/**
+ Check whether there are available command slots.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval TRUE if there is an available slot, FALSE otherwise.
+**/
+BOOLEAN
+AhciHasFreeCmdSlot (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Waits untill given command(s) complete.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] CmdMask - Command(s) mask
+
+ @retval EFI_SUCCESS - Command complete
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+ @retval EFI_NOT_STARTED - The RapidStart Entry flow should be canceled and do S3 resume back to OS
+**/
+EFI_STATUS
+AhciWaitComplete (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT32 CmdMask
+ );
+
+/**
+ Waits for all AHCI commands completed.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - All AHCI commands have completed
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Error occurred on device side.
+ @retval EFI_NOT_STARTED - The RapidStart Entry flow should be canceled and do S3 resume back to OS
+**/
+EFI_STATUS
+AhciWaitAllComplete (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+/**
+ Sends Identify Device ATA command to port
+
+ @param[in] Ahci - SATA controller information structure
+ @param[out] Buffer - Buffer to store device information
+
+ @retval EFI_SUCCESS - function executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciIdentifyDevice (
+ IN AHCI_CONTEXT *Ahci,
+ OUT VOID *Buffer
+ );
+
+/**
+ Performs TRIM command on given LBA range
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Lba - First block to be trimmed
+ @param[in] Count - Number of blocks to trim
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @exception EFI_UNSUPPORTED - TRIM is not supported by the device
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciTrimRange (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINT64 Lba,
+ IN UINT32 Count
+ );
+
+/**
+ Unlocks ATA device.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Password - security credential
+
+ @retval EFI_SUCCESS - Command executed successfully
+ @retval EFI_SECURITY_VIOLATION - Device security lock freeze
+ @exception EFI_UNSUPPORTED - Security is not supported by the device
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciSecurityUnlock (
+ IN AHCI_CONTEXT *Ahci,
+ IN CHAR8 *Password
+ );
+
+/**
+ Hybrid Hard Disk Support.
+
+ @param[in] Ahci - SATA controller information structure
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @exception EFI_UNSUPPORTED - TRIM is not supported by the device
+ @retval EFI_DEVICE_ERROR - Command failed
+**/
+EFI_STATUS
+AhciHybridHardDiskSupport (
+ IN AHCI_CONTEXT *Ahci
+ );
+
+#endif
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartPei.c b/ReferenceCode/RapidStart/Pei/RapidStartPei.c
new file mode 100644
index 0000000..08d05e8
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.c
@@ -0,0 +1,2379 @@
+/** @file
+ This Peim driver will do RapidStart Entry or RapidStart Exit transition
+
+@copyright
+ Copyright (c) 1999 - 2013 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "RapidStartConfig.h"
+#include EFI_PPI_DEFINITION (RapidStart)
+#include EFI_PROTOCOL_DEFINITION (RapidStartGlobalNvsArea)
+#include EFI_PPI_DEFINITION (Heci)
+#include <MeChipset.h>
+
+#include <PchAccess.h>
+#include <SaAccess.h>
+#include <PchPlatformLib.h>
+
+#include "GfxDisplayLibPei.h"
+#include EFI_PPI_DEFINITION (PeiGfxPpi)
+#ifdef RAPID_START_ON_MEMORY_INSTALLED
+#include EFI_GUID_DEFINITION (AcpiVariable)
+#endif
+#include EFI_PPI_DEFINITION (EndOfPeiSignal)
+#include EFI_GUID_DEFINITION (RapidStartTransition)
+#include "RapidStartPeiLib.h"
+#include "RapidStartData.h"
+#include "RapidStartAhci.h"
+#include "RapidStartCommonLib.h"
+
+#endif
+#include EFI_PPI_DEPENDENCY (SaPlatformPolicy)
+
+
+#define PAM_COUNT 7
+
+#define ME_FID_TIMEOUT 10000
+
+#define MAX_MEMORY_RANGES (MAX_GFX_MEMORY_RANGES + 0x08)
+#define MAX_SMRAM_RANGES 2
+#define DPR_RANGES 1
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef MIN
+#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
+#endif
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a)))
+#define POOL_SIZE(a) (((((EFI_HOB_GENERIC_HEADER*)a - 1)->HobLength) - sizeof(EFI_HOB_GENERIC_HEADER)) / sizeof (*(a)))
+#define VARIABLE_SIZE(a) (ARRAY_SIZE(a) > 0) ? ARRAY_SIZE(a) : POOL_SIZE(a)
+
+#define END_RANGES ((UINT64) (INT64) (-1))
+#define RANGE_LENGTH(r) ((r)->End - (r)->Start)
+
+EFI_GUID gEfiAcpiVariableGuid = EFI_ACPI_VARIABLE_GUID;
+
+typedef struct {
+ UINT64 Start;
+ UINT64 End;
+} MEMORY_RANGE;
+
+#define RAPID_START_INSTANCE_SIGNATURE EFI_SIGNATURE_32 ('i', 'R', 'S', 'T')
+
+typedef struct _RAPID_START_INSTANCE {
+ RAPID_START_PPI Ppi;
+ EFI_PEI_PPI_DESCRIPTOR PpiDesc;
+ UINT32 Signature;
+ BOOLEAN Enabled;
+ RAPID_START_PERSISTENT_DATA Data;
+ RAPID_START_TRANSITION Transition;
+ RAPID_START_GLOBAL_NVS_AREA *RapidStartGlobalNvs;
+ AHCI_CONTEXT Ahci;
+ CHAR8 HddPassword[ATA_PASSWORD_LEN];
+ EFI_STATUS PwdStatus;
+ BOOLEAN FreezeLock;
+#ifndef RAPID_START_NO_SMRAM_INTEGRITY_CHECK
+ UINT8 SmRamHash[RAPID_START_SECURE_HASH_LENGTH];
+#endif
+ UINT64 NotUsedLba;
+ UINT32 IedSize;
+} RAPID_START_INSTANCE;
+
+#define RAPID_START_INSTANCE_FROM_THIS(a) CR (a, RAPID_START_INSTANCE, Ppi, RAPID_START_INSTANCE_SIGNATURE)
+
+EFI_STATUS
+RapidStartClearAndEnablePmeEvent (
+ IN BOOLEAN EnablePme
+ );
+
+STATIC
+EFI_STATUS
+RapidStartExitAtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+STATIC
+EFI_STATUS
+RapidStartRecoveryAtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+STATIC
+EFI_STATUS
+RapidStartS4AtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+STATIC
+EFI_STATUS
+RapidStartMemoryInstalled (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+STATIC
+EFI_STATUS
+InstallRapidStartPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+STATIC EFI_PEI_NOTIFY_DESCRIPTOR mRapidStartExitNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEndOfPeiSignalPpiGuid,
+ RapidStartExitAtEndOfPei
+};
+
+STATIC EFI_PEI_NOTIFY_DESCRIPTOR mRapidStartRecoveryNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEndOfPeiSignalPpiGuid,
+ RapidStartRecoveryAtEndOfPei
+};
+
+STATIC EFI_PEI_NOTIFY_DESCRIPTOR mRapidStartS4NotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEndOfPeiSignalPpiGuid,
+ RapidStartS4AtEndOfPei
+};
+
+STATIC EFI_PEI_NOTIFY_DESCRIPTOR mRapidStartTransitionPpiNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gRapidStartTransitionPpiGuid,
+ RapidStartMemoryInstalled
+};
+
+STATIC EFI_PEI_NOTIFY_DESCRIPTOR mInstallRapidStartPpiNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gPeiHeciPpiGuid,
+ InstallRapidStartPpi
+};
+
+STATIC
+EFI_STATUS
+RapidStartDoTransition (
+ IN RAPID_START_PPI *This
+ );
+
+#if !defined(RAPID_START_NO_SMRAM_INTEGRITY_CHECK) && defined(BUILD_WITH_GLUELIB)
+#undef SetMem
+/**
+ SetMem alternative in case GlueLib defines SetMem as a macro.
+ Required by CryptoLib.
+
+ @param[out] Buffer - Pointer to the memory buffer
+ @param[in] Length - The length for setting memory
+ @param[in] Value - The value that will be set to memory buffer
+**/
+VOID *
+SetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ return GlueSetMem (Buffer, Length, Value);
+}
+
+#undef CopyMem
+/**
+ Copy Length bytes from Source to Destination.
+
+ @param[out] DestinationBuffer - Target of copy
+ @param[in] SourceBuffer - Place to copy from
+ @param[in] Length - Number of bytes to copy
+
+ @retval Status code
+**/
+VOID *
+EFIAPI
+CopyMem (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ return GlueCopyMem (DestinationBuffer, SourceBuffer, Length);
+}
+#endif
+
+#ifndef EFI_DEBUG
+#define PrintRanges(r)
+#else
+/**
+ Show memory range information by debug macro
+
+ @param[in] ranges - Memory range information structure
+**/
+VOID
+PrintRanges (
+ IN MEMORY_RANGE *ranges
+ )
+{
+ while (ranges->Start != END_RANGES) {
+ DEBUG ((EFI_D_INFO, "%08lx - %08lx\n", ranges->Start, ranges->End));
+ ++ranges;
+ }
+}
+#endif
+
+/**
+ Sort memory ranges.
+
+ @param[in][out] MemoryRanges - Memory Ranges
+ @param[in] MemoryRangesSize - Number of entries in Memory Ranges
+
+ @retval Status code
+
+--*/
+EFI_STATUS
+SortRanges (
+ IN OUT MEMORY_RANGE *MemoryRanges,
+ IN UINTN MemoryRangesSize
+ )
+{
+ UINT32 Count, Index;
+ MEMORY_RANGE TempRange;
+ MEMORY_RANGE *Range;
+
+ Range = MemoryRanges;
+
+ if (MemoryRangesSize == 0) {
+ while (Range->Start != END_RANGES) {
+ MemoryRangesSize++;
+ Range++;
+ }
+ }
+
+ for (Count = 1; Count < MemoryRangesSize; Count++) {
+ for (Index = 0; Index < MemoryRangesSize - Count; Index++) {
+ if (MemoryRanges[Index].Start > MemoryRanges[Index + 1].Start) {
+ TempRange.Start = MemoryRanges[Index].Start;
+ TempRange.End = MemoryRanges[Index].End;
+ MemoryRanges[Index].Start = MemoryRanges[Index + 1].Start;
+ MemoryRanges[Index].End = MemoryRanges[Index + 1].End;
+ MemoryRanges[Index + 1].Start = TempRange.Start;
+ MemoryRanges[Index + 1].End = TempRange.End;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Subtracts set of memory ranges from other set of memory ranges.
+ Resulting set will contain ranges covering InputRanges with SubRanges excluded.
+
+ Both InputRanges and SubRanges must be provided in ascending order
+ by Start address. Output set is also sorted.
+
+ All sets end with a range which Start address is END_RANGES.
+
+ @param[out] OutputRanges - Output buffer
+ @param[in] OutputRangesSize - Number of entries in output buffer
+ @param[in] InputRanges - Input ranges to substract from
+ @param[in] SubRanges - Ranges to be excluded from InputRanges
+
+ @retval EFI_SUCCESS - Success
+ @retval EFI_BUFFER_TOO_SMALL - Not enough space in output buffer
+**/
+STATIC
+EFI_STATUS
+SubtractRanges (
+ OUT MEMORY_RANGE *OutputRanges,
+ IN UINTN OutputRangesSize,
+ IN MEMORY_RANGE *InputRanges,
+ IN MEMORY_RANGE *SubRanges
+ )
+{
+ MEMORY_RANGE *SubRange;
+ MEMORY_RANGE Current;
+ UINTN OutIndex;
+
+ ASSERT (OutputRanges != InputRanges);
+ ASSERT (OutputRanges != SubRanges);
+
+ DEBUG ((EFI_D_INFO, "Sub ranges Before Sorting:\n"));
+ PrintRanges (SubRanges);
+ SortRanges (SubRanges, 0);
+ DEBUG ((EFI_D_INFO, "Sub ranges After Sorting:\n"));
+ PrintRanges (SubRanges);
+
+ OutIndex = 0;
+ while (InputRanges->Start != END_RANGES) {
+ Current.Start = InputRanges->Start;
+ Current.End = InputRanges->End;
+ SubRange = SubRanges;
+ while (SubRange->Start != END_RANGES) {
+ if ((Current.Start < SubRange->End) && (Current.End > SubRange->Start)) {
+ if (Current.Start < SubRange->Start) {
+ if (OutIndex + 1 >= OutputRangesSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ OutputRanges[OutIndex].Start = Current.Start;
+ OutputRanges[OutIndex].End = MIN (Current.End, SubRange->Start);
+ ++OutIndex;
+ }
+
+ if (Current.End > SubRange->End) {
+ Current.Start = SubRange->End;
+ } else {
+ Current.Start = END_RANGES;
+ }
+ }
+
+ ++SubRange;
+ }
+
+ if (Current.Start != END_RANGES) {
+ if (OutIndex + 1 >= OutputRangesSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ OutputRanges[OutIndex].Start = Current.Start;
+ OutputRanges[OutIndex].End = Current.End;
+ ++OutIndex;
+ }
+
+ ++InputRanges;
+ }
+
+ ASSERT (OutIndex < OutputRangesSize);
+ OutputRanges[OutIndex].Start = END_RANGES;
+ return EFI_SUCCESS;
+}
+
+/**
+ Returns total length of ranges in the set Ranges.
+
+ @param[in] Ranges - Array of memory ranges.
+
+ @retval The size of memory range
+**/
+STATIC
+UINT64
+SumRanges (
+ IN MEMORY_RANGE *Ranges
+ )
+{
+ UINT64 Size;
+ Size = 0;
+ while (Ranges->Start != END_RANGES) {
+ Size += RANGE_LENGTH (Ranges);
+ ++Ranges;
+ }
+
+ return Size;
+}
+
+
+/**
+ This routing is executed to clear all pending wake events and then enable wake events.
+
+ @param[in] EnablePme - set to TRUE to enable PME event
+
+ @retval EFI_SUCCESS - Operation successfully performed
+**/
+EFI_STATUS
+RapidStartClearAndEnablePmeEvent (
+ IN BOOLEAN EnablePme
+ )
+{
+ RAPID_START_PPI *This;
+ EFI_STATUS Status;
+ RAPID_START_INSTANCE *Instance;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ RAPID_START_MEM_DATA *RapidStartMemData;
+ PCH_SERIES PchSeries;
+ UINT32 PmBase;
+
+ PchSeries = GetPchSeries();
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ Status = PeiServicesLocatePpi (&gRapidStartPpiGuid, 0, NULL, (VOID **) &This);
+ ASSERT_EFI_ERROR (Status);
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ RapidStartData = &Instance->Data;
+ RapidStartMemData = RAPID_START_MEM_DATA_PTR (RapidStartData);
+ DEBUG ((EFI_D_ERROR, "RapidStart: RapidStartMemData @ %X\n", RapidStartMemData));
+
+ ///
+ /// Clear all pending wake events
+ ///
+ RapidStartClearOemPmeEvent ();
+ if (PchSeries == PchLp) {
+ IoWrite32 (PmBase + R_PCH_ACPI_GPE0_STS_127_96, ~0u);
+ } else if (PchSeries == PchH) {
+ IoWrite32 (PmBase + R_PCH_ACPI_GPE0a_STS, ~0u);
+ IoWrite32 (PmBase + R_PCH_ACPI_GPE0b_STS, ~0u);
+ }
+ IoWrite16 (
+ PmBase + R_PCH_ACPI_PM1_STS,
+ B_PCH_ACPI_PM1_STS_WAK | B_PCH_ACPI_PM1_STS_RTC | B_PCH_ACPI_PM1_STS_PWRBTN
+ );
+
+ ///
+ /// Enable wake events
+ ///
+ if (EnablePme == TRUE) {
+ if (PchSeries == PchLp) {
+ IoOr32 (PmBase + R_PCH_ACPI_GPE0_EN_127_96, RapidStartMemData->GPE0);
+ } else if (PchSeries == PchH) {
+ IoOr32 (PmBase + R_PCH_ACPI_GPE0a_EN, RapidStartMemData->GPE0a);
+ IoOr32 (PmBase + R_PCH_ACPI_GPE0b_EN, RapidStartMemData->GPE0b);
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ RapidStart End of PEI handler.
+
+ @param[in] PeiServices - Pointer to PEI Services Table.
+ @param[in] NotifyDesc - Pointer to the descriptor for the Notification event that caused this function to execute.
+ @param[in] Ppi - Pointer to the PPI data associated with this function.
+
+ @retval EFI_SUCCESS - Ppi callback function executed successfully
+**/
+STATIC
+EFI_STATUS
+RapidStartS4AtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ UINT32 PmBase;
+ EFI_STATUS Status;
+ RAPID_START_PPI *This;
+ RAPID_START_INSTANCE *Instance;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+
+ DEBUG ((EFI_D_INFO, "RapidStartS4AtEndOfPei ()\n"));
+
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ Status = PeiServicesLocatePpi (&gRapidStartPpiGuid, 0, NULL, (VOID **) &This);
+ ASSERT_EFI_ERROR (Status);
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ RapidStartData = &Instance->Data;
+
+ RapidStartWANetDetect (PeiServices, RapidStartData->WlanMmioSpace);
+ RapidStartClearAndEnablePmeEvent (TRUE);
+
+ DEBUG ((EFI_D_ERROR, "RapidStart: Switching to S4\n"));
+ IoAndThenOr32 (
+ PmBase + R_PCH_ACPI_PM1_CNT,
+ (UINT32)~B_PCH_ACPI_PM1_CNT_SLP_TYP,
+ (UINT32) (V_PCH_ACPI_PM1_CNT_S4 | B_PCH_ACPI_PM1_CNT_SLP_EN)
+ );
+
+ EFI_DEADLOOP ();
+ return EFI_SUCCESS;
+}
+
+/**
+ RapidStart End of PEI handler.
+
+ @param[in] PeiServices - Pointer to PEI Services Table.
+ @param[in] NotifyDesc - Pointer to the descriptor for the Notification event that caused this function to execute.
+ @param[in] Ppi - Pointer to the PPI data associated with this function.
+
+ @retval EFI_SUCCESS - Ppi callback function executed successfully
+**/
+STATIC
+EFI_STATUS
+RapidStartRecoveryAtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ UINT32 PmBase;
+
+ DEBUG ((EFI_D_INFO, "RapidStartRecoveryAtEndOfPei ()\n"));
+
+ RapidStartClearAndEnablePmeEvent (TRUE);
+
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ DEBUG ((EFI_D_ERROR, "RapidStart: Switching state back to S3\n"));
+ IoAndThenOr32 (
+ PmBase + R_PCH_ACPI_PM1_CNT,
+ (UINT32)~B_PCH_ACPI_PM1_CNT_SLP_TYP,
+ (UINT32) (V_PCH_ACPI_PM1_CNT_S3 | B_PCH_ACPI_PM1_CNT_SLP_EN)
+ );
+
+ EFI_DEADLOOP ();
+ return EFI_SUCCESS;
+}
+
+/**
+ Executes necessary RapidStart late initialization after Boot Script done.
+
+ @param[in] PeiServices - Pointer to PEI Services Table.
+ @param[in] NotifyDesc - Pointer to the descriptor for the Notification event that caused this function to execute.
+ @param[in] Ppi - Pointer to the PPI data associated with this function.
+
+ @retval EFI_SUCCESS - RapidStart initialization successful
+**/
+STATIC
+EFI_STATUS
+RapidStartExitAtEndOfPei (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ DEBUG ((EFI_D_INFO, "RapidStartExitAtEndOfPei ()\n"));
+ return RapidStartEnableAcpi (PeiServices);
+}
+
+/**
+ PEI_PERMANENT_MEMORY_INSTALLED_PPI handler.
+ RapidStart transition is triggered here in case RapidStart is postoponed untill memory available in PEI.
+
+ @param[in] PeiServices - Pointer to PEI Services Table.
+ @param[in] NotifyDesc - Pointer to the descriptor for the Notification event that caused this function to execute.
+ @param[in] Ppi - Pointer to the PPI data associated with this function.
+
+ @retval EFI_SUCCESS
+**/
+STATIC
+EFI_STATUS
+RapidStartMemoryInstalled (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ RAPID_START_PPI *RapidStartPpi;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "RapidStartMemoryInstalled ()\n"));
+ Status = (*PeiServices)->LocatePpi (PeiServices, &gRapidStartPpiGuid, 0, NULL, (VOID **) &RapidStartPpi);
+ ASSERT_EFI_ERROR (Status);
+
+ RapidStartDoTransition (RapidStartPpi);
+
+ return EFI_SUCCESS;
+}
+
+#ifdef EFI_DEBUG
+/**
+ Dump MCH relevant registers
+**/
+STATIC
+VOID
+DumpMcRegisters (
+ VOID
+ )
+{
+ UINTN MchBase;
+ MchBase = MmPciAddress (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, 0);
+
+ DEBUG ((EFI_D_INFO, "TOM : %lx\n", MmioRead64 (MchBase + R_SA_TOM)));
+ DEBUG ((EFI_D_INFO, "TSEGMB : %x\n", MmioRead32 (MchBase + R_SA_TSEGMB)));
+ DEBUG ((EFI_D_INFO, "TOLUD : %x\n", MmioRead32 (MchBase + R_SA_TOLUD)));
+ DEBUG ((EFI_D_INFO, "TOUUD : %lx\n", MmioRead64 (MchBase + R_SA_TOUUD)));
+ DEBUG ((EFI_D_INFO, "BDSM : %x\n", MmioRead32 (MchBase + R_SA_BDSM)));
+ DEBUG ((EFI_D_INFO, "BGSM : %x\n", MmioRead32 (MchBase + R_SA_BGSM)));
+ DEBUG ((EFI_D_INFO, "DPR : %x\n", MmioRead32 (MchBase + R_SA_DPR)));
+ DEBUG ((EFI_D_INFO, "MESEG_B : %lx\n", MmioRead64 (MchBase + R_SA_MESEG_BASE)));
+ DEBUG ((EFI_D_INFO, "MESEG_M : %lx\n", MmioRead64 (MchBase + R_SA_MESEG_MASK)));
+ DEBUG ((EFI_D_INFO, "REMAPBASE: %lx\n", MmioRead64 (MchBase + R_SA_REMAPBASE)));
+ DEBUG ((EFI_D_INFO, "REMAPLIM : %lx\n", MmioRead64 (MchBase + R_SA_REMAPLIMIT)));
+ DEBUG ((EFI_D_INFO, "SMRAMC : %02x\n", MmioRead8 (MchBase + R_SA_SMRAMC)));
+ DEBUG ((EFI_D_INFO, "GGC : %04x\n", MmioRead16 (MchBase + R_SA_GGC)));
+}
+
+/**
+ Show Hexadecimal number by debug macro
+
+ @param[in] Ptr - Pointer to buffer of number that will be showed
+ @param[in] Length - The length of the number buffer
+**/
+VOID
+PrintHex (
+ IN UINT8 *Ptr,
+ IN UINTN Length
+ )
+{
+ while (Length--) {
+ DEBUG ((EFI_D_INFO, "%02x", *Ptr++));
+ }
+
+ DEBUG ((EFI_D_INFO, "\n"));
+}
+#endif
+
+/**
+ Retrieves SMRAM areas ffrom SMRAM HOB, and places the ranges found in
+ SmRamRanges array.
+
+ @param[out] SmRamRanges - Output buffer
+ @param[in] SmRamRangesSize - Number of entries in output buffer
+
+ @retval EFI_SUCCESS
+ @retval EFI_NOT_FOUND
+ @retval EFI_BUFFER_TOO_SMALL
+**/
+STATIC
+EFI_STATUS
+GetSmRamRanges (
+ OUT MEMORY_RANGE *SmRamRanges,
+ IN UINTN SmRamRangesSize,
+ IN UINT32 IedSize
+ )
+{
+ EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *SmmDescBlock;
+ UINTN Index;
+ VOID *Hob;
+
+ Hob = GetFirstGuidHob (&gEfiSmmPeiSmramMemoryReserve);
+ if (Hob == NULL) {
+ DEBUG ((EFI_D_ERROR, "SMRAM HOB not found!\n"));
+ ASSERT (0);
+ return EFI_NOT_FOUND;
+ }
+
+ SmmDescBlock = (VOID *) ((UINT8 *) Hob + sizeof (EFI_HOB_GUID_TYPE));
+
+ DEBUG ((EFI_D_INFO, "Found %d SMM ranges\n", SmmDescBlock->NumberOfSmmReservedRegions));
+
+ ASSERT (SmRamRangesSize > SmmDescBlock->NumberOfSmmReservedRegions);
+ if (SmRamRangesSize <= SmmDescBlock->NumberOfSmmReservedRegions) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ for (Index = 0; Index < SmmDescBlock->NumberOfSmmReservedRegions; ++Index) {
+ SmRamRanges[Index].Start = SmmDescBlock->Descriptor[Index].PhysicalStart;
+ if (SmRamRanges[Index].Start > 0x100000) {
+ //
+ // This is TSEG SMRAM range.
+ // IED region is also part of SMRAM but not reported in SMRAM Hob so here include IED for Rapid Start saving/restoring.
+ //
+ DEBUG ((EFI_D_INFO, "Ied size %X\n", IedSize));
+ SmRamRanges[Index].End = SmRamRanges[Index].Start + SmmDescBlock->Descriptor[Index].PhysicalSize + IedSize;
+ }
+ }
+
+ SmRamRanges[Index].Start = END_RANGES;
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieves DPR areas from SA register, and places the ranges found in
+ DprRanges array.
+
+ @param[out] DprRanges - Output buffer
+
+ @retval EFI_SUCCESS
+ @retval EFI_NOT_FOUND
+**/
+STATIC
+EFI_STATUS
+GetDprRanges (
+ OUT MEMORY_RANGE *DprRanges
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN MchBase;
+ UINT32 DprData;
+ UINT32 DprSize;
+
+ Status = EFI_NOT_FOUND;
+ Index = 0;
+
+ MchBase = MmPciAddress (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, 0);
+ DprData = MmioRead32 (MchBase + R_SA_DPR);
+ DprSize = (DprData & V_DPR_DPRSIZE_MASK) << (N_SA_DPR_TOPOFDPR_OFFSET - N_DPR_DPRSIZE_OFFSET);
+
+ ///
+ /// Check whether DPR protection and DPR is enabled or not.
+ ///
+ if ((DprData & (B_SA_DPR_PRS_MASK + B_SA_DPR_EPM_MASK)) == (B_SA_DPR_PRS_MASK + B_SA_DPR_EPM_MASK)) {
+ DprRanges[Index].Start = (DprData & B_SA_DPR_TOPOFDPR_MASK) - DprSize;
+ DprRanges[Index].End = DprData & B_SA_DPR_TOPOFDPR_MASK;
+ DEBUG ((EFI_D_INFO, "DPR Start = %08lx, End = %08lx\n", DprRanges[Index].Start, DprRanges[Index].End));
+
+ Index ++;
+ Status = EFI_SUCCESS;
+ }
+
+ DprRanges[Index].Start = END_RANGES;
+ return Status;
+}
+
+/**
+ Constructs memory ranges to be saved/restored by RapidStart.
+ Reserved areas are excluded.
+
+ @param[out] OutMemoryRanges - Output buffer
+ @param[in] OutMemoryRangesSize - Number of entries in output buffer
+ @param[in] RapidStartData - A data buffer stored RapidStart internal non-volatile information.
+
+ @retval EFI_SUCCESS
+**/
+STATIC
+EFI_STATUS
+BuildMemoryRanges (
+ OUT MEMORY_RANGE *OutMemoryRanges,
+ IN UINTN OutMemoryRangesSize,
+ IN RAPID_START_PERSISTENT_DATA *RapidStartData
+ )
+{
+ MEMORY_RANGE MainRanges[4];
+ MEMORY_RANGE ResvRanges[3];
+ EFI_STATUS Status;
+ UINTN Index;
+
+ ///
+ /// Always exclude Legacy SMRAM ranges (A0000~BFFFF) since this range can not perform DMA.
+ /// If Legacy SMRAM is used it will be handled separately.
+ ///
+ Index = 0;
+ MainRanges[Index].Start = 0;
+ MainRanges[Index].End = LEGACY_SMRAM_BASE;
+ ++Index;
+ MainRanges[Index].Start = LEGACY_SMRAM_BASE + LEGACY_SMRAM_SIZE;
+ MainRanges[Index].End = RapidStartData->Tolm;
+ ++Index;
+ if (RapidStartData->Tohm > MEM_EQU_4GB) {
+ MainRanges[Index].Start = MEM_EQU_4GB;
+ MainRanges[Index].End = RapidStartData->Tohm;
+ ++Index;
+ }
+
+ ASSERT (Index < VARIABLE_SIZE (MainRanges));
+ MainRanges[Index].Start = END_RANGES;
+
+ Index = 0;
+ ResvRanges[Index].Start = RapidStartData->RapidStartMem;
+ ResvRanges[Index].End = RapidStartData->RapidStartMem + RapidStartData->RapidStartMemSize;
+ ++Index;
+#ifdef RAPID_START_ON_MEMORY_INSTALLED
+ ResvRanges[Index].Start = RapidStartData->AcpiReservedMemoryBase;
+ ResvRanges[Index].End = RapidStartData->AcpiReservedMemoryBase + RapidStartData->AcpiReservedMemorySize;
+ ++Index;
+#endif
+ ASSERT (Index < VARIABLE_SIZE (ResvRanges));
+ ResvRanges[Index].Start = END_RANGES;
+
+ ///
+ /// Exclude reserved ranges
+ ///
+ Status = SubtractRanges (
+ OutMemoryRanges,
+ OutMemoryRangesSize,
+ MainRanges,
+ ResvRanges
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+#ifdef RAPID_START_NO_SMRAM_INTEGRITY_CHECK
+#define HASHING_CONTEXT typedef enum { EMPTY }
+#define HashingInit(c, r) EFI_SUCCESS
+#define HashingProcessChunk(c) TRUE
+#define HashingCompleteAndVerify(c, t) EFI_SUCCESS
+#else
+
+typedef struct {
+ MEMORY_RANGE *Range;
+ UINT8 *Ptr;
+ VOID *HashState;
+} HASHING_CONTEXT;
+
+#define HASHING_CHUNK (4 * EFI_PAGE_SIZE)
+
+/**
+ Initializes secure hash algorithm.
+
+ @param[in] Context - Hashing context
+ @param[in] Ranges - Memory ranges to be included in resulting hash
+
+ @retval EFI_SUCCESS Hashing process completed
+ @retval ERROR Return the error code if PeiServicesAllocatePool () failed
+**/
+STATIC
+EFI_STATUS
+HashingInit (
+ HASHING_CONTEXT *Context,
+ MEMORY_RANGE *Ranges
+ )
+{
+ UINTN HashStatetSize;
+ EFI_STATUS Status;
+
+ Context->Range = Ranges;
+ Context->Ptr = (VOID *) (UINTN) Ranges->Start;
+
+ HashStatetSize = IfsSecureHashGetContextSize ();
+ ASSERT (HashStatetSize != 0);
+
+ Status = PeiServicesAllocatePool (HashStatetSize, &Context->HashState);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ RapidStartSecureHashInit (Context->HashState);
+ return EFI_SUCCESS;
+}
+
+/**
+ Processes next chunk of memory.
+
+ @param[in] Context - Hashing context
+
+ @retval TRUE if hashing complete, FALSE othervise.
+**/
+STATIC
+BOOLEAN
+HashingProcessChunk (
+ HASHING_CONTEXT *Context
+ )
+{
+ UINTN Size;
+ if (Context->Range->Start == END_RANGES) {
+ return TRUE;
+ }
+
+ DEBUG ((EFI_D_INFO, "#"));
+ Size = (UINTN) Context->Range->End - (UINTN) Context->Ptr;
+ if (Size > HASHING_CHUNK) {
+ Size = HASHING_CHUNK;
+ }
+
+ RapidStartSecureHashUpdate (Context->HashState, (VOID *) Context->Ptr, Size);
+ Context->Ptr += Size;
+ if ((UINTN) Context->Ptr == (UINTN) Context->Range->End) {
+ ++Context->Range;
+ Context->Ptr = (VOID *) (UINTN) Context->Range->Start;
+ }
+
+ return FALSE;
+}
+
+/**
+ Finishes hashing and saves/verifies resulting value depending on RapidStart transition.
+
+ @param[in] Context - Hashing context
+ @param[in] Instance - RapidStart instance
+
+ @retval EFI_SECURITY_VIOLATION - SMRAM content has changed.
+ @retval EFI_SUCCESS - SMRAM content no change.
+**/
+STATIC
+EFI_STATUS
+HashingCompleteAndVerify (
+ HASHING_CONTEXT *Context,
+ RAPID_START_INSTANCE *Instance
+ )
+{
+ UINT8 Hash[RAPID_START_SECURE_HASH_LENGTH];
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "HashingCompleteAndVerify...\n"));
+
+ Status = EFI_SUCCESS;
+ while (!HashingProcessChunk (Context)) {
+ }
+
+ RapidStartSecureHashFinal (Context->HashState, Hash);
+
+#ifdef EFI_DEBUG
+ PrintHex (Hash, RAPID_START_SECURE_HASH_LENGTH);
+#endif
+
+ if (Instance->Transition == RapidStartExit) {
+ if (CompareMem (Hash, Instance->SmRamHash, RAPID_START_SECURE_HASH_LENGTH) != 0) {
+ DEBUG ((EFI_D_ERROR, "Error: SMRAM content has changed!\n"));
+ Status = EFI_SECURITY_VIOLATION;
+ }
+
+ ZeroMem (Instance->SmRamHash, RAPID_START_SECURE_HASH_LENGTH);
+ } else {
+ Status = RapidStartSaveSecureHash (Hash);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ ZeroMem (Hash, RAPID_START_SECURE_HASH_LENGTH);
+ ZeroMem (Context->HashState, IfsSecureHashGetContextSize ());
+
+ return Status;
+}
+
+#endif
+
+/**
+ Check ME status and wait for ME init done
+
+ @retval EFI_SUCCESS - ME Init done
+ @retval EFI_TIMEOUT - ME is not ready after timeout occurred
+ @retval EFI_DEVICE_ERROR - Error reported by ME F/W
+**/
+STATIC
+EFI_STATUS
+WaitMeInitDone (
+ VOID
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+ PEI_HECI_PPI *HeciPpi;
+ EFI_STATUS Status;
+ UINT32 MeStatus;
+ UINT32 MeMode;
+ UINTN Timeout;
+
+ DEBUG ((EFI_D_INFO, "WaitMeInitDone()\n"));
+
+ PeiServices = GetPeiServicesTablePointer ();
+
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiHeciPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &HeciPpi
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = HeciPpi->GetMeMode (PeiServices, &MeMode);
+ ASSERT_EFI_ERROR (Status);
+ ///
+ /// If ME is in ME_DEBUG mode, return success.
+ ///
+ if (MeMode == ME_MODE_DEBUG) {
+ return EFI_SUCCESS;
+ }
+
+ if (MeMode != ME_MODE_NORMAL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Timeout = 0;
+ while (Timeout < ME_FID_TIMEOUT) {
+ Status = HeciPpi->GetMeStatus (PeiServices, &MeStatus);
+ ASSERT_EFI_ERROR (Status);
+
+ if (ME_STATUS_IS_ME_FW_INIT_COMPLETE (MeStatus)) {
+ return EFI_SUCCESS;;
+ }
+
+ PchPmTimerStall (1000);
+ Timeout++;
+ }
+
+ DEBUG ((EFI_D_ERROR, "ME init timeout!\n"));
+ return EFI_TIMEOUT;
+}
+
+/**
+ Calls Func for each port in PortMap.
+
+ @param[in] Ahci - SATA controller information structure
+ @param[in] Func - Pointer to function to be called with Ahci and port number passed as arguments
+ @param[in] PortMap - Bitmap of ports for wich Func is to be called
+**/
+STATIC
+VOID
+ForEachAhciPort (
+ IN AHCI_CONTEXT *Ahci,
+ IN EFI_STATUS (*Func) (AHCI_CONTEXT*, UINTN),
+ IN UINT32 PortMap
+ )
+{
+ UINTN Port;
+
+ for (Port = 0; Port <= 31; ++Port) {
+ if (PortMap & (1u << Port)) {
+ Func (Ahci, Port);
+ }
+ }
+ return;
+}
+
+/**
+ Issues STANDBY_IMMEDIATE command to given SATA port.
+ Port is initialized first and disabled afterwards.
+
+ @param Ahci - SATA controller information structure
+ @param Port - Port number to issue command to
+
+ @retval EFI_SUCCESS - fucntion executed successfully
+ @retval EFI_TIMEOUT - Timeout occured
+ @retval EFI_DEVICE_ERROR - AHCI port initialization failed or Command failed
+**/
+STATIC
+EFI_STATUS
+StandbyAhciPort (
+ IN AHCI_CONTEXT *Ahci,
+ IN UINTN Port
+ )
+{
+ AHCI_CONTEXT AhciTmp;
+ EFI_STATUS Status;
+ DEBUG ((EFI_D_INFO, "StandbyAhciPort(%d)\n", Port));
+
+ AhciTmp = *Ahci;
+ AhciTmp.Port = Port;
+ Status = AhciPortInit (&AhciTmp);
+ if (Status == EFI_SUCCESS) {
+ Status = AhciSimpleCommand (&AhciTmp, ATA_CMD_STANDBY_IMMEDIATE);
+ }
+ AhciPortDone (&AhciTmp);
+ return Status;
+}
+
+/**
+ Initialize Ahci port for RapidStart accessing SSD in early stage.
+
+ @param[in] Instance - Instance contains required data and function for RapidStart
+**/
+STATIC
+VOID
+RapidStartInitAhci (
+ IN RAPID_START_INSTANCE *Instance
+ )
+{
+ AHCI_CONTEXT *Ahci;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+
+ DEBUG ((EFI_D_INFO, "InitAhci\n"));
+
+ Ahci = &Instance->Ahci;
+ RapidStartData = &Instance->Data;
+
+ Ahci->Abar = (UINT32) RapidStartData->MmioSpace;
+ Ahci->PortBase = (UINT32) RapidStartData->RapidStartMem;
+ Ahci->PortSize = RapidStartData->RapidStartMemSize -
+ sizeof (RAPID_START_MEM_DATA) -
+ RapidStartData->ZeroBitmapSize -
+ RapidStartData->Crc32RecordSize;
+ Ahci->Port = RapidStartData->StoreSataPort;
+
+ DEBUG ((EFI_D_INFO, "Ahci.Abar = %08x\n", Ahci->Abar));
+ DEBUG ((EFI_D_INFO, "Ahci.Port = %d\n", Ahci->Port));
+ DEBUG ((EFI_D_INFO, "Ahci.PortBase = %08x\n", Ahci->PortBase));
+ DEBUG ((EFI_D_INFO, "Ahci.PortSize = %08x\n", Ahci->PortSize));
+
+ ///
+ /// Restore SATA ports configuration
+ ///
+ MmioWrite8 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_SATA,
+ PCI_FUNCTION_NUMBER_PCH_SATA,
+ R_PCH_SATA_PCS),
+ RapidStartData->SataPortConfiguration
+ );
+
+ AhciInit (Ahci);
+ AhciSpinUp (Ahci);
+}
+
+#define RETURN_ON_ERROR(expr) \
+ do { \
+ EFI_STATUS _status; \
+ _status = (expr); \
+ if (EFI_ERROR (_status)) { \
+ return _status; \
+ } \
+ } while (0)
+
+/**
+ Transfer SMRAM ranges to/from RapidStart partition.
+
+ Legacy SMRAM 0xA0000-0xC0000 is handled indirectly.
+
+ @param[in] Ahci - AHCI context
+ @param[in,out] AtaCmd - ATA command structure
+ @param[in] Transition - RapidStart transition
+ @param[in] SmRamRanges - Array of SMRAM ranges
+
+ @retval EFI_STATUS - the error code returned by AhciPostCommand () if failed.
+ @retval EFI_SUCCESS - Hasing SMRAM process completed.
+**/
+STATIC
+EFI_STATUS
+RapidStartHandleSmRam (
+ IN AHCI_CONTEXT *Ahci,
+ IN OUT ATA_COMMAND *AtaCmd,
+ IN RAPID_START_TRANSITION Transition,
+ IN MEMORY_RANGE *SmRamRanges
+ )
+{
+ MEMORY_RANGE *Range;
+ UINTN CmdMask;
+
+ DEBUG ((EFI_D_INFO, "SMRAM handling...\n"));
+ PrintRanges (SmRamRanges);
+
+ if (Transition == RapidStartEntry) {
+ ///
+ /// Ensure original LEGACY_SMRAM_BUFFER data has been stored into RapidStart Store before we modifying it.
+ ///
+ RETURN_ON_ERROR (AhciWaitAllComplete (Ahci));
+ CopyMem ((VOID *) LEGACY_SMRAM_BUFFER, (VOID *) LEGACY_SMRAM_BASE, (UINTN) LEGACY_SMRAM_SIZE);
+ }
+
+ CmdMask = 0;
+ Range = SmRamRanges;
+ while (Range->Start != END_RANGES) {
+ AtaCmd->SectorCount = MEM_TO_SECT (RANGE_LENGTH (Range));
+ if (Range->Start == LEGACY_SMRAM_BASE) {
+ ASSERT (Range->End == LEGACY_SMRAM_BASE + LEGACY_SMRAM_SIZE);
+ AtaCmd->MemAddr = LEGACY_SMRAM_BUFFER;
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, AtaCmd, &CmdMask));
+ } else {
+ AtaCmd->MemAddr = Range->Start;
+ CmdMask = ~CmdMask;
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, AtaCmd, &CmdMask));
+ CmdMask = ~CmdMask;
+ }
+
+ ++Range;
+ }
+
+ AhciWaitComplete (Ahci, CmdMask);
+ if (Transition == RapidStartExit) {
+ CopyMem ((VOID *) LEGACY_SMRAM_BASE, (VOID *) LEGACY_SMRAM_BUFFER, (UINTN) LEGACY_SMRAM_SIZE);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Performs AHCI commands required to save or restore memory content.
+
+ @param[in] Instance - RapidStart instance
+ @param[in] MainRanges - Ranges of memory to be transferred
+ @param[in] SmRamRanges - SMRAM ranges, to by handled by RapidStartHandleSmRam
+
+ @retval EFI_SUCCESS - RapidStart transition succeeded
+ @retval EFI_TIMEOUT - AHCI timeout occured
+ @retval EFI_DEVICE_ERROR - AHCI device not ready
+ @retval EFI_NOT_STARTED - Transition cancellation happened, abort the transition.
+ @retval EFI_NO_MEDIA - No RapidStart Store available or RapidStart store has been changed. Abort RapidStart transition.
+ @retval EFI_BAD_BUFFER_SIZE - Memory configuration changed. Abort RapidStart transition.
+**/
+STATIC
+EFI_STATUS
+RapidStartMemoryDiskTransfer (
+ IN RAPID_START_INSTANCE *Instance,
+ IN MEMORY_RANGE *MainRanges,
+ IN MEMORY_RANGE *SmRamRanges
+ )
+{
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ AHCI_CONTEXT *Ahci;
+ RAPID_START_TRANSITION Transition;
+ ATA_COMMAND AtaCmd;
+ MEMORY_RANGE *MemRanges;
+ MEMORY_RANGE *Range;
+ EFI_STATUS Status;
+ UINT32 *ZeroPageBitMap;
+ UINT32 SectorsLeft;
+ HASHING_CONTEXT Hashing;
+ BOOLEAN HashingDone;
+ UINT64 DataCount;
+ UINT32 *SmramBuffer;
+ UINT32 ZeroBitmapForSmramBuffer;
+ UINT64 LbaForData;
+ UINT64 SmRamBufferLba;
+ EFI_STATUS GfxDisplayStatus;
+ PEI_GFX_PPI *PeiGfxPpi;
+ GFX_RESTORE_MEM_TABLE *GfxRestoreMemTable;
+ GFX_RESTORE_MEM_TABLE *FbRestoreMemTable;
+ UINT32 Index, GfxIndex, MemIndex;
+ MEMORY_RANGE *GfxResvRanges;
+ MEMORY_RANGE *TempMemRanges;
+ UINT64 PageAlignedDssAddr;
+ UINT64 PageAlignedDssSize;
+
+ MemRanges = (MEMORY_RANGE *) AllocatePool (sizeof(MEMORY_RANGE) * (MAX_MEMORY_RANGES + 1));
+ if (MemRanges == NULL) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate memory for MemRanges! \n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ GfxResvRanges = (MEMORY_RANGE *) AllocatePool (sizeof(MEMORY_RANGE) * (MAX_GFX_MEMORY_RANGES + 1));
+ if (GfxResvRanges == NULL) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate memory for GfxResvRanges! \n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ TempMemRanges = (MEMORY_RANGE *) AllocatePool (sizeof(MEMORY_RANGE) * (MAX_MEMORY_RANGES + 1));
+ if (GfxResvRanges == NULL) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate memory for TempMemRanges! \n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ RapidStartData = &Instance->Data;
+ Ahci = &Instance->Ahci;
+ Transition = Instance->Transition;
+
+ ///
+ /// Exclude SMRAM ranges as they are handled separetely
+ ///
+ Status = SubtractRanges (
+ MemRanges,
+ VARIABLE_SIZE (MemRanges),
+ MainRanges,
+ SmRamRanges
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ AtaCmd.Auxiliary.Data = 0;
+ if (Transition == RapidStartEntry) {
+ if (RapidStartData->HybridHardDisk == 1) {
+ Status = AhciHybridHardDiskSupport (Ahci);
+ if (Status == EFI_SUCCESS) {
+ if (Ahci->TotalRemainingCacheCapacityInSector < RapidStartData->StoreSectors) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+ AtaCmd.Auxiliary.r.HybridPriority = Ahci->HybridInfo.HybridPriority;
+ AtaCmd.Auxiliary.r.HybridInfoValid = 1;
+ } else if (Status != EFI_UNSUPPORTED) {
+ return Status;
+ }
+ }
+
+ Ahci->PollCancellation = TRUE;
+ AtaCmd.Command = ATA_CMD_WRITE_DMA_EXT;
+ AtaCmd.Direction = AHCI_DIR_HOST2DEV;
+ } else {
+ Ahci->PollCancellation = FALSE;
+ AtaCmd.Command = ATA_CMD_READ_DMA_EXT;
+ AtaCmd.Direction = AHCI_DIR_DEV2HOST;
+ if (RapidStartData->HybridHardDisk == 1) {
+ if (((Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_SUPPORT] & B_ATA_ID_DEV_HYBRID_FEATURE_SUPPORT) &
+ (Ahci->Identify[ATA_ID_DEV_HYBRID_FEATURE_ENABLE] & B_ATA_ID_DEV_HYBRID_FEATURE_ENABLE))
+ ) {
+ AtaCmd.Auxiliary.r.HybridPriority = 0;
+ AtaCmd.Auxiliary.r.HybridInfoValid = 1;
+ }
+ }
+ }
+
+ AtaCmd.Feature = 0;
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ ///
+ /// Save CRC32 for memory below 4GB
+ ///
+ if (Transition == RapidStartEntry) {
+ SaveOrCompareCrc32 (FALSE, 0, RapidStartData->Tolm, RapidStartData);
+ }
+#endif
+ ///
+ /// Head sector store the Zero Page Bitmap, so save/restore it first
+ ///
+ ZeroPageBitMap = RAPID_START_ZERO_PAGE_BITMAP_PTR (RapidStartData);
+ ///
+ /// For Entry, store RapidStart Store UID in the head of Zero Page Bitmap.
+ ///
+ if (Transition == RapidStartEntry) {
+ *(UINT64 *) (ZeroPageBitMap) = RapidStartData->RapidStartStoreUid;
+ }
+
+ AtaCmd.MemAddr = (UINTN) ZeroPageBitMap;
+ AtaCmd.Lba = RapidStartData->StoreLbaAddr;
+ AtaCmd.SectorCount = MEM_TO_SECT (RapidStartData->ZeroBitmapSize + RapidStartData->Crc32RecordSize);
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, &AtaCmd, NULL));
+
+ LbaForData = RapidStartData->StoreLbaAddr + MEM_TO_SECT (RapidStartData->ZeroBitmapSize + RapidStartData->Crc32RecordSize);
+ GfxDisplayStatus = EFI_UNSUPPORTED;
+ if (RapidStartData->DssAddress != (UINT64)NULL) {
+ PageAlignedDssAddr = RapidStartData->DssAddress & ~EFI_PAGE_MASK;
+ PageAlignedDssSize = (EFI_SIZE_TO_PAGES(PageAlignedDssAddr) < EFI_SIZE_TO_PAGES(RapidStartData->DssAddress) ) ? EFI_PAGE_SIZE : 0;
+ PageAlignedDssSize += RapidStartData->DssSize;
+ AtaCmd.MemAddr = (UINTN) PageAlignedDssAddr;
+ AtaCmd.Lba = LbaForData;
+ AtaCmd.SectorCount = MEM_TO_SECT (PageAlignedDssSize);
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, &AtaCmd, NULL));
+ LbaForData += MEM_TO_SECT (PageAlignedDssSize);
+
+ GfxIndex = 0;
+ GfxResvRanges[GfxIndex].Start = PageAlignedDssAddr;
+ GfxResvRanges[GfxIndex].End = PageAlignedDssAddr + PageAlignedDssSize;
+ ++GfxIndex;
+
+ //
+ // save/restore GTT, GMM... ets Gfx memory related Range
+ //
+ GfxDisplayStatus = PeiServicesLocatePpi (&gPeiGfxPpiGuid, 0, NULL, &PeiGfxPpi);
+ ASSERT_EFI_ERROR (GfxDisplayStatus);
+ if (!EFI_ERROR (GfxDisplayStatus)) {
+ if (Transition == RapidStartExit) {
+ RETURN_ON_ERROR (AhciWaitAllComplete (Ahci));
+ }
+ GfxDisplayStatus = PeiGfxPpi->GetRestoreMemTable (GetPeiServicesTablePointer (), &GfxRestoreMemTable);
+ DEBUG ((EFI_D_ERROR, "Gfx GetRestoreMemTable Status = %r, NumberofEntry = %x\n", GfxDisplayStatus, GfxRestoreMemTable->NumOfEntry));
+ if (!EFI_ERROR (GfxDisplayStatus) && (GfxRestoreMemTable->NumOfEntry <= GFX_RESTORE_RANGE)) {
+ for (Index = 0; Index < GfxRestoreMemTable->NumOfEntry; Index++) {
+ DEBUG ((EFI_D_ERROR, "Gfx related memory Ranges [%x] - BaseAddress is %lx, Size is %lx\n", Index, GfxRestoreMemTable->MemRangeEntry[Index].BaseAddress, GfxRestoreMemTable->MemRangeEntry[Index].Size));
+
+ GfxResvRanges[GfxIndex].Start = GfxRestoreMemTable->MemRangeEntry[Index].BaseAddress;
+ GfxResvRanges[GfxIndex].End = GfxRestoreMemTable->MemRangeEntry[Index].BaseAddress + GfxRestoreMemTable->MemRangeEntry[Index].Size;
+
+ MemIndex = 0;
+ while (MemRanges[MemIndex].Start != END_RANGES) {
+ if (GfxResvRanges[GfxIndex].Start >= MemRanges[MemIndex].Start && GfxResvRanges[GfxIndex].End <= MemRanges[MemIndex].End) {
+ DEBUG ((EFI_D_ERROR, "Gfx related memory Ranges [%x] - BaseAddress is %lx, Size is %lx has been save(restore).\n", Index, GfxRestoreMemTable->MemRangeEntry[Index].BaseAddress, GfxRestoreMemTable->MemRangeEntry[Index].Size));
+
+ AtaCmd.MemAddr = (UINTN) GfxRestoreMemTable->MemRangeEntry[Index].BaseAddress;
+ AtaCmd.Lba = LbaForData;
+ AtaCmd.SectorCount = MEM_TO_SECT (GfxRestoreMemTable->MemRangeEntry[Index].Size);
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, &AtaCmd, NULL));
+ LbaForData += MEM_TO_SECT (GfxRestoreMemTable->MemRangeEntry[Index].Size);
+ ++GfxIndex;
+ break;
+ }
+ ++MemIndex;
+ }
+ }
+ }
+ //
+ // save/restore Gfx Frame Buffer Ranges
+ //
+ if (RapidStartData->DisplayType == 1 && !EFI_ERROR (GfxDisplayStatus)) {
+ if (Transition == RapidStartExit) {
+ RETURN_ON_ERROR (AhciWaitAllComplete (Ahci));
+ }
+ GfxDisplayStatus = PeiGfxPpi->GetRestoreFbRange (GetPeiServicesTablePointer (), &FbRestoreMemTable);
+ DEBUG ((EFI_D_ERROR, "Gfx GetRestoreFbRange Status = %r, NumberofEntry = %x\n", GfxDisplayStatus, FbRestoreMemTable->NumOfEntry));
+ if (!EFI_ERROR (GfxDisplayStatus) && (FbRestoreMemTable->NumOfEntry <= FB_RESTORE_RANGE)) {
+ for (Index = 0; Index < FbRestoreMemTable->NumOfEntry; Index++) {
+ DEBUG ((EFI_D_ERROR, "Gfx FB memory Ranges [%x] - BaseAddress is %lx, Size is %lx\n", Index, FbRestoreMemTable->MemRangeEntry[Index].BaseAddress, FbRestoreMemTable->MemRangeEntry[Index].Size));
+
+ GfxResvRanges[GfxIndex].Start = FbRestoreMemTable->MemRangeEntry[Index].BaseAddress;
+ GfxResvRanges[GfxIndex].End = FbRestoreMemTable->MemRangeEntry[Index].BaseAddress + FbRestoreMemTable->MemRangeEntry[Index].Size;
+
+ MemIndex = 0;
+ while (MemRanges[MemIndex].Start != END_RANGES) {
+ if (GfxResvRanges[GfxIndex].Start >= MemRanges[MemIndex].Start && GfxResvRanges[GfxIndex].End <= MemRanges[MemIndex].End) {
+ DEBUG ((EFI_D_ERROR, "Gfx FB memory Ranges [%x] - BaseAddress is %lx, Size is %lx has been save(restore).\n", Index, FbRestoreMemTable->MemRangeEntry[Index].BaseAddress, FbRestoreMemTable->MemRangeEntry[Index].Size));
+
+ AtaCmd.MemAddr = (UINTN) FbRestoreMemTable->MemRangeEntry[Index].BaseAddress;
+ AtaCmd.Lba = LbaForData;
+ AtaCmd.SectorCount = MEM_TO_SECT (FbRestoreMemTable->MemRangeEntry[Index].Size);
+ RETURN_ON_ERROR (AhciPostCommand (Ahci, &AtaCmd, NULL));
+ LbaForData += MEM_TO_SECT (FbRestoreMemTable->MemRangeEntry[Index].Size);
+ ++GfxIndex;
+ break;
+ }
+ ++MemIndex;
+ }
+ }
+ }
+ }
+ ASSERT (GfxIndex < VARIABLE_SIZE (GfxResvRanges));
+ GfxResvRanges[GfxIndex].Start = END_RANGES;
+
+ //
+ // Copy MemRanges to TempMemRanges
+ //
+ GfxDisplayStatus = SubtractRanges (
+ TempMemRanges,
+ VARIABLE_SIZE (TempMemRanges),
+ MainRanges,
+ SmRamRanges
+ );
+ ASSERT_EFI_ERROR (GfxDisplayStatus);
+
+ //
+ // Exclude Gfx related memory ranges as they are handled separetely
+ //
+ GfxDisplayStatus = SubtractRanges (
+ MemRanges,
+ VARIABLE_SIZE (MemRanges),
+ TempMemRanges,
+ GfxResvRanges
+ );
+ ASSERT_EFI_ERROR (GfxDisplayStatus);
+
+ }
+ }
+
+ if (RapidStartData->DssAddress != (UINT64)NULL) {
+ if (!EFI_ERROR (GfxDisplayStatus)) {
+ switch(Transition) {
+ case RapidStartEntry:
+ DEBUG ((EFI_D_INFO, "Calling GfxDisplay in RapidStart entry flow...\n"));
+// GfxDisplayStatus = RapidStartGfxDisplayScreen();
+ break;
+ case RapidStartExit:
+ DEBUG ((EFI_D_INFO, "Calling GfxDisplay in RapidStart exit flow...\n"));
+ if (RapidStartUnattendedWake() == FALSE) {
+ GfxDisplayStatus = RapidStartGfxDisplayScreen();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (Transition == RapidStartExit) {
+ AtaCmd.Lba = LbaForData;
+ if ((RapidStartHandleSmRam (Ahci, &AtaCmd, Transition, SmRamRanges) == EFI_DEVICE_ERROR) ||
+ (AhciWaitAllComplete (Ahci) == EFI_DEVICE_ERROR)
+ ) {
+ DEBUG (
+ (
+ EFI_D_ERROR,
+ "\nEFI_DEVICE_ERROR in first DMA command, probably RapidStart Store changed. Aborted RapidStart resume.\n"
+ )
+ );
+ RapidStartSetFlag (RAPID_START_FLAG_STORE_CHANGE);
+ return EFI_NO_MEDIA;
+ }
+
+ if (*(UINT64 *) (ZeroPageBitMap) != RapidStartData->RapidStartStoreUid) {
+ DEBUG ((EFI_D_ERROR, "\nRapidStart Store UID Mismatched! Aborted RapidStart resume.\n"));
+ RapidStartSetFlag (RAPID_START_FLAG_STORE_CHANGE);
+ return EFI_NO_MEDIA;
+ }
+ }
+
+ ZeroPageBitMap += 2;
+ DEBUG ((EFI_D_INFO, "Transfer ranges:\n"));
+ PrintRanges (MemRanges);
+
+ RETURN_ON_ERROR (HashingInit (&Hashing, SmRamRanges));
+
+ DataCount = 0;
+
+ HashingDone = FALSE;
+ AtaCmd.Lba = LbaForData + MEM_TO_SECT (SumRanges (SmRamRanges));
+ Range = MemRanges;
+ SmRamBufferLba = AtaCmd.Lba;
+ ///
+ /// Log the last Lba which not in used.
+ ///
+ Instance->NotUsedLba = AtaCmd.Lba;
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2510);
+ while (Range->Start != END_RANGES) {
+ AtaCmd.MemAddr = Range->Start;
+ SectorsLeft = MEM_TO_SECT (RANGE_LENGTH (Range));
+ while (SectorsLeft > 0) {
+ if (HashingDone || AhciHasFreeCmdSlot (Ahci)) {
+ if (SectorsLeft > AHCI_MAX_SECTORS) {
+ AtaCmd.SectorCount = AHCI_MAX_SECTORS;
+ } else {
+ AtaCmd.SectorCount = SectorsLeft;
+ }
+
+ SectorsLeft -= AtaCmd.SectorCount;
+ RETURN_ON_ERROR (AhciPostCommandWithZeroFilter (Ahci, &AtaCmd, NULL, ZeroPageBitMap, &SmRamBufferLba));
+ DataCount += AtaCmd.SectorCount << SECTOR_SHIFT;
+ } else {
+ if (Ahci->PollCancellation && RapidStartShouldCancelEntry ()) {
+ return EFI_NOT_STARTED;
+ }
+
+ HashingDone = HashingProcessChunk (&Hashing);
+ }
+ ///
+ /// Log the last Lba which not in used.
+ ///
+ Instance->NotUsedLba = AtaCmd.Lba;
+ }
+
+ ++Range;
+ }
+
+ RETURN_ON_ERROR (HashingCompleteAndVerify (&Hashing, Instance));
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2511);
+
+ if (Transition == RapidStartEntry) {
+ Ahci->PollCancellation = FALSE;
+ AtaCmd.Lba = LbaForData;
+ RETURN_ON_ERROR (RapidStartHandleSmRam (Ahci, &AtaCmd, Transition, SmRamRanges));
+ ///
+ /// Restore LEGACY_SMRAM_BUFFER
+ ///
+ AtaCmd.Command = ATA_CMD_READ_DMA_EXT;
+ AtaCmd.Direction = AHCI_DIR_DEV2HOST;
+ AtaCmd.MemAddr = LEGACY_SMRAM_BUFFER;
+ AtaCmd.SectorCount = MEM_TO_SECT (LEGACY_SMRAM_SIZE);
+ AtaCmd.Lba = SmRamBufferLba;
+ RETURN_ON_ERROR (AhciPostCommandWithZeroFilter (Ahci, &AtaCmd, NULL, ZeroPageBitMap, NULL));
+ }
+ ///
+ /// If LEGACY_SMRAM_BUFFER contained zero pages, they have to be zero-ed
+ ///
+ ZeroBitmapForSmramBuffer = *(ZeroPageBitMap + (LEGACY_SMRAM_BUFFER / EFI_PAGE_SIZE / 8 / 4));
+ SmramBuffer = (UINT32 *) LEGACY_SMRAM_BUFFER;
+ if (ZeroBitmapForSmramBuffer != 0) {
+ while (SmramBuffer < (UINT32 *) (LEGACY_SMRAM_BUFFER + LEGACY_SMRAM_SIZE)) {
+ if (ZeroBitmapForSmramBuffer & 1) {
+ ZeroMem (SmramBuffer, EFI_PAGE_SIZE);
+ }
+
+ ZeroBitmapForSmramBuffer >>= 1;
+ SmramBuffer += (EFI_PAGE_SIZE / 4);
+ }
+ }
+
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2520);
+ Status = AhciWaitAllComplete (Ahci);
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2521);
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ ///
+ /// Verify CRC32 for memory below 4GB
+ ///
+ if (Transition == RapidStartExit) {
+ SaveOrCompareCrc32 (TRUE, 0, RapidStartData->Tolm, RapidStartData);
+ }
+#endif
+
+ return Status;
+}
+
+/**
+ Save/Restore memory content to/from RapidStart Store
+
+ @param[in] Instance - RapidStart instance
+
+ @retval EFI_SUCCESS - RapidStart transition succeeded
+ @retval EFI_BAD_BUFFER_SIZE - Memory configuration changed. Abort RapidStart transition.
+ @retval EFI_BUFFER_TOO_SMALL - RapidStart Store size is too small to store memory content
+ @retval EFI_TIMEOUT - AHCI timeout occured
+ @retval EFI_DEVICE_ERROR - AHCI device not ready
+**/
+STATIC
+EFI_STATUS
+RapidStartTransitionInternal (
+ IN RAPID_START_INSTANCE *Instance
+ )
+{
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ AHCI_CONTEXT *Ahci;
+ UINTN MchBase;
+ UINT8 OldSmramControl;
+ UINT32 OldTseg;
+ UINT8 OldPam[PAM_COUNT];
+ MEMORY_RANGE *MemRanges;
+ MEMORY_RANGE SmRamRanges[MAX_SMRAM_RANGES + 1];
+ UINTN Index;
+ EFI_STATUS Status;
+ UINT32 OldDpr;
+
+ MemRanges = (MEMORY_RANGE *) AllocatePool (sizeof(MEMORY_RANGE) * (MAX_MEMORY_RANGES + 1));
+ if (MemRanges == NULL) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate memory for MemRanges! \n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ RapidStartData = &Instance->Data;
+ Ahci = &Instance->Ahci;
+
+#ifdef EFI_DEBUG
+ DumpMcRegisters ();
+#endif
+ DEBUG ((EFI_D_INFO, "Mem : %x\n", (UINT32) RapidStartData->RapidStartMem));
+ DEBUG ((EFI_D_INFO, "Io : %x\n", (UINT32) RapidStartData->MmioSpace));
+ DEBUG (
+ (EFI_D_INFO,
+ "Store: port=%d start=%lx size=%x\n",
+ RapidStartData->StoreSataPort,
+ RapidStartData->StoreLbaAddr,
+ RapidStartData->StoreSectors)
+ );
+
+ MchBase = MmPciAddress (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, 0);
+ if (RapidStartData->Tolm != (MmioRead32 (MchBase + R_SA_BDSM) & B_SA_BDSM_BDSM_MASK)) {
+ DEBUG ((EFI_D_ERROR, "Memory Tolm changed\n"));
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ if (RapidStartData->Tohm != (MmioRead64 (MchBase + R_SA_TOUUD) & B_SA_TOUUD_TOUUD_MASK)) {
+ DEBUG ((EFI_D_ERROR, "Memory Tohm changed\n"));
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ DEBUG ((EFI_D_INFO, "Total Memory: %lx\n", RapidStartData->TotalMem));
+
+ Status = GetSmRamRanges (SmRamRanges, VARIABLE_SIZE (SmRamRanges), Instance->IedSize);
+ ASSERT_EFI_ERROR (Status);
+ DEBUG ((EFI_D_INFO, "SMRAM ranges:\n"));
+ PrintRanges (SmRamRanges);
+
+ Status = BuildMemoryRanges (
+ MemRanges,
+ VARIABLE_SIZE (MemRanges),
+ RapidStartData
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((EFI_D_INFO, "Memory ranges:\n"));
+ PrintRanges (MemRanges);
+
+ ///
+ /// Save and open SMRAM
+ ///
+ OldSmramControl = MmioRead8 (MchBase + R_SA_SMRAMC);
+ MmioWrite8 (MchBase + R_SA_SMRAMC, B_SA_SMRAMC_D_OPEN_MASK | B_SA_SMRAMC_G_SMRAME_MASK);
+
+ ///
+ /// Open PAM regions
+ ///
+ for (Index = 0; Index < PAM_COUNT; ++Index) {
+ OldPam[Index] = MmioRead8 (MchBase + R_SA_PAM0 + Index);
+ MmioWrite8 (MchBase + R_SA_PAM0 + Index, B_SA_PAM1_HIENABLE_MASK | B_SA_PAM1_LOENABLE_MASK);
+ }
+ ///
+ /// Disable TSEG and DPR
+ ///
+ OldTseg = MmioRead32 (MchBase + R_SA_TSEGMB);
+ MmioWrite32 (MchBase + R_SA_TSEGMB, RapidStartData->Tolm);
+ OldDpr = MmioRead32 (MchBase + R_SA_DPR);
+ MmioAnd32 (MchBase + R_SA_DPR, (UINT32) ~B_SA_DPR_EPM_MASK);
+
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2500);
+ Status = AhciPortInit (Ahci);
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2501);
+
+ //
+ // Unlock device if password locked
+ //
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2530);
+ if (Status == EFI_SUCCESS) {
+ Status = AhciGetLockStatus (Ahci);
+ if (Status == EFI_ACCESS_DENIED) {
+ if (Instance->Transition == RapidStartEntry) {
+ Instance->PwdStatus = RapidStartGetDriveUnlockPassword (
+ GetPeiServicesTablePointer (),
+ Instance->Transition,
+ Instance->Data.StoreSataPort,
+ (UINT8 *) Instance->HddPassword,
+ &Instance->FreezeLock
+ );
+ }
+
+ if (Instance->PwdStatus == EFI_SUCCESS) {
+ Status = AhciSecurityUnlock (Ahci, Instance->HddPassword);
+ if (Instance->FreezeLock) {
+ AhciSimpleCommand (Ahci, ATA_CMD_SECURITY_FREEZE_LOCK);
+ }
+ } else {
+ DEBUG ((EFI_D_ERROR, "RapidStart: No drive password provided!"));
+ }
+ }
+ }
+ ZeroMem (Instance->HddPassword, ATA_PASSWORD_LEN);
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2531);
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // DPR will be disable temporary, so we won't exculde this region.
+ // To save/restore DPR region as normal memory does.
+ //
+
+ Instance->NotUsedLba = RapidStartData->StoreLbaAddr;
+
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2540);
+ Status = RapidStartMemoryDiskTransfer (Instance, MemRanges, SmRamRanges);
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2541);
+
+ if ((Instance->Transition == RapidStartEntry) && (Status == EFI_SUCCESS)) {
+ AhciSimpleCommand (Ahci, ATA_CMD_FLUSH_CACHE);
+ AhciSimpleCommand (Ahci, ATA_CMD_STANDBY_IMMEDIATE);
+ AhciPortDone (Ahci);
+ ForEachAhciPort (Ahci, StandbyAhciPort, AhciGetPresentPorts () & ~(1u << Ahci->Port));
+ } else {
+ ///
+ /// 1. In RapidStart Entry, if user has canceled RapidStart Entry flow, TRIM RapidStart Store.
+ /// 2. In RapidStart Resume, only TRIM when Resume successfully, SMRAM content changed.
+ ///
+#ifdef RAPID_START_TRIM_ON_RESUME
+ if (((Instance->Transition == RapidStartEntry) && (Status == EFI_NOT_STARTED)) ||
+ ((Instance->Transition == RapidStartExit) && ((Status == EFI_SUCCESS) || (Status == EFI_SECURITY_VIOLATION)))
+ ) {
+ DEBUG ((EFI_D_INFO, "\nNot used LBA in RapidStart store = %lX\n", Instance->NotUsedLba));
+ ASSERT (Instance->NotUsedLba > RapidStartData->StoreLbaAddr);
+ Ahci->PollCancellation = FALSE;
+
+ PERF_START_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2550);
+ AhciTrimRange (
+ Ahci,
+ RapidStartData->StoreLbaAddr,
+ (UINT32) (Instance->NotUsedLba - RapidStartData->StoreLbaAddr)
+ );
+ PERF_END_EX (NULL, L"EventRec", NULL, AsmReadTsc (), 0x2551);
+ }
+#endif
+ }
+ AhciPortDone (Ahci);
+ }
+
+ AhciDone (Ahci);
+
+ //
+ // Restore TSEG
+ //
+ MmioWrite32 (MchBase + R_SA_TSEGMB, OldTseg);
+ MmioWrite32 (MchBase + R_SA_DPR, OldDpr);
+
+ //
+ // Restore PAM regions
+ //
+ for (Index = 0; Index < PAM_COUNT; ++Index) {
+ MmioWrite8 (MchBase + R_SA_PAM0 + Index, OldPam[Index]);
+ }
+ //
+ // Restore SMRAMC
+ //
+ MmioWrite8 (MchBase + R_SA_SMRAMC, OldSmramControl);
+
+ return Status;
+}
+
+/**
+ Restores Memory pointers required by MemoryInit to install S3 reserved area on S3 resume.
+
+ @param[in] This - RapidStart PPI
+**/
+STATIC
+VOID
+RapidStartRestoreS3Pointers (
+ IN RAPID_START_PPI *This
+ )
+{
+ RAPID_START_INSTANCE *Instance;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ UINT64 AcpiVariableSet64;
+ ACPI_VARIABLE_SET *AcpiVariableSet;
+ EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;
+ UINTN VarSize;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "RapidStartRestoreS3Pointers\n"));
+
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ RapidStartData = &Instance->Data;
+
+ Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariablePpiGuid, 0, NULL, (VOID **) &ReadOnlyVariable);
+ ASSERT_EFI_ERROR (Status);
+
+ VarSize = sizeof (AcpiVariableSet64);
+ Status = ReadOnlyVariable->PeiGetVariable (
+ GetPeiServicesTablePointer (),
+ ACPI_GLOBAL_VARIABLE,
+ &gEfiAcpiVariableGuid,
+ NULL,
+ &VarSize,
+ &AcpiVariableSet64
+ );
+
+ AcpiVariableSet = (ACPI_VARIABLE_SET *) (UINTN) AcpiVariableSet64;
+
+ ASSERT (!EFI_ERROR (Status) && AcpiVariableSet != NULL);
+ if (EFI_ERROR (Status) || AcpiVariableSet == NULL) {
+ return;
+ }
+
+#ifdef RAPID_START_USE_OLD_ACPI_VARIABLE_SET
+ AcpiVariableSet->SystemMemoryLength = RapidStartData->SystemMemoryLengthBelow4GB;
+#else
+ AcpiVariableSet->SystemMemoryLengthBelow4GB = RapidStartData->SystemMemoryLengthBelow4GB;
+ AcpiVariableSet->SystemMemoryLengthAbove4GB = RapidStartData->SystemMemoryLengthAbove4GB;
+#endif
+ AcpiVariableSet->AcpiReservedMemoryBase = RapidStartData->AcpiReservedMemoryBase;
+ AcpiVariableSet->AcpiReservedMemorySize = RapidStartData->AcpiReservedMemorySize;
+
+ DEBUG ((EFI_D_INFO, "SystemMemoryLengthBelow4GB %lx\n", RapidStartData->SystemMemoryLengthBelow4GB));
+ DEBUG ((EFI_D_INFO, "SystemMemoryLengthAbove4GB %lx\n", RapidStartData->SystemMemoryLengthAbove4GB));
+ DEBUG ((EFI_D_INFO, "AcpiReservedMemoryBase %lx\n", RapidStartData->AcpiReservedMemoryBase));
+ DEBUG ((EFI_D_INFO, "AcpiReservedMemorySize %x\n", RapidStartData->AcpiReservedMemorySize));
+
+}
+
+/**
+ Check if RapidStart support is enabled.
+
+ @param[in] This - Pointer to RapidStart PPI
+
+ @retval TRUE if RapidStart support is enabled FALSE otherwise
+**/
+BOOLEAN
+RapidStartIsEnabled (
+ IN RAPID_START_PPI *This
+ )
+{
+ RAPID_START_INSTANCE *Instance;
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ return Instance->Enabled;
+}
+
+/**
+ Detremines RapidStart transition.
+
+ @param[in] This - Pointer to RapidStart PPI
+
+ @retval RapidStart_TRANSITION - The RapidStart transition being performed
+**/
+RAPID_START_TRANSITION
+RapidStartGetMode (
+ IN RAPID_START_PPI *This
+ )
+{
+ RAPID_START_INSTANCE *Instance;
+ DEBUG ((EFI_D_INFO, "RapidStartGetMode()\n"));
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ ASSERT (Instance->Transition != RapidStartTransitionMax);
+ return Instance->Transition;
+}
+
+/**
+ Performs actual RapidStart transition.
+
+ @param[in] This - RapidStart PPI
+
+ @retval EFI_ABORTED - RapidStart Entry or Resume failed
+ @retval EFI_SUCCESS - RapidStart Entry/Resume successfully
+**/
+STATIC
+EFI_STATUS
+RapidStartDoTransition (
+ IN RAPID_START_PPI *This
+ )
+{
+ RAPID_START_INSTANCE *Instance;
+ RAPID_START_PERSISTENT_DATA *RapidStartData;
+ RAPID_START_MEM_DATA *RapidStartMemData;
+ EFI_PEI_SERVICES **PeiServices;
+ EFI_STATUS Status;
+ EFI_STATUS MeStatus;
+ UINT32 PmBase;
+
+ ///
+ /// 1857 = Intel Rapid Start Technology
+ ///
+ IoWrite16 (0x80, 0x1857);
+
+ DEBUG ((EFI_D_INFO, "RapidStartDoTransition()\n"));
+
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ Instance = RAPID_START_INSTANCE_FROM_THIS (This);
+ RapidStartData = &Instance->Data;
+
+ RapidStartMemData = RAPID_START_MEM_DATA_PTR (RapidStartData);
+
+ Status = RapidStartBeforeTransition (
+ GetPeiServicesTablePointer (),
+ Instance->Transition,
+ Instance->Data.StoreSataPort
+ );
+ if (EFI_ERROR (Status)) {
+ Instance->Transition = RapidStartNone;
+ }
+
+ switch (Instance->Transition) {
+
+ case RapidStartEntry:
+ DEBUG ((EFI_D_ERROR, "RapidStart ENTRY\n"));
+
+ ///
+ /// Clear all GPE events before SIM enabling
+ ///
+ RapidStartClearAndEnablePmeEvent (FALSE);
+
+ RapidStartMemData->EntryCanceled = 0;
+
+ Status = RapidStartTransitionInternal (Instance);
+
+ MeStatus = EFI_SUCCESS;
+ MeStatus = WaitMeInitDone ();
+ if (RapidStartMemData->OsWakeTimeEnabled && (Status != EFI_NOT_STARTED)) {
+ DEBUG (
+ (EFI_D_INFO,
+ "Setting RTC alarm to OS provided value %02d-%02d:%02d:%02d\n",
+ RapidStartMemData->OsWakeTime.Date,
+ RapidStartMemData->OsWakeTime.Hour,
+ RapidStartMemData->OsWakeTime.Minute,
+ RapidStartMemData->OsWakeTime.Second)
+ );
+
+ RtcSetAlarm (&RapidStartMemData->OsWakeTime);
+
+ //
+ // set RTC_EN bit in PM1_EN to wake up from the alarm
+ //
+ IoWrite16 (
+ PmBase + R_PCH_ACPI_PM1_EN,
+ (IoRead16 (PmBase + R_PCH_ACPI_PM1_EN) | B_PCH_ACPI_PM1_EN_RTC)
+ );
+ }
+ if (EFI_ERROR (Status) || EFI_ERROR (MeStatus)) {
+ if (Status == EFI_NOT_STARTED) {
+ ///
+ /// RapidStart Entry flow has been canceled, do S3 resume.
+ ///
+ DEBUG ((EFI_D_ERROR, "User canceled RapidStart!\n"));
+ RapidStartMemData->EntryCanceled = 1;
+ } else {
+ DEBUG ((EFI_D_ERROR, "RapidStart entry failed!\n"));
+ Instance->RapidStartGlobalNvs->EventsEnabled = 0;
+ Instance->RapidStartGlobalNvs->EventsAvailable = 0;
+ }
+
+ Status = PeiServicesNotifyPpi (&mRapidStartRecoveryNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ RapidStartAfterTransition (PeiServices, RapidStartEntry, Status, RapidStartData->StoreSataPort);
+ break;
+ }
+
+ RapidStartSetFlag (RAPID_START_FLAG_ENTRY_DONE);
+
+ RapidStartAfterTransition (PeiServices, RapidStartEntry, Status, RapidStartData->StoreSataPort);
+
+ Status = PeiServicesNotifyPpi (&mRapidStartS4NotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ break;
+
+ case RapidStartExit:
+ DEBUG ((EFI_D_ERROR, "RapidStart EXIT\n"));
+
+ Status = PeiServicesNotifyPpi (&mRapidStartExitNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = RapidStartTransitionInternal (Instance);
+
+ MeStatus = EFI_SUCCESS;
+
+ if (EFI_ERROR (Status) || EFI_ERROR (MeStatus)) {
+ DEBUG ((EFI_D_ERROR, "RapidStart exit failed!\n"));
+ if (EFI_ERROR (Status)) {
+ RapidStartAfterTransition (PeiServices, RapidStartExit, Status, RapidStartData->StoreSataPort);
+ }
+
+ if (EFI_ERROR (MeStatus)) {
+ RapidStartAfterTransition (PeiServices, RapidStartExit, MeStatus, RapidStartData->StoreSataPort);
+ }
+
+ PeiServicesResetSystem ();
+ EFI_DEADLOOP ();
+ }
+ ///
+ /// Set DISB
+ ///
+ MmioOr16 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_GEN_PMCON_2),
+ B_PCH_LPC_GEN_PMCON_DRAM_INIT
+ );
+
+ RapidStartAfterTransition (PeiServices, RapidStartExit, EFI_SUCCESS, RapidStartData->StoreSataPort);
+ break;
+
+ case RapidStartNone:
+ ///
+ /// Cancelled
+ ///
+ Status = EFI_ABORTED;
+ break;
+
+ default:
+ ASSERT (0);
+ }
+
+ IoWrite16 (0x80, 0);
+
+ return Status;
+}
+
+/**
+ Executes or schedules RapidStart transition if appropriate.
+
+ @param[in] This - Pointer to RapidStart PPI
+ @param[out] BootMode - Boot mode that may be overridden
+
+ @retval EFI_SUCCESS - RapidStart transition performed/scheduled successfully
+ @retval EFI_ABORTED - RapidStart transition aborted
+**/
+STATIC
+EFI_STATUS
+RapidStartTransitionEntryPoint (
+ IN RAPID_START_PPI *This,
+ OUT EFI_BOOT_MODE *BootMode
+ )
+{
+ EFI_STATUS Status;
+ RAPID_START_TRANSITION Transition;
+
+ DEBUG ((EFI_D_INFO, "RapidStartTransitionEntryPoint\n"));
+
+ Transition = RapidStartGetMode (This);
+ Status = EFI_SUCCESS;
+
+ if (Transition != RapidStartNone) {
+#ifdef RAPID_START_ON_MEMORY_INSTALLED
+ RapidStartRestoreS3Pointers (This);
+ Status = PeiServicesNotifyPpi (&mRapidStartTransitionPpiNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+#else
+ Status = RapidStartDoTransition (This);
+#endif
+ if (Transition == RapidStartExit && BootMode != NULL) {
+ *BootMode = BOOT_ON_S3_RESUME;
+ ///
+ /// Update Boot Mode
+ ///
+ Status = PeiServicesSetBootMode (BOOT_ON_S3_RESUME);
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Checks power button override status.
+
+ @retval TRUE if power button override has taken place, FALSE otherwise.
+**/
+STATIC
+BOOLEAN
+IsPowerButtonOverride (
+ VOID
+ )
+{
+ UINT32 PmBase;
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ return (IoRead16 (PmBase + R_PCH_ACPI_PM1_STS) & B_PCH_ACPI_PM1_STS_PRBTNOR) != 0;
+}
+
+/**
+ Retrieves RapidStart non-volatile flag and data,
+ initializes RapidStart instance,
+ handles RapidStart entry conditions and prerequisites.
+
+ @param[in,out] Instance - RapidStart instance
+**/
+STATIC
+VOID
+RapidStartInitInstance (
+ IN OUT RAPID_START_INSTANCE *Instance
+ )
+{
+ EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;
+ UINTN Size;
+ EFI_STATUS Status;
+ BOOLEAN RapidStartFlag;
+ UINT8 EventsEnabled;
+ UINT32 PmBase;
+ EFI_BOOT_MODE BootMode;
+ SA_PLATFORM_POLICY_PPI *SaPlatformPolicyPpi;
+
+ Instance->Signature = RAPID_START_INSTANCE_SIGNATURE;
+ Instance->Transition = RapidStartNone;
+ Instance->Enabled = FALSE;
+ Instance->FreezeLock = TRUE;
+ Instance->PwdStatus = EFI_NOT_FOUND;
+
+ Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariablePpiGuid, 0, NULL, (VOID **) &ReadOnlyVariable);
+ ASSERT_EFI_ERROR (Status);
+
+ Size = sizeof (RAPID_START_PERSISTENT_DATA);
+ Status = ReadOnlyVariable->PeiGetVariable (
+ GetPeiServicesTablePointer (),
+ gRapidStartPersistentDataName,
+ &gRapidStartPersistentDataGuid,
+ NULL,
+ &Size,
+ &Instance->Data
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_INFO, "RapidStart disabled (No RapidStart variable found)\n"));
+ return ;
+ }
+
+ Instance->Enabled = TRUE;
+ Instance->RapidStartGlobalNvs = (RAPID_START_GLOBAL_NVS_AREA *) Instance->Data.RapidStartGlobalNvsPtr;
+ DEBUG ((EFI_D_INFO, "RapidStartGlobalNVS: %x\n", Instance->RapidStartGlobalNvs));
+
+ Status = PeiServicesGetBootMode (&BootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get IED size through the SaPlatformPolicy PPI
+ //
+ SaPlatformPolicyPpi = NULL;
+ Status = PeiServicesLocatePpi (
+ &gSaPlatformPolicyPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &SaPlatformPolicyPpi
+ );
+ ASSERT_EFI_ERROR (Status);
+ if ((SaPlatformPolicyPpi != NULL) && (SaPlatformPolicyPpi->Revision >= SA_PLATFORM_POLICY_PPI_REVISION_9)) {
+ Instance->IedSize = SaPlatformPolicyPpi->PlatformData->IedSize;
+ } else {
+ Instance->IedSize = 0x400000;
+ }
+
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ DEBUG ((EFI_D_INFO, "S3 resume\n"));
+
+ PmBase = MmioRead32 (
+ MmPciAddress (
+ 0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR;
+
+ Status = RapidStartGetConfig (&EventsEnabled);
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Check RTC alarm wake event
+ ///
+ if (IoRead16 (PmBase + R_PCH_ACPI_PM1_STS) & B_PCH_ACPI_PM1_STS_RTC) {
+ ///
+ /// Clear RTC Alarm Flag
+ ///
+ RtcRead (R_PCH_RTC_REGC);
+ if (EventsEnabled & RAPID_START_ACPI_RTC_WAKE) {
+ DEBUG ((EFI_D_INFO, "RapidStart on RTC wake\n"));
+ Instance->Transition = RapidStartEntry;
+ } else {
+ DEBUG ((EFI_D_INFO, "Boot from RapidStart cancellation or this is waking by OS timer\n"));
+ }
+ }
+ ///
+ /// Check for critical battery wake event
+ ///
+ else if ((EventsEnabled & RAPID_START_ACPI_BATT_WAKE) && RapidStartCheckCriticalBatteryWakeupEvent ()) {
+ DEBUG ((EFI_D_INFO, "RapidStart on critical battery wake from EC.\n"));
+ RapidStartInitializeCriticalBatteryWakeupEvent (FALSE);
+ RapidStartClearAllKscWakeStatus ();
+ Instance->Transition = RapidStartEntry;
+ }
+
+ return ;
+ }
+ ///
+ /// Check RapidStart non-volatile flag
+ ///
+ Status = RapidStartGetFlag (&RapidStartFlag);
+ if (EFI_ERROR (Status) || ((RapidStartFlag & RAPID_START_FLAG_ENTRY_DONE) == 0)) {
+ DEBUG ((EFI_D_INFO, "No RapidStart flag set\n"));
+ return ;
+ }
+ ///
+ /// RapidStart exit path (Cold boot assumed)
+ /// For security reasones need to clear SMRAM hash and drive password from non-volatile
+ /// memory first.
+ ///
+#ifndef RAPID_START_NO_SMRAM_INTEGRITY_CHECK
+ Status = RapidStartRestoreAndClearSecureHash (Instance->SmRamHash);
+#endif
+
+ Instance->PwdStatus = RapidStartGetDriveUnlockPassword (
+ GetPeiServicesTablePointer (),
+ RapidStartExit,
+ Instance->Data.StoreSataPort,
+ (UINT8 *) Instance->HddPassword,
+ &Instance->FreezeLock
+ );
+
+ ///
+ /// This is either RapidStart Resume flow or non-RapidStart transition
+ /// Clear RapidStart flag in the start point.
+ ///
+ RapidStartSetFlag (0);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ if (IsPowerButtonOverride ()) {
+ DEBUG ((EFI_D_INFO, "PWRBTN override\n"));
+ return ;
+ }
+
+ DEBUG ((EFI_D_INFO, "RapidStart exit\n"));
+ Instance->Transition = RapidStartExit;
+}
+
+/**
+ Install RapiStartPpi.
+
+ @param[in] PeiServices - Pointer to PEI Services Table.
+ @param[in] NotifyDesc - Pointer to the descriptor for the Notification event that caused this function to execute.
+ @param[in] Ppi - Pointer to the PPI data associated with this function.
+
+ @retval EFI_SUCCESS
+**/
+STATIC
+EFI_STATUS
+InstallRapidStartPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ RAPID_START_INSTANCE *Instance;
+ EFI_STATUS Status;
+
+ Instance = AllocateZeroPool (sizeof (RAPID_START_INSTANCE));
+ ASSERT (Instance != NULL);
+ if (Instance == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Instance->Ppi.Revision = RAPID_START_PPI_REVISION_1;
+ Instance->Ppi.GetMode = RapidStartGetMode;
+ Instance->Ppi.TransitionEntryPoint = RapidStartTransitionEntryPoint;
+ Instance->Ppi.IsEnabled = RapidStartIsEnabled;
+
+ Instance->PpiDesc.Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+ Instance->PpiDesc.Guid = &gRapidStartPpiGuid;
+ Instance->PpiDesc.Ppi = &Instance->Ppi;
+
+ RapidStartInitInstance (Instance);
+
+ if (Instance->Transition != RapidStartNone) {
+ RapidStartInitAhci (Instance);
+ }
+ if (Instance->Transition == RapidStartEntry) {
+ ForEachAhciPort (
+ &Instance->Ahci,
+ AhciSpinUpPort,
+ AhciGetEnabledPorts () & ~(1u << Instance->Ahci.Port)
+ );
+ }
+
+ Status = PeiServicesInstallPpi (&Instance->PpiDesc);
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+
+}
+
+/**
+ RapidStart PEIM entry point driver
+
+ @param[in] FfsHeader - FFS file header pointer of this driver
+ @param[in] PeiServices - Pointer to PEI service table
+
+ @retval EFI_SUCCESS - RapidStart PPI installed successfully
+ @retval EFI_OUT_OF_RESOURCES - Error in allocate required resource.
+**/
+EFI_STATUS
+RapidStartPeiEntryPoint (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ PEI_HECI_PPI *HeciPpi;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "RapidStart: RapidStartPeiEntryPoint\n"));
+
+ ///
+ /// Install RapiStart Ppi when Heci Ppi is ready.
+ ///
+
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiHeciPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &HeciPpi
+ );
+ if (EFI_ERROR(Status)) {
+ Status = PeiServicesNotifyPpi (&mInstallRapidStartPpiNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ return EFI_SUCCESS;
+ }
+
+ return InstallRapidStartPpi (PeiServices, NULL, NULL);
+} \ No newline at end of file
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartPei.cif b/ReferenceCode/RapidStart/Pei/RapidStartPei.cif
new file mode 100644
index 0000000..e2f18c8
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "RapidStartPei"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Pei"
+ RefName = "RapidStartPei"
+[files]
+"RapidStartPei.sdl"
+"RapidStartPei.mak"
+"RapidStartPei.dxs"
+"RapidStartPei.c"
+"RapidStartAhci.c"
+"RapidStartAhci.h"
+"RapidStartPei.inf"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartPei.dxs b/ReferenceCode/RapidStart/Pei/RapidStartPei.dxs
new file mode 100644
index 0000000..9c903ca
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.dxs
@@ -0,0 +1,41 @@
+/** @file
+ Dependency expression source file.
+
+@copyright
+ Copyright (c) 1999 - 2013 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
+
+**/
+
+
+#include "AutoGen.h"
+#include "PeimDepex.h"
+#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB)
+#include "EfiDepex.h"
+#include "RapidStartConfig.h"
+#include EFI_PPI_DEPENDENCY (BootMode)
+#include EFI_PPI_DEPENDENCY (Variable)
+#include EFI_PPI_DEPENDENCY (Stall)
+
+#include EFI_PPI_DEPENDENCY (PchPeiInitDone)
+#include EFI_PPI_DEPENDENCY (SaPlatformPolicy)
+#endif
+
+DEPENDENCY_START
+ PEI_MASTER_BOOT_MODE_PEIM_PPI AND
+ PEI_STALL_PPI_GUID AND
+ PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID AND
+ SA_PLATFORM_POLICY_PPI_GUID AND
+ PCH_PEI_INIT_DONE_PPI_GUID
+DEPENDENCY_END
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartPei.inf b/ReferenceCode/RapidStart/Pei/RapidStartPei.inf
new file mode 100644
index 0000000..752c1ea
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.inf
@@ -0,0 +1,119 @@
+## @file
+# Component description file for the RapidStart PEIM.
+#
+#@copyright
+# Copyright (c) 2004 - 2013 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 = RapidStartPei
+FILE_GUID = 53f019e9-bb0c-424b-870a-1faf10b1cb4c
+COMPONENT_TYPE = PE32_PEIM
+
+[sources.common]
+ RapidStartAhci.h
+ RapidStartAhci.c
+ RapidStartPei.c
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGluePeimEntryPoint.c
+
+[includes.common]
+ .
+ $(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)/Include/Library
+ $(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_RAPID_START_ROOT)/Samplecode/Library/RapidStartPlatformLib/Pei
+ $(EFI_SOURCE)/$(PROJECT_RAPID_START_ROOT)/GfxDisplay/Library/Pei
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/$(PROJECT_SA_MRC)/Pei/Source/Api
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/$(PROJECT_SA_MRC)/Pei/Source/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]
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBaseMemoryLib
+ EdkIIGluePeiDebugLibReportStatusCode
+ EdkIIGlueBaseLib
+ EdkIIGluePeiDxePostCodeLibReportStatusCode
+ EdkIIGluePeiReportStatusCodeLib
+ EdkIIGluePeiServicesLib
+ EdkIIGluePeiMemoryAllocationLib
+ EdkIIGlueBasePciLibPciExpress
+ EdkIIGlueBasePrintLib
+ RapidStartPpiLib
+#
+# Uncomment this only when ME is implemented
+#
+ MeLibPpi
+
+ EdkFrameworkPpiLib
+ IntelPchPpiLib
+ RapidStartCommonLib
+ RapidStartGuidLib
+ RapidStartPeiLib
+ GfxDisplayLibPei
+ PchPlatformLib
+ EdkIIGluePeiHobLib
+#
+# CryptoLib is required for SMRAM integrity check
+#
+ PeiCryptLib
+ OpensslLib
+ EdkIIGluePeiFirmwarePerformanceLib
+ IntelSaPpiLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+ DPX_SOURCE = RapidStartPei.dxs
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartPeiEntryPoint
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ -D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ -D __EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ -D __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_PEI_SERVICES_LIB__ \
+ -D __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__ \
+ -D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \
+ -D __EDKII_GLUE_BASE_PRINT_LIB__ \
+ -D __EDKII_GLUE_PEI_HOB_LIB__ \
+ -DRAPID_START_USE_OLD_ACPI_VARIABLE_SET
+
diff --git a/ReferenceCode/RapidStart/Pei/RapidStartPei.mak b/ReferenceCode/RapidStart/Pei/RapidStartPei.mak
new file mode 100644
index 0000000..52015a3
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.mak
@@ -0,0 +1,151 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartPei/RapidStartPei.mak 7 11/07/13 2:47a Joshchou $
+#
+# $Revision: 7 $
+#
+# $Date: 11/07/13 2:47a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartPei/RapidStartPei.mak $
+#
+# 7 11/07/13 2:47a Joshchou
+# [TAG] EIP142523
+# [Category] Spec Update
+# [Severity] Important
+# [Description] Update to RC 1.7.0
+#
+# 6 1/13/13 7:38a Bensonlai
+# [TAG] EIP112060
+# [Category] Spec Update
+# [Severity] Normal
+# [Description] [SBY]Intel Rapid Start Technology Framework Reference
+# Code Production Candidate 0.9.0
+# [Files] RapidStartDxe.c, RapidStartConfig.h, RapidStartDxe.dsc,
+# RapidStartPei.dsc, RapidStartPei.c, RapidStartPei.inf,
+# RapidStartPei.mak, RapidStartInfo.h
+#
+# 5 10/15/12 5:45a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 4 9/26/12 3:26a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+# 2 5/14/12 11:26p Yurenlai
+# [TAG] EIP90075
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Alpha 2 Version 0.5.6.
+# [Description] ReferenceCode\RapidStart\*.*,
+# Board\EM\iFfsWrapper\Library\*.*
+#
+# 1 4/19/12 7:50a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+
+all : RapidStartPei
+RapidStartPei : $(BUILD_DIR)\RapidStartPei.mak RapidStartPeiBin
+
+$(BUILD_DIR)\RapidStartPei.mak : $(RapidStartPei_DIR)\$(@B).cif $(RapidStartPei_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartPei_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartPei_INCLUDES=\
+ $(EdkIIGlueLib_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)\
+ $(INTEL_MCH_INCLUDES)\
+ $(ME_INCLUDES)\
+ /I$(GfxDisplayLibPei_DIR)\
+ $(RAPIDSTART_INCLUDES)\
+ /I$(IntelPlatformProtocolLib_DIR)\
+
+RapidStartPei_DEFINES=\
+ $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartPeiEntryPoint"\
+ /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ /D __EDKII_GLUE_BASE_MEMORY_LIB__\
+ /D __EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ /D __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__ \
+ /D __EDKII_GLUE_PEI_SERVICES_LIB__ \
+ /D __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__ \
+ /D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \
+ /D __EDKII_GLUE_PEI_HOB_LIB__ \
+!IF "$(iME_SUPPORT)"=="1"
+ /D ME_SUPPORT_FLAG\
+!ENDIF
+
+RapidStartPei_LIBS =\
+ $(EdkIIGlueBaseIoLibIntrinsic_LIB)\
+ $(EdkIIGlueBaseLib_LIB)\
+ $(EdkIIGlueBaseLibIA32_LIB)\
+ $(EdkIIGlueBasePrintLib_LIB)\
+ $(EdkIIGluePeiMemoryAllocationLib_LIB)\
+ $(EdkIIGluePeiDebugLibReportStatusCode_LIB)\
+ $(EdkIIGluePeiReportStatusCodeLib_LIB)\
+ $(EdkIIGluePeiServicesLib_LIB)\
+ $(EdkIIGlueBasePciLibPciExpress_LIB)\
+ $(EdkIIGlueBasePostCodeLibPort80_LIB)\
+ $(EDKFRAMEWORKPPILIB)\
+ $(PchPlatformPeiLib_LIB)\
+ $(IntelPchPpiLib_LIB)\
+ $(MeGuidLib_LIB)\
+ $(MeLibPpi_LIB)\
+ $(RapidStartPpiLib_LIB)\
+ $(RapidStartPeiLib_LIB)\
+ $(RapidStartCommonPeiLib_LIB)\
+ $(RapidStartGuidLib_LIB)\
+ $(EdkIIGluePeiHobLib_LIB)\
+ $(GfxDisplayLibPei_LIB)\
+ $(EdkIIGluePeiFirmwarePerformanceLib_LIB)\
+ $(INTEL_SA_PPI_LIB)\
+
+RapidStartPeiBin : $(RapidStartPei_LIBS) $(PEILIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS) \
+ /f $(BUILD_DIR)\RapidStartPei.mak all \
+ NAME=RapidStartPei \
+ MAKEFILE=$(BUILD_DIR)\RapidStartPei.mak \
+ GUID=53f019e9-bb0c-424b-870a-1faf10b1cb4c \
+ ENTRY_POINT=_ModuleEntryPoint \
+ "MY_INCLUDES = $(RapidStartPei_INCLUDES)" \
+ "MY_DEFINES = $(RapidStartPei_DEFINES)" \
+ TYPE=PEIM \
+ EDKIIModule=PEIM \
+ DEPEX1=$(RapidStartPei_DIR)\RapidStartPei.dxs \
+ DEPEX1_TYPE=EFI_SECTION_PEI_DEPEX \
+ COMPRESS=0
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/ReferenceCode/RapidStart/Pei/RapidStartPei.sdl b/ReferenceCode/RapidStart/Pei/RapidStartPei.sdl
new file mode 100644
index 0000000..008fedb
--- /dev/null
+++ b/ReferenceCode/RapidStart/Pei/RapidStartPei.sdl
@@ -0,0 +1,68 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartPei/RapidStartPei.sdl 1 4/19/12 7:50a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 7:50a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartPei/RapidStartPei.sdl $
+#
+# 1 4/19/12 7:50a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartPei_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable iFFS support in PEI Phase"
+End
+
+MODULE
+ Help = "Includes RapidStartPei.mak to Project"
+ File = "RapidStartPei.mak"
+End
+
+PATH
+ Name = "RapidStartPei_DIR"
+ Help = "RapidStartPei dir"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartPei.ffs"
+ Parent = "FV_BB"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.c b/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.c
new file mode 100644
index 0000000..185f36c
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.c
@@ -0,0 +1,33 @@
+/** @file
+ This file defines iFFS Gfx PPI
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "PeiGfxPpi.h"
+#endif
+//
+// Protocol GUID definition
+//
+EFI_GUID gPeiGfxPpiGuid = PEI_GFX_PPI_GUID;
+
+//
+// Protocol description
+//
+EFI_GUID_STRING(&gPeiGfxPpiGuid, "PeiGfxPpi", "RST Gfx PPI");
diff --git a/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.h b/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.h
new file mode 100644
index 0000000..6636e8e
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/PeiGfxPpi/PeiGfxPpi.h
@@ -0,0 +1,89 @@
+/** @file
+ Header file for RapidStart Gfx PPI
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _PEI_GFX_PPI_H_
+#define _PEI_GFX_PPI_H_
+
+#define PEI_GFX_PPI_GUID \
+ { \
+ 0xc4d6994a, 0xaa3d, 0x47c0, 0xae, 0xa, 0xb0, 0xbf, 0xad, 0xba, 0xa6, 0x13 \
+ }
+
+extern EFI_GUID gPeiGfxPpiGuid;
+
+#define DSS_RANGE 0x01 //< Dss Range is 1
+#define GFX_RESTORE_RANGE 0x02 ///< Gfx Memory restore Range is 2
+#define FB_RESTORE_RANGE 250 ///< The Max FB Range is 16
+#define MAX_GFX_MEMORY_RANGES (DSS_RANGE + GFX_RESTORE_RANGE + FB_RESTORE_RANGE)
+
+#pragma pack(1)
+
+typedef struct {
+ UINT64 BaseAddress;
+ UINT64 Size;
+} GFX_MEM_RANGE_ENTRY;
+
+typedef struct {
+ UINT16 NumOfEntry;
+ UINT8 Reserved[2];
+ GFX_MEM_RANGE_ENTRY MemRangeEntry[MAX_GFX_MEMORY_RANGES];
+} GFX_RESTORE_MEM_TABLE;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * PEI_GFX_PPI_GET_DSS_ADDRESS_RANGE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ OUT GFX_RESTORE_MEM_TABLE **DssAddressRange
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * PEI_GFX_PPI_GET_RESTORE_MEM_TABLE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ OUT GFX_RESTORE_MEM_TABLE **GfxRestoreMemTable
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * PEI_GFX_PPI_GET_RESTORE_FB_RANGE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ OUT GFX_RESTORE_MEM_TABLE **FbRestoreMemTable
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * PEI_GFX_PPI_RESTORE_DISPLAY) (
+ IN CONST EFI_PEI_SERVICES **PeiServices
+);
+
+#pragma pack(1)
+
+typedef struct _PEI_GFX_PPI {
+ PEI_GFX_PPI_RESTORE_DISPLAY RestoreDisplay;
+ PEI_GFX_PPI_GET_DSS_ADDRESS_RANGE GetDssAddressRange;
+ PEI_GFX_PPI_GET_RESTORE_MEM_TABLE GetRestoreMemTable;
+ PEI_GFX_PPI_GET_RESTORE_FB_RANGE GetRestoreFbRange;
+} PEI_GFX_PPI;
+
+#pragma pack()
+
+#endif
diff --git a/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.c b/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.c
new file mode 100644
index 0000000..d27cbf3
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.c
@@ -0,0 +1,35 @@
+/** @file
+ This file defines RapidStart PPI
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "RapidStart.h"
+#endif
+
+///
+/// Protocol GUID definition
+///
+EFI_GUID gRapidStartPpiGuid = RAPID_START_PPI_GUID;
+
+///
+/// Protocol description
+///
+EFI_GUID_STRING(&gRapidStartPpiGuid, "RapidStartPpi", "Rapid Start PPI");
diff --git a/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.h b/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.h
new file mode 100644
index 0000000..48d4bfc
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStart/RapidStart.h
@@ -0,0 +1,190 @@
+/** @file
+ Header file for RapidStart PPI
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+#ifndef PPI_RAPID_START_H_
+#define PPI_RAPID_START_H_
+
+#define RAPID_START_PPI_GUID \
+ { \
+ 0x3d0e663a, 0xdc72, 0x4489, 0x87, 0xc5, 0xe4, 0x9e, 0xe7, 0x73, 0xa4, 0x52 \
+ }
+
+#define ATA_PASSWORD_LEN 32
+
+extern EFI_GUID gRapidStartPpiGuid;
+
+typedef struct _RAPID_START_PPI RAPID_START_PPI;
+
+///
+/// PPI revision number
+/// Any backwards compatible changes to this PPI will result in an update in the revision number
+/// Major changes will require publication of a new PPI
+///
+/// Revision 1: Original version
+///
+#define RAPID_START_PPI_REVISION_1 1
+
+typedef enum {
+ RapidStartNone,
+ RapidStartEntry,
+ RapidStartExit,
+ RapidStartTransitionMax
+} RAPID_START_TRANSITION;
+
+/**
+ Detremines RapidStart transition.
+
+ This PPI function will determine which Rapid Start transition state should be
+ performed. It will check current Rapid Start enable/disable by calling
+ RapidStartIsEnabled(), current boot mode, wakeup source and Rapid Start Entry
+ Flag. If Rapid Start enabled, current boot mode is S3 Resume and wakeup source
+ is one of the supported sources, the Rapid Start Entry will be performed. Once
+ Rapid Start Entry completed successfully the Rapid Start Entry Flag will be set
+ and next boot GetMode() will check this flag and perform Rapid Start Resume as
+ requested.
+
+ GetMode () function will do the following check:
+ - Rapid Start function is enabled or not
+ - Current boot mode is S3 resume or not
+ - If it is S3 resume, check wakeup source is one of enabled Rapid Start Entry
+ conditions to perform Rapid Start Entry.
+ - If it is not S3 resume, the Rapid Start transition mode should already be
+ determined in the RapidStartPeiEntryPoint ().
+
+ After Rapid Start Transition state determined TransitionEntryPoint () PPI
+ function will do the necessary Rapid Start transition.
+
+ @param[in] This - A pointer to RAPID_START_PPI itself.
+
+ @retval RAPID_START_TRANSITION - The RapidStart transition being performed
+**/
+typedef
+RAPID_START_TRANSITION
+(EFIAPI *RAPID_START_GET_MODE) (
+ IN RAPID_START_PPI *This
+ );
+
+/**
+ Executes or schedules RapidStart transition if appropriate.
+
+ This PPI function will perform or schedule an Rapid Start transition (by
+ registering either EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID or
+ PEI_RAPID_START_TRANSITION_START_PPI_GUID callback function). It includes Rapid
+ Start Entry or Rapid Start Exit transition basing on Transition mode. If
+ Transition mode is RapidStartTransitionMax which means unknown transition mode,
+ GetMode() will be called again to determine current Rapid Start transition mode.
+ In Rapid Start Entry transition, the memory content will be saved in "Rapid
+ Start Store" and Rapid Start Entry Flag will be set then system will be
+ switched to Rapid Start state. If error occurred during Rapid Start Entry
+ transition, it will switch system back to S3 state. In Rapid Start Exit
+ transition, Rapid Start Entry Flag will be cleared and the memory content will
+ be restored from "Rapid Start Store". If no error occurred, it will boot
+ from S3 resume path back to OS, otherwise it will reset system.
+
+ TransitionEntryPoint () function will do the following check:
+ - Rapid Start function is enabled or not
+ - If current Rapid Start transition mode is not determined yet, call
+ GetMode () PPI function.
+ - If current Transition state is "RapidStartNone", do nothing and
+ return to caller.
+ - If transition state is "Rapid Start Entry", save memory content to
+ Rapid Start Store. If no error occurring, set Rapid Start Entry Flag and
+ put system to Rapid Start state, otherwise it will re-enter S3 state as
+ Rapid Start Entry failed.
+ - If transition state is "RapidStartExit", restore memory content from
+ Rapid Start Store and override boot mode to "S3 Resume" so that
+ system will perform S3 resume back to OS. If error occurred during Rapid
+ Start Exit transition it will reset system.
+ - When "RapidStartDoTransition ()" is executed in
+ EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID or
+ PEI_RAPID_START_TRANSITION_START_PPI_GUID callback function, platform
+ code should ensure the NEM mode has been disabled and cache
+ configuration basing on memory map has been completed prior to execute
+ RapidStartDoTransition ().
+ - SMRAM hashing algorithm in reference code uses SHA256 algorithm in
+ "Crypto library" from UDK2010 source code. Those SMRAM hashing
+ relevant functions are not included in this document since they are no
+ porting required. Refer to Crypto library and BaseCryptLib.h for detail
+ information regarding those functions. See section Porting
+ Recommendation" for more information.
+
+ @param[in] This - Pointer to RapidStart PPI
+ @param[out] BootMode - Boot mode that may be overridden
+
+ @retval EFI_SUCCESS - RapidStart transition performed/scheduled successfully
+ @retval EFI_ABORTED - RapidStart transition aborted
+**/
+typedef
+EFI_STATUS
+(EFIAPI *RAPID_START_TRANSITION_ENTRY_POINT) (
+ IN RAPID_START_PPI * This,
+ OUT EFI_BOOT_MODE * BootMode
+ );
+
+/**
+ Check if RapidStart support is enabled.
+
+ This PPI function will return current Rapid Start enable/disable state.
+
+ IsEnabled () function will return current Rapid Start enable/disable state.
+
+ @param[in] This - Pointer to RapidStart PPI
+
+ @retval TRUE if RapidStart support is enabled FALSE otherwise
+**/
+typedef
+BOOLEAN
+(EFIAPI *RAPID_START_IS_ENABLED) (
+ IN RAPID_START_PPI * This
+ );
+
+/**
+ This PPI provides main functions required for Rapid Start Entry and Exit flow.
+
+ This PPI provides major functions required for Rapid Start transition. Both
+ GetMode() and TransitionEntryPoint() should be executed after memory is ready
+ for accessing since they will save, restore or check memory content. Besides,
+ SATA controller must be initialized to AHCI mode before executing
+ TransitionEntryPoint() PPI so Rapid Start Store can be accessed.
+**/
+struct _RAPID_START_PPI {
+ ///
+ /// Indicate PPI structure revision.
+ ///
+ UINT8 Revision;
+ ///
+ /// GetMode function will base on current Rapid Start configurations and boot mode
+ /// to determine which Rapid Start transition flow should be performed.
+ ///
+ RAPID_START_GET_MODE GetMode;
+ ///
+ /// This function will perform or schedule Rapid Start transition if appropriate.
+ /// This includes Rapid Start Entry, Rapid Start Exit or does nothing basing on the
+ /// Rapid Start transition mode.
+ ///
+ RAPID_START_TRANSITION_ENTRY_POINT TransitionEntryPoint;
+ ///
+ /// This function returns Rapid Start feature current enable/disable state.
+ ///
+ RAPID_START_IS_ENABLED IsEnabled;
+};
+
+#endif
diff --git a/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.cif b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.cif
new file mode 100644
index 0000000..e5f533c
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "RapidStartPpiLib"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Ppi\"
+ RefName = "RapidStartPpiLib"
+[files]
+"RapidStartPpiLib.inf"
+"RapidStartPpiLib.sdl"
+"RapidStartPpiLib.mak"
+"PeiGfxPpi\PeiGfxPpi.c"
+"PeiGfxPpi\PeiGfxPpi.h"
+"RapidStart\RapidStart.h"
+"RapidStart\RapidStart.c"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.inf b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.inf
new file mode 100644
index 0000000..51111e8
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.inf
@@ -0,0 +1,51 @@
+## @file
+# Component description file for the RapidStart Ppi 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 = RapidStartPpiLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ RapidStart/RapidStart.h
+ RapidStart/RapidStart.c
+ PeiGfxPpi/PeiGfxPpi.h
+ PeiGfxPpi/PeiGfxPpi.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
+#
+# 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/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.mak b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.mak
new file mode 100644
index 0000000..24cf02d
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.mak
@@ -0,0 +1,60 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartPpiLib/RapidStartPpiLib.mak 1 4/19/12 8:10a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:10a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartPpiLib/RapidStartPpiLib.mak $
+#
+# 1 4/19/12 8:10a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+
+all : RapidStartPpiLib
+
+$(RapidStartPpiLib_LIB) : RapidStartPpiLib
+
+RapidStartPpiLib : $(BUILD_DIR)\RapidStartPpiLib.mak RapidStartPpiLibBin
+
+$(BUILD_DIR)\RapidStartPpiLib.mak : $(RapidStartPpiLib_DIR)\$(@B).cif $(RapidStartPpiLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartPpiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartPpiLib_INCLUDES =\
+ $(EDK_INCLUDES)\
+
+RapidStartPpiLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartPpiLib.mak all\
+ "MY_INCLUDES=$(RapidStartPpiLib_INCLUDES)" \
+ TYPE=PEI_LIBRARY
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#************************************************************************* \ No newline at end of file
diff --git a/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.sdl b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.sdl
new file mode 100644
index 0000000..f39c912
--- /dev/null
+++ b/ReferenceCode/RapidStart/Ppi/RapidStartPpiLib.sdl
@@ -0,0 +1,72 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartPpiLib/RapidStartPpiLib.sdl 1 4/19/12 8:10a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:10a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartPpiLib/RapidStartPpiLib.sdl $
+#
+# 1 4/19/12 8:10a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartPpiLib_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStartPpiLib support in Project"
+End
+
+PATH
+ Name = "RapidStartPpiLib_DIR"
+ Help = "RapidStartPpiLib file source directory"
+End
+
+MODULE
+ File = "RapidStartPpiLib.mak"
+ Help = "Includes RapidStartPpiLib.mak to Project"
+End
+
+ELINK
+ Name = "RapidStartPpiLib_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartPpiLib.lib"
+ Parent = "RapidStartPpiLib_LIB"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.c b/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.c
new file mode 100644
index 0000000..326da6b
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.c
@@ -0,0 +1,30 @@
+/** @file
+
+@copyright
+ Copyright (c) 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#include "EdkIIGlueDxe.h"
+
+#include "DxeGfxProtocol.h"
+
+EFI_GUID gDxeGfxProtocolGuid = DXE_GFX_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gDxeGfxProtocolGuid, "RST Gfx Protocol",
+ "Protocol describing RST Gfx Protocol."
+ );
diff --git a/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.h b/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.h
new file mode 100644
index 0000000..70e1c1d
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/DxeGfxProtocol/DxeGfxProtocol.h
@@ -0,0 +1,63 @@
+/** @file
+
+@copyright
+ Copyright (c) 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 DXE_GFX_PROTOCOL_H_
+#define DXE_GFX_PROTOCOL_H_
+
+#define DXE_GFX_PROTOCOL_GUID \
+ { \
+ 0xc4d6994a, 0xaa3d, 0x47c0, 0xae, 0xa, 0xb0, 0xbf, 0xad, 0xba, 0xa6, 0x13 \
+ }
+
+//
+// Extern the GUID for protocol users.
+//
+extern EFI_GUID gDxeGfxProtocolGuid;
+
+#define BIOS_RESTORE 0 // 12 Mbytes space
+#define DESKTOP_RESTORE 1 // 512 Kb Space
+
+typedef
+EFI_STATUS
+(EFIAPI * GFX_ALLOCATE_DSS_BUFFER) (
+ IN UINT8 DisplayType
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * GFX_GET_DSS_ADDRESS) (
+ OUT UINT64 **DssAddress,
+ OUT UINT64 *SizeOfDss
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * GFX_SAVE_DISPLAY) (
+ IN UINT8 *RestoreImage
+);
+
+#pragma pack(1)
+
+typedef struct _DXE_GFX_PROTOCOL {
+ GFX_ALLOCATE_DSS_BUFFER AllocateDssBuffer;
+ GFX_GET_DSS_ADDRESS GetDssAddress;
+ GFX_SAVE_DISPLAY SaveDisplay;
+} DXE_GFX_PROTOCOL;
+
+#pragma pack()
+
+#endif
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.c b/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.c
new file mode 100644
index 0000000..b0230a2
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.c
@@ -0,0 +1,31 @@
+/** @file
+ RapidStart Global NVS Area description protocol implementation.
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#include "EdkIIGlueDxe.h"
+
+#include "RapidStartGlobalNvsArea.h"
+
+EFI_GUID gRapidStartGlobalNvsAreaProtocolGuid = RAPID_START_GLOBAL_NVS_AREA_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gRapidStartGlobalNvsAreaProtocolGuid, "RapidStart Global NVS Area Protocol",
+ "Protocol describing RapidStart ACPI NVS memory region used by ACPI subsystem."
+ );
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.h b/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.h
new file mode 100644
index 0000000..25fa453
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.h
@@ -0,0 +1,100 @@
+/** @file
+ Definition of the RapidStart global NVS area protocol. This protocol
+ publishes the address and format of a global ACPI NVS buffer used as a communications
+ buffer between SMM/DXE/PEI code and ASL code.
+ @todo The format is derived from the ACPI reference code, version 0.95.
+
+ Note: Data structures defined in this protocol are not naturally aligned.
+
+@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
+**/
+#ifndef _RAPID_START_GLOBAL_NVS_AREA_H_
+#define _RAPID_START_GLOBAL_NVS_AREA_H_
+
+//
+// Includes
+//
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (RAPID_START_GLOBAL_NVS_AREA_PROTOCOL);
+
+///
+/// RapidStart Global NVS Area Protocol GUID
+///
+#define RAPID_START_GLOBAL_NVS_AREA_PROTOCOL_GUID \
+ { \
+ 0xa5559f06, 0x6415, 0x4759, 0x88, 0x69, 0xde, 0x15, 0xf9, 0xcd, 0x9c, 0x9b \
+ }
+
+///
+/// Extern the GUID for protocol users.
+///
+extern EFI_GUID gRapidStartGlobalNvsAreaProtocolGuid;
+
+/**
+ Global NVS Area definition
+
+ To provide OS base utility controlling capability, these ACPI Global NVS fields
+ provides the interface for OS base utility to control Rapid Start behavior and
+ Rapid Start reference code will work accordingly.
+**/
+#pragma pack(1)
+typedef struct {
+ ///
+ /// It shows what wake up event sources available for Rapid Start Entry.
+ ///
+ /// Used by RapidStart.asl as "RSTA"
+ ///
+ UINT8 EventsAvailable;
+ ///
+ /// This controls which wake up source can be used to trigger Rapid Start Entry tasks.
+ ///
+ /// Used by RapidStart.asl as "RSTS"
+ ///
+ UINT8 EventsEnabled;
+ ///
+ /// This defines how many minutes the wake up event will happen for performing Rapid
+ /// Start Entry transition. Available options are "Immediately" (wake system up
+ /// once system entering S3 mode), 1 Min, 2 Min, 5 Min and 10 Min etc. Default
+ /// Platform Policy will set this to 10 minutes.
+ ///
+ /// Used by RapidStart.asl as "RSTT"
+ ///
+ UINT16 WakeTimerMin;
+ ///
+ /// This is the pointer for performance data structure.
+ ///
+ /// Used by RapidStart.asl as "RSTP"
+ ///
+ UINT32 PerfDataPtr;
+} RAPID_START_GLOBAL_NVS_AREA;
+#pragma pack()
+
+/**
+ RapidStart Global NVS Area Protocol
+
+ To provide OS base utility controlling mechanism there are some items
+ created in Rapid Start private ACPI Global NVS area. Note: This will be
+ published by reference code as one SSDT table so no Platform code change
+ required.
+**/
+struct _RAPID_START_GLOBAL_NVS_AREA_PROTOCOL {
+ RAPID_START_GLOBAL_NVS_AREA *Area;
+ VOID *RapidStartData;
+};
+
+#endif
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.c b/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.c
new file mode 100644
index 0000000..7269ff9
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.c
@@ -0,0 +1,40 @@
+/** @file
+ This file defines the RapidStart Info Protocol.
+
+@copyright
+ Copyright (c) 2011 - 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
+**/
+
+//
+// Statements that include other files
+//
+//
+// 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 "RapidStartInfo.h"
+#endif
+
+///
+/// Protocol GUID definition
+///
+EFI_GUID gRapidStartInfoProtocolGuid = RAPID_START_INFO_PROTOCOL_GUID;
+
+///
+/// Protocol description
+///
+EFI_GUID_STRING(&gRapidStartInfoProtocolGuid, "RapidStart Info Protocol", "RapidStart Information Protocol");
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.h b/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.h
new file mode 100644
index 0000000..3997eda
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartInfo/RapidStartInfo.h
@@ -0,0 +1,93 @@
+/** @file
+ This file defines the RapidStart Info Protocol.
+
+@copyright
+ Copyright (c) 2011 - 2014 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 _RAPID_START_INFO_H_
+#define _RAPID_START_INFO_H_
+
+///
+/// GUID to locate Rapid Start Info Protocol
+///
+/// EDK and EDKII have different GUID formats
+///
+/// @see _RAPID_START_INFO_PROTOCOL
+///
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#define RAPID_START_INFO_PROTOCOL_GUID \
+ { \
+ 0xd231db5b, 0x4a9c, 0x4092, 0xa8, 0xc5, 0x9c, 0xa0, 0xbc, 0x7d, 0x6a, 0xa6 \
+ }
+
+#else
+#define RAPID_START_INFO_PROTOCOL_GUID \
+ { \
+ 0xd231db5b, 0x4a9c, 0x4092, \
+ { \
+ 0xa8, 0xc5, 0x9c, 0xa0, 0xbc, 0x7d, 0x6a, 0xa6 \
+ } \
+ }
+#endif
+
+///
+/// Extern the GUID for protocol users.
+///
+/// @see _RAPID_START_INFO_PROTOCOL
+///
+extern EFI_GUID gRapidStartInfoProtocolGuid;
+
+//
+// Forward reference for ANSI C compatibility
+//
+EFI_FORWARD_DECLARATION (RAPID_START_INFO_PROTOCOL);
+
+///
+/// Protocol revision number
+/// Any backwards compatible changes to this protocol will result in an update in the revision number
+/// Major changes will require publication of a new protocol
+///
+/// Revision 1: Original version
+///
+#define RAPID_START_INFO_PROTOCOL_REVISION_1 1
+
+///
+/// RapidStart Reference Code formats 0xAABBCCDD
+/// DD - Build Number
+/// CC - Reference Code Revision
+/// BB - Reference Code Minor Version
+/// AA - Reference Code Major Version
+/// Example: RapidStart Reference Code 0.7.1 should be 00 07 01 00 (0x00070100)
+///
+#define RAPID_START_RC_VERSION 0x01090000
+#define RAPID_START_FVI_STRING "Reference Code - Intel Rapid Start"
+#define RAPID_START_FVI_SMBIOS_TYPE 0xDD
+#define RAPID_START_FVI_SMBIOS_INSTANCE 0x05
+/**
+ A protocol to indicate Rapid Start reference code revision.
+
+ This protocol will be initialized by Rapid Start reference code to indicate the reference code revision.
+ It will be installed by reference code even Rapid Start is disabled.
+
+ @see RAPID_START_INFO_PROTOCOL_GUID
+ @see gRapidStartInfoProtocolGuid
+ @see RapidStartInstallInfoProtocol()
+**/
+struct _RAPID_START_INFO_PROTOCOL {
+ UINT8 Revision; ///< Revision of this protocol
+ UINT32 RCVersion; ///< Rapid Start reference code revision
+};
+
+#endif
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.c b/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.c
new file mode 100644
index 0000000..eb7d873
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.c
@@ -0,0 +1,46 @@
+/** @file
+ This file defines the RapidStart Policy Protocol.
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+
+//
+// Statements that include other files
+//
+//
+// 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 "RapidStartPlatformPolicy.h"
+#endif
+
+///
+/// Protocol GUID definition
+///
+EFI_GUID gRapidStartPlatformPolicyProtocolGuid = RAPID_START_PLATFORM_POLICY_PROTOCOL_GUID;
+
+///
+/// Protocol description
+///
+EFI_GUID_STRING
+ (
+ &gRapidStartPlatformPolicyProtocolGuid, "RapidStartPlatformPolicy Protocol",
+ "Intel(R) DXE Phase RapidStart Platform Policy Protocol"
+ );
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.h b/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.h
new file mode 100644
index 0000000..32bc704
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartPlatformPolicy/RapidStartPlatformPolicy.h
@@ -0,0 +1,162 @@
+/** @file
+ This file defines the RapidStart Policy Protocol.
+
+@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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Reference Module" and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _RAPID_START_PLATFORM_POLICY_H_
+#define _RAPID_START_PLATFORM_POLICY_H_
+
+///
+/// GUID to locate Rapid Start Platform Policy Protocol
+///
+/// @see _RAPID_START_PLATFORM_POLICY_PROTOCOL
+///
+#define RAPID_START_PLATFORM_POLICY_PROTOCOL_GUID \
+ { \
+ 0x42bbaca3, 0x7161, 0x4891, 0xac, 0x10, 0xc7, 0x5e, 0x2e, 0x4d, 0xf6, 0x14 \
+ }
+
+#define RAPID_START_WAKE_TIMER_MAX (24 * 60)
+#define RAPID_START_WAKE_TIMER_DEFAULT 10
+
+///
+/// Extern the GUID for protocol users.
+///
+/// @see _RAPID_START_PLATFORM_POLICY_PROTOCOL
+///
+extern EFI_GUID gRapidStartPlatformPolicyProtocolGuid;
+
+//
+// Forward reference for ANSI C compatibility
+//
+EFI_FORWARD_DECLARATION (RAPID_START_PLATFORM_POLICY_PROTOCOL);
+
+///
+/// Revision 1: Original version
+///
+///
+/// Revision 2: Added DisplaySaveRestore
+/// Added DisplayType
+#define DXE_RAPID_START_PLATFORM_POLICY_PROTOCOL_REVISION 1
+#define DXE_RAPID_START_PLATFORM_POLICY_PROTOCOL_REVISION_2 2
+
+/**
+ RapidStart DXE Platform Platform Policy Protocol
+
+ This protocol provides an interface for platform code to configure Rapid Start
+ behavior and usable resource without modifying reference code.
+
+ This protocol provides interface to configure Rapid Start policy. Platform code
+ should initialize this protocol before RapidStartDxe driver executing basing on
+ the platform implementation. RapidStartDxePolicyInit sample code provided to
+ initialize default settings which has been validated by CRB BIOS. Platform code
+ can include this sample code with some porting to make it setup menu
+ controllable.
+
+ @see RAPID_START_PLATFORM_POLICY_PROTOCOL_GUID
+ @see gRapidStartPlatformPolicyProtocolGuid
+ @see RapidStartDxePolicyInitEntryPoint()
+**/
+struct _RAPID_START_PLATFORM_POLICY_PROTOCOL {
+ ///
+ /// Revision for the protocol structure
+ ///
+ UINT8 Revision;
+ ///
+ /// Enable or disable Rapid Start function. 0=Disable (Default) and 1=Enable
+ ///
+ UINT16 EnableRapidStart : 1;
+ ///
+ /// Enable reference code to do Rapid Start Entry flow when system waking up from S3
+ /// state by RTC timer event. 0=Disable, 1=Enable (Default)
+ ///
+ /// @see S3WakeTimerMin
+ ///
+ UINT16 EntryOnS3RtcWake : 1;
+ ///
+ /// Enable reference code to perform Rapid Start Entry flow when system waking up
+ /// from Critical low battery event (from S3 state). 0=Disable, 1=Enable (Default)
+ ///
+ UINT16 EntryOnS3CritBattWake : 1;
+ ///
+ /// Enable Active Page Threshold support in Rapid Start reference code. Once enabled
+ /// with proper ActivePageThresholdSize value, Rapid Start functions are able to
+ /// work on systems with Rapid Start partition size smaller than the amount of the
+ /// whole system memory.
+ ///
+ /// @see ActivePageThresholdSize
+ ///
+ UINT16 ActivePageThresholdSupport : 1;
+ ///
+ /// Enable Hybrid Hard Disk support in Rapid Start reference code.
+ ///
+ /// @see AhciHybridHardDiskSupport
+ ///
+
+ UINT16 HybridHardDisk : 1;
+ UINT16 DisplaySaveRestore : 1;
+ UINT16 DisplayType : 1;
+ ///
+ /// These bits are reserved for future use
+ ///
+ UINT16 Reserved : 9; ///< Reserved
+ ///
+ /// Specific the minutes used for RTC timeout wakeup event. This setting only works
+ /// when EntryOnS3RtcWake = 1. Default is 10 minutes which will set 10 minutes RTC
+ /// Alarm to wake system up after system entering S3 state. Available settings:
+ /// "Immediately=0min", 1min, 2mins, 5mins, 10mins, 15mins, 30mins, 60mins and
+ /// 120mins etc.
+ ///
+ /// @see EntryOnS3RtcWake
+ /// @see RAPID_START_WAKE_TIMER_MAX
+ /// @see RAPID_START_WAKE_TIMER_DEFAULT
+ ///
+ UINT16 S3WakeTimerMin;
+ ///
+ /// This is reserved and not used by FRC. It may be used by sample code for RST
+ /// Caching mode support.
+ ///
+ UINT8 RaidModeSataPortNumber;
+ ///
+ /// When ActivePageThresholdSupport is enabled, ActivePageThresholdSize will be
+ /// adopted as the criteria for the Rapid Start partition size. For example, on a
+ /// system with 2GB system memory and 1GB Rapid Start partition, when
+ /// ActivePageThresholdSupport is disabled, partition provisioning will fail because
+ /// system memory size is greater than Rapid Start partition size. When
+ /// ActivePageThresholdSupport is enabled and ActivePageThresholdSize set to 1G or
+ /// smaller, it passes the provisioning. When ActivePageThresholdSize is set to
+ /// zero, size checking will be skipped. Any size of partition reserved for Rapid
+ /// Start will pass the provisioning. If Rapid Start functions are still enabled
+ /// during S3 entry, Rapid Start reference code calculates the size of Active Memory
+ /// Pages, which is the amount of memory that is to be transferred to the Rapid
+ /// Start partition after the Zero page filtering. If it is smaller than or equal to
+ /// the provisioned Rapid Start partition size, then Rapid Start transitions will be
+ /// activated normally after system entering S3. Otherwise, system will remain in S3
+ /// state.
+ ///
+ /// @see ActivePageThresholdSupport
+ ///
+ UINT32 ActivePageThresholdSize;
+ ///
+ /// Specifies the type value of the Firmware Version Info(FVI) Structure used to report
+ /// version information about Rapid Start through the FVI Interface.
+ ///
+ UINT8 FviSmbiosType;
+};
+
+#endif
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.cif b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.cif
new file mode 100644
index 0000000..81b954a
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.cif
@@ -0,0 +1,18 @@
+<component>
+ name = "RapidStartProtocolLib"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Protocol\"
+ RefName = "RapidStartProtocolLib"
+[files]
+"RapidStartProtocolLib.inf"
+"RapidStartProtocolLib.mak"
+"RapidStartProtocolLib.sdl"
+"DxeGfxProtocol\DxeGfxProtocol.c"
+"DxeGfxProtocol\DxeGfxProtocol.h"
+"RapidStartPlatformPolicy\RapidStartPlatformPolicy.c"
+"RapidStartPlatformPolicy\RapidStartPlatformPolicy.h"
+"RapidStartInfo\RapidStartInfo.c"
+"RapidStartInfo\RapidStartInfo.h"
+"RapidStartGlobalNvsArea\RapidStartGlobalNvsArea.c"
+"RapidStartGlobalNvsArea\RapidStartGlobalNvsArea.h"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.inf b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.inf
new file mode 100644
index 0000000..3bfb5da
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.inf
@@ -0,0 +1,61 @@
+## @file
+# Component description file for RapidStart module
+#
+#@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 an 'Intel Peripheral Driver' and uniquely
+# identified as "Intel Reference Module" and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+
+[defines]
+BASE_NAME = RapidStartProtocolLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ RapidStartPlatformPolicy/RapidStartPlatformPolicy.h
+ RapidStartPlatformPolicy/RapidStartPlatformPolicy.c
+ RapidStartInfo/RapidStartInfo.h
+ RapidStartInfo/RapidStartInfo.c
+ RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.c
+ RapidStartGlobalNvsArea/RapidStartGlobalNvsArea.h
+ DxeGfxProtocol/DxeGfxProtocol.c
+ DxeGfxProtocol/DxeGfxProtocol.h
+
+[includes.common]
+ $(EFI_SOURCE)
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EFI_SOURCE)/Include
+ $(EFI_SOURCE)/Platform/$(PROJECT_FAMILY)/Common
+ $(EFI_SOURCE)/Platform/$(PROJECT_FAMILY)/Common/Include
+#
+# Edk II Glue Library, some hearder are included by R9 header so have to include
+#
+
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/Framework
+ $(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/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.mak b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.mak
new file mode 100644
index 0000000..4672d99
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.mak
@@ -0,0 +1,58 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartProtocolLib/RapidStartProtocolLib.mak 1 4/19/12 8:12a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:12a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartProtocolLib/RapidStartProtocolLib.mak $
+#
+# 1 4/19/12 8:12a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+
+all : RapidStartProtocolLib
+
+$(BUILD_DIR)\RapidStartProtocolLib.lib : RapidStartProtocolLib
+
+RapidStartProtocolLib : $(BUILD_DIR)\RapidStartProtocolLib.mak RapidStartProtocolLibBin
+
+$(BUILD_DIR)\RapidStartProtocolLib.mak : $(RapidStartProtocolLib_DIR)\$(@B).cif $(RapidStartProtocolLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartProtocolLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartProtocolLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartProtocolLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES) $(MISCFRAMEWORK_INCLUDES) $(EdkIIGlueLib_INCLUDES)" \
+ TYPE=LIBRARY
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.sdl b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.sdl
new file mode 100644
index 0000000..75cd95a
--- /dev/null
+++ b/ReferenceCode/RapidStart/Protocol/RapidStartProtocolLib.sdl
@@ -0,0 +1,71 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartProtocolLib/RapidStartProtocolLib.sdl 1 4/19/12 8:12a Yurenlai $
+#
+# $Revision: 1 $
+#
+# $Date: 4/19/12 8:12a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartProtocolLib/RapidStartProtocolLib.sdl $
+#
+# 1 4/19/12 8:12a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = RapidStartProtocolLib_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStartProtocolLib support in Project"
+End
+
+MODULE
+ Help = "Includes RapidStartProtocolLib.mak to Project"
+ File = "RapidStartProtocolLib.mak"
+End
+
+PATH
+ Name = "RapidStartProtocolLib_DIR"
+End
+
+ELINK
+ Name = "RapidStartProtocolLib_LIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartProtocolLib.lib"
+ Parent = "RapidStartProtocolLib_LIB"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/ReferenceCode/RapidStart/RapidStart.cif b/ReferenceCode/RapidStart/RapidStart.cif
new file mode 100644
index 0000000..9564fd1
--- /dev/null
+++ b/ReferenceCode/RapidStart/RapidStart.cif
@@ -0,0 +1,23 @@
+<component>
+ name = "Intel Rapid Start Technology"
+ category = eModule
+ LocalRoot = "ReferenceCode\RapidStart"
+ RefName = "RapidStart"
+[files]
+"RapidStart.sdl"
+"ReleaseNotes.chm"
+[parts]
+"RapidStartAcpiTables"
+"RapidStartPei"
+"RapidStartDxe"
+"RapidStartGuidLib"
+"RapidStartSmm"
+"RapidStartInclude"
+"RapidStartPpiLib"
+"RapidStartProtocolLib"
+"DxeFfsGfxDriver"
+"PeiGfxDriver"
+"GfxDisplayLibDxe"
+"GfxDisplayLibPei"
+"RapidStartWrapper"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/RapidStart.sdl b/ReferenceCode/RapidStart/RapidStart.sdl
new file mode 100644
index 0000000..66557d2
--- /dev/null
+++ b/ReferenceCode/RapidStart/RapidStart.sdl
@@ -0,0 +1,237 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStart.sdl 5 4/18/13 1:14a Bensonlai $
+#
+# $Revision: 5 $
+#
+# $Date: 4/18/13 1:14a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStart.sdl $
+#
+# 5 4/18/13 1:14a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] Removing the debug mode for the ELINK of
+# RAPID_START_ON_MEMORY_INSTALLED.
+#
+# 4 10/15/12 5:47a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 3 9/26/12 3:45a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Enable iFFS Zero Page function.
+# [Description] RapidStart.sdl
+#
+# 2 8/14/12 7:50a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Support ASLPREPROCESS_FLAG to include Iintel RC flags.
+# [Description] RapidStart.sdl, RapidStartSmm.sdl
+#
+# 1 4/19/12 7:50a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStart_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch to enable RapidStart support in Project"
+End
+
+TOKEN
+ Name = "TRIM_ON_RESUME"
+ Value = "0"
+ TargetMAK = Yes
+ TokenType = Boolean
+End
+
+TOKEN
+ Name = "ON_MEMORY_INSTALLED"
+ Value = "1"
+ TargetMAK = Yes
+ TokenType = Boolean
+End
+
+TOKEN
+ Name = "ON_START_PPI_INSTALLED"
+ Value = "1"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Token = "ON_MEMORY_INSTALLED" "=" "1"
+End
+
+TOKEN
+ Name = "NO_SMRAM_INTEGRITY_CHECK"
+ Value = "0"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "RapidStart reference code uses SHA256 algorithm in Crypto library from UDK2010 source code for SMRAM integrity check."
+End
+
+TOKEN
+ Name = "WHOLE_MEMORY_CHECK"
+ Value = "0"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "This function is only for debug. It will increase RapidStart Entry and Resume time significantly because it calculates whole memory CRC32 value by dividing to several memory chunks. By default each memory chunk is 1MB size."
+End
+
+TOKEN
+ Name = "FFS_ME7_SUPPORT"
+ Value = "0"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "This function is only for debug. It will increase RapidStart Entry and Resume time significantly because it calculates whole memory CRC32 value by dividing to several memory chunks. By default each memory chunk is 1MB size."
+End
+
+TOKEN
+ Name = "FFS_PERF_MON"
+ Value = "0"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "RapidStart performance data logging support"
+End
+
+TOKEN
+ Name = "FFS_USE_OLD_ACPI_VARIABLE_SET"
+ Value = "1"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "From RC 0.8.0.0, build switch RapidStart_USE_OLD_ACPI_VARIABLE_SET is added into the reference code for backward compatibility with platform code base comes with old ACPI_VARIABLE_SET structure."
+End
+
+TOKEN
+ Name = "FFS_SCAN_ZERO_PAGE"
+ Value = "1"
+ TargetMAK = Yes
+ TokenType = Boolean
+ Help = "Enable/Disable Rapid Start scen zero page."
+End
+
+ELINK
+ Name = "INTEL_IRST_RC_FLAGS"
+ Help = "iRST Reference Code command line options of the compiler"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(INTEL_IRST_RC_FLAGS)"
+ Parent = "GLOBAL_DEFINES"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D RAPID_START_FLAG"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D RAPID_START_TRIM_ON_RESUME"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "TRIM_ON_RESUME" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_ON_MEMORY_INSTALLED"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "ON_MEMORY_INSTALLED" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_ON_START_PPI_INSTALLED"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "ON_START_PPI_INSTALLED" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_NO_SMRAM_INTEGRITY_CHECK"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "NO_SMRAM_INTEGRITY_CHECK" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_WHOLE_MEMORY_CHECK"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "WHOLE_MEMORY_CHECK" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_PERF_MON"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "FFS_PERF_MON" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_USE_OLD_ACPI_VARIABLE_SET"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "FFS_USE_OLD_ACPI_VARIABLE_SET" "=" "1"
+End
+
+ELINK
+ Name = "/D RAPID_START_SCAN_ZERO_PAGE"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ InvokeOrder = AfterParent
+ Token = "FFS_SCAN_ZERO_PAGE" "=" "1"
+End
+
+PATH
+ Name = "RapidStart_DIR"
+End
+
+ELINK
+ Name = "RAPIDSTART_INCLUDES"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "/I$(RapidStart_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/ReferenceCode/RapidStart/ReleaseNotes.chm b/ReferenceCode/RapidStart/ReleaseNotes.chm
new file mode 100644
index 0000000..5ae44c6
--- /dev/null
+++ b/ReferenceCode/RapidStart/ReleaseNotes.chm
Binary files differ
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.c b/ReferenceCode/RapidStart/Smm/RapidStartSmm.c
new file mode 100644
index 0000000..1e4316c
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.c
@@ -0,0 +1,836 @@
+/** @file
+ This SMM driver will install a S3 Entry callback SMI handler for RTC wakeup policy.
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+
+**/
+
+///
+/// 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 "RapidStartConfig.h"
+#include EFI_PROTOCOL_CONSUMER (RapidStartPlatformPolicy)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartGlobalNvsArea)
+
+#ifdef ISCT_FLAG
+#include EFI_PROTOCOL_PRODUCER (IsctNvsArea)
+#endif //ISCT_FLAG
+
+#include <SaAccess.h>
+#include <PchAccess.h>
+#include <PchPlatformLib.h>
+#include "RapidStartSmm.h"
+#include "RapidStartData.h"
+#include "RapidStartCommonLib.h"
+#include "RapidStartAhciReg.h"
+#endif
+
+#define DAY_IN_SEC (24 * 60 * 60)
+#define RAPID_START_DELTA_SEC 45
+
+EFI_GUID gRapidStartPersistantDataGuid = RAPID_START_PERSISTENT_DATA_GUID;
+CHAR16 gRapidStartPersistantDataName[] = RAPID_START_PERSISTENT_DATA_NAME;
+
+RAPID_START_PERSISTENT_DATA *mRapidStartData;
+RAPID_START_MEM_DATA *mRapidStartMemData;
+RAPID_START_GLOBAL_NVS_AREA *mRapidStartGlobalNvs;
+UINT32 *mRapidStartZeroPageBitMap;
+UINT32 *mCrc32Record;
+
+#ifdef ISCT_FLAG
+ISCT_NVS_AREA *mIsctNvs;
+#endif //ISCT_FLAG
+/**
+ Convert RTC_TIME structure data to seconds
+
+ @param[in] tm A time data structure including second, minute and hour fields.
+
+ @retval A number of seconds converted from given RTC_TIME structure data.
+**/
+STATIC
+UINT32
+TimeToSeconds (
+ IN RTC_TIME *tm
+ )
+{
+ ASSERT (tm->Hour < 24);
+ ASSERT (tm->Minute < 60);
+ ASSERT (tm->Second < 60);
+ return ((tm->Hour * 60) + tm->Minute) * 60 + tm->Second;
+}
+
+/**
+ Check if it is leap year
+
+ @param[in] Year year to be check
+
+ @retval True year is leap year
+ @retval FALSE year is not a leap year
+**/
+BOOLEAN
+IsLeapYear (
+ IN UINT16 Year
+ )
+{
+ return (Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0));
+}
+
+STATIC UINT8 mDaysOfMonthInfo[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+/**
+ Check if it is leap year
+
+ @param[in] Year Year number
+ @param[in] Month Month number, January is 1, Feburary is 2, ... December is 12.
+
+ @retval Days Number of day of the Month of the Year
+**/
+UINT8
+DaysOfMonth (
+ IN UINT16 Year,
+ IN UINT8 Month
+ )
+{
+ UINT8 Days;
+ if (Month < 1 || Month > 12) {
+ return 0;
+ }
+
+ Days = mDaysOfMonthInfo[Month - 1];
+ if (Month == 2) {
+ Days += IsLeapYear (Year);
+ }
+
+ return Days;
+}
+
+/**
+ Convert seconds to RTC_TIME structure data
+
+ @param[out] tm A time data structure which will be updated with converted value.
+ @param[in] Seconds Total seconds that will be converted into RTC_TIME
+**/
+STATIC
+VOID
+SecondsToTime (
+ OUT RTC_TIME *tm,
+ IN UINT32 Seconds
+ )
+{
+ tm->Second = Seconds % 60;
+ Seconds /= 60;
+ tm->Minute = Seconds % 60;
+ Seconds /= 60;
+ tm->Hour = Seconds % 24;
+ tm->Date = 0;
+}
+
+/**
+ Check if tm2 is after 2 days of tm1
+
+ @param tm1 First time to compare
+ @param tm2 Second time to compare
+
+ @retval TRUE tm2 is 2 days after tm1
+ @retval FALSE tm2 is not 2 days after tm1
+**/
+BOOLEAN
+IsOver2Days (
+ IN RTC_TIME *tm1,
+ IN RTC_TIME *tm2
+)
+{
+ BOOLEAN RetVal;
+ RetVal = TRUE;
+ if (tm2->Date > tm1->Date) {
+ if (tm2->Date - tm1->Date == 1) {
+ RetVal = FALSE;;
+ }
+ } else if ((DaysOfMonth (tm1->Year, tm1->Month) == tm1->Date) && (tm2->Date == 1)) {
+ RetVal = FALSE;;
+ }
+ return RetVal;
+}
+
+/**
+ Adjusts RTC Alarm setting according to RapidStart platform policy.
+
+ @param[in] WakeAfter Time offset in seconds to wake from S3
+
+ @retval EFI_SUCCESS Timer started successfully
+ @retval EFI_ALREADY_STARTED Timer already set sooner than desired
+**/
+STATIC
+EFI_STATUS
+RapidStartAdjustRtcAlarm (
+ IN UINT32 WakeAfter
+ )
+{
+ UINT32 CurrentTime;
+ UINT32 AlarmTime;
+ UINT32 WakeTime;
+ RTC_TIME tm;
+ RTC_TIME wake_tm;
+ EFI_STATUS Status, RtcStatus;
+ UINT16 PmBase;
+#ifdef ISCT_FLAG
+ UINT32 IsctWakeAfter;
+ RTC_TIME Isct_wake_tm;
+#endif // ISCT_FLAG
+
+ Status = EFI_SUCCESS;
+
+ ///
+ /// For an instant wake 2 seconds is a safe value
+ ///
+ if (WakeAfter < 2) {
+ WakeAfter = 2;
+ }
+ ///
+ /// Make sure RTC is in BCD and 24h format
+ ///
+ RtcInit ();
+
+ RtcStatus = RtcGetTime (&tm);
+ ASSERT_EFI_ERROR (RtcStatus);
+
+ CurrentTime = TimeToSeconds (&tm);
+
+#ifdef ISCT_FLAG
+ IsctWakeAfter = 0;
+ Isct_wake_tm.Second = 0;
+ Isct_wake_tm.Minute = 0;
+ Isct_wake_tm.Hour = 0;
+ Isct_wake_tm.Date = 0;
+ Isct_wake_tm.Month = 0;
+ Isct_wake_tm.Year = 0;
+
+ //
+ // Get Isct wake up time
+ //
+ if (mIsctNvs != NULL) {
+ mIsctNvs->IsctOverWrite = 0;
+
+ IsctWakeAfter = mIsctNvs->RtcDurationTime;
+ if ((IsctWakeAfter != 0) && (IsctWakeAfter < 2)) {
+ IsctWakeAfter = 2;
+ }
+ }
+
+ SecondsToTime (&Isct_wake_tm, IsctWakeAfter + CurrentTime);
+#endif //ISCT_FLAG
+ RtcStatus = RtcGetAlarm (&wake_tm);
+ if (RtcStatus == EFI_SUCCESS && (!(mRapidStartMemData->EntryCanceled))) {
+ AlarmTime = TimeToSeconds (&wake_tm);
+ ///
+ /// When OS set alarm date to zero,
+ /// that would mean the alarm date is today or next day depending alarm time,
+ /// and the alarm will happen in 24 hour.
+ ///
+ if (wake_tm.Date != 0 && wake_tm.Date != tm.Date) {
+ ///
+ /// OS Wake-up time is over 1 day
+ ///
+ AlarmTime += DAY_IN_SEC;
+ if (IsOver2Days (&tm, &wake_tm)) {
+ ///
+ /// OS Wake-up time is over 2 day
+ ///
+ AlarmTime += DAY_IN_SEC;
+ }
+ } else if (AlarmTime < CurrentTime && wake_tm.Date == 0) {
+ ///
+ /// When alarm time behind current time and alarm date is zero,
+ /// OS set the alarm for next day
+ //
+ AlarmTime += DAY_IN_SEC;
+ }
+ ///
+ /// OS RTC alarm set sooner than RapidStart entry after
+ /// Add some seconds so RapidStart wake time won't overcome the OS timer
+ ///
+ if ((WakeAfter + RAPID_START_DELTA_SEC >= AlarmTime - CurrentTime)
+#ifdef ISCT_FLAG
+ ///
+ /// OS RTC alarm set sooner than Isct alarm
+ ///
+ && ((IsctWakeAfter >= AlarmTime - CurrentTime) || (IsctWakeAfter == 0))
+#endif // ISCT_FLAG
+ ) {
+ return EFI_ALREADY_STARTED;
+ }
+ ///
+ /// Store OS wake-up time, so it can be restored upon entering RapidStart
+ ///
+ mRapidStartMemData->OsWakeTime = wake_tm;
+ mRapidStartMemData->OsWakeTimeEnabled = 1;
+#ifdef ISCT_FLAG
+ ///
+ /// ISCT time is smaller than OS's, so store ISCT wake-up time, so it can be restored upon entering RapidStart
+ ///
+ if ((IsctWakeAfter <= AlarmTime - CurrentTime) && (IsctWakeAfter != 0)) {
+ mRapidStartMemData->OsWakeTime = Isct_wake_tm;
+ mIsctNvs->IsctOverWrite = 1;
+ }
+#endif // ISCT_FLAG
+ }
+
+ WakeTime = CurrentTime + WakeAfter;
+#ifdef ISCT_FLAG
+ ///
+ /// ISCT alarm set sooner than RapidStart entry after
+ /// Add some seconds so RapidStart wake time won't overcome the ISCT timer
+ ///
+ if ((IsctWakeAfter <= WakeAfter + RAPID_START_DELTA_SEC) && (IsctWakeAfter != 0)) {
+ WakeTime = CurrentTime + IsctWakeAfter;
+ mIsctNvs->IsctOverWrite = 1;
+ Status = EFI_NOT_STARTED;
+ }
+
+ ///
+ /// OS hasn't set up the wake-up time, so store ISCT wake-up time then it can be restored upon entering RapidStart
+ ///
+ if (mRapidStartMemData->OsWakeTimeEnabled == 0 && IsctWakeAfter != 0) {
+ mRapidStartMemData->OsWakeTime = Isct_wake_tm;
+ mRapidStartMemData->OsWakeTimeEnabled = 1;
+ mIsctNvs->IsctOverWrite = 1;
+ }
+#endif // ISCT_FLAG
+
+ SecondsToTime (&tm, WakeTime);
+
+ RtcStatus = RtcSetAlarm (&tm);
+ ASSERT_EFI_ERROR (RtcStatus);
+
+ PmBase = (UINT16) (PciRead32 (
+ PCI_LIB_ADDRESS (DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR);
+
+ ///
+ /// Clear RTC PM1 status
+ ///
+ IoWrite16 (PmBase + R_PCH_ACPI_PM1_STS, B_PCH_ACPI_PM1_STS_RTC);
+
+ ///
+ /// set RTC_EN bit in PM1_EN to wake up from the alarm
+ ///
+ IoWrite16 (
+ PmBase + R_PCH_ACPI_PM1_EN,
+ (IoRead16 (PmBase + R_PCH_ACPI_PM1_EN) | B_PCH_ACPI_PM1_EN_RTC)
+ );
+ return Status;
+}
+
+#ifdef ISCT_FLAG
+/**
+ Adjusts RTC Alarm setting according to Isct.
+
+ @retval EFI_SUCCESS Timer started successfully
+ @retval EFI_ALREADY_STARTED Timer already set sooner than desired
+**/
+STATIC
+EFI_STATUS
+IsctAdjustRtcAlarm (
+ )
+{
+ UINT32 CurrentTime;
+ UINT32 AlarmTime;
+ UINT32 WakeTime;
+ RTC_TIME tm;
+ RTC_TIME wake_tm;
+ EFI_STATUS Status, RtcStatus;
+ UINT16 PmBase;
+ UINT32 IsctWakeAfter;
+ RTC_TIME Isct_wake_tm;
+
+ Status = EFI_SUCCESS;
+
+ DEBUG((EFI_D_INFO, "IsctAdjustRtcAlarm() Begin.\n"));
+
+ ///
+ /// Make sure RTC is in BCD and 24h format
+ ///
+ RtcInit ();
+
+ RtcStatus = RtcGetTime (&tm);
+ ASSERT_EFI_ERROR (RtcStatus);
+
+ CurrentTime = TimeToSeconds (&tm);
+
+ IsctWakeAfter = 0;
+ Isct_wake_tm.Second = 0;
+ Isct_wake_tm.Minute = 0;
+ Isct_wake_tm.Hour = 0;
+ Isct_wake_tm.Date = 0;
+ Isct_wake_tm.Month = 0;
+ Isct_wake_tm.Year = 0;
+
+ if (mIsctNvs == NULL) {
+ return EFI_ABORTED;
+ }
+
+ mIsctNvs->IsctOverWrite = 0;
+
+ //
+ // Get Isct wake up time
+ //
+ IsctWakeAfter = mIsctNvs->RtcDurationTime;
+ if ((IsctWakeAfter != 0) && (IsctWakeAfter < 2)) {
+ IsctWakeAfter = 2;
+ }
+
+ SecondsToTime (&Isct_wake_tm, IsctWakeAfter + CurrentTime);
+
+ RtcStatus = RtcGetAlarm (&wake_tm);
+ if (RtcStatus == EFI_SUCCESS) {
+ AlarmTime = TimeToSeconds (&wake_tm);
+ ///
+ /// When OS set alarm date to zero,
+ /// that would mean the alarm date is today or next day depending alarm time,
+ /// and the alarm will happen in 24 hour.
+ ///
+ if (wake_tm.Date != 0 && wake_tm.Date != tm.Date) {
+ ///
+ /// OS Wake-up time is over 1 day
+ ///
+ AlarmTime += DAY_IN_SEC;
+ if (IsOver2Days (&tm, &wake_tm)) {
+ ///
+ /// OS Wake-up time is over 2 day
+ ///
+ AlarmTime += DAY_IN_SEC;
+ }
+ } else if (AlarmTime < CurrentTime && wake_tm.Date == 0) {
+ ///
+ /// When alarm time behind current time and alarm date is zero,
+ /// OS set the alarm for next day
+ //
+ AlarmTime += DAY_IN_SEC;
+ }
+ ///
+ /// OS RTC alarm set sooner than Isct alarm
+ ///
+ if ((IsctWakeAfter >= AlarmTime - CurrentTime) || (IsctWakeAfter == 0)) {
+ return EFI_ALREADY_STARTED;
+ }
+ }
+
+ mIsctNvs->IsctOverWrite = 1;
+
+ WakeTime = CurrentTime + IsctWakeAfter;
+ Status = EFI_NOT_STARTED;
+
+ SecondsToTime (&tm, WakeTime);
+
+ RtcStatus = RtcSetAlarm (&tm);
+ ASSERT_EFI_ERROR (RtcStatus);
+
+ PmBase = (UINT16) (PciRead32 (
+ PCI_LIB_ADDRESS (DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR);
+
+ ///
+ /// Clear RTC PM1 status
+ ///
+ IoWrite16 (PmBase + R_PCH_ACPI_PM1_STS, B_PCH_ACPI_PM1_STS_RTC);
+
+ ///
+ /// set RTC_EN bit in PM1_EN to wake up from the alarm
+ ///
+ IoWrite16 (
+ PmBase + R_PCH_ACPI_PM1_EN,
+ (IoRead16 (PmBase + R_PCH_ACPI_PM1_EN) | B_PCH_ACPI_PM1_EN_RTC)
+ );
+
+ DEBUG((EFI_D_INFO, "IsctAdjustRtcAlarm() End.\n"));
+
+ return Status;
+}
+#endif // ISCT_FLAG
+
+/**
+ Scan Zero page within specific memory range.
+
+ @param[in] BaseAddress Start address of memory
+ @param[in] EndAddress End address of memory
+
+ @retval SaveSize Save Size requirement
+**/
+STATIC
+UINTN
+ScanZeroPageByRange (
+ IN UINT64 BaseAddress,
+ IN UINT64 EndAddress
+ )
+{
+ UINT64 NonZeroPointer;
+ UINT32 TempBitMap;
+ UINTN count;
+ UINT32 *ZeroPagePointer;
+ UINTN SaveSize;
+
+ count = 0;
+ TempBitMap = 0;
+ ZeroPagePointer = mRapidStartZeroPageBitMap + 2 + (UINT32) NUMBER_OF_PAGES_IN_DWORD (BaseAddress);
+ SaveSize = 0;
+ while (BaseAddress < EndAddress) {
+ NonZeroPointer = (UINT64)ScanValueMem64 ((VOID*)BaseAddress, EFI_PAGE_SIZE/ sizeof (UINT64), 0);
+ BaseAddress += EFI_PAGE_SIZE;
+ NonZeroPointer++;
+ if (NonZeroPointer == 0) {
+ //
+ // This is Zero Page so we set the corresponding bit in BitMap.
+ //
+ TempBitMap |= 1;
+ } else {
+ SaveSize += EFI_PAGE_SIZE;
+ }
+
+ TempBitMap = RRotU32 (TempBitMap, 1);
+ count++;
+ if (count == (sizeof (*mRapidStartZeroPageBitMap) * 8)) {
+ *ZeroPagePointer = TempBitMap;
+ count = 0;
+ TempBitMap = 0;
+ ZeroPagePointer += 1;
+ if ((UINTN) ((UINTN) ZeroPagePointer - (UINTN) (mRapidStartZeroPageBitMap + 2)) >= mRapidStartData->ZeroBitmapSize) {
+ //
+ // Zero page filter table is full, skip other checking.
+ //
+ SaveSize += (UINTN)(EndAddress - BaseAddress);
+ break;
+ }
+ }
+
+ }
+ return SaveSize;
+}
+
+/**
+ Create a bitmap for zero page filter.
+
+ @retval Save Size requirement
+**/
+STATIC
+UINTN
+BuildZeroPageBitMap (
+ VOID
+ )
+{
+ UINT32 GfxGTTBase;
+ UINTN SaveSize;
+
+ SaveSize = 0;
+ GfxGTTBase = (PciRead32 (
+ PCI_LIB_ADDRESS (SA_MC_BUS,
+ SA_MC_DEV,
+ SA_MC_FUN,
+ R_SA_BGSM)
+ ) & B_SA_BGSM_BGSM_MASK);
+
+ ///
+ /// Ensure all ZeroPageBitMap were zero-ed
+ ///
+ ZeroMem (mRapidStartZeroPageBitMap, mRapidStartData->ZeroBitmapSize);
+
+#ifdef RAPID_START_SCAN_ZERO_PAGE
+ ///
+ /// Handle Below 4GB memory
+ /// Skip GTT region
+ ///
+ SaveSize = ScanZeroPageByRange (0x0, GfxGTTBase);
+
+#if defined(EFIX64)
+ ///
+ /// Handle Above 4GB memory
+ ///
+ if (mRapidStartData->Tohm > MEM_EQU_4GB) {
+ SaveSize += ScanZeroPageByRange (MEM_EQU_4GB, mRapidStartData->Tohm);
+ }
+#endif
+#endif
+ return SaveSize;
+}
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+/**
+ Log or compare CRC32 value for above 4GB memory.
+
+ @param[in] IsComparingCrc32 - FALSE to save CRC32 value into buffer. TRUE to compare CRC32 value with pre-saved value in buffer.
+**/
+VOID
+SaveOrCompareCrc32ForAbove4GB (
+ IN BOOLEAN IsComparingCrc32
+ )
+{
+#if defined(EFIX64)
+ if (mRapidStartData->Tohm > MEM_EQU_4GB) {
+ SaveOrCompareCrc32 (IsComparingCrc32, MEM_EQU_4GB, mRapidStartData->Tohm, mRapidStartData);
+ }
+#endif
+}
+
+/**
+ A SW SMI callback to check whole memory CRC32
+
+ @param[in] DispatchHandle - The handle of this callback, obtained when registering
+ @param[in] DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT
+**/
+VOID
+RapidStartSwSmiCallback (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
+ )
+{
+ if (mRapidStartGlobalNvs->EventsEnabled) {
+ SaveOrCompareCrc32ForAbove4GB (TRUE);
+ }
+}
+#endif
+
+/**
+ RapidStart S3 entry callback SMI handler
+
+ @param[in] DispatchHandle - The handle of this callback, obtained when registering
+ @param[in] DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT
+**/
+VOID
+EFIAPI
+RapidStartS3EntryCallback (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext
+ )
+{
+ UINT16 PmBase;
+ EFI_STATUS Status;
+ UINTN SaveSize;
+ UINT32 CheckingSizeInSector;
+ UINT8 EventsEnabledFlag;
+ PCH_SERIES PchSeries;
+
+ mRapidStartMemData->OsWakeTimeEnabled = 0;
+ EventsEnabledFlag = 0;
+ PchSeries = GetPchSeries();
+
+ Status = EFI_SUCCESS;
+ if (mRapidStartMemData->EntryCanceled) {
+ ///
+ /// Immediate wake system up regardless of original setting.
+ ///
+ RapidStartAdjustRtcAlarm (0);
+ Status = EFI_NOT_STARTED;
+ mRapidStartMemData->EntryCanceled = 0;
+ } else {
+ /* mRapidStartMemData->EntryCanceled */
+ if (mRapidStartGlobalNvs->EventsEnabled) {
+ SaveSize = BuildZeroPageBitMap ();
+ if (mRapidStartData->ActivePageThresholdSizeInSector == 0) {
+ ///
+ /// In AUTO mode, RapidStart will check the partition size automatically with active memory size
+ ///
+ CheckingSizeInSector = mRapidStartData->StoreSectors;
+ } else {
+ ///
+ /// If Active Page Threshold Size is set manually, RapidStart compare this with active memory size
+ ///
+ CheckingSizeInSector = mRapidStartData->ActivePageThresholdSizeInSector;
+ }
+ if (MEM_TO_SECT (SaveSize + mRapidStartData->ZeroBitmapSize + mRapidStartData->Crc32RecordSize) > CheckingSizeInSector) {
+ Status = EFI_BUFFER_TOO_SMALL;
+ }
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ if (!EFI_ERROR (Status)) {
+ SaveOrCompareCrc32ForAbove4GB (FALSE);
+ }
+#endif
+ }
+ //
+ // Enable and override KSC critical battery wake up event threshold
+ // to ensure enough battery capacity for RapidStart Entry transition
+ //
+ if (!EFI_ERROR (Status)) {
+ if (mRapidStartGlobalNvs->EventsEnabled & RAPID_START_ACPI_BATT_WAKE) {
+ RapidStartInitializeCriticalBatteryWakeupEvent (TRUE);
+ EventsEnabledFlag |= RAPID_START_ACPI_BATT_WAKE;
+ }
+
+ if (mRapidStartGlobalNvs->EventsEnabled & RAPID_START_ACPI_RTC_WAKE) {
+ Status = RapidStartAdjustRtcAlarm (mRapidStartGlobalNvs->WakeTimerMin * 60);
+ if (!EFI_ERROR (Status)) {
+ EventsEnabledFlag |= RAPID_START_ACPI_RTC_WAKE;
+ }
+ }
+#ifdef ISCT_FLAG
+ else {
+ IsctAdjustRtcAlarm();
+ }
+#endif
+ }
+#ifdef ISCT_FLAG
+ else {
+ IsctAdjustRtcAlarm();
+ }
+#endif
+ } /* end else: mRapidStartMemData->EntryCanceled */
+
+ RapidStartSetConfig (EventsEnabledFlag);
+
+ if (!EFI_ERROR (Status)) {
+ PmBase = (UINT16) (PciRead32 (
+ PCI_LIB_ADDRESS (DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_ACPI_BASE)
+ ) & B_PCH_LPC_ACPI_BASE_BAR);
+
+ ///
+ /// Save wake events
+ ///
+ if (PchSeries == PchLp) {
+ mRapidStartMemData->GPE0 = IoRead32 (PmBase + R_PCH_ACPI_GPE0_EN_127_96);
+ } else if (PchSeries == PchH) {
+ mRapidStartMemData->GPE0a = IoRead32 (PmBase + R_PCH_ACPI_GPE0a_EN);
+ mRapidStartMemData->GPE0b = IoRead32 (PmBase + R_PCH_ACPI_GPE0b_EN);
+ }
+ }
+
+ AfterInitializingEntryEvent (Status);
+ return;
+}
+
+/**
+ Initializes the SMM S3 Handler.
+
+ @param[in] ImageHandle - The image handle of Wake On Lan driver
+ @param[in] SystemTable - The standard EFI system table
+
+ @retval EFI_SUCCESS - RapidStart S3 entry callback SMI handle has been registered when RapidStart wake up policy enabled
+**/
+EFI_STATUS
+RapidStartSmmEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ RAPID_START_GLOBAL_NVS_AREA_PROTOCOL *RapidStartGlobalNvsAreaProtocol;
+ EFI_SMM_SX_DISPATCH_PROTOCOL *SxDispatchProtocol;
+ EFI_SMM_SX_DISPATCH_CONTEXT EntryDispatchContext;
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ EFI_SMM_SW_DISPATCH_PROTOCOL *SwDispatch;
+ EFI_SMM_SW_DISPATCH_CONTEXT SwContext;
+#endif
+ EFI_HANDLE DispatchHandle;
+ EFI_STATUS Status;
+#ifdef ISCT_FLAG
+ ISCT_NVS_AREA_PROTOCOL *IsctNvsAreaProtocol;
+#endif //ISCT_FLAG
+
+ DEBUG ((EFI_D_INFO, "RapidStartSmmEntryPoint()\n"));
+
+ Status = gBS->LocateProtocol (
+ &gRapidStartGlobalNvsAreaProtocolGuid,
+ NULL,
+ (VOID **) &RapidStartGlobalNvsAreaProtocol
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_INFO, "No RapidStart info protocol available\n"));
+ ASSERT (0);
+ return Status;
+ }
+
+#ifdef ISCT_FLAG
+ mIsctNvs = NULL;
+ ///
+ /// Locate ISCT Global NVS protocol.
+ ///
+ Status = gBS->LocateProtocol (
+ &gIsctNvsAreaProtocolGuid,
+ NULL,
+ &IsctNvsAreaProtocol
+ );
+ if (!EFI_ERROR (Status)) {
+ mIsctNvs = IsctNvsAreaProtocol->Area;
+ mIsctNvs->IsctOverWrite = 0;
+ }
+#endif //ISCT_FLAG
+ mRapidStartData = RapidStartGlobalNvsAreaProtocol->RapidStartData;
+ mRapidStartGlobalNvs = RapidStartGlobalNvsAreaProtocol->Area;
+ mRapidStartMemData = RAPID_START_MEM_DATA_PTR (mRapidStartData);
+ mRapidStartZeroPageBitMap = RAPID_START_ZERO_PAGE_BITMAP_PTR (mRapidStartData);
+ mCrc32Record = RAPID_START_CRC32_RECORD_PTR (mRapidStartData);
+
+ DEBUG ((EFI_D_INFO, "RapidStartGlobalNvs: %x\n", mRapidStartGlobalNvs));
+ DEBUG ((EFI_D_INFO, "RapidStartMemData: %x\n", mRapidStartMemData));
+ DEBUG ((EFI_D_INFO, "RapidStartZeroPageBitMap: %x\n", mRapidStartZeroPageBitMap));
+ DEBUG ((EFI_D_INFO, "CRC32 record: %x\n", mCrc32Record));
+
+ mRapidStartMemData->OsWakeTimeEnabled = 0;
+
+ Status = gBS->LocateProtocol (
+ &gEfiSmmSxDispatchProtocolGuid,
+ NULL,
+ (VOID **) &SxDispatchProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Register S3 entry phase call back function
+ ///
+ EntryDispatchContext.Type = SxS3;
+ EntryDispatchContext.Phase = SxEntry;
+ Status = SxDispatchProtocol->Register (
+ SxDispatchProtocol,
+ RapidStartS3EntryCallback,
+ &EntryDispatchContext,
+ &DispatchHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+
+#ifdef RAPID_START_WHOLE_MEMORY_CHECK
+ ///
+ /// Locate the SMM SW dispatch protocol
+ ///
+ Status = gBS->LocateProtocol (&gEfiSmmSwDispatchProtocolGuid, NULL, &SwDispatch);
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Register SWSMI handler
+ ///
+ DEBUG ((EFI_D_INFO, "Register RapidStart SwSmi: %x\n", SW_SMI_WHOLE_MEMORY_CHECK));
+ SwContext.SwSmiInputValue = SW_SMI_WHOLE_MEMORY_CHECK;
+ Status = SwDispatch->Register (
+ SwDispatch,
+ RapidStartSwSmiCallback,
+ &SwContext,
+ &DispatchHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+ return EFI_SUCCESS;
+}
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.cif b/ReferenceCode/RapidStart/Smm/RapidStartSmm.cif
new file mode 100644
index 0000000..d165c6b
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "RapidStartSmm"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\RapidStart\Smm"
+ RefName = "RapidStartSmm"
+[files]
+"RapidStartSmm.sdl"
+"RapidStartSmm.h"
+"RapidStartSmm.mak"
+"RapidStartSmm.c"
+"RapidStartSmm.dxs"
+"RapidStartSmm.inf"
+"x64\RapidStartAsm.asm"
+<endComponent>
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.dxs b/ReferenceCode/RapidStart/Smm/RapidStartSmm.dxs
new file mode 100644
index 0000000..af3643c
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.dxs
@@ -0,0 +1,47 @@
+/** @file
+ Dependency expression source file.
+
+@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
+
+**/
+
+
+//
+// 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 (SmmSxDispatch)
+#include EFI_PROTOCOL_DEPENDENCY (RapidStartGlobalNvsArea)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+#endif
+
+DEPENDENCY_START
+ EFI_SMM_BASE_PROTOCOL_GUID AND
+ EFI_SMM_SX_DISPATCH_PROTOCOL_GUID AND
+ EFI_VARIABLE_ARCH_PROTOCOL_GUID AND
+ RAPID_START_GLOBAL_NVS_AREA_PROTOCOL_GUID
+DEPENDENCY_END
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.h b/ReferenceCode/RapidStart/Smm/RapidStartSmm.h
new file mode 100644
index 0000000..c5fb174
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.h
@@ -0,0 +1,47 @@
+/** @file
+ Header file for RapidStart SMM S3 Handler.
+
+@copyright
+ Copyright (c) 2011 - 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 an 'Intel Peripheral Driver' and uniquely
+ identified as "Intel Mobile Silicon Support Module" and is
+ licensed for Intel Mobile CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+**/
+#ifndef _RAPID_START_SMM_H_
+#define _RAPID_START_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"
+//
+// Driver Consumed Protocol Prototypes
+//
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)
+#include EFI_PROTOCOL_DEPENDENCY (SmmBase)
+#include EFI_PROTOCOL_DEPENDENCY (SmmSxDispatch)
+#include EFI_PROTOCOL_DEPENDENCY (DevicePath)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+
+UINT64
+ScanValueMem64 (
+ VOID* BaseAddress,
+ UINT64 PageSize,
+ UINT64 Index
+);
+
+#endif
+#endif
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.inf b/ReferenceCode/RapidStart/Smm/RapidStartSmm.inf
new file mode 100644
index 0000000..e9017a5
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.inf
@@ -0,0 +1,104 @@
+## @file
+# Component description file for the RapidStart SMM module.
+#
+#@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 = RapidStartSmm
+FILE_GUID = 43172851-cf7e-4345-9fe0-d7012bb17b88
+COMPONENT_TYPE = RT_DRIVER
+
+[sources.common]
+ RapidStartSmm.c
+ RapidStartSmm.h
+ x64/RapidStartAsm.asm
+
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGlueSmmDriverEntryPoint.c
+
+[includes.common]
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Framework
+ .
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Core/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Pcd
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Library
+ $(EDK_SOURCE)/Foundation/Cpu/Pentium/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include/Library
+ $(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
+#
+# Uncomment the following ISCT include directories if ISCT is supported
+#
+ $(EFI_SOURCE)/Platform/Isct
+
+[libraries.common]
+ EdkProtocolLib
+ ArchProtocolLib
+ EdkFrameworkProtocolLib
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueDxeMemoryAllocationLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkIIGlueSmmRuntimeDxeReportStatusCodeLib
+ EdkIIGlueBasePciLibPciExpress
+ EdkIIGlueUefiLib
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiDevicePathLib
+ EfiProtocolLib
+ RapidStartCommonLib
+ RapidStartProtocolLib
+ RapidStartGuidLib
+ PchPlatformLib
+#
+# Uncomment the following ISCT include directories if ISCT is supported
+#
+ IsctProtocolLib
+ IsctGuidLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT=_ModuleEntryPoint
+ DPX_SOURCE=RapidStartSmm.dxs
+
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartSmmEntryPoint
+ C_FLAGS = $(C_FLAGS) -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__
diff --git a/ReferenceCode/RapidStart/Smm/RapidStartSmm.mak b/ReferenceCode/RapidStart/Smm/RapidStartSmm.mak
new file mode 100644
index 0000000..efa04b7
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.mak
@@ -0,0 +1,130 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/RapidStartSmm/RapidStartSmm.mak 3 10/15/12 5:38a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 10/15/12 5:38a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartSmm/RapidStartSmm.mak $
+#
+# 3 10/15/12 5:38a Bensonlai
+# [Category] Improvement
+# [Severity] Important
+# [Description] Rename all IFFS sting to Rapid Start.
+# [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
+#
+# 2 9/26/12 3:33a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Update Intel Rapid Start Technology Framework Reference
+# Code Beta Version 0.7.0.
+# [Description] ReferenceCode\RapidStart\*.*, RapidStartPeiLib.h
+#
+# 1 4/19/12 8:07a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+
+EDK : RapidStartSmm
+
+RapidStartSmm : $(BUILD_DIR)\RapidStartSmm.mak RapidStartSmmBin
+
+$(BUILD_DIR)\RapidStartSmm.mak : $(RapidStartSmm_DIR)\$(@B).cif $(RapidStartSmm_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(RapidStartSmm_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+RapidStartSmm_INCLUDES=\
+ $(RAPIDSTART_INCLUDES)\
+ $(INTEL_PCH_INCLUDES)\
+ $(INTEL_MCH_INCLUDES)\
+ $(EdkIIGlueLib_INCLUDES)\
+ /I$(IntelPlatformProtocolLib_DIR)\
+!IF "$(ISCT_PLATFORM_SUPPORT)"=="1"
+ /I$(ISCT_PLATFORM_DIR)\
+!ENDIF
+
+RapidStartSmm_DEFINES = $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=RapidStartSmmEntryPoint"\
+ /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__ \
+
+RapidStartSmm_LIB_LINKS =\
+ $(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)\
+ $(RapidStartCommonSmmLib_LIB)\
+ $(RapidStartProtocolLib_LIB)\
+ $(PchPlatformSmmLib_LIB)\
+ $(RapidStartGuidLib_LIB)\
+ $(INTEL_PCH_PROTOCOL_LIB)\
+!IF "$(ISCT_PLATFORM_SUPPORT)"=="1"
+ $(IsctGuidLib_LIB)\
+ $(IsctProtocolLib_LIB)\
+!ENDIF
+
+RapidStartSmmBin: $(RapidStartSmm_LIB_LINKS)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\RapidStartSmm.mak all \
+ "MY_INCLUDES=$(RapidStartSmm_INCLUDES)" \
+ "MY_DEFINES=$(RapidStartSmm_DEFINES)" \
+ GUID=43172851-cf7e-4345-9fe0-d7012bb17b88\
+ ENTRY_POINT=_ModuleEntryPoint \
+ TYPE=BS_DRIVER\
+ EDKIIModule=SMMDRIVER\
+ DEPEX1=$(RapidStartSmm_DIR)\RapidStartSmm.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/ReferenceCode/RapidStart/Smm/RapidStartSmm.sdl b/ReferenceCode/RapidStart/Smm/RapidStartSmm.sdl
new file mode 100644
index 0000000..4660102
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/RapidStartSmm.sdl
@@ -0,0 +1,97 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, 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/RapidStartSmm/RapidStartSmm.sdl 3 12/27/12 1:19a Bensonlai $
+#
+# $Revision: 3 $
+#
+# $Date: 12/27/12 1:19a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartSmm/RapidStartSmm.sdl $
+#
+# 3 12/27/12 1:19a Bensonlai
+# [TAG] None
+# [Category] Improvement
+# [Description] Change the SMI port to 0xB5 for
+# AMI_SW_SMI_WHOLE_MEMORY_CHECK.
+# [Files] RapidStartSmm.sdl
+#
+# 2 8/14/12 7:52a Yurenlai
+# [TAG] None
+# [Category] Improvement
+# [Severity] Important
+# [Description] Support ASLPREPROCESS_FLAG to include Iintel RC flags.
+# [Description] RapidStart.sdl, RapidStartSmm.sdl
+#
+# 1 4/19/12 8:07a Yurenlai
+# Initial check in.
+#
+#*************************************************************************
+TOKEN
+ Name = "RapidStartSmm_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable RapidStartSmm support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "AMI_SW_SMI_WHOLE_MEMORY_CHECK"
+ Value = "0xB5"
+ Help = "SWSMI# for whole memory check."
+ TokenType = Integer
+ TargetH = Yes
+ TargetMAK = Yes
+ Token = "WHOLE_MEMORY_CHECK" "=" "1"
+End
+
+PATH
+ Name = "RapidStartSmm_DIR"
+End
+
+MODULE
+ Help = "Includes RapidStartSmm.mak to Project"
+ File = "RapidStartSmm.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\RapidStartSmm.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/D SW_SMI_WHOLE_MEMORY_CHECK=$(AMI_SW_SMI_WHOLE_MEMORY_CHECK)"
+ Parent = "INTEL_IRST_RC_FLAGS"
+ Token = "WHOLE_MEMORY_CHECK" "=" "1"
+ InvokeOrder = AfterParent
+End
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#************************************************************************* \ No newline at end of file
diff --git a/ReferenceCode/RapidStart/Smm/x64/RapidStartAsm.asm b/ReferenceCode/RapidStart/Smm/x64/RapidStartAsm.asm
new file mode 100644
index 0000000..84c501f
--- /dev/null
+++ b/ReferenceCode/RapidStart/Smm/x64/RapidStartAsm.asm
@@ -0,0 +1,56 @@
+;
+; This file contains an 'Intel Peripheral Driver' and is
+; licensed for Intel CPUs and chipsets under the terms of your
+; license agreement with Intel or your vendor. This file may
+; be modified by the user, subject to additional terms of the
+; license agreement
+;
+ page ,132
+ title RapidStart ARCHITECTURAL SMM ASSEMBLY HOOKS
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2005 -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.
+;
+; Module Name:
+;
+; RapidStartAsm.asm
+;
+; Abstract:
+;
+; Assembly code of the implementation of X64 RapidStart
+;
+;------------------------------------------------------------------------------
+
+text SEGMENT
+
+;------------------------------------------------------------------------------
+; UINT64
+; ScanValueMem64 (
+; VOID* BaseAddress,
+; UINT64 PageSize,
+; UINT64 Index
+; )
+;------------------------------------------------------------------------------
+ScanValueMem64 PROC USES rbx rsi rdi
+ xor rsi, rsi
+ dec rsi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repe scasq
+ mov rax, rsi
+ lea rbx, [rdi - 8]
+ cmovne rax, rbx
+ ret
+ScanValueMem64 ENDP
+
+text ENDS
+END
+