summaryrefslogtreecommitdiff
path: root/Core/EM/OFBD/MEUD
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/MEUD
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Core/EM/OFBD/MEUD')
-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
17 files changed, 2545 insertions, 0 deletions
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 **
+//** **
+//*************************************************************************
+//*************************************************************************