summaryrefslogtreecommitdiff
path: root/Core/EM/OFBD
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 /Core/EM/OFBD
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Core/EM/OFBD')
-rw-r--r--Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.c176
-rw-r--r--Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.cif11
-rw-r--r--Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.h64
-rw-r--r--Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.mak68
-rw-r--r--Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.sdl55
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c259
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif11
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h71
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak75
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl63
-rw-r--r--Core/EM/OFBD/DEFCFG/DefCfg.c269
-rw-r--r--Core/EM/OFBD/DEFCFG/DefCfg.cif11
-rw-r--r--Core/EM/OFBD/DEFCFG/DefCfg.h72
-rw-r--r--Core/EM/OFBD/DEFCFG/DefCfg.mak76
-rw-r--r--Core/EM/OFBD/DEFCFG/DefCfg.sdl56
-rw-r--r--Core/EM/OFBD/MEUD/InitMEUDString.c243
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.c519
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.cif13
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.dxs53
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.h98
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.mak78
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/AutoUpdate.sdl103
-rw-r--r--Core/EM/OFBD/MEUD/MEAU/MERegion.binbin0 -> 8388608 bytes
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.c746
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.chmbin0 -> 34024 bytes
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.cif19
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.h198
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.mak123
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.sd112
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.sdl121
-rw-r--r--Core/EM/OFBD/MEUD/MEUD.unibin0 -> 6004 bytes
-rw-r--r--Core/EM/OFBD/MEUD/MEUD_MSG.c119
-rw-r--r--Core/EM/OFBD/OEMCMD/OEMCMD.c368
-rw-r--r--Core/EM/OFBD/OEMCMD/OEMCMD.cif11
-rw-r--r--Core/EM/OFBD/OEMCMD/OEMCMD.h72
-rw-r--r--Core/EM/OFBD/OEMCMD/OEMCMD.mak74
-rw-r--r--Core/EM/OFBD/OEMCMD/OEMCMD.sdl56
-rw-r--r--Core/EM/OFBD/OEMOAHandle/OEMOAHandle.c233
-rw-r--r--Core/EM/OFBD/OEMOAHandle/OEMOAHandle.cif11
-rw-r--r--Core/EM/OFBD/OEMOAHandle/OEMOAHandle.h64
-rw-r--r--Core/EM/OFBD/OEMOAHandle/OEMOAHandle.mak68
-rw-r--r--Core/EM/OFBD/OEMOAHandle/OEMOAHandle.sdl56
-rw-r--r--Core/EM/OFBD/OEMPWDCK/OEMPwdCk.c250
-rw-r--r--Core/EM/OFBD/OEMPWDCK/OEMPwdCk.cif11
-rw-r--r--Core/EM/OFBD/OEMPWDCK/OEMPwdCk.h74
-rw-r--r--Core/EM/OFBD/OEMPWDCK/OEMPwdCk.mak76
-rw-r--r--Core/EM/OFBD/OEMPWDCK/OEMPwdCk.sdl65
-rw-r--r--Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.c253
-rw-r--r--Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.cif11
-rw-r--r--Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.h72
-rw-r--r--Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.mak74
-rw-r--r--Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.sdl76
-rw-r--r--Core/EM/OFBD/OEMROMID/OEMROMID.c220
-rw-r--r--Core/EM/OFBD/OEMROMID/OEMROMID.cif11
-rw-r--r--Core/EM/OFBD/OEMROMID/OEMROMID.h74
-rw-r--r--Core/EM/OFBD/OEMROMID/OEMROMID.mak75
-rw-r--r--Core/EM/OFBD/OEMROMID/OEMROMID.sdl102
-rw-r--r--Core/EM/OFBD/OEMSETUP/OEMSETUP.c361
-rw-r--r--Core/EM/OFBD/OEMSETUP/OEMSETUP.cif11
-rw-r--r--Core/EM/OFBD/OEMSETUP/OEMSETUP.h74
-rw-r--r--Core/EM/OFBD/OEMSETUP/OEMSETUP.mak87
-rw-r--r--Core/EM/OFBD/OEMSETUP/OEMSETUP.sdl71
-rw-r--r--Core/EM/OFBD/OFBD.c415
-rw-r--r--Core/EM/OFBD/OFBD.cif24
-rw-r--r--Core/EM/OFBD/OFBD.dxs84
-rw-r--r--Core/EM/OFBD/OFBD.h647
-rw-r--r--Core/EM/OFBD/OFBD.mak111
-rw-r--r--Core/EM/OFBD/OFBD.sdl68
-rw-r--r--Core/EM/OFBD/OFBD_Help.chmbin0 -> 55276 bytes
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.c343
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.chmbin0 -> 29136 bytes
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.cif12
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.h68
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.mak76
-rw-r--r--Core/EM/OFBD/SecureFlash/SecureFlash.sdl51
-rw-r--r--Core/EM/OFBD/StdEC/StdEC.c531
-rw-r--r--Core/EM/OFBD/StdEC/StdEC.cif11
-rw-r--r--Core/EM/OFBD/StdEC/StdEC.h102
-rw-r--r--Core/EM/OFBD/StdEC/StdEC.mak75
-rw-r--r--Core/EM/OFBD/StdEC/StdEC.sdl39
80 files changed, 9600 insertions, 0 deletions
diff --git a/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.c b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.c
new file mode 100644
index 0000000..ff9a63a
--- /dev/null
+++ b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.c
@@ -0,0 +1,176 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/BATTERYCHECK/BATTERYCHECK.c 1 10/11/12 2:27a Terrylin $
+//
+// $Revision: 1 $
+//
+// $Date: 10/11/12 2:27a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/BATTERYCHECK/BATTERYCHECK.c $
+//
+// 1 10/11/12 2:27a Terrylin
+// Initial check-in for OEM can control AC/Battery status check rule
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: BATTERYCHECK.c
+//
+// Description:
+//
+// This function is used for OEM can decided AFU flash behavior, when
+// AC/Battery is under warning status and can output the OEM String message
+// to the flash utility.
+//
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "BATTERYCHECK.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDBATTERYCHECK
+//
+// Description: OFBD AC/Battery check
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDBatteryCheck(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if BATTERYCHECK_SAMPLE_TEST
+
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_5B_AC_BATTERY_STRUCT *AC_BatteryPtr;
+
+ char *ErrorMsg_1 = "AC adapter is not connected.For an update, the AC adapter has to be connected.";
+ char *ErrorMsg_2 = "There is no installed battery or the remaining charge level of the battery is lower than 60%%.Check your battery.";
+ char *ErrorMsg_3 = "There is no installed battery or the remaining charge level of the battery is lower than 30%%.Check your battery.";
+ char *ErrorMsg_4 = "No support this version of flash Common Interface.";
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ AC_BatteryPtr = (OFBD_TC_5B_AC_BATTERY_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ switch(AC_BatteryPtr->dbGetSts)
+ {
+ //
+ // Please add your code here +>>>
+ //
+ case OFBD_TC_AC_BAT_INFO_REQ:
+ /*
+ //+>>>if AC/Battery has an issue please add your message here
+ Strcpy (pOFBDTblEnd , ErrorMsg_1);
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ AC_BatteryPtr->dbRetSts |= OFBD_RS_AC_BAT_ERR ;
+ //<<<
+ */
+ AC_BatteryPtr->dbRetSts |= OFBD_RS_AC_BAT_OK;
+ break;
+
+ default:
+ AC_BatteryPtr->dbRetSts |= OFBD_RS_AC_BAT_OK;
+ break;
+ //
+ // Please add your code here <<<+
+ //
+
+ }
+
+
+#endif // #ifdef BATTERYCHECK_SAMPLE_TEST
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BatteryCheckEntry
+//
+// Description: OFBD Battery Check Header Handle Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BatteryCheckEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_AC_BAT)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_AC_BAT)
+ {
+ if(OFBDBatteryCheck(pOFBDHdr) == EFI_SUCCESS)
+ {
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.cif b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.cif
new file mode 100644
index 0000000..291c5db
--- /dev/null
+++ b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "AC/Battery checking"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\BATTERYCHECK\"
+ RefName = "OFBD_BATTERYCHECK"
+[files]
+"BATTERYCHECK.sdl"
+"BATTERYCHECK.mak"
+"BATTERYCHECK.h"
+"BATTERYCHECK.c"
+<endComponent>
diff --git a/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.h b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.h
new file mode 100644
index 0000000..2903f92
--- /dev/null
+++ b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.h
@@ -0,0 +1,64 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/BATTERYCHECK/BATTERYCHECK.h 1 10/11/12 2:27a Terrylin $
+//
+// $Revision: 1 $
+//
+// $Date: 10/11/12 2:27a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/BATTERYCHECK/BATTERYCHECK.h $
+//
+// 1 10/11/12 2:27a Terrylin
+// Initial check-in for OEM can control AC/Battery status check rule
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: BATTERYCHECK.h
+//
+// Description: Header file for the BATTERYCHECK
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_EC_BATTERY_CHECK_STATUS_H_
+#define _EFI_EC_BATTERY_CHECK_STATUS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//**********************************************************************//
+//**********************************************************************//
diff --git a/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.mak b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.mak
new file mode 100644
index 0000000..eb28d80
--- /dev/null
+++ b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.mak
@@ -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/OFBD/BATTERYCHECK/BATTERYCHECK.mak 1 10/11/12 2:27a Terrylin $
+#
+# $Revision: 1 $
+#
+# $Date: 10/11/12 2:27a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/BATTERYCHECK/BATTERYCHECK.mak $
+#
+# 1 10/11/12 2:27a Terrylin
+# Initial check-in for OEM can control AC/Battery status check rule
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: BATTERYCHECK.mak
+#
+# Description: Make file for the BatteryCheck.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : BATTERYCHECK
+
+BATTERYCHECK : $(BUILD_DIR)\BATTERYCHECK.mak BATTERYCHECKBin
+
+$(BUILD_DIR)\BATTERYCHECK.mak : $(OFBD_BATTERYCHECK_DIR)\$(@B).cif $(OFBD_BATTERYCHECK_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_BATTERYCHECK_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+BATTERYCHECKBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\BATTERYCHECK.mak all\
+ NAME=BATTERYCHECK \
+ TYPE=LIBRARY LIBRARY_NAME=$(BATTERYCHECKLIB)
+
+$(BATTERYCHECKLIB) : BATTERYCHECK
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.sdl b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.sdl
new file mode 100644
index 0000000..2aa5df0
--- /dev/null
+++ b/Core/EM/OFBD/BATTERYCHECK/BATTERYCHECK.sdl
@@ -0,0 +1,55 @@
+TOKEN
+ Name = "AC_BATTERY_CHECK_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable AC/Battery Check support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "BATTERYCHECKLIB"
+ Value = "$(BUILD_DIR)\BATTERYCHECK.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[AC/Battery Check Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "BATTERYCHECK_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test AC/Battery Check Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "AC_BATTERY_CHECK_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_BATTERYCHECK_DIR"
+End
+
+MODULE
+ Help = "Includes BATTERYCHECK.mak to Project"
+ File = "BATTERYCHECK.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\BATTERYCHECK.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "BatteryCheckEntry,"
+ Parent = "OFBDPartsList"
+ Token = "AC_BATTERY_CHECK_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c
new file mode 100644
index 0000000..80889d9
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c
@@ -0,0 +1,259 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/CleanErrorLog/CleanErrorLog.c 3 10/06/11 1:28a Terrylin $
+//
+// $Revision: 3 $
+//
+// $Date: 10/06/11 1:28a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.c $
+//
+// 3 10/06/11 1:28a Terrylin
+// Fix the build error, when Gpnv Error Logging module didn't enable.
+//
+// 2 3/16/11 10:32p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] CleanErrorLog.mak
+// CleanErrorLog.h
+// CleanErrorLog.c
+//
+// 1 1/17/11 3:56a Terrylin
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CleanErrorLog.c
+//
+// Description:
+// This function is used to Clean Error Log. For example,AFU will call this function to clean error log when
+// /CLNEVNLOG is issued.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include <Protocol\SmiFlash.h>
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "CleanErrorLog.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+EFI_SMI_FLASH_PROTOCOL *mSmiFlash = NULL;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogCallback
+//
+// Description: Locate SmiFlash protocol callback
+//
+// Input:
+// IN EFI_EVENT Event
+// IN VOID *Context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogCallback(
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+
+ pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogInSmm
+//
+// Description: OFBD Clear event log InSmm Function
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogInSmm(VOID)
+{
+ EFI_STATUS Status;
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+
+ Status = pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+ if (EFI_ERROR(Status)){
+ EFI_EVENT SmiFlashCallbackEvt;
+ VOID *Reg;
+ RegisterProtocolCallback(
+ &gEfiSmiFlashProtocolGuid, CleanErrorLogCallback,
+ NULL,&SmiFlashCallbackEvt, &Reg
+ );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDCleanErrorLogHandle
+//
+// Description: OFBD Clean Gpnv Error Log Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDCleanErrorLogHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if CLEAN_GPNV_ERROR_LOG_SAMPLE_TEST
+
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_58_CEL_STRUCT *CELStructPtr;
+ #if defined(FV_ERROR_LOGGING_BASE) && defined(FV_ERROR_LOGGING_SIZE)
+ FUNC_BLOCK FuncBlock;
+ UINT8 pType1Header[16];
+ #endif
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ CELStructPtr = (OFBD_TC_58_CEL_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ // Is need to Clean Gpnv Error Log
+ if (CELStructPtr->dwFunSts == OFBD_TC_CEL_FUNC_REQ)
+ {
+ // Check Gpnv Error Logging module whether support or not
+ #if !defined(FV_ERROR_LOGGING_BASE) || !defined(FV_ERROR_LOGGING_SIZE)
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_BIOS_NOT_SUPPORT;
+ #else
+ //
+ // Reference from "ErrorLogging/SmiGpnv/SmiGpnv.c" file code +>>>
+ //
+ // SS: Alaska;$/Alaska/SOURCE/Modules/ErrorLogging;
+ //
+ // Label 4.6.3.6_GPNV_ERRLOG_2.1a
+ //
+ // Enable Flash Write.
+ Status = mSmiFlash->EnableFlashWrite(&FuncBlock);
+ // Read flash to preserve EFI_GPNV_ERROR_HEADER_TYPE1 header.
+ FuncBlock.BufAddr = (UINTN)&pType1Header;
+ FuncBlock.BlockSize = 0x10; // EFI_GPNV_ERROR_HEADER_TYPE1
+ FuncBlock.BlockAddr = ((UINT32)FV_ERROR_LOGGING_BASE & \
+ (FLASH_SIZE - 1)); //0 starts at 0xfff0_0000
+ FuncBlock.ErrorCode = 0;
+ Status = mSmiFlash->ReadFlash(&FuncBlock);
+ // Erase Error Logging GPNV.
+ FuncBlock.BlockSize = FV_ERROR_LOGGING_SIZE; //max size 0xffff
+ FuncBlock.BufAddr = 0;
+ Status = mSmiFlash->EraseFlash(&FuncBlock); // Write Flash
+ // Restore EFI_GPNV_ERROR_HEADER_TYPE1 header.
+ FuncBlock.BlockSize = 0x10; //EFI_GPNV_ERROR_HEADER_TYPE1
+ FuncBlock.BufAddr = (UINTN)&pType1Header;
+ Status = mSmiFlash->WriteFlash(&FuncBlock); // Write Flash
+ // Disable Flash Write.
+ Status = mSmiFlash->DisableFlashWrite(&FuncBlock);
+ //
+ // <<<+
+ //
+ if (EFI_ERROR (Status))
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_ERROR;
+ else
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_OK;
+ #endif
+ }
+
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogEntry
+//
+// Description: OFBD Clean Gpnv Error Log Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_58_CEL_STRUCT *CELStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ CELStructPtr = (OFBD_TC_58_CEL_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_ERR_LOG)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_CLN_ERR_LOG)
+ {
+ if(OFBDCleanErrorLogHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM Default Command Configuration Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif
new file mode 100644
index 0000000..a04fe75
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "Clean Gpnv Error Log"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\CleanErrorLog\"
+ RefName = "OFBD_CLEANERRORLOG"
+[files]
+"CleanErrorLog.sdl"
+"CleanErrorLog.mak"
+"CleanErrorLog.h"
+"CleanErrorLog.c"
+<endComponent>
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h
new file mode 100644
index 0000000..466a1ff
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h
@@ -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/OFBD/CleanErrorLog/CleanErrorLog.h 2 3/16/11 10:32p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:32p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.h $
+//
+// 2 3/16/11 10:32p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] CleanErrorLog.mak
+// CleanErrorLog.h
+// CleanErrorLog.c
+//
+// 1 1/17/11 3:56a Terrylin
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CleanErrorLog.h
+//
+// Description: Header file for the CleanErrorLog
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_CLEANERRORLOG_H_
+#define _EFI_CLEANERRORLOG_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak
new file mode 100644
index 0000000..1055d73
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak
@@ -0,0 +1,75 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/CleanErrorLog/CleanErrorLog.mak 2 3/16/11 10:32p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:32p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.mak $
+#
+# 2 3/16/11 10:32p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] CleanErrorLog.mak
+# CleanErrorLog.h
+# CleanErrorLog.c
+#
+# 1 1/17/11 3:56a Terrylin
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CleanErrorLog.mak
+#
+# Description: Make file for the CleanErrorLog.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : CLEANERRORLOG
+
+CLEANERRORLOG : $(BUILD_DIR)\CLEANERRORLOG.mak CLEANERRORLOGBin
+
+$(BUILD_DIR)\CLEANERRORLOG.mak : $(OFBD_CLEANERRORLOG_DIR)\$(@B).cif $(OFBD_CLEANERRORLOG_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_CLEANERRORLOG_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CLEANERRORLOGBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\CLEANERRORLOG.mak all\
+ NAME=CLEANERRORLOG \
+ TYPE=LIBRARY LIBRARY_NAME=$(CLEANERRORLOGLIB)
+
+$(CLEANERRORLOGLIB) : CLEANERRORLOG
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl
new file mode 100644
index 0000000..4a26863
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl
@@ -0,0 +1,63 @@
+TOKEN
+ Name = "CLEAN_ERROR_LOG_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable Clean Gpnv Error Log support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "CLEANERRORLOGLIB"
+ Value = "$(BUILD_DIR)\CLEANERRORLOG.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[Clean Gpnv Error Log Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "CLEAN_GPNV_ERROR_LOG_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test Clean Gpnv Error Log Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_CLEANERRORLOG_DIR"
+End
+
+MODULE
+ Help = "Includes CleanErrorLog.mak to Project"
+ File = "CleanErrorLog.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\CLEANERRORLOG.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "CleanErrorLogEntry,"
+ Parent = "OFBDPartsList"
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "CleanErrorLogInSmm,"
+ Parent = "OFBDInSmmFuncList"
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.c b/Core/EM/OFBD/DEFCFG/DefCfg.c
new file mode 100644
index 0000000..5923a0b
--- /dev/null
+++ b/Core/EM/OFBD/DEFCFG/DefCfg.c
@@ -0,0 +1,269 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.c 9 8/16/13 3:13a Terrylin $
+//
+// $Revision: 9 $
+//
+// $Date: 8/16/13 3:13a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.c $
+//
+// 9 8/16/13 3:13a Terrylin
+// [Description] Correct the description error.
+//
+// 8 8/07/13 11:21p Terrylin
+// [Description] Add more description.
+//
+// 7 7/31/13 4:49a Terrylin
+// [TAG] EIP125898
+// [Category] New Feature
+// [Description] Add the AFU's /Kn and /Ln two commands status control.
+//
+// 6 8/06/12 7:00a Terrylin
+// [TAG] EIP96286
+// [Category] Improvement
+// [Description] Add the template codes for SMBIOS module DMI data
+// preserve support.
+// [Files] DefCfg.sdl
+// DefCfg.c
+//
+// 5 2/22/12 4:37a Terrylin
+// Add the GAN command support sample
+//
+// 4 3/16/11 10:37p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] DefCfg.mak
+// DefCfg.h
+// DefCfg.c
+//
+// 3 12/17/10 3:21a Terrylin
+// Fix sample code is wrong problem.
+//
+// 2 6/07/10 11:22p Terrylin
+// Fix sample code is wrong problem.
+//
+// 1 5/06/10 2:22a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: DefCfg.c
+//
+// Description:
+// OFBD Default Command Configuration provides BIOS an oppertunity to override end user issued command in AFU.
+//
+// For example, BIOS could disable /k command even user issued it in AFU, or automatically enable /b when /p
+// is issued.
+//
+// For AFU¡¦s "/Ln" and "/Kn" two commands parameter identify. That AFU will replace the OFBD_EXT_TBL_END data
+// from 0xFFFF55AA to OFBD_TC_51_DC_EXT_STRUCT. Therefore, BIOS can through the "ddIndexCfg" flag to identify
+// who is this command structure. (The AFU version 3.05.1 or later supports.)
+//
+// Please reference OFBDDEFCFGHandle for more details.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "DefCfg.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDDEFCFGHandle
+//
+// Description: OFBD Default Command Configuration Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDDEFCFGHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_51_DC_STRUCT *DCStructPtr;
+ OFBD_TC_51_DC_EXT_STRUCT *DCExtStructPtr;
+ UINT32 ExtAddr;
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ DCStructPtr = (OFBD_TC_51_DC_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ DCExtStructPtr = (OFBD_TC_51_DC_EXT_STRUCT *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size) - sizeof(OFBD_END));
+ ExtAddr = *(UINT32 *)((UINT8 *)pOFBDTblEnd - sizeof(OFBD_END));
+ if (ExtAddr == OFBD_EXT_TBL_END)
+ DCExtStructPtr = NULL;
+
+#if SMBIOS_DMIEDIT_DATA_LOC == 2
+
+ if ((DCStructPtr->ddRetSts & OFBD_TC_CFG_N) && (DCStructPtr->ddRetSts & OFBD_TC_CFG_R) && (DCStructPtr->ddRetSts & OFBD_TC_CFG_CAPSULE))
+ {
+ EFI_GUID gEfiSmbiosNvramGuid = {0x4b3082a3, 0x80c6, 0x4d7e, { 0x9c, 0xd0, 0x58, 0x39, 0x17, 0x26, 0x5d, 0xf1 }};
+ CHAR16 *PreserveSmbiosNvramVar = L"PreserveSmbiosNvramVar";
+ UINTN Size = sizeof (UINT8);
+ UINT32 PreserveSmbiosNvram;
+
+ // Set PreserveSmbiosNvram
+ pRS->SetVariable (
+ PreserveSmbiosNvramVar,
+ &gEfiSmbiosNvramGuid,
+ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ Size,
+ &PreserveSmbiosNvram
+ );
+ }
+
+#endif
+
+#if DEF_CFG_SAMPLE_TEST
+ //
+ // OEM add
+ //
+
+ // Sample : always cancel /K command
+ if (DCStructPtr->ddRetSts & OFBD_TC_CFG_K)
+ {
+ DCStructPtr->ddExtCfg |= OFBD_TC_CFG_K;
+ }
+
+ // Sample : add new /B command when /P has issued
+ if (DCStructPtr->ddRetSts & OFBD_TC_CFG_P)
+ {
+ DCStructPtr->ddRetSts |= OFBD_TC_CFG_B;
+ }
+
+ // Sample : For GAN command
+ // If ddRetSts equals to "0xFFFFFFFF", this means BIOS supply "/GAN" command.
+ if (DCStructPtr->ddRetSts & OFBD_TC_CFG_GAN)
+ {
+ DCStructPtr->ddRetSts = 0xFFFFFFFF;
+ }
+
+ // Sample : For /Ln or /Kn command status setting
+ if (DCExtStructPtr)
+ {
+ OFBD_TC_51_DC_EXT_STRUCT *NStructPtr = DCExtStructPtr;
+
+ do
+ {
+ // Check current struct is Ln command or not
+ if (NStructPtr->ddIndexCfg == OFBD_TC_CFG_LN)
+ {
+ // Sample : add new /L1 command when /L0 command is issued
+ if (NStructPtr->ddExtCfg & BIT00)
+ {
+ NStructPtr->ddExtCfg |= BIT01;
+ }
+ }
+
+ // Check current struct is Kn command or not
+ if (NStructPtr->ddIndexCfg == OFBD_TC_CFG_KN)
+ {
+ // Sample : always cancel /K0 command
+ if (NStructPtr->ddExtCfg & BIT00)
+ {
+ NStructPtr->ddIgnCfg |= BIT00;
+ }
+ }
+ // Ponit to next structure
+ NStructPtr++;
+ ExtAddr = *(UINT32 *)NStructPtr;
+ }while(ExtAddr && ExtAddr != 0xFFFFFFFF);
+ }
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DEFCFGEntry
+//
+// Description: OFBD Default Command Configuration Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DEFCFGEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_51_DC_STRUCT *DCStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ DCStructPtr = (OFBD_TC_51_DC_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_CFG)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_AFUDEFCFG)
+ {
+ if(OFBDDEFCFGHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM Default Command Configuration Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.cif b/Core/EM/OFBD/DEFCFG/DefCfg.cif
new file mode 100644
index 0000000..a4f0d7b
--- /dev/null
+++ b/Core/EM/OFBD/DEFCFG/DefCfg.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "AFU Default Command Configuration"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\DEFCFG\"
+ RefName = "OFBD_DEFCFG"
+[files]
+"DefCfg.sdl"
+"DefCfg.mak"
+"DefCfg.h"
+"DefCfg.c"
+<endComponent>
diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.h b/Core/EM/OFBD/DEFCFG/DefCfg.h
new file mode 100644
index 0000000..06f9cfe
--- /dev/null
+++ b/Core/EM/OFBD/DEFCFG/DefCfg.h
@@ -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/OFBD/DEFCFG/DefCfg.h 2 3/16/11 10:37p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:37p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.h $
+//
+// 2 3/16/11 10:37p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] DefCfg.mak
+// DefCfg.h
+// DefCfg.c
+//
+// 1 5/06/10 2:21a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: DefCfg.h
+//
+// Description: Header file for the DefCfg
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_DEFCFG_H_
+#define _EFI_DEFCFG_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/DEFCFG/DefCfg.mak b/Core/EM/OFBD/DEFCFG/DefCfg.mak
new file mode 100644
index 0000000..060d5d5
--- /dev/null
+++ b/Core/EM/OFBD/DEFCFG/DefCfg.mak
@@ -0,0 +1,76 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/DEFCFG/DefCfg.mak 2 3/16/11 10:37p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:37p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.mak $
+#
+# 2 3/16/11 10:37p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] DefCfg.mak
+# DefCfg.h
+# DefCfg.c
+#
+# 1 5/06/10 2:21a Lawrencechang
+# Initial check-in.
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: DefCfg.mak
+#
+# Description: Make file for the DefCfg.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : DEFCFG
+
+DEFCFG : $(BUILD_DIR)\DEFCFG.mak DEFCFGBin
+
+$(BUILD_DIR)\DEFCFG.mak : $(OFBD_DEFCFG_DIR)\$(@B).cif $(OFBD_DEFCFG_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_DEFCFG_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+DEFCFGBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\DEFCFG.mak all\
+ NAME=DEFCFG \
+ TYPE=LIBRARY LIBRARY_NAME=$(DEFCFGLIB)
+
+$(DEFCFGLIB) : DEFCFG
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/DEFCFG/DefCfg.sdl b/Core/EM/OFBD/DEFCFG/DefCfg.sdl
new file mode 100644
index 0000000..d19994f
--- /dev/null
+++ b/Core/EM/OFBD/DEFCFG/DefCfg.sdl
@@ -0,0 +1,56 @@
+TOKEN
+ Name = "DEFCFG_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable AFU Default Command Configuration support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "DEFCFGLIB"
+ Value = "$(BUILD_DIR)\DEFCFGLIB.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[AFU Default Command Configuration Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "DEF_CFG_SAMPLE_TEST"
+ Value = "0"
+ Help = "Test AFU Default Command Configuration Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "DEFCFG_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_DEFCFG_DIR"
+End
+
+MODULE
+ Help = "Includes DefCfg.mak to Project"
+ File = "DefCfg.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\DEFCFGLIB.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "DEFCFGEntry,"
+ Parent = "OFBDPartsList"
+ Token = "DEFCFG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/MEUD/InitMEUDString.c b/Core/EM/OFBD/MEUD/InitMEUDString.c
new file mode 100644
index 0000000..00c0ac2
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/InitMEUDString.c
@@ -0,0 +1,243 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/InitMEUDString.c 6 11/01/11 2:54a Klzhan $
+//
+// $Revision: 6 $
+//
+// $Date: 11/01/11 2:54a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/InitMEUDString.c $
+//
+// 6 11/01/11 2:54a Klzhan
+// [TAG] EIP73028
+// [Category] Improvement
+// [Description] Pointer might be used without initial.
+//
+// 5 2/10/11 4:04a Klzhan
+// Improvement : Update output string for SPS FW when disabled ME.
+//
+// 4 12/27/10 3:15a Klzhan
+// Improvement : Output message for Disabled ME setup item.
+//
+// 3 6/10/10 5:54a Klzhan
+// Improvement : Implement Setup call back by Elink.
+//
+// 2 10/30/09 6:43a Klzhan
+// 1. Remove un-used function.
+//
+// 1 10/20/09 3:31a Klzhan
+// Initail check-in.
+//
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: InitMEUDString.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "..\OFBD.h"
+#include "MEUD.h"
+#if EFI_SPECIFICATION_VERSION>0x20000
+#include <Protocol/HiiString.h>
+#include <Protocol/HiiDatabase.h>
+#else
+#include <Protocol\Hii.h>
+#endif
+#include <Setup.h>
+#include <Protocol/AMIPostMgr.h>
+
+extern EFI_GUID guidHII;
+#if EFI_SPECIFICATION_VERSION>0x20000
+EFI_STATUS MEUDSetupCallbackFunction(
+ EFI_HII_HANDLE HiiHandle,
+ UINT16 Class,
+ UINT16 SubClass,
+ UINT16 Key);
+#else
+EFI_STATUS MEUDSetupCallbackFunction(
+ IN EFI_FORM_CALLBACK_PROTOCOL *This,
+ IN UINT16 KeyValue,
+ IN EFI_IFR_DATA_ARRAY *Data,
+ OUT EFI_HII_CALLBACK_PACKET **Packet );
+EFI_FORM_CALLBACK_PROTOCOL MEUDSetupCallBack = { NULL,NULL,MEUDSetupCallbackFunction };
+#endif
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MEUDSetupCallbackFunction
+//
+// Description: TSE Callbeck Function.
+// To make ME enter Disable Mode.
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#if EFI_SPECIFICATION_VERSION>0x20000
+EFI_STATUS MEUDSetupCallbackFunction(
+ EFI_HII_HANDLE HiiHandle,
+ UINT16 Class,
+ UINT16 SubClass,
+ UINT16 Key)
+#else
+EFI_STATUS MEUDSetupCallbackFunction(
+ IN EFI_FORM_CALLBACK_PROTOCOL *This,
+ IN UINT16 KeyValue,
+ IN EFI_IFR_DATA_ARRAY *Data,
+ OUT EFI_HII_CALLBACK_PACKET **Packet )
+#endif
+{
+ UINTN VariableSize = 1;
+ UINT8 Flag,MsgBoxSel;
+ EFI_GUID gMEUDErrorguid = MEUD_ERROR_GUID;
+ EFI_GUID AmiPostMgrProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID;
+ EFI_STATUS Status;
+ CHAR16 *OutputString = L"Disable ME fail !!";
+
+ IoWrite8(0xB2,Disable_ME_SW_SMI);
+
+ Status = pRS->GetVariable( L"ShowMEUDFailMSG", &gMEUDErrorguid,
+ NULL, &VariableSize, &Flag);
+
+ // In SPS, BIOS doesn't send reset message.
+ // Add message for User to know what happened.
+ if(!EFI_ERROR(Status))
+ {
+ AMI_POST_MANAGER_PROTOCOL *AmiPostMgr = NULL;
+
+ switch(Flag)
+ {
+ case 0:
+#ifdef CSP_SPSUD_SUPPORT
+#if CSP_SPSUD_SUPPORT
+ OutputString = L"ME been Disabled !! Please boot your system to OS for updating ME!!";
+#endif
+#endif
+#ifdef CSP_MEUD_SUPPORT
+#if CSP_MEUD_SUPPORT
+ OutputString = L"ME been Disabled !! Please reboot your system !!";
+#endif
+#endif
+ break;
+
+ default:
+ OutputString = L"Disable ME fail !!";
+ break;
+ }
+ if (!EFI_ERROR(pBS->LocateProtocol
+ (&AmiPostMgrProtocolGuid, NULL, &AmiPostMgr)))
+ {
+ AmiPostMgr->DisplayMsgBox(
+ L"ME Update Info",
+ OutputString,
+ MSGBOX_TYPE_NULL,
+ &MsgBoxSel
+ );
+
+ }
+ }
+
+ return EFI_SUCCESS ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitMEUDInfo
+//
+// Description: Register a Setup Item CallBack Info.
+//
+// Input:
+// IN EFI_HII_HANDLE HiiHandle
+// IN UINT16 Class
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitMEUDInfo(EFI_HII_HANDLE HiiHandle, UINT16 Class)
+{
+/*
+ EFI_GUID guidFormCallback = EFI_FORM_CALLBACK_PROTOCOL_GUID;
+ EFI_HANDLE Handle=0;
+ EFI_GUID guidHii = EFI_HII_PROTOCOL_GUID;
+ EFI_HII_PROTOCOL *MEUDHii = NULL;
+ EFI_HII_UPDATE_DATA UpdateData;
+ UINT16 RegData = 0;
+ EFI_STATUS Status;
+
+ if (Class != EXIT_FORM_SET_CLASS)
+ return EFI_NOT_FOUND ;
+
+ Status = pBS->LocateProtocol(&guidHii,NULL,&MEUDHii);
+ if( EFI_ERROR(Status) )
+ {
+ TRACE((0x800,"ERROR=%X Locate HII",Status));
+ }
+
+ // Install a form callback
+ TRACE((0x800,"Installing form callback\n"));
+ if (EFI_ERROR(
+ Status = pBS->InstallProtocolInterface (
+ &Handle,
+ &guidFormCallback,
+ EFI_NATIVE_INTERFACE,
+ &MEUDSetupCallBack
+ )
+ ))
+ {
+ TRACE((0x800,"ERROR=%X - InstallProtocolInterface",Status));
+ }
+
+
+ UpdateData.FormSetUpdate = TRUE; // Flag update pending in FormSet
+ UpdateData.FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) Handle; // Register CallbackHandle data for FormSet
+ UpdateData.FormUpdate = FALSE;
+ UpdateData.FormTitle = 0;
+ UpdateData.DataCount = 0;
+ Status = MEUDHii->UpdateForm(MEUDHii, HiiHandle, (EFI_FORM_LABEL)0x0000, FALSE, &UpdateData);
+ if( EFI_ERROR(Status) )
+ {
+ TRACE((0x800,"ERROR=%X UpdateForm",Status));
+ }
+*/
+ return EFI_SUCCESS;
+
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.c b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.c
new file mode 100644
index 0000000..0c16ea6
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.c
@@ -0,0 +1,519 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.c 3 10/04/11 5:08a Klzhan $
+//
+// $Revision: 3 $
+//
+// $Date: 10/04/11 5:08a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.c $
+//
+// 3 10/04/11 5:08a Klzhan
+// Support update OPR region with auto update.
+//
+// 2 9/09/11 7:25a Klzhan
+// Fix system hang issue.
+//
+// 1 8/30/11 8:17a Klzhan
+//
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AutoUpdate.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include <AmiDxeLib.h>
+#include <Protocol/ConsoleControl.h>
+#include <Protocol/LoadedImage.h>
+#include <Flash.h>
+#include "AutoUpdate.h"
+#include <Protocol/SimpleTextOut.h>
+#include <Core\EM\OFBD\MEUD\MEUD.h>
+
+UINT32 FlashCapacity;
+
+EFI_GUID guidConsoleControl = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
+EFI_GUID guidLoadedImage = EFI_LOADED_IMAGE_PROTOCOL_GUID;
+
+//defined in Tokens.c
+extern const UINT32 FlashBlockSize;
+
+//defined in CSP_MEUD module
+extern EFI_STATUS GET_FW_VERSION(
+ UINT16 *MeFwVersionData
+);
+extern UINT32 GetHFS(VOID);
+
+extern UINT32 GetFlashCapacity(VOID);
+
+extern EFI_STATUS
+GetRegionOffset(
+ UINT8 Region,
+ UINT32* Offset,
+ UINT32* Length
+);
+
+extern OFBD_TC_55_ME_PROCESS_STRUCT *StructPtr;
+
+extern EFI_STATUS UpdateRegions(
+ UINT8* Buffer,
+ BOOLEAN InSmm
+);
+
+#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \
+ { 0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93 }
+EFI_GUID gBdsAllDriversConnectedProtocolGuid = \
+ BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID;
+EFI_GUID gMEAUVariableGuid = MEAU_VAR_GUID;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NeedtoUpdate
+//
+// Description: Check ME version.
+//
+// Input:
+// VOID
+//
+// Output:
+// TRUE - Update ME in this BOOT.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+NeedtoUpdate(
+ VOID
+)
+{
+ ME_FW_VERSION Image_MEversion = IMAGE_ME_FW_VERSION, CurrentMEVersion;
+ EFI_STATUS Status;
+
+ if(REFLASH_UPDATE_FORCE)
+ {
+ UINTN SetupVariableSize = 1;
+ UINT8 Data8;
+ Status = pRS->GetVariable (
+ L"MEAU",
+ &gMEAUVariableGuid,
+ NULL,
+ &SetupVariableSize,
+ &Data8);
+
+ // Flag Not Found, just return TRUE
+ if(Status == EFI_NOT_FOUND)
+ return TRUE;
+ }
+ Status = GET_FW_VERSION((UINT16*)&CurrentMEVersion);
+
+ if(EFI_ERROR(Status))
+ return FALSE;
+
+ // Check version
+#if ME_UPDATE_DOWNGRADE
+ // Downgrade allow, update when the version is different.
+ if(MemCmp(&Image_MEversion, &CurrentMEVersion, sizeof(ME_FW_VERSION)) == 0)
+ return FALSE;
+ else
+ return TRUE;
+#else
+ // Because parameters in ME verions are words
+ // so check version in 2 parts
+ if(ME_VERSION_VALUE(CurrentMEVersion) < ME_VERSION_VALUE(Image_MEversion))
+ return TRUE;
+
+ if((ME_VERSION_VALUE(CurrentMEVersion) == ME_VERSION_VALUE(Image_MEversion))
+ && (ME_VERSION_VALUE1(CurrentMEVersion) < ME_VERSION_VALUE1(Image_MEversion)))
+ return TRUE;
+
+#endif
+
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetRawImage
+//
+// Description: Find ME binary in FV_MAIN.
+//
+// Input:
+// NameGuid - Guid of FFS need to find.
+// Buffer - Input buffer
+// Size - Size of Input buffer
+//
+// Output:
+// Status
+// Buffer - FFS data
+// Size - Size of Output buffer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+GetRawImage (
+ IN EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *Size
+ )
+
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+ EFI_HANDLE *HandleBuff;
+ UINT32 AuthenticationStatus;
+
+ Status = pBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolumeProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuff
+ );
+
+ if (EFI_ERROR (Status) || HandleCount == 0) {
+ return EFI_NOT_FOUND;
+ }
+ //
+ // Find desired image in all Fvs
+ //
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = pBS->HandleProtocol (
+ HandleBuff[Index],
+ &gEfiFirmwareVolumeProtocolGuid,
+ &Fv
+ );
+
+ if (EFI_ERROR (Status)) {
+ if (HandleBuff != NULL) {
+ pBS->FreePool (HandleBuff);
+ }
+
+ return EFI_LOAD_ERROR;
+ }
+ //
+ // Try a raw file
+ //
+ Status = Fv->ReadSection (
+ Fv,
+ NameGuid,
+ EFI_SECTION_RAW,
+ 0,
+ Buffer,
+ Size,
+ &AuthenticationStatus
+ );
+
+ if (!EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ if (HandleBuff != NULL) {
+ pBS->FreePool (HandleBuff);
+ }
+
+ if (Index >= HandleCount) {
+
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ProgressMEUpdate
+//
+// Description: Do ME update
+//
+// Input:
+// NameGuid - Guid of FFS need to find.
+// Buffer - Input buffer
+// Size - Size of Input buffer
+//
+// Output:
+// Status
+// Buffer - FFS data
+// Size - Size of Output buffer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+ProgressMEUpdate(
+ IN UINT8* Buffer,
+ IN UINTN Size
+)
+{
+ EFI_STATUS Status;
+ UINTN SetupVariableSize;
+ UINT8 Data8 = 0;
+ UINT32 TempReg, i;
+ OFBD_TC_55_ME_PROCESS_STRUCT MEProcessStructPtr;
+ CHAR8 String[256];
+ CHAR8* StringBuffer = String;
+ CHAR16 wString[256];
+
+ // Init Global variable
+ MEProcessStructPtr.ddMessageBuffer = (UINT32)StringBuffer;
+ StructPtr = &MEProcessStructPtr;
+
+ FlashCapacity = GetFlashCapacity();
+ if((Size) != FlashCapacity)
+ return;
+
+#ifdef CSP_MEUD_SUPPORT
+#if CSP_MEUD_SUPPORT == 1
+ // For Desktop and Mobile
+ if (((GetHFS() >> 16) & 0x0F) == 0)
+ IoWrite8(SW_SMI_IO_ADDRESS, Disable_ME_SW_SMI);
+ // Comes here, System should be in Disabled mode.
+ // If not, just return
+ if (((GetHFS() >> 16) & 0x0F) != 5)
+ return;
+#endif
+#endif
+
+ // Get ME Region.
+ if(REFLASH_UPDATE_ME)
+ {
+ // Prepare Buffer
+ if(DIRECT_FW_UPDATE)
+ StructPtr->bBlockType = ME_OPR_BLK;
+ else
+ StructPtr->bBlockType = ME_BLK;
+
+ StructPtr->bHandleRequest = BIT02;
+
+ pST->ConOut->OutputString (pST->ConOut,
+ L"ME is updated now ... \r\n");
+
+ pST->ConOut->OutputString (pST->ConOut,
+ L"Please don't shut down or reset system \r\n");
+
+ do{
+ Status = UpdateRegions(Buffer, FALSE);
+ // Request to continue
+ if((StructPtr->UpdateResult & BIT01))
+ StructPtr->bHandleRequest = BIT03;
+
+ // Show string
+ if((StructPtr->UpdateResult & BIT02))
+ {
+ StructPtr->bHandleRequest = BIT03;
+ MemSet(wString, 512, 0);
+ for(i = 0 ; String[i] ; (CHAR8)wString[i] = String[i], i++);
+ wString[i] = 0;
+ pST->ConOut->OutputString (pST->ConOut,wString);
+ pST->ConOut->OutputString (pST->ConOut,L"\r\n");
+ }
+ // End
+ if((StructPtr->UpdateResult & BIT03))
+ break;
+ // TODO : Error Handle
+ }while(1);
+ }
+
+ if(REFLASH_UPDATE_GBE)
+ {
+ // Prepare Buffer
+ StructPtr->bBlockType = GBE_BLK;
+ StructPtr->bHandleRequest = BIT02;
+
+ pST->ConOut->OutputString (pST->ConOut,
+ L"GBE region is updated now ... \r\n");
+
+ Status = UpdateRegions(Buffer, FALSE);
+
+ // Show string
+ if((StructPtr->UpdateResult & BIT02))
+ {
+ StructPtr->bHandleRequest = BIT03;
+ MemSet(wString, 512, 0);
+ for(i = 0 ; String[i] ; (CHAR8)wString[i] = String[i], i++);
+ wString[i] = 0;
+ pST->ConOut->OutputString (pST->ConOut,wString);
+ pST->ConOut->OutputString (pST->ConOut,L"\r\n");
+ }
+ }
+
+ if(REFLASH_UPDATE_MEDS)
+ {
+ // Prepare Buffer
+ StructPtr->bBlockType = GBE_BLK;
+ StructPtr->bHandleRequest = BIT02;
+
+ pST->ConOut->OutputString (pST->ConOut,
+ L"GBE region is updated now ... \r\n");
+
+ Status = UpdateRegions(Buffer, FALSE);
+
+ // Show string
+ if((StructPtr->UpdateResult & BIT02))
+ {
+ StructPtr->bHandleRequest = BIT03;
+ MemSet(wString, 512, 0);
+ for(i = 0 ; String[i] ; (CHAR8)wString[i] = String[i], i++);
+ wString[i] = 0;
+ pST->ConOut->OutputString (pST->ConOut,wString);
+ pST->ConOut->OutputString (pST->ConOut,L"\r\n");
+ }
+ }
+
+ // Update Finish, update Flag
+ if(REFLASH_UPDATE_FORCE)
+ {
+ SetupVariableSize = 1;
+ Status = pRS->SetVariable (
+ L"MEAU",
+ &gMEAUVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE
+ | EFI_VARIABLE_BOOTSERVICE_ACCESS
+ | EFI_VARIABLE_RUNTIME_ACCESS,
+ SetupVariableSize,
+ &Data8);
+ }
+ // Reset System and ME
+ IoWrite32(0xCF8, 0x8000F8AC);
+ TempReg = IoRead32(0xCFC);
+
+ if(!(TempReg & BIT20))
+ {
+ IoWrite32(0xCF8, 0x8000F8AC);
+ IoWrite32(0xCFC, TempReg | BIT20);
+ }
+
+ pRS->ResetSystem( EfiResetCold, EFI_SUCCESS, 0, NULL );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MEAutoUpdate
+//
+// Description: System updaete ME in POST.
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MEAutoUpdate(
+ VOID
+)
+{
+ UINTN Size;
+ EFI_PHYSICAL_ADDRESS ImageLocation;
+ UINT8* ImageBuffer;
+ EFI_STATUS Status;
+ EFI_GUID gMEUDfileguid = MEUD_FILE_GUID;
+
+ if(!NeedtoUpdate())
+ return EFI_SUCCESS;
+
+
+ Size = ME_UPDATE_BINARY_SIZE * 0x100000 / 0x1000;
+ Status = pBS->AllocatePages (
+ AllocateAnyPages,
+ EfiBootServicesData,
+ Size,
+ &ImageLocation );
+
+ ImageBuffer = (UINT8*)ImageLocation;
+
+ if(EFI_ERROR(Status))
+ return Status;
+
+ Size = Size * 0x1000;
+ Status = GetRawImage (&gMEUDfileguid, &ImageBuffer, &Size);
+
+ ProgressMEUpdate(ImageBuffer, Size);
+
+ pBS->FreePages(ImageLocation, Size );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AllDriverConnectEvent
+//
+// Description: This routine for reset the TPM Establishment flag.
+//
+// Input: EFI_EVENT - Efi event.
+// VOID* - Image handle.
+//
+// Output: None.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+MEAUAllDriverConnectEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ MEAutoUpdate();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReFlashEntry
+//
+// Description: This is the standard EFI driver entry point called for
+// Recovery flash module initlaization
+// Input: IN EFI_HANDLE ImageHandle - ImageHandle of the loaded driver
+// IN EFI_SYSTEM_TABLE SystemTable - Pointer to the System Table
+//
+// Output: EFI_SUCCESS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AUTOUPDEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
+{
+ EFI_STATUS Status;
+ EFI_EVENT AllDriverConnectEvent;
+ VOID *Registration;
+
+
+ InitAmiLib(ImageHandle,SystemTable);
+
+ //---Set up Callback----------------
+ Status = RegisterProtocolCallback ( &gBdsAllDriversConnectedProtocolGuid, \
+ MEAUAllDriverConnectEvent, \
+ NULL, \
+ &AllDriverConnectEvent, \
+ &Registration );
+
+ return EFI_SUCCESS;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, 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/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.cif b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.cif
new file mode 100644
index 0000000..a32e4ad
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "MEAU"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\MEUD\MEAU"
+ RefName = "AutoUpdate"
+[files]
+"AutoUpdate.sdl"
+"AutoUpdate.mak"
+"AutoUpdate.c"
+"AutoUpdate.dxs"
+"AutoUpdate.h"
+"MERegion.bin"
+<endComponent>
diff --git a/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.dxs b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.dxs
new file mode 100644
index 0000000..b150b49
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.dxs
@@ -0,0 +1,53 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.dxs 1 8/30/11 8:17a Klzhan $
+//
+// $Revision: 1 $
+//
+// $Date: 8/30/11 8:17a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.dxs $
+//
+// 1 8/30/11 8:17a Klzhan
+//
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AutoUpdate.dxs
+//
+// Description: Dependancy expression for the component
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+DEPENDENCY_START
+ TRUE
+DEPENDENCY_END
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, 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/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.h b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.h
new file mode 100644
index 0000000..00a5718
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.h
@@ -0,0 +1,98 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.h 1 8/30/11 8:17a Klzhan $
+//
+// $Revision: 1 $
+//
+// $Date: 8/30/11 8:17a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.h $
+//
+// 1 8/30/11 8:17a Klzhan
+//
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AutoUpdate.h
+//
+// Description: Header file for component
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef __AUTOUPDATE__H__
+#define __AUTOUPDATE__H__
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <Token.h>
+
+// {80E1202E-2697-4264-9CC9-80762C3E5863}
+#define MEAU_VAR_GUID { 0xC87690DC, 0x9005, 0x47EA, 0xAC, 0x34, 0x12, 0xF, 0xD8, 0x36, 0x33, 0x7D}
+
+
+#define MEUD_FILE_GUID \
+{ 0xfeaaa7a6, 0xcb95, 0x4670, 0xb4, 0x99, 0x87, 0x7f, 0xa6, 0xca, 0x6b, 0xae }
+
+#define ME_VERSION_VALUE(a) \
+(UINT32)((a.CoreMajor << 16) + (a.CoreMinor))
+
+#define ME_VERSION_VALUE1(a) \
+(UINT32)((a.CoreBuild << 16) + (a.CorePatch))
+
+#define FLASH_BASE_ADDRESS(a) (UINTN)(0xFFFFFFFF - GetFlashCapacity() + 1 + (UINTN)a)
+
+
+#pragma pack(1)
+typedef struct
+{
+ UINT8 UpdateGBE;
+ UINT8 UpdateME;
+ UINT8 UpdateMEDS;
+ UINT8 ForceME;
+} MEAUTOUpdate;
+
+#pragma pack()
+
+#define MEAUTOUPD_MAIN 1
+#define MEAUTOUPD_FLASH 2
+
+#define FLASH_PROGRESS_KEY 100
+#define FLASH_START_KEY 101
+
+#include <Setup.h>
+ /****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, 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/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.mak b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.mak
new file mode 100644
index 0000000..dd1d567
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.mak
@@ -0,0 +1,78 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2010, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.mak 1 8/30/11 8:17a Klzhan $
+#
+# $Revision: 1 $
+#
+# $Date: 8/30/11 8:17a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/AutoUpdate.mak $
+#
+# 1 8/30/11 8:17a Klzhan
+#
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: AutoUpdate.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+all : MEAUTOUPD
+
+SetupData : MEAUTOUPD
+
+MEAUTOUPD : $(BUILD_DIR)\AutoUpdate.mak MEAUTOUPDBin $(BUILD_DIR)\MERegion.ffs
+
+$(BUILD_DIR)\AutoUpdate.mak : $(MEAUPD_DIR)\$(@B).cif $(MEAUPD_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(MEAUPD_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+MEUDMSG_CFLAGS=$(CFLAGS) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(TSEBIN_DIR)\
+
+MEAUTOUPDBin : $(AMIDXELIB) $(FLASHLIB) $(CSP_MEUDLIB) $(BUILD_DIR)\MELib.lib
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AutoUpdate.mak all\
+ GUID=39d1830f-259b-4d7e-b1a3-074135b4c934\
+ ENTRY_POINT=AUTOUPDEntry\
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ TYPE=BS_DRIVER \
+ COMPRESS=1
+
+$(BUILD_DIR)\MERegion.ffs: $(ME_UPDATE_BINARY_FILE)
+ $(MAKE) /$(MAKEFLAGS) /f Core\FFS.mak \
+ GUID=feaaa7a6-cb95-4670-b499-877fa6ca6bae \
+ TYPE=EFI_FV_FILETYPE_FREEFORM \
+ BINFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B)
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2010, 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/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.sdl b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.sdl
new file mode 100644
index 0000000..050e758
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/AutoUpdate.sdl
@@ -0,0 +1,103 @@
+TOKEN
+ Name = "ME_AUTO_UPDATE_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable ReFlash support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "MEAUPD_DIR"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\AutoUpdate.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+MODULE
+ Help = "Includes ReFlash.mak to Project"
+ File = "AutoUpdate.mak"
+End
+
+TOKEN
+ Name = "REFLASH_UPDATE_ME"
+ Value = "1"
+ Help = "Enables/Disables update of the NVRAM flash area.\When REFLASH_INTERACTIVE is on and REFLASH_UPDATE_NVRAM_CONTROL is on\this value can be overriden by the user using setup option."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "DIRECT_FW_UPDATE"
+ Value = "1"
+ Help = "1 = Support Direct ME FW Update , 0 = ME FW full image updated."
+ TokenType = Boolean
+ TargetH = Yes
+ Token = "REFLASH_UPDATE_ME" "=" "1"
+End
+
+TOKEN
+ Name = "REFLASH_UPDATE_GBE"
+ Value = "1"
+ Help = "Enables/Disables update of the NVRAM flash area.\When REFLASH_INTERACTIVE is on and REFLASH_UPDATE_NVRAM_CONTROL is on\this value can be overriden by the user using setup option."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "REFLASH_UPDATE_MEDS"
+ Value = "1"
+ Help = "Enables/Disables update of the NVRAM flash area.\When REFLASH_INTERACTIVE is on and REFLASH_UPDATE_NVRAM_CONTROL is on\this value can be overriden by the user using setup option."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "REFLASH_UPDATE_FORCE"
+ Value = "1"
+ Help = "Enables/Disables update of the NVRAM flash area.\When REFLASH_INTERACTIVE is on and REFLASH_UPDATE_NVRAM_CONTROL is on\this value can be overriden by the user using setup option."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "ME_UPDATE_BINARY_SIZE"
+ Value = "8"
+ TokenType = Integer
+ TargetH = Yes
+ Help = "Size in MB of Image."
+End
+
+TOKEN
+ Name = "ME_UPDATE_BINARY_FILE"
+ Value = "$(MEAUPD_DIR)\MERegion.BIN"
+ Help = "Eaglelake BIOS Authenticated Code Module - Production/Release Version."
+ TokenType = File
+ TargetMAK = Yes
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MERegion.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+TOKEN
+ Name = "IMAGE_ME_FW_VERSION"
+ Value = "{{2},{2},{0},{5}}"
+ TokenType = Expression
+ TargetH = Yes
+ Help = "ME version, {Major, Minor, Patch, Build}."
+End
+
+TOKEN
+ Name = "ME_UPDATE_DOWNGRADE"
+ Value = "1"
+ TokenType = Boolean
+ TargetH = Yes
+ Help = "Set to 1, System will auto-update ME even the image in BIOS is old version."
+End
diff --git a/Core/EM/OFBD/MEUD/MEAU/MERegion.bin b/Core/EM/OFBD/MEUD/MEAU/MERegion.bin
new file mode 100644
index 0000000..36bb9c8
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEAU/MERegion.bin
Binary files differ
diff --git a/Core/EM/OFBD/MEUD/MEUD.c b/Core/EM/OFBD/MEUD/MEUD.c
new file mode 100644
index 0000000..1d1cb68
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.c
@@ -0,0 +1,746 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.c 28 5/14/14 1:54a Tristinchou $
+//
+// $Revision: 28 $
+//
+// $Date: 5/14/14 1:54a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.c $
+//
+// 28 5/14/14 1:54a Tristinchou
+// [TAG] EIP167375
+// [Category] Improvement
+// [Description] Remove the variables' RT attribute
+//
+// 27 5/16/13 4:05a Klzhan
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Fix system hangs when BIOS is not on the top of ROM
+//
+// 26 5/16/13 1:54a Klzhan
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Remove Flash Device Enable/Disable.
+// Report BIOS information to AFU.
+//
+// 25 3/08/12 5:32a Klzhan
+// Report error when CSP_ReportMEInfo return error.
+//
+// 24 8/30/11 4:24a Klzhan
+// Remove Un-use code.
+//
+// 23 8/15/11 5:06a Klzhan
+// Fix can't update Ignition FW.
+//
+// 22 8/05/11 6:44a Klzhan
+// [TAG] EIP63481
+// [Category] Improvement
+// [Description] AFU support commands for each regions update.
+//
+// 21 7/15/11 4:54a Klzhan
+// Remove un used comment.
+//
+// 20 7/15/11 4:52a Klzhan
+// [TAG] EIP60754
+// [Category] Spec Update
+// [Severity] Important
+// [Description] Support Direct FW Update.
+//
+// 19 6/14/11 3:42a Klzhan
+// Support SPS spec to 1.1.
+//
+// 18 5/31/11 5:01a Klzhan
+// [TAG] EIP60991
+// [Category] New Feature
+// [Description] Read whole Flash image.
+//
+// 17 5/09/11 3:55a Klzhan
+// Remove Debug include.
+//
+// 16 5/09/11 3:24a Klzhan
+// Add Setup Item in Advanced Page to select regions to update.
+//
+// 15 4/22/11 5:53a Klzhan
+// Fix Build Error.
+//
+// 14 4/22/11 4:36a Klzhan
+// Add error handler when restore MAC.
+//
+// 13 4/22/11 4:15a Klzhan
+// Resotre MAC address when update GBE.
+//
+// 12 4/22/11 2:30a Klzhan
+// Remove the code related to ME AUTO UPDATE.
+// Add OFBD version control for update ME though OFBD.
+//
+// 11 2/10/11 5:52a Klzhan
+// [TAG] EIP52968
+// [Category] New Feature
+// [Description] Update ME through OFBD not SMIFlash.
+// [Files] MEUD.sdl
+// MEUD.h
+// MEUD.c
+//
+// 10 1/12/11 10:34p Klzhan
+// Fix build error when ME_AUTO_UPDATE is disabled.
+//
+// 9 12/27/10 4:42a Klzhan
+// Improvement : ME auto update.
+//
+// 8 11/16/10 4:38a Klzhan
+// Correct behavior of ME update.
+//
+// 7 11/16/10 1:44a Klzhan
+// Fill all parameters in MEUDStructPtr.
+//
+// 6 11/11/10 4:46a Klzhan
+// Correct error check when report MEInfo.
+//
+// 5 6/10/10 11:25p Klzhan
+// BugFix : FIx Compiler Error when ME_Ignition_FW_MSG_SUPPORT is
+// disabled.
+//
+// 4 6/10/10 4:21a Klzhan
+// Improvement : Correct "ME_IGNITION_FW_MSG_SUPPORT" behavior.
+//
+// 3 11/18/09 5:07a Klzhan
+// Improvement : Restore FlashCapacity after program for AFUWin.
+//
+// 2 10/13/09 3:33a Klzhan
+// Updated for Aptio Source Enhancement.
+//
+// 1 9/30/09 11:15p Lawrencechang
+// Move Intel ME update module part to an independent SS path.
+//
+// 5 8/31/09 9:04a Klzhan
+// Update Procedure name to support Capella.
+//
+// 4 7/10/09 4:19a Klzhan
+// Improvement: Command /ME support flash entire image when Ignition FW.
+//
+// 3 7/03/09 5:04a Klzhan
+// Bug fix: Update ME Ignition FW fail.
+// Severity: Critical
+// Symptom: System will write wrong address when Ignition update.
+// Root Cause: Coding Error
+// Improvement: Add a token for showing ME Ignition status message
+//
+// 2 7/02/09 8:25a Klzhan
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: MEUD.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "MEUD.h"
+#include "Flash.h"
+#include "..\OFBD.h"
+#include <Protocol\smiflash.h>
+#include <Protocol\SmmSwDispatch.h>
+#include <Protocol\SmmBase2.h>
+#include "Setup.h"
+
+EFI_SMI_FLASH_PROTOCOL *mSmiFlash;
+UINT32 FlashCapacity;
+// Skip Area, Now there are only 5 regions(FD, ME, GBE, PDR and BIOS)
+
+UINT8 MacAddr[6];
+
+VOID MEUDSMIHandler (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
+);
+
+// SMM Nvram Control Protocol Definitions
+typedef
+EFI_STATUS (*SHOW_BOOT_TIME_VARIABLES)(BOOLEAN Show);
+
+typedef struct{
+ SHOW_BOOT_TIME_VARIABLES ShowBootTimeVariables;
+}AMI_NVRAM_CONTROL_PROTOCOL;
+
+AMI_NVRAM_CONTROL_PROTOCOL *gNvramControl = NULL;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LocateNvramControlSmmProtocol
+//
+// Description: Locate NvramControlProtocol
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+AMI_NVRAM_CONTROL_PROTOCOL*
+LocateNvramControlSmmProtocol()
+{
+ EFI_STATUS Status;
+ static EFI_GUID AmiNvramControlProtocolGuid = { 0xf7ca7568, 0x5a09, 0x4d2c, { 0x8a, 0x9b, 0x75, 0x84, 0x68, 0x59, 0x2a, 0xe2 } };
+ EFI_GUID EfiSmmBase2ProtocolGuid = EFI_SMM_BASE2_PROTOCOL_GUID;
+ EFI_SMM_BASE2_PROTOCOL *SmmBase2 = NULL;
+ EFI_SMM_SYSTEM_TABLE2 *Smst2 = NULL;
+ EFI_CONFIGURATION_TABLE *Table = NULL;
+ UINTN Count = 0;
+
+ Status = pBS->LocateProtocol( &EfiSmmBase2ProtocolGuid, NULL, &SmmBase2 );
+ if( !EFI_ERROR(Status) )
+ {
+ Status = SmmBase2->GetSmstLocation( SmmBase2, &Smst2 );
+ if( EFI_ERROR(Status) || Smst2 == NULL )
+ return NULL;
+ }
+
+ Table = Smst2->SmmConfigurationTable;
+ Count = Smst2->NumberOfTableEntries;
+
+ for( ; Count ; --Count, ++Table )
+ {
+ if( guidcmp( &Table->VendorGuid, &AmiNvramControlProtocolGuid ) == 0 )
+ return Table->VendorTable;
+ }
+
+ return NULL;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MEUDCallback
+//
+// Description: Locate SmiFlash protocol callback
+//
+// Input:
+// IN EFI_EVENT Event
+// IN VOID *Context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MEUDCallback(
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+
+ pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MEUDInSmm
+//
+// Description: OFBD ME Firmware Update InSmm Function
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MEUDInSmm(VOID)
+{
+ EFI_STATUS Status;
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+ EFI_GUID gMEUDErrorGuid = MEUD_ERROR_GUID;
+ UINT8 FW_Usage = 0, MeResetFlag;
+ UINT32 VariableAttr;
+ UINTN VariableSize;
+ FlashCapacity = GetFlashCapacity();
+
+ Status = pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+ if (EFI_ERROR(Status)){
+ EFI_EVENT SmiFlashCallbackEvt;
+ VOID *MEUDReg;
+ RegisterProtocolCallback(
+ &gEfiSmiFlashProtocolGuid, MEUDCallback,
+ NULL,&SmiFlashCallbackEvt, &MEUDReg
+ );
+ }
+
+ gNvramControl = LocateNvramControlSmmProtocol();
+
+ CSP_MEUDInSmm();
+ VariableSize = sizeof(UINT8);
+ Status = pRS->GetVariable( L"MEUpdateResetFlag", &gMEUDErrorGuid,
+ &VariableAttr, &VariableSize, &MeResetFlag);
+
+
+ if((!EFI_ERROR(Status)) && (MeResetFlag == 1))
+ {
+ UINT32 TempReg;
+
+ // Reset ME
+ IoWrite32(0xCF8, 0x8000F8AC);
+ TempReg = IoRead32(0xCFC);
+
+ if(!(TempReg & BIT20))
+ {
+ IoWrite32(0xCF8, 0x8000F8AC);
+ IoWrite32(0xCFC, TempReg | BIT20);
+ }
+
+ // Clear Flag
+ VariableSize = 0;
+ pRS->SetVariable( L"MEUpdateResetFlag", &gMEUDErrorGuid,
+ VariableAttr,
+ VariableSize, &MeResetFlag);
+
+ pRS->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ }
+
+
+ // If HFS is NULL, return.
+#if ME_IGNITION_FW_MSG_SUPPORT
+ if(GetHFS() == 0)
+ return;
+
+ FW_Usage = (GetHFS() >> 24);
+ if(((GetHFS() >> 16) & 0x0F) == 1)
+ // Set A variable as Flag or Link many lib to AMITSE.
+ pRS->SetVariable( L"ShowMEUDFailMSG", &gMEUDErrorGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(UINT8), &FW_Usage);
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MEUDEntry
+//
+// Description: OFBD ME Firmware Update Entry point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MEUDEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_55_MEUD_STRUCT *MEUDStructPtr;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 Buffer1, Buffer2;
+ OFBD_TC_55_ME_INFO_STRUCT *MEInfoStructPtr;
+ OFBD_TC_55_ME_PROCESS_STRUCT *MEProcessStructPtr;
+#ifdef CSP_SPSUD_SUPPORT
+#if CSP_SPSUD_SUPPORT
+ UINT8 Timer = 0;
+ UINT8 MeResetFlag = 0;
+ EFI_GUID gMEUDErrorGuid = MEUD_ERROR_GUID;
+#endif
+#endif
+#if (OFBD_VERSION >= 0x0210)
+ UINT32 Length, Offset;
+ BOOLEAN FlashStatus = TRUE;
+ UINT8 *Address;
+ UINT32 Size;
+ UINT8* Data;
+#endif
+ if (*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + \
+ (pOFBDHdr->OFBD_HDR_SIZE));
+ MEUDStructPtr = (OFBD_TC_55_MEUD_STRUCT *)((UINT8 *)pOFBDExtHdr + \
+ sizeof(OFBD_EXT_HDR));
+ MEInfoStructPtr = (OFBD_TC_55_ME_INFO_STRUCT*)MEUDStructPtr;
+ MEProcessStructPtr = (OFBD_TC_55_ME_PROCESS_STRUCT*)MEUDStructPtr;
+
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if (pOFBDHdr->OFBD_FS & OFBD_FS_MEUD)
+ {
+ //Check Type Code ID
+ if (pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_MEUD)
+ {
+ switch (MEUDStructPtr->bSubFunction)
+ {
+ case 0 :
+
+ Status = CSP_ReportMEInfo(0 , \
+ &(MEUDStructPtr->dMERuntimeBase), \
+ &(MEUDStructPtr->dMERuntimeLength));
+
+ MEUDStructPtr->dMEBiosRegionBase = \
+ FlashCapacity - FLASH_SIZE;
+ MEUDStructPtr->dMEBiosRegionLength = (UINT32)FLASH_SIZE;
+
+ if ((FlashCapacity == 0) || EFI_ERROR(Status))
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ return;
+ case 3 :
+ Status = CSP_ReportMEInfo(3, \
+ &(MEUDStructPtr->dMERuntimeBase), \
+ &(MEUDStructPtr->dMERuntimeLength));
+
+ MEUDStructPtr->dMEBiosRegionBase = \
+ FlashCapacity - FLASH_SIZE;
+ MEUDStructPtr->dMEBiosRegionLength = (UINT32)FLASH_SIZE;
+
+ // If FlashCapacity == 0, Not support ME Update
+ if (FlashCapacity == 0)
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ return;
+ case 1 :
+ // Send this again to check is this suppoet.
+ Status = CSP_ReportMEInfo(0, \
+ &Buffer1, \
+ &Buffer2);
+
+ if (!EFI_ERROR(Status))
+ Status = HMRFPO_ENABLE_MSG();
+
+ if (EFI_ERROR(Status))
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ *pOFBDDataHandled = 0xFF;
+ mSmiFlash->FlashCapacity = FlashCapacity;
+ return;
+ case 4 :
+ // Send this again to check is this suppoet.
+ Status = CSP_ReportMEInfo(3, \
+ &Buffer1, \
+ &Buffer2);
+ if (EFI_ERROR(Status))
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ *pOFBDDataHandled = 0xFF;
+ mSmiFlash->FlashCapacity = FlashCapacity;
+#if (OFBD_VERSION >= 0x0210)
+ // Get GBE Region for Restore MAC address
+ Status = GetRegionOffset(3, &Offset, &Length);
+
+ // Before Erase, Get mac address
+ if(Length)
+ {
+#if (OFBD_VERSION >= 0x0220)
+ DoNotConvert = TRUE;
+#endif
+ Address = (UINT8*)FLASH_BASE_ADDRESS(Offset);
+ FlashRead(Address, MacAddr, 6);
+#if (OFBD_VERSION >= 0x0220)
+ DoNotConvert = FALSE;
+#endif
+ }
+#endif
+ return;
+ case 2 :
+ Status = HMRFPO_LOCK_MSG();
+ if (EFI_ERROR(Status))
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ case 5 :
+ mSmiFlash->FlashCapacity = FLASH_SIZE;
+#if defined (CSP_SPSUD_SUPPORT) && (CSP_SPSUD_SUPPORT == 1)
+/*
+ do{
+ Status = HMRFPO_LOCK_MSG();
+ if(!EFI_ERROR(Status))
+ break;
+ Timer ++;
+ }while(Timer < 3);
+*/
+ //reset ME.
+ MeResetFlag = 1;
+
+ if( gNvramControl )
+ gNvramControl->ShowBootTimeVariables( TRUE );
+ Status = pRS->SetVariable(
+ L"MEUpdateResetFlag",
+ &gMEUDErrorGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_NON_VOLATILE,
+ sizeof(UINT8),
+ &MeResetFlag );
+ if( gNvramControl )
+ gNvramControl->ShowBootTimeVariables( FALSE );
+ if (EFI_ERROR(Status))
+ {
+ // Fail , Return
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+#endif
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ *pOFBDDataHandled = 0xFF;
+ return;
+
+ default :
+ *pOFBDDataHandled = 0xFE;
+ break;
+// =============== OFBD Version 2.1 and AFU version 2.37 or newer ===============
+#if (OFBD_VERSION >= 0x0210)
+ // earse
+ case 6 :
+
+ Size = MEUDStructPtr->ddBlockSize;
+
+ Address = (UINT8*)FLASH_BASE_ADDRESS(MEUDStructPtr->ddBlockAddr);
+
+
+
+ for (; FlashStatus && Size > 0; Address += 0x1000, Size -= 0x1000)
+ {
+ FlashBlockWriteEnable(Address);
+ FlashStatus = FlashEraseBlock(Address);
+ FlashBlockWriteDisable(Address);
+ }
+
+ if(FlashStatus)
+ {
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ }
+ break;
+ // program
+ case 7 :
+ Size = MEUDStructPtr->ddBlockSize;
+ Data = (UINT8*)pOFBDHdr;
+ Status = CSP_ReportMEInfo(3, \
+ &Buffer1,
+ &Buffer2);
+ (UINTN)Address = FLASH_BASE_ADDRESS(MEUDStructPtr->ddBlockAddr);
+ Status = GetRegionOffset(3, &Offset, &Length);
+
+ (UINTN)Data += MEUDStructPtr->ddFlashBufOffset;
+ // Restore MAC Address
+ if((MEUDStructPtr->ddBlockAddr == Offset) && (Length != 0))
+ MemCpy(Data,MacAddr,6);
+
+ FlashDeviceWriteEnable();
+
+ FlashBlockWriteEnable(Address);
+ FlashStatus = FlashProgram(Address, Data, Size);
+ FlashBlockWriteDisable(Address);
+
+ FlashDeviceWriteDisable();
+ if(FlashStatus)
+ {
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ }
+ break;
+
+ // Read
+ case 8 :
+ (UINTN)Address = FLASH_BASE_ADDRESS(MEUDStructPtr->ddBlockAddr);
+ Data = (UINT8*)pOFBDHdr;
+ (UINTN)Data += MEUDStructPtr->ddFlashBufOffset;
+
+ FlashRead(Address, Data, MEUDStructPtr->ddBlockSize);
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ break;
+
+ case 9 :
+ // Get Info
+ {
+ UINT16 TotalBlocks = 0;
+
+ // Get FD
+ Status = GetRegionOffset(0 ,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize);
+
+ // Fill FD Info
+ if(!EFI_ERROR(Status))
+ {
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"FDR",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash Flash-Descriptor Region",64);
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = FDT_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+ }
+ // Get GBE
+ Status = GetRegionOffset(3 ,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize);
+
+ // Fill GBE Info
+ if(!EFI_ERROR(Status))
+ {
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"GBER",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash GBE Region",64);
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = GBE_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+ }
+
+ // Get PDR
+ Status = GetRegionOffset(4 ,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize);
+
+ // Fill PDR Info
+ if(!EFI_ERROR(Status))
+ {
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"PDR",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash PDR Region",64);
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = PDR_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+ }
+
+ // Get ME
+ Status = GetRegionOffset(2 ,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize);
+
+ // Fill ME Info
+ if(!EFI_ERROR(Status))
+ {
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"MER",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash Entire ME Region",64);
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = ME_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+ }
+
+ // Get BIOS
+ Status = GetRegionOffset(1 ,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress,
+ &MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize);
+
+ // Fill BIOS Info
+ if(!EFI_ERROR(Status))
+ {
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"MER",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash Entire ME Region",64);
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = BIOS_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+ }
+#if defined (CSP_SPSUD_SUPPORT) && (CSP_SPSUD_SUPPORT == 1)
+ //
+ // Fill SPS Partition Info
+ //
+
+ // OPR1
+ MEInfoStructPtr->BlockInfo[TotalBlocks].StartAddress = OPR1_START;
+ MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize = OPR1_LENGTH;
+ // OPR2
+ if(OPR2_LENGTH != 0)
+ MEInfoStructPtr->BlockInfo[TotalBlocks].BlockSize += OPR2_LENGTH;
+
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Command,"OPR",4);
+ MemCpy(MEInfoStructPtr->BlockInfo[TotalBlocks].Description,
+ "Flash Operation Region of SPS",64);
+
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Type = ME_OPR_BLK;
+ // Status = 1 means Protect
+ MEInfoStructPtr->BlockInfo[TotalBlocks].Status = 0;
+ TotalBlocks += 1;
+#endif
+ MEInfoStructPtr->TotalBlocks = TotalBlocks;
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+
+ }
+ break;
+ case 10 :
+ // ME Process Handle
+ // In CSP_MEUD.c
+ MEProcessHandler(&MEProcessStructPtr);
+ *pOFBDDataHandled = 0xFF;
+ MEUDStructPtr->bReturnStatus = OFBD_TC_MEUD_OK;
+ break;
+#endif //#if (OFBD_VERSION >= 0x0210)
+ }// End of Switch
+ }
+
+ }
+
+ }
+ return;
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/OFBD/MEUD/MEUD.chm b/Core/EM/OFBD/MEUD/MEUD.chm
new file mode 100644
index 0000000..6b977bc
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.chm
Binary files differ
diff --git a/Core/EM/OFBD/MEUD/MEUD.cif b/Core/EM/OFBD/MEUD/MEUD.cif
new file mode 100644
index 0000000..1f91c24
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "On Flash Block Description (APTIO) - Intel ME Update"
+ category = eModule
+ LocalRoot = "Core\EM\OFBD\MEUD\"
+ RefName = "OFBD_MEUD"
+[files]
+"MEUD.sdl"
+"MEUD.mak"
+"MEUD.h"
+"MEUD.c"
+"MEUD_MSG.c"
+"MEUD.uni"
+"MEUD.sd"
+"InitMEUDString.c"
+"MEUD.chm"
+[parts]
+"CSP_MEUD"
+"AutoUpdate"
+<endComponent>
diff --git a/Core/EM/OFBD/MEUD/MEUD.h b/Core/EM/OFBD/MEUD/MEUD.h
new file mode 100644
index 0000000..7485c57
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.h
@@ -0,0 +1,198 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.h 7 5/16/13 2:00a Klzhan $
+//
+// $Revision: 7 $
+//
+// $Date: 5/16/13 2:00a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.h $
+//
+// 7 5/16/13 2:00a Klzhan
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Support OFBD_VERSION is 0x220.
+//
+// 6 9/09/11 7:27a Klzhan
+// Fix build Error when enable MEAU
+//
+// 5 8/05/11 6:43a Klzhan
+// [TAG] EIP63481
+// [Category] New Feature
+// [Description] AFU support commands for each regions update.
+//
+// 4 2/10/11 5:52a Klzhan
+// [TAG] EIP52968
+// [Category] New Feature
+// [Description] Update ME through OFBD not SMIFlash.
+// [Files] MEUD.sdl
+// MEUD.h
+// MEUD.c
+//
+// 3 12/27/10 4:42a Klzhan
+// Improvement : ME auto update.
+//
+// 2 10/13/09 3:33a Klzhan
+// Updated for Aptio Source Enhancement.
+//
+// 1 9/30/09 11:15p Lawrencechang
+// Move Intel ME update module part to an independent SS path.
+//
+// 3 8/31/09 9:03a Klzhan
+// Update Procedure name to support Capella.
+//
+// 2 7/02/09 8:25a Klzhan
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: MEUD.h
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_MEUD_H_
+#define _EFI_MEUD_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+UINT32 GetFlashCapacity(VOID);
+UINT32 GetHFS(VOID);
+EFI_STATUS HMRFPO_LOCK_MSG(VOID);
+EFI_STATUS HMRFPO_ENABLE_MSG(VOID);
+VOID CSP_MEUDInSmm(VOID);
+EFI_STATUS CSP_ReportMEInfo(UINT8 Func_Num, UINT32* BASE_Address, UINT32* Length);
+EFI_STATUS GET_FW_VERSION(UINT16* MeFwVersionData);
+EFI_STATUS
+GetRegionOffset(
+ IN UINT8 Region,
+ IN OUT UINT32* Offset,
+ IN OUT UINT32* Length
+);
+#if OFBD_VERSION >= 0x220
+extern BOOLEAN DoNotConvert;
+#endif
+
+#define MEUD_ERROR_GUID \
+{ 0x732BD39, 0xD6B0, 0x4039, 0xB6, 0xC2, 0x96, 0x54, 0x46, 0x6D, 0xE5, 0x25 }
+
+#define MEUD_FILE_GUID \
+{ 0xfeaaa7a6, 0xcb95, 0x4670, 0xb4, 0x99, 0x87, 0x7f, 0xa6, 0xca, 0x6b, 0xae }
+
+#define ME_VERSION_VALUE(a) \
+(UINT32)((a.CoreMajor << 16) + (a.CoreMinor))
+
+#define ME_VERSION_VALUE1(a) \
+(UINT32)((a.CoreBuild << 16) + (a.CorePatch))
+
+// Override for new ME.
+#if OFBD_VERSION >= 0x220
+#define FLASH_BASE_ADDRESS(a) (UINTN)((UINT64)a)
+#else
+#define FLASH_BASE_ADDRESS(a) (UINTN)(0xFFFFFFFF - GetFlashCapacity() + 1 + (UINTN)a)
+#endif
+
+#ifdef PCIEX_BASE_ADDRESS
+#define PCIE_CFG_ADDRESS(bus, dev, func, reg) \
+ ((UINTN)(PCIEX_BASE_ADDRESS + ((UINT8)(bus) << 20) + \
+ ((UINT8)(dev) << 15) + ((UINT8)(func) << 12) + (reg)))
+#endif
+#define ME_BLK_PROTECT BIT00
+
+typedef enum
+{
+ FDT_BLK,
+ PDR_BLK,
+ GBE_BLK,
+ ME_BLK,
+ ME_OPR_BLK,
+ BIOS_BLK,
+ MAX_BLK
+}ME_BLOCK_TYPE;
+
+#pragma pack(1)
+typedef struct
+{
+ CHAR8 Command[4];
+ CHAR8 Description[64];
+ UINT32 StartAddress;
+ UINT32 BlockSize;
+ UINT8 Type;
+ UINT8 Status;
+}ME_BLOCK_T;
+
+typedef struct
+{
+ UINT8 bReturnStatus;
+ UINT8 bSubFunction;
+ UINT16 TotalBlocks;
+ ME_BLOCK_T BlockInfo[MAX_BLK];
+}OFBD_TC_55_ME_INFO_STRUCT;
+
+typedef struct
+{
+ UINT8 bReturnStatus;
+ UINT8 bSubFunction;
+ UINT32 TotalBlocks;
+ UINT32 BlockIndex;
+ UINT8 bHandleRequest;
+ UINT8 bBlockType;
+ UINT16 UpdateResult;
+ UINT32 ddMeDataBuffer;
+ UINT32 ddMeDataSize;
+ UINT32 ddMeDataChecksum;
+ UINT32 ddMessageBuffer;
+}OFBD_TC_55_ME_PROCESS_STRUCT;
+
+typedef struct
+{
+ UINT16 CoreMajor;
+ UINT16 CoreMinor;
+ UINT16 CoreBuild;
+ UINT16 CorePatch;
+}ME_FW_VERSION;
+#pragma pack()
+VOID
+MEProcessHandler(
+ IN OUT OFBD_TC_55_ME_PROCESS_STRUCT **MEProcessStructPtr
+);
+ /****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/OFBD/MEUD/MEUD.mak b/Core/EM/OFBD/MEUD/MEUD.mak
new file mode 100644
index 0000000..0c8305a
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.mak
@@ -0,0 +1,123 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2007, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.mak 9 5/09/11 3:24a Klzhan $
+#
+# $Revision: 9 $
+#
+# $Date: 5/09/11 3:24a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.mak $
+#
+# 9 5/09/11 3:24a Klzhan
+# Add Setup Item in Advanced Page to select regions to update.
+#
+# 8 4/22/11 2:29a Klzhan
+# Remove the code related to ME AUTO UPDATE.
+#
+# 7 12/27/10 4:38a Klzhan
+# Improvement : ME auto update.
+#
+# 6 11/09/10 10:26p Klzhan
+# Fix Build warming.
+#
+# 5 10/30/09 6:40a Klzhan
+# BugFix : Fix compile Fail.
+#
+# 4 10/20/09 3:43a Klzhan
+# Improvement : Replace TSE2.0 callback by formset callback.
+#
+# 3 10/13/09 6:13a Klzhan
+# Improvement : Add a token for ME SECOVR setup item.
+#
+# 2 10/13/09 3:32a Klzhan
+# 1. Support TSE2.0 Exit page callback for ME update(SECOVR_MEI_MSG
+# mode).
+#
+# 1 9/30/09 11:15p Lawrencechang
+# Move Intel ME update module part to an independent SS path.
+#
+# 2 7/02/09 8:25a Klzhan
+#
+# 1 4/13/09 5:47a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: MEUD.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+all : MEUD
+
+MEUD : $(BUILD_DIR)\MEUD.mak MEUDBin
+
+$(BUILD_DIR)\MEUD.mak : $(OFBD_MEUD_DIR)\$(@B).cif $(OFBD_MEUD_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_MEUD_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+MEUDBin : $(FLASHLIB)
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\MEUD.mak all\
+ NAME=MEUD \
+ TYPE=LIBRARY LIBRARY_NAME=$(MEUDLIB)
+
+$(MEUDLIB) : MEUD
+
+#---------------------------------------------------------------------------
+# Compile Password customization file
+#---------------------------------------------------------------------------
+MEUDMSG_CFLAGS=$(CFLAGS) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(TSEBIN_DIR)\
+
+AMITSE.mak : $(BUILD_DIR)\$(OFBD_MEUD_DIR)\MEUD_MSG.obj
+
+$(BUILD_DIR)\$(OFBD_MEUD_DIR)\MEUD_MSG.obj : $(OFBD_MEUD_DIR)\MEUD_MSG.c
+ $(CC) $(MEUDMSG_CFLAGS) $(ME_INCLUDES) /Fo$@ $**
+#----------------------------------------------------------------------------
+# Create ME Setup Screens
+#----------------------------------------------------------------------------
+SetupSdbs : $(MELIB) $(BUILD_DIR)\MEUD.mak MEUDSDB
+SetupBin : $(BUILD_DIR)\InitMEUDString.obj
+
+MEUDSDB :
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\MEUD.mak all\
+ TYPE=SDB NAME=MEUD STRING_CONSUMERS=$(OFBD_MEUD_DIR)\MEUD.sd
+
+$(BUILD_DIR)\InitMEUDString.obj : $(PROJECT_DIR)\$(OFBD_MEUD_DIR)\InitMEUDString.c $(BUILD_DIR)\SetupStrTokens.h
+ $(CC) $(CFLAGS) /Fo$(BUILD_DIR)\ $(PROJECT_DIR)\$(OFBD_MEUD_DIR)\InitMEUDString.c
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2007, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Core/EM/OFBD/MEUD/MEUD.sd b/Core/EM/OFBD/MEUD/MEUD.sd
new file mode 100644
index 0000000..f551364
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.sd
@@ -0,0 +1,112 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.sd 7 8/30/11 5:38a Klzhan $
+//
+// $Revision: 7 $
+//
+// $Date: 8/30/11 5:38a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD.sd $
+//
+// 7 8/30/11 5:38a Klzhan
+// Remove un-used setup item.
+// SPS FW doesn't need setup item to disabled ME FW.
+//
+// 6 6/14/11 3:43a Klzhan
+// Set Update ME Item to default Enable.
+//
+// 5 5/09/11 3:24a Klzhan
+// Add Setup Item in Advanced Page to select regions to update.
+//
+// 4 11/16/10 4:36a Klzhan
+// Support SPS FW update.
+//
+// 3 5/27/10 3:44a Klzhan
+// Improvement : ME_SECOVR_MEI_MSG_SUPPORT control setup item
+// enable/disable.
+//
+// 2 10/20/09 3:38a Klzhan
+// Improvement : Replace TSE2.0 callback by formset callback.
+//
+// 1 10/13/09 3:28a Klzhan
+// 1. Support TSE2.0 Exit page callback for ME update(SECOVR_MEI_MSG
+// mode).
+//
+//
+//**********************************************************************
+
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+// Name: MEUD.sd
+//
+// Description: Setup definition for MEUD.
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifdef SETUP_DATA_DEFINITION
+
+#endif
+#ifdef FORM_SET_TYPEDEF
+
+#endif
+
+#ifdef FORM_SET_VARSTORE
+
+#endif
+
+#ifdef ADVANCED_FORM_SET
+#if ME_SECOVR_MEI_MSG_SUPPORT
+#ifdef FORM_SET_GOTO
+ //
+ // this grayout is always false, but ensures that callback function will receive pointer to ICC_VOLATILE_SETUP_DATA instead SETUP_DATA
+ //
+ goto MEUD_FORM_ID,
+ prompt = STRING_TOKEN(STR_MEUD_PROMPT),
+ help = STRING_TOKEN(STR_MEUD_PROMPT_HELP);
+#endif
+
+#ifdef FORM_SET_FORM
+ form formid = AUTO_ID(MEUD_FORM_ID),
+ title = STRING_TOKEN(STR_MEUD_PROMPT);
+
+
+#if defined(CSP_MEUD_SUPPORT) && (CSP_MEUD_SUPPORT == 1)
+ goto MEUD_FORM_ID,
+ prompt = STRING_TOKEN(STR_ME_TODISABLE_MODE_PROMPT),
+ help = STRING_TOKEN(STR_ME_TODISABLE_MODE_PROMPT_HELP),
+ flags = INTERACTIVE,
+ key = AMITSESETUP_KEY;
+#endif
+
+ endform;
+#endif //FORM_SET_FORM
+#endif // ME_SECOVR_MEI_MSG_SUPPORT
+#endif //ADVANCED_FORM_SET
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, 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/Core/EM/OFBD/MEUD/MEUD.sdl b/Core/EM/OFBD/MEUD/MEUD.sdl
new file mode 100644
index 0000000..468a210
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.sdl
@@ -0,0 +1,121 @@
+TOKEN
+ Name = MEUD_SUPPORT
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable ME Ignition Firmware Update support in Project"
+End
+
+TOKEN
+ Name = ME_IGNITION_FW_MSG_SUPPORT
+ Value = "0"
+ TokenType = Boolean
+ TargetH = Yes
+ Help = "Enable this Token to Show Ignition FW status during POST"
+End
+
+TOKEN
+ Name = "MEUDLIB"
+ Value = "$(BUILD_DIR)\MEUD.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OFBD ME Firmware Update]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+PATH
+ Name = "OFBD_MEUD_DIR"
+End
+
+MODULE
+ Help = "Includes MEUD.mak to Project"
+ File = "MEUD.mak"
+End
+
+TOKEN
+ Name = ME_SECOVR_MEI_MSG_SUPPORT
+ Value = "0"
+ TokenType = Boolean
+ TargetH = Yes
+ TargetMAK = Yes
+ Help = "Support ME update when ME in SECOVR_MEI_MSG mode,MPG or RC please disable this."
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MEUD.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "MEUDEntry,"
+ Parent = "OFBDPartsList"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "MEUDInSmm,"
+ Parent = "OFBDInSmmFuncList"
+ Token = "MEUD_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ShowMEUDErrors,"
+ Parent = "ProcessConInAvailabilityHook,"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\$(OFBD_MEUD_DIR)\MEUD_MSG.obj"
+ Parent = "AMITSE_Objects"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MEUD.lib"
+ Parent = "MINISETUPLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MEUD.sdb"
+ Parent = "SETUP_SDBS"
+ Priority = 40
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(OFBD_MEUD_DIR)\MEUD.sd"
+ Parent = "SETUP_DEFINITIONS"
+ Priority = 40
+ InvokeOrder = AfterParent
+End
+
+TOKEN
+ Name = "Disable_ME_SW_SMI"
+ Value = "0x29"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+ELINK
+ Name = "InitMEUDInfo,"
+ Parent = "SetupStringInit"
+ Token = "ME_SECOVR_MEI_MSG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ITEM_CALLBACK(ADVANCED_FORM_SET_CLASS,0,AMITSESETUP_KEY,MEUDSetupCallbackFunction),"
+ Parent = "SetupItemCallbacks"
+ Token = "ME_SECOVR_MEI_MSG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
diff --git a/Core/EM/OFBD/MEUD/MEUD.uni b/Core/EM/OFBD/MEUD/MEUD.uni
new file mode 100644
index 0000000..aad1fc5
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD.uni
Binary files differ
diff --git a/Core/EM/OFBD/MEUD/MEUD_MSG.c b/Core/EM/OFBD/MEUD/MEUD_MSG.c
new file mode 100644
index 0000000..619eb90
--- /dev/null
+++ b/Core/EM/OFBD/MEUD/MEUD_MSG.c
@@ -0,0 +1,119 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD_MSG.c 3 10/20/09 3:44a Klzhan $
+//
+// $Revision: 3 $
+//
+// $Date: 10/20/09 3:44a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/MEUD_MSG.c $
+//
+// 3 10/20/09 3:44a Klzhan
+// Improvement : Replace TSE2.0 callback by formset callback.
+//
+// 2 10/13/09 3:35a Klzhan
+// 1. Support TSE2.0 Exit page callback for ME update(SECOVR_MEI_MSG
+// mode).
+// 2. Updated for Aptio Source Enhancement.
+//
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: MEUD_MSG.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "..\OFBD.h"
+#include "MEUD.h"
+#include <Protocol\SimpleTextOut.h>
+
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_RUNTIME_SERVICES *gRT;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowMEUDErrors
+//
+// Description: Show Message on Screen If Ignition FW runs on Factory Default
+//
+// Input:
+// VOID
+//
+// Output: BOOLEAN. Should return TRUE if the screen was used to
+// ask password; FALSE if the screen was not used to ask
+// password.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN ShowMEUDErrors(VOID)
+{
+ EFI_GUID gMEUDErrorGuid = MEUD_ERROR_GUID;
+ UINTN DataSize;
+ UINT8 Data;
+ EFI_STATUS Status;
+ DataSize = sizeof(UINT8);
+
+ Status = gRT->GetVariable( L"ShowMEUDFailMSG", &gMEUDErrorGuid,
+ NULL,
+ &DataSize, &Data);
+ if(EFI_ERROR(Status))
+ return FALSE;
+
+
+ gST->ConOut->OutputString(gST->ConOut,
+ L"\n\rMe Ignition FW Data Paritition Usage :" );
+ if(Data & 0x4)
+ gST->ConOut->OutputString(gST->ConOut, \
+ L"[Runtime Image]\n\r" );
+ else
+ gST->ConOut->OutputString(gST->ConOut, \
+ L"[Factory Default]\n\r" );
+
+
+ gST->ConOut->OutputString(gST->ConOut,
+ L"Me Ignition FW Code Paritition Usage :" );
+ if(Data & 0x8)
+ gST->ConOut->OutputString(gST->ConOut, \
+ L"[Runtime Image]\n\r" );
+ else
+ gST->ConOut->OutputString(gST->ConOut, \
+ L"[Factory Default]\n\r" );
+
+ return FALSE;
+
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/OFBD/OEMCMD/OEMCMD.c b/Core/EM/OFBD/OEMCMD/OEMCMD.c
new file mode 100644
index 0000000..c7613e3
--- /dev/null
+++ b/Core/EM/OFBD/OEMCMD/OEMCMD.c
@@ -0,0 +1,368 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMCMD/OEMCMD.c 4 4/12/11 10:28p Terrylin $
+//
+// $Revision: 4 $
+//
+// $Date: 4/12/11 10:28p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMCMD/OEMCMD.c $
+//
+// 4 4/12/11 10:28p Terrylin
+// Fix sample code is wrong problem.
+//
+// 3 3/16/11 10:36p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMCMD.mak
+// OEMCMD.h
+// OEMCMD.c
+//
+// 2 1/26/11 3:52a Terrylin
+// [Category] Improvement
+// [Description] Add /CMD: command description and its sample code.
+//
+// 1 5/06/10 2:23a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMCMD.c
+//
+// Description:
+//By OEMCMD module, OEM engineers define customized commands to extend AFU functions. AFU sends OEM defined commands
+// to BIOS if user issued /oemcmd:<command>. Then BIOS reacts by these customized commands.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OEMCMD.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDOEMCMDHandle
+//
+// Description: OFBD OEM CMD Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDOEMCMDHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_CMD_CHECKING_SAMPLE_TEST
+
+ UINT8 *pOFBDTblEnd;
+ UINT8 *pCMDBufferStr;
+ UINT32 ddCMDLength = 0;
+ char *DisOemBFStr = "Sample Message: OEM CMD Before Flash Run is OK !!";
+ char *DisOemAFStr = "Sample Message: OEM CMD After Flash Run is OK !!";
+ char *DisOemBEStr = "Sample Message: OEM CMD Before End Run is OK !!";
+ char *DisOemSFStr = "Sample Message: OEM CMD Start to Flash Run is OK !!";
+
+ OFBD_TC_57_OEM_CMD_STRUCT *OCStructPtr;
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ OCStructPtr = (OFBD_TC_57_OEM_CMD_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ //
+ // OEM add start here >>>+
+ //
+
+ //--------------------------------------------------------------------------------------
+ //
+ // OEM Notice :
+ //
+ // case 1:
+ // OCStructPtr->ddCMD is parse by AFU, according "/OEMCMD:x" to given Hex value.
+ //
+ // case 2:
+ // OCStructPtr->ddCMD is "/CMD:{xxx}" command string offset.
+ // OCStructPtr->ddReserve is command string length.
+ //
+ //--------------------------------------------------------------------------------------
+
+ // IoWrite32(0x1080, OCStructPtr->ddCMD); //debug
+
+ //------------------------------------------------------------------------------------------
+ // Case 1
+ //------------------------------------------------------------------------------------------
+
+ // 01. Before Flash
+ if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BF) {
+ //--------------------------------------------------------------------------------------
+ //
+ // OEM Command sample definition:
+ //
+ //--------------------------------------------------------------------------------------
+ // Bit 0 : Restart
+ // Bit 1 : Shutdown
+ // Bit 2 : Wait
+ // ...
+ // Bit 5 : No Check AC adapter
+ // Bit 6 : OEM function 01
+ // Bit 7 : OEM function 02
+ // ...
+ //
+ // 01. /OEMCMD:1 , OCStructPtr->ddCMD = 0x1 (Hex). ("Restart")
+ // 02. /OEMCMD:5 , OCStructPtr->ddCMD = 0x5 (Hex). ("Restart" + "Wait")
+ // 03. /OEMCMD:11 , OCStructPtr->ddCMD = 0x11 (Hex). ("No Check AC adapter" + "Restart")
+ // 04. /OEMCMD:A2 , OCStructPtr->ddCMD = 0xA2 (Hex). ("OEM function 02" + "No Check AC adapter" + "Shutdown")
+ // 05. /OEMCMD:123 , OCStructPtr->ddCMD = 0x123(Hex). ...
+ // 06. /OEMCMD:AABB , OCStructPtr->ddCMD = 0xAABB(Hex). ...
+ //--------------------------------------------------------------------------------------
+
+ //
+ // OCStructPtr->ddCMD
+ //
+
+ // Check Bit 0
+ if (OCStructPtr->ddCMD & 0x1) {
+ // Restart code
+ }
+
+ // Check Bit 1
+ if (OCStructPtr->ddCMD >> 1 & 0x1) {
+ // Shutdown code
+ }
+
+ // Check Bit 2
+ if (OCStructPtr->ddCMD >> 2 & 0x1) {
+ // Wait code
+ }
+
+ // Check Bit 5
+ if (OCStructPtr->ddCMD >> 5 & 0x1) {
+ // No Check AC adapter code
+ }
+
+ // Check Bit 7
+ if (OCStructPtr->ddCMD >> 7 & 0x1) {
+ // OEM function 02 code
+ }
+
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemBFStr);
+
+
+ // 02. After Flash
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_AF) {
+
+ //
+ // Display OEM String Usage +>>>
+ //
+
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemAFStr);
+
+ //
+ // Display OEM String Usage <<<+
+ //
+
+ // 03. Before End
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BE) {
+
+ // OEM add ...
+
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemBEStr);
+
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_SF) {
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemSFStr);
+
+ }
+
+ //------------------------------------------------------------------------------------------
+ // Case 2
+ //------------------------------------------------------------------------------------------
+ // 05. Before Flash
+ if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BUF) {
+ //--------------------------------------------------------------------------------------
+ //
+ // OEM Command sample definition:
+ //
+ //--------------------------------------------------------------------------------------
+ //
+ // 01. /CMD:{123} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 3 (Bytes)
+ // 02. /CMD:{Reset} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 5 (Bytes)
+ // 03. /CMD:{NoVer} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 5 (Bytes)
+ // 04. /CMD:{NoAC} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 4 (Bytes)
+ // 05. /CMD:{Battery} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 7 (Bytes)
+ // 06. /CMD:{NoAc Battery NoVer} , OCStructPtr->ddCMD = 0x400(Hex), OCStructPtr->ddReserve = 18 (Bytes)
+ //--------------------------------------------------------------------------------------
+
+ //
+ // Get Command String Offset
+ //
+
+ pCMDBufferStr = (UINT8 *)((UINT8 *)pOFBDHdr + (OCStructPtr->ddCMD));
+
+
+ //
+ // Get Command String Length
+ //
+
+ ddCMDLength = OCStructPtr->ddReserve;
+
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemBFStr);
+
+
+ // 06. After Flash
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BUF_AF) {
+
+ //
+ // Display OEM String Usage +>>>
+ //
+
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemAFStr);
+
+ //
+ // Display OEM String Usage <<<+
+ //
+
+ // 07. Before End
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BUF_BE) {
+
+ // OEM add ...
+
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemBEStr);
+
+ } else if (OCStructPtr->dwFlaSts == OFBD_TC_OEM_CMD_BUF_SF) {
+ // << debug >>
+ // set oem string flag for AFU to know
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ // copy the oem string ptr for AFU
+ Strcpy((char *)pOFBDTblEnd, DisOemSFStr);
+
+ }
+
+ //
+ // OEM add start here <<<+
+ //
+
+ // Setting Return Status is '1' for AFU to know OFBD has supported OEM CMD module.
+ OCStructPtr->dwRetSts = 1;
+
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OEMCMDEntry
+//
+// Description: OFBD OEM CMD CHECKING Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OEMCMDEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_57_OEM_CMD_STRUCT *OCStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ OCStructPtr = (OFBD_TC_57_OEM_CMD_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_OEM_CMD)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_OEM_CMD)
+ {
+ if(OFBDOEMCMDHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM CMD CHECKING Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMCMD/OEMCMD.cif b/Core/EM/OFBD/OEMCMD/OEMCMD.cif
new file mode 100644
index 0000000..6491426
--- /dev/null
+++ b/Core/EM/OFBD/OEMCMD/OEMCMD.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM CMD Checking"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMCMD\"
+ RefName = "OFBD_OEMCMD"
+[files]
+"OEMCMD.sdl"
+"OEMCMD.mak"
+"OEMCMD.h"
+"OEMCMD.c"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMCMD/OEMCMD.h b/Core/EM/OFBD/OEMCMD/OEMCMD.h
new file mode 100644
index 0000000..a92d5e6
--- /dev/null
+++ b/Core/EM/OFBD/OEMCMD/OEMCMD.h
@@ -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/OFBD/OEMCMD/OEMCMD.h 2 3/16/11 10:36p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:36p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMCMD/OEMCMD.h $
+//
+// 2 3/16/11 10:36p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMCMD.mak
+// OEMCMD.h
+// OEMCMD.c
+//
+// 1 5/06/10 2:23a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMCMD.h
+//
+// Description: Header file for the OEMCMD
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMCMD_H_
+#define _EFI_OEMCMD_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMCMD/OEMCMD.mak b/Core/EM/OFBD/OEMCMD/OEMCMD.mak
new file mode 100644
index 0000000..8cb2617
--- /dev/null
+++ b/Core/EM/OFBD/OEMCMD/OEMCMD.mak
@@ -0,0 +1,74 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/OEMCMD/OEMCMD.mak 2 3/16/11 10:36p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:36p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMCMD/OEMCMD.mak $
+#
+# 2 3/16/11 10:36p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] OEMCMD.mak
+# OEMCMD.h
+# OEMCMD.c
+#
+# 1 5/06/10 2:23a Lawrencechang
+# Initial check-in.
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OEMCMD.mak
+#
+# Description: Make file for the OEMCMD.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OEMCMD
+
+OEMCMD : $(BUILD_DIR)\OEMCMD.mak OEMCMDBin
+
+$(BUILD_DIR)\OEMCMD.mak : $(OFBD_OEMCMD_DIR)\$(@B).cif $(OFBD_OEMCMD_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEMCMD_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OEMCMDBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMCMD.mak all\
+ NAME=OEMCMD \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMCMDLIB)
+
+$(OEMCMDLIB) : OEMCMD
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMCMD/OEMCMD.sdl b/Core/EM/OFBD/OEMCMD/OEMCMD.sdl
new file mode 100644
index 0000000..43be6ca
--- /dev/null
+++ b/Core/EM/OFBD/OEMCMD/OEMCMD.sdl
@@ -0,0 +1,56 @@
+TOKEN
+ Name = "OEMCMD_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable OEM CMD Checking support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMCMDLIB"
+ Value = "$(BUILD_DIR)\OEMCMD.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OEM CMD Checking Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_CMD_CHECKING_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test OEM CMD CHECKING Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEMCMD_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_OEMCMD_DIR"
+End
+
+MODULE
+ Help = "Includes OEMCMD.mak to Project"
+ File = "OEMCMD.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMCMD.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OEMCMDEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEMCMD_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.c b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.c
new file mode 100644
index 0000000..f995c2e
--- /dev/null
+++ b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.c
@@ -0,0 +1,233 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMOAHandle/OEMOAHandle.c 1 10/24/11 3:03a Terrylin $
+//
+// $Revision: 1 $
+//
+// $Date: 10/24/11 3:03a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMOAHandle/OEMOAHandle.c $
+//
+// 1 10/24/11 3:03a Terrylin
+// Add for EIP 66385
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OemOAHandle.c
+//
+// Description:
+//
+// This function is used for OEM can receive the OA data, and then decide what to do.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include <Protocol\SmiFlash.h>
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OemOAHandle.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDOemOADataHandle
+//
+// Description: OFBD Oem OA Data Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDOemOADataHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_OA_DATA_HANDLE_SAMPLE_TEST
+
+ char *TestOemOAStr = " [DBG] OA function is called !!";
+
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_5A_OA_HANDLE_STRUCT *OAStructPtr;
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ OAStructPtr = (OFBD_TC_5A_OA_HANDLE_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ //
+ // OA Structure Description:
+ //
+ /*
+ UINT8 dbOASts; // Bit 0: Notification BIOS, utility is now ready to update the OA data. - OFBD_TC_OA_UPDATE_NOTIFY
+ // Bit 1~7: Reserved
+
+ UINT8 dbErrorID; // 0~255 : Filled by O.E.M.
+
+ UINT16 dwRetSts; // Bit 0: OA data is invalid, tell the utility stop the flash procedure - OFBD_RS_OA_DATA_IS_INVALID
+ // Bit 1: OA data has been modified, tell the utility use the new data to update - OFBD_RS_OA_DATA_IS_MODIFIED
+ // Bit 2: BIOS has updated the OA, so tell the utility doesn't to update - OFBD_RS_OA_UPDATE_SKIPPED
+ // Bit 3: BIOS doesn't allow the OA update, tell the utility stop the flash procedure - OFBD_RS_OA_UPDATE_DECLINED
+ // Bit 4~14: Reserved
+ // Bit 15: Use dbErrorID field for utility return OEM specific error code, when this Bit is set to 1. - OFBD_RS_OA_USE_OEM_ERROR_ID
+ UINT32 ddOABlockAddr; // OA Block Address of BIOS ROM (For NCB mode to use)
+ UINT64 ddOADataBuffer; // OA Data Buffer
+ UINT32 dwOADataSize; // OA Data Buffer Size
+ */
+
+ //
+ // Please add your code here +>>>
+ //
+ if (OAStructPtr->dbOASts == OFBD_TC_OA_UPDATE_NOTIFY)
+ {
+ //
+ // Please set the dwRetSts for utility to know the process is success or fail
+ //
+
+ //
+ // Case 1: OA Data is invalid
+ //
+
+ // OAStructPtr->dwRetSts = OFBD_RS_OA_DATA_IS_INVALID;
+
+
+ //
+ // Case 2: OA Data has been modified, tell the utility use the new data to update
+ //
+
+ // OAStructPtr->dwRetSts = OFBD_RS_OA_DATA_IS_MODIFIED;
+
+
+ //
+ // Case 3: BIOS has updated the OA, so tell the utility doesn't to update
+ //
+
+ // OAStructPtr->dwRetSts = OFBD_RS_OA_UPDATE_SKIPPED;
+
+
+ //
+ // Case 4: BIOS doesn't allow the OA update, tell the utility stop the flash procedure
+ //
+
+ // OAStructPtr->dwRetSts = OFBD_RS_OA_UPDATE_DECLINED;
+
+
+ //
+ // Case X: OEM want to use their error code definition for /A update command status
+ //
+
+
+ // Step 1: Set Bit 15 to 1
+ //
+ // OAStructPtr->dwRetSts = OFBD_RS_OA_USE_OEM_ERROR_ID;
+ //
+ // Step 2: Use dbErrorID field for utility return OEM specific error code
+ //
+ // OAStructPtr->dbErrorID = 0~255;
+
+
+ //
+ // Tell the utility to show the OEM message, if needed. +>>>
+ //
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ Strcpy((char *)pOFBDTblEnd, TestOemOAStr);
+ //
+ // <<<+
+ //
+
+ }
+
+ //
+ // Please add your code here <<<+
+ //
+
+#endif // #ifdef OEM_OA_DATA_HANDLE_SAMPLE_TEST
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OemOAHandleEntry
+//
+// Description: OFBD Oem OA Data Handle Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OemOAHandleEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_5A_OA_HANDLE_STRUCT *OAStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ OAStructPtr = (OFBD_TC_5A_OA_HANDLE_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_OA)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_OA_HANDLE)
+ {
+ if(OFBDOemOADataHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //Oem OA Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.cif b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.cif
new file mode 100644
index 0000000..07aadc1
--- /dev/null
+++ b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM OA Data Handle"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMOAHandle\"
+ RefName = "OFBD_OA_DATA_HANDLE"
+[files]
+"OEMOAHandle.sdl"
+"OEMOAHandle.mak"
+"OEMOAHandle.h"
+"OEMOAHandle.c"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.h b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.h
new file mode 100644
index 0000000..a816d2c
--- /dev/null
+++ b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.h
@@ -0,0 +1,64 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/OEMOAHandle/OEMOAHandle.h 1 10/24/11 3:02a Terrylin $
+//
+// $Revision: 1 $
+//
+// $Date: 10/24/11 3:02a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMOAHandle/OEMOAHandle.h $
+//
+// 1 10/24/11 3:02a Terrylin
+// Add for EIP 66385
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OemOAHandle.h
+//
+// Description: Header file for the OemOAHandle
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMOAHANDLE_H_
+#define _EFI_OEMOAHANDLE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.mak b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.mak
new file mode 100644
index 0000000..54563e0
--- /dev/null
+++ b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.mak
@@ -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/OFBD/OEMOAHandle/OEMOAHandle.mak 1 10/24/11 3:02a Terrylin $
+#
+# $Revision: 1 $
+#
+# $Date: 10/24/11 3:02a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMOAHandle/OEMOAHandle.mak $
+#
+# 1 10/24/11 3:02a Terrylin
+# Add for EIP 66385
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OemOAHandle.mak
+#
+# Description: Make file for the OemOAHandle.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OEMOAHANDLE
+
+OEMOAHANDLE : $(BUILD_DIR)\OEMOAHANDLE.mak OEMOAHANDLEBin
+
+$(BUILD_DIR)\OEMOAHANDLE.mak : $(OFBD_OEM_OA_HANDLE_DIR)\$(@B).cif $(OFBD_OEM_OA_HANDLE_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEM_OA_HANDLE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OEMOAHANDLEBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMOAHANDLE.mak all\
+ NAME=OEMOAHANDLE \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMOAHANDLELIB)
+
+$(OEMOAHANDLELIB) : OEMOAHANDLE
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.sdl b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.sdl
new file mode 100644
index 0000000..7e8a474
--- /dev/null
+++ b/Core/EM/OFBD/OEMOAHandle/OEMOAHandle.sdl
@@ -0,0 +1,56 @@
+TOKEN
+ Name = "OEM_OA_DATA_HANDLE_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable OEM OA Data Handle support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMOAHANDLELIB"
+ Value = "$(BUILD_DIR)\OEMOAHANDLE.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OEM OA Data Handle Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_OA_DATA_HANDLE_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test OEM OA Data Handle Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_OA_DATA_HANDLE_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_OEM_OA_HANDLE_DIR"
+End
+
+MODULE
+ Help = "Includes OemOAHandle.mak to Project"
+ File = "OemOAHandle.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMOAHANDLE.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OemOAHandleEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEM_OA_DATA_HANDLE_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.c b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.c
new file mode 100644
index 0000000..99afa2a
--- /dev/null
+++ b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.c
@@ -0,0 +1,250 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMPWDCK/OEMPwdCk.c 2 3/16/11 10:34p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:34p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMPWDCK/OEMPwdCk.c $
+//
+// 2 3/16/11 10:34p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMPwdCk.mak
+// OEMPwdCk.c
+// OEMPwdCk.h
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMPwdCk.c
+//
+// Description:
+// Password Check protocol is for BIOS to indicate AFU that BIOS password exists and needs to initiate password
+// checking before flashing BIOS. AFU will set OEM_PC_CK in dbGetCkSts field and send OFBD data to BIOS to report
+// password checking is required or not.
+//
+// If password check function is requested then BIOS should fill out password length in dwPwdLen field. Afterward AFU
+// asks user to input password with specified password length given from BIOS in field dwPwdLen and fill user input
+// password in memory buffer after signature of OFBD_EXT_TBL_END for BIOS to do the comparison.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OEMPwdCk.h"
+#include "..\OFBD.h"
+
+static int ErrorNum = 0;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDPwdGetHandle
+//
+// Description: OFBD Password Get Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDPwdGetHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_PWDCK_SAMPLE_TEST
+ char *DisOemStrPwd1 = "Password";
+ char *DisOemStrPwd2 = "Password Retry count exceeded!";
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_52_PC_STRUCT *PwdCkStructPtr;
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ PwdCkStructPtr = (OFBD_TC_52_PC_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ PwdCkStructPtr->dbRetSts = OEM_RS_PC_REQ;
+ PwdCkStructPtr->dwPwdLen = 7;
+ if(ErrorNum < PASSWORD_RETRY_NUM)
+ {
+ //pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //Strcpy((char *)pOFBDTblEnd, DisOemStrPwd1);
+ }
+ else
+ {
+ PwdCkStructPtr->dbRetSts |= OEM_RS_PC_TIMES_EXCEEDED;
+ //pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //Strcpy((char *)pOFBDTblEnd, DisOemStrPwd2);
+ }
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDPwdCheckHandle
+//
+// Description: OFBD Password Check Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDPwdCheckHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_PWDCK_SAMPLE_TEST
+ char *DisOemStrPwdOK = "Password Comparison successes!";
+ char *DisOemStrPwdErr = "Password Comparison error!";
+ char *DisOemStrPwdErr2 = "Password Retry count exceeded!";
+ char *Password = "0123456";
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_52_PC_STRUCT *PwdCkStructPtr;
+
+ PwdCkStructPtr = (OFBD_TC_52_PC_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ if(!MemCmp(pOFBDTblEnd, Password, PwdCkStructPtr->dwPwdLen))
+ {
+ PwdCkStructPtr->dbRetSts |= OEM_RS_PC_CK_OK;
+ //pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //Strcpy((char *)pOFBDTblEnd, DisOemStrPwdOK);
+ }
+ else
+ {
+ ErrorNum++;
+ PwdCkStructPtr->dbRetSts |= 0;
+ if(ErrorNum < PASSWORD_RETRY_NUM)
+ {
+ //pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //Strcpy((char *)pOFBDTblEnd, DisOemStrPwdErr);
+ }
+ else
+ {
+ PwdCkStructPtr->dbRetSts |= OEM_RS_PC_TIMES_EXCEEDED;
+ //pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //Strcpy((char *)pOFBDTblEnd, DisOemStrPwdErr2);
+ }
+ }
+
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDEntryPoint
+//
+// Description: OFBD OEM Password CHECK Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OEMPWDCKEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_52_PC_STRUCT *PwdCkStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ PwdCkStructPtr = (OFBD_TC_52_PC_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ //TRACE((-1,"pOFBDHdr address is:%x ------\n",pOFBDHdr));
+ //TRACE((-1,"pOFBDTblEnd address is:%x ------\n",*(UINT64 *)((UINT8 *)pOFBDTblEnd -sizeof(OFBD_END))));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_PWD)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_PWD)
+ {
+ //IoWrite32(0x300, *(UINT32 *)((UINT8 *)pOFBDTblEnd -4)); //debug
+ if(PwdCkStructPtr->dbGetCkSts == OFBD_TC_OPC_GET)
+ {
+ if(OFBDPwdGetHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM ROM ID Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(PwdCkStructPtr->dbGetCkSts == OFBD_TC_OPC_CHECK)
+ {
+ if(OFBDPwdCheckHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM ROM ID Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ /*//Not OEM ROM ID Data.
+ *pOFBDDataHandled = 0;
+ return;*/
+ }
+ //else
+ //{
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ //}
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.cif b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.cif
new file mode 100644
index 0000000..080fa36
--- /dev/null
+++ b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM Password Checking"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMPWDCK\"
+ RefName = "OFBD_OEMPWDCK"
+[files]
+"OEMPwdCk.sdl"
+"OEMPwdCk.mak"
+"OEMPwdCk.c"
+"OEMPwdCk.h"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.h b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.h
new file mode 100644
index 0000000..a53a8fc
--- /dev/null
+++ b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.h
@@ -0,0 +1,74 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/OEMPWDCK/OEMPwdCk.h 2 3/16/11 10:34p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:34p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMPWDCK/OEMPwdCk.h $
+//
+// 2 3/16/11 10:34p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMPwdCk.mak
+// OEMPwdCk.c
+// OEMPwdCk.h
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMPwdCk.h
+//
+// Description: Header file for the OEMPwdCk
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMPWDCK_H_
+#define _EFI_OEMPWDCK_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.mak b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.mak
new file mode 100644
index 0000000..2926ec5
--- /dev/null
+++ b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.mak
@@ -0,0 +1,76 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/OEMPWDCK/OEMPwdCk.mak 2 3/16/11 10:34p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:34p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMPWDCK/OEMPwdCk.mak $
+#
+# 2 3/16/11 10:34p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] OEMPwdCk.mak
+# OEMPwdCk.c
+# OEMPwdCk.h
+#
+# 1 4/13/09 5:47a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OEMPwdCk.mak
+#
+# Description: Make file for the OEMPwdCk.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OEMPWDCK
+
+OEMPWDCK : $(BUILD_DIR)\OEMPwdCk.mak OEMPWDCKBin
+
+$(BUILD_DIR)\OEMPwdCk.mak : $(OFBD_OEMPWDCK_DIR)\$(@B).cif $(OFBD_OEMPWDCK_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEMPWDCK_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OEMPWDCKBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMPwdCk.mak all\
+ NAME=OEMPWDCK \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMPWDCKLIB)
+
+$(OEMPWDCKLIB) : OEMPWDCK
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.sdl b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.sdl
new file mode 100644
index 0000000..0d3a8d7
--- /dev/null
+++ b/Core/EM/OFBD/OEMPWDCK/OEMPwdCk.sdl
@@ -0,0 +1,65 @@
+TOKEN
+ Name = "OEMPWDCK_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable OEM Password Checking support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMPWDCKLIB"
+ Value = "$(BUILD_DIR)\OEMPWDCK.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OFBD OEM Password Checking]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_PWDCK_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test Supervisor password checking Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "PASSWORD_RETRY_NUM"
+ Value = "3"
+ Help = "Password Retry Num."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_PWDCK_SAMPLE_TEST" "=" "1"
+End
+
+PATH
+ Name = "OFBD_OEMPWDCK_DIR"
+End
+
+MODULE
+ Help = "Includes OEMPwdCk.mak to Project"
+ File = "OEMPwdCk.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMPWDCK.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OEMPWDCKEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEMPWDCK_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.c b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.c
new file mode 100644
index 0000000..a129d72
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.c
@@ -0,0 +1,253 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMROMHOLE/OEMROMHOLE.c 3 3/16/11 10:33p Terrylin $
+//
+// $Revision: 3 $
+//
+// $Date: 3/16/11 10:33p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMHOLE/OEMROMHOLE.c $
+//
+// 3 3/16/11 10:33p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMROMHOLE.mak
+// OEMROMHOLE.c
+// OEMROMHOLE.h
+//
+// 2 1/11/10 4:00a Lawrencechang
+// Solve compiling warning about type casting from UINTN to UINT16.
+//
+// 1 12/16/09 12:51a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMROMHOLE.c
+//
+// Description:
+// Unlike the same name module in CORE8. Due to AFUAPTIO has ability to identify ROM hole location and size in ROM
+// file. This function is only used to provide AFU the messages to show on screen if user tries to flash sesitive data
+// in ROM hole.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OEMROMHOLE.h"
+#include "..\OFBD.h"
+
+static UINT16 dwOFBDTblEndOffset = 0;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDOemStrHandle
+//
+// Description: OFBD OEM STRING Handle
+//
+// This routine will output the OEM String message to the flash utility.
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// IN char *OEMSTR
+// IN EFI_GUID *ROMHOLEGUID
+// IN BOOLEAN IsAppend
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDOemStrHandle(
+ IN OUT OFBD_HDR *pOFBDHdr,
+ IN char *OEMSTR,
+ IN EFI_GUID * ROMHOLEGUID,
+ IN BOOLEAN IsAppend)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ OFBD_TC_50_RH_STRUCT *RomHoleStructPtr;
+ UINT8 *pOFBDTblEnd;
+
+ RomHoleStructPtr = (OFBD_TC_50_RH_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+
+ if (MemCmp(&(RomHoleStructPtr->HoleGuid), ROMHOLEGUID, sizeof(EFI_GUID)) == 0)
+ {
+ if (IsAppend == 0 && dwOFBDTblEndOffset > 0) {
+ Strcpy((char *)pOFBDTblEnd+dwOFBDTblEndOffset, "\n");
+ dwOFBDTblEndOffset += (UINT16)Strlen("\n");
+ Strcpy((char *)pOFBDTblEnd+dwOFBDTblEndOffset, OEMSTR);
+ }else
+ Strcpy((char *)pOFBDTblEnd+dwOFBDTblEndOffset, OEMSTR);
+ dwOFBDTblEndOffset += (UINT16)Strlen(OEMSTR);
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ }
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDRomHoleCheckHandle
+//
+// Description: OFBD Rom Hole Check Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDRomHoleCheckHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ //
+ // About OEM RomHole Message, PLEASE FOLLOW BELOW 3 Steps TO DO. +>>> <OEM_STR>
+ //
+#if OEM_ROM_HOLE_SAMPLE_TEST
+
+ OFBD_TC_50_RH_STRUCT *RHPtr;
+//
+// Step 1: Add your RomHole OEM string message for AFU to display
+//
+ char *DisOemStr0Protect = "RomHole 0 is Protected!";
+ char *DisOemStr0Program = "RomHole 0 is Programming!";
+ char *DisOemStr1Protect = "RomHole 1 is Protected!";
+ char *DisOemStr1Program = "RomHole 1 is Programming!";
+ char *DisOemStrNewLine = "After next line ";
+ char *DisOemStrAppend = "& Test!";
+//
+// Step 2: Add your RomHole GUID definition here for AFU to compare
+//
+// For example :
+// EFI_GUID gEfiRomHoleX = OEM_ROM_HOLE_X_GUID; // Specific Rom Hole X Guid
+//
+// Notice: X range should be 0~7. ( Max of 8 RomHole support )
+//
+ EFI_GUID gEfiRomHole0 = OEM_ROM_HOLE_0_GUID; // Specific Rom Hole 0 Guid
+ EFI_GUID gEfiRomHole1 = OEM_ROM_HOLE_1_GUID; // Specific Rom Hole 1 Guid
+
+ // --------------------------------------------------------------------------------------------------
+ // DO NOT MODIFY +>>>>
+ // --------------------------------------------------------------------------------------------------
+ RHPtr = (OFBD_TC_50_RH_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ dwOFBDTblEndOffset = 0;
+ // --------------------------------------------------------------------------------------------------
+ // DO NOT MODIFY <<<<+
+ // --------------------------------------------------------------------------------------------------
+
+//
+// Step 3: Define your RomHole message to the corresponding AFU commands.
+//
+// Notice: OFBD_TC_CFG_XXX reference from OFBD.H file (Type Code 51 Return Status)
+//
+ //
+ // Sample 1: AFU issued the /Hole command to update the specific Rom Hole
+ //
+ if (RHPtr->ddExtCmd == OFBD_TC_CFG_ROMHOLE)
+ {
+ // Display the OEM message
+ OFBDOemStrHandle(pOFBDHdr, DisOemStr0Program, &gEfiRomHole0, 0);
+ OFBDOemStrHandle(pOFBDHdr, DisOemStr1Program, &gEfiRomHole1, 0);
+ }
+ //
+ // Sample 2: AFU issued the /P or /B command to update the FV_MAIN or FV_BB region (default the Rom Hole is been protected.)
+ //
+ if (RHPtr->ddExtCmd == OFBD_TC_CFG_P || RHPtr->ddExtCmd == OFBD_TC_CFG_B)
+ {
+ // Display the OEM message
+ OFBDOemStrHandle(pOFBDHdr, DisOemStr0Protect, &gEfiRomHole0, 0);
+ OFBDOemStrHandle(pOFBDHdr, DisOemStr1Protect, &gEfiRomHole1, 0);
+ OFBDOemStrHandle(pOFBDHdr, DisOemStrNewLine, &gEfiRomHole0, 0);
+ OFBDOemStrHandle(pOFBDHdr, DisOemStrAppend, &gEfiRomHole0, 1);
+ }
+
+#endif // #if OEM_ROM_HOLE_SAMPLE_TEST
+ // About OEM RomHole Message, PLEASE FOLLOW ABOVE 3 Steps TO DO. <<<+ <OEM_STR>
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OEMROMHOLEEntry
+//
+// Description: OFBD OEM ROM HOLE Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OEMROMHOLEEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_ROMH)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_ROMHOLE)
+ {
+ if(OFBDRomHoleCheckHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM ROM HOLE Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.cif b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.cif
new file mode 100644
index 0000000..c22a98a
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM ROM HOLE Checking"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMROMHOLE\"
+ RefName = "OFBD_OEMROMHOLE"
+[files]
+"OEMROMHOLE.sdl"
+"OEMROMHOLE.mak"
+"OEMROMHOLE.c"
+"OEMROMHOLE.h"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.h b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.h
new file mode 100644
index 0000000..5ab9f62
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.h
@@ -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/OFBD/OEMROMHOLE/OEMROMHOLE.h 2 3/16/11 10:33p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:33p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMHOLE/OEMROMHOLE.h $
+//
+// 2 3/16/11 10:33p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMROMHOLE.mak
+// OEMROMHOLE.c
+// OEMROMHOLE.h
+//
+// 1 12/16/09 12:50a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMROMHOLE.h
+//
+// Description:Header file for the OEMROMHOLE
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMROMHOLE_H_
+#define _EFI_OEMROMHOLE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.mak b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.mak
new file mode 100644
index 0000000..368350f
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.mak
@@ -0,0 +1,74 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/OEMROMHOLE/OEMROMHOLE.mak 2 3/16/11 10:33p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:33p $
+##*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMHOLE/OEMROMHOLE.mak $
+#
+# 2 3/16/11 10:33p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] OEMROMHOLE.mak
+# OEMROMHOLE.c
+# OEMROMHOLE.h
+#
+# 1 12/16/09 12:50a Lawrencechang
+# Initial check-in.
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OEMROMHOLE.mak
+#
+# Description: Make file for the OEMROMHOLE.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OEMROMHOLE
+
+OEMROMHOLE : $(BUILD_DIR)\OEMROMHOLE.mak OEMROMHOLEBin
+
+$(BUILD_DIR)\OEMROMHOLE.mak : $(OFBD_OEMROMHOLE_DIR)\$(@B).cif $(OFBD_OEMROMHOLE_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEMROMHOLE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OEMROMHOLEBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMROMHOLE.mak all\
+ NAME=OEMROMHOLE \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMROMHOLELIB)
+
+$(OEMROMHOLELIB) : OEMROMHOLE
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.sdl b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.sdl
new file mode 100644
index 0000000..5fc97b1
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMHOLE/OEMROMHOLE.sdl
@@ -0,0 +1,76 @@
+TOKEN
+ Name = "OEMROMHOLE_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable OEM ROM HOLE Checking support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMROMHOLELIB"
+ Value = "$(BUILD_DIR)\OEMROMHOLE.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OEM ROM HOLE Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_ROM_HOLE_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test OEM ROM HOLE Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEMROMHOLE_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_HOLE_0_GUID"
+ Value = "{0x05ca01fc, 0x0fc1, 0x11dc, 0x90, 0x11, 0x00, 0x17, 0x31, 0x53, 0xeb, 0xa8}"
+ Help = "OEM ROM HOLE 0 GUID."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "GUID"
+ Token = "OEM_ROM_HOLE_SAMPLE_TEST" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_HOLE_1_GUID"
+ Value = "{0x05ca01fd, 0x0fc1, 0x11dc, 0x90, 0x11, 0x00, 0x17, 0x31, 0x53, 0xeb, 0xa8}"
+ Help = "OEM ROM HOLE 1 GUID."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "GUID"
+ Token = "OEM_ROM_HOLE_SAMPLE_TEST" "=" "1"
+End
+
+PATH
+ Name = "OFBD_OEMROMHOLE_DIR"
+End
+
+MODULE
+ Help = "Includes OEMROMHOLE.mak to Project"
+ File = "OEMROMHOLE.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMROMHOLE.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OEMROMHOLEEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEMROMHOLE_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OEMROMID/OEMROMID.c b/Core/EM/OFBD/OEMROMID/OEMROMID.c
new file mode 100644
index 0000000..3fdae23
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMID/OEMROMID.c
@@ -0,0 +1,220 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMROMID/OEMROMID.c 2 3/16/11 10:35p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:35p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMID/OEMROMID.c $
+//
+// 2 3/16/11 10:35p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMROMID.mak
+// OEMROMID.h
+// OEMROMID.c
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMROMID.c
+//
+// Description:
+// OEM Rom ID Check protocol is for Flash utility to send customer defined specific ROM ID for BIOS to ID version
+// checking uses.
+//
+// BIOS should provide inserted ROM file's specific ROM ID location and then check it, when ID is given by Flash
+// Utility after OFBD_EXT_TBL_END.
+//
+// Moreover, Flash utility will have corresponding action, either stop flashing BIOS.
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OEMROMID.h"
+#include "..\OFBD.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDORIGetHandle
+//
+// Description: OFBD OEM ROM ID Get Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDORIGetHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_ROM_ID_SAMPLE_TEST
+ OFBD_TC_53_ORI_STRUCT *ORIStructPtr;
+ ORIStructPtr = (OFBD_TC_53_ORI_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ ORIStructPtr->dwRetSts = OFBD_TC_ORI_REQ + OFBD_TC_ORI_ROM;
+ ORIStructPtr->ddStartAddrLow = OEM_ROM_ID_Address;
+ ORIStructPtr->ddSize = OEM_ROM_ID_SIZE;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDORICheckHandle
+//
+// Description: OFBD OEM ROM ID Check Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDORICheckHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_ROM_ID_SAMPLE_TEST
+ UINT8 *pOFBDTblEnd;
+ char *DisOemStrOK = "Sample Message: OEM ROM ID Check OK";
+ char *DisOemStrFail = "Sample Message: OEM ROM ID Check Fail";
+ UINT32 OIDLengthMajMin = 0x0c; // hard coded
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ if(*(UINT32 *)(pOFBDTblEnd + OIDLengthMajMin) >= OEM_ROM_ID_SUB)
+ {
+ pOFBDHdr->OFBD_RS |= OFBD_RS_DIS_OEMSTR;
+ //pOFBDHdr->OFBD_RS |= 0; //comparison passed and do nothing
+ Strcpy((char *)pOFBDTblEnd, DisOemStrOK);
+ }
+ else
+ {
+ pOFBDHdr->OFBD_RS |= OFBD_RS_ERR_OUT + OFBD_RS_DIS_OEMSTR;
+ //pOFBDHdr->OFBD_RS |= 0; //comparison failed and do nothing
+ Strcpy((char *)pOFBDTblEnd, DisOemStrFail);
+ }
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDEntryPoint
+//
+// Description: OFBD OEM ROMID CHECK Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OEMROMIDEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_53_ORI_STRUCT *ORIStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ ORIStructPtr = (OFBD_TC_53_ORI_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ //TRACE((-1,"pOFBDHdr address is:%x ------\n",pOFBDHdr));
+ //TRACE((-1,"pOFBDTblEnd address is:%x ------\n",*(UINT64 *)((UINT8 *)pOFBDTblEnd -sizeof(OFBD_END))));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_ORI)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_ORI)
+ {
+ //IoWrite32(0x300, *(UINT32 *)((UINT8 *)pOFBDTblEnd -4)); //debug
+ if(ORIStructPtr->dwGetCkSts == OFBD_TC_ORI_GET)
+ {
+ if(OFBDORIGetHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM ROM ID Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(ORIStructPtr->dwGetCkSts == OFBD_TC_ORI_CHECK)
+ {
+ if(OFBDORICheckHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM ROM ID Data Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ /*//Not OEM ROM ID Data.
+ *pOFBDDataHandled = 0;
+ return;*/
+ }
+ //else
+ //{
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ //}
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMROMID/OEMROMID.cif b/Core/EM/OFBD/OEMROMID/OEMROMID.cif
new file mode 100644
index 0000000..a6c9f68
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMID/OEMROMID.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM ROM ID Checking"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMROMID\"
+ RefName = "OFBD_OEMROMID"
+[files]
+"OEMROMID.sdl"
+"OEMROMID.mak"
+"OEMROMID.h"
+"OEMROMID.c"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMROMID/OEMROMID.h b/Core/EM/OFBD/OEMROMID/OEMROMID.h
new file mode 100644
index 0000000..2432de7
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMID/OEMROMID.h
@@ -0,0 +1,74 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/OEMROMID/OEMROMID.h 2 3/16/11 10:35p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:35p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMID/OEMROMID.h $
+//
+// 2 3/16/11 10:35p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMROMID.mak
+// OEMROMID.h
+// OEMROMID.c
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMROMID.h
+//
+// Description: Header file for the OEMROMID
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMROMID_H_
+#define _EFI_OEMROMID_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMROMID/OEMROMID.mak b/Core/EM/OFBD/OEMROMID/OEMROMID.mak
new file mode 100644
index 0000000..08ab4cc
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMID/OEMROMID.mak
@@ -0,0 +1,75 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/OEMROMID/OEMROMID.mak 2 3/16/11 10:35p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:35p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMROMID/OEMROMID.mak $
+#
+# 2 3/16/11 10:35p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] OEMROMID.mak
+# OEMROMID.h
+# OEMROMID.c
+#
+# 1 4/13/09 5:46a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OEMROMID.mak
+#
+# Description: Make file for the OEMROMID.obj
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+all : OEMROMID
+
+OEMROMID : $(BUILD_DIR)\OEMROMID.mak OEMROMIDBin
+
+$(BUILD_DIR)\OEMROMID.mak : $(OFBD_OEMROMID_DIR)\$(@B).cif $(OFBD_OEMROMID_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEMROMID_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OEMROMIDBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMROMID.mak all\
+ NAME=OEMROMID \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMROMIDLIB)
+
+$(OEMROMIDLIB) : OEMROMID
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMROMID/OEMROMID.sdl b/Core/EM/OFBD/OEMROMID/OEMROMID.sdl
new file mode 100644
index 0000000..043df08
--- /dev/null
+++ b/Core/EM/OFBD/OEMROMID/OEMROMID.sdl
@@ -0,0 +1,102 @@
+TOKEN
+ Name = "OEMROMID_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable OEM ROM ID Checking support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMROMIDLIB"
+ Value = "$(BUILD_DIR)\OEMROMID.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OEM ROM ID Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test OEM ROM ID Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_Address"
+ Value = "083000h"
+ Help = "OEM ROM ID Address."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_ROM_ID_SAMPLE_TEST" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_MAJOR"
+ Value = "ORI_AAAA"
+ TokenType = Expression
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_ROM_ID_SAMPLE_TEST" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_MINOR"
+ Value = "K101"
+ TokenType = Expression
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_ROM_ID_SAMPLE_TEST" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_SUB"
+ Value = "00001h"
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_ROM_ID_SAMPLE_TEST" "=" "1"
+End
+
+TOKEN
+ Name = "OEM_ROM_ID_SIZE"
+ Value = "10h"
+ Help = "OEM ROM ID Length depends on size of Major, Minor, Sub version IDs."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "OEM_ROM_ID_SAMPLE_TEST" "=" "1"
+End
+
+PATH
+ Name = "OFBD_OEMROMID_DIR"
+End
+
+MODULE
+ Help = "Includes OEMROMID.mak to Project"
+ File = "OEMROMID.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMROMID.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OEMROMIDEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEMROMID_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OEMSETUP/OEMSETUP.c b/Core/EM/OFBD/OEMSETUP/OEMSETUP.c
new file mode 100644
index 0000000..398c8ab
--- /dev/null
+++ b/Core/EM/OFBD/OEMSETUP/OEMSETUP.c
@@ -0,0 +1,361 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/OEMSETUP/OEMSETUP.c 3 3/16/11 10:33p Terrylin $
+//
+// $Revision: 3 $
+//
+// $Date: 3/16/11 10:33p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMSETUP/OEMSETUP.c $
+//
+// 3 3/16/11 10:33p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMSETUP.mak
+// OEMSETUP.h
+// OEMSETUP.c
+//
+// 2 5/06/10 2:12a Lawrencechang
+// Add the DMI store/restore function sample code.
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMSETUP.c
+//
+// Description:
+// Basically this function is not always necessary for all projects, because there is a more direct method to achieve
+// the same target. Two E-Links exposed by SMIFlash module, SMIFlashPreUpdateList and SMIFlashEndUpdateList, are made
+// for doing the same thing as this OFBD module.
+//
+// We prefer you make use of E-Links than this OFBD module. The only advantage of this OFBD module is you don't have
+// to link your code with SMIFlash module.If DMI data is stored in the NVRAM, you have two ways to preserve DMI data
+// when updating NVRAM.
+//
+// 1. Controlled by SMBIOS module: SMBIOS module can set SMBIOS_PRESERVE_NVRAM token to preserves DMI data through
+// e-Link PreserveDmiEditData and RestoreDmiEditData.
+//
+// 2. Controlled By Flash utility: AFU will call into OEMSETUP.c only when user issues /r or /sp command. When
+// SMBIOS_PRESERVE_NVRAM token is disable, OEM enginner can set OEMSETUP_SUPPORT token to handle the duty of DMI data
+// preservation through OEM NVRAM/Setup Variable Preserve module. Thus user can decide to clear DMI data or not.
+// In this case, /n parameter will clear NVRAM, and /r parameter is required to preserve DMI data in NVRAM. When /n is
+// triggered, without /r all DMI data in NVRAM will be cleared.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "OEMSETUP.h"
+#include "..\OFBD.h"
+
+// EIP 37169 ->
+#if (SMBIOS_DMIEDIT_DATA_LOC == 2) && (SMBIOS_PRESERVE_NVRAM != 1)
+VOID PreserveDmiEditData (VOID);
+VOID RestoreDmiEditData (VOID);
+#endif
+// <- EIP 37169
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDSETUPSupportHandle
+//
+// Description: OFBD SETUP Store/Restore Support Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDSETUPSupportHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_SETUP_SAMPLE_TEST
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_OK;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDSETUPStoreHandle
+//
+// Description: OFBD SETUP Store Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDSETUPStoreHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_SETUP_SAMPLE_TEST || OEM_DMI_SAMPLE_TEST
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ //OEM add ...
+
+ if (!EFI_ERROR(Status))
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_OK;
+ else
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_STORE_ERROR;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDSETUPRestoreHandle
+//
+// Description: OFBD SETUP Restore Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDSETUPRestoreHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_SETUP_SAMPLE_TEST
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ //OEM add ...
+
+ if (!EFI_ERROR(Status))
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_OK;
+ else
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_RESTORE_ERROR;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDDMIStoreHandle
+//
+// Description: OFBD DMI Data Store Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDDMIStoreHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_DMI_SAMPLE_TEST
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ // OEM add ...
+ // Store the DMI data
+// EIP 37169 ->
+#if (SMBIOS_DMIEDIT_DATA_LOC == 2) && (SMBIOS_PRESERVE_NVRAM != 1)
+ PreserveDmiEditData ();
+#endif
+// <- EIP 37169
+
+ if (!EFI_ERROR(Status))
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_OK;
+ else
+ SETUPStructPtr->dbRetSts = OFBD_TC_DMI_STORE_ERROR;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDDMIRestoreHandle
+//
+// Description: OFBD DMI Data Restore Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDDMIRestoreHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if OEM_DMI_SAMPLE_TEST
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ // OEM add ...
+ // Restore the DMI data
+// EIP 37169 ->
+#if (SMBIOS_DMIEDIT_DATA_LOC == 2) && (SMBIOS_PRESERVE_NVRAM != 1)
+ RestoreDmiEditData ();
+#endif
+// <- EIP 37169
+
+ if (!EFI_ERROR(Status))
+ SETUPStructPtr->dbRetSts = OFBD_TC_SETUP_OK;
+ else
+ SETUPStructPtr->dbRetSts = OFBD_TC_DMI_RESTORE_ERROR;
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OEMSETUPEntry
+//
+// Description: OFBD NVRAM/SETUP Store/Restore Entry point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OEMSETUPEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_56_SETUP_STRUCT *SETUPStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ SETUPStructPtr = (OFBD_TC_56_SETUP_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_SETUP)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_SETUP)
+ {
+ //IoWrite32(0x300, *(UINT32 *)((UINT8 *)pOFBDTblEnd -4)); //debug
+ if(SETUPStructPtr->dbGetSts == OFBD_TC_SETUP_SUPPORT)
+ {
+ if(OFBDSETUPSupportHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM SETUP SUPPORT Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(SETUPStructPtr->dbGetSts == OFBD_TC_SETUP_STORE)
+ {
+ if(OFBDSETUPStoreHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM SETUP STORE Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(SETUPStructPtr->dbGetSts == OFBD_TC_SETUP_RESTORE)
+ {
+ if(OFBDSETUPRestoreHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM SETUP RESTORE Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(SETUPStructPtr->dbGetSts == OFBD_TC_DMI_STORE)
+ {
+ if(OFBDDMIStoreHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM DMI STORE Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ else if(SETUPStructPtr->dbGetSts == OFBD_TC_DMI_RESTORE)
+ {
+ if(OFBDDMIRestoreHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM DMI RESTORE Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/OEMSETUP/OEMSETUP.cif b/Core/EM/OFBD/OEMSETUP/OEMSETUP.cif
new file mode 100644
index 0000000..712b31a
--- /dev/null
+++ b/Core/EM/OFBD/OEMSETUP/OEMSETUP.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "OEM NVRAM/Setup Variable Preserve"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\OEMSETUP\"
+ RefName = "OFBD_OEMSETUP"
+[files]
+"OEMSETUP.sdl"
+"OEMSETUP.mak"
+"OEMSETUP.h"
+"OEMSETUP.c"
+<endComponent>
diff --git a/Core/EM/OFBD/OEMSETUP/OEMSETUP.h b/Core/EM/OFBD/OEMSETUP/OEMSETUP.h
new file mode 100644
index 0000000..3ab063a
--- /dev/null
+++ b/Core/EM/OFBD/OEMSETUP/OEMSETUP.h
@@ -0,0 +1,74 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/OEMSETUP/OEMSETUP.h 2 3/16/11 10:33p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:33p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OEMSETUP/OEMSETUP.h $
+//
+// 2 3/16/11 10:33p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] OEMSETUP.mak
+// OEMSETUP.h
+// OEMSETUP.c
+//
+// 1 4/13/09 5:47a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OEMSETUP.h
+//
+// Description: Header file for the OEMSETUP
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OEMSETUP_H_
+#define _EFI_OEMSETUP_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/OEMSETUP/OEMSETUP.mak b/Core/EM/OFBD/OEMSETUP/OEMSETUP.mak
new file mode 100644
index 0000000..5a84667
--- /dev/null
+++ b/Core/EM/OFBD/OEMSETUP/OEMSETUP.mak
@@ -0,0 +1,87 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/OEMSETUP/OEMSETUP.mak 3 3/16/11 10:33p Terrylin $
+#
+# $Revision: 3 $
+#
+# $Date: 3/16/11 10:33p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OEMSETUP/OEMSETUP.mak $
+#
+# 3 3/16/11 10:33p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] OEMSETUP.mak
+# OEMSETUP.h
+# OEMSETUP.c
+#
+# 2 5/06/10 2:15a Lawrencechang
+# Add a different rule for storing DMI in NVRAM.
+#
+# 1 4/13/09 5:47a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OEMSETUP.mak
+#
+# Description: Make file for the OEMSETUP.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OEMSETUP
+
+OEMSETUP : $(BUILD_DIR)\OEMSETUP.mak OEMSETUPBin
+
+$(BUILD_DIR)\OEMSETUP.mak : $(OFBD_OEMSETUP_DIR)\$(@B).cif $(OFBD_OEMSETUP_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_OEMSETUP_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+# EIP 37169
+!IF "$(SMBIOS_DMIEDIT_DATA_LOC)"=="2" && "$(SMBIOS_PRESERVE_NVRAM)"!="1"
+$(BUILD_DIR)\$(SMBIOS_DMIEDIT_DIR)\SmbiosNvramFunc.obj : $(SMBIOS_DMIEDIT_DIR)\SmbiosNvramFunc.c
+ mkdir $(BUILD_DIR)\$(SMBIOS_DMIEDIT_DIR)
+ $(CC) $(CFLAGS:/W4=/W3) /Fo$(BUILD_DIR)\$(SMBIOS_DMIEDIT_DIR)\ $(SMBIOS_DMIEDIT_DIR)\SmbiosNvramFunc.c
+
+OEMSETUPBin : $(BUILD_DIR)\$(SMBIOS_DMIEDIT_DIR)\SmbiosNvramFunc.obj
+!ELSE
+OEMSETUPBin :
+!ENDIF
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OEMSETUP.mak all\
+ NAME=OEMSETUP \
+ TYPE=LIBRARY LIBRARY_NAME=$(OEMSETUPLIB)
+
+$(OEMSETUPLIB) : OEMSETUP
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/OEMSETUP/OEMSETUP.sdl b/Core/EM/OFBD/OEMSETUP/OEMSETUP.sdl
new file mode 100644
index 0000000..a8d09d4
--- /dev/null
+++ b/Core/EM/OFBD/OEMSETUP/OEMSETUP.sdl
@@ -0,0 +1,71 @@
+TOKEN
+ Name = "OEMSETUP_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable OEM SETUP Preserve support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "OEMSETUPLIB"
+ Value = "$(BUILD_DIR)\OEMSETUP.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OFBD OEM SETUP Preserve]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_SETUP_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test BIOS Setting preserve Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "[OFBD OEM DMI Data Preserve]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "OEM_DMI_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test BIOS DMI Data preserve Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+PATH
+ Name = "OFBD_OEMSETUP_DIR"
+End
+
+MODULE
+ Help = "Includes OEMSETUP.mak to Project"
+ File = "OEMSETUP.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMSETUP.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OEMSETUPEntry,"
+ Parent = "OFBDPartsList"
+ Token = "OEMSETUP_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/EM/OFBD/OFBD.c b/Core/EM/OFBD/OFBD.c
new file mode 100644
index 0000000..4a0c265
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.c
@@ -0,0 +1,415 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2016, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/OFBD.c 10 1/22/16 12:52a Terrylin $
+//
+// $Revision: 10 $
+//
+// $Date: 1/22/16 12:52a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OFBD.c $
+//
+// 10 1/22/16 12:52a Terrylin
+// [TAG] EIP253222
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Update for AMISV035 SMM vulnerability
+// [RootCause] BufAddr is an embedded input pointer which has not been
+// validated to be outside of SMRAM.
+// [Solution] Change the SMRAM corruption validation rules to use
+// AmiBufferValidationLib module.
+// [Files] OFBD.sdl
+// OFBD.c
+// OFBD_Help.chm
+//
+// 9 8/15/13 5:35a Terrylin
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Build Error
+// [Files] OFBD.mak
+// OFBD.c
+//
+// 8 8/06/13 6:32a Terrylin
+// [TAG] EIP131682
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] System BIOS will hang up, when AFU run in Windows or Linux.
+//
+// 7 7/31/13 4:55a Terrylin
+// [TAG] EIP125898
+// [Category] Improvement
+// [Description] 1. Update modules to compliant with PI 1.2 and UEFI
+// 2.3.1 specifications.
+// 2. Add OFBD_TC_51_DC_EXT_STRUCT new structure definition.
+// [Files] OFBD.c
+// OFBD.h
+//
+// 6 7/02/13 3:18a Terrylin
+// [TAG] EIP126656
+// [Category] Improvement
+// [Description] Limited write into SMRAM via OFBD SMM driver - BugID
+// 305380
+//
+// 5 6/14/13 3:54a Terrylin
+// [Category] Improvement
+// [Description] Add the Not InSmmFuncList support.
+// [Files] OFBD.sdl
+// OFBD.mak
+// OFBD.c
+//
+// 4 3/16/11 10:39p Terrylin
+// Correct Copyright information.
+//
+// 3 3/16/11 10:13p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description of each file for user more
+// clearly.
+// [Files] OFBD.mak
+// OFBD.dxs
+// OFBD.c
+// OFBD.h
+//
+// 2 7/02/09 5:54a Klzhan
+// Improvement: Add an E-Link in SMM.
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OFBD.c
+//
+// Description:
+// This is the main file of OFBD module. We setup OFBD SMI handler here. Please also refer to Aptio SMM Module Porting
+// guide.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+#include <Protocol\SmmCpu.h>
+#include <Protocol\SmmBase2.h>
+#include <Protocol\SmmSwDispatch2.h>
+#define RETURN(status) {return status;}
+#else
+#include <Protocol\SmmBase.h>
+#include <Protocol\SmmSwDispatch.h>
+#endif
+#include <Protocol\DevicePath.h>
+#include <AmiHobs.h>
+#include <AmiSmm.h>
+#include <Include\AmiBufferValidationLib.h>
+#include "OFBD.h"
+
+EFI_GUID gSwSmiCpuTriggerGuid = SW_SMI_CPU_TRIGGER_GUID;
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+EFI_GUID gEfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH2_PROTOCOL_GUID;
+EFI_GUID gEfiSmmBase2ProtocolGuid = EFI_SMM_BASE2_PROTOCOL_GUID;
+EFI_GUID gEfiSmmCpuProtocolGuid = EFI_SMM_CPU_PROTOCOL_GUID;
+EFI_SMM_BASE2_PROTOCOL *gSmmBase2;
+EFI_SMM_CPU_PROTOCOL *gSmmCpu;
+#else
+EFI_GUID gEfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH_PROTOCOL_GUID;
+#endif
+
+SMM_HOB gSmmHob;
+
+VOID InitParts(VOID *pOFBDBuffer, UINT8 *pOFBDDataHandled);
+
+typedef VOID (OFBD_SMM) (VOID);
+extern OFBD_SMM OFBD_SMM_FUNC_LIST EndOfOFBDSMMList;
+extern OFBD_SMM OFBD_NOT_SMM_FUNC_LIST EndOfOFBDSMMList;
+OFBD_SMM* OFBDInSMMFunc[] = {OFBD_SMM_FUNC_LIST NULL};
+OFBD_SMM* OFBDNotInSMMFunc[] = {OFBD_NOT_SMM_FUNC_LIST NULL};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckAddressRange
+//
+// Description: Check address to avoid TSEG area.
+//
+// Input:
+// Address - starting address
+// Range - length of the area
+//
+// Output:
+// EFI_SUCCESS - Access granted
+// EFI_ACCESS_DENIED - Access denied!
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CheckAddressRange( IN UINT8 *Address, IN UINTN Range )
+{
+ // Check the size and range
+ if ( ((EFI_PHYSICAL_ADDRESS)Address >= gSmmHob.Tseg) &&
+ ((EFI_PHYSICAL_ADDRESS)Address <= (gSmmHob.Tseg + gSmmHob.TsegLength)) )
+ return EFI_ACCESS_DENIED;
+
+ if ( (((EFI_PHYSICAL_ADDRESS)Address + Range) >= gSmmHob.Tseg) &&
+ (((EFI_PHYSICAL_ADDRESS)Address + Range) <= (gSmmHob.Tseg + gSmmHob.TsegLength)) )
+ return EFI_ACCESS_DENIED;
+
+ return EFI_SUCCESS;
+}
+
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: OFBDSMIHandler
+//
+// Description: OFBD SMI Handlers.
+//
+// Input:
+// IN EFI_HANDLE DispatchHandle,
+// IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
+// Output:
+// EFI_STATUS
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+EFI_STATUS
+OFBDSMIHandler (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context OPTIONAL,
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
+)
+#else
+VOID OFBDSMIHandler (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
+)
+#endif
+{
+#if PI_SPECIFICATION_VERSION < 0x1000A
+ EFI_SMM_CPU_SAVE_STATE *pCpuSaveState = NULL;
+ SW_SMI_CPU_TRIGGER *SwSmiCpuTrigger = NULL;
+ UINTN i;
+#endif
+ UINT8 Data;
+ UINT64 BuffAddr;
+ UINT32 HighBufferAddress = 0;
+ UINT32 LowBufferAddress = 0;
+ UINTN Cpu = pSmst->CurrentlyExecutingCpu - 1;
+ OFBD_HDR *OFBDHeader;
+ UINT8 OFBDDataHandled = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+
+ Cpu = ((EFI_SMM_SW_CONTEXT*)CommBuffer)->SwSmiCpuIndex;
+ //
+ // Found Invalid CPU number, return
+ //
+ if(Cpu == (UINTN)-1) RETURN(Status);
+
+ Status = gSmmCpu->ReadSaveState ( gSmmCpu, \
+ 4, \
+ EFI_SMM_SAVE_STATE_REGISTER_RBX, \
+ Cpu, \
+ &LowBufferAddress );
+ Status = gSmmCpu->ReadSaveState ( gSmmCpu, \
+ 4, \
+ EFI_SMM_SAVE_STATE_REGISTER_RCX, \
+ Cpu, \
+ &HighBufferAddress );
+
+ Data = ((EFI_SMM_SW_CONTEXT*)CommBuffer)->CommandPort;
+
+#else
+ for (i = 0; i < pSmst->NumberOfTableEntries; ++i) {
+ if (guidcmp(&pSmst->SmmConfigurationTable[i].VendorGuid, \
+ &gSwSmiCpuTriggerGuid) == 0) {
+ break;
+ }
+ }
+
+ //If found table, check for the CPU that caused the software Smi.
+ if (i != pSmst->NumberOfTableEntries) {
+ SwSmiCpuTrigger = pSmst->SmmConfigurationTable[i].VendorTable;
+ Cpu = SwSmiCpuTrigger->Cpu;
+ }
+
+ Data = (UINT8)DispatchContext->SwSmiInputValue;
+
+ pCpuSaveState = pSmst->CpuSaveState;
+ HighBufferAddress = pCpuSaveState[Cpu].Ia32SaveState.ECX;
+ LowBufferAddress = pCpuSaveState[Cpu].Ia32SaveState.EBX;
+#endif
+ BuffAddr = HighBufferAddress;
+ BuffAddr = Shl64(BuffAddr, 32);
+ BuffAddr += LowBufferAddress;
+
+ //TRACE((-1,"\nOFBD address is:%x ------\n",BuffAddr));
+
+ OFBDHeader = (OFBD_HDR *)BuffAddr;
+ if ((Data == OFBD_SW_SMI_VALUE) && (OFBDHeader->OFBD_SIG == 'DBFO'))
+ {
+ //Status = CheckAddressRange((UINT8*)(UINTN)OFBDHeader, OFBDHeader->OFBD_Size);
+ if(EFI_ERROR(AmiValidateMemoryBuffer ((UINT8*)(UINTN)OFBDHeader, \
+ OFBDHeader->OFBD_Size))) return EFI_ACCESS_DENIED;
+ //if (!EFI_ERROR(Status)) {
+ OFBDHeader->OFBD_VER = OFBD_VERSION;
+ OFBDHeader->OFBD_RS |= OFBD_RS_SUPPORT;
+
+ InitParts((VOID *)BuffAddr,&OFBDDataHandled);
+ //}
+ }
+
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+ RETURN(Status);
+#endif
+}
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: InSmmFunction
+//
+// Description: Install OFBD SMI Handlers.
+//
+// Input:
+// IN EFI_HANDLE ImageHandle
+// OUT EFI_SYSTEM_TABLE *SystemTable
+// Output:
+// EFI_STATUS
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+EFI_STATUS InSmmFunction(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable)
+{
+
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+ EFI_SMM_SW_DISPATCH2_PROTOCOL *pSwDispatch = NULL;
+ EFI_SMM_SW_REGISTER_CONTEXT SwContext = {OFBD_SW_SMI_VALUE};
+#else
+ EFI_SMM_SW_DISPATCH_PROTOCOL *pSwDispatch;
+ EFI_SMM_SW_DISPATCH_CONTEXT SwContext = {OFBD_SW_SMI_VALUE};
+#endif
+
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ UINT8 i;
+ SMM_HOB *SmmHob;
+ EFI_GUID SmmHobGuid = SMM_HOB_GUID;
+ EFI_GUID HobListGuid = HOB_LIST_GUID;
+
+ Status = InitAmiBufferValidationLib(ImageHandle, SystemTable);
+
+#if PI_SPECIFICATION_VERSION >= 0x1000A
+ Status = InitAmiSmmLib( ImageHandle, SystemTable );
+
+ Status = pBS->LocateProtocol(&gEfiSmmBase2ProtocolGuid, NULL, &gSmmBase2);
+ if (EFI_ERROR(Status)) return EFI_SUCCESS;
+
+ Status = pSmmBase->GetSmstLocation (gSmmBase2, &pSmst);
+ if (EFI_ERROR(Status)) return EFI_SUCCESS;
+
+ Status = pSmst->SmmLocateProtocol( \
+ &gEfiSmmSwDispatch2ProtocolGuid, NULL, &pSwDispatch);
+ if (EFI_ERROR(Status)) return EFI_SUCCESS;
+
+ Status = pSmst->SmmLocateProtocol(&gEfiSmmCpuProtocolGuid, NULL, &gSmmCpu);
+ if (EFI_ERROR(Status)) return EFI_SUCCESS;
+#else
+ VERIFY_EFI_ERROR(pBS->LocateProtocol(
+ &gEfiSmmSwDispatchProtocolGuid, NULL, &pSwDispatch));
+#endif
+
+ SmmHob = (SMM_HOB*)GetEfiConfigurationTable(pST, &HobListGuid);
+ if (SmmHob == NULL) return EFI_NOT_FOUND;
+
+ Status = FindNextHobByGuid(&SmmHobGuid,(VOID**)&SmmHob);
+ if (EFI_ERROR(Status)) return Status;
+
+ MemCpy( &gSmmHob, SmmHob, sizeof(SMM_HOB) );
+
+ Status = pSwDispatch->Register(pSwDispatch, OFBDSMIHandler, &SwContext, \
+ &Handle);
+ ASSERT_EFI_ERROR(Status);
+
+ for (i = 0; OFBDInSMMFunc[i] != NULL; i++) OFBDInSMMFunc[i]();
+ return Status;
+}
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: NotInSmmFunction
+//
+// Description: Install OFBD SMI Handlers.
+//
+// Input:
+// IN EFI_HANDLE ImageHandle
+// OUT EFI_SYSTEM_TABLE *SystemTable
+// Output:
+// EFI_STATUS
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+EFI_STATUS NotInSmmFunction(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable)
+{
+ UINT8 i;
+ for (i = 0; OFBDNotInSMMFunc[i] != NULL; i++) OFBDNotInSMMFunc[i]();
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDEntryPoint
+//
+// Description: The main entry point of OFBD module.
+//
+// Input:
+// IN EFI_HANDLE ImageHandle
+// OUT EFI_SYSTEM_TABLE *SystemTable
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OFBDEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable )
+{
+ InitAmiLib(ImageHandle, SystemTable);
+
+ return InitSmmHandler(ImageHandle, SystemTable, InSmmFunction, NotInSmmFunction);
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2016, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/OFBD/OFBD.cif b/Core/EM/OFBD/OFBD.cif
new file mode 100644
index 0000000..bd88325
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.cif
@@ -0,0 +1,24 @@
+<component>
+ name = "On Flash Block Description (APTIO)"
+ category = eModule
+ LocalRoot = "Core\EM\OFBD\"
+ RefName = "OFBD_eModule"
+[files]
+"OFBD.sdl"
+"OFBD.mak"
+"OFBD.dxs"
+"OFBD.c"
+"OFBD.h"
+"OFBD_Help.chm"
+[parts]
+"OFBD_DEFCFG"
+"OFBD_OEMCMD"
+"OFBD_STDEC"
+"OFBD_OEMROMID"
+"OFBD_OEMPWDCK"
+"OFBD_OEMSETUP"
+"OFBD_OEMROMHOLE"
+"OFBD_CLEANERRORLOG"
+"OFBD_OA_DATA_HANDLE"
+"OFBD_BATTERYCHECK"
+<endComponent>
diff --git a/Core/EM/OFBD/OFBD.dxs b/Core/EM/OFBD/OFBD.dxs
new file mode 100644
index 0000000..07ef653
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.dxs
@@ -0,0 +1,84 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/OFBD.dxs 4 3/16/11 10:39p Terrylin $
+//
+// $Revision: 4 $
+//
+// $Date: 3/16/11 10:39p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OFBD.dxs $
+//
+// 4 3/16/11 10:39p Terrylin
+// Correct Copyright information.
+//
+// 3 3/16/11 10:13p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description of each file for user more
+// clearly.
+// [Files] OFBD.mak
+// OFBD.dxs
+// OFBD.c
+// OFBD.h
+//
+// 2 4/01/10 3:22a Lawrencechang
+// Add dependency for USB.
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 5/11/07 1:47p Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OFBD_dxs
+//
+// Description: Dependency expression for OFBD driver.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include <Token.h>
+#include <Protocol/SmmBase.h>
+#include <Protocol/SmmSwDispatch.h>
+#if defined(AMIUSB_SUPPORT) && AMIUSB_SUPPORT == 1
+#include <Protocol/AmiUsbController.h>
+#endif
+
+DEPENDENCY_START
+#if defined(AMIUSB_SUPPORT) && AMIUSB_SUPPORT == 1
+ EFI_USB_PROTOCOL_GUID AND
+#endif
+ EFI_SMM_BASE_PROTOCOL_GUID AND
+ EFI_SMM_SW_DISPATCH_PROTOCOL_GUID
+DEPENDENCY_END
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/OFBD/OFBD.h b/Core/EM/OFBD/OFBD.h
new file mode 100644
index 0000000..b85eb6c
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.h
@@ -0,0 +1,647 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//**********************************************************************//
+//**********************************************************************//
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/OFBD.h 20 7/31/13 4:55a Terrylin $
+//
+// $Revision: 20 $
+//
+// $Date: 7/31/13 4:55a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/OFBD.h $
+//
+// 20 7/31/13 4:55a Terrylin
+// [TAG] EIP125898
+// [Category] Improvement
+// [Description] 1. Update modules to compliant with PI 1.2 and UEFI
+// 2.3.1 specifications.
+// 2. Add OFBD_TC_51_DC_EXT_STRUCT new structure definition.
+// [Files] OFBD.c
+// OFBD.h
+//
+// 19 10/11/12 2:34a Terrylin
+// [Category] New Feature
+// [Description] Add BatteryCheck component for OEM can use this to
+// replace Legacy ECB table check support in Non-CSM environment.
+// [Files] OFBD.sdl
+// OFBD.h
+// OFBD.cif
+//
+// 18 7/24/12 3:59a Terrylin
+// [Category] Improvement
+// [Description] Add new Return Statuses of Type Code 51 for AFU general
+// commands.
+//
+// 17 2/22/12 4:39a Terrylin
+// Add new command status for GAN support
+//
+// 16 10/27/11 5:01a Terrylin
+// Add new command status of Secure Update.
+//
+// 15 10/24/11 2:47a Terrylin
+// Adjust the OEM OA module part definitions.
+//
+// 14 10/13/11 11:23p Terrylin
+// [TAG] EIP72332
+// [Category] Improvement
+// [Description] Add new Return Statuses of Type Code 51 for AFU general
+// commands.
+//
+// 13 9/19/11 5:03a Terrylin
+// Added OEM OA module part definitions.
+//
+// 12 9/15/11 11:43p Calvinchen
+// Added Secure Update OFBD definitions.
+//
+// 11 7/21/11 5:54a Terrylin
+// [TAG] EIP46069
+// [Category] Improvement
+// [Description] Support Runtime secure flash update mode
+//
+// 10 7/07/11 1:52a Terrylin
+// [TAG] EIP46069
+// [Category] New Feature
+// [Description] Support Secure Flash Update interface via OFBD
+// protocols
+// [Files] OFBD.h
+// OFBD.cif
+//
+// 9 4/20/11 6:46a Terrylin
+// [TAG] EIP52968
+// [Category] Improvement
+// [Description] Adjust OFBD_TC_55_MEUD_STRUCT structure, for new ME
+// firmware update rule.
+//
+// 8 3/16/11 10:39p Terrylin
+// Correct Copyright information.
+//
+// 7 3/16/11 10:13p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description of each file for user more
+// clearly.
+// [Files] OFBD.mak
+// OFBD.dxs
+// OFBD.c
+// OFBD.h
+//
+// 6 1/17/11 4:01a Terrylin
+// [TAG] EIP51076
+// [Category] New Feature
+// [Description] Add some new statuses for "/CLNEVNLOG" command of AFU.
+//
+// 5 8/11/10 11:13p Terrylin
+// Add some new statuses for /CMD: command.
+//
+// 4 5/06/10 2:10a Lawrencechang
+// 1. Modify the Type Code 51 Structure and Return Status.
+// 2. Add some new statuses for /ECX command.
+// 3. Add new DMI flags for /R command.
+//
+// 3 1/11/10 3:45a Lawrencechang
+// Modify Type#50 ROM hole structure.
+//
+// 2 12/01/09 4:35a Lawrencechang
+// Add a new status for /ECX command.
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: OFBD.h
+//
+// Description: Header file for the OFBD
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_OFBD_H_
+#define _EFI_OFBD_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//----------------------------------------------------------------------------
+// On Flash Block Structure Definition
+//----------------------------------------------------------------------------
+//=======================
+// OFBD Header structure
+//=======================
+#pragma pack(1)
+typedef struct
+{
+ UINT32 OFBD_SIG; //'OFBD'
+ UINT16 OFBD_VER; //0200
+ UINT16 OFBD_Size;
+ UINT32 OFBD_FS;
+ UINT16 OFBD_RS;
+ UINT16 OFBD_HDR_SIZE;
+ UINT16 OFBD_OS;
+}OFBD_HDR;
+#pragma pack()
+
+//=================
+// On Flash Status
+//=================
+#define OFBD_FS_VC BIT00
+#define OFBD_FS_BBLK BIT01
+#define OFBD_FS_NVRAM BIT02
+#define OFBD_FS_MAIN BIT03
+#define OFBD_FS_NCB BIT04
+#define OFBD_FS_ROMH BIT05
+#define OFBD_FS_SFU BIT06
+#define OFBD_FS_OA BIT07
+#define OFBD_FS_AC_BAT BIT16
+#define OFBD_FS_SECURUD BIT22
+#define OFBD_FS_ERR_LOG BIT23
+#define OFBD_FS_OEM_CMD BIT24
+#define OFBD_FS_SETUP BIT25
+#define OFBD_FS_MEUD BIT26
+#define OFBD_FS_EC BIT27
+#define OFBD_FS_ORI BIT28
+#define OFBD_FS_PWD BIT29
+#define OFBD_FS_CFG BIT30
+
+//================
+// Return Status
+//================
+#define OFBD_RS_SUPPORT BIT00
+#define OFBD_RS_PROTECT BIT01
+#define OFBD_RS_PROTECT_PART BIT02
+#define OFBD_RS_ERR_OUT BIT03
+#define OFBD_RS_DIS_OEMSTR BIT04
+
+//================
+// OS environment
+//================
+#define OFBD_OS_DOS BIT00
+#define OFBD_OS_WIN BIT01
+#define OFBD_OS_LINUX BIT02
+#define OFBD_OS_FREEBSD BIT03
+#define OFBD_OS_EFI BIT04
+
+//===============================
+// Extended Table Header Status
+//===============================
+#pragma pack(1)
+typedef struct
+{
+ UINT8 TypeCodeID;
+ UINT8 NumTCStruct;
+ UINT16 TCStructSize;
+}OFBD_EXT_HDR;
+
+typedef struct
+{
+ UINT32 OFBD_END;
+}OFBD_END;
+#pragma pack()
+
+#define OFBD_EXT_TBL_END 0x0FFFF55AA
+
+//================
+// Type Code ID
+//================
+#define OFBD_EXT_TC_ROMHOLE 0x50
+#define OFBD_EXT_TC_AFUDEFCFG 0x51
+#define OFBD_EXT_TC_PWD 0x52
+#define OFBD_EXT_TC_ORI 0x53
+#define OFBD_EXT_TC_EC 0x54
+#define OFBD_EXT_TC_MEUD 0x55
+#define OFBD_EXT_TC_SETUP 0x56
+#define OFBD_EXT_TC_OEM_CMD 0x57
+#define OFBD_EXT_TC_CLN_ERR_LOG 0x58
+#define OFBD_EXT_TC_SECURE_UD 0x59
+#define OFBD_EXT_TC_OA_HANDLE 0x5A
+#define OFBD_EXT_TC_AC_BAT 0x5B
+#define OFBD_EXT_TC_SFU 0x70
+
+//----------------------------------------------------------------------------
+// On Flash Block Type Code Structure Section
+//----------------------------------------------------------------------------
+#pragma pack(1)
+//===============================
+// Type Code 50 Struct ROM HOLE
+//===============================
+typedef struct
+{
+ UINT32 ddExtCmd;
+ EFI_GUID HoleGuid;
+}OFBD_TC_50_RH_STRUCT;
+
+//===============================
+// Type Code 51 Struct Def Cfg
+//===============================
+typedef struct
+{
+ UINT32 ddExtCfg;
+ UINT32 ddRetSts;
+}OFBD_TC_51_DC_STRUCT;
+
+typedef struct
+{
+ UINT32 ddIndexCfg;
+ UINT16 ddExtCfg;
+ UINT16 ddIgnCfg;
+}OFBD_TC_51_DC_EXT_STRUCT;
+
+//=======================
+// Type Code 52 Struct
+//=======================
+typedef struct
+{
+ UINT16 dwPwdLen; //Password Length
+ UINT8 dbGetCkSts; //Get Check Status
+ UINT8 dbRetSts; //Return Status
+}OFBD_TC_52_PC_STRUCT;
+
+//=================================
+// Type Code 53 Struct OEM ROM ID
+//=================================
+typedef struct
+{
+ UINT8 dwGetCkSts;
+ UINT8 dwRetSts;
+ UINT32 ddStartAddrLow;
+ UINT32 ddStartAddrHigh;
+ UINT32 ddSize;
+}OFBD_TC_53_ORI_STRUCT;
+
+//=======================================
+// Type Code 54 Struct Standard EC Flash
+//=======================================
+typedef struct
+{
+ UINT8 dbFlaSts; //EC Set & Check Status
+ UINT16 dwRetSts; //EC Return Status
+ UINT32 ddChkSum; //EC Data CheckSum
+ UINT32 ddSize; //EC Data Size
+}OFBD_TC_54_STD_EC_STRUCT;
+
+//=======================================
+// Type Code 55 - ME Ignition Firmware Update Structure
+
+//=======================================
+typedef struct
+{
+ UINT8 bReturnStatus;
+ UINT8 bSubFunction;
+ UINT32 dMERuntimeBase;
+ UINT32 dMERuntimeLength;
+ UINT32 dMEBiosRegionBase;
+ UINT32 dMEBiosRegionLength;
+#if (OFBD_VERSION >= 0x0210)
+ UINT32 ddFlashBufOffset;
+ UINT32 ddBlockAddr;
+ UINT32 ddBlockSize;
+#endif
+}OFBD_TC_55_MEUD_STRUCT;
+
+//=======================================
+// Type Code 56 Struct
+//=======================================
+typedef struct
+{
+ UINT8 dbGetSts; //Get Status
+ UINT8 dbRetSts; //Return Status
+}OFBD_TC_56_SETUP_STRUCT;
+
+//=======================================
+// Type Code 57 Struct
+//=======================================
+typedef struct
+{
+ UINT16 dwFlaSts; // 0: Before Flash, 1: After Flash, 2: Before End
+ UINT16 dwRetSts; // 0: Failure, 1: Successfully
+ UINT32 ddCMD; // Bit 0~15: OEM CMD
+ UINT32 ddReserve; // Reserve
+} OFBD_TC_57_OEM_CMD_STRUCT;
+
+
+//=======================================
+// Type Code 58 Struct
+//=======================================
+typedef struct
+{
+ UINT16 dwFunSts; // 0: Do nothing 1: Clean Event Log
+ UINT16 dwRetSts; // 0: Failure, 1: Successfully
+} OFBD_TC_58_CEL_STRUCT;
+
+//=======================================
+// Type Code 59 Struct
+//=======================================
+typedef struct
+{
+ UINT64 BufAddr;
+ UINT32 BlockAddr; //0 starts at 0xfff0_0000
+ UINT32 BlockSize;
+ UINT8 ErrorCode;
+ UINT8 bSubFunction;
+} OFBD_TC_59_SECURE_UD;
+
+//=======================================
+// Type Code 5A Struct
+//=======================================
+typedef struct
+{
+ UINT8 dbOASts; // Bit 0: Notification BIOS, utility is now ready to update the OA data. - OFBD_TC_OA_UPDATE_NOTIFY
+ // Bit 1~7: Reserved
+
+ UINT8 dbErrorID; // 0~255 : Filled by O.E.M.
+
+ UINT16 dwRetSts; // Bit 0: OA data is invalid, tell the utility stop the flash procedure - OFBD_RS_OA_DATA_IS_INVALID
+ // Bit 1: OA data has be modified, tell the utility use the new data to update - OFBD_RS_OA_DATA_IS_MODIFIED
+ // Bit 2: BIOS has updated the OA, so tell the utility doesn't to update - OFBD_RS_OA_UPDATE_SKIPPED
+ // Bit 3: BIOS doesn't allow the OA update, tell the utility stop the flash procedure - OFBD_RS_OA_UPDATE_DECLINED
+ // Bit 4~14: Reserved
+ // Bit 15: Use dbErrorID field for utility return OEM specific error code, when this Bit is set to 1. - OFBD_RS_OA_USE_OEM_ERROR_ID
+ UINT32 ddOABlockAddr; // OA Block Address of BIOS ROM (For NCB mode to use)
+ UINT64 ddOADataBuffer; // OA Data Buffer
+ UINT32 dwOADataSize; // OA Data Buffer Size
+} OFBD_TC_5A_OA_HANDLE_STRUCT;
+
+//=======================================
+// Type Code 5B Struct
+//=======================================
+typedef struct
+{
+ UINT8 dbGetSts; // Get Status
+ UINT8 dbRetSts; // Return Status
+
+} OFBD_TC_5B_AC_BATTERY_STRUCT;
+
+//=======================================
+// Type Code 70 Struct
+//=======================================
+typedef struct
+{
+ UINT8 Command;
+ UINT8 Status;
+} OFBD_TC_70_SFU_STRUCT;
+#pragma pack()
+
+//=============================
+// Type Code Specific Status
+//=============================
+//=============================
+// Type Code 50 Return Status
+//=============================
+#define OFBD_TC_GRS_PROTECT BIT00
+
+//===============================
+// Type Code 50 Hole Description
+//===============================
+#define OFBD_TC_RH_HD_ROMHOLE BIT00
+#define OFBD_TC_RH_HD_NCB BIT01
+
+//=============================
+// Type Code 51 Return Status
+//=============================
+#define OFBD_TC_CFG_P BIT00
+#define OFBD_TC_CFG_B BIT01
+#define OFBD_TC_CFG_N BIT02
+#define OFBD_TC_CFG_K BIT03
+#define OFBD_TC_CFG_E BIT04
+#define OFBD_TC_CFG_Q BIT05
+#define OFBD_TC_CFG_REBOOT BIT06
+#define OFBD_TC_CFG_X BIT07
+#define OFBD_TC_CFG_S BIT08
+#define OFBD_TC_CFG_ECUF BIT09
+#define OFBD_TC_CFG_SHUTDOWN BIT10
+#define OFBD_TC_CFG_SETUPRESERVE BIT11
+#define OFBD_TC_CFG_ROMHOLE BIT12
+#define OFBD_TC_CFG_NCB BIT13
+#define OFBD_TC_CFG_CLNEVNLOG BIT14
+#define OFBD_TC_CFG_R BIT15
+#define OFBD_TC_CFG_O BIT16
+#define OFBD_TC_CFG_GAN BIT17 //Patch for EIP 75281
+#define OFBD_TC_CFG_KN BIT18
+#define OFBD_TC_CFG_L BIT19
+#define OFBD_TC_CFG_LN BIT20
+#define OFBD_TC_CFG_A BIT21
+#define OFBD_TC_CFG_OAD BIT22
+#define OFBD_TC_CFG_CAPSULE BIT23
+#define OFBD_TC_CFG_RECOVERY BIT24
+#define OFBD_TC_CFG_CAF BIT25
+
+//===============================
+// Type Code 52 Get Check Status
+// See OFBD Spec 5.2, 6.3 for detail
+//===============================
+#define OFBD_TC_OPC_GET BIT00
+#define OFBD_TC_OPC_CHECK BIT01
+
+//============================
+// Type Code 52 Return Status
+// See OFBD Spec 5.2, 6.3 for detail
+//============================
+#define OEM_RS_PC_REQ BIT00
+#define OEM_RS_PC_CK_OK BIT01
+#define OEM_RS_PC_TIMES_EXCEEDED BIT02
+
+//========================================
+// Type Code 53 Get & Check Status
+// See OFBD Spec 5.4, 6.4 for detail
+//========================================
+#define OFBD_TC_ORI_GET BIT00
+#define OFBD_TC_ORI_CHECK BIT01
+
+//========================================
+// Type Code 53 Return Status
+// See OFBD Spec 5.4, 6.4 for detail
+//========================================
+#define OFBD_TC_ORI_REQ BIT00
+#define OFBD_TC_ORI_ROM BIT01
+#define OFBD_TC_ORI_MOD BIT02
+#define OFBD_TC_ORI_GUID BIT03
+#define OFBD_TC_ORI_CK_OK BIT04
+
+//=======================================
+// Type Code 54 Set Status
+// See OFBD Spec 5.5, 6.5 for detail
+//=======================================
+#define OFBD_TC_STD_EC_START BIT00
+#define OFBD_TC_STD_EC_FLASH BIT01
+#define OFBD_TC_STD_EC_END BIT02
+#define OFBD_TC_ECX_SIZE BIT03 //(EIP31739+) Andy+
+#define OFBD_TC_ECX_ERASE BIT04
+#define OFBD_TC_ECX_VERIFY BIT05
+#define OFBD_TC_ECX_RETRY BIT06
+
+//=======================================
+// Type Code 54 Return Status
+// See OFBD Spec 5.5, 6.5 for detail
+//=======================================
+#define OFBD_RS_EC_OK BIT00
+#define OFBD_RS_EC_CHKSUM BIT01
+#define OFBD_RS_EC_ENTRY BIT02
+#define OFBD_RS_EC_ERASE BIT03
+#define OFBD_RS_EC_INIT BIT04
+#define OFBD_RS_EC_START BIT05
+#define OFBD_RS_EC_WRITE BIT06
+#define OFBD_RS_EC_EXIT BIT07
+#define OFBD_RS_EC_CHIPID BIT08
+
+//===============================
+// Type Code 55 SubFunction
+//===============================
+#define OFBD_TC_MEUD_GETINFO 0
+#define OFBD_TC_MEUD_START BIT00
+
+//============================
+// Type Code 55 Return Status
+//============================
+#define OFBD_TC_MEUD_OK BIT00
+#define OFBD_TC_MEUD_ERROR BIT01
+
+//===============================
+// Type Code 56 Get Check Status
+//===============================
+#define OFBD_TC_SETUP_SUPPORT BIT00
+#define OFBD_TC_SETUP_STORE BIT01
+#define OFBD_TC_SETUP_RESTORE BIT02
+#define OFBD_TC_DMI_STORE BIT03
+#define OFBD_TC_DMI_RESTORE BIT04
+
+//============================
+// Type Code 56 Return Status
+//============================
+#define OFBD_TC_SETUP_OK BIT00
+#define OFBD_TC_SETUP_NOT_SUPPORT BIT01
+#define OFBD_TC_SETUP_STORE_ERROR BIT02
+#define OFBD_TC_SETUP_RESTORE_ERROR BIT03
+#define OFBD_TC_DMI_STORE_ERROR BIT04
+#define OFBD_TC_DMI_RESTORE_ERROR BIT05
+
+//===================================//
+// Type Code 57 Flash & Return Status//
+//===================================//
+// OEM CMD - Flash Status.
+#define OFBD_TC_OEM_CMD_BF 1
+#define OFBD_TC_OEM_CMD_AF 2
+#define OFBD_TC_OEM_CMD_BE 3
+#define OFBD_TC_OEM_CMD_SF 4
+#define OFBD_TC_OEM_CMD_BUF 5 // For /CMD:"" to use (EIP40787+)
+#define OFBD_TC_OEM_CMD_BUF_SF 6
+#define OFBD_TC_OEM_CMD_BUF_AF 7
+#define OFBD_TC_OEM_CMD_BUF_BE 8
+
+// OEM CMD - Return Status.
+#define OFBD_TC_OEM_CMD_OK BIT00
+#define OFBD_TC_OEM_CMD_NOT_SUPPORT BIT01
+#define OFBD_TC_OEM_CMD_ERROR BIT02
+
+//===============================
+// Type Code 58 Func Status
+//===============================
+#define OFBD_TC_CEL_FUNC_REQ BIT00
+
+//============================
+// Type Code 58 Return Status
+//============================
+#define OFBD_TC_CEL_OK BIT00
+#define OFBD_TC_CEL_ERROR BIT01
+#define OFBD_TC_CEL_BIOS_NOT_SUPPORT BIT02
+
+//===============================
+// Type Code 59 SubFunction
+//===============================
+#define OFBD_TC_SECUREUD_LOAD2SMM BIT00
+#define OFBD_TC_SECUREUD_VERIFY_SMM BIT01
+#define OFBD_TC_SECUREUD_DONE BIT02
+
+//===============================
+// Type Code 5A Func Status
+//===============================
+#define OFBD_TC_OA_UPDATE_NOTIFY BIT00
+
+//============================
+// Type Code 5A Return Status
+//============================
+#define OFBD_RS_OA_DATA_IS_INVALID BIT00
+#define OFBD_RS_OA_DATA_IS_MODIFIED BIT01
+#define OFBD_RS_OA_UPDATE_SKIPPED BIT02
+#define OFBD_RS_OA_UPDATE_DECLINED BIT03
+#define OFBD_RS_OA_USE_OEM_ERROR_ID BIT15
+
+//===============================
+// Type Code 5B Func Status
+//===============================
+#define OFBD_TC_AC_BAT_INFO_REQ BIT00
+
+//============================
+// Type Code 5B Return Status
+//============================
+#define OFBD_RS_AC_BAT_OK BIT00
+#define OFBD_RS_AC_BAT_ERR BIT01
+
+//===================================//
+// Type Code 70 Get & Set Status //
+//===================================//
+#define OFBD_TC_SFU_GET_FLASH_INFO BIT00
+#define OFBD_TC_SFU_LOAD_FIRMWARE_IMAGE BIT01
+#define OFBD_TC_SFU_GET_FLASH_UPDATE_POLICY BIT02
+#define OFBD_TC_SFU_SET_FLASH_UPDATE_METHOD BIT03
+#define OFBD_TC_SFU_RUNTIME_FLASH BIT04
+
+//==============================//
+// Type Code 70 Return Status //
+//==============================//
+#define OFBD_TC_SFU_OK BIT00
+#define OFBD_TC_SFU_NOT_SUPPORTED BIT01
+#define OFBD_TC_SFU_FW_AUTH_FAILED BIT02
+#define OFBD_TC_SFU_INVALID_FW_CAPSULE_HDR BIT03
+#define OFBD_TC_SFU_SIGNING_KEYS_DONT_MATCH BIT04
+#define OFBD_TC_SFU_UNSUPPORTED_CERTIFICATE_HDR_FORMAT BIT05
+
+//----------------------------------------------------------------------------
+// OFBD ROM HOLE CORE SERVICE ROUTINE - INVOKE FUNCTION - Function Driven Token
+//----------------------------------------------------------------------------
+#define OFBD_RH_HOLE_EXIST_CK 0 // This token is to check OEM's ROM Hole's existance.
+#define OFBD_RH_GET_HOLE_PHY_ADDR 1 // Pass Addr, Size, then Get Phy Addr. Notice: If NULL means AFU Does not support
+#define OFBD_RH_HOLE_PROTECT 2 // Protect Sts, Addr, Size
+
+//----------------------------------------------------------------------------
+// ROM HOLE - INVOKE FUNCTION RTN STS
+//----------------------------------------------------------------------------
+#define OFBD_RH_RTN_SUCCESSFUL 0
+#define OFBD_RH_RTN_SERVICE_NOT_FOUND BIT00
+#define OFBD_RH_RTN_SERVICE_PARAMETER_ERROR BIT01
+#define OFBD_RH_RTN_HOLE_NOT_EXIST BIT02
+#define OFBD_RH_RTN_PHY_ADDR_NOT_VALID BIT03
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//**********************************************************************//
+//**********************************************************************//
diff --git a/Core/EM/OFBD/OFBD.mak b/Core/EM/OFBD/OFBD.mak
new file mode 100644
index 0000000..0fe4c0b
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.mak
@@ -0,0 +1,111 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2013, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
+
+#*************************************************************************
+# $Header: /Alaska/SOURCE/Modules/OFBD/OFBD.mak 6 8/15/13 5:35a Terrylin $
+#
+# $Revision: 6 $
+#
+# $Date: 8/15/13 5:35a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/OFBD.mak $
+#
+# 6 8/15/13 5:35a Terrylin
+# [Category] Bug Fix
+# [Severity] Important
+# [Symptom] Build Error
+# [Files] OFBD.mak
+# OFBD.c
+#
+# 5 6/14/13 3:54a Terrylin
+# [Category] Improvement
+# [Description] Add the Not InSmmFuncList support.
+# [Files] OFBD.sdl
+# OFBD.mak
+# OFBD.c
+#
+# 4 3/16/11 10:39p Terrylin
+# Correct Copyright information.
+#
+# 3 3/16/11 10:13p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description of each file for user more
+# clearly.
+# [Files] OFBD.mak
+# OFBD.dxs
+# OFBD.c
+# OFBD.h
+#
+# 2 7/02/09 5:53a Klzhan
+# Improvement: Add an E-Link in SMM.
+#
+# 1 4/13/09 5:46a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OFBD.mak
+#
+# Description: Make file for the OFBD.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : OFBD
+
+OFBD : $(BUILD_DIR)\OFBD.mak OFBDBin
+
+$(BUILD_DIR)\OFBD.mak : $(OFBD_DIR)\$(@B).cif $(OFBD_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OFBD_ELINK_LISTS = \
+/D\"OFBD_SMM_FUNC_LIST=$(OFBDInSmmFuncList)\"\
+/D\"OFBD_NOT_SMM_FUNC_LIST=$(OFBDNotInSmmFuncList)\"
+
+OFBDBin : $(AMIDXELIB) $(OFBDLISTLIB)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\OFBD.mak all\
+ NAME=OFBD\
+ GUID=57E56594-CE95-46ad-9531-3C49310CA7CE\
+ ENTRY_POINT=OFBDEntryPoint\
+ "INIT_LIST=$(OFBDPartsList)"\
+!IF $(PI_SPECIFICATION_VERSION) >= 0x1000A
+ TYPE=DXESMM_DRIVER\
+ DEPEX1=$(OFBD_DIR)\OFBD.dxs \
+ DEPEX1_TYPE=EFI_SECTION_SMM_DEPEX \
+!ELSE
+ TYPE=BS_DRIVER\
+ DEPEX1=$(OFBD_DIR)\OFBD.dxs \
+ DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \
+!ENDIF
+ "CFLAGS=$(CFLAGS) /DVFRCOMPILE $(OFBD_ELINK_LISTS)"\
+ COMPRESS=1\
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2013, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/Core/EM/OFBD/OFBD.sdl b/Core/EM/OFBD/OFBD.sdl
new file mode 100644
index 0000000..268a56a
--- /dev/null
+++ b/Core/EM/OFBD/OFBD.sdl
@@ -0,0 +1,68 @@
+TOKEN
+ Name = OFBD_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable On Flash Block Description support in Project"
+End
+
+TOKEN
+ Name = "OFBD_SW_SMI_VALUE"
+ Value = "0x26"
+ Help = "Sw SMI value of OFBD item change"
+ TokenType = Integer
+ TargetH = Yes
+ Range = "0-0xff"
+End
+
+TOKEN
+ Name = "OFBD_VERSION"
+ Value = "0x0210"
+ Help = "OFBD Version"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+MODULE
+ Help = "Includes OFBD.mak to Project"
+ File = "OFBD.mak"
+End
+
+PATH
+ Name = "OFBD_DIR"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OFBD.ffs"
+ Parent = "FV_MAIN"
+ Help = "OFBD component"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\AmiBufferValidationLib.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OFBDLISTLIB"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "OFBDPartsList"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "OFBDInSmmFuncList"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "OFBDNotInSmmFuncList"
+ InvokeOrder = ReplaceParent
+End
diff --git a/Core/EM/OFBD/OFBD_Help.chm b/Core/EM/OFBD/OFBD_Help.chm
new file mode 100644
index 0000000..0ec5f4a
--- /dev/null
+++ b/Core/EM/OFBD/OFBD_Help.chm
Binary files differ
diff --git a/Core/EM/OFBD/SecureFlash/SecureFlash.c b/Core/EM/OFBD/SecureFlash/SecureFlash.c
new file mode 100644
index 0000000..f787d33
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.c
@@ -0,0 +1,343 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD Secure Flash/SecureFlash.c 7 1/17/12 10:24p Lawrencechang $
+//
+// $Revision: 7 $
+//
+// $Date: 1/17/12 10:24p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Secure Flash/SecureFlash.c $
+//
+// 7 1/17/12 10:24p Lawrencechang
+// Remove unnecessary header file.
+//
+// 6 1/04/12 7:14a Lawrencechang
+// Remove runtime flash codes, which will be done by SMIFlash protocol.
+//
+// 5 12/21/11 8:17a Lawrencechang
+// 1. Check if SMIFlash module exists or enables before install SMIFlash
+// protocol.
+// 2. Add WriteBlockEx() for SMIFlash protocol compatibility.
+// WriteBlockEx() will be only used in SMIFlash protocol but no exposed to
+// flash ROM interface.
+//
+// 4 10/29/11 5:26a Lawrencechang
+// Modified for adding SMIFlash protocol compatibility.
+//
+// 3 10/28/11 4:28a Lawrencechang
+// Add GetFlashInfo() for compatibility with SMIFlash protocol. Only works
+// with 4.6.3.2_OFBD.1.0.2.
+//
+// 2 10/18/11 3:11a Lawrencechang
+// Force LoadFirmwareImage(), GetFlashUpdatePolicy() and
+// SetFlashUpdateMethod() to return correct error code.
+//
+// 1 9/16/11 4:25a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SecureFlash.c
+//
+// Description: This file provides OFBD Secure Flash function.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include <EFI.h>
+#include <Token.h>
+#include <AmiDxeLib.h>
+#include <Protocol/SecSmiFlash.h>
+#include <Protocol/FlashProtocol.h>
+
+#include <OFBD.h>
+#include <SecureFlash.h>
+
+// GUIDs of consumed protocols
+static EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+static EFI_GUID gEfiSecSmiFlashProtocolGuid = EFI_SEC_SMI_FLASH_GUID;
+
+// Consumed protocols
+EFI_SEC_SMI_FLASH_PROTOCOL *SecSmiFlash = NULL;
+FLASH_PROTOCOL *Flash = NULL;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadFirmwareImage
+//
+// Description: Transfer ROM image from AFU's buffer to Secure Flash Module
+// through EFI_SEC_SMI_FLASH_PROTOCOL.
+//
+// Input:
+// IN VOID *Data The data is a memory buffer. Its content is FUNC_BLOCK
+// defined in SmiFlash.h. The member function
+// LOAD_FLASH_IMAGE in EFI_SEC_SMI_FLASH_PROTOCOL only
+// accepts this type of parameter.
+//
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LoadFirmwareImage (
+ VOID *Data
+)
+{
+ EFI_STATUS Status;
+
+ if (NULL == SecSmiFlash) return EFI_UNSUPPORTED;
+
+ Status = SecSmiFlash->LoadFwImage((FUNC_BLOCK *)Data);
+
+ ((FUNC_BLOCK *)Data)->ErrorCode = (EFI_ERROR(Status) ? 1 : 0);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetFlashUpdatePolicy
+//
+// Description: Get Flash Update Policy from Secure Flash module.
+//
+// Input:
+// IN VOID *Data The data is a memory buffer. Its content is
+// FLASH_POLICY_INFO_BLOCK defined in SecSmiFlash.h.
+//
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetFlashUpdatePolicy (
+ VOID *Data
+)
+{
+ EFI_STATUS Status;
+ FLASH_POLICY_INFO_BLOCK *pFlashPolicy = (FLASH_POLICY_INFO_BLOCK *)Data;
+
+ if (NULL == SecSmiFlash) return EFI_UNSUPPORTED;
+
+ Status = SecSmiFlash->GetFlUpdPolicy(pFlashPolicy);
+
+ pFlashPolicy->ErrorCode = (EFI_ERROR(Status) ? 1 : 0);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetFlashUpdateMethod
+//
+// Description: Set Flash Update Policy to Secure Flash module.
+//
+// Input:
+// IN VOID *Data The data is a memory buffer. Its content is
+// FUNC_FLASH_SESSION_BLOCK defined in SecSmiFlash.h.
+//
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetFlashUpdateMethod (
+ VOID *Data
+)
+{
+ EFI_STATUS Status;
+ FUNC_FLASH_SESSION_BLOCK *pFlashSessionBlock = (FUNC_FLASH_SESSION_BLOCK *)Data;
+
+ if (NULL == SecSmiFlash) return EFI_UNSUPPORTED;
+
+ Status = SecSmiFlash->SetFlUpdMethod(pFlashSessionBlock);
+
+ pFlashSessionBlock->ErrorCode = (EFI_ERROR(Status) ? 1 : 0);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SecureFlashProtocolCallback
+//
+// Description: Locate SecSmiFlash protocol callback
+//
+// Input:
+// IN EFI_EVENT Event
+// IN VOID *Context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SecureFlashProtocolCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ pBS->LocateProtocol(&gEfiSecSmiFlashProtocolGuid, NULL, &SecSmiFlash);
+ pBS->CloseEvent(Event);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SmmFlashProtocolCallback
+//
+// Description: Locate Flash protocol callback
+//
+// Input:
+// IN EFI_EVENT Event
+// IN VOID *Context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SmmFlashProtocolCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ pBS->LocateProtocol(&gFlashSmmProtocolGuid, NULL, &Flash);
+ pBS->CloseEvent(Event);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: ASFUInSmm
+//
+// Description: This function installs the ASFU Protocol.
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ASFUInSmm (
+ VOID
+)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE DummyHandle = NULL;
+
+ Status = pBS->LocateProtocol(&gEfiSecSmiFlashProtocolGuid, NULL, &SecSmiFlash);
+ if (EFI_ERROR(Status)) {
+ EFI_EVENT SecFlashCallbackEvt;
+ VOID *Reg;
+ RegisterProtocolCallback(
+ &gEfiSecSmiFlashProtocolGuid,
+ SecureFlashProtocolCallback,
+ NULL,
+ &SecFlashCallbackEvt,
+ &Reg);
+ }
+
+ Status = pBS->LocateProtocol(&gFlashSmmProtocolGuid, NULL, &Flash);
+ if (EFI_ERROR(Status)) {
+ EFI_EVENT SmmFlashCallbackEvt;
+ VOID *Reg;
+ RegisterProtocolCallback(
+ &gFlashSmmProtocolGuid,
+ SmmFlashProtocolCallback,
+ NULL,
+ &SmmFlashCallbackEvt,
+ &Reg);
+ }
+
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ASFUEntry
+//
+// Description: OFBD Secure Flash Update Entry point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ASFUEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled
+)
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_70_SFU_STRUCT *ASFUStructPtr;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (*pOFBDDataHandled == 0) {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ ASFUStructPtr = (OFBD_TC_70_SFU_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if (pOFBDHdr->OFBD_FS & OFBD_FS_SFU) {
+ //Check Type Code ID
+ if (pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_SFU) {
+ switch (ASFUStructPtr->Command) {
+ case OFBD_TC_SFU_LOAD_FIRMWARE_IMAGE :
+ Status = LoadFirmwareImage(pOFBDTblEnd);
+ break;
+ case OFBD_TC_SFU_GET_FLASH_UPDATE_POLICY :
+ Status = GetFlashUpdatePolicy(pOFBDTblEnd);
+ break;
+ case OFBD_TC_SFU_SET_FLASH_UPDATE_METHOD :
+ Status = SetFlashUpdateMethod(pOFBDTblEnd);
+ break;
+ default :
+ Status = EFI_UNSUPPORTED;
+ break;
+ }
+ if (EFI_ERROR(Status)) {
+ *pOFBDDataHandled = 0xFE;
+ ASFUStructPtr->Status = OFBD_TC_SFU_NOT_SUPPORTED;
+ } else {
+ *pOFBDDataHandled = 0xFF;
+ ASFUStructPtr->Status = OFBD_TC_SFU_OK;
+ }
+ }
+ }
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/SecureFlash/SecureFlash.chm b/Core/EM/OFBD/SecureFlash/SecureFlash.chm
new file mode 100644
index 0000000..1d3bd8d
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.chm
Binary files differ
diff --git a/Core/EM/OFBD/SecureFlash/SecureFlash.cif b/Core/EM/OFBD/SecureFlash/SecureFlash.cif
new file mode 100644
index 0000000..feed7f2
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "On Flash Block Description (APTIO) - Secure Flash"
+ category = eModule
+ LocalRoot = "Core\EM\OFBD\SecureFlash\"
+ RefName = "OFBD_SECURE_FLASH"
+[files]
+"SecureFlash.sdl"
+"SecureFlash.mak"
+"SecureFlash.h"
+"SecureFlash.c"
+"SecureFlash.chm"
+<endComponent>
diff --git a/Core/EM/OFBD/SecureFlash/SecureFlash.h b/Core/EM/OFBD/SecureFlash/SecureFlash.h
new file mode 100644
index 0000000..99b251e
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.h
@@ -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/OFBD Secure Flash/SecureFlash.h 3 1/04/12 7:12a Lawrencechang $
+//
+// $Revision: 3 $
+//
+// $Date: 1/04/12 7:12a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD Secure Flash/SecureFlash.h $
+//
+// 3 1/04/12 7:12a Lawrencechang
+// Remove SMIFlash related codes.
+//
+// 2 10/29/11 5:29a Lawrencechang
+// Modified for adding SMIFlash protocol compatibility.
+//
+// 1 9/16/11 4:25a Lawrencechang
+// Initial check-in.
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SecureFlash.h
+//
+// Description: Header file for OFBD Secure Flash module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_ASFU_H_
+#define _EFI_ASFU_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/SecureFlash/SecureFlash.mak b/Core/EM/OFBD/SecureFlash/SecureFlash.mak
new file mode 100644
index 0000000..337cf61
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.mak
@@ -0,0 +1,76 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD Secure Flash/SecureFlash.mak 4 1/04/12 7:11a Lawrencechang $
+#
+# $Revision: 4 $
+#
+# $Date: 1/04/12 7:11a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD Secure Flash/SecureFlash.mak $
+#
+# 4 1/04/12 7:11a Lawrencechang
+# Remove SMIFlash related make rules.
+#
+# 3 10/29/11 5:30a Lawrencechang
+# Modified for adding SMIFlash protocol compatibility.
+#
+# 2 10/03/11 2:36a Lawrencechang
+# Modify path of SecSMIFlashHook.obj to adapt the latest version
+# SecureFlashPkg.
+#
+# 1 9/16/11 4:25a Lawrencechang
+# Initial check-in.
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: SecureFlash.mak
+#
+# Description: Make file for OFBD Secure Flash module.
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+
+$(OFBD_SECUREFLASH_LIB) : $(BUILD_DIR)\SecureFlash.mak OFBD_SECUREFLASH_BIN
+
+OFBD_SECFLASH_EXT_INCLUDES = \
+ /I $(OFBD_DIR)\
+ /I $(OFBD_SECURE_FLASH_DIR)
+
+$(BUILD_DIR)\SecureFlash.mak : $(OFBD_SECURE_FLASH_DIR)\$(@B).cif
+ $(CIF2MAK) $(OFBD_SECURE_FLASH_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+OFBD_SECUREFLASH_BIN : $(AMIDXELIB) $(FLASHLIB) $(OFBD_EXT_OBJS)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\SecureFlash.mak all\
+ "MY_INCLUDES=$(OFBD_SECFLASH_EXT_INCLUDES)"\
+ NAME=SecureFlash TYPE=LIBRARY LIBRARY_NAME=$(OFBD_SECUREFLASH_LIB)
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/SecureFlash/SecureFlash.sdl b/Core/EM/OFBD/SecureFlash/SecureFlash.sdl
new file mode 100644
index 0000000..da1b3c5
--- /dev/null
+++ b/Core/EM/OFBD/SecureFlash/SecureFlash.sdl
@@ -0,0 +1,51 @@
+TOKEN
+ Name = SECURE_FLASH_SUPPORT
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable Security Flash in Project"
+ Token = "SecSMIFlash_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "OFBD_SECUREFLASH_LIB"
+ Value = "$(BUILD_DIR)\OfbdSecureFlash.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[OFBD Security Update]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+PATH
+ Name = "OFBD_SECURE_FLASH_DIR"
+End
+
+MODULE
+ Help = "Includes SecureFlash.mak to Project"
+ File = "SecureFlash.mak"
+End
+
+ELINK
+ Name = "$(OFBD_SECUREFLASH_LIB)"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ASFUEntry,"
+ Parent = "OFBDPartsList"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "ASFUInSmm,"
+ Parent = "OFBDInSmmFuncList"
+ InvokeOrder = AfterParent
+End
diff --git a/Core/EM/OFBD/StdEC/StdEC.c b/Core/EM/OFBD/StdEC/StdEC.c
new file mode 100644
index 0000000..7fd87fa
--- /dev/null
+++ b/Core/EM/OFBD/StdEC/StdEC.c
@@ -0,0 +1,531 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/OFBD/StdEC/StdEC.c 2 3/16/11 10:36p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:36p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/StdEC/StdEC.c $
+//
+// 2 3/16/11 10:36p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] StdEC.mak
+// StdEC.c
+// StdEC.h
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/25/05 5:37p Markw
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: StdEC.c
+//
+// Description:
+// This function is used to support flashing AMI EC firmware.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "StdEC.h"
+#include "..\OFBD.h"
+
+
+UINT8 PMBase30 = 0 ; // (for Intel ICHx)
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: ObFullRead
+//
+// Description: Waits for Output Buffer Full and then reads the data port
+//
+// Input: None
+//
+// Output: KBC Data port data
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+
+UINT8 ObFullRead()
+{
+ for (;;) {
+ if (IoRead8(EC_KBC_CMD_PORT) & EC_KBC_OBF) {
+ return IoRead8(EC_KBC_DATA_PORT);
+ }
+ }
+}
+
+void IbFree()
+{
+ for (;;) {
+ if (!(IoRead8(EC_KBC_CMD_PORT) & EC_KBC_IBF)) {
+ break;
+ }
+ }
+}
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: WriteKeyboardCommand
+//
+// Description: Writes command to KBC.
+//
+// Input: Command to send to KBC
+//
+// Output: None
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+
+void WriteKeyboardCommand(UINT8 bCmd)
+{
+ IbFree();
+ IoWrite8(EC_KBC_CMD_PORT, bCmd);
+ IbFree();
+}
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: WriteKeyboardData
+//
+// Description: Writes data to KBC.
+//
+// Input: Data to send to KBC
+//
+// Output: None
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+void WriteKeyboardData(UINT8 bData)
+{
+ IbFree();
+ IoWrite8(EC_KBC_DATA_PORT, bData);
+ IbFree();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDECCommand
+//
+// Description: EC command
+//
+// Input:
+// IN UINT8 bCmd
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDECCommand(IN UINT8 bCmd)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ WriteKeyboardCommand(bCmd);
+ if(ObFullRead() != EC_NO_ERROR_FM_ACK)
+ Status = RETURN_ERR;
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDECCheckSum
+//
+// Description: computes EC data checksum
+//
+// Input:
+// IN UINT8 *BuffPtr
+// IN UINT32 Size
+// Output:
+// UINT32
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32
+OFBDECCheckSum(IN UINT8 *BuffPtr, IN UINT32 Size)
+{
+ UINT32 CheckSum = 0;
+ UINT32 i = 0;
+
+ for (i = 0; i < Size / sizeof (UINT32); i++)
+ CheckSum += *(UINT32*)(BuffPtr + i * sizeof (UINT32));
+
+ return (~CheckSum);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: USBKeyboardMouseDisable
+//
+// Description: USB Keyboard Mouse Disable
+//
+// Input:
+// IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr
+// OUT UINT8 *ReturnErr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+USBKeyboardMouseDisable(
+ IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr,
+ OUT UINT8 *ReturnErr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if(ECStructPtr->dbFlaSts & OFBD_TC_STD_EC_START)
+ {
+ *ReturnErr = 0;
+ // Disable Legacy USB SMI
+ //for example (for Intel ICHx)
+ //PMBase30 = IoRead8 (PM_BASE_ADDRESS + 0x30) ;
+ //IoWrite8 ( (PM_BASE_ADDRESS + 0x30), (PMBase30 & ~8));
+ }
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: USBKeyboardMouseEnable
+//
+// Description: USB Keyboard Mouse Enable
+//
+// Input:
+// IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr,
+// IN UINT8 *ReturnErr)
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+USBKeyboardMouseEnable(
+ IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr,
+ IN UINT8 *ReturnErr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if((ECStructPtr->dbFlaSts & OFBD_TC_STD_EC_END) | (*ReturnErr != 0))
+ {
+ // Restore Legacy USB SMI
+ //for example (for Intel ICHx)
+ //IoWrite8 ( (PM_BASE_ADDRESS + 0x30), PMBase30 ) ;
+ }
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDStdECStart
+//
+// Description: for EC firmware entry flash mode and start transmit data
+//
+// Input:
+// IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDStdECStart(
+ IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 ChipID = 0;
+ VOID *pOFBDTblEnd = (VOID *)((UINT8 *)ECStructPtr + sizeof(OFBD_TC_54_STD_EC_STRUCT) + sizeof(OFBD_END));
+
+ WriteKeyboardCommand(EC_CMD_DISABLE_KBD); //0xAD
+
+ //Identify Chip ID
+ WriteKeyboardCommand(EC_CMD_GET_CHIPID); //0xA3
+ ChipID = ObFullRead() << 8; //Chip ID HiByte
+ ChipID |= ObFullRead(); //save Chip ID LowByte
+ if(*(UINT16 *)pOFBDTblEnd != ChipID)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_CHIPID;
+ WriteKeyboardCommand(EC_CMD_ENABLE_KBD); //0xAE
+ return(RETURN_ERR);
+ }
+
+ WriteKeyboardCommand(EC_CMD_ENABLE_KBD); //0xAE
+
+ //Entry Flash Mode 0xDF
+ if(OFBDECCommand(EC_CMD_ENTRY_FLASHMODE) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_ENTRY;
+ return(RETURN_ERR);
+ }
+
+ //Erase Flash Memory 0x01
+ if(OFBDECCommand(EC_CMD_ERASE_MEMORY) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_ERASE;
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+ return(RETURN_ERR);
+ }
+
+ //Initial Programming Mode 0x02
+ if(OFBDECCommand(EC_CMD_INITIAL_PM) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_INIT;
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+ return(RETURN_ERR);
+ }
+
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_OK;
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDStdECFlash
+//
+// Description: for EC firmware to transmit data
+//
+// Input:
+// IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDStdECFlash(IN OFBD_TC_54_STD_EC_STRUCT *ECStructPtr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 CheckSum = 0;
+ UINT8 ByteCheckSum = 0;
+ VOID *pOFBDTblEnd = (VOID *)((UINT8 *)ECStructPtr + sizeof(OFBD_TC_54_STD_EC_STRUCT) + sizeof(OFBD_END));
+ UINT8 *DataPtr = (UINT8 *)(*(UINT64 *)((UINT8 *)pOFBDTblEnd - sizeof(OFBD_END)));
+ UINT32 i, j;
+
+ //calc Check Sum
+ CheckSum = OFBDECCheckSum(DataPtr, ECStructPtr->ddSize);
+ if(ECStructPtr->ddChkSum != CheckSum)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_CHKSUM;
+ return(RETURN_ERR);
+ }
+
+ for(i=0; i < ECStructPtr->ddSize; i += 0x80)
+ {
+ //Start Flash Data Transmit
+ if(OFBDECCommand(EC_CMD_START_TRANS) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_START;
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+ return(RETURN_ERR);
+ }
+ ByteCheckSum = 0;
+ for(j = 0; j < 0x80; j++)
+ {
+ WriteKeyboardData(*(DataPtr + i + j));
+ ByteCheckSum += *(DataPtr + i + j);
+ }
+ if(ObFullRead() == ByteCheckSum)
+ {
+ //Write Flash Data 0x04
+ if(OFBDECCommand(EC_CMD_WRITE_DATA) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_WRITE;
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+ return(RETURN_ERR);
+ }
+ }
+ else
+ {
+ i -= 0x80;
+ }
+ }
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_OK;
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDStdECEnd
+//
+// Description: for EC firmware leave flash mode and finished transmit data
+//
+// Input:
+// IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDStdECEnd(
+ IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr,
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ //Exit Programming Mode 0x05
+ if(OFBDECCommand(EC_CMD_EXIT_PM) != EFI_SUCCESS)
+ {
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_EXIT;
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+ return(RETURN_ERR);
+ }
+
+ if(pOFBDHdr->OFBD_OS & OFBD_OS_DOS)
+ WriteKeyboardCommand(EC_CMD_RESTART); //0xFF
+ else
+ WriteKeyboardCommand(EC_CMD_EXIT_FLASHMODE); //0xFE
+
+ ECStructPtr->dwRetSts |= OFBD_RS_EC_OK;
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDStdECFlashHandle
+//
+// Description: OFBD Standard EC Flash Handle
+//
+// Input:
+// IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDStdECFlashHandle(
+ IN OUT OFBD_TC_54_STD_EC_STRUCT *ECStructPtr,
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ReturnErr = 0;
+
+ USBKeyboardMouseDisable(ECStructPtr, &ReturnErr);
+
+ if(ECStructPtr->dbFlaSts & OFBD_TC_STD_EC_START)
+ {
+ //Entry flash mode
+ ReturnErr = (UINT8)OFBDStdECStart(ECStructPtr);
+ }
+ else if(ECStructPtr->dbFlaSts & OFBD_TC_STD_EC_FLASH)
+ {
+ //Transmit data
+ ReturnErr = (UINT8)OFBDStdECFlash(ECStructPtr);
+ }
+ else if(ECStructPtr->dbFlaSts & OFBD_TC_STD_EC_END)
+ {
+ //Leave flash mode
+ ReturnErr = (UINT8)OFBDStdECEnd(ECStructPtr, pOFBDHdr);
+ }
+ else
+ {
+ Status = RETURN_ERR;
+ }
+
+ USBKeyboardMouseEnable(ECStructPtr, &ReturnErr);
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDEntryPoint
+//
+// Description: OFBD Standard EC Flash Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StdECEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_54_STD_EC_STRUCT *ECStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ ECStructPtr = (OFBD_TC_54_STD_EC_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ //TRACE((-1,"pOFBDHdr address is:%x ------\n",pOFBDHdr));
+ //TRACE((-1,"pOFBDTblEnd address is:%x ------\n",*(UINT64 *)((UINT8 *)pOFBDTblEnd -sizeof(OFBD_END))));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_EC)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_EC)
+ {
+ //IoWrite32(0x300, *(UINT32 *)((UINT8 *)pOFBDTblEnd -4)); //debug
+
+ if(OFBDStdECFlashHandle(ECStructPtr, pOFBDHdr) == EFI_SUCCESS)
+ {
+ //Standard EC Flash Handled
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ else
+ {
+ //Not Standard EC Flash Data
+ *pOFBDDataHandled = 0;
+ return;
+ }
+ }
+ else
+ {
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Core/EM/OFBD/StdEC/StdEC.cif b/Core/EM/OFBD/StdEC/StdEC.cif
new file mode 100644
index 0000000..07273a2
--- /dev/null
+++ b/Core/EM/OFBD/StdEC/StdEC.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "Embedded Controller Flash"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\StdEC\"
+ RefName = "OFBD_STDEC"
+[files]
+"StdEC.sdl"
+"StdEC.mak"
+"StdEC.c"
+"StdEC.h"
+<endComponent>
diff --git a/Core/EM/OFBD/StdEC/StdEC.h b/Core/EM/OFBD/StdEC/StdEC.h
new file mode 100644
index 0000000..c126f0c
--- /dev/null
+++ b/Core/EM/OFBD/StdEC/StdEC.h
@@ -0,0 +1,102 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/OFBD/StdEC/StdEC.h 2 3/16/11 10:36p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:36p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/StdEC/StdEC.h $
+//
+// 2 3/16/11 10:36p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] StdEC.mak
+// StdEC.c
+// StdEC.h
+//
+// 1 4/13/09 5:46a Lawrencechang
+// Initial check-in.
+//
+// 1 3/13/06 1:16a Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: StdEC.h
+//
+// Description: Header file for the StdEC
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_STDEC_H_
+#define _EFI_STDEC_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+//===============================
+// Standard EC Flash Port define
+//===============================
+#define EC_KBC_DATA_PORT 0x60
+#define EC_KBC_CMD_PORT 0x64
+
+//===============================
+// Standard EC status bits definition
+//===============================
+#define EC_KBC_OBF 0x01
+#define EC_KBC_IBF 0x02
+
+//===========================
+// Standard EC Flash Command
+//===========================
+#define EC_CMD_ERASE_MEMORY 0x01
+#define EC_CMD_INITIAL_PM 0x02
+#define EC_CMD_START_TRANS 0x03
+#define EC_CMD_WRITE_DATA 0x04
+#define EC_CMD_EXIT_PM 0x05
+#define EC_CMD_ENTRY_FLASHMODE 0x0DF
+#define EC_CMD_EXIT_FLASHMODE 0x0FE
+#define EC_CMD_RESTART 0x0FF
+#define EC_NO_ERROR_FM_ACK 0x0FA
+#define EC_CMD_GET_CHIPID 0x0A3
+#define EC_CMD_DISABLE_KBD 0x0AD
+#define EC_CMD_ENABLE_KBD 0x0AE
+
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (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/Core/EM/OFBD/StdEC/StdEC.mak b/Core/EM/OFBD/StdEC/StdEC.mak
new file mode 100644
index 0000000..a3d3624
--- /dev/null
+++ b/Core/EM/OFBD/StdEC/StdEC.mak
@@ -0,0 +1,75 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/OFBD/StdEC/StdEC.mak 2 3/16/11 10:35p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:35p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/StdEC/StdEC.mak $
+#
+# 2 3/16/11 10:35p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] StdEC.mak
+# StdEC.c
+# StdEC.h
+#
+# 1 4/13/09 5:46a Lawrencechang
+# Initial check-in.
+#
+# 1 3/18/07 5:23p Felixp
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: StdEC.mak
+#
+# Description: Make file for the StdEC.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : StdEC
+
+StdEC : $(BUILD_DIR)\StdEC.mak StdECBin
+
+$(BUILD_DIR)\StdEC.mak : $(OFBD_StdEC_DIR)\$(@B).cif $(OFBD_StdEC_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_StdEC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+StdECBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\StdEC.mak all\
+ NAME=StdEC \
+ TYPE=LIBRARY LIBRARY_NAME=$(STDECLIB)
+
+$(STDECLIB) : StdEC
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/Core/EM/OFBD/StdEC/StdEC.sdl b/Core/EM/OFBD/StdEC/StdEC.sdl
new file mode 100644
index 0000000..1d2caf8
--- /dev/null
+++ b/Core/EM/OFBD/StdEC/StdEC.sdl
@@ -0,0 +1,39 @@
+TOKEN
+ Name = "StdEC_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable Embedded Controller Flash support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "STDECLIB"
+ Value = "$(BUILD_DIR)\StdEC.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "OFBD_StdEC_DIR"
+End
+
+MODULE
+ Help = "Includes StdEC.mak to Project"
+ File = "StdEC.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\StdEC.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "StdECEntry,"
+ Parent = "OFBDPartsList"
+ Token = "StdEC_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+