summaryrefslogtreecommitdiff
path: root/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/MeWrapper/AmtWrapper/AmtStatusCode
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Board/EM/MeWrapper/AmtWrapper/AmtStatusCode')
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.cif12
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.mak81
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.sdl42
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c151
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c224
-rw-r--r--Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c368
6 files changed, 878 insertions, 0 deletions
diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.cif b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.cif
new file mode 100644
index 0000000..dcc3413
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "AmtStatusCode"
+ category = ModulePart
+ LocalRoot = "Board\EM\MeWrapper\AmtWrapper\AmtStatusCode"
+ RefName = "AmtStatusCode"
+[files]
+"AmtStatusCode.sdl"
+"AmtStatusCode.mak"
+"AmtStatusCodePei.c"
+"AmtStatusCodeDxe.c"
+"AmtStatusCodeSmm.c"
+<endComponent>
diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.mak b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.mak
new file mode 100644
index 0000000..d75f602
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.mak
@@ -0,0 +1,81 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (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/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCode.mak 1 2/08/12 1:10a Klzhan $
+#
+# $Revision: 1 $
+#
+# $Date: 2/08/12 1:10a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCode.mak $
+#
+# 1 2/08/12 1:10a Klzhan
+# Initial Check in
+#
+# 1 2/25/11 1:44a Klzhan
+# Initial Check-in
+#
+# 1 12/03/10 5:10a Klzhan
+# Initial Check-in.
+#
+#**********************************************************************
+#
+#<AMI_FHDR_START>
+#---------------------------------------------------------------------------
+# Name: AMTStatusCode.mak
+#
+# Description: AMT Status Code Makfile.
+#
+#---------------------------------------------------------------------------
+#<AMI_FHDR_END>
+
+#---------------------------------------------------------------------------
+# AMT StatusCode for DXE
+#---------------------------------------------------------------------------
+CORE_DXEBin : $(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodeDxe.obj
+
+$(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodeDxe.obj : $(AmtStatusCode_DIR)\AmtStatusCodeDxe.c
+ $(CC) $(CFLAGS:/W4=/W3) /DTIANO_RELEASE_VERSION=0x00080006 /DDXE_STATUS_CODE $(AlertStandardFormatDxe_INCLUDES) $(EDK_INCLUDES) $(STATUS_CODE_INCLUDES) /Fo$(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodeDxe.obj $(AmtStatusCode_DIR)\AmtStatusCodeDxe.c
+
+#---------------------------------------------------------------------------
+# AMT StatusCode for PEI
+#---------------------------------------------------------------------------
+CORE_PEIBin : $(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodePei.obj
+
+$(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodePei.obj : $(AmtStatusCode_DIR)\AmtStatusCodePei.c
+ $(CCPEI) $(CFLAGS:/W4=/W3) /DTIANO_RELEASE_VERSION=0x00080006 /DPEI_STATUS_CODE /IEDK\Foundation\Include\IA32 $(AlertStandardFormatPei_INCLUDES) $(EDK_INCLUDES) $(ME_INCLUDES) $(STATUS_CODE_INCLUDES) /Fo$(BUILD_DIR)\$(STATUS_CODE_DIR)\AmtStatusCodePei.obj $(AmtStatusCode_DIR)\AmtStatusCodePei.c
+
+#---------------------------------------------------------------------------
+# AMT StatusCode for SMM
+#---------------------------------------------------------------------------
+SmmStatusCodeBin : $(BUILD_DIR)\$(SmmStatusCode_DIR)\AmtStatusCodeSmm.obj
+
+$(BUILD_DIR)\$(SmmStatusCode_DIR)\AmtStatusCodeSmm.obj : $(AmtStatusCode_DIR)\AmtStatusCodeSmm.c
+ $(CC) $(CFLAGS:/W4=/W3) /DTIANO_RELEASE_VERSION=0x00080006 /DSMM_STATUS_CODE $(AlertStandardFormat_INCLUDES) $(ME_INCLUDES) $(STATUS_CODE_INCLUDES) $(CORE_INCLUDES) /Fo$(BUILD_DIR)\$(SmmStatusCode_DIR)\AmtStatusCodeSmm.obj $(AmtStatusCode_DIR)\AmtStatusCodeSmm.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/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.sdl b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.sdl
new file mode 100644
index 0000000..f83c100
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCode.sdl
@@ -0,0 +1,42 @@
+TOKEN
+ Name = "AmtStatusCode_SUPPORT"
+ Value = "0"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable AmtStatusCode support in Project"
+End
+
+MODULE
+ Help = "Includes AmtStatusCode.mak to Project"
+ File = "AmtStatusCode.mak"
+End
+
+PATH
+ Name = "AmtStatusCode_DIR"
+End
+
+ELINK
+ Name = "AmtStatusCode,"
+ Parent = "ReportMiscStatus"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "AmtStatusInit,"
+ Parent = "StatusCodeInitialize"
+ InvokeOrder = AfterParent
+End
+
+#ELINK
+# Name = "SmmAmtStatusCode,"
+# Parent = "SmmReportMiscStatus"
+# InvokeOrder = AfterParent
+#End
+
+#ELINK
+# Name = "SmmAmtStatusInit,"
+# Parent = "SmmStatusCodeInitialize"
+# InvokeOrder = AfterParent
+#End
diff --git a/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c
new file mode 100644
index 0000000..7cae372
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c
@@ -0,0 +1,151 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c 1 2/08/12 1:10a Klzhan $
+//
+// $Revision: 1 $
+//
+// $Date: 2/08/12 1:10a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodeDxe.c $
+//
+// 1 2/08/12 1:10a Klzhan
+// Initial Check in
+//
+// 1 2/25/11 1:44a Klzhan
+// Initial Check-in
+//
+// 1 12/03/10 5:11a Klzhan
+// Initial Check-in.
+//
+//**********************************************************************
+//
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+// Name: AMTStatusDxeCode.c
+//
+// Description: Processes ASF messages for DXE.
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+/*++
+
+Copyright (c) 2009 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:
+
+ AmtStatusCodeDxe.c
+
+Abstract:
+ Processes ASF messages
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (StatusCode)
+
+VOID AmtStatusCode(
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+)
+/*++
+Routine Description:
+
+ Provides an interface that a software module can call to report an ASF DXE status code.
+
+Arguments:
+
+ PeiServices - PeiServices pointer.
+
+ Type - Indicates the type of status code being reported.
+
+ Value - Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is
+ used to classify the entity as well as an operation.
+
+ Instance - The enumeration of a hardware or software entity within
+ the system. Valid instance numbers start with 1.
+
+ CallerId - This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different
+ rules to different callers.
+
+ Data - This optional parameter may be used to pass additional data.
+
+Returns:
+
+ None
+
+--*/
+{
+ //
+ // Do nothing, because AMT ASF driver will handle that.
+ //
+ return ;
+}
+
+EFI_STATUS
+AmtStatusInit(
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+)
+/*++
+Routine Description:
+
+ Init routine for DXE ASF StatusCode.
+
+Arguments:
+
+ FfsHeader - FfsHeader pointer.
+ PeiServices - PeiServices pointer.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ //
+ // Do nothing, because AMT ASF driver will handle that.
+ //
+ return EFI_SUCCESS;
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c
new file mode 100644
index 0000000..8cf18ba
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c
@@ -0,0 +1,224 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c 1 2/08/12 1:10a Klzhan $
+//
+// $Revision: 1 $
+//
+// $Date: 2/08/12 1:10a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodePei.c $
+//
+// 1 2/08/12 1:10a Klzhan
+// Initial Check in
+//
+// 1 2/25/11 1:44a Klzhan
+// Initial Check-in
+//
+// 1 12/03/10 5:11a Klzhan
+// Initial Check-in.
+//
+//**********************************************************************
+//
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+// Name: AMTStatusCodePei.c
+//
+// Description: Processes ASF messages for Pei.
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+/*++
+
+Copyright (c) 2009 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:
+
+ AmtStatusCodePei.c
+
+Abstract:
+ Processes ASF messages
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (StatusCode)
+
+#include EFI_PPI_DEFINITION (AmtStatusCode)
+
+EFI_GUID mPeiAmtStatusCodePpiGuid = PEI_AMT_STATUS_CODE_PPI_GUID;
+EFI_GUID mAmtPETQueueHobGuid = AMT_PET_QUEUE_HOB_GUID;
+
+EFI_STATUS
+AmtQueuePetMessage (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+/*++
+Routine Description:
+
+ This routine puts PET message to MessageQueue, which will be sent later.
+
+Arguments:
+
+ PeiServices - PeiServices pointer.
+ Type - StatusCode message type.
+ Value - StatusCode message value.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ AMT_PET_QUEUE_HOB *PETQueueHob;
+ EFI_STATUS Status;
+
+ // Create PET queue hob
+ Status = (**PeiServices).CreateHob ( PeiServices, \
+ EFI_HOB_TYPE_GUID_EXTENSION, \
+ sizeof(AMT_PET_QUEUE_HOB), \
+ &PETQueueHob );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ PETQueueHob->EfiHobGuidType.Name = mAmtPETQueueHobGuid;
+ PETQueueHob->Type = Type;
+ PETQueueHob->Value = Value;
+
+ return EFI_SUCCESS;
+}
+
+VOID AmtStatusCode(
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+)
+/*++
+Routine Description:
+
+ Provides an interface that a software module can call to report an ASF PEI status code.
+
+Arguments:
+
+ PeiServices - PeiServices pointer.
+
+ Type - Indicates the type of status code being reported.
+
+ Value - Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is
+ used to classify the entity as well as an operation.
+
+ Instance - The enumeration of a hardware or software entity within
+ the system. Valid instance numbers start with 1.
+
+ CallerId - This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different
+ rules to different callers.
+
+ Data - This optional parameter may be used to pass additional data.
+
+Returns:
+
+ None
+
+--*/
+{
+ PEI_AMT_STATUS_CODE_PPI *AmtStatusCode;
+ EFI_STATUS Status;
+
+ Status = (*PeiServices)->LocatePpi( PeiServices, \
+ &mPeiAmtStatusCodePpiGuid, \
+ 0, \
+ NULL, \
+ &AmtStatusCode );
+ if ( EFI_ERROR (Status) ) {
+ if (((Type & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) &&
+ ((Type & EFI_STATUS_CODE_TYPE_MASK) != EFI_ERROR_CODE)) {
+ return ;
+ }
+
+ // Register to Hob
+
+ // Create PET queue hob
+ AmtQueuePetMessage (PeiServices, Type, Value);
+
+ return ;
+ }
+
+ AmtStatusCode->ReportStatusCode (
+ PeiServices,
+ AmtStatusCode,
+ Type,
+ Value,
+ Instance,
+ CallerId,
+ Data
+ );
+
+ return ;
+}
+
+EFI_STATUS
+AmtStatusInit(
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+)
+/*++
+Routine Description:
+
+ Init routine for PEI ASF StatusCode.
+
+Arguments:
+
+ FfsHeader - FfsHeader pointer.
+ PeiServices - PeiServices pointer.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c
new file mode 100644
index 0000000..63b3919
--- /dev/null
+++ b/Board/EM/MeWrapper/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c
@@ -0,0 +1,368 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c 1 2/08/12 1:10a Klzhan $
+//
+// $Revision: 1 $
+//
+// $Date: 2/08/12 1:10a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/ME/AmtWrapper/AmtStatusCode/AmtStatusCodeSmm.c $
+//
+// 1 2/08/12 1:10a Klzhan
+// Initial Check in
+//
+// 1 2/25/11 1:44a Klzhan
+// Initial Check-in
+//
+// 1 12/03/10 5:11a Klzhan
+// Initial Check-in.
+//
+//**********************************************************************
+//
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+// Name: AMTStatusCodePei.c
+//
+// Description: Processes ASF messages for Pei.
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+/*++
+
+Copyright (c) 2009 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:
+
+ AmtStatusCodeSmm.c
+
+Abstract:
+ Processes ASF messages
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+#include "Protocol/AmtStatusCodeSmm/AmtStatusCodeSmm.h"
+//#include EFI_PROTOCOL_DEFINITION (AmtStatusCodeSmm)
+
+EFI_GUID mAmtSmmStatusCodeProtocolGuid = AMT_SMM_STATUS_CODE_PROTOCOL_GUID;
+EFI_GUID gAmtSmmPETQueueProtocolGuid = AMT_SMM_PET_QUEUE_PROTOCOL_GUID;
+
+AMT_SMM_PET_QUEUE_PROTOCOL gAmtSmmPETQueue;
+AMT_SMM_PET_QUEUE_PROTOCOL *gAmtSmmPETQueueProtocol;
+
+AMT_SMM_STATUS_CODE_PROTOCOL *mAmtSmmStatusCode;
+
+EFI_SYSTEM_TABLE *pST;
+EFI_BOOT_SERVICES *pBS;
+EFI_RUNTIME_SERVICES *pRS;
+EFI_SMM_BASE_PROTOCOL *pSmmBase;
+EFI_SMM_SYSTEM_TABLE *pSmst;
+
+VOID
+AmtInitializeListHead (
+ EFI_LIST_ENTRY *List
+ )
+{
+ List->ForwardLink = List;
+ List->BackLink = List;
+}
+
+VOID
+AmtInsertTailList (
+ EFI_LIST_ENTRY *ListHead,
+ EFI_LIST_ENTRY *Entry
+ )
+{
+ EFI_LIST_ENTRY *_ListHead;
+ EFI_LIST_ENTRY *_BackLink;
+
+ _ListHead = ListHead;
+ _BackLink = _ListHead->BackLink;
+ Entry->ForwardLink = _ListHead;
+ Entry->BackLink = _BackLink;
+ _BackLink->ForwardLink = Entry;
+ _ListHead->BackLink = Entry;
+}
+
+EFI_STATUS
+AmtQueuePetMessage (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+/*++
+Routine Description:
+
+ This routine puts PET message to MessageQueue, which will be sent later.
+
+Arguments:
+
+ PeiServices - PeiServices pointer.
+ Type - StatusCode message type.
+ Value - StatusCode message value.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ AMT_SMM_PET_QUEUE_NODE *NewNode;
+ EFI_STATUS Status;
+
+ Status = pSmmBase->SmmAllocatePool (
+ pSmmBase,
+ EfiRuntimeServicesData,
+ sizeof (AMT_SMM_PET_QUEUE_NODE),
+ &NewNode
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ NewNode->Signature = AMT_SMM_PET_QUEUE_NODE_SIGNATURE;
+ NewNode->Type = Type;
+ NewNode->Value = Value;
+ AmtInsertTailList (&gAmtSmmPETQueueProtocol->MessageList, &NewNode->Link);
+
+ return EFI_SUCCESS;
+}
+
+VOID SmmAmtStatusCode(
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+)
+/*++
+Routine Description:
+
+ Provides an interface that a software module can call to report an ASF DXE status code.
+
+Arguments:
+
+ PeiServices - PeiServices pointer.
+
+ Type - Indicates the type of status code being reported.
+
+ Value - Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is
+ used to classify the entity as well as an operation.
+
+ Instance - The enumeration of a hardware or software entity within
+ the system. Valid instance numbers start with 1.
+
+ CallerId - This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different
+ rules to different callers.
+
+ Data - This optional parameter may be used to pass additional data.
+
+Returns:
+
+ None
+
+--*/
+{
+ if (mAmtSmmStatusCode == NULL) {
+ if (((Type & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) &&
+ ((Type & EFI_STATUS_CODE_TYPE_MASK) != EFI_ERROR_CODE)) {
+ return ;
+ }
+
+ // Register to Queue
+ AmtQueuePetMessage (PeiServices, Type, Value);
+
+ return ;
+ }
+
+ mAmtSmmStatusCode->ReportStatusCode (
+ mAmtSmmStatusCode,
+ Type,
+ Value,
+ Instance,
+ CallerId,
+ Data
+ );
+
+ return ;
+}
+
+VOID
+EFIAPI
+AmtCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+Routine Description:
+
+ ASF SMM StatusCode Callback.
+
+Arguments:
+
+ Event - ASF StatusCode Callback Event.
+
+ Context - ASF StatusCode Callback Context.
+
+Returns:
+
+ None
+
+--*/
+{
+ pBS->LocateProtocol ( &mAmtSmmStatusCodeProtocolGuid, NULL, &mAmtSmmStatusCode );
+
+ return;
+}
+
+EFI_STATUS
+AmtCreateMessageQueue (
+ VOID
+ )
+/*++
+Routine Description:
+
+ This routine creats PET MessageQueue.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Status = pBS->LocateProtocol (
+ &gAmtSmmPETQueueProtocolGuid,
+ NULL,
+ &gAmtSmmPETQueueProtocol
+ );
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Create Queue for later usage
+ //
+ gAmtSmmPETQueueProtocol = &gAmtSmmPETQueue;
+
+ AmtInitializeListHead (&gAmtSmmPETQueueProtocol->MessageList);
+ Handle = NULL;
+ Status = pBS->InstallProtocolInterface (
+ &Handle,
+ &gAmtSmmPETQueueProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &gAmtSmmPETQueue
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+SmmAmtStatusInit(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+/*++
+Routine Description:
+
+ Init routine for SMM ASF StatusCode.
+
+Arguments:
+
+ FfsHeader - FfsHeader pointer.
+ PeiServices - PeiServices pointer.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+--*/
+{
+ EFI_STATUS Status;
+ VOID *AmtRegistration;
+ EFI_EVENT Event;
+
+ pST=SystemTable;
+ pBS=SystemTable->BootServices;
+ pRS=SystemTable->RuntimeServices;
+ Status = pBS->LocateProtocol(&gEfiSmmBaseProtocolGuid, NULL, &pSmmBase);
+ Status = pSmmBase->GetSmstLocation(pSmmBase,&pSmst);
+
+ AmtCreateMessageQueue ();
+
+ Status = pBS->LocateProtocol ( &mAmtSmmStatusCodeProtocolGuid, NULL, &mAmtSmmStatusCode );
+ if ( !EFI_ERROR (Status) ) return EFI_SUCCESS;
+
+ //
+ // Create the event
+ //
+ Status = pBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ AmtCallback,
+ NULL,
+ &Event
+ );
+ if (EFI_ERROR (Status)) return Status;
+
+ //
+ // Register for protocol notifactions on this event
+ // NOTE: Because this protocol will be installed in SMM, it is safety to
+ // register ProtocolNotify here. This event will be triggered in SMM later.
+ //
+ Status = pBS->RegisterProtocolNotify (
+ &mAmtSmmStatusCodeProtocolGuid,
+ Event,
+ &AmtRegistration
+ );
+ if (EFI_ERROR (Status)) return Status;
+
+ return EFI_SUCCESS;
+}
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (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