summaryrefslogtreecommitdiff
path: root/Core/EM/OFBD/CleanErrorLog
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /Core/EM/OFBD/CleanErrorLog
downloadzprj-master.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Core/EM/OFBD/CleanErrorLog')
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c259
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif11
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h71
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak75
-rw-r--r--Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl63
5 files changed, 479 insertions, 0 deletions
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c
new file mode 100644
index 0000000..80889d9
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.c
@@ -0,0 +1,259 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.c 3 10/06/11 1:28a Terrylin $
+//
+// $Revision: 3 $
+//
+// $Date: 10/06/11 1:28a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.c $
+//
+// 3 10/06/11 1:28a Terrylin
+// Fix the build error, when Gpnv Error Logging module didn't enable.
+//
+// 2 3/16/11 10:32p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] CleanErrorLog.mak
+// CleanErrorLog.h
+// CleanErrorLog.c
+//
+// 1 1/17/11 3:56a Terrylin
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CleanErrorLog.c
+//
+// Description:
+// This function is used to Clean Error Log. For example,AFU will call this function to clean error log when
+// /CLNEVNLOG is issued.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "Efi.h"
+#include <Protocol\SmiFlash.h>
+#include <AmiLib.h>
+#include <AmiDxeLib.h>
+#include "CleanErrorLog.h"
+#include "..\OFBD.h"
+
+//#define CONVERT_TO_STRING(a) #a
+#define STR(a) CONVERT_TO_STRING(a)
+
+EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+EFI_SMI_FLASH_PROTOCOL *mSmiFlash = NULL;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogCallback
+//
+// Description: Locate SmiFlash protocol callback
+//
+// Input:
+// IN EFI_EVENT Event
+// IN VOID *Context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogCallback(
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+
+ pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogInSmm
+//
+// Description: OFBD Clear event log InSmm Function
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogInSmm(VOID)
+{
+ EFI_STATUS Status;
+ EFI_GUID gEfiSmiFlashProtocolGuid = EFI_SMI_FLASH_GUID;
+
+ Status = pBS->LocateProtocol (&gEfiSmiFlashProtocolGuid, NULL, &mSmiFlash);
+ if (EFI_ERROR(Status)){
+ EFI_EVENT SmiFlashCallbackEvt;
+ VOID *Reg;
+ RegisterProtocolCallback(
+ &gEfiSmiFlashProtocolGuid, CleanErrorLogCallback,
+ NULL,&SmiFlashCallbackEvt, &Reg
+ );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OFBDCleanErrorLogHandle
+//
+// Description: OFBD Clean Gpnv Error Log Handle
+//
+// Input:
+// IN OUT OFBD_HDR *pOFBDHdr
+// Output:
+// EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+OFBDCleanErrorLogHandle(
+ IN OUT OFBD_HDR *pOFBDHdr)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if CLEAN_GPNV_ERROR_LOG_SAMPLE_TEST
+
+ UINT8 *pOFBDTblEnd;
+ OFBD_TC_58_CEL_STRUCT *CELStructPtr;
+ #if defined(FV_ERROR_LOGGING_BASE) && defined(FV_ERROR_LOGGING_SIZE)
+ FUNC_BLOCK FuncBlock;
+ UINT8 pType1Header[16];
+ #endif
+
+ pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size));
+ CELStructPtr = (OFBD_TC_58_CEL_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR));
+
+ // Is need to Clean Gpnv Error Log
+ if (CELStructPtr->dwFunSts == OFBD_TC_CEL_FUNC_REQ)
+ {
+ // Check Gpnv Error Logging module whether support or not
+ #if !defined(FV_ERROR_LOGGING_BASE) || !defined(FV_ERROR_LOGGING_SIZE)
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_BIOS_NOT_SUPPORT;
+ #else
+ //
+ // Reference from "ErrorLogging/SmiGpnv/SmiGpnv.c" file code +>>>
+ //
+ // SS: Alaska;$/Alaska/SOURCE/Modules/ErrorLogging;
+ //
+ // Label 4.6.3.6_GPNV_ERRLOG_2.1a
+ //
+ // Enable Flash Write.
+ Status = mSmiFlash->EnableFlashWrite(&FuncBlock);
+ // Read flash to preserve EFI_GPNV_ERROR_HEADER_TYPE1 header.
+ FuncBlock.BufAddr = (UINTN)&pType1Header;
+ FuncBlock.BlockSize = 0x10; // EFI_GPNV_ERROR_HEADER_TYPE1
+ FuncBlock.BlockAddr = ((UINT32)FV_ERROR_LOGGING_BASE & \
+ (FLASH_SIZE - 1)); //0 starts at 0xfff0_0000
+ FuncBlock.ErrorCode = 0;
+ Status = mSmiFlash->ReadFlash(&FuncBlock);
+ // Erase Error Logging GPNV.
+ FuncBlock.BlockSize = FV_ERROR_LOGGING_SIZE; //max size 0xffff
+ FuncBlock.BufAddr = 0;
+ Status = mSmiFlash->EraseFlash(&FuncBlock); // Write Flash
+ // Restore EFI_GPNV_ERROR_HEADER_TYPE1 header.
+ FuncBlock.BlockSize = 0x10; //EFI_GPNV_ERROR_HEADER_TYPE1
+ FuncBlock.BufAddr = (UINTN)&pType1Header;
+ Status = mSmiFlash->WriteFlash(&FuncBlock); // Write Flash
+ // Disable Flash Write.
+ Status = mSmiFlash->DisableFlashWrite(&FuncBlock);
+ //
+ // <<<+
+ //
+ if (EFI_ERROR (Status))
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_ERROR;
+ else
+ CELStructPtr->dwRetSts = OFBD_TC_CEL_OK;
+ #endif
+ }
+
+#endif
+
+ return(Status);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanErrorLogEntry
+//
+// Description: OFBD Clean Gpnv Error Log Entry Point
+//
+// Input:
+// IN VOID *Buffer
+// IN OUT UINT8 *pOFBDDataHandled
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanErrorLogEntry (
+ IN VOID *Buffer,
+ IN OUT UINT8 *pOFBDDataHandled )
+{
+ OFBD_HDR *pOFBDHdr;
+ OFBD_EXT_HDR *pOFBDExtHdr;
+ VOID *pOFBDTblEnd;
+ OFBD_TC_58_CEL_STRUCT *CELStructPtr;
+
+ if(*pOFBDDataHandled == 0)
+ {
+ pOFBDHdr = (OFBD_HDR *)Buffer;
+ pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE));
+ CELStructPtr = (OFBD_TC_58_CEL_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR));
+ pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size));
+
+ if(pOFBDHdr->OFBD_FS & OFBD_FS_ERR_LOG)
+ {
+ //Check Type Code ID
+ if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_CLN_ERR_LOG)
+ {
+ if(OFBDCleanErrorLogHandle(pOFBDHdr) == EFI_SUCCESS)
+ {
+ //OEM Default Command Configuration Handled.
+ *pOFBDDataHandled = 0xFF;
+ return;
+ }
+ }
+ //Error occured
+ *pOFBDDataHandled = 0xFE;
+ return;
+ }
+ }
+
+ return;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif
new file mode 100644
index 0000000..a04fe75
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "Clean Gpnv Error Log"
+ category = ModulePart
+ LocalRoot = "Core\EM\OFBD\CleanErrorLog\"
+ RefName = "OFBD_CLEANERRORLOG"
+[files]
+"CleanErrorLog.sdl"
+"CleanErrorLog.mak"
+"CleanErrorLog.h"
+"CleanErrorLog.c"
+<endComponent>
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h
new file mode 100644
index 0000000..466a1ff
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.h
@@ -0,0 +1,71 @@
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//**********************************************************************//
+//**********************************************************************//
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.h 2 3/16/11 10:32p Terrylin $
+//
+// $Revision: 2 $
+//
+// $Date: 3/16/11 10:32p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.h $
+//
+// 2 3/16/11 10:32p Terrylin
+// [TAG] EIP51285
+// [Category] Improvement
+// [Description] Fill the description for user more clearly.
+// [Files] CleanErrorLog.mak
+// CleanErrorLog.h
+// CleanErrorLog.c
+//
+// 1 1/17/11 3:56a Terrylin
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CleanErrorLog.h
+//
+// Description: Header file for the CleanErrorLog
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EFI_CLEANERRORLOG_H_
+#define _EFI_CLEANERRORLOG_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RETURN_ERR 1
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//**********************************************************************//
+//**********************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//**********************************************************************//
+//**********************************************************************//
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak
new file mode 100644
index 0000000..1055d73
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.mak
@@ -0,0 +1,75 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
+
+#*************************************************************************
+# $Header: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.mak 2 3/16/11 10:32p Terrylin $
+#
+# $Revision: 2 $
+#
+# $Date: 3/16/11 10:32p $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/OFBD/CleanErrorLog/CleanErrorLog.mak $
+#
+# 2 3/16/11 10:32p Terrylin
+# [TAG] EIP51285
+# [Category] Improvement
+# [Description] Fill the description for user more clearly.
+# [Files] CleanErrorLog.mak
+# CleanErrorLog.h
+# CleanErrorLog.c
+#
+# 1 1/17/11 3:56a Terrylin
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CleanErrorLog.mak
+#
+# Description: Make file for the CleanErrorLog.obj
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+all : CLEANERRORLOG
+
+CLEANERRORLOG : $(BUILD_DIR)\CLEANERRORLOG.mak CLEANERRORLOGBin
+
+$(BUILD_DIR)\CLEANERRORLOG.mak : $(OFBD_CLEANERRORLOG_DIR)\$(@B).cif $(OFBD_CLEANERRORLOG_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(OFBD_CLEANERRORLOG_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CLEANERRORLOGBin :
+ @set INCLUDE=%%INCLUDE%%
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\CLEANERRORLOG.mak all\
+ NAME=CLEANERRORLOG \
+ TYPE=LIBRARY LIBRARY_NAME=$(CLEANERRORLOGLIB)
+
+$(CLEANERRORLOGLIB) : CLEANERRORLOG
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
+
+
diff --git a/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl
new file mode 100644
index 0000000..4a26863
--- /dev/null
+++ b/Core/EM/OFBD/CleanErrorLog/CleanErrorLog.sdl
@@ -0,0 +1,63 @@
+TOKEN
+ Name = "CLEAN_ERROR_LOG_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable Clean Gpnv Error Log support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "CLEANERRORLOGLIB"
+ Value = "$(BUILD_DIR)\CLEANERRORLOG.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "[Clean Gpnv Error Log Sample Code Section]"
+ Help = "See detail description in each token's help box."
+ TokenType = Expression
+ Lock = Yes
+End
+
+TOKEN
+ Name = "CLEAN_GPNV_ERROR_LOG_SAMPLE_TEST"
+ Value = "1"
+ Help = "Test Clean Gpnv Error Log Function"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "OFBD_CLEANERRORLOG_DIR"
+End
+
+MODULE
+ Help = "Includes CleanErrorLog.mak to Project"
+ File = "CleanErrorLog.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\CLEANERRORLOG.lib"
+ Parent = "OFBDLISTLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "CleanErrorLogEntry,"
+ Parent = "OFBDPartsList"
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "CleanErrorLogInSmm,"
+ Parent = "OFBDInSmmFuncList"
+ Token = "CLEAN_ERROR_LOG_SUPPORT" "=" "1"
+ InvokeOrder = AfterParent
+End
+