summaryrefslogtreecommitdiff
path: root/Chipset/eM/ME/MEUD/MEFwUpdLcl
diff options
context:
space:
mode:
Diffstat (limited to 'Chipset/eM/ME/MEUD/MEFwUpdLcl')
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.h566
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.libbin0 -> 31840 bytes
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/me_status.h986
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.c701
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.cif17
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.dxs9
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.mak118
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.sdl51
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLclUpdateHooks.c596
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl_SBY.dxs14
-rw-r--r--Chipset/eM/ME/MEUD/MEFwUpdLcl/MeFwUpdLclProtocol.h109
11 files changed, 3167 insertions, 0 deletions
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.h b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.h
new file mode 100644
index 0000000..062fe89
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.h
@@ -0,0 +1,566 @@
+/*++
+
+This file contains a 'Sample Driver' and is licensed as such
+under the terms of your license agreement with Intel or your
+vendor. This file may be modified by the user, subject to
+the additional terms of the license agreement
+
+--*/
+
+/*++
+
+Copyright (c) 2009-13 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ FwUpdateLib.h
+
+Abstract:
+
+ FW Update Local Sample Code Header file
+
+--*/
+
+#define INVALID_DATA_FORMAT_VERSION 0
+#define INVALID_MANIFEST_DATA 1
+#define NO_FPT_IMAGE 2
+#define MANIFEST_BUFFER 0x1000
+#define FPT_PARTITION_NAME_FPT 0x54504624
+
+//=====
+#define bool BOOLEAN
+
+extern
+InitializeLib(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+);
+
+void _fltused();
+
+typedef UINT32 STATUS;
+
+typedef struct {
+ UINT16 Major;
+ UINT16 Minor;
+ UINT16 Hotfix;
+ UINT16 Build;
+} FWVersion;
+
+typedef struct {
+ FWVersion code;
+ FWVersion rcvy;
+} FlashVersion;
+
+typedef struct
+{
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[8];
+} _UUID;
+
+typedef enum
+{
+ FWU_ENV_MANUFACTURING = 0, // Manufacturing update
+ FWU_ENV_IFU, // Independent Firmware update
+}FWU_ENVIRONMENT;
+
+enum errorValues {
+ FWU_ERROR_SUCCESS,
+ FWU_IME_NO_DEVICE = 8193,
+ FWU_UPD_VER_MIS = 8199,
+ FWU_VER_GET_ERR = 8204,
+ FWU_CERT_ERR = 8213,
+ FWU_REBOOT_NEEDED = 8703,
+ FWU_SKU_MISMATCH,
+ FWU_VER_MISMATCH,
+ FWU_SGN_MISMATCH,
+ FWU_GENERAL,
+ FWU_UPD_PROCESS,
+ FWU_NO_MEMORY = 8710,
+ FWU_AUTH = 8712,
+ FWU_IMG_HEADER,
+ FWU_FILE_OPEN,
+ FWU_HTTP_ERROR,
+ FWU_USAGE_ERROR,
+ FWU_HOSTNAME,
+ FWU_UPDATE_TIMEOUT,
+ FWU_LOCAL_DIS,
+ FWU_SECURE_DIS,
+ FWU_IME_UN_SUP_MESS = 8722,
+ FWU_NO_UPDATE,
+ FWU_IME_NOT_READY,
+ FWU_LAST_STATUS,
+ FWU_GET_VER_ERR = 8727,
+ FWU_IME_SMALL_BUFF,
+ FWU_WSMAN_NO = 8734,
+ FWU_UNSUPPRT_OS = 8740,
+ FWU_ERROR_FW,
+ FWU_HECI,
+ FWU_UNSUPPRT_PLAT,
+ FWU_VERIFY_OEM_ID_ERR,
+ FWU_INVALID_OEM_ID = 8745,
+ FWU_INVALID_IMG_LENGTH,
+ FWU_GLBL_BUFF_UNAVAILABLE,
+ FWU_INVALID_FW_PARAMS,
+ FWU_AMT_STATUS_INTERNAL_ERROR,
+ FWU_AMT_STATUS_NOT_READY = 8750,
+ FWU_AMT_STATUS_INVALID_AMT_MODE,
+ FWU_AMT_STATUS_INVALID_MESSAGE_LENGTH,
+ FWU_SAVE_RESTORE_POINT_ERROR,
+ FWU_FILE_WRITE,
+ FWU_GET_BLIST_ERROR = 8755,
+ FWU_CHECK_VERSION_ERROR,
+ FWU_DISPLAY_FW_VERSION,
+ FWU_IMAGE_UNDER_VCN,
+ FWU_IMAGE_VER_HIST_CHK_FAIL,
+ FWU_DOWNGRADE_VETOED = 8760,
+ FWU_FW_WRITE_FILE_FAIL,
+ FWU_FW_READ_FILE_FAIL,
+ FWU_FW_DELETE_FILE_FAIL,
+ FWU_PARTITION_LAYOUT_NOT_COMP,
+ FWU_DOWNGRADE_NOT_ALLOWED_DATA_MISMATCH = 8765,
+ FWU_UPDATE_PASSWORD_NOT_MATCHED,
+ FWU_UPDATE_PASSWORD_EXCEED_MAXIMUM_RETRY,
+ FWU_UPDATE_PASSWORD_NOT_PROVIDED,
+ FWU_UPDATE_POLLING_FAILED,
+ FWU_FILE_ALREADY_EXISTS = 8770,
+ FWU_FILE_INVALID,
+ FWU_USAGE_ERROR_B,
+ FWU_AUDIT_POLICY_FAILURE,
+ FWU_ERROR_CREATING_FT,
+ FWU_SAL_NOTIFICATION_ERROR = 8775,
+ FWU_GET_PATTRIB_ERROR,
+ FWU_GET_UPD_INFO_STATUS,
+ FWU_PID_NOT_EXPECTED,
+ FWU_UPDATE_INRECOVERY_MODE_RESTRICT_UPDATE_TO_ATTEMPTED_VERSION,
+ FWU_BUFFER_COPY_FAILED,
+ FWU_GET_ME_FWU_INFO,
+ FWU_APP_REGISTER_OS_FAILURE,
+ FWU_APP_UNREGISTER_OS_FAILURE,
+ FWU_INVALID_PARTID,
+ FWU_LIVE_PING_FAILURE,
+ FWU_SERVICE_CONNECT_FAILURE,
+ FWU_SERVICE_NOT_AVAILABLE,
+ FWU_SERVICE_BUSY,
+ FWU_USER_NOT_ADMIN,
+ FWU_WMI_FAIL,
+ FWU_CHK_BIT_LOCKER_FAIL,
+ FWU_REG_CMD_FAIL,
+ FWU_UPDATE_IMAGE_BLACKLISTED,
+ FWU_DOWNGRADE_NOT_ALLOWED_SVN_RESTRICTION
+};
+//=====
+
+
+// below structure is defiend by the fw team
+// in fwucommon.h file
+typedef struct _UPDATE_FLAGS_LIB
+{
+ unsigned int RestorePoint:1; // If set indicate restore point
+ unsigned int RestartOperation:1; // If set indicate restart operation, like lost hard drive etc...
+ unsigned int UserRollback:1; // indicates user has initiated a rollback
+ unsigned int Reserve:29; //
+}UPDATE_FLAGS_LIB;
+
+// Used by the tool to perform FULL FW update
+typedef enum _UPDATE_TYPE
+{
+ DOWNGRADE_SUCCESS = 0,
+ DOWNGRADE_FAILURE,
+ SAMEVERSION_SUCCESS,
+ SAMEVERSION_FAILURE,
+ UPGRADE_SUCCESS,
+ UPGRADE_PROMPT
+}UPDATE_TYPE;
+
+//Image type to validate the binary sent to update
+//For Full Update - only FULL image type is valid
+//For Partial Update - only FULL and PARTIAL image type is valid
+//FULL Image => Image with Flash Partition Table, FTPR, and NFTPR
+//PARTIAL Image => Image with no Flash Partition Table or FTPR or NFTPR,
+// only WCOD or LOCL
+typedef enum _IMAGE_TYPE
+{
+ FULL = 0,
+ PARTIAL,
+ RESTORE,
+ INVALID
+}IMAGE_TYPE;
+
+typedef enum _SKU_TYPE {
+ SKU_1_5_MB = 0,
+ SKU_5_MB,
+ SKU_INVALID
+}SKU_TYPE;
+
+//Used by the tool to retrieve FW version information
+typedef struct {
+ unsigned short Major;
+ unsigned short Minor;
+ unsigned short Hotfix;
+ unsigned short Build;
+} VersionLib;
+
+//Should be used by both tool and UNS to retrieve the Updated UPV version
+typedef struct _IPU_UPDATED_INFO
+{
+ unsigned int UpdatedUpvVer;//Version from the update image file that is for updating IPU
+ unsigned int Reserved[4];
+}IPU_UPDATED_INFO;
+
+// disable the "zero-sized array" warning
+#pragma warning(disable:4200)
+typedef enum _FWU_STATUS {
+ FWU_STATUS_SUCCESS = 0,
+ FWU_STATUS_NO_MEMORY = 1,
+ FWU_STATUS_NOT_READY = 2,
+ FWU_STATUS_ILLEGAL_LENGTH = 3,
+ FWU_STATUS_AUTHENTICATION_FAILED = 4,
+ FWU_STATUS_INTERNAL_ERROR = 5,
+ FWU_STATUS_SKU_FAILURE = 6,
+ FWU_STATUS_VERSION_FAILURE = 7
+}FWU_STATUS;
+
+// From FWU_if.h
+
+#pragma pack(1)
+
+/**
+ * FWU_GET_INFO_MESSAGE - get version
+ *
+ * @MessageType: FWU_MESSAGE_TYPE_GET_INFO
+ */
+typedef struct {
+ UINT32 MessageType;
+} FWU_GET_INFO_MESSAGE;
+
+/**
+ * FWU_DATA_MESSAGE - data fragment of the image
+ *
+ * @MessageType: FWU_MESSAGE_TYPE_DATA
+ * @Length: The length of the data field, in Little Endian
+ * @Reserved: Reserved, must be 0
+ * @Data: The data of the image fragment
+ */
+typedef struct {
+ UINT32 MessageType;
+ UINT32 Length;
+ UINT8 Reserved[3];
+#ifndef _DOS
+ UINT8 Data[0];
+#endif
+} FWU_DATA_MESSAGE;
+
+#pragma pack()
+
+bool
+IsUpdateStatusPending (
+ IN UINT32 status
+)
+/*++
+
+Routine Description:
+
+ Checks if ME FW Update client is ready to accept an update
+
+Arguments:
+
+
+Returns:
+
+ true if ready
+
+--*/
+;
+
+unsigned int
+CheckPolicyBuffer (
+ IN char* buffer,
+ IN int bufferLength,
+ IN int AllowSV,
+ IN UPDATE_TYPE *Upd_Type,
+ IN VersionLib *ver
+)
+/*++
+
+Routine Description:
+
+ This routine determines if the update is allowed given the ME Upgrade/downgrade/same version policy
+
+Arguments:
+
+Returns:
+
+ FWU_ERROR_SUCCESS if operation allowed
+
+--*/
+;
+
+unsigned int
+FwUpdateFullBuffer (
+ IN char *buffer,
+ IN unsigned int bufferLength,
+ IN char *_pwd,
+ IN int _forceResetLib,
+ IN unsigned int UpdateEnvironment,
+ IN _UUID OemID,
+ IN UPDATE_FLAGS_LIB update_flags,
+ IN void(*func)(float, float)
+)
+/*++
+
+Routine Description:
+
+ This routine sends the buffer to the ME FW Update Client
+
+Arguments:
+
+Returns:
+
+ FWU_ERROR_SUCCESS if operation allowed
+
+--*/
+;
+
+unsigned int
+FWUpdate_QueryStatus_Get_Response (
+ IN unsigned int *UpdateStatus,
+ IN unsigned int *TotalStages,
+ IN unsigned int *PercentWritten,
+ IN unsigned int *LastUpdateStatus,
+ IN unsigned int *LastResetType
+)
+/*++
+
+Routine Description:
+
+ This routine queries the ME Kernel for the update status
+
+Arguments:
+
+Returns:
+
+ FWU_ERROR_SUCCESS if operation allowed
+
+--*/
+;
+
+bool
+VerifyOemId(
+ IN _UUID id
+)
+/*++
+
+Routine Description:
+
+ The ME FW when created has an OEM ID embedded in it. For security
+ reasons, we need to verify that the OEM ID of the application (mOemID)
+ matches the OEM ID of the ME FW.
+
+ NOTE: A connection to the client is required before this routine is
+ executed.
+
+Arguments:
+
+ UUID to check
+
+
+Returns:
+
+ true or false indicating if the match was succesfull
+
+--*/
+;
+
+EFI_STATUS
+GetLastStatus(
+ OUT UINT32 *LastFwUpdateStatus
+)
+/*++
+
+Routine Description:
+
+ Get the last status of the FW Update Client - this is used to determine if a previous update
+ requires a reboot
+
+Arguments:
+
+ UINT32 pointer for results of previous update.
+
+
+Returns:
+
+ EFI Error code
+
+--*/
+;
+
+EFI_STATUS
+GetLastUpdateResetType (
+ OUT UINT32 *LastResetType
+)/*++
+
+Routine Description:
+
+ Get the last status of the FW Update Client - this is used to determine if a previous update
+ requires a reboot
+
+Arguments:
+
+ UINT32 pointer for results of previous update.
+
+
+Returns:
+
+ EFI Error code
+
+--*/
+;
+
+EFI_STATUS
+GetInterfaces (
+ OUT UINT16 *interfaces
+)
+;
+
+EFI_STATUS
+CheckVersion(
+ IN UINT8 *FileBuffer,
+ IN BOOLEAN AllowSV,
+ OUT FlashVersion *FlashVersion,
+ OUT UINT32 *LastFwUpdateStatus
+)
+/*++
+
+Routine Description:
+
+ Policy routine to verify if the current FW version is older
+ than the version in the image.
+
+ The routine will return the result of a previous ME FW Update. If a reset is required
+ before an update can occur, the return value will indicate it
+
+ NOTE: A connection to the client is required before this routine is
+ executed.
+
+Arguments:
+
+ UINT8 pointer to update image
+ BOOLEAN indicating TRUE for same version update
+ FlashVersion pointer for return version numbers of FW Update image
+ UINT32 pointer for results of previous update.
+
+
+Returns:
+
+ EFI_UNSUPPORTED if version is of update image is not supported
+
+--*/
+;
+
+EFI_STATUS
+StartUpdate(
+ IN UINT8 *FileBuffer,
+ IN UINT32 FileLength,
+ IN CHAR8 *Password,
+ IN VOID (*DataProgressProc)(),
+ IN UINT32 DataProgessSteps,
+ OUT STATUS *FWU_Status
+)
+/*++
+
+Routine Description:
+
+ Start the update process by asking the ME FW Update client
+ to allocate a buffer for the image. Note that the ME does not update the flash until
+ the FWU_END message is received.
+
+ If the current ME Flash image is password protected, then that password is required to unlock
+ the update process
+
+ Because the process of downloading the image is time consuming, a callback is provided for each
+ chunk of data sent to the ME FW Update client. If desired, the caller can specify the number of steps
+ that the total data send will have (e.g. 100 means a total of 100 callbacks for the entire duration). The
+ number of steps supplied will be divided by the total result of (FileLength / Chunksize) + 1.
+
+Arguments:
+
+ UINT8 pointer to FW Update Image
+ UINT32 FW Update image length
+ CHAR16 pointer to password (if no password then NULL)
+ VOID pointer to callback function (if no callback then NULL)
+ UINT32 callback steps (1 means each packet sent will trigger a callback)
+ UINT32 pointer to ME FW Update Client return status
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+;
+
+EFI_STATUS
+EndUpdate (
+ IN VOID (*EndProgressProc)(),
+ IN UINT32 EndProgressSteps,
+ OUT STATUS *FWU_Status
+)
+/*++
+
+Routine Description:
+
+ Send the FWU_END message to the ME after a successful data download.
+ This operation will request the ME to validate the image and update the
+ flash. Depending on flash speed, the operation may take serveral minutes
+ to finish. Be patient...
+
+ Because the process of updating the image is time consuming, a callback is provided each delay (5 seconds)
+ that occurs waiting for the ME FW Update client to respond. If desired, the caller can specify a number of timeouts before
+ a callback (e.g. 1 means send wait 5 seconds then invoke the callback routine).
+
+Arguments:
+
+ VOID pointer to callback function (if no callback then NULL)
+ UINT32 callback ratio (1 means wait 5 seconds and then trigger a callback)
+ UINT32 pointer to ME FW Update Client return status
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+;
+
+EFI_STATUS
+GetFwFlashVersion(
+ IN FWVersion *fwVersion
+)
+/*++
+
+Routine Description:
+
+ Get the FW version of the currently running ME FW
+
+ NOTE: A connection to the client is required before this routine is
+ executed.
+
+Arguments:
+
+ FWVersion pointer to FW Flash version
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+; \ No newline at end of file
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.lib b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.lib
new file mode 100644
index 0000000..267f5a6
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/FWUpdateLib.lib
Binary files differ
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/me_status.h b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/me_status.h
new file mode 100644
index 0000000..5a66448
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/IntelLib/me_status.h
@@ -0,0 +1,986 @@
+/*++
+
+INTEL CONFIDENTIAL
+Copyright 2005-2013 Intel Corporation All Rights Reserved.
+
+The source code contained or described herein and all documents
+related to the source code ("Material") are owned by Intel Corporation
+or its suppliers or licensors. Title to the Material remains with
+Intel Corporation or its suppliers and licensors. The Material
+contains trade secrets and proprietary and confidential information of
+Intel or its suppliers and licensors. The Material is protected by
+worldwide copyright and trade secret laws and treaty provisions. No
+part of the Material may be used, copied, reproduced, modified,
+published, uploaded, posted, transmitted, distributed, or disclosed in
+any way without Intel's prior express written permission.
+
+No license under any patent, copyright, trade secret or other
+intellectual property right is granted to or conferred upon you by
+disclosure or delivery of the Materials, either expressly, by
+implication, inducement, estoppel or otherwise. Any license under such
+intellectual property rights must be express and approved by Intel in
+writing.
+
+File Name:
+
+ me_status.h
+
+Abstract:
+
+ Defines the ME Status codes
+
+Authors:
+
+ Hemaprabhu Jayanna
+
+--*/
+
+#ifndef _ME_STATUS_H_
+#define _ME_STATUS_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// ERROR & STATUS CODE RANGES //
+///////////////////////////////////////////////////////////////////////////////
+// RANGE // DESCRIPTION //
+///////////////////////////////////////////////////////////////////////////////
+// 0x0000FFFF - 0x00000000 // Pre-defined standard error values used by all //
+// // ME Components and interfaces //
+///////////////////////////////////////////////////////////////////////////////
+// 0x0001FFFF - 0x00010000 // Capability Module specific error codes //
+///////////////////////////////////////////////////////////////////////////////
+// 0xFFFFFFFF - 0x00020000 // Reserved for future use. //
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// KERNEL STATUS AND ERROR CODES //
+//The following are the status and error codes returned by the ME Kernel. //
+//ThreadX Codes range from (0x00 to 0x7F) //
+//Other Kernel codes range from (0x80 to 0xFF) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+
+
+//
+//STATUS_SUCCESS
+// The operation completed successfully.
+//
+
+/**
+ * @brief The operation completed successfully.
+ */
+#define STATUS_SUCCESS 0x0
+
+//
+//STATUS_DELETED
+// The requested object has been deleted.
+//
+#define STATUS_DELETED 0x1
+
+//
+//STATUS_POOL_ERROR
+// An invalid memory pool pointer (NULL) was given or the pool is
+// already created.
+//
+#define STATUS_POOL_ERROR 0x2
+
+//
+//STATUS_PTR_ERROR
+// An invalid pointer was provided.
+//
+#define STATUS_PTR_ERROR 0x3
+
+//
+//STATUS_WAIT_ERROR
+// The specified wait option is invalid.
+//
+#define STATUS_WAIT_ERROR 0x4
+
+//
+//STATUS_SIZE_ERROR
+// The size of the specified object (memory pool, stack, message queue,
+// etc.) is invalid.
+//
+#define STATUS_SIZE_ERROR 0x5
+
+//
+//STATUS_GROUP_ERROR
+// An invalid group pointer was provided. The pointer is NULL or points
+// to an already created group.
+//
+#define STATUS_GROUP_ERROR 0x6
+
+//
+//STATUS_NO_EVENTS
+// The requested event could not be found.
+//
+#define STATUS_NO_EVENTS 0x7
+
+//
+//STATUS_OPTION_ERROR
+// Invalid event flag set option (AND, OR).
+//
+#define STATUS_OPTION_ERROR 0x8
+
+//
+//STATUS_QUEUE_ERROR
+// An invalid queue pointer passed or the queue is already created.
+//
+#define STATUS_QUEUE_ERROR 0x9
+
+//
+//STATUS_QUEUE_EMPTY
+// The requested queue is empty.
+//
+#define STATUS_QUEUE_EMPTY 0xA
+
+//
+//STATUS_QUEUE_FULL
+// The requested queue is full.
+//
+#define STATUS_QUEUE_FULL 0xB
+
+//
+//STATUS_SEMAPHORE_ERROR
+// An invalid semaphore pointer provided or the semaphore is already created.
+//
+#define STATUS_SEMAPHORE_ERROR 0xC
+
+//
+//STATUS_NO_INSTANCE
+// The requested instance was not found (semaphore count is 0x0).
+//
+#define STATUS_NO_INSTANCE 0xD
+
+//
+//STATUS_THREAD_ERROR
+// An invalid thread control pointer provided or the thread is already created.
+//
+#define STATUS_THREAD_ERROR 0xE
+
+//
+//STATUS_PRIORITY_ERROR
+// An invalid thread priority level has been given.
+//
+#define STATUS_PRIORITY_ERROR 0xF
+
+//
+//STATUS_START_ERROR
+// An invalid auto-start selection was given during thread creation.
+// NOTE: This value is the same a as STATUS_NO_MEMORY.
+//
+#define STATUS_START_ERROR 0x10
+
+//
+//STATUS_DELETE_ERROR
+// The requested object can not be deleted. This can occur if an attempt is
+// made to delete a thread that is not in a terminated or completed state.
+//
+#define STATUS_DELETE_ERROR 0x11
+
+//
+//STATUS_RESUME_ERROR
+// The thread can not be resumed (e.g. the specified thread is not in a
+// suspended state or was suspended by a driver other than the RTOS protocol).
+//
+#define STATUS_RESUME_ERROR 0x12
+
+//
+//STATUS_CALLER_ERROR
+// Invalid caller of this service.
+//
+#define STATUS_CALLER_ERROR 0x13
+
+//
+//STATUS_SUSPEND_ERROR
+// The thead can not be suspended (e.g. the specified thread is in a
+// terminated or completed state).
+//
+#define STATUS_SUSPEND_ERROR 0x14
+
+//
+//STATUS_TIMER_ERROR
+// An invalid timer object pointer was given.
+//
+#define STATUS_TIMER_ERROR 0x15
+
+//
+//STATUS_TICK_ERROR
+// An invalid value (0x0) supplied for the initial tick count.
+//
+#define STATUS_TICK_ERROR 0x16
+
+//
+//STATUS_ACTIVATE_ERROR
+// The object is already active.
+//
+#define STATUS_ACTIVATE_ERROR 0x17
+
+//
+//STATUS_THRESH_ERROR
+// An invalid preemption threashold was specified.
+//
+#define STATUS_THRESH_ERROR 0x18
+
+//
+//STATUS_SUSPEND_LIFTED
+// An attempt to resume a thread marked for delayed suspension has
+// occurred.
+//
+#define STATUS_SUSPEND_LIFTED 0x19
+
+//
+//STATUS_WAIT_ABORTED
+// The wait condition on which the thread is waiting has been aborted.
+//
+#define STATUS_WAIT_ABORTED 0x1A
+
+//
+//STATUS_WAIT_ABORT_ERROR
+// An attempt to abort a waiting thread was attempted on a thread that is
+// not in a waiting condition (terminated, ready, completed, etc.).
+//
+#define STATUS_WAIT_ABORT_ERROR 0x1B
+
+//
+//STATUS_MUTEX_ERROR
+// An invalid mutex pointer was provided.
+//
+#define STATUS_MUTEX_ERROR 0x1C
+
+//
+//STATUS_NOT_AVAILABLE
+// An attempt to remove a mutex on which a thread is suspended has been
+// attempted.
+//
+#define STATUS_NOT_AVAILABLE 0x1D
+
+//
+//STATUS_NOT_OWNED
+// An attempt to access a mutex not owned by the caller was made.
+//
+#define STATUS_NOT_OWNED 0x1E
+
+//
+//STATUS_INHERIT_ERROR
+// An invalid inherit option was given when trying to create a mutex.
+//
+#define STATUS_INHERIT_ERROR 0x1F
+
+//
+//STATUS_TIMER_RUNNING
+// An attempt to set an alarm was made while alarm is already enabled.
+//
+#define STATUS_TIMER_RUNNING 0x20
+
+//
+//STATUS_INVALID_FUNCTION
+// The requested function was not found.
+//
+#define STATUS_INVALID_FUNCTION 0x80
+
+//
+//STATUS_NOT_FOUND
+// The requested item could not be found.
+//
+#define STATUS_NOT_FOUND 0x81
+
+//
+//STATUS_ACCESS_DENIED
+// Access to the requested object could not be granted.
+//
+#define STATUS_ACCESS_DENIED 0x82
+
+//
+//STATUS_INVALID_HANDLE
+// The provided handle does not exist.
+//
+#define STATUS_INVALID_HANDLE 0x83
+
+//
+//STATUS_INVALID_ACCESS
+// An attempt was made to access an inaccessible or unavailable object.
+//
+#define STATUS_INVALID_ACCESS 0x84
+
+//
+//STATUS_INVALID_PARAMS
+// One or more parameters are invalid.
+//
+#define STATUS_INVALID_PARAMS 0x85
+
+//
+//STATUS_INVALID_PARAMS
+// Request could not be processed because a Power Management event is already
+// in progress.
+//
+#define STATUS_PM_EVENT_IN_PROGRESS 0x86
+
+//
+//STATUS_WRITE_PROTECTED
+// The media is write protected. When writing to flash, this means
+// the flash block is write protected.
+//
+#define STATUS_WRITE_PROTECTED 0x87
+
+//
+//STATUS_NOT_READY
+// The h/w device is not ready.
+//
+#define STATUS_NOT_READY 0x88
+
+//
+//STATUS_NOT_SUPPORTED
+// The function, message or request is not recognized or supported.
+//
+#define STATUS_NOT_SUPPORTED 0x89
+
+//
+//STATUS_NETWORK_BUSY
+// The network device is busy.
+//
+#define STATUS_NETWORK_BUSY 0x8A
+
+//
+//STATUS_DEVICE_ERROR
+// The h/w device reported an error while attempting the operation.
+//
+#define STATUS_DEVICE_ERROR 0x8B
+
+//
+//STATUS_INVALID_ADDRESS
+// The address provided in invalid.
+//
+#define STATUS_INVALID_ADDRESS 0x8C
+
+//
+//STATUS_INVALID_COMMAND
+// The requested command is unrecognized or invalid.
+//
+#define STATUS_INVALID_COMMAND 0x8D
+
+//
+//STATUS_STACK_OVERFLOW
+// The request caused a stack overflow.
+//
+#define STATUS_STACK_OVER_FLOW 0x8E
+
+//
+//STATUS_BUFFER_TOO_SMALL
+// The provided buffer is too small to hold the requested data.
+//
+#define STATUS_BUFFER_TOO_SMALL 0x8F
+
+//
+//STATUS_LOAD_ERROR
+// The image failed to load.
+//
+#define STATUS_LOAD_ERROR 0x90
+
+//
+//STATUS_INVALID_BUFFER
+// The buffer was not the proper size for the request.
+//
+#define STATUS_INVALID_BUFFER 0x91
+
+//
+//STATUS_NO_RESPONSE
+// No response was received from the requested target.
+//
+#define STATUS_NO_RESPONSE 0x92
+
+//
+//STATUS_TIMED_OUT
+// The device or object timed out and was unable to complete the request.
+//
+#define STATUS_TIMED_OUT 0x93
+
+//
+//STATUS_NOT_STARTED
+// The requested operation could not be started. For protocols, this
+// error indicates the protocol has not been started.
+//
+#define STATUS_NOT_STARTED 0x94
+
+//
+//STATUS_ALREADY_STARTED
+// The requested operation has already been started.
+// - For protocols, this error
+// indicates the protocol has already been started.
+// - For Policy Manager this error means
+// that the MKHI group ID is already registered.
+// For FW update, we only allow one process to do the update at a time, this means error
+// case where FW update is already in progress, the current process will have to try later.
+//
+#define STATUS_ALREADY_STARTED 0x95
+
+//
+//STATUS_PROTOCOL_ERROR
+// The protocol in use has generated an error. For network traffic this error
+// means the networking protocol returned and error. When returned from a
+// protocol this means the protocol itself generated an error.
+//
+#define STATUS_PROTOCOL_ERROR 0x96
+
+//
+//STATUS_INCOMPATIBLE_VERSION
+// The version of the object is incompatible with the request. For protocols,
+// this indicates that the protocol version number is not supported.
+//
+#define STATUS_INCOMPATIBLE_VERSION 0x97
+
+//
+//STATUS_SECURITY_VIOLATION
+// A security violation has occurred.
+//
+#define STATUS_SECURITY_VIOLATION 0x98
+
+//
+//STATUS_AUTHENTICATION_FAIL
+// The authentication of an object has failed.
+//
+#define STATUS_AUTHENTICATION_FAIL 0x99
+
+//
+//STATUS_INVALID_MEM_TYPE
+// The target memory is invalid for the requested operation (e.g. DMA to
+// ROM or cypto DMA from system memory).
+//
+#define STATUS_INVALID_MEM_TYPE 0x9A
+
+//
+//STATUS_MODE_NOT_SUPPORTED
+// The type of blocking mode is not supported. Refer to the documentation on
+// the specific interface.
+//
+#define STATUS_MODE_NOT_SUPPORTED 0x9B
+
+//
+//STATUS_RESOURCE_BUSY
+// The requested resource is busy or can not be acquired.
+//
+#define STATUS_RESOURCE_BUSY 0x9C
+
+//
+//STATUS_OUT_OF_RESOURCES
+// Insufficient resources to perform the request. Used by components operating
+// in non-blocking mode. A caller will be returned this error when a component
+// does not have enough resources like command buffers, PRDs etc... to entertain
+// a new request.
+//
+#define STATUS_OUT_OF_RESOURCES 0x9D
+
+//
+//STATUS_FAILURE
+// A unknown error encountered while performing a requested transaction.
+//
+#define STATUS_FAILURE 0x9E
+
+//
+//STATUS_QUEUED
+// A requested has been successfully placed in a command queue. This status
+// is returned by non-blocking components after successfully queuing a request
+// in their command queue.
+//
+#define STATUS_QUEUED 0x9F
+
+//
+//STATUS_WEAR_OUT_VIOLATION
+// The partition manager returns this error code when it can not perform a
+// requested erase operation due to flash wear out constraints.
+#define STATUS_WEAR_OUT_VIOLATION 0xA0
+
+//
+//STATUS_GENERAL_ERROR
+// This is a general error code used for errors that do not require a specific
+// code.
+#define STATUS_GENERAL_ERROR 0xA1
+
+//
+//STATUS_SMB_EMPTY
+// The smbus slave circular buffer does not contain any smbus transactions data.
+#define STATUS_SMB_EMPTY 0xA2
+
+//
+//STATUS_SMB_NO_MORE_ENTRIES
+// The smbus slave has reached its maximal number of registered transactions.
+// New transactions can not be added until the removal of one of the current
+// registered ones.
+#define STATUS_SMB_NO_MORE_ENTRIES 0xA3
+
+//
+//STATUS_BUS_ERROR
+// Generic error code for bus errors. Common cause could be losing arbitration
+// on a multi-mastered bus.
+#define STATUS_BUS_ERROR 0xA4
+
+//
+//STATUS_IMAGE_INVALID
+// The FW Update image content is invalid.
+#define STATUS_IMAGE_INVALID 0xA5
+
+//
+//STATUS_UPDATE_AUTH_FAILED
+// The FW Update image authentication failed.
+#define STATUS_UPDATE_AUTH_FAILED 0xA6
+
+//
+//STATUS_UPDATE_ALLOWED
+// Used in the policy manager to indicate whether a policy can be updated at
+// the time of this request.
+#define STATUS_UPDATE_ALLOWED 0xA7
+
+//
+//STATUS_UPDATE_NOT_ALLOWED
+// Used in the policy manager to indicate that a policy cannot be updated at
+// the time of this request.
+#define STATUS_UPDATE_NOT_ALLOWED 0xA8
+
+//
+//STATUS_LOCKED
+// Indicates policy element has been already locked and cannot be updated.
+#define STATUS_LOCKED 0xA9
+
+//
+//STATUS_NOT_INITIALIZED
+// Indicates that SDM core is not initialized
+#define STATUS_NOT_INITIALIZED 0xAA //REQUIRES COORDINATION!!!
+
+//
+//STATUS_END_OF_FILE
+// Indicates that EOF is reached while accessing a file
+#define STATUS_END_OF_FILE 0xAB //REQUIRES COORDINATION!!!
+
+//
+//STATUS_NO_STORAGE_AVAILABLE
+// Indicates policy element could not be stored in the NVAR.
+#define STATUS_NO_STORAGE_AVAILABLE 0xB0
+
+//
+//STATUS_LOCKING_NOT_ALLOWED
+// Indicates policy element cannot be locked.
+#define STATUS_LOCKING_NOT_ALLOWED 0xB1
+
+//
+//STATUS_UNKNOWN_LAN_FUSE_CAPS
+// Indicates a unknown capability of the LAN device is being set.
+#define STATUS_UNKNOWN_LAN_FUSE_CAPS 0xB2
+
+//
+//STATUS_INVALID_FEATURE_ID
+// Indicates an invalid feature ID.
+#define STATUS_INVALID_FEATURE_ID 0xB3
+
+//
+//STATUS_PET_TRANSMIT_DISABLED
+// The transmission of pet packets is disabled.
+#define STATUS_PET_TRANSMIT_DISABLED 0xB4
+
+// STATUS_MAX_KERB_DOMAIN_REACHED
+// indicates that in the kerberos ACL there are users from MAX DOMAINS (4).
+#define STATUS_MAX_KERB_DOMAIN_REACHED 0xB5
+
+// STATUS_UPDATE_MISMATCH_HW_SKU
+// Indicates that there is a mismatch between the current HW SKU and the
+// one in the new image.
+#define STATUS_UPDATE_MISMATCH_HW_SKU 0xB6
+
+// STATUS_UPDATE_MISMATCH_FW_SKU
+// Indicates that there is a mismatch between the current FW SKU and the
+// one in the new image.
+#define STATUS_UPDATE_MISMATCH_FW_SKU 0xB7
+
+// STATUS_UPDATE_MISMATCH_VERSION
+// Indicates that there is a mismatch between the current FW version and the
+// one in the new image.
+#define STATUS_UPDATE_MISMATCH_VERSION 0xB8
+
+// STATUS_EVENT_DISABLED_CONFIG
+// This wake event is configured to be disabled (via MEBx setup or remote
+// configuration).
+#define STATUS_EVENT_DISABLED_CONFIG 0xB9
+
+// STATUS_NOT_REGISTERED
+// Caller is trying to use an interface that requires registration, but the
+// registration process has not been completed.
+#define STATUS_NOT_REGISTERED 0xBA
+
+
+// STATUS_INVALID_EVENT
+// Caller is trying to use a wake event code which is invalid
+#define STATUS_INVALID_EVENT 0xBB
+
+// STATUS_INVALID_EVENT
+// Caller is trying to use an event context which is invalid
+#define STATUS_BAD_CONTEXT 0xBC
+
+
+//
+//STATUS_NET_RESTART_NEEDED
+// The network stack need restart to continue working.
+#define STATUS_NET_RESTART_NEEDED 0xBD
+
+//
+//STATUS_OUT_OF_MEMORY
+// This error can be returned for the following reasons:
+// 1.Attempt to allocate memory and no memory is available
+// 2.Attempt to free a memory block on which a thread is suspended
+// NOTE: This value is the same a as STATUS_START_ERROR.
+//
+#define STATUS_OUT_OF_MEMORY 0xBE
+
+
+//
+//STATUS_COUNTER_ROLLOVER
+// This error can be returned by MC_PROTOCOL IncrementCounter()
+// if given monotonic counter reaches maximum value.
+// Along with error, counter will be initialized with value "1"
+//
+// The value will also be returned by TIME_PROTOCOL GetPRTC()
+// if the PRTC rolls over
+#define STATUS_COUNTER_ROLLOVER 0xBF
+
+
+//
+// BLOB SERVICE SPECIFIC FAILURES
+//
+// STATUS_BLOB_INTEGRITY_FAILED
+// STATUS_BLOB_CONFIDENTIALITY_FAILED
+// STATUS_BLOB_AR_FAILED
+#define STATUS_BLOB_INTEGRITY_FAILED 0xC0
+#define STATUS_BLOB_CONFIDENTIALITY_FAILED 0xC1
+#define STATUS_BLOB_AR_FAILED 0xC2
+
+
+
+//STATUS_PROCESSING
+// Caller is asking for process result that is not already finished
+#define STATUS_PROCESSING 0xC3
+
+//STATUS_REGISTERED
+// Caller registered for something that itself or others already did
+#define STATUS_REGISTERED 0xC4
+//
+//STATUS_EAC_NOT_PERMITTED
+// This error can be returned for the following reasons:
+// 1.Attempt to enable EAC when sign certificate is not set
+
+//
+#define STATUS_EAC_NOT_PERMITTED 0xC5
+
+//
+//STATUS_EAC_NO_ASSOCIATION
+// This error can be returned for the following reasons:
+// 1.Attempt to receive a posture or posture hash sign certificate is not set
+
+//
+#define STATUS_EAC_NO_ASSOCIATION 0xC6
+
+//
+//STATUS_AUDIT_FAIL
+// This error can be returned when these conditions are met:
+// 1. The action should be logged to the Audit Log
+// 2. The event was defined as critical
+// 3. The Audit Log is enabled
+// 4. Either:
+// a. The Audit Log is currently Locked
+// b. The storage for the Audit Log is full
+
+//
+#define STATUS_AUDIT_FAIL 0xC7
+
+#define STATUS_DUPLICATED 0xC8
+
+//
+//STATUS_IPP_INTERNAL_ERROR
+// This error can bb returned in case of internal IPP function failed.
+#define STATUS_IPP_INTERNAL_ERROR 0xC9
+
+//
+//STATUS_IPP_CORRUPTED_KEY
+// This error can be returned when trying to load or validate corrupted RSA key
+// using the IPP stack.
+// Can be returned RsaEncryptDecrypt and RsaValidateKey functions.
+#define STATUS_IPP_CORRUPTED_KEY 0xCA
+
+//
+//STATUS_IPP_DATA_NOT_ALIGNED
+// This error can be returned when trying to load, create or validate RSA key using the
+// IPP stack, and the data is not aligned.
+// Can be returned RsaGenerateKey, RsaEncryptDecrypt and RsaValidateKey functions.
+#define STATUS_IPP_DATA_NOT_ALIGNED 0xCB
+
+//
+//STATUS_IPP_OPERATION_ABORTED
+// This error will be returned if the IPP aborted key generation before completion.
+#define STATUS_IPP_OPERATION_ABORTED 0xCC
+
+//
+//STATUS_IPP_CACHE_CONVERTION_FAILED
+// This error can be returned if the TRAMD-Cache conversion failed.
+#define STATUS_IPP_CACHE_CONVERTION_FAILED 0xCD
+
+//
+//STATUS_IPP_EXPONENT_CHANGED
+// This error will be returned if the IPP decided to use differnt exponent (E)
+// than the one the caller supplied.
+#define STATUS_IPP_EXPONENT_CHANGED 0xCE
+
+// STATUS_PERMIT_EXPIRED
+// iCLS Permit has expired
+#define STATUS_PERMIT_EXPIRED 0xCF
+
+// STATUS_PERMIT_RESET_REQUIRED
+// iCLS permit is invalid in some way (for example expired)
+// and HW fuses are overided by permit still
+#define STATUS_PERMIT_RESET_REQUIRED 0xD0
+
+// STATUS_CLOSED_BY_HOST
+// HECI will return this in the event that AddBuffer call is failing because
+// the connection is in a close pending status.
+// This will indicate that freeing the SendBufferQ and BufferQ is not permitted at
+// this time and the client should wait for a HIE_CLOSED message to cleanup HECI_CONNECTION.
+#define STATUS_CLOSED_BY_HOST 0xD1
+
+
+// STATUS_DISABLED_BY_POLICY
+// This error will be returned if the call is blocked by previous defined policy
+#define STATUS_DISABLED_BY_POLICY 0xD2
+
+//STATUS_INVALID_COMP_HANDLE
+// The provided component handle does not exist.
+//
+#define STATUS_INVALID_COMP_HANDLE 0xD3
+
+//
+//Status Codes used by state manager to indicate ME Database status
+//and general Client/Daemon registration problems in state manager
+//that prohibit the Daemon from returning more exact status.
+//
+
+//
+//STATUS_ALREADY_REGISTERED
+// This error is used to indicate if a Daemon is already
+// registered with state manager.
+#define STATUS_ALREADY_REGISTERED 0xD4
+
+//
+//STATUS_DATABASE_IN_USE
+// This error is used to indicate if a ME Database is currently in
+// use when a delete is called on it.
+#define STATUS_DATABASE_IN_USE 0xD5
+
+//
+//STATUS_ENTRY_IN_USE
+// This error is used to indicate if an entry in a ME Database is
+// currently in use when a release is called on it.
+#define STATUS_ENTRY_IN_USE 0xD6
+
+//
+//STATUS_UNABLE_TO_REGISTER
+// This error is used to indicate that a Daemon cannot register
+// with state manager.
+#define STATUS_UNABLE_TO_REGISTER 0xD7
+
+//
+// STATUS_TLB_ENTRY_NOT_FOUND
+// This error indicates that a free TLB entry or the specified TLB entry
+// could not be found.
+//
+#define STATUS_TLB_ENTRY_NOT_FOUND 0xD8
+
+//
+//STATUS_UNABLE_TO_UNREGISTER
+// This error code is used to indicate that a Daemon cannot
+// unregister with the state manager.
+#define STATUS_UNABLE_TO_UNREGISTER 0xD9
+
+//
+//STATUS_TIMER_VALUE_NOT_SET
+// Error used by PRTC to indicate the alarm value
+// has not been set prior to enabling the alarm.
+#define STATUS_TIMER_VALUE_NOT_SET 0xDA
+
+//
+//STATUS_ICV_CHECK_ERROR
+// HW reported an ICV check failure
+#define STATUS_ICV_CHECK_ERROR 0xDB
+
+// STATUS_SUCCESS_WITH_ERRORS
+// This error will be returned if the opration completed but had some errors (e,eg Transfer AHCI for DT)
+// It is shared between Danbury components
+#define STATUS_SUCCESS_WITH_ERRORS 0xDC
+
+// STATUS_SUCCESS_HOST_RESET_REQUIRED
+// This status will be returned by FwUpdateMgr after successfully updating FW
+// if Danbury is enabled
+#define STATUS_SUCCESS_HOST_RESET_REQUIRED 0xDD
+
+// STATUS_FIPS_FAILURE
+// This status will be returned by when FIPS self-tests fail
+#define STATUS_FIPS_FAILURE 0xDE
+
+//STATUS_PRIVILEGE_CHECK
+// Privileged component access
+#define STATUS_PRIVILEGE_CHECK 0xDF
+
+// STATUS_INCOMPLETE
+// This error indicates that the operation is incomplete
+#define STATUS_INCOMPLETE 0xE0
+
+// STATUS_RETRY
+// This error indicates that the operation is being retried or needs to be retried
+#define STATUS_RETRY 0xE1
+
+#define STATUS_NOT_RUN 0xE2
+
+#define STATUS_NOT_IMPLEMENTED 0xE3
+
+
+#define STATUS_INVALID_INDEX 0xE4
+#define STATUS_SLOT_IN_USE 0xE5
+#define STATUS_SLOT_EMPTY 0xE6
+
+// STATUS_OVERRIDDEN
+// This error indicates that the operation can't be performed because
+// it was overridden by some other logic/request
+#define STATUS_OVERRIDDEN 0xE7
+
+//STATUS_PERMIT_IS_DEACTIVE
+// iCLS Permit has been deactivated
+#define STATUS_PERMIT_IS_DEACTIVE 0xF0
+
+//Return this if it is a Patsburg chipset
+#define STATUS_UNKNOWN_CPUID 0xF1
+
+#define STATUS_CRC_ERROR 0xF2
+
+#if 1
+//STATUS for task isolation
+#define STATUS_HECI_CONNECTION_ACCEPT 0xF3
+#define STATUS_HECI_CONNECTION_REJECT 0xF4
+#define STATUS_RETURN_NOT_AVAILABLE 0xF5
+#endif
+//STATUS for PG
+#define STATUS_PG_ENTRY_IN_PROGRESS 0xF6
+
+// Intel Secret Key Unavailable
+// RCR CCG0100111613
+#define STATUS_BLOB_UNAVAILABLE 0xF6
+
+#define STATUS_FPF_READ_MISMATCH 0xF7
+#define STATUS_FPF_ARRAY_FULL 0xF8
+#define STATUS_FPF_WRITE_FAILED 0xF9
+#define STATUS_FPF_FILE_INVALID 0xFA
+#define STATUS_FPF_FILE_FULL 0xFB
+#define STATUS_FPF_FILE_LOCKED 0xFC
+#define STATUS_FPF_NOT_AVAILABLE 0xFD
+#define STATUS_FPF_BUSY 0xFE // FPF write currently in progress
+#define STATUS_FPF_FATAL_ERROR 0xFF // Fatal error, fuses are no longer valid (bad PCH)
+#define STATUS_FPF_FILE_EMPTY 0x100 // File has not been written to
+#define STATUS_FPF_ALREADY_COMMITTED 0x101
+#define STATUS_FPF_COMMIT_FAILED_EOM_NOT_SET 0x102
+#define STATUS_FPF_INVALID_SB_VALUES 0x103
+#define STATUS_FPF_NOT_COMMITTED 0x104
+#define STATUS_FPF_NVAR_MISMATCH 0x105
+#define STATUS_FPF_FILE_UNLOCKED 0x106
+#define STATUS_FPF_COMMIT_NOT_ALLOWED 0x107
+#define STATUS_FPF_CANARY_FAILURE 0x108
+#define STATUS_FPF_SENSE_FAILED 0x109
+#if 1
+// STATUS for FWU kernel between 0x200 to 0x2FF
+#define FW_UPDATE_STATUS UINT32
+
+#define NO_UPDATE 0
+#define STATUS_UPDATE_SUCCESS 0x0 // Zero for sucess anything else is consider failures
+#define STATUS_UPDATE_IMAGE_INVALID 0x201
+#define STATUS_UPDATE_INTEGRITY_FAILURE 0x202
+#define STATUS_UPDATE_SKU_MISMATCH 0x203
+#define STATUS_UPDATE_FW_VERSION_MISMATCH 0x204
+#define STATUS_UPDATE_GENERAL_FAILURE 0x205
+#define STATUS_UPDATE_OUT_OF_RESOURCES 0x206
+#define STATUS_UPDATE_AUDIT_POLICY_FAILURE 0x207
+#define STATUS_UPDATE_ERROR_CREATING_FT 0x208
+#define STATUS_UPDATE_SAL_NOTIFICATION_ERROR 0x209
+#define STATUS_UPDATE_IMG_LOADING 0x20A
+#define STATUS_UPDATE_IMG_AUTHENTICATING 0x20B
+#define STATUS_UPDATE_IMG_PROCESSING 0x20C
+#define STATUS_UPDATE_CREATING_FT 0x20D
+#define STATUS_UPDATE_UPDATING_CODE 0x20E
+#define STATUS_UPDATE_UPDATING_NFT 0x20F
+#define STATUS_UPDATE_FLASH_CODE_PARTITION_INVALID 0x210
+#define STATUS_UPDATE_FLASH_NFT_PARTITION_INVALID 0x211
+#define STATUS_UPDATE_ILLEGAL_IMAGE_LENGTH 0x212
+#define STATUS_UPDATE_NOT_READY 0x213
+
+#define STATUS_UPDATE_HOST_RESET_REQUIRED 0x214
+#define STATUS_INVALID_GLUT 0x215
+#define STATUS_INVALID_OEM_ID 0x216
+
+// New for CPT add below here
+#define STATUS_UPDATE_IMAGE_BLACKLISTED 0x217
+#define STATUS_UPDATE_IMAGE_VERSION_HISTORY_CHECK_FAILURE 0x218
+#define STATUS_UPDATE_DOWNGRADE_VETOED 0x219
+#define STATUS_UPDATE_WRITE_FILE_FAILURE 0x22A
+#define STATUS_UPDATE_READ_FILE_FAILURE 0x22B
+#define STATUS_UPDATE_DELETE_FILE_FAILURE 0x22C
+#define STATUS_UPDATE_PARTITION_LAYOUT_NOT_COMPATIBLE 0x22D // FW Update is not possible due to partition move
+#define STATUS_DOWNGRADE_NOT_ALLOWED_DATA_MISMATCHED 0x22E
+#define STATUS_UPDATE_FW_UPDATE_IS_DISABLED 0x22F
+#define STATUS_UPDATE_PASSWORD_NOT_MATCHED 0x230
+#define STATUS_UPDATE_PASSWORD_EXCEED_MAXIMUM_RETRY 0x231
+#define STATUS_UPDATE_INRECOVERY_MODE_RESTRICT_UPDATE_TO_ATTEMPTED_VERSION 0x232 // They have to update with the same image that they started with.
+
+
+// New for Partial FW update
+#define STATUS_UPDATE_UPV_VERSION_MISMATCHED 0x233 // UPV version mismatched update is not allow
+#define STATUS_UPDATE_INSTID_IS_NOT_EXPECTED_ID 0x234 // Reject update, instance ID sent is not one of expected ID
+#define STATUS_UPDATE_INFO_NOT_AVAILABLE 0x235 // While in the middle of update IPU attrib info will bot be available
+#define STATUS_UPDATE_REJ_IPU_FULL_UPDATE_NEEDED 0x236 // Can't do IPU update while we are in Full recovery mode.
+#define STATUS_UPDATE_IPU_NAMEID_NOT_FOUND 0x237 // IPU name not found when compare with UPV extension
+
+#define STATUS_UPDATE_RESTORE_POINT_INVALID 0x238
+#define STATUS_UPDATE_RESTORE_POINT_VALID_BUT_NOT_LATEST 0x239
+#define STATUS_UPDATE_RESTORE_POINT_OPERATION_NOT_ALLOWED 0x23A
+#define STATUS_DOWNGRADE_NOT_ALLOWED_SVN_RESTRICTION 0x23B
+#define STATUS_DOWNGRADE_NOT_ALLOWED_VCN_RESTRICTION 0x23C
+#define STATUS_INVALID_SVN 0x23D
+#define STATUS_UPDATE_OUT_OF_SVN_RESOURCES 0x23E
+#define STATUS_UPDATE_REJECT_RESTORE_POINT_REQUEST_FLASH_IN_RECOVERY 0x23F
+#define STATUS_UPDATE_REJECTED_BY_UPDATE_POLICY 0x240
+#define STATUS_UPDATE_REJECTED_INCOMPATIBLE_TOOL_USAGE 0x241
+#define STATUS_UPDATE_REJECTED_CROSSPOINT_UPDATE_NOT_ALLOWED 0x242
+#define STATUS_UPDATE_REJECTED_CROSSHOTFIX_UPDATE_NOT_ALLOWED 0x243
+#define STATUS_UPDATE_REJECTED_CURRENT_FW_NOT_ELIGIBLE_FOR_UPDATE 0x244
+#define STATUS_UPDATE_REJECTED_WRONG_UPDATE_OPERATION 0x245
+#define STATUS_UPDATE_REJECTED_WRONG_UPDATE_IMAGE_FOUND 0x246
+#define STATUS_UPDATE_REJECTED_IFR_UPDATE_NOT_ALLOWED 0x247
+#define STATUS_UPDATE_FAILURE_OCCURRED_DURING_ROLLBACK 0x248
+
+//.........................................................................
+//......................................................................... // Reserve for FWU usage
+#define STATUS_UPDATE_LAST_STATUS_CODE 0x2FF
+
+// Hotham-specific error codes
+#define STATUS_HTM_HOST_NOT_RDY 0x300
+#define STATUS_HTM_INTERNAL_ERROR 0x301
+#define STATUS_HTM_REQ_IN_PROGRESS 0x302
+#define STATUS_HTM_RESP_IN_PROGRESS 0x303
+#define STATUS_HTM_INVALID_FRAGMENT 0x304
+#define STATUS_HTM_RESP_NONE_ACTIVE 0x305
+#define STATUS_HTM_NOT_CONNECTED 0x306
+//...
+//... Reserved for future use
+#define STATUS_HTM_LAST_STATUS_CODE 0x31F
+
+
+
+
+// means internal FW operation errors
+//#define STATUS_UPDATE_UNKNOWN = 0xFFFFFFFF
+
+
+#endif
+
+
+#endif // _ME_STATUS_H_
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.c b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.c
new file mode 100644
index 0000000..d5caea8
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.c
@@ -0,0 +1,701 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2015, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+#include <Token.h>
+#include <AmiDxeLib.h>
+#include <Protocol\Heci\Heci.h>
+#include <Protocol\PchPlatformPolicy\PchPlatformPolicy.h>
+#include <Protocol\PchReset\PchReset.h>
+#include <Protocol\MeBiosPayloadData\MeBiosPayloadData.h>
+#include <Protocol\Decompress.h>
+#include <Protocol\GuidedSectionExtraction.h>
+#include <Protocol\ConsoleControl.h>
+#include <Protocol\AMIPostMgr.h>
+
+#ifdef _HECI_PROTOCOL_H
+//Broadwell RC
+#include <Library\MeDxeLib.h>
+#include <Library\MeChipsetLib.h>
+#else
+//Haswell RC
+#undef EFI_PROTOCOL_DEFINITION
+#define EFI_STRINGIZE(a) #a
+#define EFI_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (Protocol/a/a.h)
+#include "HeciMsgLib.h"
+#include "MeChipsetLib.h"
+#endif
+
+#include <Guid\FirmwareFileSystem2.h>
+
+
+#include "IntelLib\FWUpdateLib.h"
+#include "IntelLib\me_status.h"
+#include "MeFwUpdLclProtocol.h"
+#include "EdkIICommon.h"
+
+_UUID mOemId = {0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// Last Reset Types
+#define NORESET 0
+#define HOSTRESET 1
+#define MERESET 2
+#define GLOBALRESET 3
+
+// Get Interface
+#define FW_UPDATE_DISABLED 0
+#define FW_UPDATE_ENABLED 1
+#define FW_UPDATE_PASSWORD_PROTECTED 2
+
+#ifdef _HECI_PROTOCOL_H
+//Broadwell RC
+typedef struct _PCH_PLATFORM_POLICY PRIVATE_PCH_PLATFORM_POLICY_PROTOCOL;
+#else
+//Haswell RC
+typedef struct _DXE_PCH_PLATFORM_POLICY_PROTOCOL PRIVATE_PCH_PLATFORM_POLICY_PROTOCOL;
+#define HECI_PROTOCOL EFI_HECI_PROTOCOL
+#define MBP_DATA_PROTOCOL DXE_MBP_DATA_PROTOCOL
+#define PCH_PLATFORM_POLICY_PROTOCOL_GUID DXE_PCH_PLATFORM_POLICY_PROTOCOL_GUID
+#endif
+
+#ifndef MAX_ADDRESS
+#define MAX_ADDRESS 0xFFFFFFFF
+#endif
+#define ME_UPD_LCL_SIGNATURE SIGNATURE_32 ('_', 'M', 'U', 'L')
+
+EFI_GUID mAmiGlobalVariableGuid = AMI_GLOBAL_VARIABLE_GUID;
+
+EFI_GUID mEfiHeciProtocolGuid = HECI_PROTOCOL_GUID;
+EFI_GUID mMeFwUpdLclProtocolGuid = ME_FW_UPD_LOCAL_PROTOCOL_GUID;
+EFI_GUID mPchPlatformPolicyProtocolGuid = PCH_PLATFORM_POLICY_PROTOCOL_GUID;
+EFI_GUID mPchResetProtocolGuid = PCH_RESET_PROTOCOL_GUID;
+EFI_GUID mMeBiosPayloadDataProtocolGuid = ME_BIOS_PAYLOAD_DATA_PROTOCOL_GUID;
+EFI_GUID mConOutStartedProtocolGuid = CONSOLE_OUT_DEVICES_STARTED_PROTOCOL_GUID;
+
+EFI_GUID mMeRegionFfsGuid = \
+{0xDE90FFA8, 0xB985, 0x4575, 0xAB, 0x8D, 0xAD, 0xE5, 0x2C, 0x36, 0x2C, 0xA3};
+
+ME_FW_UPDATE_LOCAL_PROTOCOL *mMeFwUpdateLclProtocol = NULL;
+PRIVATE_PCH_PLATFORM_POLICY_PROTOCOL *mPchPlatformPolicy = NULL;
+
+EFI_BOOT_SERVICES *BS = NULL;
+EFI_RESET_SYSTEM mSavedResetSystem = NULL;
+
+ME_FW_UPD_VERSION mMeFwImgVersion[] = ME_FW_IMAGE_VERSION;
+
+void _fltused()
+{
+}
+
+VOID *
+SetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+)
+{
+ MemSet( Buffer, Length, Value);
+ return Buffer;
+}
+
+INTN
+EFIAPI
+CompareMem (
+ IN VOID *DestinationBuffer,
+ IN VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ return MemCmp( DestinationBuffer, SourceBuffer, Length );
+}
+
+VOID* AllocatePool(
+ IN UINTN AllocationSize)
+{
+ VOID *p;
+ EFI_STATUS Status;
+
+ Status = BS->AllocatePool(EfiBootServicesData, AllocationSize, &p);
+ return (EFI_ERROR(Status)) ? NULL : p;
+}
+
+VOID FreePool(
+ IN VOID *Buffer)
+{
+ BS->FreePool(Buffer);
+}
+
+VOID *
+EFIAPI
+CopyMem (
+ OUT VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+{
+ MemCpy( Destination, Source, Length);
+ return Destination;
+}
+
+VOID *
+EFIAPI
+ZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ ASSERT (!(Buffer == NULL && Length > 0));
+ ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
+ return SetMem (Buffer, Length, 0);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeUpdPlatformUnlock
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeUpdPlatformUnlock (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN UINT32 UnlockType
+)
+{
+ if( mPchPlatformPolicy != NULL )
+#ifdef _HECI_PROTOCOL_H
+ //Broadwell RC
+ mPchPlatformPolicy->LockDownConfig.BiosLock = 0;
+#else
+ //Haswell RC
+ mPchPlatformPolicy->LockDownConfig->BiosLock = 0;
+#endif
+
+ // Patch disabling IDE_R if ME is Disabled for system assert if DEBUG_MODE is ON.
+ // The IDE-R device will be disabled if ME is in Normal state (HeciInit.c),
+ // Here ME is in ME_MODE_SECOVER, the IDE-R is active and could cause assert error
+ // in IdeBus.Start proceduce.
+ MeDeviceControl( IDER, Disabled );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeUpdPlatformReset
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeUpdPlatformReset (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN EFI_RESET_TYPE ResetType
+)
+{
+ EFI_STATUS Status;
+ PCH_RESET_PROTOCOL *PchReset;
+ // Reset system to re-start ME FW..
+ Status = pBS->LocateProtocol(
+ &mPchResetProtocolGuid,
+ NULL,
+ (VOID**)&PchReset);
+ if( !EFI_ERROR(Status) )
+ PchReset->Reset(PchReset, EfiResetCold);
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeCheckFwState
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeCheckFwState(
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN ME_FW_STATE MeFwState
+)
+{
+ EFI_STATUS Status;
+ UINT32 MeMode;
+ HECI_PROTOCOL *Heci = NULL;
+
+ Status = pBS->LocateProtocol(
+ &mEfiHeciProtocolGuid, NULL, (VOID**)&Heci);
+ if (EFI_ERROR(Status)) return EFI_UNSUPPORTED;
+ Status = Heci->GetMeMode (&MeMode);
+ if (EFI_ERROR(Status)) return EFI_UNSUPPORTED;
+ if (((MeFwState == MeModeNormal) && (MeMode == ME_MODE_NORMAL)) || \
+ ((MeFwState == MeModeDebug) && (MeMode == ME_MODE_DEBUG)) || \
+ ((MeFwState == MeModeTempDisabled) && (MeMode == ME_MODE_TEMP_DISABLED)) || \
+ ((MeFwState == MeModeSecOver) && (MeMode == ME_MODE_SECOVER)) || \
+ ((MeFwState == MeModeFailed) && (MeMode == ME_MODE_FAILED))) return EFI_SUCCESS;
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeGetFwVersion
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeGetFwVersion (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN OUT ME_FW_UPD_VERSION *MeFwVersion
+)
+{
+ EFI_STATUS Status;
+ MBP_DATA_PROTOCOL *MbpData;
+
+ // Get ME Firmware Version from MBP, then save for future used.
+ Status = pBS->LocateProtocol ( \
+ &mMeBiosPayloadDataProtocolGuid, NULL, (VOID **)&MbpData);
+ if (!EFI_ERROR (Status)) {
+ MemCpy(MeFwVersion, \
+ &MbpData->MeBiosPayload.FwVersionName, sizeof(ME_FW_UPD_VERSION));
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeUpdHmrfpoEnable
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeUpdHmrfpoEnable (
+ ME_FW_UPDATE_LOCAL_PROTOCOL *This
+)
+{
+ EFI_STATUS Status;
+ UINT8 HeciHmrfpoEnableResult;
+ HeciHmrfpoEnableResult = HMRFPO_ENABLE_UNKNOWN_FAILURE;
+ Status = HeciHmrfpoEnable (0, &HeciHmrfpoEnableResult);
+ if ((Status == EFI_SUCCESS) && (HeciHmrfpoEnableResult == HMRFPO_ENABLE_SUCCESS)) {
+ /// (A6) The BIOS sends the GLOBAL RESET MEI message
+ HeciSendCbmResetRequest (CBM_RR_REQ_ORIGIN_BIOS_POST, CBM_HRR_GLOBAL_RESET);
+ MeUpdPlatformReset(This, EfiResetCold);
+ //CpuDeadLoop();
+ while(1);
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: DisplaySendStatus
+//
+// Description:
+//
+// Input:
+// float BytesSent
+// float BytestobeSent
+// Output:
+// None
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+void
+DisplaySendStatus (
+ float BytesSent,
+ float BytestobeSent
+ )
+{
+// float value = (BytesSent / BytestobeSent) * 100;
+// UINT32 pValue = (UINT32)value;
+//
+// if (pValue != 100)
+// {
+// DEBUG ((D_ERROR, "Sending the update image to FW for verification: [ %d%% ]\r", pValue));
+// }
+// else
+// {
+// DEBUG ((D_ERROR, "Sending the update image to FW for verification: [ COMPLETE ] \n"));
+// }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: FwUpdLclFunc
+//
+// Description: The main function to update ME firmware.
+// It will call Intel's API to update ME firmware.
+//
+// Input:
+// IN ME_FW_UPDATE_LOCAL_PROTOCOL *This
+// IN UINT8 *FileBuffer
+// IN UINTN FileLength
+// Output:
+// None
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+FwUpdLclFunc (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN UINT8 *FileBuffer,
+ IN UINTN FileLength
+)
+{
+ EFI_STATUS Status;
+ UINTN ImageLength = 0;
+ UINT8 *ImageBuffer = NULL;
+ UPDATE_FLAGS_LIB update_flags;
+ CHAR8 Password[9];
+ UINT32 FWUpdateStatus;
+ UINT32 QueryStatus;
+ UINT32 UpdateStatus = 0;
+ UINT32 TotalStages = 0;
+ UINT32 PercentWritten = 0;
+ UINT32 LastStatus;
+ UINT32 LastResetType;
+ UINT16 Interfaces;
+ UINT8 Symbol;
+ UINT32 Index;
+ UINT32 CheckPolicyStatus = 0;
+ BOOLEAN AllowSV = FALSE;
+ UPDATE_TYPE UpdType;
+ VersionLib Ver;
+ VOID *DisplayHandle;
+ AMI_POST_MGR_KEY OutKey;
+
+ BS = pBS;
+
+ ImageBuffer = FileBuffer;
+ ImageLength = FileLength;
+
+ ZeroMem( &update_flags, sizeof(UPDATE_FLAGS_LIB) );
+
+ Status = GetLastStatus( &LastStatus );
+ if( EFI_ERROR(Status) )
+ {
+ return Status;
+ }
+
+ if( LastStatus == STATUS_UPDATE_HOST_RESET_REQUIRED )
+ {
+ //DEBUG ((D_ERROR, "PLEASE REBOOT YOUR SYSTEM. "));
+ //DEBUG ((D_ERROR, "Firmware update cannot be initiated without a reboot.\n"));
+ return EFI_SUCCESS;
+ }
+
+ if( IsUpdateStatusPending(LastStatus) )
+ {
+ //DEBUG ((D_ERROR, "Firmware Update operation not initiated "));
+ //DEBUG ((D_ERROR, "because a firmware update is already in progress\n"));
+ return EFI_SUCCESS;
+ }
+
+ Status = GetLastUpdateResetType( &LastResetType );
+ if( EFI_ERROR(Status) ) return Status;
+ switch( LastResetType )
+ {
+ case HOSTRESET:
+ case GLOBALRESET:
+ //DEBUG ((D_ERROR, "PLEASE REBOOT YOUR SYSTEM. "));
+ //DEBUG ((D_ERROR, "Firmware update cannot be initiated without a reboot.\n"));
+ return EFI_SUCCESS;
+ break;
+ default:
+ break;
+ }
+
+ Status = GetInterfaces( &Interfaces );
+ if( EFI_ERROR(Status) ) return Status;
+ switch( Interfaces )
+ {
+ case FW_UPDATE_DISABLED:
+ //DEBUG ((D_ERROR, "Local FWUpdate is Disabled\n"));
+ return EFI_SUCCESS;
+ case FW_UPDATE_PASSWORD_PROTECTED:
+ //DEBUG ((D_ERROR, "Local FWUpdate is Password Protected\n"));
+ break;
+ case FW_UPDATE_ENABLED:
+ break;
+ default:
+ break;
+ }
+
+ //DEBUG ((D_ERROR, "Checking firmware parameters...\n"));
+
+ CheckPolicyStatus = CheckPolicyBuffer( (char *)ImageBuffer,
+ (INT32)ImageLength,
+ (INT32)AllowSV,
+ &UpdType,
+ &Ver );
+ switch( UpdType )
+ {
+ case DOWNGRADE_SUCCESS:
+ case SAMEVERSION_SUCCESS:
+ case UPGRADE_SUCCESS:
+ break;
+
+ case DOWNGRADE_FAILURE:
+ //DEBUG ((D_ERROR, "FW Update downgrade not allowed\n"));
+ return EFI_SUCCESS;
+ break;
+
+ case SAMEVERSION_FAILURE:
+ //DEBUG ((D_ERROR, "FW Update same version not allowed, specify /s on command line\n"));
+ return EFI_SUCCESS;
+
+ default:
+ break;
+ }
+
+ ZeroMem( &Password, sizeof(Password) );
+
+ if( This->AmiPostMgr != NULL )
+ {
+ This->AmiPostMgr->DisplayProgress(
+ AMI_PROGRESS_BOX_INIT,
+ L"ME FW update",
+ L"Flash New ME Firmware",
+ NULL,
+ 0,
+ &DisplayHandle,
+ &OutKey );
+ }
+
+ FWUpdateStatus = FwUpdateFullBuffer(
+ (char*)ImageBuffer,
+ (unsigned int)ImageLength,
+ Password,
+ 0,
+ FWU_ENV_MANUFACTURING,
+ mOemId,
+ update_flags,
+ &DisplaySendStatus );
+ if( FWUpdateStatus != FWU_ERROR_SUCCESS )
+ {
+ //DEBUG ((D_ERROR, "FWUpdateStatus: %x\n", FWUpdateStatus));
+ //if( ImageBuffer )
+ // FreePool( ImageBuffer );
+ return EFI_SUCCESS;
+ }
+
+ //if( ImageBuffer )
+ //{
+ // Status = FreePool( ImageBuffer );
+ //}
+
+ Index = 0;
+ do
+ {
+ Symbol = (++Index % 2 == 0) ? '|':'-';
+
+ QueryStatus = FWUpdate_QueryStatus_Get_Response(
+ &UpdateStatus,
+ &TotalStages,
+ &PercentWritten,
+ &LastStatus,
+ &LastResetType );
+ if( QueryStatus == FWU_ERROR_SUCCESS )
+ {
+ //DEBUG ((D_ERROR, "FW Update: [ %d%% (Stage: %d of %d) (%c)]\r", PercentWritten, UpdateStatus, TotalStages, Symbol));
+ if( This->AmiPostMgr != NULL )
+ {
+ This->AmiPostMgr->DisplayProgress(
+ AMI_PROGRESS_BOX_UPDATE,
+ L"ME FW update",
+ L"Flash New ME Firmware",
+ NULL,
+ PercentWritten,
+ &DisplayHandle,
+ &OutKey );
+ }
+ }
+ else if ( LastStatus != STATUS_UPDATE_NOT_READY )
+ {
+ //DEBUG ((D_ERROR, "\nLastStatus: %x\n", LastStatus));
+ break;
+ }
+ BS->Stall(100000);
+ } while( (PercentWritten != 100) && (QueryStatus == FWU_ERROR_SUCCESS) );
+
+ if( This->AmiPostMgr != NULL )
+ {
+ This->AmiPostMgr->DisplayProgress(
+ AMI_PROGRESS_BOX_CLOSE,
+ L"ME FW update",
+ L"Flash New ME Firmware",
+ NULL,
+ 0,
+ &DisplayHandle,
+ &OutKey );
+ }
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeFwUpdateProtocolEvent
+//
+// Description: The driver entry
+//
+// Input:
+//
+// Output:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeFwUpdateProtocolEvent (
+ IN EFI_EVENT Event,
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ UINT32 Dummy = 0;
+ UINTN VariableSize = sizeof(UINT8);
+ EFI_STATUS Status;
+ ME_FW_UPD_VERSION MeFwVersion;
+
+ if (mMeFwImgVersion->MajorVersion != 0) {
+ Status = MeGetFwVersion(mMeFwUpdateLclProtocol, &MeFwVersion);
+ if (!EFI_ERROR (Status)) {
+ VariableSize = sizeof(ME_FW_UPD_VERSION);
+ // Set MbpMeFwVersion to "NV+BS", because MBP could be not available if
+ // Capsule Update mode.
+ pRS->SetVariable(L"MbpMeFwVersion", \
+ &mAmiGlobalVariableGuid, \
+ EFI_VARIABLE_NON_VOLATILE | \
+ EFI_VARIABLE_BOOTSERVICE_ACCESS, \
+ sizeof(ME_FW_UPD_VERSION), \
+ &MeFwVersion);
+ }
+ }
+ // Check "MeAutoUpdateReq" variable if ME Auto Update is requested.
+ VariableSize = sizeof(UINT32);
+ Status = pRS->GetVariable(L"MeAutoUpdateReq", \
+ &mAmiGlobalVariableGuid, NULL, &VariableSize, &Dummy);
+ if (EFI_ERROR(Status)) return EFI_SUCCESS;
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MEFwUpdLclEntry
+//
+// Description: The driver entry
+//
+// Input:
+// IN EFI_HANDLE ImageHandle
+// OUT EFI_SYSTEM_TABLE *SystemTable
+// Output:
+// None
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MEFwUpdLclEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ UINT32 Dummy;
+ UINTN VariableSize = sizeof(UINT32);
+ EFI_HANDLE pHandle = NULL;
+ EFI_STATUS Status;
+
+ InitAmiLib( ImageHandle, SystemTable );
+
+ Status = pBS->LocateProtocol(
+ &mPchPlatformPolicyProtocolGuid,
+ NULL,
+ &mPchPlatformPolicy );
+ if( EFI_ERROR(Status) ) return EFI_SUCCESS;
+
+ //Prepare ME firmware update local protocol
+ Status = pBS->AllocatePool(
+ EfiBootServicesData,
+ sizeof(ME_FW_UPDATE_LOCAL_PROTOCOL),
+ (VOID**)&mMeFwUpdateLclProtocol );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ mMeFwUpdateLclProtocol->FwUpdBufferAddress = 0;
+ mMeFwUpdateLclProtocol->FwUpdBufferLength = 0;
+ mMeFwUpdateLclProtocol->FwUpdLcl = FwUpdLclFunc;
+ mMeFwUpdateLclProtocol->MeFwCheckMode = MeCheckFwState;
+ mMeFwUpdateLclProtocol->MeFwGetVersion = MeGetFwVersion;
+ mMeFwUpdateLclProtocol->HmrfpoEnable = MeUpdHmrfpoEnable;
+ mMeFwUpdateLclProtocol->PlatformReset = MeUpdPlatformReset;
+ mMeFwUpdateLclProtocol->PlatformUnlock = MeUpdPlatformUnlock;
+ mMeFwUpdateLclProtocol->AmiPostMgr = NULL;
+
+ Status = pBS->InstallProtocolInterface(
+ &pHandle,
+ &mMeFwUpdLclProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ mMeFwUpdateLclProtocol );
+
+ MeFwUpdateProtocolEvent( NULL, NULL );
+
+ Status = pRS->GetVariable(
+ L"MeAutoUpdateReq",
+ &mAmiGlobalVariableGuid,
+ NULL,
+ &VariableSize,
+ &Dummy );
+ if( EFI_ERROR(Status) || (Dummy == ME_UPD_LCL_SIGNATURE) )
+ return EFI_SUCCESS;
+
+ return EFI_SUCCESS;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2015, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.cif b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.cif
new file mode 100644
index 0000000..675fb33
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.cif
@@ -0,0 +1,17 @@
+<component>
+ name = "ME Firmware Update Local"
+ category = ModulePart
+ LocalRoot = "\Chipset\eM\ME\MEUD\MEFwUpdLcl\"
+ RefName = "MEFwUpdLcl"
+[files]
+"MEFwUpdLcl.c"
+"MeFwUpdLclProtocol.h"
+"MEFwUpdLcl.sdl"
+"MEFwUpdLcl.dxs"
+"MEFwUpdLcl_SBY.dxs"
+"MEFwUpdLcl.mak"
+"MEFwUpdLclUpdateHooks.c"
+"IntelLib\FWUpdateLib.h"
+"IntelLib\me_status.h"
+"IntelLib\FWUpdateLib.lib"
+<endComponent>
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.dxs b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.dxs
new file mode 100644
index 0000000..077fe27
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.dxs
@@ -0,0 +1,9 @@
+#include <Protocol\HeciProtocol.h>
+#include <Protocol\MeBiosPayloadData.h>
+#include <Protocol\PchPlatformPolicy.h>
+#include "MeFwUpdLclProtocol.h"
+
+DEPENDENCY_START
+ HECI_PROTOCOL_GUID AND
+ PCH_PLATFORM_POLICY_PROTOCOL_GUID
+DEPENDENCY_END \ No newline at end of file
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.mak b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.mak
new file mode 100644
index 0000000..3eb64c2
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.mak
@@ -0,0 +1,118 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/CSP_MEUD/ME80/MEFwUpdLcl/MEFwUpdLcl.mak 2 5/14/15 4:28a Tristinchou $
+#
+# $Revision: 2 $
+#
+# $Date: 5/14/15 4:28a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD Intel ME Update/CSP_MEUD/ME80/MEFwUpdLcl/MEFwUpdLcl.mak $
+#
+# 2 5/14/15 4:28a Tristinchou
+# [TAG] EIP215437
+# [Category] New Feature
+# [Description] ME capsule update support on SharkBay
+# [Files] MEFwUpdLcl.c
+# MeFwUpdLclProtocol.h
+# MEFwUpdLcl.sdl
+# MEFwUpdLcl.dxs
+# MEFwUpdLcl.mak
+# MEFwUpdLcl.cif
+#
+# 1 3/05/14 3:16a Tristinchou
+# [TAG] EIP147099
+# [Category] Improvement
+# [Description] Support ME FWUpdate API
+# [Files] MEFwUpdLcl.cif
+# MEFwUpdLcl.c
+# MeFwUpdLclProtocol.h
+# MEFwUpdLcl.sdl
+# MEFwUpdLcl.dxs
+# MEFwUpdLcl.mak
+# IntelLib\FWUpdateLib.h
+# IntelLib\me_status.h
+# IntelLib\FWUpdateLib.lib
+#
+# 6 1/13/10 2:13p Felixp
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: <ComponentName>.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+all : MEFwUpdLcl
+
+MEFwUpdLcl_LIBS=\
+ $(EFIPROTOCOLLIB)\
+ $(INTEL_FWUPDATE_LIB)\
+ $(AMIDXELIB)\
+ $(MeChipsetDxeLib_LIB)\
+ $(MeLibDxe_LIB)\
+ $(PchPlatformLib_LIB)\
+ $(PchPlatformDxeLib_LIB)\
+ $(EdkIIGlueBaseDebugLibNull_LIB)
+
+MEFwUpdLcl_INCLUDES=\
+ $(ME_INCLUDES)\
+ /I Core\
+
+MEFwUpdLcl_OBJ = \
+ $(BUILD_DIR)\$(MEFwUpdLcl_DIR)\MEFwUpdLcl.obj
+
+MEFwUpdLcl : $(BUILD_DIR)\MEFwUpdLcl.mak MEFwUpdLclBin
+
+$(BUILD_DIR)\MEFwUpdLcl.mak : $(MEFwUpdLcl_DIR)\$(@B).cif $(MEFwUpdLcl_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(MEFwUpdLcl_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+MEFwUpdLclBin : $(MEFwUpdLcl_LIBS)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\MEFwUpdLcl.mak all\
+ "MY_INCLUDES=$(MEFwUpdLcl_INCLUDES)"\
+ GUID=a11585b7-8fa2-4f1c-aa6f-dd6309469613\
+ OBJECTS="$(MEFwUpdLcl_OBJ)" \
+ ENTRY_POINT=MEFwUpdLclEntry\
+ TYPE=BS_DRIVER \
+!IF "$(MEFWUPDLCL_ON_SHARKBAY_PLATFORM)"=="0"
+ DEPEX1=$(MEFwUpdLcl_DIR)\MEFwUpdLcl.dxs \
+!ELSE
+ DEPEX1=$(MEFwUpdLcl_DIR)\MEFwUpdLcl_SBY.dxs \
+!ENDIF
+ DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \
+ COMPRESS=1\
+
+ReFlashBin : $(BUILD_DIR)\MEFwUpdLclUpdateHooks.obj
+
+$(BUILD_DIR)\MEFwUpdLclUpdateHooks.obj : $(MEFwUpdLcl_DIR)\MEFwUpdLclUpdateHooks.c
+ $(CC) /Fo$(BUILD_DIR)\MEFwUpdLclUpdateHooks.obj $(CFLAGS) $(MEFwUpdLcl_DIR)\MEFwUpdLclUpdateHooks.c
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (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/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.sdl b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.sdl
new file mode 100644
index 0000000..6844616
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl.sdl
@@ -0,0 +1,51 @@
+TOKEN
+ Name = MEFwUpdLcl_SUPPORT
+ Value = 0
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable MEFwUpdLcl support in Project"
+End
+
+TOKEN
+ Name = "MEFWUPDLCL_ON_SHARKBAY_PLATFORM"
+ Value = "0"
+ TokenType = Boolean
+ TargetMAK = Yes
+End
+
+MODULE
+ Help = "Includes MEFwUpdLcl.mak to Project"
+ File = "MEFwUpdLcl.mak"
+End
+
+PATH
+ Name = "MEFwUpdLcl_DIR"
+End
+
+TOKEN
+ Name = "INTEL_FWUPDATE_LIB"
+ Value = "$(MEFwUpdLcl_DIR)\IntelLib\FWUpdateLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MEFwUpdLcl.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "AutoMeudBeforeReflashHook,"
+ Parent = "OemBeforeFlashUpdateList"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "AutoMeudAfterReflashHook,"
+ Parent = "OemAfterFlashUpdateList"
+ InvokeOrder = AfterParent
+ Priority = -100
+End \ No newline at end of file
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLclUpdateHooks.c b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLclUpdateHooks.c
new file mode 100644
index 0000000..0ec4b8e
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLclUpdateHooks.c
@@ -0,0 +1,596 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2015, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+#include <AmiDxeLib.h>
+#include <AmiHobs.h>
+#include <Capsule.h>
+#include <Token.h>
+#include <Protocol/Decompress.h>
+#include <Protocol/GuidedSectionExtraction.h>
+#include <Protocol/AmiPostMgr.h>
+
+#include "MeFwUpdLclProtocol.h"
+
+#define SECTION_SIZE(SectionHeaderPtr) \
+ ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
+#define SIGNATURE_16(A, B) ((A) | (B << 8))
+#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))
+
+#define EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID \
+ { 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f }
+#define ME_UPD_LCL_SIGNATURE SIGNATURE_32 ('_', 'M', 'U', 'L')
+#define FV_GUID_OFFSET 0x60
+
+extern EFI_GUID gAmiGlobalVariableGuid;
+EFI_GUID mMeRegionFfsGuid = \
+ { 0xDE90FFA8, 0xB985, 0x4575, 0xAB, 0x8D, 0xAD, 0xE5, 0x2C, 0x36, 0x2C, 0xA3 };
+EFI_GUID mMeVersionFfsFileGuid = \
+ { 0x0B4AE6BE, 0x6DA6, 0x4908, 0x8A, 0x71, 0x7E, 0x6A, 0x8A, 0x33, 0xB1, 0x1C };
+EFI_GUID mMeVersionFfsSectionGuid = \
+ { 0x6A6D576A, 0x8F38, 0x45E7, 0x97, 0xC0, 0x8A, 0xCD, 0x9E, 0x99, 0x26, 0x74 };
+EFI_GUID mEfiCustomizedDecompressProtocolGuid = \
+ { 0X9A44198E, 0XA4A2, 0X44E6, 0X8A, 0X1F, 0X39, 0XBE, 0XFD, 0XAC, 0X89, 0X6F };
+static EFI_GUID mAmiPostManagerProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID;
+static AMI_POST_MANAGER_PROTOCOL *mAmiPostMgr = NULL;
+ME_FW_UPD_VERSION mMeFwImgVersion[] = ME_FW_IMAGE_VERSION;
+ME_FW_UPD_VERSION MbpMeFwVer;
+
+extern UINT8 *RecoveryBuffer;
+
+UINT8*
+FvFindFfsFileByGuid (
+ UINT8 *FvAddress,
+ EFI_GUID *pGuid
+);
+
+VOID
+AutoMeudBeforeReflashHook(
+ VOID
+);
+
+VOID
+AutoMeudAfterReflashHook(
+ VOID
+);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: DecompressBinary
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+DecompressBinary(
+ IN UINTN *BinaryBuffer,
+ IN UINTN BinaryBufferSize,
+ OUT UINTN **DecompressBuffer,
+ OUT UINTN *DecompressBufferSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER *FfsFileHeader = NULL;
+ EFI_COMMON_SECTION_HEADER *SectionHeader = NULL;
+ UINTN NvarSize = 0;
+ VOID *NvarBuffer = NULL;
+ EFI_COMPRESSION_SECTION *CompressSection = NULL;
+ EFI_GUID_DEFINED_SECTION *GuidedSection = NULL;
+ EFI_DECOMPRESS_PROTOCOL *Decompress = NULL;
+ EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *GuidedExtraction = NULL;
+ VOID *CompressionSource = NULL;
+ UINT32 CompressionSourceSize = 0;
+ UINT32 UncompressedLength = 0;
+ UINT8 CompressionType;
+ VOID *ScratchBuffer = NULL;
+ UINT32 ScratchSize = 0;
+ VOID *NewBuffer = NULL;
+ UINTN NewBufferSize = 0;
+ UINT32 AuthenticationStatus = 0;
+
+ FfsFileHeader = (EFI_FFS_FILE_HEADER*)BinaryBuffer;
+ SectionHeader = (EFI_COMMON_SECTION_HEADER*)((UINT8*)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));
+
+ if( FfsFileHeader->Type == EFI_FV_FILETYPE_RAW ) {
+ //The binary is the NVRAM ffs without any section,
+ //allocate the memory and copy it.
+
+ NvarSize = BinaryBufferSize - sizeof(EFI_FFS_FILE_HEADER);
+
+ Status = pBS->AllocatePool( EfiBootServicesData,
+ NvarSize,
+ &NvarBuffer );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ MemCpy( NvarBuffer, (VOID*)SectionHeader, NvarSize );
+
+ *DecompressBuffer = NvarBuffer;
+ *DecompressBufferSize = NvarSize;
+
+ return EFI_SUCCESS;
+ }
+ //The binary is the NVRAM ffs with section,
+ //determine the section type.
+
+ switch( SectionHeader->Type )
+ {
+ case EFI_SECTION_COMPRESSION:
+ //The section is compressed by PI_STD
+ CompressSection = (EFI_COMPRESSION_SECTION*)SectionHeader;
+
+ CompressionSource = (VOID*)((UINT8*)CompressSection + sizeof(EFI_COMPRESSION_SECTION));
+ CompressionSourceSize = (UINT32)(SECTION_SIZE(CompressSection) - sizeof(EFI_COMPRESSION_SECTION));
+ UncompressedLength = CompressSection->UncompressedLength;
+ CompressionType = CompressSection->CompressionType;
+
+ if( UncompressedLength > 0 )
+ {
+ NewBufferSize = UncompressedLength;
+
+ Status = pBS->AllocatePool( EfiBootServicesData,
+ NewBufferSize,
+ &NewBuffer );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ if( CompressionType == EFI_NOT_COMPRESSED )
+ {
+ MemCpy( NewBuffer, (VOID*)CompressionSource, NewBufferSize );
+ }
+ else if ( CompressionType == EFI_STANDARD_COMPRESSION ||
+ CompressionType == EFI_CUSTOMIZED_COMPRESSION )
+ {
+
+ if( CompressionType == EFI_STANDARD_COMPRESSION )
+ {
+ Status = pBS->LocateProtocol(
+ &gEfiDecompressProtocolGuid,
+ NULL,
+ &Decompress );
+ }
+ else
+ {
+ Status = pBS->LocateProtocol(
+ &mEfiCustomizedDecompressProtocolGuid,
+ NULL,
+ &Decompress );
+ }
+ if( EFI_ERROR(Status) )
+ {
+ pBS->FreePool( NewBuffer );
+ return Status;
+ }
+
+ Status = Decompress->GetInfo( Decompress,
+ CompressionSource,
+ CompressionSourceSize,
+ (UINT32 *)&NewBufferSize,
+ &ScratchSize );
+ if( EFI_ERROR(Status) || (NewBufferSize != UncompressedLength))
+ {
+ pBS->FreePool( NewBuffer );
+ if(!EFI_ERROR (Status))
+ Status = EFI_BAD_BUFFER_SIZE;
+ return Status;
+ }
+
+ Status = pBS->AllocatePool( EfiBootServicesData,
+ ScratchSize,
+ &ScratchBuffer );
+ if( EFI_ERROR(Status) )
+ {
+ pBS->FreePool( NewBuffer );
+ return Status;
+ }
+
+ Status = Decompress->Decompress( Decompress,
+ CompressionSource,
+ CompressionSourceSize,
+ NewBuffer,
+ (UINT32)NewBufferSize,
+ ScratchBuffer,
+ ScratchSize );
+ pBS->FreePool( ScratchBuffer );
+ if( EFI_ERROR(Status) )
+ {
+ pBS->FreePool( NvarBuffer );
+ return Status;
+ }
+
+ //The decompressed data is the EFI_SECTION_RAW
+ //Add the section header length to get data
+ SectionHeader = (EFI_COMMON_SECTION_HEADER*)NewBuffer;
+
+ NvarSize = SECTION_SIZE(SectionHeader) - sizeof(EFI_COMMON_SECTION_HEADER);
+ NvarBuffer = (VOID*)((UINT8*)NewBuffer + sizeof(EFI_COMMON_SECTION_HEADER));
+ }
+ }
+
+ break;
+
+ case EFI_SECTION_GUID_DEFINED:
+
+ //The section is compressed by LZMA
+ GuidedSection = (EFI_GUID_DEFINED_SECTION*)SectionHeader;
+
+ Status = pBS->LocateProtocol( &(GuidedSection->SectionDefinitionGuid),
+ NULL,
+ &GuidedExtraction );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ Status = GuidedExtraction->ExtractSection(
+ GuidedExtraction,
+ GuidedSection,
+ &NewBuffer,
+ &NewBufferSize,
+ &AuthenticationStatus );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ //The decompressed data is the EFI_SECTION_RAW
+ //Add the section header length to get data
+ SectionHeader = (EFI_COMMON_SECTION_HEADER*)NewBuffer;
+
+ NvarSize = SECTION_SIZE(SectionHeader) - sizeof(EFI_COMMON_SECTION_HEADER);
+ NvarBuffer = (VOID*)((UINT8*)NewBuffer + sizeof(EFI_COMMON_SECTION_HEADER));
+
+ break;
+
+ case EFI_SECTION_RAW:
+
+ //The section is not compressed.
+ NvarSize = BinaryBufferSize - (sizeof(EFI_FFS_FILE_HEADER) + sizeof(EFI_COMMON_SECTION_HEADER));
+
+ Status = pBS->AllocatePool( EfiBootServicesData,
+ NvarSize,
+ &NvarBuffer );
+ if( EFI_ERROR(Status) )
+ return Status;
+
+ MemCpy( NvarBuffer, (VOID*)((UINT8*)SectionHeader + sizeof(EFI_COMMON_SECTION_HEADER)), NvarSize );
+
+ break;
+
+ default:
+
+ NvarBuffer = NULL;
+ NvarSize = 0;
+
+ break;
+ }
+
+ *DecompressBuffer = NvarBuffer;
+ *DecompressBufferSize = NvarSize;
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: MeFwUpdateViaIntelLib
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MeFwUpdateViaIntelLib(
+ IN UINT8 *pBuffer,
+ IN AMI_POST_MANAGER_PROTOCOL *AmiPostMgr
+ )
+{
+ EFI_STATUS Status;
+ UINTN *pMeRegionFile, *UcMeBuffer, UcMeBufferSize;
+ EFI_GUID mMeFwUpdLclProtocolGuid = ME_FW_UPD_LOCAL_PROTOCOL_GUID;
+ ME_FW_UPDATE_LOCAL_PROTOCOL *mMeFwUpdateLclProtocol = NULL;
+ EFI_FFS_FILE_HEADER *pHdr;
+
+ // Locate ME FW Update Local Protocol.
+ Status = pBS->LocateProtocol (&mMeFwUpdLclProtocolGuid, \
+ NULL, (VOID**)&mMeFwUpdateLclProtocol);
+ if(EFI_ERROR(Status) || (pBuffer == NULL)) return Status;
+
+ // Check ME is in Normal mode.
+ Status = mMeFwUpdateLclProtocol->MeFwCheckMode(mMeFwUpdateLclProtocol, MeModeNormal);
+ if(EFI_ERROR(Status)) return Status;
+
+ // Search the ME FW file from buffer.
+ if (((UINT8*)pMeRegionFile = FvFindFfsFileByGuid( \
+ pBuffer, &mMeRegionFfsGuid)) == NULL) return Status;
+
+ // Decompress the ME FW file..
+ pHdr = (EFI_FFS_FILE_HEADER*)pMeRegionFile;
+ Status = DecompressBinary ( pMeRegionFile, \
+ (UINTN)(*(UINT32*)pHdr->Size & 0xffffff), \
+ &UcMeBuffer, &UcMeBufferSize);
+ if (EFI_ERROR(Status)) return Status;
+
+ // Update reflash progress bar only if Secure flash capsule update.
+ // Do not display any messages if Windwos Firmware Update Capsule.
+ mMeFwUpdateLclProtocol->AmiPostMgr = NULL;
+ if (AmiPostMgr != NULL) mMeFwUpdateLclProtocol->AmiPostMgr = AmiPostMgr;
+ Status = mMeFwUpdateLclProtocol->FwUpdLcl(mMeFwUpdateLclProtocol, \
+ (UINT8*)UcMeBuffer, UcMeBufferSize);
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: GetFvMeFwRegionAddress
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8*
+GetFvMeFwRegionAddress(
+ UINT8 *StartAddress
+ )
+{
+ EFI_GUID mMeFwCapsuleFirmwareVolumeGuid = ME_FW_CAPSULE_FIRMWARE_VOLUME_GUID;
+ if (!guidcmp((UINT8*)StartAddress + FV_GUID_OFFSET, \
+ &mMeFwCapsuleFirmwareVolumeGuid)) return StartAddress;
+ if (!guidcmp((UINT8*)StartAddress + FLASH_SIZE + FV_GUID_OFFSET, \
+ &mMeFwCapsuleFirmwareVolumeGuid)) return StartAddress + FLASH_SIZE;
+ return NULL;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: FvFindFfsFileByGuid
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8*
+FvFindFfsFileByGuid(
+ UINT8 *FvAddress,
+ EFI_GUID *pGuid
+ )
+{
+ EFI_FFS_FILE_HEADER *pFfsFile;
+ UINT32 i, FvLength = FLASH_SIZE, FileSize;
+ UINT8 *p = (UINT8*)NULL;
+ EFI_GUID EfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;
+
+ if ((p = GetFvMeFwRegionAddress(FvAddress)) == NULL) return NULL;
+ FvLength = (UINT32)((EFI_FIRMWARE_VOLUME_HEADER*)p)->FvLength;
+ for (i = 0; (i + 16) < FvLength; i += 16) {
+ if (guidcmp (&((EFI_FIRMWARE_VOLUME_HEADER*)(p + i))->FileSystemGuid, \
+ &EfiFirmwareFileSystem2Guid)) continue;
+ FileSize = ((EFI_FIRMWARE_VOLUME_HEADER*)(p + i))->HeaderLength;
+ pFfsFile = (EFI_FFS_FILE_HEADER*)(p + i + FileSize);
+ do {
+ if (!guidcmp (&((EFI_FFS_FILE_HEADER*)pFfsFile)->Name, pGuid)) {
+ return ((UINT8*)pFfsFile);
+ }
+ FileSize = *(UINT32 *)pFfsFile->Size & 0x00FFFFFF;
+ pFfsFile = (EFI_FFS_FILE_HEADER*)((UINT32)pFfsFile + FileSize);
+ pFfsFile = (EFI_FFS_FILE_HEADER*)(((UINT32)pFfsFile + 7) & 0xfffffff8);
+ } while(((*(UINT32 *)pFfsFile->Size & 0x00FFFFFF) != 0xFFFFFF) && \
+ ((*(UINT32 *)pFfsFile->Size & 0x00FFFFFF) != 0));
+ i += (UINT32)(((EFI_FIRMWARE_VOLUME_HEADER*)(p + i))->FvLength - 16);
+ }
+ return ((UINT8*)NULL);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: CheckMeFirmwareVersion
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+CheckMeFirmwareVersion(
+ UINT8 *pFileSection
+ )
+{
+ UINT8 *p = pFileSection + sizeof(EFI_COMMON_SECTION_HEADER);
+ ME_FW_UPD_VERSION *NewMeFwVer;
+
+ if (guidcmp (p, &mMeVersionFfsSectionGuid)) return FALSE;
+ NewMeFwVer = (ME_FW_UPD_VERSION*)(p + sizeof (EFI_GUID));
+
+ // ??? PORTING REQUEST ??? [TO DO] if can't get ME FW version from MBP ??
+ // ==== PORTING REQUEST ==== >>
+ if (MbpMeFwVer.MajorVersion != NewMeFwVer->MajorVersion) return FALSE;
+ if (MbpMeFwVer.MinorVersion < NewMeFwVer->MinorVersion) return FALSE;
+ if ((UINT32)((NewMeFwVer->HotfixVersion << 16) + NewMeFwVer->BuildVersion) >
+ (UINT32)((MbpMeFwVer.HotfixVersion << 16) + MbpMeFwVer.BuildVersion)) {
+ return TRUE;
+ }
+ // << ==== PORTING REQUEST ====
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: IsMeFirmawareUpgraded
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+IsMeFirmawareUpgraded(
+ EFI_GUID *pGuid
+ )
+{
+ UINT8 *pFfsFile;
+ if ((pFfsFile = FvFindFfsFileByGuid(RecoveryBuffer, pGuid)) == NULL) return FALSE;
+ return CheckMeFirmwareVersion (pFfsFile + sizeof(EFI_FFS_FILE_HEADER));
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: IsWindowsFwUpdate
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+IsWindowsFwUpdate(
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_CAPSULE_HEADER *Capsule;
+ EFI_HOB_UEFI_CAPSULE *Hob;
+ static EFI_GUID ImageCapsuleGuid = W8_SCREEN_IMAGE_CAPSULE_GUID;
+ static EFI_GUID HobListGuid = HOB_LIST_GUID;
+
+ if ((Hob = GetEfiConfigurationTable(pST, &HobListGuid)) == NULL) return FALSE;
+ do {
+ Status = FindNextHobByType(EFI_HOB_TYPE_UEFI_CAPSULE, &Hob);
+ if(!EFI_ERROR(Status)) {
+ Capsule = (EFI_CAPSULE_HEADER *)(VOID *)(UINTN)Hob->BaseAddress;
+ if(!guidcmp(&(Capsule->CapsuleGuid), &ImageCapsuleGuid)) return TRUE;
+ }
+ } while(!EFI_ERROR(Status));
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: AutoMeudBeforeReflashHook
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+AutoMeudBeforeReflashHook(
+ VOID
+ )
+{
+ UINTN Length = sizeof(ME_FW_UPD_VERSION);
+ EFI_STATUS Status;
+
+ // Save "MeAutoUpdateReq" variable here for avoiding NVRAM could be updated later.
+ Status = pRS->GetVariable (L"MbpMeFwVersion", \
+ &gAmiGlobalVariableGuid, NULL, &Length, &MbpMeFwVer);
+ if (EFI_ERROR(Status)) MemSet(&MbpMeFwVer, sizeof(ME_FW_UPD_VERSION), 0);
+
+ // Start ME FW update process here if ME FW Capsule only.
+ if (RecoveryBuffer == GetFvMeFwRegionAddress(RecoveryBuffer)) {
+ EFI_EVENT event;
+ AutoMeudAfterReflashHook();
+ if (mAmiPostMgr != NULL)
+ mAmiPostMgr->DisplayInfoBox(L"ME FW update", L"ME FW update completed, Press any key to reset the system", 5, &event);
+ pRS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ }
+
+ return;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: AutoMeudAfterReflashHook
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+AutoMeudAfterReflashHook(
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_VOLUME_CORRUPTED;
+ UINT32 MeMode;
+
+ if ((mMeFwImgVersion->MajorVersion != 0) && \
+ (!IsMeFirmawareUpgraded(&mMeVersionFfsFileGuid))) return ;
+ if (!IsWindowsFwUpdate())
+ Status = pBS->LocateProtocol(&mAmiPostManagerProtocolGuid, NULL, &mAmiPostMgr);
+ // ME FW Update API could returns error "EFI_VOLUME_CORRUPTED" if capsule mode
+ // in S3 resume path, so, we set the MeAutoUpdateReq variable to "_MUL" for
+ // trying update ME FW again if error.
+ MeMode = ME_UPD_LCL_SIGNATURE;
+ Status = MeFwUpdateViaIntelLib (RecoveryBuffer, mAmiPostMgr);
+ if (EFI_ERROR(Status))
+ {
+ pRS->SetVariable (L"MeAutoUpdateReq",
+ &gAmiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | \
+ EFI_VARIABLE_BOOTSERVICE_ACCESS, \
+ sizeof(UINT32), \
+ &MeMode);
+ }
+ return;
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2015, 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/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl_SBY.dxs b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl_SBY.dxs
new file mode 100644
index 0000000..5728a1c
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MEFwUpdLcl_SBY.dxs
@@ -0,0 +1,14 @@
+#define HECI_PROTOCOL_GUID \
+ { \
+ 0xcfb33810, 0x6e87, 0x4284, 0xb2, 0x3, 0xa6, 0x6a, 0xbe, 0x7, 0xf6, 0xe8 \
+ }
+
+#define DXE_PCH_PLATFORM_POLICY_PROTOCOL_GUID \
+ { \
+ 0x9797aaf8, 0xe49b, 0x4f02, 0xa3, 0x68, 0xc8, 0x14, 0x8d, 0x2b, 0xc9, 0xe7 \
+ }
+
+DEPENDENCY_START
+ HECI_PROTOCOL_GUID AND
+ DXE_PCH_PLATFORM_POLICY_PROTOCOL_GUID
+DEPENDENCY_END \ No newline at end of file
diff --git a/Chipset/eM/ME/MEUD/MEFwUpdLcl/MeFwUpdLclProtocol.h b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MeFwUpdLclProtocol.h
new file mode 100644
index 0000000..66c805e
--- /dev/null
+++ b/Chipset/eM/ME/MEUD/MEFwUpdLcl/MeFwUpdLclProtocol.h
@@ -0,0 +1,109 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+#include <Protocol/AmiPostMgr.h>
+
+#define SEC_SMI_FLASH_GUID \
+ { 0x3bf4af16, 0xab7c, 0x4b43, 0x89, 0x8d, 0xab, 0x26, 0xac, 0x5d, 0xdc, 0x6c }
+
+//{ DCA334AB-56E3-4EDE-B9B3-8EAE2ACF5E78 }
+#define ME_FW_UPD_LOCAL_PROTOCOL_GUID \
+ { 0xDCA334AB, 0x56E3, 0x4EDE, 0xB9, 0xB3, 0x8E, 0xAE, 0x2A, 0xCF, 0x5E, 0x78 }
+
+//{ 9F8B1DEF-B62B-45F3-8282-BFD7EA19801B }
+#define ME_FW_CAPSULE_FIRMWARE_VOLUME_GUID \
+ { 0x9F8B1DEF, 0xB62B, 0x45F3, 0x82, 0x82, 0xBF, 0xD7, 0xEA, 0x19, 0x80, 0x1B }
+
+typedef struct _ME_FW_UPD_VERSION {
+ UINT32 MajorVersion : 16;
+ UINT32 MinorVersion : 16;
+ UINT32 HotfixVersion : 16;
+ UINT32 BuildVersion : 16;
+} ME_FW_UPD_VERSION;
+
+typedef enum {
+ MeModeNormal,
+ MeModeDebug,
+ MeModeTempDisabled,
+ MeModeSecOver,
+ MeModeFailed
+} ME_FW_STATE;
+
+typedef struct _ME_FW_UPDATE_LOCAL_PROTOCOL ME_FW_UPDATE_LOCAL_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *ME_FW_UPD_LOCAL_FUNC) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN UINT8 *FileBuffer,
+ IN UINTN FileLength
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *ME_FW_CHECK_MODE) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN ME_FW_STATE MeFwState
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *ME_FW_CHECK_VERSION) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN ME_FW_UPD_VERSION *MeFwVerion
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *ME_MEI_HMRFPO_ENABLE) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *PLATFORM_RESET) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN EFI_RESET_TYPE ResetType
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *PLATFORM_UNLOCK) (
+ IN ME_FW_UPDATE_LOCAL_PROTOCOL *This,
+ IN UINT32 UnlockType OPTIONAL
+);
+
+typedef struct _ME_FW_UPDATE_LOCAL_PROTOCOL {
+ EFI_PHYSICAL_ADDRESS FwUpdBufferAddress;
+ UINTN FwUpdBufferLength;
+ ME_FW_UPD_LOCAL_FUNC FwUpdLcl;
+ ME_FW_CHECK_MODE MeFwCheckMode;
+ ME_FW_CHECK_VERSION MeFwGetVersion;
+ ME_MEI_HMRFPO_ENABLE HmrfpoEnable;
+ PLATFORM_RESET PlatformReset;
+ PLATFORM_UNLOCK PlatformUnlock;
+ AMI_POST_MANAGER_PROTOCOL *AmiPostMgr;
+};
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file