summaryrefslogtreecommitdiff
path: root/Core/CSPLib
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/CSPLib
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Core/CSPLib')
-rw-r--r--Core/CSPLib/CSP Library.chmbin0 -> 56836 bytes
-rw-r--r--Core/CSPLib/CspLib.CIF20
-rw-r--r--Core/CSPLib/CspLib.mak251
-rw-r--r--Core/CSPLib/CspLib.sdl107
-rw-r--r--Core/CSPLib/CspLibDxe.C104
-rw-r--r--Core/CSPLib/CspLibDxe.Dxs67
-rw-r--r--Core/CSPLib/CspLibGeneric.C399
-rw-r--r--Core/CSPLib/CspLibGeneric.h444
-rw-r--r--Core/CSPLib/CspLibPei.C329
-rw-r--r--Core/CSPLib/FID.c108
10 files changed, 1829 insertions, 0 deletions
diff --git a/Core/CSPLib/CSP Library.chm b/Core/CSPLib/CSP Library.chm
new file mode 100644
index 0000000..9aca1b6
--- /dev/null
+++ b/Core/CSPLib/CSP Library.chm
Binary files differ
diff --git a/Core/CSPLib/CspLib.CIF b/Core/CSPLib/CspLib.CIF
new file mode 100644
index 0000000..c53fab8
--- /dev/null
+++ b/Core/CSPLib/CspLib.CIF
@@ -0,0 +1,20 @@
+<component>
+ name = "CSP Library"
+ category = eBoard
+ LocalRoot = "Core\CSPLib\"
+ RefName = "CSP Library"
+[files]
+"CspLib.sdl"
+"CspLib.mak"
+"CspLibPei.C"
+"CspLibDxe.C"
+"CspLibDxe.Dxs"
+"CspLibGeneric.C"
+"CspLibGeneric.h"
+"CSP Library.chm"
+"FID.c"
+[parts]
+"CSP Library Include"
+"CSP Library Protocols"
+"CSP Library PPIs"
+<endComponent>
diff --git a/Core/CSPLib/CspLib.mak b/Core/CSPLib/CspLib.mak
new file mode 100644
index 0000000..990087e
--- /dev/null
+++ b/Core/CSPLib/CspLib.mak
@@ -0,0 +1,251 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLib.mak 25 3/15/11 5:24p Felixp $
+#
+# $Revision: 25 $
+#
+# $Date: 3/15/11 5:24p $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLib.mak $
+#
+# 25 3/15/11 5:24p Felixp
+# Include $(CSP_LIB_DIR)\CspLibGeneric.h at the beginning of
+# AMICSPLIBINc.h
+#
+# 24 2/22/11 3:48p Artems
+# EIP 51548 - replaced TABs with spaces
+#
+# 23 2/22/11 12:38p Artems
+# Updated file header. Removed dependency of Fid.c from Fid.ffs (EIP
+# 52936)
+#
+# 20 5/25/10 6:06p Artems
+# Fixed bug, use CORE_COMBINED_VERSION instead of CORE_REVISION
+#
+# 19 5/21/10 4:38p Artems
+# Changed backward compatibility token from CORE_REVISION to
+# CORE_COMBINED_VERSION
+#
+# 18 5/07/10 3:57p Artems
+# Build CSP library separately for PEI and DXE phase
+#
+# 17 5/06/10 12:22p Artems
+# EIP 38241 - $FID signature is absent
+#
+# 16 4/05/10 5:50p Artems
+# Added Core 4.6.3 backward compatibility fix
+#
+# 15 3/25/10 3:07p Artems
+# EIP 33953: Added eLink infrastructure to support runtime shadow ram
+# writing
+#
+# 14 12/02/09 4:52p Robert
+# Added changes for support for Revision 2 of the Firmware Version
+# Structure
+#
+# 13 8/26/09 10:59a Robert
+# Adding back the changes from checkin #11. This was accidentally
+# overwritten in checkin #12
+#
+# 12 8/14/09 10:47a Robert
+# Added FID.asm to the component for compliance with AMI Utility
+# specification
+#
+# 11 8/11/09 12:34p Felixp
+# Improvement (EIP 24965). New method of contributing files to CspLib
+# library. Modules that contribute files to CspLib should now use new
+# notation.
+# 1. AMI_CSP_LIB_INCLUDE_FILES is replaced with dependency from
+# $(BUILD_DIR)\AMICSPLIBInc.H (no plus needed between files)
+# 2. AMI_CSP_LIB_OBJS is replaced with dependency from AMICSPLibBin
+# 3. AMI_CSP_LIB_LIBRARY_PATH should not be used
+# Items #1 & #2 are improvements. Old macros based approach only worked
+# for modules that are above than CspLib in the project tree.
+# Item #3 is a cleanup.
+#
+# 10 6/11/09 5:43p Robert
+# Comment updates for CHM and coding standard
+#
+# 9 10/13/07 11:41p Michaela
+# Added CspLibGeneric.c to CSP library
+#
+# 8 8/25/06 11:02a Felixp
+#
+# 7 8/24/06 3:40p Felixp
+# Preliminary x64 support (work in progress)
+#
+# 6 12/08/05 11:19a Felixp
+#
+# 5 11/21/05 6:51p Felixp
+# dependency for $(BUILD_DIR)\AMICSPLIBInc.H added
+#
+# 4 10/12/05 8:38p Felixp
+# CspLibPei is no longer a separate FFS file. It is now linked with PEI
+# Core
+# CspLib.mak,CspLib.lib, and CspLib.cif modified.
+# CspLibPei.dxe removed
+#
+# 3 4/19/05 2:52p Sivagarn
+# Changed the dependency order
+#
+# 2 3/25/05 11:44a Sivagarn
+# Fixed a build issue related to wrong dependency
+#
+# 1 1/21/05 12:46p Sivagarn
+# Initial Checkin - Version 0.05
+#
+#**********************************************************************
+
+#<AMI_FHDR_START>
+#---------------------------------------------------------------------------
+# Name: CspLib.mak
+#
+# Description:
+# Make file for the CSP Library. CSP library contains all library
+# functions related to chipset and CPU. The main idea for this library is
+# to consolidate porting hooks related to various components
+# (like CSM, SMM etc) in respective chipset files say NB, SB, CPU etc.
+# This library can be built us a LIB file or as various FFS files.
+# The MACROS and library init functions mask the actual implementation
+# which is controlled by the SDL token
+#
+#---------------------------------------------------------------------------
+#<AMI_FHDR_END>
+
+all : AMICSPLib $(BUILD_DIR)\AMICSPLIBInc.H
+
+!IF "$(CORE_COMBINED_VERSION)"==""
+CORE_COMBINED_VERSION=0x40280
+!ENDIF
+
+!IF $(CORE_COMBINED_VERSION) >= 0x40280
+$(AMICSPLib) : $(BUILD_DIR)\AMICSPLIBInc.H AMICSPLib $(BUILD_DIR)\Fid.ffs AMICspLibPei AMICspLibDxe
+!ELSE
+$(AMICSPLib) : $(BUILD_DIR)\AMICSPLIBInc.H AMICSPLib AMICspLibPei AMICspLibDxe
+!ENDIF
+
+CSP_LIB_DIR = Core\CspLib
+
+AMICSPLib : $(BUILD_DIR)\AMICSPLib.mak AMICSPLibBin
+
+$(BUILD_DIR)\AMICspLib.mak : $(CSP_LIB_DIR)\CSPLib.cif $(CSP_LIB_CIF_FILES) $(CSP_LIB_DIR)\CspLib.mak $(BUILD_RULES)
+ $(CIF2MAK) $(CSP_LIB_DIR)\CSPLib.cif $(CIF2MAK_DEFAULTS) $(CSP_LIB_CIF_FILES)
+
+#---------------------------------------------------------------------------
+# Add Generic Functions to CSP Library
+#---------------------------------------------------------------------------
+
+AMICSPLibBin : $(BUILD_DIR)\CspLibGeneric.obj
+
+{$(CSP_LIB_DIR)}.c{$(BUILD_DIR)}.obj::
+ $(CC) $(CFLAGS) /D\"RUNTIME_SHADOW_RAM_WRITE_LIST=$(RuntimeShadowRamWrite)\" /I $(CSP_LIB_DIR) /Fo$(BUILD_DIR)\ $<
+
+$(BUILD_DIR)\CspLibGeneric.obj : $(CSP_LIB_DIR)\CspLibGeneric.c
+
+#---------------------------------------------------------------------------
+# Generate CSP Library
+#---------------------------------------------------------------------------
+$(BUILD_DIR)\AMICSPLIBInc.H : $(AMI_CSP_LIB_INCLUDE_FILES:+= )
+ $(ECHO) #include"$(BUILD_DIR)\token.h" > $@
+ $(ECHO) #include"$(CSP_LIB_DIR)\CspLibGeneric.h" >> $@
+ $(SILENT) for %%f in ($(**:"=)) do $(ECHO) #include"%%f" >> $@
+
+AMICSPLibBin : $(AMI_CSP_LIB_OBJS)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AMICSPLib.mak all\
+ NAME=AMICSPLib\
+ OBJECTS=\
+ TYPE=LIBRARY
+ $(MAKE) /$(MAKEFLAGS) BUILD_ROOT=$(BUILD_DIR) "EXT_OBJS=$(**:Build\=Build\IA32\)" PROJECT_DIR=$(PROJECT_DIR)\
+ /f $(BUILD_DIR)\AMICSPLib.mak all\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ NAME=AMICSPLib\
+ OBJECTS=\
+ TYPE=PEI_LIBRARY
+
+#---------------------------------------------------------------------------
+# Generate CSP Library PEI
+#---------------------------------------------------------------------------
+CORE_PEIBin : $(BUILD_DIR)\CspLibPei.lib
+
+$(BUILD_DIR)\CspLibPei.lib : $(BUILD_DIR)\AMICSPLib.mak AMICspLibPei
+
+CSP_LIB_PEI_OBJECTS =\
+$$(BUILD_DIR)\$(CSP_LIB_DIR)\CspLibPei.obj
+
+!IF $(CORE_COMBINED_VERSION) >= 0x40280
+
+$(BUILD_DIR)\Fid.ffs : $(BUILD_DIR)\AMICspLib.mak
+ $(MAKE) /$(MAKEFLAGS) EXT_OBJS= $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AMICspLib.mak bin\
+ NAME=Fid OBJECTS=$(BUILD_DIR)\$(CSP_LIB_DIR)\Fid.obj\
+ MAKEFILE=$(BUILD_DIR)\AMICspLib.mak \
+ TYPE=BINARY
+ $(MAKE) /f Core\FFS.mak \
+ BUILD_DIR=$(BUILD_DIR) \
+ GUID=3FD1D3A2-99F7-420b-BC69-8BB1D492A332 \
+ TYPE=EFI_FV_FILETYPE_FREEFORM \
+ FFSFILE=$@ COMPRESS=0 NAME=$(@B)\
+ RESOURCE=$(BUILD_DIR)\Fid.bin \
+ SECTION_GUID=2EBE0275-6458-4AF9-91ED-D3F4EDB100AA \
+
+!ELSE
+
+CSP_LIB_PEI_OBJECTS =\
+$(CSP_LIB_PEI_OBJECTS)\
+$$(BUILD_DIR)\$(CSP_LIB_DIR)\Fid.obj
+
+!ENDIF
+
+AMICspLibPei : $(AMIPEILIB)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AMICspLib.mak all\
+ NAME=CspLibPei\
+ MAKEFILE=$(BUILD_DIR)\AMICspLib.mak \
+ OBJECTS="$(CSP_LIB_PEI_OBJECTS)" \
+ TYPE=PEI_LIBRARY
+
+
+#---------------------------------------------------------------------------
+# Generate CSP Library DXE
+#---------------------------------------------------------------------------
+AMICspLibDxe :
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AMICspLib.mak all\
+ NAME=CspLibDxe\
+ MAKEFILE=$(BUILD_DIR)\AMICspLib.mak \
+ GUID=CD84562C-6864-40a3-A081-C8D35E82B920 \
+ OBJECTS=$(BUILD_DIR)\$(CSP_LIB_DIR)\CspLibDxe.obj \
+ DEPEX1=$(CSP_LIB_DIR)\CspLibDxe.DXS DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \
+ ENTRY_POINT=CspLibDxe_Init \
+ TYPE=BS_DRIVER \
+ COMPRESS=1
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/Core/CSPLib/CspLib.sdl b/Core/CSPLib/CspLib.sdl
new file mode 100644
index 0000000..cb5e5d4
--- /dev/null
+++ b/Core/CSPLib/CspLib.sdl
@@ -0,0 +1,107 @@
+TOKEN
+ Name = "CSPLIB_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable CSP Library support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "CSP_LIBRARY"
+ Value = "1"
+ Help = "Build as library"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "AMICSPLib"
+ Value = "$$(LIB_BUILD_DIR)\AmiCSPLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "CSP_LIB_MAJOR_VER"
+ Value = "00"
+ Help = "CSP Library Major Version Number.\ DO NOT CHANGE THIS VALUE"
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+End
+
+TOKEN
+ Name = "CSP_LIB_MINOR_VER"
+ Value = "17"
+ Help = "CSP Library Minor Version Number.\ DO NOT CHANGE THIS VALUE"
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Lock = Yes
+End
+
+TOKEN
+ Name = "BIOS_TAG"
+ Value = "$(PROJECT_TAG)$(PROJECT_MAJOR_VERSION)$(PROJECT_MINOR_VERSION)"
+ Help = "BIOS Tag inserted into Firmware ID structure.\9 characters. \5 characters of project tag followed by 3 characters of project version and terminating zero"
+ TokenType = Expression
+ TargetEQU = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FW_VERSION_GUID"
+ Value = "{0xb5c59087, 0xfeac, 0x4b41, {0x9d, 0x80, 0x79, 0xb, 0xa5, 0xaa, 0x7, 0xf}}"
+ Help = "FW Version GUID inserted into Firmware ID structure.\FW version has to be overridden for every project."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "GUID"
+End
+
+MODULE
+ Help = "Includes CSPLib.mak to Project"
+ File = "CspLib.mak"
+End
+
+ELINK
+ Name = "CSP_LIB_CIF_FILES"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\CspLibDxe.ffs"
+ Parent = "FV_MAIN"
+ Help = "CSP Library DXE Component"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "/I $(BUILD_DIR) "
+ Parent = "CFLAGS"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "CspLibPei_Init,"
+ Parent = "PeiCoreInitialize"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "RuntimeShadowRamWrite"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\fid.ffs"
+ Parent = "FV_BB"
+ Token = "CORE_COMBINED_VERSION" ">=" "0x40280"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Core/CSPLib/CspLibDxe.C b/Core/CSPLib/CspLibDxe.C
new file mode 100644
index 0000000..499cf55
--- /dev/null
+++ b/Core/CSPLib/CspLibDxe.C
@@ -0,0 +1,104 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibDxe.C 3 2/22/11 3:36p Artems $
+//
+// $Revision: 3 $
+//
+// $Date: 2/22/11 3:36p $
+//
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibDxe.C $
+//
+// 3 2/22/11 3:36p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 2 6/11/09 5:43p Robert
+// Comment updates for CHM and coding standard
+//
+// 1 1/21/05 12:46p Sivagarn
+// Initial Checkin - Version 0.05
+//
+//
+//*****************************************************************************
+
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: CspLibDxe.C
+//
+// Description: This file contains code for Generic Csp protocols such as
+// PCI table init etc
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+// Module specific Includes
+#include "Efi.h"
+#include "token.h"
+#include <AmiLib.h>
+
+#include "protocol\CspLibProtocols.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CspLibDxe_Init
+//
+// Description:
+// This function is the entry point for this DXE. This function installs
+// necessary Csp protocols
+//
+// Input:
+// EFI_HANDLE ImageHandle - Image handle
+// EFI_SYSTEM_TABLE SystemTable - Pointer to the system table
+//
+// Output:
+// Return Status currently always EFI_SUCCESS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS
+CspLibDxe_Init (
+IN EFI_HANDLE ImageHandle,
+IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+
+ return Status;
+
+}
+
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/CSPLib/CspLibDxe.Dxs b/Core/CSPLib/CspLibDxe.Dxs
new file mode 100644
index 0000000..0c58b73
--- /dev/null
+++ b/Core/CSPLib/CspLibDxe.Dxs
@@ -0,0 +1,67 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibDxe.Dxs 3 2/22/11 3:35p Artems $
+//
+// $Revision: 3 $
+//
+// $Date: 2/22/11 3:35p $
+//
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibDxe.Dxs $
+//
+// 3 2/22/11 3:35p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 2 6/11/09 5:43p Robert
+// Comment updates for CHM and coding standard
+//
+//
+//**********************************************************************
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: CspLibDxe.DXS
+//
+// Description: This file is the dependency file for the CspLib DXE
+// driver
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include <Protocol\Cpu.h>
+
+DEPENDENCY_START
+ EFI_CPU_ARCH_PROTOCOL_GUID
+DEPENDENCY_END
+
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//************************************************************************* \ No newline at end of file
diff --git a/Core/CSPLib/CspLibGeneric.C b/Core/CSPLib/CspLibGeneric.C
new file mode 100644
index 0000000..6b96877
--- /dev/null
+++ b/Core/CSPLib/CspLibGeneric.C
@@ -0,0 +1,399 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibGeneric.C 7 11/12/11 6:39p Artems $
+//
+// $Revision: 7 $
+//
+// $Date: 11/12/11 6:39p $
+//
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibGeneric.C $
+//
+// 7 11/12/11 6:39p Artems
+// Added functions for TopSwap functionality
+//
+// 6 2/22/11 3:33p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 5 3/31/10 11:31a Artems
+// Updated function help header
+//
+// 4 3/29/10 3:58p Artems
+// Fixed OemRuntimeShadowRamWrite function help header
+//
+// 3 3/25/10 3:07p Artems
+// EIP 33953: Added eLink infrastructure to support runtime shadow ram
+// writing
+//
+// 2 6/11/09 5:43p Robert
+// Comment updates for CHM and coding standard
+//
+// 1 10/13/07 11:27p Michaela
+// Initial Checkin
+//
+// 1 10/05/07 7:02a Michaela
+// Initial checkin.
+//
+//*****************************************************************************
+
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: CspLibGeneric.c
+//
+// Description: This file contains generic code to add functionality that can
+// be used by any module.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include <Token.h>
+#include "CspLibGeneric.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LocateMultiplePpi
+//
+// Description:
+// This function wraps the initialization and error checking of LocatePpi()
+// in a table, in order to reduce code size in functions that use several PPI.
+//
+// Input:
+// EFI_PEI_SERVICES **PeiServices - Instance of a pointer to the PeiServices pointer
+// UINT32 PpiTableSize - Size of argument table
+// PPI_LOCATE_STRUCT *Ppi - Table of arguments for LocatePpi()
+//
+// Output:
+// Pointers in PPI_LOCATE_STRUCT are updated
+// Status is returned with values defined by the LocatePpi function
+//
+// Note:
+// This function will use a Guid pointer or a Guid value defined locally
+// in the PPI_LOCATE_STRUCT of the caller.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS LocateMultiplePpi (
+ EFI_PEI_SERVICES **PeiServices,
+ UINT32 PpiTableSize,
+ PPI_LOCATE_STRUCT *Ppi
+)
+{
+ EFI_STATUS Status;
+ UINT32 i;
+ EFI_PEI_LOCATE_PPI Locate = (*PeiServices)->LocatePpi;
+
+ for (i = 0; i < PpiTableSize; i++) {
+ //-------------------------------------------
+ // locate the PPI (or) break on error
+ Status = Locate( PeiServices,
+ (Ppi[i].Guid.Data1 == 0)
+ ? Ppi[i].GuidPtr : &Ppi[i].Guid,
+ Ppi[i].Instance,
+ Ppi[i].Descriptor,
+ Ppi[i].Ptr );
+ if (EFI_ERROR(Status)){
+ break;
+ }
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LocateMultipleProtocol
+//
+// Description:
+// This function wraps the initialization and error checking of
+// LocateProtocol() in a table, in order to reduce code size in functions
+// that use several Protocol.
+//
+// Input:
+// EFI_BOOT_SERVICES *pBS - Instance of a pointer to the Boot Services Table
+// UINT32 ProtocolTableSize - Number of Protocols in the table
+// PROTOCOL_LOCATE_STRUCT *Protocol - Table of Parameters for LocateProtocol
+//
+// Output:
+// Pointers in PROTOCOL_LOCATE_STRUCT are updated
+// Status is returned with values defined by the LocateProtocol function
+//
+// Note:
+// This function will use a Guid pointer or a Guid value defined locally in
+// the PROTOCOL_LOCATE_STRUCT of the caller.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS LocateMultipleProtocol (
+ EFI_BOOT_SERVICES *pBS,
+ UINT32 ProtocolTableSize,
+ PROTOCOL_LOCATE_STRUCT *Protocol
+)
+{
+ EFI_STATUS Status;
+ UINT32 i;
+ EFI_LOCATE_PROTOCOL Locate = pBS->LocateProtocol;
+
+ for (i = 0; i < ProtocolTableSize; i++) {
+ //-------------------------------------------
+ // locate the PPI (or) break on error
+ Status = Locate((Protocol[i].Guid.Data1 == 0)
+ ? Protocol[i].GuidPtr
+ : &Protocol[i].Guid,
+ Protocol[i].Registration,
+ Protocol[i].Interface );
+ if (EFI_ERROR(Status)){
+ break;
+ }
+ }
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PeiWritePci
+//
+// Description:
+// This function writes a value to a PCI register using a PCI_CONTROL
+// structure to simplify the call.
+//
+// Input:
+// PEI_PCI_ARGS *Pci - control structure
+//
+// Output:
+// Status is returned with values defined in the PCI PPI Write function
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PeiWritePci (
+ PEI_PCI_ARGS *Pci
+)
+{
+ EFI_STATUS Status;
+ Status = Pci->Cfg->Write( Pci->PeiServices,
+ Pci->Cfg,
+ Pci->Width,
+ Pci->Address,
+ Pci->Value );
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PeiReadPci
+//
+// Description:
+// This function reads the value in a PCI Register using a PCI_CONTROL
+// structure to simplify the call.
+//
+// Input:
+// PEI_PCI_ARGS *Pci - control structure
+//
+// Output:
+// Pci->Value is updated with the value read from the PCI device
+// Status is returned with values defined in the PCI PPI Read function
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PeiReadPci (
+ PEI_PCI_ARGS *Pci
+)
+{
+ EFI_STATUS Status;
+ Status = Pci->Cfg->Read( Pci->PeiServices,
+ Pci->Cfg,
+ Pci->Width,
+ Pci->Address,
+ Pci->Value );
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RbReadPci
+//
+// Description:
+// This function reads the value(s) in a PCI Register using a RTBRG_PCI_ARGS
+// structure to simplify the call.
+//
+// Input:
+// RTBRG_PCI_ARGS *Arg - pointer to an instance of RTBRG_PCI_ARGS that contains parameters to the RootBrg PCI Read Function
+//
+// Output:
+// Arg->Buffer is filled with the data read from the PCI device
+// Return the status returned by the PCI Read funcntion of the Root Bridge protocol
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS RbReadPci (
+ RTBRG_PCI_ARGS *Arg
+)
+{
+ EFI_STATUS Status =
+ Arg->RtBrdg->Pci.Read( Arg->RtBrdg,
+ Arg->Width,
+ Arg->Address,
+ Arg->Count,
+ Arg->Buffer);
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RbWritePci
+//
+// Description:
+// This function writes the value(s) in a PCI Register using a RTBRG_PCI_ARGS
+// structure to simplify the call.
+//
+// Input:
+// RTBRG_PCI_ARGS *Arg - pointer to an instance of RTBRG_PCI_ARGS that contains parameters to the RootBrg PCI Read Function
+//
+// Output:
+// Return the status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS RbWritePci (
+ RTBRG_PCI_ARGS *Arg
+)
+{
+ EFI_STATUS Status =
+ Arg->RtBrdg->Pci.Write( Arg->RtBrdg,
+ Arg->Width,
+ Arg->Address,
+ Arg->Count,
+ Arg->Buffer);
+ return Status;
+}
+
+//************** Runtime Shadow Ram access support ****************************
+typedef VOID (RUNTIME_SHADOW_RAM_WRITE)(
+ IN BOOLEAN Enable
+);
+
+extern RUNTIME_SHADOW_RAM_WRITE RUNTIME_SHADOW_RAM_WRITE_LIST EndOfList;
+RUNTIME_SHADOW_RAM_WRITE* RuntimeShadowRamWriteList[] = {RUNTIME_SHADOW_RAM_WRITE_LIST NULL};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OemRuntimeShadowRamWrite
+//
+// Description: This function enables or disables runtime writing to shadow RAM
+// (E000-F000 segment)
+//
+//
+// Input:
+// IN BOOLEAN Enable - if TRUE - enable writing to shadow region
+// if FALSE - disable writing to shadow region
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OemRuntimeShadowRamWrite(
+ IN BOOLEAN Enable
+)
+{
+ UINTN i;
+
+ for (i = 0; RuntimeShadowRamWriteList[i]; i++)
+ RuntimeShadowRamWriteList[i](Enable);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsTopSwapOn
+//
+// Description: This function checks if TopSwap (A16 address line inversion)
+// is on
+//
+//
+// Input:
+// None
+//
+// Output:
+// TRUE - TopSwap is ON
+// FALSE - TopSwap is OFF
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsTopSwapOn(
+ VOID
+)
+{
+ volatile UINT8* Address8;
+
+ Address8 = (UINT8 *)(SB_RCBA + SB_BACKED_UP_CONTROL_REGISTER);
+
+ return ((*Address8) & 1) ? TRUE : FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetTopSwap
+//
+// Description: This function sets TopSwap (A16 address line inversion) ON or OFF
+//
+// Input:
+// BOOLEAN On - if TRUE, set TopSwap to ON, if FALSE - set to OFF
+//
+// Output:
+// None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetTopSwap(
+ IN BOOLEAN On
+)
+{
+ volatile UINT8* Address8;
+
+ Address8 = (UINT8 *)(SB_RCBA + SB_BACKED_UP_CONTROL_REGISTER);
+
+ if (On) {
+ *Address8 |= 1;
+ } else {
+ *Address8 &= 0xFE;
+ }
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/CSPLib/CspLibGeneric.h b/Core/CSPLib/CspLibGeneric.h
new file mode 100644
index 0000000..0c24d1f
--- /dev/null
+++ b/Core/CSPLib/CspLibGeneric.h
@@ -0,0 +1,444 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibGeneric.h 6 11/12/11 6:39p Artems $
+//
+// $Revision: 6 $
+//
+// $Date: 11/12/11 6:39p $
+//
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibGeneric.h $
+//
+// 6 11/12/11 6:39p Artems
+// Added functions for TopSwap functionality
+//
+// 5 7/14/11 3:19p Artems
+// EIP 64106: Updated source to be UEFI 2.3.1 and PI 1.2 compliant
+//
+// 4 2/22/11 3:31p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 3 3/25/10 3:08p Artems
+// EIP 33953: Added eLink infrastructure to support runtime shadow ram
+// writing
+//
+// 2 6/11/09 5:43p Robert
+// Comment updates for CHM and coding standard
+//
+// 1 10/13/07 11:29p Michaela
+// Initial Checkin
+//
+//
+//*****************************************************************************
+
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: CspLibGeneric.h
+//
+// Description: This file contains generic code to add functionality that can
+// be used by any module.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef __CSP_LIB_GENERIC__H__
+#define __CSP_LIB_GENERIC__H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <efi.h>
+#include <pei.h>
+#include <Protocol\PciRootBridgeIo.h>
+
+#ifndef GUID_ZERO
+#define GUID_ZERO \
+{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
+GUID_VARIABLE_DECLARATION(GuidZero, GUID_ZERO);
+#endif
+
+
+//<AMI_MHDR_START>
+//----------------------------------------------------------------------------
+// Name: AMI_TRACE
+//
+// Description:
+// This general-purpose, phase-independent macro allows debugging
+// messages in code that is shared between PEI and DXE phases.
+//
+// Input:
+// Identical to TRACE (Type must be AMI_TRACE_ALWAYS)
+//
+// Notes:
+// For PEI phase, this macro assumes the identifier PeiServices is
+// defined.
+//
+// The usage of this macro is identical to TRACE with the exception that
+// the type must always be AMI_TRACE_ALWAYS:
+//
+// AMI_TRACE((AMI_TRACE_ALWAYS, "Hello World\n"));
+//
+//----------------------------------------------------------------------------
+//<AMI_MHDR_END>
+
+#if ( defined(TRACE) )
+ #define AMI_TRACE(args) TRACE(args)
+ #define AMI_TRACE_ALWAYS TRACE_ALWAYS
+#elif ( defined(PEI_TRACE) )
+ //------------------------------------------------------------------------
+ // Generate a compiler message to help identify the build error if
+ // PeiServices is not defined in the calling function.
+ //------------------------------------------------------------------------
+ #pragma message("AMI_TRACE requires identifier definition: EFI_PEI_SERVICES **PeiServices")
+ #define AMI_TRACE(args) PEI_TRACE(args)
+ #define AMI_TRACE_ALWAYS TRACE_ALWAYS,PeiServices
+#else
+ #define AMI_TRACE(args)
+ #define AMI_TRACE_ALWAYS
+#endif
+
+
+//<AMI_MHDR_START>
+//----------------------------------------------------------------------------
+// Name: ABORT_ERROR
+//
+// Description:
+// This phase-independent macro can be used to force premature
+// return from a function on error, displaying a message if possible and
+// returning the EFI_STATUS value of the error. (For compatibility,
+// ABORT_CALL is also defined as a synonym for this macro.)
+//
+// Input:
+// arg - type must be EFI_STATUS
+//
+// Notes:
+// Use the macro with a function call to save screen/source file
+// real estate:
+//
+// ABORT_ERROR(FunctionCall(...));
+//
+// The macro is replaced with the following:
+//
+// {
+// EFI_STATUS Status = FunctionCall(...);
+// if (EFI_ERROR(Status)){
+// ...message with file name, line number and function name...
+// return Status;
+// }
+// }
+//
+//----------------------------------------------------------------------------
+//<AMI_MHDR_END>
+
+#define ABORT_ERROR(arg) { \
+ EFI_STATUS Status = arg; \
+ if ( EFI_ERROR( Status ) ) \
+ { \
+ AMI_TRACE((AMI_TRACE_ALWAYS, \
+ "\n\nABORT Error in %s \nLine %i: %s\n\n\n",__FILE__, __LINE__, #arg)); \
+ return Status; \
+ } }
+#ifndef ABORT_CALL
+#define ABORT_CALL(arg) ABORT_ERROR(arg)
+#endif
+
+
+//<AMI_MHDR_START>
+//----------------------------------------------------------------------------
+// Name: ABORT_ERROR_STATUS
+//
+// Description:
+// This phase-independent macro can be used to force premature
+// return from a function on error, displaying a message if possible and
+// returning the caller-specified value in the event of an error.
+// (For compatibility, ABORT_CALL_STATUS is also defined as a
+// synonym for this macro.)
+//
+// Input:
+// status - value to return (no type constraint)
+// arg - type must be EFI_STATUS
+//
+// Notes:
+// Use the macro with a function call to save screen/source file
+// real estate (note: the return value is discarded):
+//
+// ABORT_ERROR_STATUS(MyErrorValue, FunctionCall(...));
+//
+// The macro is replaced with the following:
+//
+// {
+// if (EFI_ERROR( FunctionCall(...) ) ){
+// ...message with file name, line number and function name...
+// return MyErrorValue;
+// }
+// }
+//
+//----------------------------------------------------------------------------
+//<AMI_MHDR_END>
+
+#define ABORT_ERROR_STATUS(retval, arg) { \
+ if ( EFI_ERROR(arg) ) \
+ { \
+ AMI_TRACE((AMI_TRACE_ALWAYS, \
+ "\n\nABORT Error in %s \nLine %i: %s\n\n\n",__FILE__, __LINE__, #arg)); \
+ return (retval); \
+ } }
+#ifndef ABORT_CALL_STATUS
+#define ABORT_CALL_STATUS(retval, arg) ABORT_ERROR_STATUS(retval, arg)
+#endif
+
+
+//<AMI_MHDR_START>
+//----------------------------------------------------------------------------
+// Name: STOP_ERROR
+//
+// Description:
+// This phase-independent macro can be used to force an infinite loop
+// on error, ensuring execution does not continue past the error and
+// easing the burden of locating the source of the error. A message is
+// displayed if possible. (For compatibility, ASSERT_CALL is
+// also defined as a synonym for this macro.)
+//
+// Input:
+// arg - type must be EFI_STATUS
+//
+// Notes:
+// Use the macro with a function call to save screen/source file
+// real estate (note: the return value is discarded):
+//
+// STOP_ERROR(FunctionCall(...));
+//
+// The macro is replaced with the following:
+//
+// {
+// if (EFI_ERROR(FunctionCall(...))){
+// ...message with file name, line number and function name...
+// EFI_DEADLOOP();
+// }
+// }
+//
+//----------------------------------------------------------------------------
+//<AMI_MHDR_END>
+
+#define STOP_ERROR(arg) { \
+ if ( EFI_ERROR( arg ) ) { \
+ AMI_TRACE((AMI_TRACE_ALWAYS, \
+ "\n\nSTOP Error in %s \nLine %i: %s\n",__FILE__, __LINE__,#arg)); \
+ EFI_DEADLOOP(); \
+ } }
+#ifndef ASSERT_CALL
+#define ASSERT_CALL(arg) STOP_ERROR(arg)
+#endif
+
+
+//----------------------------------------------------------------------------
+// LocateMultiplePpi types/declarations
+
+//<AMI_THDR_START>
+//------------------------------------------------------------------
+//
+// Name: PPI_LOCATE_STRUCT
+//
+// Fields: Type ParameterName Description
+//------------------------------------------------------------------
+// EFI_GUID Guid - GUID_ZERO or value of Guid
+// EFI_GUID *GuidPtr - NULL or pointer to Guid
+// UINTN Instance - Instance Number to discover
+// EFI_PEI_PPI_DESCRIPTOR **Descriptor - Pointer to a Pointer to reference the found descriptor. If not NULL, returns a pointer to the descriptor (includes flags, etc)
+// VOID **Ptr - Pointer to be updated with an instance of a pointer to a pointer of the PPI being located
+//
+// Description:
+// This data structure contains the information that is used to
+// make a call to LocatePpi and return the needed pointers
+//
+// Notes:
+//
+//------------------------------------------------------------------
+//<AMI_THDR_END>
+typedef struct {
+ EFI_GUID Guid; // GUID_ZERO or value of Guid
+ EFI_GUID *GuidPtr; // NULL or pointer to Guid
+ UINTN Instance;
+ EFI_PEI_PPI_DESCRIPTOR **Descriptor;
+ VOID **Ptr;
+} PPI_LOCATE_STRUCT;
+
+EFI_STATUS LocateMultiplePpi (
+ EFI_PEI_SERVICES **PeiServices,
+ UINT32 PpiTableSize,
+ PPI_LOCATE_STRUCT *Ppi
+);
+
+
+//----------------------------------------------------------------------------
+// LocateMultipleProtocol types/declarations
+
+//<AMI_THDR_START>
+//------------------------------------------------------------------
+//
+// Name: PROTOCOL_LOCATE_STRUCT
+//
+// Fields: Type ParameterName Description
+//------------------------------------------------------------------
+// EFI_GUID Guid - GUID_ZERO or value of Guid
+// EFI_GUID *GuidPtr - NULL or pointer to Guid
+// VOID *Registration - Optional Registration Key returned from RegisterProtocolNotify()
+// VOID **Interface - Pointer to be updated with an instance of a pointer to a pointer of the Protocol being located
+//
+// Description:
+// This data structure contains the information that is used to
+// make a call to LocateProtocol and return the needed pointers
+//
+// Notes:
+//
+//------------------------------------------------------------------
+//<AMI_THDR_END>
+typedef struct {
+ EFI_GUID Guid; // GUID_ZERO or value of Guid
+ EFI_GUID *GuidPtr; // NULL or pointer to Guid
+ VOID *Registration;
+ VOID **Interface;
+} PROTOCOL_LOCATE_STRUCT;
+
+EFI_STATUS LocateMultipleProtocol (
+ EFI_BOOT_SERVICES *pBS,
+ UINT32 ProtocolTableSize,
+ PROTOCOL_LOCATE_STRUCT *Protocol
+);
+
+
+//----------------------------------------------------------------------------
+// PEI PCI Access related types/declarations
+
+//<AMI_THDR_START>
+//------------------------------------------------------------------
+//
+// Name: PEI_PCI_ARGS
+//
+// Fields: Type ParameterName Description
+//------------------------------------------------------------------
+// EFI_PEI_SERVICES **PeiServices - instance of the PEI Services Table
+// EFI_PEI_PCI_CFG_PPI *Cfg - OPTIONAL Pointer to an Instance of the PciCfg PPI
+// EFI_PEI_PCI_CFG_PPI_WIDTH Width - Width of the data to be accessed in the PCI space
+// UINT32 Address - (B/D/F/R) PCI address of the device to read from
+// VOID *Value - Buffer to store Data to Write or Data that is read
+//
+// Description:
+// This data structure contains the information that is used to
+// read or write to PCI Devices using the PEI PciCfg PPI
+//
+// Notes:
+//
+//------------------------------------------------------------------
+//<AMI_THDR_END>
+typedef struct {
+ EFI_PEI_SERVICES **PeiServices;
+ EFI_PEI_PCI_CFG2_PPI *Cfg;
+ EFI_PEI_PCI_CFG_PPI_WIDTH Width;
+ UINT32 Address; // PEI phase uses 32-bit addresses
+ VOID *Value;
+} PEI_PCI_ARGS;
+
+EFI_STATUS
+PeiWritePci (
+ PEI_PCI_ARGS *Pci
+);
+
+EFI_STATUS
+PeiReadPci(
+ PEI_PCI_ARGS *Pci
+);
+
+
+//----------------------------------------------------------------------------
+// DXE PCI Access related related types/declarations
+
+//<AMI_THDR_START>
+//------------------------------------------------------------------
+//
+// Name: RTBRG_PCI_ARGS
+//
+// Fields: Type ParameterName Description
+//------------------------------------------------------------------
+// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RtBrdg - Pointer to an instance of the DXE PCI Root Bridge Protocol
+// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width - Width of the data to read from or write to the PCI Device
+// UINT64 Address - PCI Address of the Device to read from or write to
+// UINTN Count - Number of times to repeat the Read or write command
+// VOID *Buffer - Buffer to store Data to Write or Data that is read
+//
+// Description:
+// This data structure contains the information that is used to
+// read or write to PCI Devices using the DXE PCI Root Bridge Protocol
+//
+// Notes:
+//
+//------------------------------------------------------------------
+//<AMI_THDR_END>
+typedef struct {
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RtBrdg;
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width;
+ IN UINT64 Address;
+ IN UINTN Count;
+ IN OUT VOID *Buffer;
+} RTBRG_PCI_ARGS;
+
+EFI_STATUS RbReadPci (
+ RTBRG_PCI_ARGS *Arg
+);
+
+EFI_STATUS RbWritePci (
+ RTBRG_PCI_ARGS *Arg
+);
+
+VOID OemRuntimeShadowRamWrite(
+ IN BOOLEAN Enable
+);
+
+
+#define SB_BACKED_UP_CONTROL_REGISTER 0x3414
+
+BOOLEAN IsTopSwapOn(
+ VOID
+);
+
+VOID SetTopSwap(
+ IN BOOLEAN On
+);
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//************************************************************************* \ No newline at end of file
diff --git a/Core/CSPLib/CspLibPei.C b/Core/CSPLib/CspLibPei.C
new file mode 100644
index 0000000..50a83a1
--- /dev/null
+++ b/Core/CSPLib/CspLibPei.C
@@ -0,0 +1,329 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibPei.C 17 7/14/11 2:44p Artems $
+//
+// $Revision: 17 $
+//
+// $Date: 7/14/11 2:44p $
+//
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/CspLibPei.C $
+//
+// 17 7/14/11 2:44p Artems
+// EIP 64106: Updated source to be UEFI 2.3.1 and PI 1.2 compliant
+//
+// 16 3/23/11 1:02p Artems
+// Bug fix - added backward compatibility with Core 4.6.4.1
+//
+// 15 2/22/11 3:48p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 1 2/02/11 5:17p Artems
+//
+// 14 5/07/10 10:09a Artems
+// Fixed bug that causes build error when use Core 4.6.4.0
+//
+// 13 5/06/10 12:22p Artems
+// EIP 38241 - $FID signature is absent
+//
+// 12 8/14/09 10:47a Robert
+// Added FID.asm to the component for compliance with AMI Utility
+// specification
+//
+// 11 6/11/09 5:43p Robert
+// Comment updates for CHM and coding standard
+//
+// 10 10/13/07 11:49p Michaela
+// added PciTableInit2 with a PCI access width parameter to support
+// PCI initialization tables for various access widths
+//
+// 9 2/16/07 6:13p Felixp
+// Better handling of Firmware ID structure:
+// 1. FW_VERSION_GUID and BIOS Tag come from SDL tokens.
+// 2. Core/Project versions properly reported
+// 3. CSM version removed
+//
+// 5 6/06/05 3:20p Felixp
+// updated to match PEI CIS 0.91 (CpuIo and PciCfg usage model changed)
+//
+// 4 4/08/05 11:39a Sivagarn
+// Included FID table
+//
+// 3 2/15/05 12:29p Sivagarn
+// Optimized the register programming call
+//
+// 1 1/21/05 12:46p Sivagarn
+// Initial Checkin - Version 0.05
+//
+//*****************************************************************************
+
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: CspLibPei.C
+//
+// Description:
+// This file contains code for Generic CSP Library PEI functions. The
+// functions include PCI table update etc.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+//============================================================================
+// Module specific Includes
+#include <token.h>
+#include <Efi.h>
+#include <Pei.h>
+#include <StatusCodes.h>
+#include <AmiLib.h>
+#include <AmiPeiLib.h>
+#include <PPI\CspLibPpi.h>
+#include <PPI\PCICfg.h>
+
+
+
+//============================================================================
+// GUID Definitions
+EFI_GUID gPeiPCITableInitPCIGUID = AMI_PEI_PCI_TABLE_INIT_PPI_GUID;
+
+//============================================================================
+
+
+#if CORE_REVISION <= 3
+#include "ppi\FwVersion.h"
+extern FW_VERSION FwVersionData;
+FW_VERSION *Version = &FwVersionData;
+#endif //#if CORE_REVISION <= 3
+
+#ifndef PI_SPECIFICATION_VERSION //old Core
+
+EFI_STATUS PciCfgModify(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits)
+{
+ if((*PeiServices)->PciCfg==NULL)
+ return EFI_NOT_AVAILABLE_YET;
+
+ return (*PeiServices)->PciCfg->Modify(
+ (EFI_PEI_SERVICES**)PeiServices,
+ (*PeiServices)->PciCfg,
+ Width, Address,
+ SetBits, ClearBits);
+}
+#endif
+
+
+EFI_STATUS PciTableInit (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN AMI_PEI_PCI_TABLE_INIT_PPI *This,
+ IN EFI_PEI_PCI_CFG2_PPI *PciCfg,
+ IN UINT64 Address,
+ IN AMI_PEI_PCI_INIT_TABLE_STRUCT *PCIInitTable,
+ IN UINT16 wSize
+);
+
+EFI_STATUS PciTableInit2 (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN AMI_PEI_PCI_TABLE_INIT_PPI *This,
+ IN EFI_PEI_PCI_CFG2_PPI *PciCfg, // OPTIONAL
+ IN UINT64 CfgAddress,
+ IN AMI_PEI_PCI_INIT_TABLE_STRUCT2 *PciInitTable,
+ IN UINT16 TableEntries,
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH AccessWidth
+);
+
+
+// PPI interface definition
+AMI_PEI_PCI_TABLE_INIT_PPI mPciTableInitPpi =
+{
+ PciTableInit,
+ PciTableInit2,
+};
+
+static EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gPeiPCITableInitPCIGUID,
+ &mPciTableInitPpi};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PciTableInit
+//
+// Description:
+// This function programs the PCI device with the values provided
+// in the init table provided
+//
+// Input:
+// EFI_PEI_SERVICES **PeiServices - Pointer to the PEI Core data Structure
+// AMI_PEI_PCI_TABLE_INIT_PPI *This - Pointer to an instance of the AMI PEI PCI TABLE INIT PPI
+// EFI_PEI_PCI_CFG_PPI *PciCfg - Optional pointer to an instance of the PciCfg PPI
+// UINT64 Address - PCI address of the register to write to (Bus/Dev/Func/Reg)
+// AMI_PEI_PCI_INIT_TABLE_STRUCT *PCIInitTable - Table with register number, set and clear bits
+// UINT16 wSize - Table length (multiples of structure)
+//
+// Output:
+// Always returns EFI_SUCCESS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PciTableInit (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN AMI_PEI_PCI_TABLE_INIT_PPI *This,
+ IN EFI_PEI_PCI_CFG2_PPI *PciCfg,
+ IN UINT64 Address,
+ IN AMI_PEI_PCI_INIT_TABLE_STRUCT *PCIInitTable,
+ IN UINT16 wSize)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN Index;
+ UINT64 LocalAddr;
+
+
+ if ((! wSize) || (!PCIInitTable))
+ return Status;
+
+ // Take data defined in the PCIInitTable and program the PCI devices
+ // as ported
+ for (Index = 0; Index < wSize; Index ++) {
+ LocalAddr = Address + PCIInitTable[Index].bRegIndex;
+
+ PciCfgModify( PeiServices,
+ EfiPeiPciCfgWidthUint8,
+ LocalAddr,
+ PCIInitTable[Index].bORMask,
+ ~PCIInitTable[Index].bANDMask );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PciTableInit2
+//
+// Description:
+// This function is identical to PciTableInit with the addition of an extra
+// parameter to specify PCI access width.
+//
+// Input:
+// EFI_PEI_SERVICES **PeiServices - Pointer to the PEI Core data Structure
+// AMI_PEI_PCI_TABLE_INIT_PPI *This - Pointer to an instance of the AMI PEI PCI TABLE INIT PPI
+// EFI_PEI_PCI_CFG_PPI *PciCfg - Optional pointer to an instance of the PciCfg PPI
+// UINT64 CfgAddress - PCI address of the register to write to (Bus/Dev/Func/Reg)
+// AMI_PEI_PCI_INIT_TABLE_STRUCT2 *PCIInitTable - Table with register number, set and clear bits
+// UINT16 TableEntries - Table length (multiples of structure)
+// EFI_PEI_PCI_CFG_PPI_WIDTH AccessWidth - Register-level access width
+//
+// Output:
+// Always returns EFI_SUCCESS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PciTableInit2 (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN AMI_PEI_PCI_TABLE_INIT_PPI *This,
+ IN EFI_PEI_PCI_CFG2_PPI *PciCfg, // OPTIONAL
+ IN UINT64 CfgAddress,
+ IN AMI_PEI_PCI_INIT_TABLE_STRUCT2 *PciInitTable,
+ IN UINT16 TableEntries,
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH AccessWidth)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN Index;
+ UINT64 LocalAddr;
+
+
+ if ((! TableEntries) || (!PciInitTable))
+ return Status;
+
+ // Take data defined in the PCIInitTable and program the PCI devices
+ // as ported
+ for (Index = 0;
+ Index < TableEntries && !EFI_ERROR(Status);
+ Index ++)
+ {
+ LocalAddr = CfgAddress + PciInitTable[Index].bRegIndex;
+
+ Status = PciCfgModify( PeiServices,
+ AccessWidth,
+ LocalAddr,
+ PciInitTable[Index].bORMask,
+ PciInitTable[Index].bANDMask );
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CspLibPei_Init
+//
+// Description:
+// This function is the entry point for this PEI. This function initializes
+// installs the CSP PPI
+//
+// Input:
+// FfsHeader Pointer to the FFS file header
+// PeiServices Pointer to the PEI services table
+//
+// Output:
+// Return Status based on errors that are returned by the InstallPpi function
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS CspLibPei_Init (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices)
+{
+ EFI_STATUS Status;
+
+ // Install the NB Init Policy PPI
+ Status = (*PeiServices)->InstallPpi(PeiServices, &mPpiList[0]);
+#ifdef EFI_DEBUG
+ if (Status) {
+ PEI_TRACE((TRACE_PEI_CHIPSET, PeiServices, "CspLibPei_Init Return Code : %r\n", Status));
+ }
+#endif
+ return Status;
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+
diff --git a/Core/CSPLib/FID.c b/Core/CSPLib/FID.c
new file mode 100644
index 0000000..8b33f92
--- /dev/null
+++ b/Core/CSPLib/FID.c
@@ -0,0 +1,108 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//**********************************************************************
+//
+// $Header: /Alaska/BIN/Chipset/Template/CSPLibrary/FID.c 6 2/22/11 3:28p Artems $
+//
+// $Revision: 6 $
+//
+// $Date: 2/22/11 3:28p $
+//
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Chipset/Template/CSPLibrary/FID.c $
+//
+// 6 2/22/11 3:28p Artems
+// EIP 51548 - Added AMI copyright headers, replaced TABs with spaces
+//
+// 5 12/17/10 4:42p Artems
+// Added OEM activation key support
+//
+// 4 5/21/10 4:29p Artems
+// Changed to version 3 as per Utility specification
+//
+// 3 4/05/10 6:15p Artems
+// Added Core 4.6.3 backward compatibility fix
+//
+// 2 12/03/09 12:09p Robert
+// updated comments and file header information
+//
+//
+//*****************************************************************************
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: FID.C
+//
+// Description:
+// This file the Firmware Version Data Structure definition
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+// Module specific Includes
+#include "Pei.h"
+#include "token.h"
+#include <timestamp.h>
+#include <AmiLib.h>
+#include <Ppi\FwVersion.h>
+
+#define THREE_CHAR_ARRAY(x) {(x)/10+'0',(x)%10+'0',0}
+
+FW_VERSION FwVersionData = {
+ "$FID", //$FID signature of the FW VERSION STRUCTURE
+ 0x04, //Version 4
+ sizeof(FW_VERSION), //Size of this structure
+ CONVERT_TO_STRING(BIOS_TAG), //8 character BIOS Tag, Plus NULL Cahracter at the end
+ FW_VERSION_GUID, //FW Version GUID
+ THREE_CHAR_ARRAY(CORE_MAJOR_VERSION), //Core Major Version from BIOS Parameters
+ THREE_CHAR_ARRAY(CORE_MINOR_VERSION), //Core Minor Version from BIOS Parameters
+ THREE_CHAR_ARRAY(PROJECT_MAJOR_VERSION), //Project Major Version from BIOS Parameters
+ THREE_CHAR_ARRAY(PROJECT_MINOR_VERSION), //Project Minor Version from BIOS Parameters
+ FOUR_DIGIT_YEAR_INT,
+ TWO_DIGIT_MONTH_INT,
+ TWO_DIGIT_DAY_INT,
+ TWO_DIGIT_HOUR_INT,
+ TWO_DIGIT_MINUTE_INT,
+ TWO_DIGIT_SECOND_INT,
+ 0xffff,
+ CONVERT_TO_STRING(T_ACPI_OEM_ID),
+ CONVERT_TO_STRING(T_ACPI_OEM_TBL_ID),
+ 49,
+ {
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+ }
+};
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//************************************************************************* \ No newline at end of file