diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Core/EM/OFBD/DEFCFG | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Core/EM/OFBD/DEFCFG')
-rw-r--r-- | Core/EM/OFBD/DEFCFG/DefCfg.c | 269 | ||||
-rw-r--r-- | Core/EM/OFBD/DEFCFG/DefCfg.cif | 11 | ||||
-rw-r--r-- | Core/EM/OFBD/DEFCFG/DefCfg.h | 72 | ||||
-rw-r--r-- | Core/EM/OFBD/DEFCFG/DefCfg.mak | 76 | ||||
-rw-r--r-- | Core/EM/OFBD/DEFCFG/DefCfg.sdl | 56 |
5 files changed, 484 insertions, 0 deletions
diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.c b/Core/EM/OFBD/DEFCFG/DefCfg.c new file mode 100644 index 0000000..5923a0b --- /dev/null +++ b/Core/EM/OFBD/DEFCFG/DefCfg.c @@ -0,0 +1,269 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.c 9 8/16/13 3:13a Terrylin $ +// +// $Revision: 9 $ +// +// $Date: 8/16/13 3:13a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.c $ +// +// 9 8/16/13 3:13a Terrylin +// [Description] Correct the description error. +// +// 8 8/07/13 11:21p Terrylin +// [Description] Add more description. +// +// 7 7/31/13 4:49a Terrylin +// [TAG] EIP125898 +// [Category] New Feature +// [Description] Add the AFU's /Kn and /Ln two commands status control. +// +// 6 8/06/12 7:00a Terrylin +// [TAG] EIP96286 +// [Category] Improvement +// [Description] Add the template codes for SMBIOS module DMI data +// preserve support. +// [Files] DefCfg.sdl +// DefCfg.c +// +// 5 2/22/12 4:37a Terrylin +// Add the GAN command support sample +// +// 4 3/16/11 10:37p Terrylin +// [TAG] EIP51285 +// [Category] Improvement +// [Description] Fill the description for user more clearly. +// [Files] DefCfg.mak +// DefCfg.h +// DefCfg.c +// +// 3 12/17/10 3:21a Terrylin +// Fix sample code is wrong problem. +// +// 2 6/07/10 11:22p Terrylin +// Fix sample code is wrong problem. +// +// 1 5/06/10 2:22a Lawrencechang +// Initial check-in. +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: DefCfg.c +// +// Description: +// OFBD Default Command Configuration provides BIOS an oppertunity to override end user issued command in AFU. +// +// For example, BIOS could disable /k command even user issued it in AFU, or automatically enable /b when /p +// is issued. +// +// For AFU¡¦s "/Ln" and "/Kn" two commands parameter identify. That AFU will replace the OFBD_EXT_TBL_END data +// from 0xFFFF55AA to OFBD_TC_51_DC_EXT_STRUCT. Therefore, BIOS can through the "ddIndexCfg" flag to identify +// who is this command structure. (The AFU version 3.05.1 or later supports.) +// +// Please reference OFBDDEFCFGHandle for more details. +// +//<AMI_FHDR_END> +//********************************************************************** +#include "Efi.h" +#include "token.h" +#include <AmiLib.h> +#include <AmiDxeLib.h> +#include "DefCfg.h" +#include "..\OFBD.h" + +//#define CONVERT_TO_STRING(a) #a +#define STR(a) CONVERT_TO_STRING(a) + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: OFBDDEFCFGHandle +// +// Description: OFBD Default Command Configuration Handle +// +// Input: +// IN OUT OFBD_HDR *pOFBDHdr +// Output: +// EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +OFBDDEFCFGHandle( + IN OUT OFBD_HDR *pOFBDHdr) +{ + EFI_STATUS Status = EFI_SUCCESS; + + UINT8 *pOFBDTblEnd; + OFBD_TC_51_DC_STRUCT *DCStructPtr; + OFBD_TC_51_DC_EXT_STRUCT *DCExtStructPtr; + UINT32 ExtAddr; + + pOFBDTblEnd = (UINT8 *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size)); + DCStructPtr = (OFBD_TC_51_DC_STRUCT *)((UINT8 *)pOFBDHdr + pOFBDHdr->OFBD_HDR_SIZE + sizeof(OFBD_EXT_HDR)); + DCExtStructPtr = (OFBD_TC_51_DC_EXT_STRUCT *)((UINT8 *)pOFBDHdr + (pOFBDHdr->OFBD_Size) - sizeof(OFBD_END)); + ExtAddr = *(UINT32 *)((UINT8 *)pOFBDTblEnd - sizeof(OFBD_END)); + if (ExtAddr == OFBD_EXT_TBL_END) + DCExtStructPtr = NULL; + +#if SMBIOS_DMIEDIT_DATA_LOC == 2 + + if ((DCStructPtr->ddRetSts & OFBD_TC_CFG_N) && (DCStructPtr->ddRetSts & OFBD_TC_CFG_R) && (DCStructPtr->ddRetSts & OFBD_TC_CFG_CAPSULE)) + { + EFI_GUID gEfiSmbiosNvramGuid = {0x4b3082a3, 0x80c6, 0x4d7e, { 0x9c, 0xd0, 0x58, 0x39, 0x17, 0x26, 0x5d, 0xf1 }}; + CHAR16 *PreserveSmbiosNvramVar = L"PreserveSmbiosNvramVar"; + UINTN Size = sizeof (UINT8); + UINT32 PreserveSmbiosNvram; + + // Set PreserveSmbiosNvram + pRS->SetVariable ( + PreserveSmbiosNvramVar, + &gEfiSmbiosNvramGuid, + EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, + Size, + &PreserveSmbiosNvram + ); + } + +#endif + +#if DEF_CFG_SAMPLE_TEST + // + // OEM add + // + + // Sample : always cancel /K command + if (DCStructPtr->ddRetSts & OFBD_TC_CFG_K) + { + DCStructPtr->ddExtCfg |= OFBD_TC_CFG_K; + } + + // Sample : add new /B command when /P has issued + if (DCStructPtr->ddRetSts & OFBD_TC_CFG_P) + { + DCStructPtr->ddRetSts |= OFBD_TC_CFG_B; + } + + // Sample : For GAN command + // If ddRetSts equals to "0xFFFFFFFF", this means BIOS supply "/GAN" command. + if (DCStructPtr->ddRetSts & OFBD_TC_CFG_GAN) + { + DCStructPtr->ddRetSts = 0xFFFFFFFF; + } + + // Sample : For /Ln or /Kn command status setting + if (DCExtStructPtr) + { + OFBD_TC_51_DC_EXT_STRUCT *NStructPtr = DCExtStructPtr; + + do + { + // Check current struct is Ln command or not + if (NStructPtr->ddIndexCfg == OFBD_TC_CFG_LN) + { + // Sample : add new /L1 command when /L0 command is issued + if (NStructPtr->ddExtCfg & BIT00) + { + NStructPtr->ddExtCfg |= BIT01; + } + } + + // Check current struct is Kn command or not + if (NStructPtr->ddIndexCfg == OFBD_TC_CFG_KN) + { + // Sample : always cancel /K0 command + if (NStructPtr->ddExtCfg & BIT00) + { + NStructPtr->ddIgnCfg |= BIT00; + } + } + // Ponit to next structure + NStructPtr++; + ExtAddr = *(UINT32 *)NStructPtr; + }while(ExtAddr && ExtAddr != 0xFFFFFFFF); + } +#endif + + return(Status); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: DEFCFGEntry +// +// Description: OFBD Default Command Configuration Entry Point +// +// Input: +// IN VOID *Buffer +// IN OUT UINT8 *pOFBDDataHandled +// Output: +// VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID DEFCFGEntry ( + IN VOID *Buffer, + IN OUT UINT8 *pOFBDDataHandled ) +{ + OFBD_HDR *pOFBDHdr; + OFBD_EXT_HDR *pOFBDExtHdr; + VOID *pOFBDTblEnd; + OFBD_TC_51_DC_STRUCT *DCStructPtr; + + if(*pOFBDDataHandled == 0) + { + pOFBDHdr = (OFBD_HDR *)Buffer; + pOFBDExtHdr = (OFBD_EXT_HDR *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_HDR_SIZE)); + DCStructPtr = (OFBD_TC_51_DC_STRUCT *)((UINT8 *)pOFBDExtHdr + sizeof(OFBD_EXT_HDR)); + pOFBDTblEnd = (VOID *)((UINT8 *)Buffer + (pOFBDHdr->OFBD_Size)); + + if(pOFBDHdr->OFBD_FS & OFBD_FS_CFG) + { + //Check Type Code ID + if(pOFBDExtHdr->TypeCodeID == OFBD_EXT_TC_AFUDEFCFG) + { + if(OFBDDEFCFGHandle(pOFBDHdr) == EFI_SUCCESS) + { + //OEM Default Command Configuration Handled. + *pOFBDDataHandled = 0xFF; + return; + } + } + //Error occured + *pOFBDDataHandled = 0xFE; + return; + } + } + + return; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.cif b/Core/EM/OFBD/DEFCFG/DefCfg.cif new file mode 100644 index 0000000..a4f0d7b --- /dev/null +++ b/Core/EM/OFBD/DEFCFG/DefCfg.cif @@ -0,0 +1,11 @@ +<component> + name = "AFU Default Command Configuration" + category = ModulePart + LocalRoot = "Core\EM\OFBD\DEFCFG\" + RefName = "OFBD_DEFCFG" +[files] +"DefCfg.sdl" +"DefCfg.mak" +"DefCfg.h" +"DefCfg.c" +<endComponent> diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.h b/Core/EM/OFBD/DEFCFG/DefCfg.h new file mode 100644 index 0000000..06f9cfe --- /dev/null +++ b/Core/EM/OFBD/DEFCFG/DefCfg.h @@ -0,0 +1,72 @@ +//**********************************************************************// +//**********************************************************************// +//** **// +//** (C)Copyright 1985-2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **// +//** **// +//** Phone: (770)-246-8600 **// +//** **// +//**********************************************************************// +//**********************************************************************// + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.h 2 3/16/11 10:37p Terrylin $ +// +// $Revision: 2 $ +// +// $Date: 3/16/11 10:37p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.h $ +// +// 2 3/16/11 10:37p Terrylin +// [TAG] EIP51285 +// [Category] Improvement +// [Description] Fill the description for user more clearly. +// [Files] DefCfg.mak +// DefCfg.h +// DefCfg.c +// +// 1 5/06/10 2:21a Lawrencechang +// Initial check-in. +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: DefCfg.h +// +// Description: Header file for the DefCfg +// +//<AMI_FHDR_END> +//********************************************************************** +#ifndef _EFI_DEFCFG_H_ +#define _EFI_DEFCFG_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#define RETURN_ERR 1 + +/****** DO NOT WRITE BELOW THIS LINE *******/ +#ifdef __cplusplus +} +#endif +#endif + +//**********************************************************************// +//**********************************************************************// +//** **// +//** (C)Copyright 1985-2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **// +//** **// +//** Phone: (770)-246-8600 **// +//** **// +//**********************************************************************// +//**********************************************************************// diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.mak b/Core/EM/OFBD/DEFCFG/DefCfg.mak new file mode 100644 index 0000000..060d5d5 --- /dev/null +++ b/Core/EM/OFBD/DEFCFG/DefCfg.mak @@ -0,0 +1,76 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.mak 2 3/16/11 10:37p Terrylin $ +# +# $Revision: 2 $ +# +# $Date: 3/16/11 10:37p $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/OFBD/DEFCFG/DefCfg.mak $ +# +# 2 3/16/11 10:37p Terrylin +# [TAG] EIP51285 +# [Category] Improvement +# [Description] Fill the description for user more clearly. +# [Files] DefCfg.mak +# DefCfg.h +# DefCfg.c +# +# 1 5/06/10 2:21a Lawrencechang +# Initial check-in. +# +#************************************************************************* +#<AMI_FHDR_START> +# +# Name: DefCfg.mak +# +# Description: Make file for the DefCfg.obj +# +#<AMI_FHDR_END> +#************************************************************************* +all : DEFCFG + +DEFCFG : $(BUILD_DIR)\DEFCFG.mak DEFCFGBin + +$(BUILD_DIR)\DEFCFG.mak : $(OFBD_DEFCFG_DIR)\$(@B).cif $(OFBD_DEFCFG_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(OFBD_DEFCFG_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +DEFCFGBin : + @set INCLUDE=%%INCLUDE%% + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\DEFCFG.mak all\ + NAME=DEFCFG \ + TYPE=LIBRARY LIBRARY_NAME=$(DEFCFGLIB) + +$(DEFCFGLIB) : DEFCFG + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + + diff --git a/Core/EM/OFBD/DEFCFG/DefCfg.sdl b/Core/EM/OFBD/DEFCFG/DefCfg.sdl new file mode 100644 index 0000000..d19994f --- /dev/null +++ b/Core/EM/OFBD/DEFCFG/DefCfg.sdl @@ -0,0 +1,56 @@ +TOKEN + Name = "DEFCFG_SUPPORT" + Value = "1" + Help = "Main switch to enable AFU Default Command Configuration support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "DEFCFGLIB" + Value = "$(BUILD_DIR)\DEFCFGLIB.lib" + TokenType = Expression + TargetMAK = Yes +End + +TOKEN + Name = "[AFU Default Command Configuration Sample Code Section]" + Help = "See detail description in each token's help box." + TokenType = Expression + Lock = Yes +End + +TOKEN + Name = "DEF_CFG_SAMPLE_TEST" + Value = "0" + Help = "Test AFU Default Command Configuration Function" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes + Token = "DEFCFG_SUPPORT" "=" "1" +End + +PATH + Name = "OFBD_DEFCFG_DIR" +End + +MODULE + Help = "Includes DefCfg.mak to Project" + File = "DefCfg.mak" +End + +ELINK + Name = "$(BUILD_DIR)\DEFCFGLIB.lib" + Parent = "OFBDLISTLIB" + InvokeOrder = AfterParent +End + +ELINK + Name = "DEFCFGEntry," + Parent = "OFBDPartsList" + Token = "DEFCFG_SUPPORT" "=" "1" + InvokeOrder = AfterParent +End + |